query_report 0.1.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. data/{LICENSE.txt → MIT-LICENSE} +2 -4
  2. data/README.md +32 -53
  3. data/Rakefile +50 -0
  4. data/app/helpers/query_report_filter_helper.rb +22 -0
  5. data/app/helpers/query_report_helper.rb +31 -0
  6. data/app/views/query_report/_charts.html.erb +10 -0
  7. data/app/views/query_report/_search.html.erb +8 -0
  8. data/app/views/query_report/list.html.erb +19 -38
  9. data/config/locales/query_report.yml +7 -0
  10. data/config/routes.rb +2 -0
  11. data/db/schema.rb +34 -0
  12. data/lib/query_report.rb +22 -15
  13. data/lib/query_report/chart/chart_base.rb +60 -0
  14. data/lib/query_report/chart/chart_column.rb +12 -0
  15. data/lib/query_report/chart/column_chart.rb +40 -0
  16. data/lib/query_report/chart/pie_chart.rb +22 -25
  17. data/lib/query_report/chart/themes.rb +18 -114
  18. data/lib/query_report/column.rb +29 -18
  19. data/lib/query_report/config.rb +6 -0
  20. data/lib/query_report/engine.rb +4 -0
  21. data/lib/query_report/errors.rb +4 -0
  22. data/lib/query_report/filter.rb +110 -31
  23. data/lib/query_report/helper.rb +19 -3
  24. data/lib/query_report/paginate.rb +13 -0
  25. data/lib/query_report/record.rb +46 -0
  26. data/lib/query_report/report.rb +19 -102
  27. data/lib/query_report/report_pdf.rb +68 -84
  28. data/lib/query_report/version.rb +1 -1
  29. data/lib/tasks/query_report_tasks.rake +4 -0
  30. data/test/dummy/README.rdoc +261 -0
  31. data/test/dummy/Rakefile +7 -0
  32. data/test/dummy/app/assets/javascripts/application.js +15 -0
  33. data/test/dummy/app/assets/javascripts/invoices.js +2 -0
  34. data/test/dummy/app/assets/javascripts/users.js +2 -0
  35. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  36. data/test/dummy/app/assets/stylesheets/invoices.css +4 -0
  37. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  38. data/test/dummy/app/assets/stylesheets/users.css +4 -0
  39. data/test/dummy/app/controllers/application_controller.rb +3 -0
  40. data/test/dummy/app/controllers/invoices_controller.rb +114 -0
  41. data/test/dummy/app/controllers/users_controller.rb +91 -0
  42. data/test/dummy/app/helpers/application_helper.rb +2 -0
  43. data/test/dummy/app/helpers/invoices_helper.rb +2 -0
  44. data/test/dummy/app/helpers/users_helper.rb +2 -0
  45. data/test/dummy/app/models/invoice.rb +3 -0
  46. data/test/dummy/app/models/pdf_report_template.rb +24 -0
  47. data/test/dummy/app/models/user.rb +3 -0
  48. data/test/dummy/app/views/invoices/_form.html.erb +33 -0
  49. data/test/dummy/app/views/invoices/edit.html.erb +6 -0
  50. data/test/dummy/app/views/invoices/index.html.erb +29 -0
  51. data/test/dummy/app/views/invoices/new.html.erb +5 -0
  52. data/test/dummy/app/views/invoices/show.html.erb +25 -0
  53. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  54. data/test/dummy/app/views/users/_form.html.erb +33 -0
  55. data/test/dummy/app/views/users/edit.html.erb +6 -0
  56. data/test/dummy/app/views/users/index.html.erb +29 -0
  57. data/test/dummy/app/views/users/new.html.erb +5 -0
  58. data/test/dummy/app/views/users/show.html.erb +25 -0
  59. data/test/dummy/config.ru +4 -0
  60. data/test/dummy/config/application.rb +60 -0
  61. data/test/dummy/config/boot.rb +10 -0
  62. data/test/dummy/config/database.yml +25 -0
  63. data/test/dummy/config/environment.rb +5 -0
  64. data/test/dummy/config/environments/development.rb +37 -0
  65. data/test/dummy/config/environments/production.rb +67 -0
  66. data/test/dummy/config/environments/test.rb +37 -0
  67. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  68. data/test/dummy/config/initializers/inflections.rb +15 -0
  69. data/test/dummy/config/initializers/mime_types.rb +5 -0
  70. data/test/dummy/config/initializers/query_report.rb +3 -0
  71. data/test/dummy/config/initializers/secret_token.rb +7 -0
  72. data/test/dummy/config/initializers/session_store.rb +8 -0
  73. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  74. data/test/dummy/config/locales/en.yml +10 -0
  75. data/test/dummy/config/routes.rb +64 -0
  76. data/test/dummy/db/development.sqlite3 +0 -0
  77. data/test/dummy/db/migrate/20130622120853_create_users.rb +12 -0
  78. data/test/dummy/db/migrate/20130630132513_create_invoices.rb +12 -0
  79. data/test/dummy/db/schema.rb +34 -0
  80. data/test/dummy/db/seed.rb +4 -0
  81. data/test/dummy/db/test.sqlite3 +0 -0
  82. data/test/dummy/log/development.log +30613 -0
  83. data/test/dummy/log/test.log +28 -0
  84. data/test/dummy/public/404.html +26 -0
  85. data/test/dummy/public/422.html +26 -0
  86. data/test/dummy/public/500.html +25 -0
  87. data/test/dummy/public/favicon.ico +0 -0
  88. data/test/dummy/script/rails +6 -0
  89. data/test/dummy/test/fixtures/invoices.yml +13 -0
  90. data/test/dummy/test/functional/invoices_controller_test.rb +49 -0
  91. data/test/dummy/test/unit/helpers/invoices_helper_test.rb +4 -0
  92. data/test/dummy/test/unit/invoice_test.rb +7 -0
  93. data/test/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212 +0 -0
  94. data/test/dummy/tmp/cache/assets/CA9/F20/sprockets%2F00ff4f84806dd8834ab35f800a082640 +0 -0
  95. data/test/dummy/tmp/cache/assets/CAA/620/sprockets%2F87b209c0c9da28094a8d5581a21262c6 +0 -0
  96. data/test/dummy/tmp/cache/assets/CB5/B70/sprockets%2Fa769d915e72b1c8c0614793b54d02c86 +0 -0
  97. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  98. data/test/dummy/tmp/cache/assets/CD8/B70/sprockets%2F4050a4e5062ab95c9f32e9b6940821ea +0 -0
  99. data/test/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2 +0 -0
  100. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  101. data/test/dummy/tmp/cache/assets/D46/650/sprockets%2Ff56253b5f374fff1a33fbbc9881c9124 +0 -0
  102. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  103. data/test/dummy/tmp/cache/assets/D54/B90/sprockets%2F90719d7bdca76469cd487928f710decb +0 -0
  104. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  105. data/test/dummy/tmp/cache/assets/D67/B60/sprockets%2F5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  106. data/test/dummy/tmp/cache/assets/D7C/990/sprockets%2F302f7d851fcdb17936f8096bfb967cab +0 -0
  107. data/test/dummy/tmp/cache/assets/D7F/AF0/sprockets%2Fa7deca9af827ab462635389b96c7da39 +0 -0
  108. data/test/dummy/tmp/cache/assets/DA3/AC0/sprockets%2F797d3e5f21daaf5c046cc6ec4830e95b +0 -0
  109. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  110. data/test/dummy/tmp/cache/assets/DFC/6F0/sprockets%2F2c45c36e4d7c7bfaeb826eeba29a09d2 +0 -0
  111. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  112. data/test/dummy/tmp/cache/assets/E0E/8A0/sprockets%2Fbecd48a9cf2ece858e433d7dcf0554f6 +0 -0
  113. data/test/dummy/tmp/miniprofiler/mp_timers_5awpjfhldzcfjkeiia3p +0 -0
  114. data/test/dummy/tmp/miniprofiler/mp_timers_a7ev5lal7xp2xzjj2n9p +0 -0
  115. data/test/dummy/tmp/miniprofiler/mp_timers_c5lzifpf785aic4t3cm8 +0 -0
  116. data/test/dummy/tmp/miniprofiler/mp_timers_etmdhvrbbmdadc7oyw8q +0 -0
  117. data/test/dummy/tmp/miniprofiler/mp_timers_m0kxxiow6jlfcjulu02t +0 -0
  118. data/test/dummy/tmp/miniprofiler/mp_timers_m2ow1xy7c6tw0f4fj2co +0 -0
  119. data/test/dummy/tmp/miniprofiler/mp_timers_mitzsa7y0lvka04il6an +0 -0
  120. data/test/dummy/tmp/miniprofiler/mp_timers_ujpdek4jfp8flbqp7fi3 +0 -0
  121. data/test/dummy/tmp/miniprofiler/mp_timers_wbiyljqrnox89js4m0at +0 -0
  122. data/test/dummy/tmp/miniprofiler/mp_views_127.0.0.1 +1 -0
  123. data/test/test_helper.rb +15 -0
  124. metadata +380 -24
  125. data/.gitignore +0 -18
  126. data/Gemfile +0 -10
  127. data/README.rdoc +0 -3
  128. data/app/views/query_report/_custom_filters.html.erb +0 -7
  129. data/lib/query_report/chart/basic_chart.rb +0 -41
  130. data/lib/query_report/chart/custom_chart.rb +0 -55
  131. data/lib/query_report/row.rb +0 -11
  132. data/query_report.gemspec +0 -31
