module ExcelReports
  module VideoReports
    module DiscoveryProductionElementsLogs
      class MediaRightsCertificationSheet < ::ExcelReports::Worksheet
        def title
          "Media Rights Certification"
        end

        def fill_content(sheet)
          sheet.add_row ["MEDIA RIGHTS CERTIFICATION  (Required for final payment)", "", "", "", "", "", "", "", "", ""]
          sheet.add_row ["By uploading this file I certify that:"]
          sheet.add_row ["1) Check one"]
          sheet.add_row ["", "Rights waivers have been submitted and approved by DCL for all Program elements with any restriction or limitation not permitted by the Programming Agreement (including, without limitation, all music, footage, photographic stills, graphics, talent, and releases)."]
          sheet.add_row ["", "OR"]
          sheet.add_row ["", "No rights waivers are required because all the Program elements are fully cleared or subject only to the restrictions or limitations permitted by the Programming Agreement."]
          sheet.add_row ["AND"]
          sheet.add_row ["2) Check one\n\nIn the event the Programming Agreement permits that third-party stills or stock footage can be licensed with certain term or media restrictions (e.g., 10 year license or no theatrical rights or US standard television rights), it is further certified that this Program (check one):"]
          sheet.add_row ["", "Does contain third-party stills or stock footage secured subject to those restrictions."]
          sheet.add_row ["", "OR"]
          sheet.add_row ["", "Does not contain third-party stills or stock footage secured subject to those restrictions."]
          sheet.add_row ["", "OR"]
          sheet.add_row ["", "This Program does NOT contain any third-party stills or stock footage."]
          sheet.add_row ["Submitted By _____________________________"]
          sheet.add_row ["Uploading this document to the Producer’s Portal constitutes electronic signature"]
        end

        def format(sheet)
          sheet.column_widths *column_widths
          cells_to_merge.each { |cell| sheet.merge_cells cell }
        end

        def style(sheet)
          sheet.add_style "A1", { sz: 18 }, Styles::BOLD, Styles::UNDERLINE
          sheet.add_style "A2", { sz: 16 }, Styles::BOLD
          sheet.add_style "A2", { sz: 12 }, Styles::BOLD
          sheet.add_style "A7", { sz: 12 }, Styles::BOLD
          sheet.add_style "A14", { sz: 12 }, Styles::BOLD
          sheet.add_style "A15", { sz: 12 }, Styles::ITALIC, Styles::BOLD, Styles::COLOR_RED
          sheet.add_style "B5", Styles::COLOR_BLUE
          sheet.add_style "B10", Styles::COLOR_BLUE
          sheet.add_style "B12", Styles::COLOR_BLUE
          sheet.add_style "A8", Styles::WRAP_TEXT
          sheet.add_style "B4", Styles::WRAP_TEXT
          sheet.add_style "B6", Styles::WRAP_TEXT
        end

        private

        def column_widths
          [10, 20, 10, 10, 10, 10, 10, 10, 10, 10]
        end

        def cells_to_merge
          %w[
          A1:J1 A2:J2 A3:J3 B4:J4 B5:J5 B6:J6 A8:J8 B9:J9 B10:J10 B11:J11 B12:J12 B13:J13 A14:J14 A15:J15
          ]
        end
      end
    end
  end
end
