9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/crm/reports/tech_calls_report_controller.rb', line 9
def show
@report_command = ::Report::TechCallsReport::TechCallsReportCommand.new(tech_calls_report_command_params)
@result = @report_command.execute
@command_params = tech_calls_report_command_params.to_h.presence || {}
if @result
@tab = params[:tab].presence || 'ttl'
@page = [params[:page].to_i, 1].max
@per_page = PER_PAGE
@sort_col = SORTABLE_COLUMNS.include?(params[:sort_col]) ? params[:sort_col] : 'start_time'
@sort_dir = params[:sort_dir] == 'asc' ? 'asc' : 'desc'
tab_records = sorted_records(tab_data(@tab))
@tab_total = tab_records.size
@tab_pages = [(@tab_total.to_f / @per_page).ceil, 1].max
@tab_records = tab_records.slice((@page - 1) * @per_page, @per_page) || []
end
flash_report_command_errors
respond_to do |format|
format.html
format.turbo_stream
end
end
|