Class: Crm::Reports::KpiCallController
- Inherits:
-
CrmController
- Object
- CrmController
- Crm::Reports::KpiCallController
- Includes:
- Controllers::ReportCommandFlashable
- Defined in:
- app/controllers/crm/reports/kpi_call_controller.rb
Overview
Controller: kpi call.
Instance Method Summary collapse
-
#refresh_data ⇒ Object
Enqueues the KPI call data refresh worker.
-
#show ⇒ Object
Runs the KPI call report command.
Instance Method Details
#refresh_data ⇒ Object
Enqueues the KPI call data refresh worker.
31 32 33 34 |
# File 'app/controllers/crm/reports/kpi_call_controller.rb', line 31 def refresh_data job_id = RefreshKpiCallDataWorker.perform_async redirect_to_job_or_fallback(job_id, reports_kpi_call_path) end |
#show ⇒ Object
Runs the KPI call report command.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/crm/reports/kpi_call_controller.rb', line 9 def show :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.headers['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 |