lolita-report 0.0.2
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.
- data/.document +5 -0
- data/Gemfile +18 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/app/controllers/lolita/reports_controller.rb +18 -0
- data/app/views/components/lolita/configuration/report/_display.html.erb +1 -0
- data/app/views/lolita/reports/show.html.erb +9 -0
- data/author +1 -0
- data/doc/ActiveSupport.html +167 -0
- data/doc/ActiveSupport/TestCase.html +168 -0
- data/doc/Comment.html +184 -0
- data/doc/Gemfile.html +157 -0
- data/doc/LICENSE.html +111 -0
- data/doc/Lolita.html +184 -0
- data/doc/Lolita/Configuration.html +178 -0
- data/doc/Lolita/Configuration/Report.html +837 -0
- data/doc/Lolita/Configuration/Reports.html +413 -0
- data/doc/LolitaReport.html +194 -0
- data/doc/LolitaReport/Configuration.html +250 -0
- data/doc/Post.html +183 -0
- data/doc/Rakefile.html +124 -0
- data/doc/author.html +111 -0
- data/doc/created.rid +15 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +126 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/lib/lolita-report/configuration/base_rb.html +61 -0
- data/doc/lib/lolita-report/configuration/report_rb.html +57 -0
- data/doc/lib/lolita-report/configuration/reports_rb.html +55 -0
- data/doc/lib/lolita-report/version_rb.html +52 -0
- data/doc/lib/lolita-report_rb.html +58 -0
- data/doc/rdoc.css +706 -0
- data/doc/spec/configuration/report_spec_rb.html +56 -0
- data/doc/spec/configuration/reports_spec_rb.html +56 -0
- data/doc/spec/factories/factories_rb.html +52 -0
- data/doc/spec/orm/mongoid_rb.html +56 -0
- data/doc/spec/spec_helper_rb.html +58 -0
- data/lib/lolita-report.rb +33 -0
- data/lib/lolita-report/configuration/base.rb +22 -0
- data/lib/lolita-report/configuration/report.rb +147 -0
- data/lib/lolita-report/configuration/reports.rb +42 -0
- data/lib/lolita-report/module.rb +1 -0
- data/lib/lolita-report/rails.rb +6 -0
- data/lib/lolita-report/routes.rb +15 -0
- data/lolita-report.gemspec +150 -0
- data/spec/configuration/report_spec.rb +87 -0
- data/spec/configuration/reports_spec.rb +40 -0
- data/spec/factories/factories.rb +7 -0
- data/spec/orm/mongoid.rb +27 -0
- data/spec/spec_helper.rb +38 -0
- metadata +259 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
8
|
+
|
|
9
|
+
<title>File: report_spec.rb [RDoc Documentation]</title>
|
|
10
|
+
|
|
11
|
+
<link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet" />
|
|
12
|
+
|
|
13
|
+
<script src="../../js/jquery.js" type="text/javascript"
|
|
14
|
+
charset="utf-8"></script>
|
|
15
|
+
<script src="../../js/thickbox-compressed.js" type="text/javascript"
|
|
16
|
+
charset="utf-8"></script>
|
|
17
|
+
<script src="../../js/quicksearch.js" type="text/javascript"
|
|
18
|
+
charset="utf-8"></script>
|
|
19
|
+
<script src="../../js/darkfish.js" type="text/javascript"
|
|
20
|
+
charset="utf-8"></script>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body class="file file-popup">
|
|
24
|
+
<div id="metadata">
|
|
25
|
+
<dl>
|
|
26
|
+
<dt class="modified-date">Last Modified</dt>
|
|
27
|
+
<dd class="modified-date">2011-03-23 09:25:59 +0200</dd>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<dt class="requires">Requires</dt>
|
|
31
|
+
<dd class="requires">
|
|
32
|
+
<ul>
|
|
33
|
+
|
|
34
|
+
</ul>
|
|
35
|
+
</dd>
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
</dl>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div id="documentation">
|
|
43
|
+
|
|
44
|
+
<div class="description">
|
|
45
|
+
<h2>Description</h2>
|
|
46
|
+
<p>
|
|
47
|
+
To change this template, choose Tools | Templates and open the template in
|
|
48
|
+
the editor.
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
</body>
|
|
55
|
+
</html>
|
|
56
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
8
|
+
|
|
9
|
+
<title>File: reports_spec.rb [RDoc Documentation]</title>
|
|
10
|
+
|
|
11
|
+
<link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet" />
|
|
12
|
+
|
|
13
|
+
<script src="../../js/jquery.js" type="text/javascript"
|
|
14
|
+
charset="utf-8"></script>
|
|
15
|
+
<script src="../../js/thickbox-compressed.js" type="text/javascript"
|
|
16
|
+
charset="utf-8"></script>
|
|
17
|
+
<script src="../../js/quicksearch.js" type="text/javascript"
|
|
18
|
+
charset="utf-8"></script>
|
|
19
|
+
<script src="../../js/darkfish.js" type="text/javascript"
|
|
20
|
+
charset="utf-8"></script>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body class="file file-popup">
|
|
24
|
+
<div id="metadata">
|
|
25
|
+
<dl>
|
|
26
|
+
<dt class="modified-date">Last Modified</dt>
|
|
27
|
+
<dd class="modified-date">2011-03-09 10:42:00 +0200</dd>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<dt class="requires">Requires</dt>
|
|
31
|
+
<dd class="requires">
|
|
32
|
+
<ul>
|
|
33
|
+
|
|
34
|
+
</ul>
|
|
35
|
+
</dd>
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
</dl>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div id="documentation">
|
|
43
|
+
|
|
44
|
+
<div class="description">
|
|
45
|
+
<h2>Description</h2>
|
|
46
|
+
<p>
|
|
47
|
+
To change this template, choose Tools | Templates and open the template in
|
|
48
|
+
the editor.
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
</body>
|
|
55
|
+
</html>
|
|
56
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
8
|
+
|
|
9
|
+
<title>File: factories.rb [RDoc Documentation]</title>
|
|
10
|
+
|
|
11
|
+
<link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet" />
|
|
12
|
+
|
|
13
|
+
<script src="../../js/jquery.js" type="text/javascript"
|
|
14
|
+
charset="utf-8"></script>
|
|
15
|
+
<script src="../../js/thickbox-compressed.js" type="text/javascript"
|
|
16
|
+
charset="utf-8"></script>
|
|
17
|
+
<script src="../../js/quicksearch.js" type="text/javascript"
|
|
18
|
+
charset="utf-8"></script>
|
|
19
|
+
<script src="../../js/darkfish.js" type="text/javascript"
|
|
20
|
+
charset="utf-8"></script>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body class="file file-popup">
|
|
24
|
+
<div id="metadata">
|
|
25
|
+
<dl>
|
|
26
|
+
<dt class="modified-date">Last Modified</dt>
|
|
27
|
+
<dd class="modified-date">2011-03-16 12:44:19 +0200</dd>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<dt class="requires">Requires</dt>
|
|
31
|
+
<dd class="requires">
|
|
32
|
+
<ul>
|
|
33
|
+
|
|
34
|
+
</ul>
|
|
35
|
+
</dd>
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
</dl>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div id="documentation">
|
|
43
|
+
|
|
44
|
+
<div class="description">
|
|
45
|
+
<h2>Description</h2>
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
</div>
|
|
50
|
+
</body>
|
|
51
|
+
</html>
|
|
52
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
8
|
+
|
|
9
|
+
<title>File: mongoid.rb [RDoc Documentation]</title>
|
|
10
|
+
|
|
11
|
+
<link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet" />
|
|
12
|
+
|
|
13
|
+
<script src="../../js/jquery.js" type="text/javascript"
|
|
14
|
+
charset="utf-8"></script>
|
|
15
|
+
<script src="../../js/thickbox-compressed.js" type="text/javascript"
|
|
16
|
+
charset="utf-8"></script>
|
|
17
|
+
<script src="../../js/quicksearch.js" type="text/javascript"
|
|
18
|
+
charset="utf-8"></script>
|
|
19
|
+
<script src="../../js/darkfish.js" type="text/javascript"
|
|
20
|
+
charset="utf-8"></script>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body class="file file-popup">
|
|
24
|
+
<div id="metadata">
|
|
25
|
+
<dl>
|
|
26
|
+
<dt class="modified-date">Last Modified</dt>
|
|
27
|
+
<dd class="modified-date">2011-03-21 17:44:01 +0200</dd>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<dt class="requires">Requires</dt>
|
|
31
|
+
<dd class="requires">
|
|
32
|
+
<ul>
|
|
33
|
+
|
|
34
|
+
<li>mongoid</li>
|
|
35
|
+
|
|
36
|
+
<li>ruport</li>
|
|
37
|
+
|
|
38
|
+
</ul>
|
|
39
|
+
</dd>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
</dl>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div id="documentation">
|
|
47
|
+
|
|
48
|
+
<div class="description">
|
|
49
|
+
<h2>Description</h2>
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
</body>
|
|
55
|
+
</html>
|
|
56
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
8
|
+
|
|
9
|
+
<title>File: spec_helper.rb [RDoc Documentation]</title>
|
|
10
|
+
|
|
11
|
+
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet" />
|
|
12
|
+
|
|
13
|
+
<script src="../js/jquery.js" type="text/javascript"
|
|
14
|
+
charset="utf-8"></script>
|
|
15
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript"
|
|
16
|
+
charset="utf-8"></script>
|
|
17
|
+
<script src="../js/quicksearch.js" type="text/javascript"
|
|
18
|
+
charset="utf-8"></script>
|
|
19
|
+
<script src="../js/darkfish.js" type="text/javascript"
|
|
20
|
+
charset="utf-8"></script>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body class="file file-popup">
|
|
24
|
+
<div id="metadata">
|
|
25
|
+
<dl>
|
|
26
|
+
<dt class="modified-date">Last Modified</dt>
|
|
27
|
+
<dd class="modified-date">2011-03-22 11:21:41 +0200</dd>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<dt class="requires">Requires</dt>
|
|
31
|
+
<dd class="requires">
|
|
32
|
+
<ul>
|
|
33
|
+
|
|
34
|
+
<li>rubygems</li>
|
|
35
|
+
|
|
36
|
+
<li>abstract</li>
|
|
37
|
+
|
|
38
|
+
<li>factory_girl_rails</li>
|
|
39
|
+
|
|
40
|
+
</ul>
|
|
41
|
+
</dd>
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
</dl>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div id="documentation">
|
|
49
|
+
|
|
50
|
+
<div class="description">
|
|
51
|
+
<h2>Description</h2>
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
</div>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
58
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
$:<<File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
|
|
2
|
+
#require 'lolita'
|
|
3
|
+
require "lolita-report/configuration/base"
|
|
4
|
+
require "lolita-report/rails"
|
|
5
|
+
require "ruport"
|
|
6
|
+
require "spreadsheet"
|
|
7
|
+
module Lolita
|
|
8
|
+
module Report
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
module Configuration
|
|
12
|
+
autoload(:Reports,"lolita-report/configuration/reports")
|
|
13
|
+
autoload(:Report,"lolita-report/configuration/report")
|
|
14
|
+
#Lolita::Configuration::Base.send(:include,LolitaReport::Configuration)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
require "lolita-report/module.rb"
|
|
18
|
+
|
|
19
|
+
Lolita::Navigation::Tree.after_branch_added do
|
|
20
|
+
if self.name==:"left_side_navigation"
|
|
21
|
+
if @last_branch && @last_branch.object && @last_branch.object.is_a?(Lolita::Mapping)
|
|
22
|
+
if @last_branch.object.to.lolita.reports.any?
|
|
23
|
+
@last_branch.object.to.lolita.reports.each do |report|
|
|
24
|
+
unless @last_branch.children.branches.detect{|b| b.options[:report_name]==report.name}
|
|
25
|
+
@last_branch.append(report,:title=>report.title,:report_name=>report.name,:url=>Proc.new{
|
|
26
|
+
send(lolita_resource_name(:action=>:reports,:plural=>true),:name=>report.name)
|
|
27
|
+
})
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Every class that include Lolita::Configuration this module assign
|
|
2
|
+
# #lolita and #lolita= methods. First one is for normal Lolita configuration
|
|
3
|
+
# definition, and the other one made to assing Lolita to class as a Lolita::Configuration::Base
|
|
4
|
+
# object. You may want to do that to change configuration or for testing purpose.
|
|
5
|
+
|
|
6
|
+
module Lolita
|
|
7
|
+
module Configuration
|
|
8
|
+
|
|
9
|
+
class Base
|
|
10
|
+
# Container for reports
|
|
11
|
+
def reports &block
|
|
12
|
+
Lolita::LazyLoader.lazy_load(self,:@reports,Lolita::Configuration::Reports,@dbi,&block)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Container for report
|
|
16
|
+
def report *args, &block
|
|
17
|
+
self.reports << Lolita::Configuration::Report.new(@dbi,*args,&block)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Lolita::Configuration::Report class contain methods for generating report
|
|
2
|
+
|
|
3
|
+
module Lolita
|
|
4
|
+
module Configuration
|
|
5
|
+
class Report
|
|
6
|
+
include Lolita::Builder
|
|
7
|
+
|
|
8
|
+
lolita_accessor :title,:name,:total_columns, :table,:fields
|
|
9
|
+
|
|
10
|
+
def initialize(dbi,title=nil, &block)
|
|
11
|
+
|
|
12
|
+
@dbi=dbi
|
|
13
|
+
@fields=[]
|
|
14
|
+
@title=title
|
|
15
|
+
self.instance_eval(&block) if block_given?
|
|
16
|
+
raise ArgumentError, "Report must have title" unless @title
|
|
17
|
+
set_default_values
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Set data for counting.
|
|
21
|
+
def total(*args)
|
|
22
|
+
@collumns_for_counting=args if args
|
|
23
|
+
@collumns_for_counting
|
|
24
|
+
end
|
|
25
|
+
# Return columns in array, which are needed counted.
|
|
26
|
+
def total_columns
|
|
27
|
+
@collumns_for_counting
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Set a title for report.
|
|
31
|
+
def name value=nil
|
|
32
|
+
@name=value if value
|
|
33
|
+
@name
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def field *args, &block
|
|
37
|
+
@fields<<Lolita::Configuration::Field::Base.new(@dbi,*args,&block)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def fields *args
|
|
41
|
+
if args
|
|
42
|
+
@fields=[]
|
|
43
|
+
args.each{|f| field(f)}
|
|
44
|
+
end
|
|
45
|
+
@fields
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def file_name ext
|
|
49
|
+
"#{self.title} at #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}.#{ext}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Return fields for displaying in report.
|
|
53
|
+
def custom_fields
|
|
54
|
+
@fields if @fields
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Generate table for report, which contain all necessary data
|
|
58
|
+
def generate_table_for_report
|
|
59
|
+
self.create_table
|
|
60
|
+
add_collumns_for_counting if collumns_for_counting_defined?
|
|
61
|
+
self.collect_data
|
|
62
|
+
@table
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# generate excel file with necessary data and formating
|
|
66
|
+
def to_xls response_type=:raw
|
|
67
|
+
book = Spreadsheet::Workbook.new
|
|
68
|
+
sheet1=book.create_worksheet
|
|
69
|
+
sheet1.name=self.title
|
|
70
|
+
sheet1.row(0).replace(@table[0].attributes.map(&:to_s))
|
|
71
|
+
1.upto(@table.size){|i|
|
|
72
|
+
sheet1.row(i).replace(@table[0].attributes.collect{|f| @table[i-1].data[f]})
|
|
73
|
+
}
|
|
74
|
+
table_header_format_for sheet1
|
|
75
|
+
set_columns_width_for sheet1
|
|
76
|
+
if response_type==:raw
|
|
77
|
+
blob = StringIO.new("")
|
|
78
|
+
book.write blob
|
|
79
|
+
blob.string
|
|
80
|
+
else
|
|
81
|
+
book.write self.file_name(:xls)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
protected
|
|
86
|
+
|
|
87
|
+
# set excel collumns width for sheet
|
|
88
|
+
def set_columns_width_for sheet
|
|
89
|
+
0.upto(@table[0].attributes.size-1){|i|
|
|
90
|
+
sheet.column(i).width=20
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# make format for excel table header
|
|
95
|
+
def table_header_format_for sheet
|
|
96
|
+
title_format = Spreadsheet::Format.new :pattern_bg_color=>:grey,
|
|
97
|
+
:weight => :bold,
|
|
98
|
+
:size => 12
|
|
99
|
+
sheet.row(0).default_format =title_format
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Make table,which contain all necessary data for report.
|
|
103
|
+
def create_table
|
|
104
|
+
@table = Table @fields.map{|f| f.title}
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Set all necessary data into table.
|
|
108
|
+
def collect_data
|
|
109
|
+
field_names=@fields.map{|f| f.name}
|
|
110
|
+
@dbi.find(:all).each{|record|
|
|
111
|
+
@table<<field_names.map{|f_name|
|
|
112
|
+
record.send(f_name)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Set necessary data in columns, where will bi counting something.
|
|
118
|
+
def set_data_in_counting_columns object
|
|
119
|
+
@collumns_for_counting.each{|method|
|
|
120
|
+
@hsh["#{method.to_s}_total"]=object.send(method).size
|
|
121
|
+
}
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Check if fields for counting are defined for report.
|
|
125
|
+
def collumns_for_counting_defined?
|
|
126
|
+
@collumns_for_counting.size>0 if @collumns_for_counting
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# For setting data for cuonting, necessary to add this collumns to table.
|
|
130
|
+
def add_collumns_for_counting
|
|
131
|
+
@collumns_for_counting.each{|method|
|
|
132
|
+
@table.add_column("#{method.to_s}_total",:default=>0) if @table
|
|
133
|
+
}
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def set_default_values
|
|
137
|
+
@name||="report_for_#{dbi.class.to_s}_#{self.__id__}"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
class << self
|
|
141
|
+
def formats
|
|
142
|
+
[:xls]
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|