@@ -1,4 +1,11 @@
1
+ # Author:: A.K.M. Ashrafuzzaman (mailto:ashrafuzzaman.g2@gmail.com)
2
+ # License:: MIT-LICENSE
3
+
4
+ # The purpose of the helper module is to help controllers with the responders
5
+
6
+ require 'csv'
1
7
  require 'query_report/report'
8
+ require 'query_report/report_pdf'
2
9
 
3
10
  module QueryReport
4
11
  module Helper
@@ -13,10 +20,19 @@ module QueryReport
13
20
  respond_to do |format|
14
21
  format.js { render 'query_report/list' }
15
22
  format.html { render 'query_report/list' }
16
- format.json { render json: @report.records }
23
+ format.json { render json: @report.all_records }
17
24
  format.csv { send_data generate_csv_for_report(@report.all_records), :disposition => "attachment;" }
18
- format.pdf { render_pdf(ReportPdf.new(@report).standard) }
25
+ format.pdf { send_data query_report_pdf_template_class.new(@report).to_pdf.render }
26
+ end
27
+ end
28
+
29
+ def query_report_pdf_template_class
30
+ options = QueryReport.config.pdf_options
31
+ if options[:template_class]
32
+ @template_class ||= options[:template_class].to_s.constantize
33
+ return @template_class
19
34
  end
