class Pdf::Service::StudentRecordService < Pdf::NewApplicationService
  def initialize(student, logs)
    @student = student
    @logs = logs
    @hours = @logs.sum(&:hours)
  end

  private
    def header
      content = ActionController::Base.new.render_to_string(
        partial: 'pdf/headers/school_info.html.haml',
        locals: {
          school: @student.school,
          side_content_partial: 'pdf/service/student_record_header.html.haml',
          side_content: {
            full_name: @student.full_name,
            hours: @hours
          }
        }
      )
      { content: content, spacing: 25 }
    end

    def body
      ActionController::Base.new.render_to_string(
        partial: 'pdf/service/student_record.html.haml',
        locals: { student: @student, logs: @logs, hours: @hours }
      )
    end
end
