]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/reporter/templates/stage1.ttk
0e8bbee763994aed37577eefa94e8c17619d0bf5
[Evergreen.git] / Open-ILS / src / reporter / templates / stage1.ttk
1 [%
2
3 BLOCK logme_block;
4         "\n\t<!-- " _ x _ " -->\n";
5 END;
6
7 MACRO logme(a) PROCESS logme_block x = a.list.join(', ');
8
9 %]
10
11 [%
12         USE CGI;
13         USE DBI;
14         USE WebSession;
15         USE utils = WebUtils;
16         USE config = XML.LibXML(config_xml);
17
18         userid = 1;
19
20         dir = '/reporter/setup/files/' _ stage_dir;
21         dir = config.findvalue(dir);
22
23         dbname = config.findvalue('/reporter/setup/database/name');
24         dbhost = config.findvalue('/reporter/setup/database/host');
25         d_u = config.findvalue('/reporter/setup/database/user');
26         d_p = config.findvalue('/reporter/setup/database/password');
27
28         dsn = "dbi:Pg:dbname=" _ dbname _';host=' _ dbhost;
29
30         logme([dsn,d_u,d_p]);
31         
32         DBI.connect(dsn,d_u,d_p);
33 %]
34
35
36 <html>
37         [% INCLUDE header.ttk title="Basic Report Types" %]     
38         <body>
39                 [% INCLUDE logout.ttk %]
40                 [% PROCESS PRINT_STAGE1 %]
41         </body>
42         [% INCLUDE footer.ttk %]        
43 </html>
44
45
46
47
48
49
50
51 [% BLOCK PRINT_STAGE1 %]
52                 <table width="50%">
53 [%                      FOR s1 IN DBI.query("select * from reporter.stage1 where pub is true;");
54                                 file = dir _ '/' _ s1.filename;
55                                 USE doc = XML.LibXML(file);
56                                 fact_table = doc.findvalue('//report/@fact-table');
57                                 logme(fact_table);
58 %]
59
60                                 <tr>
61                                         <td align="right">
62                                                 <b>Name:</b>
63                                         </td>
64                                         <td>
65                                                 [%doc.findvalue('/reporter/report/@name')%]
66                                         </td>
67                                 </tr>
68                                 <tr>
69                                         <td align="right">
70                                                 <b>Description:</b>
71                                         </td>
72                                         <td>
73                                                 [%doc.findvalue('/reporter/report/description')%]
74                                         </td>
75                                 </tr>
76
77 [%                              PROCESS stage1_detail IF CGI.param('detail') == 1 %]
78
79 [%                      END %]
80                 </table>
81 [% END %]
82
83 [% PROCESS stage2_new IF CGI.param('create_stage2') == 1 %]
84
85
86
87
88
89 [%
90 BLOCK stage2_new;
91         col_xpath = "/reporter/tables/table[@id='" _ fact_table _ "']/fields/field[@core='true']";
92         logme(col_xpath);
93
94         '<h3><u>Core report limiters</u></h3>';
95
96         FOR col IN config.findnodes(col_xpath);
97                 logme(col.findvalue('@name'));
98                 widget = col.findvalue('@widget') or col.findvalue('@datatype');
99                 INCLUDE "draw_$widget" column = col; 
100         END;
101
102 END;
103 %]
104
105
106
107
108 [% BLOCK draw_timestamptz %]
109
110 <b>[% column.findvalue('label') %]</b><br/><br/>
111 <table border=1 width="100%">
112         <tr>
113                 <td colspan=2>
114                         <b>[% column.findvalue('description') %]</b>
115                 </td>
116         </tr>
117         <tr>
118                 <td>
119                         Report Range Size:
120                 </td>
121                 <td>
122                         <select
123                                 name="[% column.parentNode.parentNode.findvalue('tablename') _ '.' _
124                                                         column.findvalue('@name') _ ':range_size' %]" >
125                                 <option value="">User Selectable</option>
126                                 <option value="hour">Hour</option>
127                                 <option value="day">Day</option>
128                                 <option value="week">Week</option>
129                                 <option value="month">Month</option>
130                                 <option value="year">Year</option>
131                                 <option value="decade">Decade</option>
132                         </select>
133                 </td>
134         </tr>
135 [% END %]
136
137
138
139
140 [% BLOCK dim_description %]
141
142 <tr>
143         <td>Name:</td>
144         <td>[% dim.findvalue('name') %]</td>
145 </tr>
146 [% PROCESS table_fields table = dim %]
147 [% END %]
148
149
150
151
152
153
154 [% BLOCK table_fields %]
155 [%              FOR f IN table.findnodes('fields/field') %]
156 <tr>
157         <td>Field:</td>
158         <td>[% f.findvalue('@name') %] ([% f.findvalue('@datatype') %])</td>
159 </tr>
160 [%              END %]
161
162 [% END %]
163
164
165
166
167
168
169
170
171 [% BLOCK stage1_detail %]
172                                 <tr>
173                                         <td>
174                                                 Visible Stage2 reports:
175                                         </td>
176                                         <td>
177                                                 [% q = 'select count(*) as x from reporter.stage2 ' _
178                                                                 'where pub is true or owner = ' _ userid;
179                                                 FOR r IN DBI.query(q);
180                                                         r.x;
181                                                 END %]
182                                         </td>
183                                 </tr>
184
185 [% PROCESS table_fields table = config.findnodes("/reporter/tables/table[@id='$fact_table']") %]
186                                 <tr>
187                                         <td>
188                                                 Report Attributes<br/>(dimensions):
189                                         </td>
190                                         <td>
191 [%
192                                                 incs = doc.findnodes('//report/dims/dim/@include');
193
194                                                 FOR dim IN incs;
195                                                         '<table border=1 width="100%">';
196
197                                                         link_xpath = '/reporter/tables/table[@id="' _ fact_table _'"]'_
198                                                                                                 '/links/link[@field="' _ dim.value() _ '"]/@table';
199                                                         logme(link_xpath);
200
201                                                         dim_table = config.findvalue(link_xpath);
202
203                                                         dim_xpath = '/reporter/tables/table[@id="' _ dim_table _'"]';
204                                                         logme(dim_xpath);
205                                                         
206                                                         dim_def = config.findnodes(dim_xpath);
207
208                                                         PROCESS dim_description dim = dim_def;
209                                                         '</table>';
210                                                 END
211 %]
212                                         </td>
213                                 </tr>
214 [%                      END %]
215
216