35
+ reurn QueryReport::ReportPdf
20
36
  end
21
37
 
22
38
  def generate_csv_for_report(records)
@@ -25,7 +41,7 @@ module QueryReport
25
41
  CSV.generate do |csv|
26
42
  csv << columns
27
43
  records.each do |record|
28
- csv << record.values
44
+ csv << record.values.collect { |val| val.kind_of?(String) ? view_context.strip_links(val) : val }
29
45
  end
30
46
  end
31
47
  else
@@ -0,0 +1,13 @@
1
+ # Author:: A.K.M. Ashrafuzzaman (mailto:ashrafuzzaman.g2@gmail.com)
2
+ # License:: MIT-LICENSE
3
+
4
+ # The purpose of the paginate module is to offer support for pagination
5
+
6
+ module QueryReport
7
+ module PaginateModule
8
+ def apply_pagination(query, params)
9
+ page_method_name = Kaminari.config.page_method_name
10
+ query.send(page_method_name, params[:page])
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,46 @@
1
+ module QueryReport
2
+ module Record
3
+ attr_accessor :query
4
+
5
+ def model_class
6
+ query.klass
7
+ end
8
+
9
+ def filtered_query
10
+ apply
11
+ @filtered_query
12
+ end
13
+
14
+ def paginated_query
15
+ apply
16
+ @paginated_query
17
+ end
18
+
19
+ def search
20
+ apply
21
+ @search
22
+ end
23
+
24
+ def apply
25
+ @filtered_query ||= apply_filters(query.clone, @params)
26
+ @paginated_query ||= apply_pagination(@filtered_query, @params)
27
+ end
28
+
29
+ def records
30
+ @records ||= map_record(paginated_query, true)
31
+ end
32
+
33
+ def all_records
34
+ @all_records ||= map_record(filtered_query, false)
35
+ end
36
+
37
+ def map_record(query, render_from_view)
38
+ @columns = @columns.delete_if { |col| col.only_on_web? } unless render_from_view
39
+
40
+ query.map do |record|
41
+ array = @columns.collect { |column| [column.humanize, column.value(record)] }
42
+ Hash[*array.flatten]
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,25 +1,31 @@
1
- require 'query_report/filter'
2
- require 'query_report/column'
3
-
4
1
  module QueryReport
