class Pdf::Service::FamilyRecordService < Pdf::NewApplicationService
  def initialize(family, logs)
    @family = family
    @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: @family.school,
          side_content_partial: 'pdf/service/family_record_header.html.haml',
          side_content: {
            family_name: @family.name,
            hours: @hours
          }
        }
      )
      { content: content, spacing: 25 }
    end

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