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