5
- DEFAULT_OPTIONS = {
6
- chart_on_pdf: true, paginate: true
7
- }
2
+ autoload :ColumnModule, 'query_report/column'
3
+ autoload :FilterModule, 'query_report/filter'
4
+ autoload :PaginateModule, 'query_report/paginate'
5
+ autoload :Record, 'query_report/record'
6
+ autoload :ColumnChartModule, 'query_report/chart/column_chart'
7
+ autoload :PieChartModule, 'query_report/chart/pie_chart'
8
+
9
+ DEFAULT_OPTIONS = {enable_chart: true, chart_on_web: true, chart_on_pdf: true, paginate: true}
8
10
 
9
11
  class Report
10
12
  include QueryReport::ColumnModule
11
13
  include QueryReport::FilterModule
14
+ include QueryReport::PaginateModule
15
+ include QueryReport::Record
16
+ include QueryReport::ColumnChartModule
17
+ include QueryReport::PieChartModule
12
18
 
13
- attr_accessor :params, :template, :chart, :charts, :filters, :scopes, :current_scope, :options
19
+ attr_reader :params, :template, :options, :charts
14
20
 
15
21
  def initialize(params, template, options={}, &block)
16
22
  @params, @template = params, template
17
- @columns, @filters, @scopes, @charts = [], [], [], []
18
- @current_scope = @params[:scope] || 'all'
23
+ @columns, @filters, @charts = [], [], []
19
24
  @options = QueryReport::DEFAULT_OPTIONS.merge options
20
25
  instance_eval &block if block_given?
21
26
  end
22
27
 
28
+ # define options methods
23
29
  QueryReport::DEFAULT_OPTIONS.each do |option_name, value|
24
30
  if value.class == TrueClass or value.class == FalseClass
25
31
  define_method "#{option_name.to_s}?" do
@@ -28,6 +34,10 @@ module QueryReport
28
34
  end
29
35
  end
30
36
 
37
+ def has_chart?
38
+ !@charts.empty?
39
+ end
40
+
31
41
  # to support the helper methods
32
42
  def method_missing(meth, *args, &block)
33
43
  if @template.respond_to?(meth)
@@ -36,98 +46,5 @@ module QueryReport
36
46
  super
37
47
  end
38
48
  end
