4 "\n\t<!-- " _ x _ " -->\n";
7 MACRO logme(a) PROCESS logme_block x = a.list.join(', ');
13 USE config = XML.LibXML(config_xml, expand_xinclude => 1);
15 dir = '/reporter/setup/files/' _ stage_dir;
16 dir = config.findvalue(dir);
18 dbname = config.findvalue('/reporter/setup/database/name');
19 dbhost = config.findvalue('/reporter/setup/database/host');
20 d_u = config.findvalue('/reporter/setup/database/user');
21 d_p = config.findvalue('/reporter/setup/database/password');
23 dsn = "dbi:Pg:dbname=" _ dbname _';host=' _ dbhost;
27 DBI.connect(dsn,d_u,d_p);
31 INCLUDE header.ttk title="Basic Report Types";
35 IF CGI.param('detail');
36 %]|<a href="?detail=0">No Details (All)</a>[%
38 %]|<a href="?detail=1">Details (All)</a>[%
51 #=============================================================================
56 CGI.url('-absolute',1,'-path_info',1,'-query',1).replace('&?id=\d+','');
59 uid = DBI.quote(user.id());
60 rid = DBI.quote(CGI.param('id'));
62 q = "select * from reporter.stage1 where (pub is true or owner = $uid) and id = $rid;";
63 FOR s1 IN DBI.query(q);
64 file = dir _ '/' _ s1.filename;
65 USE doc = XML.LibXML(file);
67 fact_table = doc.findvalue('//report/@fact-table');
70 PROCESS stage1_summary;
71 PROCESS stage2_new IF CGI.param('create_stage2') == 1;
81 uid = DBI.quote(user.id());
82 FOR s1 IN DBI.query("select * from reporter.stage1 where pub is true or owner = $uid;");
84 file = dir _ '/' _ s1.filename;
85 USE doc = XML.LibXML(file);
87 fact_table = doc.findvalue('//report/@fact-table');
90 PROCESS stage1_summary links = 1;
92 IF loop.count != loop.size;
102 BLOCK stage1_summary links=0;
103 WRAPPER html/table width="100%";
105 WRAPPER html/cell align="right";
109 doc.findvalue('/reporter/report/@name');
113 WRAPPER html/cell align="right";
114 %]<b>Description:</b>[%
117 doc.findvalue('/reporter/report/description');
121 WRAPPER html/cell align="right";
125 IF CGI.param('detail');
126 %]<a href="?detail=0&id=[% s1.id %]">No Details</a>[%
128 %]<a href="?detail=1&id=[% s1.id %]">Details</a>[%
130 %]|<a href="?create_stage2=1&id=[% s1.id %]">New Report Template</a>[%
133 PROCESS stage1_detail IF CGI.param('detail') == 1;
141 col_xpath = "/reporter/tables/table[@id='" _ fact_table _ "']/fields/field[@core='true']";
144 WRAPPER html/table width="100%" border=1;
146 WRAPPER html/cell colspan=2;
147 # hidden input here ...
148 table = config.findnodes("/reporter/tables/table[@id='$fact_table']");
149 INCLUDE hidden name="filtertable" value=fact_table;
150 table.findvalue('label');
154 INCLUDE widget_selector tableid=fact_table columns=config.findnodes(col_xpath) force=1;
157 dim_xpath = "/reporter/tables/table[@id='$fact_table']/links/link/@table";
158 FOR dim_table IN config.findnodes(dim_xpath);
159 dim_table = dim_table.value();
160 dimension = config.findnodes("/reporter/tables/table[@id='$dim_table']");
162 WRAPPER html/table width="100%" border=1;
164 WRAPPER html/cell colspan=2;
165 # checkbox input here ...
166 INCLUDE checkbox name="filtertable" value=dim_table checked=1;
167 dimension.findvalue('label');
171 INCLUDE widget_selector tableid=dim_table;
178 BLOCK widget_selector;
180 logme("widget_selector called for table $tableid");
182 # if we got some columns, use them. if not, get all non-primary columns
185 '/reporter/tables/table[@id="' _ tableid _
186 '"]/fields/field[not(@primary) or @primary!="true"]'
187 columns = config.findnodes(columns_xpath);
188 logme("widget_selector had to grab columns for table $tableid!");
191 column_input_type="checkbox";
193 column_input_type="hidden";
196 FOR column IN columns;
197 column_name=column.findvalue('@name');
200 WRAPPER html/cell valign='top';
201 # checkbox for column filter here ...
202 INCLUDE $column_input_type
203 name="filtercolumn:$tableid"
206 column.findvalue('label');
210 col_widget_fams_xpath =
211 '/reporter/widgets/widget-family[@datatype="' _
212 column.findvalue('@datatype') _ '"]';
214 IF column.findnodes('@widget-family');
215 col_widget_fams_xpath =
216 '/reporter/widgets/widget-family[@name="' _
217 column.findvalue('@widget-family') _ '"]';
220 logme("finding widget families using $col_widget_fams_xpath");
222 widget_fams = config.findnodes(col_widget_fams_xpath);
225 FOR fam IN widget_fams;
229 fam_input = 'hidden';
237 fam_name = fam.findvalue('@name');
238 # radio for widget family here ...
241 name="filterfamily:$tableid:$column_name"
243 fam.findvalue('label');
246 FOR widget IN fam.findnodes('widget');
250 fam_input = 'hidden';
258 widget_name = widget.findvalue('@name');
259 # radio for widget here ...
262 name="filter:$tableid:$column_name:$fam_name"
264 widget.findvalue('label');
286 %]<INPUT TYPE="text" NAME="[%
295 %]MAXLENGTH="[% mx %]" [%
301 %]<TEXTAREA NAME="[% name %]">[% value %]</TEXTAREA>[%
305 %]<INPUT TYPE="hidden" NAME="[% name %]" VALUE="[% value %]">[%
309 %]<INPUT TYPE="radio" NAME="[% name %]" VALUE="[% value %]" [% IF checked %]CHECKED[% END %]>[%
313 %]<INPUT TYPE="checkbox" NAME="[% name %]" VALUE="[% value %]" [% IF checked %]CHECKED[% END %]>[%
319 BLOCK render_dimension;
320 INCLUDE checkbox checked = 1 name = 's2_dim_table' value = dim_object.findvalue('@id');
321 %]<b>[% dim_object.findvalue('name') %]</b><br>[%
323 WRAPPER html/table width="100%" ;
325 WRAPPER html/cell align="right";
335 BLOCK dim_description;
337 WRAPPER html/cell align="right";
341 dim.findvalue('name');
344 PROCESS table_fields table = dim;
353 FOR f IN table.findnodes('fields/field');
355 WRAPPER html/cell align="right";
359 f.findvalue('@name');
360 %] ([% f.findvalue('@datatype') %])[%
373 WRAPPER html/cell align="right";
374 %]Visible Stage2 reports:[%
377 q = 'select count(*) as x from reporter.stage2 ' _
378 'where pub is true or owner = ' _ DBI.quote(user.id());
379 FOR r IN DBI.query(q);
385 PROCESS table_fields table = config.findnodes("/reporter/tables/table[@id='$fact_table']");
388 WRAPPER html/cell align="right";
389 %]Report Attributes<br/>(dimensions):[%
392 incs = doc.findnodes('//report/dims/dim/@include');
395 %]<table border=1 width="100%">[%
397 link_xpath = '/reporter/tables/table[@id="' _ fact_table _'"]'_
398 '/links/link[@field="' _ dim.value() _ '"]/@table';
401 dim_table = config.findvalue(link_xpath);
403 dim_xpath = '/reporter/tables/table[@id="' _ dim_table _'"]';
406 dim_def = config.findnodes(dim_xpath);
408 PROCESS dim_description dim = dim_def;