4 "\n\t<!-- " _ x _ " -->\n";
7 MACRO logme(a) PROCESS logme_block x = a.list.join(', ');
16 USE config = XML.LibXML(config_xml);
18 dir = '/reporter/setup/files/' _ stage_dir;
19 dir = config.findvalue(dir);
21 dbname = config.findvalue('/reporter/setup/database/name');
22 dbhost = config.findvalue('/reporter/setup/database/host');
23 d_u = config.findvalue('/reporter/setup/database/user');
24 d_p = config.findvalue('/reporter/setup/database/password');
26 dsn = "dbi:Pg:dbname=" _ dbname _';host=' _ dbhost;
30 DBI.connect(dsn,d_u,d_p);
35 [% INCLUDE header.ttk title="Basic Report Types" %]
37 [% INCLUDE logout.ttk %]
38 [% IF !CGI.param('id') %]
39 [% IF CGI.param('detail') %]
40 |<a href="?detail=0">No Details (All)</a>
42 |<a href="?detail=1">Details (All)</a>
44 [% PROCESS all_stage1 %]
46 [% PROCESS one_stage1 IF CGI.param('id') %]
48 [% INCLUDE footer.ttk %]
57 [% BLOCK one_stage1 %]
59 url('-absolute',1,'-path_info',1,'-query',1).
60 replace('&?id=\d+','') %]">Show all</a>
61 [% uid = DBI.quote(user.id());
62 rid = DBI.quote(CGI.param('id'));
63 q = "select * from reporter.stage1 where (pub is true or owner = $uid) and id = $rid;";
64 FOR s1 IN DBI.query(q);
65 file = dir _ '/' _ s1.filename;
66 USE doc = XML.LibXML(file);
68 fact_table = doc.findvalue('//report/@fact-table');
71 PROCESS stage1_summary;
72 PROCESS stage2_new IF CGI.param('create_stage2') == 1;
80 uid = DBI.quote(user.id());
81 FOR s1 IN DBI.query("select * from reporter.stage1 where pub is true or owner = $uid;");
82 file = dir _ '/' _ s1.filename;
83 USE doc = XML.LibXML(file);
85 fact_table = doc.findvalue('//report/@fact-table');
88 PROCESS stage1_summary links = 1;
90 IF loop.count != loop.size;
97 [% BLOCK stage1_summary links=0 %]
104 [%doc.findvalue('/reporter/report/@name')%]
112 [%doc.findvalue('/reporter/report/description')%]
120 [% IF CGI.param('detail') %]
121 <a href="?detail=0&id=[% s1.id %]">No Details</a>
123 <a href="?detail=1&id=[% s1.id %]">Details</a>
125 |<a href="?create_stage2=1&id=[% s1.id %]">New Report Template</a>
128 [% PROCESS stage1_detail IF CGI.param('detail') == 1 %]
135 col_xpath = "/reporter/tables/table[@id='" _ fact_table _ "']/fields/field[@core='true']";
138 '<h3><u>Core report limiters</u></h3>';
140 FOR col IN config.findnodes(col_xpath);
141 logme(col.findvalue('@name'));
142 widget = col.findvalue('@widget') or col.findvalue('@datatype');
143 INCLUDE "draw_$widget" column = col;
152 [% BLOCK draw_timestamptz %]
153 [% varname = column.parentNode.parentNode.findvalue('tablename') _ '.' _ column.findvalue('@name') %]
155 <b>[% column.findvalue('label') %]</b><br/><br/>
156 <table border=1 width="100%">
159 <b>[% column.findvalue('description') %]</b>
169 <option value="[% varname %]:">Any</option>
170 <option value="[% varname %]:hour">Hour</option>
171 <option value="[% varname %]:day">Day</option>
172 <option value="[% varname %]:week">Week</option>
173 <option value="[% varname %]:month">Month</option>
174 <option value="[% varname %]:year">Year</option>
175 <option value="[% varname %]:decade">Decade</option>
185 [% BLOCK dim_description %]
187 <td align="right">Name:</td>
188 <td>[% dim.findvalue('name') %]</td>
190 [% PROCESS table_fields table = dim %]
198 [% BLOCK table_fields %]
199 [% FOR f IN table.findnodes('fields/field') %]
201 <td align="right">Field:</td>
202 <td>[% f.findvalue('@name') %] ([% f.findvalue('@datatype') %])</td>
212 [% BLOCK stage1_detail %]
215 Visible Stage2 reports:
218 [% q = 'select count(*) as x from reporter.stage2 ' _
219 'where pub is true or owner = ' _ DBI.quote(user.id());
220 FOR r IN DBI.query(q);
226 [% PROCESS table_fields table = config.findnodes("/reporter/tables/table[@id='$fact_table']") %]
230 Report Attributes<br/>(dimensions):
234 incs = doc.findnodes('//report/dims/dim/@include');
237 '<table border=1 width="100%">';
239 link_xpath = '/reporter/tables/table[@id="' _ fact_table _'"]'_
240 '/links/link[@field="' _ dim.value() _ '"]/@table';
243 dim_table = config.findvalue(link_xpath);
245 dim_xpath = '/reporter/tables/table[@id="' _ dim_table _'"]';
248 dim_def = config.findnodes(dim_xpath);
250 PROCESS dim_description dim = dim_def;