39
-
40
- def model_name
41
- query.table.name.singularize
42
- end
43
-
44
- def query=(query)
45
- @query_cache = query
46
- end
47
-
48
- def query
49
- apply_filters_and_pagination
50
- @query_cache
51
- end
52
-
53
- def query_without_pagination
54
- apply_filters_and_pagination
55
- @query_without_pagination_cache
56
- end
57
-
58
- def records
59
- @cached_records ||= map_record(query)
60
- end
61
-
62
- def all_records
63
- @cached_all_records ||= map_record(query_without_pagination)
64
- end
65
-
66
- def map_record(query)
67
- query.clone.map do |record|
68
- array = @columns.collect { |column| [column.humanize,
69
- (column.data.kind_of?(Symbol) ? record.send(column.name) : column.data.call(record))] }
70
- Hash[*array.flatten]
71
- end
72
- end
73
-
74
- def scope(scope)
75
- @scopes << scope
76
- @scopes = @scopes.uniq
77
- end
78
-
79
- def search
80
- apply_filters_and_pagination
81
- @search
82
- end
83
-
84
- def compare_with_column_chart(title, x_axis='', &block)
85
- @chart = QueryReport::Chart::CustomChart.new(:column, title, query_without_pagination)
86
- @chart.add_column x_axis
87
- @chart.instance_eval &block if block_given?
88
- @charts << @chart
89
- end
90
-
91
- def pie_chart(title, &block)
92
- @chart = QueryReport::Chart::PieChart.new(title, query_without_pagination)
93
- @chart.instance_eval &block if block_given?
94
- @charts << @chart
95
- end
96
-
97
- private
98
- def apply_filters_and_pagination
99
- return if @applied_filters_and_pagination
100
- #apply ransack
101
- @search = @query_cache.search(@params[:q])
102
- @query_cache = @search.result
103
-
104
- #apply scope
105
- if @current_scope and !['all', 'delete_all', 'destroy_all'].include?(@current_scope)
106
- @query_cache = @query_cache.send(@current_scope)
107
- end
108
-
109
- #apply filters
110
- @filters.each do |filter|
111
- if filter.custom
112
- param = @params[:custom_search]
113
- first_val = param[filter.keys.first] rescue nil
114
- last_val = param[filter.keys.last] rescue nil
115
- case filter.keys.size
116
- when 1
117
- @query_cache = filter.block.call(@query_cache, first_val) if first_val.present?
118
- break
119
- when 2
120
- @query_cache = filter.block.call(@query_cache, first_val, last_val) if first_val.present? and last_val.present?
121
- break
122
- end
123
- end
124
- end
125
-
126
- #apply pagination
127
- @query_without_pagination_cache = @query_cache
128
- page_method_name = Kaminari.config.page_method_name
129
- @query_cache = @query_without_pagination_cache.send(page_method_name, @params[:page])
130
- @applied_filters_and_pagination = true
131
- end
132
49
  end
133
50
  end
@@ -1,113 +1,97 @@
1
- require "prawn"
2
- require "open-uri"
3
-
4
- class ReportPdf
5
- attr_accessor :pdf, :default_options
1
+ module QueryReport
2
+ class ReportPdf
3
+ attr_reader :pdf, :options, :report
4
+
5
+ def initialize(report)
6
+ @report = report
7
+ @options = QueryReport.config.pdf_options
8
+ @pdf = Prawn::Document.new
9
+ end
6
10
 
7
- def initialize(report)
8
- @report = report
9
- self.default_options = {alternate_row_bg_color: ["DDDDDD", "FFFFFF"],
10
- header_bg_color: 'AAAAAA',
11
- color: '000000',
12
- light_color: '555555'}
13
- self.pdf = Prawn::Document.new
14
- end
11
+ #render the header from the template class
12
+ def render_header
13
+ template.try(:render_header)
14
+ end
15
15
 
16
- def render_header(options={})
17
- #pdf.font("Times-Roman", size: 10) do
18
- # pdf.text_box current_institute.address.to_s,
19
- # :at => [400, pdf.cursor+20],
20
- # :inline_format => true,
21
- # :height => 100,
22
- # :width => 100
23
- #end
24
- end
16
+ def render_footer
17
+ template.try(:render_footer)
18
+ end
25
19
 
26
- def pdf_content(&code)
27
- render_header
28
- code.call(pdf)
29
- pdf
30
- end
20
+ def to_pdf
21
+ render_charts_with report
22
+ render_table_with report
23
+ pdf
24
+ end
31
25
 
32
- def standard
33
- pdf_content do
34
- render_charts_with @report
35
- render_table_with(@report.all_records, {font_size: 8, header_font_size: 10})
26
+ private
27
+ def render_charts_with(report)
28
+ return if report.charts.empty? #or !report.chart_on_pdf?
29
+ height = options[:chart][:height] * (report.charts.size.to_f/2).ceil
30
+ pdf.column_box([0, pdf.cursor], :columns => 2, :width => pdf.bounds.width, :height => height) do
31
+ report.charts.each do |chart|
32
+ render_chart(chart)
33
+ end
34
+ end
36
35
  end
37
- end
38
36
 
39
- private
40
- def render_charts_with(report)
41
- return if report.charts.nil? or !report.chart_on_pdf?
42
- report.charts.each do |chart|
37
+ def render_chart(chart)
43
38
  if chart.respond_to?(:to_blob)
44
39
  blob = chart.to_blob
45
40
  data = StringIO.new(blob)
46
41
  pdf.pad_top(10) do
