Module: DcReport

Defined in:
app/controls/dc_report.rb

Overview

Common methods required by reports

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bulkObject

Returns the value of attribute bulk.



29
30
31
# File 'app/controls/dc_report.rb', line 29

def bulk
  @bulk
end

#report_idObject

Returns the value of attribute report_id.



28
29
30
# File 'app/controls/dc_report.rb', line 28

def report_id
  @report_id
end

Instance Method Details

#data_filterObject

Default filter to select data for result.



74
75
76
# File 'app/controls/dc_report.rb', line 74

def data_filter
  params['clear'].to_s == 'yes' ? DcTemp.where(key: false) : DcTemp.where(key: temp_key).order_by(order: 1)
end

#dc_new_recordObject

Clear result if params is ‘yes’ when form is first displayed



34
35
36
# File 'app/controls/dc_report.rb', line 34

def dc_new_record
  DcTemp.clear(temp_key) unless params[:clear].to_s == 'no'
end

#dc_update_formObject

If exists, set report section as form, so it can be used to display result.



41
42
43
44
45
# File 'app/controls/dc_report.rb', line 41

def dc_update_form
  return unless @form && @form['report'] && CmsHelper.table_param(params) == 'dc_temp'

  @form = @form['report']
end

#exportObject

Export data do excel action



67
68
69
# File 'app/controls/dc_report.rb', line 67

def export
  export_to_excel( temp_key )
end

Print to PDF action



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controls/dc_report.rb', line 50

def print
  begin
    pdf_do
  rescue Exception => e
    dc_dump_exception(e)
    render json: { msg_error: t('drgcms.runtime_error') } and return
  end

  pdf_file = "tmp/dokument-#{Time.now.to_i}.pdf"
  @pdf.render_file Rails.root.join('public', pdf_file)

  render json: print_response(pdf_file)
end