module ExcelReports
  module VideoReports
    module DiscoveryProductionElementsLogs
      class ProductIntegrationSheet < ::ExcelReports::Worksheet
        def title
          "Product Integration"
        end

        def fill_content(sheet)
          sheet.add_row ["Product Integration / Trade-Out Log"]
          sheet.add_row [instructions]
          sheet.add_row
          sheet.add_row table_headers
          sheet.add_row table_headers2
        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", Styles::BOLD, { sz: 14 }
          sheet.add_style "A2", Styles::BOLD, { sz: 12 }
          sheet.add_style "A4:J4", Styles::TABLE_HEADER
          sheet.add_style "A5:J5", Styles::TABLE_HEADER
          sheet.add_style "A4:J4", Styles::WRAP_TEXT
          sheet.add_style "A5:J5", Styles::WRAP_TEXT
          sheet.add_style "I4:J4", Styles::BG_YELLOW
        end

        private

        def instructions
          "All contract agreements with companies providing trade-outs must be uploaded to the Producer's Portal"
        end

        def table_headers
          ["EPISODE #\nTitle\n(if applicable)", "PRODUCT ITEM(S)\n(ex: free airfare)", "COMPANY PROVIDING TRADE-OUT\n(ex: United Airlines)", "PRODUCT VALUE", "BUDGETED VALUE\nItem & Category in production budget", "OBLIGATIONS\n(ex: \"thanks to\" credit)", "AGREEMENT WITH COMPANY EXECUTION DATE", "DATE APPROVED BY DCI", "SELECT \"A\" OR \"B\"", ""]
        end

        def table_headers2
          ["", "", "", "", "", "", "", "", "A\nTrade will be savings to program List amount", "B\nTrade will be added value to program List amount"]
        end

        def column_widths
          [15, 15, 15, 15, 15, 15, 15, 15, 15, 15]
        end

        def cells_to_merge
          %w[ A4:A5 B4:B5 C4:C5 D4:D5 E4:E5 F4:F5 G4:G5 H4:H5 I4:J4 ]
        end
      end
    end
  end
end
