6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/crm/reports/kpi_call_controller.rb', line 6
def show
authorize! :read, CallLog
command_attrs = kpi_call_command_params
unless helpers.user_has_role?(%w[admin sales_director sales_manager accounting_manager])
command_attrs[:employee_ids] = [current_user.id.to_s] if command_attrs.present?
end
@report_command = ::Report::KpiCall::KpiCallCommand.new(command_attrs)
@results = @report_command.execute
return render partial: 'mini_view', layout: false if request.['Turbo-Frame'].present?
flash_report_command_errors
respond_to do |format|
format.html do
render partial: 'mini_view', layout: false if request.xhr?
end
format.turbo_stream
format.csv { send_data @report_command.to_csv, filename: "kpi-call-#{Date.current}.csv" }
end
end
|