Module: DcReport
- Defined in:
- app/controls/dc_report.rb
Overview
Common methods required by reports
Instance Attribute Summary collapse
-
#bulk ⇒ Object
Returns the value of attribute bulk.
-
#report_id ⇒ Object
Returns the value of attribute report_id.
Instance Method Summary collapse
-
#data_filter ⇒ Object
Default filter to select data for result.
-
#dc_new_record ⇒ Object
Clear result if params is ‘yes’ when form is first displayed.
-
#dc_update_form ⇒ Object
If exists, set report section as form, so it can be used to display result.
-
#export ⇒ Object
Export data do excel action.
-
#print ⇒ Object
Print to PDF action.
Instance Attribute Details
#bulk ⇒ Object
Returns the value of attribute bulk.
29 30 31 |
# File 'app/controls/dc_report.rb', line 29 def bulk @bulk end |
#report_id ⇒ Object
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_filter ⇒ Object
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_record ⇒ Object
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_form ⇒ Object
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 |
#export ⇒ Object
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 ⇒ Object
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/document-#{Time.now.to_i}.pdf" @pdf.render_file Rails.root.join('public', pdf_file) render json: print_response(pdf_file) end |