prawn_report 1.9.21 → 1.9.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/ac_filter_defs_controller.rb +16 -17
- data/app/controllers/custom_generate_report_controller.rb +18 -18
- data/app/controllers/generate_report_controller.rb +24 -24
- data/app/controllers/report_templates_controller.rb +40 -48
- data/app/models/ac_filter.rb +15 -15
- data/app/models/ac_filter_def.rb +38 -40
- data/app/models/ac_filter_option.rb +5 -5
- data/app/models/report_template.rb +22 -27
- data/lib/ac_filters_utils.rb +187 -189
- data/lib/active_record_helpers.rb +218 -219
- data/lib/bands/band.rb +23 -23
- data/lib/bands/footer_band.rb +7 -7
- data/lib/bands/header_band.rb +9 -9
- data/lib/bands/summary_band.rb +7 -7
- data/lib/custom_report_controller.rb +48 -60
- data/lib/generators/prawn_report/install/templates/20131107172133_add_excluir_to_report_template.rb +0 -1
- data/lib/prawn_report.rb +21 -21
- data/lib/prawn_report/version.rb +3 -0
- data/lib/prawn_report_seeds.rb +45 -59
- data/lib/report.rb +189 -195
- data/lib/report_helpers.rb +82 -83
- data/lib/report_info.rb +27 -27
- data/repo/bands/footers/footer_001.rb +20 -20
- data/repo/bands/headers/header_001.rb +61 -61
- data/repo/bands/headers/header_002.rb +31 -31
- data/repo/reports/column_group.rb +4 -3
- data/repo/reports/listing.rb +1 -59
- data/repo/reports/simple_listing.rb +130 -149
- metadata +58 -90
- data/app/serializers/ac_filter_def_serializer.rb +0 -10
- data/app/serializers/ac_filter_option_serializer.rb +0 -7
- data/app/serializers/ac_filter_serializer.rb +0 -9
- data/app/serializers/report_template_basic_serializer.rb +0 -4
- data/app/serializers/report_template_serializer.rb +0 -9
- data/lib/generators/prawn_report/install/templates/20140529153300_add_description_to_report_template.rb +0 -6
data/lib/bands/footer_band.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module PrawnReport
|
2
|
-
|
3
|
-
class FooterBand < Band
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
end
|
1
|
+
module PrawnReport
|
2
|
+
|
3
|
+
class FooterBand < Band
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
end
|
data/lib/bands/header_band.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
module PrawnReport
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + "/band")
|
4
|
-
|
5
|
-
class HeaderBand < Band
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
1
|
+
module PrawnReport
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + "/band")
|
4
|
+
|
5
|
+
class HeaderBand < Band
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
data/lib/bands/summary_band.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module PrawnReport
|
2
|
-
|
3
|
-
class SummaryBand < Band
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
end
|
1
|
+
module PrawnReport
|
2
|
+
|
3
|
+
class SummaryBand < Band
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
end
|
@@ -1,60 +1,48 @@
|
|
1
|
-
#coding: utf-8
|
2
|
-
|
3
|
-
module PrawnReportController
|
4
|
-
|
5
|
-
def get_pr_report_data
|
6
|
-
[]
|
7
|
-
end
|
8
|
-
|
9
|
-
def get_pr_report_class
|
10
|
-
@pr_report_class
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_pr_suggested_filename; end
|
14
|
-
|
15
|
-
def get_pr_report_params
|
16
|
-
@pr_report_params || {}
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_pr_serialization_params
|
20
|
-
@serialization_params || {}
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_pr_filters
|
24
|
-
@filters
|
25
|
-
end
|
26
|
-
|
27
|
-
def index
|
28
|
-
@filters = []
|
29
|
-
rec = get_pr_report_data
|
30
|
-
if rec.nil? || (rec.is_a?(Array) && rec.count == 0)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
report =
|
36
|
-
|
37
|
-
|
38
|
-
fn = get_pr_suggested_filename
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
format.csv do
|
51
|
-
report_content = report.draw_csv(report_content.get_yaml)
|
52
|
-
fn ||= "report"
|
53
|
-
send_data(report_content, :filename => "#{fn}.csv")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
1
|
+
#coding: utf-8
|
2
|
+
|
3
|
+
module PrawnReportController
|
4
|
+
|
5
|
+
def get_pr_report_data
|
6
|
+
[]
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_pr_report_class
|
10
|
+
@pr_report_class
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_pr_suggested_filename; end
|
14
|
+
|
15
|
+
def get_pr_report_params
|
16
|
+
@pr_report_params || {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_pr_serialization_params
|
20
|
+
@serialization_params || {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_pr_filters
|
24
|
+
@filters
|
25
|
+
end
|
26
|
+
|
27
|
+
def index
|
28
|
+
@filters = []
|
29
|
+
rec = get_pr_report_data
|
30
|
+
if rec.nil? || (rec.is_a?(Array) && rec.count == 0)
|
31
|
+
render :nothing => true, :status => :no_content
|
32
|
+
else
|
33
|
+
report_content = rec.pr_serialize(get_pr_serialization_params)
|
34
|
+
report = get_pr_report_class.new(get_pr_report_params)
|
35
|
+
report.report_params[:filters] = get_pr_filters
|
36
|
+
report_content = report.draw(report_content.get_yaml)
|
37
|
+
|
38
|
+
fn = get_pr_suggested_filename
|
39
|
+
|
40
|
+
if fn
|
41
|
+
send_data(report_content, :filename => fn)
|
42
|
+
else
|
43
|
+
send_data(report_content, :disposition => 'inline', :type => 'application/pdf')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/lib/prawn_report.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
module PrawnReport
|
5
|
-
mattr_accessor :parent_controller
|
6
|
-
@@parent_controller = "CustomGenerateReportController"
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
require "report"
|
11
|
-
require "bands/band"
|
12
|
-
require "bands/summary_band"
|
13
|
-
require "active_record_helpers"
|
14
|
-
require "ac_filters_utils"
|
15
|
-
require File.expand_path(File.dirname(__FILE__) + "/../repo/bands/headers/header_001.rb")
|
16
|
-
require File.expand_path(File.dirname(__FILE__) + "/../repo/bands/footers/footer_001.rb")
|
17
|
-
require File.expand_path(File.dirname(__FILE__) + "/../repo/reports/simple_listing.rb")
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + "/../repo/reports/column_group.rb")
|
19
|
-
|
20
|
-
# Rails 3 compatibility
|
21
|
-
require 'prawn_report/engine' if ((defined? Rails) and (Rails::version >= '3.0.0'))
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
module PrawnReport
|
5
|
+
mattr_accessor :parent_controller
|
6
|
+
@@parent_controller = "CustomGenerateReportController"
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
require "report"
|
11
|
+
require "bands/band"
|
12
|
+
require "bands/summary_band"
|
13
|
+
require "active_record_helpers"
|
14
|
+
require "ac_filters_utils"
|
15
|
+
require File.expand_path(File.dirname(__FILE__) + "/../repo/bands/headers/header_001.rb")
|
16
|
+
require File.expand_path(File.dirname(__FILE__) + "/../repo/bands/footers/footer_001.rb")
|
17
|
+
require File.expand_path(File.dirname(__FILE__) + "/../repo/reports/simple_listing.rb")
|
18
|
+
require File.expand_path(File.dirname(__FILE__) + "/../repo/reports/column_group.rb")
|
19
|
+
|
20
|
+
# Rails 3 compatibility
|
21
|
+
require 'prawn_report/engine' if ((defined? Rails) and (Rails::version >= '3.0.0'))
|
data/lib/prawn_report_seeds.rb
CHANGED
@@ -1,59 +1,45 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
params["excluir"] = false
|
48
|
-
r.update_attributes(params)
|
49
|
-
puts "Atualizado relatório: " + params["name"]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
#ReportTemplate.create(params)
|
53
|
-
#puts "Criado relatório: " + params["name"]
|
54
|
-
end
|
55
|
-
#puts "FIM"
|
56
|
-
#ReportTemplate.delete_all(:excluir => true)
|
57
|
-
ReportTemplate.destroy_all(:excluir => true)
|
58
|
-
puts "finishing, closing, and going home"
|
59
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
ReportTemplate.update_all({:ac_filter_def_id => nil, :excluir => true})
|
6
|
+
AcFilterOption.delete_all
|
7
|
+
AcFilter.delete_all
|
8
|
+
AcFilterDef.delete_all
|
9
|
+
|
10
|
+
puts "Iniciando importação dos filtros"
|
11
|
+
Dir.glob("#{Rails.root}/db/filters/*.yml").each do |f|
|
12
|
+
params = YAML::load(File.open(f, 'r'))
|
13
|
+
AcFilterDef.create(params)
|
14
|
+
puts "Criado filtro: " + params["name"]
|
15
|
+
end
|
16
|
+
puts "FIM"
|
17
|
+
|
18
|
+
puts "Iniciando importação dos reports"
|
19
|
+
Dir.glob("#{Rails.root}/db/reports/*.yml").each do |f|
|
20
|
+
params = YAML::load(File.open(f, 'r'))
|
21
|
+
r = ReportTemplate.find_by_name(params["name"])
|
22
|
+
if r.nil?
|
23
|
+
if params["filter_name"]
|
24
|
+
f = AcFilterDef.find_by_name(params.delete("filter_name"))
|
25
|
+
if f
|
26
|
+
params["ac_filter_def_id"] = f.id
|
27
|
+
end
|
28
|
+
end
|
29
|
+
params["excluir"] = false
|
30
|
+
ReportTemplate.create(params)
|
31
|
+
puts "Criado relatório: " + params["name"]
|
32
|
+
else
|
33
|
+
if params["filter_name"]
|
34
|
+
f = AcFilterDef.find_by_name(params.delete("filter_name"))
|
35
|
+
if f
|
36
|
+
params["ac_filter_def_id"] = f.id
|
37
|
+
end
|
38
|
+
end
|
39
|
+
params["excluir"] = false
|
40
|
+
r.update_attributes(params)
|
41
|
+
puts "Atualizado relatório: " + params["name"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
ReportTemplate.destroy_all(:excluir => true)
|
45
|
+
puts "finishing, closing, and going home"
|
data/lib/report.rb
CHANGED
@@ -1,195 +1,189 @@
|
|
1
|
-
#coding: utf-8
|
2
|
-
|
3
|
-
require 'prawn'
|
4
|
-
|
5
|
-
require File.expand_path(File.dirname(__FILE__) + "/report_helpers")
|
6
|
-
require File.expand_path(File.dirname(__FILE__) + "/report_info")
|
7
|
-
|
8
|
-
# This is the module for all classes in the prawn_report gem
|
9
|
-
module PrawnReport
|
10
|
-
unless defined? DEFAULT_REPORT_PARAMS
|
11
|
-
DEFAULT_REPORT_PARAMS = {:page_size => 'A4', :margin => [20, 20, 20, 20],
|
12
|
-
:page_layout => :portrait}
|
13
|
-
|
14
|
-
LABEL_SIZE = 6
|
15
|
-
TEXT_SIZE = 10
|
16
|
-
|
17
|
-
SECTION_SPACING = LABEL_SIZE + 4
|
18
|
-
|
19
|
-
LINE_WIDTH = 0.3
|
20
|
-
|
21
|
-
DEFAULT_FONT = 'Times-Roman'
|
22
|
-
|
23
|
-
TEXT_BOX_RADIUS = 2
|
24
|
-
TEXT_BOX_HEIGTH = 20
|
25
|
-
end
|
26
|
-
|
27
|
-
# Report is the base class for all reports, it encapsulates all logic for rendering
|
28
|
-
# report parts.
|
29
|
-
class Report
|
30
|
-
attr_reader :pdf, :data, :max_width, :max_height, :totals, :group_totals
|
31
|
-
attr_accessor :header_class, :header_other_pages_class, :x, :report_params,
|
32
|
-
:running_totals
|
33
|
-
|
34
|
-
def initialize(report_params)
|
35
|
-
@report_params = DEFAULT_REPORT_PARAMS.merge(report_params || {})
|
36
|
-
@running_totals = @report_params.delete(:running_totals) || []
|
37
|
-
@num_pages = 1
|
38
|
-
|
39
|
-
@pdf = Prawn::Document.new(@report_params)
|
40
|
-
|
41
|
-
@pdf.font(DEFAULT_FONT)
|
42
|
-
@pdf.line_width = LINE_WIDTH
|
43
|
-
|
44
|
-
if @report_params[:page_size].is_a?(String)
|
45
|
-
if @report_params[:page_layout] == :portrait
|
46
|
-
w, h = *Prawn::Document::PageGeometry::SIZES[@report_params[:page_size]]
|
47
|
-
else
|
48
|
-
h, w = *Prawn::Document::PageGeometry::SIZES[@report_params[:page_size]]
|
49
|
-
end
|
50
|
-
else
|
51
|
-
w, h = @report_params[:page_size]
|
52
|
-
end
|
53
|
-
@x = 0
|
54
|
-
@y = @max_height = h - (@report_params[:margin][0] + @report_params[:margin][2])
|
55
|
-
@max_width = w - (@report_params[:margin][1] + @report_params[:margin][3])
|
56
|
-
|
57
|
-
@footer_size = 0
|
58
|
-
@pdf.move_cursor_to(max_height - @report_params[:margin][2])
|
59
|
-
|
60
|
-
@header_class = @header_other_pages_class = @summary_band_class = @footer_class = nil
|
61
|
-
@totals = {}
|
62
|
-
@group_totals = {}
|
63
|
-
|
64
|
-
initialize_running_totals
|
65
|
-
end
|
66
|
-
|
67
|
-
def params
|
68
|
-
@report_params
|
69
|
-
end
|
70
|
-
|
71
|
-
def draw(data)
|
72
|
-
@data = data
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
c.nil? ? '' : c
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
1
|
+
#coding: utf-8
|
2
|
+
|
3
|
+
require 'prawn'
|
4
|
+
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + "/report_helpers")
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + "/report_info")
|
7
|
+
|
8
|
+
# This is the module for all classes in the prawn_report gem
|
9
|
+
module PrawnReport
|
10
|
+
unless defined? DEFAULT_REPORT_PARAMS
|
11
|
+
DEFAULT_REPORT_PARAMS = {:page_size => 'A4', :margin => [20, 20, 20, 20],
|
12
|
+
:page_layout => :portrait}
|
13
|
+
|
14
|
+
LABEL_SIZE = 6
|
15
|
+
TEXT_SIZE = 10
|
16
|
+
|
17
|
+
SECTION_SPACING = LABEL_SIZE + 4
|
18
|
+
|
19
|
+
LINE_WIDTH = 0.3
|
20
|
+
|
21
|
+
DEFAULT_FONT = 'Times-Roman'
|
22
|
+
|
23
|
+
TEXT_BOX_RADIUS = 2
|
24
|
+
TEXT_BOX_HEIGTH = 20
|
25
|
+
end
|
26
|
+
|
27
|
+
# Report is the base class for all reports, it encapsulates all logic for rendering
|
28
|
+
# report parts.
|
29
|
+
class Report
|
30
|
+
attr_reader :pdf, :data, :max_width, :max_height, :totals, :group_totals
|
31
|
+
attr_accessor :header_class, :header_other_pages_class, :x, :report_params,
|
32
|
+
:running_totals
|
33
|
+
|
34
|
+
def initialize(report_params)
|
35
|
+
@report_params = DEFAULT_REPORT_PARAMS.merge(report_params || {})
|
36
|
+
@running_totals = @report_params.delete(:running_totals) || []
|
37
|
+
@num_pages = 1
|
38
|
+
|
39
|
+
@pdf = Prawn::Document.new(@report_params)
|
40
|
+
|
41
|
+
@pdf.font(DEFAULT_FONT)
|
42
|
+
@pdf.line_width = LINE_WIDTH
|
43
|
+
|
44
|
+
if @report_params[:page_size].is_a?(String)
|
45
|
+
if @report_params[:page_layout] == :portrait
|
46
|
+
w, h = *Prawn::Document::PageGeometry::SIZES[@report_params[:page_size]]
|
47
|
+
else
|
48
|
+
h, w = *Prawn::Document::PageGeometry::SIZES[@report_params[:page_size]]
|
49
|
+
end
|
50
|
+
else
|
51
|
+
w, h = @report_params[:page_size]
|
52
|
+
end
|
53
|
+
@x = 0
|
54
|
+
@y = @max_height = h - (@report_params[:margin][0] + @report_params[:margin][2])
|
55
|
+
@max_width = w - (@report_params[:margin][1] + @report_params[:margin][3])
|
56
|
+
|
57
|
+
@footer_size = 0
|
58
|
+
@pdf.move_cursor_to(max_height - @report_params[:margin][2])
|
59
|
+
|
60
|
+
@header_class = @header_other_pages_class = @summary_band_class = @footer_class = nil
|
61
|
+
@totals = {}
|
62
|
+
@group_totals = {}
|
63
|
+
|
64
|
+
initialize_running_totals
|
65
|
+
end
|
66
|
+
|
67
|
+
def params
|
68
|
+
@report_params
|
69
|
+
end
|
70
|
+
|
71
|
+
def draw(data)
|
72
|
+
@data = data
|
73
|
+
|
74
|
+
draw_header_first_page
|
75
|
+
draw_internal
|
76
|
+
draw_summary
|
77
|
+
draw_footer
|
78
|
+
|
79
|
+
second_pass
|
80
|
+
|
81
|
+
@pdf.close_and_stroke
|
82
|
+
@pdf.render
|
83
|
+
end
|
84
|
+
|
85
|
+
def new_page(print_titles = true)
|
86
|
+
draw_footer
|
87
|
+
|
88
|
+
@num_pages += 1
|
89
|
+
@pdf.start_new_page
|
90
|
+
@x = 0
|
91
|
+
@pdf.move_down(@report_params[:margin][0])
|
92
|
+
|
93
|
+
draw_header_other_pages
|
94
|
+
end
|
95
|
+
|
96
|
+
def fill_color(color)
|
97
|
+
@pdf.fill_color color
|
98
|
+
@pdf.fill_rectangle [x,y], max_width, 15
|
99
|
+
@pdf.fill_color '000000'
|
100
|
+
end
|
101
|
+
|
102
|
+
protected
|
103
|
+
|
104
|
+
def draw_header_first_page
|
105
|
+
draw_header(@header_class)
|
106
|
+
end
|
107
|
+
|
108
|
+
def draw_header_other_pages
|
109
|
+
draw_header(@header_other_pages_class || @header_class)
|
110
|
+
end
|
111
|
+
|
112
|
+
def draw_header(klass)
|
113
|
+
if klass
|
114
|
+
header = klass.new(self)
|
115
|
+
header.draw
|
116
|
+
@pdf.y = @max_height - header.height
|
117
|
+
@x = 0
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def draw_footer
|
122
|
+
if @footer_class
|
123
|
+
footer = @footer_class.new(self)
|
124
|
+
@pdf.move_cursor_to(@footer_class.height)
|
125
|
+
footer.draw
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def draw_summary
|
130
|
+
if @summary_class
|
131
|
+
summary = @summary_class.new(self)
|
132
|
+
summary.draw
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def draw_group_summary
|
137
|
+
if @report_params[:group] && @report_params[:group][:summary_class]
|
138
|
+
summary = @report_params[:group][:summary_class].new(self)
|
139
|
+
summary.draw
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def draw_group_header
|
144
|
+
if @report_params[:group][:header_class]
|
145
|
+
header = @report_params[:group][:header_class].new(self)
|
146
|
+
header.draw
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def second_pass
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
def run_totals(data_row)
|
155
|
+
@running_totals.each do |rt|
|
156
|
+
vl= get_raw_field_value(data_row,rt)
|
157
|
+
vl= (vl.is_a?(String) ? vl.to_f : vl)
|
158
|
+
@totals[rt] = (@totals[rt] || 0) + (vl == '' ? 0 : vl)
|
159
|
+
@group_totals[rt] = (@group_totals[rt] || 0) + (vl == '' ? 0 : vl)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def initialize_running_totals
|
164
|
+
@running_totals.each do |rt|
|
165
|
+
@totals[rt] = 0
|
166
|
+
@group_totals[rt] = 0
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def reset_group_totals
|
171
|
+
@running_totals.each do |rt|
|
172
|
+
@group_totals[rt] = 0
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def reset_totals
|
177
|
+
@running_totals.each do |rt|
|
178
|
+
@totals[rt] = 0
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def get_raw_field_value(row, column_name)
|
183
|
+
c = row
|
184
|
+
column_name.split('.').each {|n| c = c[n] if c}
|
185
|
+
c.nil? ? '' : c
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|