Class: Crm::Reports::SmartServicesController

Inherits:
CrmController
  • Object
show all
Includes:
Controllers::ReportCommandFlashable
Defined in:
app/controllers/crm/reports/smart_services_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/crm/reports/smart_services_controller.rb', line 6

def show
  @report_command = ::Report::SmartServices::SmartServicesCommand.new(smart_services_command_params)
  @result = @report_command.execute

  flash_report_command_errors
  respond_to do |format|
    format.html
    format.turbo_stream
    format.csv do
      send_data @report_command.to_smart_services_by_report_grouping_csv, filename: "smart-services-sales-by-report-grouping-#{Date.current}.csv" if params[:report] == 'by_report_grouping'
      send_data @report_command.to_smart_services_by_rep_csv, filename: "smart-services-sales-by-rep-#{Date.current}.csv" if params[:report] == 'by_rep'
    end
  end
end