[% PROCESS inputs; PROCESS logic_header.ttk; WRAPPER html/html; INCLUDE header.ttk title="Basic Report Types"; WRAPPER html/body html.body.onload= "if (document.getElementById('templatename')) {" _ "document.getElementById('templatename').focus();" _ "document.getElementById('templatename').select();}"; INCLUDE logout.ttk; IF !CGI.param('id'); IF CGI.param('detail'); %]|No Details (All)[% ELSE; %]|Details (All)[% END; PROCESS all_stage1; ELSE; PROCESS one_stage1; END; END; INCLUDE footer.ttk; END; #============================================================================= BLOCK one_stage1; %]|Show all[% table_xpath = '/reporter/tables/table[@id="' _ CGI.param('id') _ '"]'; table = config.findnodes(table_xpath); fact_table = table.findvalue('@id'); logme(fact_table); INCLUDE stage1_summary; INCLUDE stage2_new IF CGI.param('create_stage2') == 1; END; BLOCK all_stage1; ''; END; BLOCK stage1_summary links=0; fact_table = table.findvalue('@id'); WRAPPER html/table width="100%"; WRAPPER html/row; WRAPPER html/cell align="right"; %]Name:[% END; WRAPPER html/cell; table.findvalue('label'); END; END; WRAPPER html/row; WRAPPER html/cell align="right"; %]Description:[% END; WRAPPER html/cell; table.findvalue('description'); END; END; WRAPPER html/row; WRAPPER html/cell align="right"; %]Actions:[% END; WRAPPER html/cell; IF CGI.param('detail'); %]No Details[% ELSE; %]Details[% END; %]|New Report Template[% END; END; WRAPPER html/row; INCLUDE html/cell align="right" valign='top' content='Report Templates:'; WRAPPER html/cell; q = 'select * from reporter.stage2 ' _ 'where pub is true or owner = ' _ DBI.quote(user.id()); FOR r IN DBI.query(q); INCLUDE anchor href="stage2?id=" _ r.id text=utils.JSON2perl(r.params).templatename; '
'; END; END; END; PROCESS stage1_detail IF CGI.param('detail') == 1; END; END; %][% BLOCK stage2_new; col_xpath = "/reporter/tables/table[@id='" _ fact_table _ "']/fields/field[@core='true']"; logme(col_xpath); %]

Public template

[% WRAPPER html/table width="100%" border=1; WRAPPER html/row; WRAPPER html/cell colspan=2; # hidden input here ... table = config.findnodes("/reporter/tables/table[@id='$fact_table']"); INCLUDE hidden name="filter" value=fact_table; table.findvalue('label'); ' Core Columns'; END; END; INCLUDE widget_selector tableid=fact_table columns=config.findnodes(col_xpath) force=1; END; dim_xpath = "/reporter/tables/table[@id='$fact_table']/links/link/@table"; FOR dim_table IN config.findnodes(dim_xpath); dim_table = dim_table.value(); dimension = config.findnodes("/reporter/tables/table[@id='$dim_table']"); WRAPPER html/table width="100%" border=1; WRAPPER html/row; WRAPPER html/cell colspan=2; # checkbox input here ... INCLUDE checkbox name="filter" value=dim_table checked=1; dimension.findvalue('label'); ' Dimension'; END; END; INCLUDE widget_selector tableid=dim_table; END; END; INCLUDE submit name='button' value='Save'; %]
[% END; BLOCK widget_selector; logme("widget_selector called for table $tableid"); # if we got some columns, use them. if not, get all non-primary columns IF ! columns; columns_xpath = '/reporter/tables/table[@id="' _ tableid _ '"]/fields/field[not(@primary) or @primary!="true"]' columns = config.findnodes(columns_xpath); logme("widget_selector had to grab columns for table $tableid!"); END; column_input_type="checkbox"; IF force; column_input_type="hidden"; END; FOR column IN columns; column_name=column.findvalue('@name'); WRAPPER html/row; WRAPPER html/cell valign='top' align='right'; # checkbox for column filter here ... INCLUDE $column_input_type name="filter:$tableid" value=column_name checked=1; column.findvalue('label'); END; WRAPPER html/cell; col_widget_fams_xpath = '/reporter/widgets/widget-family[@datatype="' _ column.findvalue('@datatype') _ '"]'; IF column.findnodes('@widget-family'); col_widget_fams_xpath = '/reporter/widgets/widget-family[@name="' _ column.findvalue('@widget-family') _ '"]'; END; logme("finding widget families using $col_widget_fams_xpath"); widget_fams = config.findnodes(col_widget_fams_xpath); ''; END; END; END; END; %][% BLOCK text; %][% END; BLOCK textarea; %][% END; BLOCK hidden; %][% END; BLOCK radio; %][% END; BLOCK checkbox; %][% END; BLOCK submit; %][% END; BLOCK anchor; %][%text%][% END; BLOCK render_dimension; INCLUDE checkbox checked = 1 name = 's2_dim_table' value = dim_object.findvalue('@id'); %][% dim_object.findvalue('name') %]
[% WRAPPER html/table width="100%" ; WRAPPER html/row; WRAPPER html/cell align="right"; END; END; END; END; BLOCK dim_description; WRAPPER html/row; WRAPPER html/cell align="right"; %]Name:[% END; WRAPPER html/cell; dim.findvalue('label'); END; END; PROCESS table_fields table = dim; END; BLOCK table_fields; FOR f IN table.findnodes('fields/field'); WRAPPER html/row; WRAPPER html/cell align="right"; %]Field:[% END; WRAPPER html/cell; f.findvalue('@name'); %] ([% f.findvalue('@datatype') %])[% END; END; END; END; BLOCK stage1_detail; PROCESS table_fields table = config.findnodes("/reporter/tables/table[@id='$fact_table']"); WRAPPER html/row; WRAPPER html/cell align="right"; %]Report Attributes
(dimensions):[% END; WRAPPER html/cell; incs_xpath = '/reporter/tables/table[@id="' _ fact_table _'"]'_ '/links/link/@field'; logme(incs_xpath); incs = config.findnodes(incs_xpath); FOR dim IN incs; %][% link_xpath = '/reporter/tables/table[@id="' _ fact_table _'"]'_ '/links/link[@field="' _ dim.value() _ '"]/@table'; logme(link_xpath); dim_table = config.findvalue(link_xpath); dim_xpath = '/reporter/tables/table[@id="' _ dim_table _ '"]'; logme(dim_xpath); dim_def = config.findnodes(dim_xpath); PROCESS dim_description dim = dim_def; %]
[% END; END; END; END; %]