47
- pdf.image(data, :width => 200)
42
+ pdf.image(data, :width => options[:chart][:width])
48
43
  end
49
44
  end
50
45
  end
51
- end
52
46
 
53
- def table_header_for(table_items, options={})
54
- table_items.first.keys
55
- end
47
+ def table_header_for(table_items)
48
+ table_items.first.keys
49
+ end
56
50
 
57
- def humanized_table_header_for(table_items, options={})
58
- table_items.first.keys.collect(&:humanize) rescue table_header_for(table_items, options)
59
- end
51
+ def humanized_table_header
52
+ report_columns.collect(&:humanize)
53
+ end
60
54
 
61
- def table_content_for(table_items, options)
62
- table_items.map do |item|
63
- item_values = []
55
+ def table_content_for(report)
56
+ table_items = report.all_records
57
+ table_items.map do |item|
58
+ item_values = []
64
59
 
65
- options[:table_header].each do |header|
66
- item_values << cell_for(item, header)
60
+ report_columns.collect(&:humanize).each do |column|
61
+ item_values << item[column].to_s
62
+ end
63
+ item_values
67
64
  end
68
- item_values
69
65
  end
70
- end
71
66
 
72
- def cell_for(item, prop)
73
- val = item.respond_to?(prop) ? item.send(prop) : item[prop]
74
- if val.kind_of? Array
75
- val.collect { |v| [v] }
76
- return pdf.make_table(val)
67
+ def render_table_with(report)
68
+ items = [humanized_table_header]
69
+ items += table_content_for(report)
70
+ render_table(items)
77
71
  end
78
- val
79
- end
80
72
 
81
- def render_table_with(table_items, options={})
82
- if table_items.present?
83
- options[:table_header] ||= table_header_for(table_items, options)
84
- items = [humanized_table_header_for(table_items)]
85
- items += table_content_for(table_items, options)
86
- items += table_footer_for(table_items, options)
87
- options[:bold_footer] = options[:titles_of_column_to_sum].present?
88
- render_table(items, options)
73
+ def render_table(items)
74
+ header_bg_color = options[:table][:header][:bg_color]
75
+ alternate_row_bg_color = [options[:table][:row][:odd_bg_color], options[:table][:row][:even_bg_color]]
76
+ font_size = options[:font_size]
77
+ header_font_size = options[:table][:header][:font_size]
78
+ pdf.move_down 10
79
+ pdf.table(items, :row_colors => alternate_row_bg_color, :header => true, :cell_style => {:inline_format => true, :size => font_size}) do
80
+ row(0).style(:font_style => :bold, :background_color => header_bg_color, :size => header_font_size)
81
+ end
89
82
  end
90
- pdf
91
- end
92
83
 
93
- def render_table(items, options={})
94
- options = default_options.merge options
95
- header_bg_color = options[:header_bg_color]
96
- pdf.move_down 10
97
- pdf.table(items, :row_colors => options[:alternate_row_bg_color], :header => true, :cell_style => {:inline_format => true, :size => options[:font_size] || 10}) do
98
- row(0).style(:font_style => :bold, :background_color => header_bg_color, :size => options[:header_font_size] || 14)
99
- row(items.size-1).style(:font_style => :bold) if options[:bold_footer]
84
+ private
85
+ def report_columns
86
+ report.columns.select { |c| !c.only_on_web? }
100
87
  end
101
- end
102
88
 
103
- def table_footer_for(table_items, options)
104
- return [] if options[:titles_of_column_to_sum].blank?
105
- total_hash = {} #for calculating total for a column
106
- options[:titles_of_column_to_sum].each do |col|
107
- total_hash[col] = table_items.sum { |i| (i.respond_to?(col) ? i.send(col) : i[col]) || 0 }
89
+ def template
90
+ if options[:template_class]
91
+ @template ||= options[:template_class].to_s.constantize.new(report, pdf)
92
+ return @template
93
+ end
94
+ nil
108
95
  end
109
-
110
- render_footer_with_col_span(total_hash, options)
111
96
  end
112
-
113
97
  end
@@ -1,3 +1,3 @@
1
1
  module QueryReport
2
- VERSION = "0.1.2"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :query_report do
3
+ # # Task goes here
4
+ # end