Module: AgileReport
- Defined in:
- app/controls/agile_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.
-
#export ⇒ Object
Export data do excel action.
-
#new_record ⇒ Object
Clear data unless params is 'no'.
-
#print ⇒ Object
Print to PDF action.
-
#report_url_for(params = {}) ⇒ Object
Return url for report iframe with additional parameters.
-
#update_form ⇒ Object
Will replace @form with @form if table=ar_temp.
Instance Attribute Details
#bulk ⇒ Object
Returns the value of attribute bulk.
28 29 30 |
# File 'app/controls/agile_report.rb', line 28 def bulk @bulk end |
#report_id ⇒ Object
Returns the value of attribute report_id.
28 29 30 |
# File 'app/controls/agile_report.rb', line 28 def report_id @report_id end |
Instance Method Details
#data_filter ⇒ Object
Default filter to select data for result.
101 102 103 |
# File 'app/controls/agile_report.rb', line 101 def data_filter params['clear'].to_s == 'yes' ? ArTemp.where(key: false) : ArTemp.where(key: temp_key).order(:order) end |
#export ⇒ Object
Export data do excel action
94 95 96 |
# File 'app/controls/agile_report.rb', line 94 def export export_to_excel(temp_key) end |
#new_record ⇒ Object
Clear data unless params is 'no'
33 34 35 |
# File 'app/controls/agile_report.rb', line 33 def new_record ArTemp.clear(temp_key) unless params[:clear].to_s == 'no' end |
#print ⇒ Object
Print to PDF action
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controls/agile_report.rb', line 77 def print begin pdf_do rescue Exception => e Agile.dump_exception(e) render json: { msg_error: t('agile.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 |
#report_url_for(params = {}) ⇒ Object
Return url for report iframe with additional parameters. Use when you need to send additional parameters to resulting iframe.
41 42 43 44 |
# File 'app/controls/agile_report.rb', line 41 def report_url_for(params = {}) url = "if_ar_temp;/agile?field_name=ar_temp&iframe=if_ar_temp&table=ar_temp&form_name=#{@report_id}" params.inject(url) { |r, v| "#{r}&#{v[0]}=#{v[1]}" } end |
#update_form ⇒ Object
Will replace @form with @form if table=ar_temp. Will load agile_report_defaults if table=ar_memory and actions are not present.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controls/agile_report.rb', line 50 def update_form agile_form_read if @form.nil? if AgileHelper.table_param(params) == 'ar_temp' && @form['report'].present? @form = @form['report'] elsif AgileHelper.table_param(params) == 'ar_memory' && !AgileHelper.dont?(@form['defaults']) defaults = File.read(AgileHelper.form_file_find('agile_report_defaults')) defaults.gsub!('&report', AgileHelper.form_param(params)) defaults = YAML.load(defaults) rescue nil return if defaults.nil? case @form['form']['actions'].class.to_s when 'NilClass' when 'Hash' then defaults = {} when 'String' # only print or export are specified if @form['form']['actions'] == 'print' defaults['form']['actions'].delete(30) elsif @form['form']['actions'] == 'export' defaults['form']['actions'].delete(20) end end @form.deep_merge!(defaults) end end |