[%
WRAPPER html/html;
WRAPPER header.ttk + navbar.ttk title="Report Templates";
PROCESS inputs;
PROCESS class_manip;
PROCESS widget_manip;
INCLUDE logout.ttk;
END;
WRAPPER html/body;
PROCESS logic_header.ttk;
PROCESS select_sorter.js;
templates = DBI.tie('reporter.stage2', 'id')
tmpl = {};
IF CGI.param('id');
tid = CGI.param('id');
tmpl = templates.$tid;
END;
IF CGI.param('action') == 'save';
PROCESS save_stage2;
ELSIF CGI.param('action') == 'edit';
PROCESS edit_stage2;
ELSIF CGI.param('action') == 'run';
PROCESS run_stage2;
ELSE;
PROCESS view_stage2;
END;
END;
INCLUDE footer.ttk;
END;
BLOCK save_stage2;
stage1 = CGI.param('stage1');
pub = CGI.param('publictemplate') OR 'f';
owner = user.id();
p_obj = {};
FOR p = CGI.param();
logme([p,CGI.param(p)]);
parts = p.split(':');
p1 = parts.0;
p2 = parts.1;
p3 = parts.2;
p4 = parts.3;
IF p4
AND (CGI.param("$p1").list.grep("^$p2$").size > 0)
AND (CGI.param("$p1:$p2").list.grep("^$p3$").size > 0)
AND (CGI.param("$p1:$p2:$p3").list.grep("^$p4$").size > 0);
p_obj.$p1.$p2.$p3.$p4 = CGI.param(p);
ELSIF p2
AND (CGI.param("$p1").list.grep(p2).size > 0);
p_obj.dims.$p2 = 1;
ELSIF p1 != 'filter';
p_obj.$p1 = CGI.param(p);
END;
END;
params = utils.perl2JSON( p_obj );
logme([stage1, params, owner, pub]);
q = DBI.prepare( stage2_insert );
CALL q.execute(stage1, params, owner, pub);
FOR new_s2 = DBI.query("SELECT * FROM reporter.stage2_id_seq;");
tid = new_s2.last_value;
INCLUDE view_stage2 tmpl = templates.$tid;
END;
END;
BLOCK edit_stage2;
END;
BLOCK view_stage2;
logme(tmpl.params);
params = utils.JSON2perl( tmpl.params );
WRAPPER html/table border=0 width='100%';
WRAPPER html/row;
WRAPPER html/cell colspan=5 align='center';
s1_name_xpath = '/reporter/tables/table[@id="' _ params.stage1 _ '"]/label';
INCLUDE anchor
content=config.findvalue( s1_name_xpath )
href="stage1?id=" _ params.stage1;
' :: ' _ params.templatename _ '
';
INCLUDE anchor
content="Create a report from this template"
href=CGI.url('-path', 1) _ '?action=run&id=' _ tmpl.id;
END;
END;
WRAPPER html/row;
INCLUDE html/cell colspan=4 content="Filterable Attributes:";
END;
core_table = params.stage1;
tables = params.filter.keys;
tables.unshift(core_table);
tables = tables.unique;
FOR t = tables;
logme(['table id or link id', t]);
f_table = INCLUDE find_table_id id=t;
table = config.findnodes( "/reporter/tables/table[@id='$f_table']");
WRAPPER html/row;
INCLUDE html/cell;
WRAPPER html/cell colspan=4 align='left';
IF t != f_table;
link_xpath = '//*[@id="' _ t _ '"]';
dim_link = config.findnodes(link_xpath);
link_label_xpath =
'../../fields/field[@name="' _
dim_link.findvalue('@field') _ '"]/label';
dim_link.findvalue(link_label_xpath);
' -- ';
END;
table.findvalue( 'label' );
END;
END;
FOR f_field = params.filter.$t.keys;
logme([f_table,f_field]);
FOR f_fam = params.filter.$t.$f_field.keys;
logme([f_table,f_field,f_fam]);
f_widget = params.filter.$t.$f_field.$f_fam;
logme([f_table,f_field,f_fam,f_widget]);
WRAPPER html/row;
field = table.findnodes( "fields/field[@name='$f_field']" );
fam = config.findnodes( "/reporter/widgets/widget-family[@name='$f_fam']" );
widget = fam.findnodes( "widget[@name='$f_widget']" );
INCLUDE html/cell colspan=2;
INCLUDE html/cell align='right' content=field.findvalue( 'label' );
INCLUDE html/cell align='center' content=fam.findvalue( 'label' );
INCLUDE html/cell align='left' content=widget.findvalue( 'label' );
END;
END;
END;
END;
WRAPPER html/row;
INCLUDE html/cell colspan=5 content="
";
END;
WRAPPER html/row;
INCLUDE html/cell colspan=5 content="Attributes Available for Output";
END;
tables = params.dims.keys;
tables.unshift(core_table);
tables = tables.unique;
FOR t = tables;
f_table = INCLUDE find_table_id id=t;
table = config.findnodes( "/reporter/tables/table[@id='$f_table']");
tname = table.findvalue( "label" );
tdesc = table.findvalue( "desription" );
#NEXT IF table.findvalue('@fact-table') == 'true';
WRAPPER html/row;
INCLUDE html/cell;
WRAPPER html/cell colspan=4 align='left';
IF t != f_table;
link_xpath = '//*[@id="' _ t _ '"]';
dim_link = config.findnodes(link_xpath);
link_label_xpath =
'../../fields/field[@name="' _
dim_link.findvalue('@field') _ '"]/label';
dim_link.findvalue(link_label_xpath);
' -- ';
END;
tname;
END;
END;
FOR field = table.findnodes('fields/field[not(@primary) or @primary != "true"]');
link_test = '../../links/link[@field="' _ field.findvalue('@name') _ '"]';
logme(['link_test',link_test]);
NEXT IF field.findnodes( link_test );
fname = field.findvalue( "label" );
fdesc = field.findvalue( "desription" );
WRAPPER html/row;
INCLUDE html/cell colspan=2;
INCLUDE html/cell align='right' content=fname;
INCLUDE html/cell colspan=2 align='center' content=fdesc;
END;
END;
END;
END;
END;
BLOCK run_stage2;
logme(tmpl.params);
params = utils.JSON2perl( tmpl.params );
%]
[%
WRAPPER html/table width="100%";
WRAPPER html/row;
WRAPPER html/cell align='center';
s1_name_xpath = '/reporter/tables/table[@id="' _ params.stage1 _ '"]/label';
INCLUDE anchor
content=config.findvalue( s1_name_xpath )
href="stage1?id=" _ params.stage1;
' :: ' _ params.templatename;
END;
END;
END;
'
';
WRAPPER form id="stage3_new" name="stage3_new" action="stage3" onsubmit="return send_it(this);" method="POST";
INCLUDE hidden name='stage2' value=CGI.param('id');
'
Report Name:';
INCLUDE text name='reportname' size="50";
'
';
'';
WRAPPER html/table width="100%";
WRAPPER html/row style="border-top: solid black 2px;";
INCLUDE html/cell colspan=2 content='Output and Sort Order' style="border-top: solid black 2px;";
INCLUDE html/cell colspan=2 content='Output Formats' align="center" style="border-top: solid black 2px;";
END;
WRAPPER html/row;
WRAPPER html/cell rowspan=3 width="25%";
INCLUDE select multi=1 size=5 id='output_order' name='output_order';
END;
WRAPPER html/cell;
INCLUDE anchor href='javascript:void(0);' content='Up' onclick="Widget.Select.moveSelectedOptionsUp('output_order')";
END;
WRAPPER html/cell align="right";
INCLUDE checkbox name='output_format' value='csv' checked='checked';
END;
INCLUDE html/cell content="CSV" align="left";
END;
WRAPPER html/row;
WRAPPER html/cell;
INCLUDE anchor href='javascript:void(0);' content='Down' onclick="Widget.Select.moveSelectedOptionsDown('output_order')";
END;
WRAPPER html/cell align="right";
INCLUDE checkbox name='output_format' value='excel' checked='checked';
END;
INCLUDE html/cell content="Excel" align="left";
END;
WRAPPER html/row;
INCLUDE html/cell;
WRAPPER html/cell align="right" valign='top';
INCLUDE checkbox name='output_format' value='html' checked='checked';
END;
WRAPPER html/cell align="left";
'HTML
';
WRAPPER html/table;
WRAPPER html/row + html/cell colspan=2;
"Graph types";
END;
WRAPPER html/row;
WRAPPER html/cell;
INCLUDE checkbox name='html_graph_type' value='bar' checked=1;
END;
INCLUDE html/cell content='Bar';
END;
WRAPPER html/row;
WRAPPER html/cell;
INCLUDE checkbox name='html_graph_type' value='pie' checked=1;
END;
INCLUDE html/cell content='Pie';
END;
WRAPPER html/row;
WRAPPER html/cell;
INCLUDE checkbox name='html_graph_type' value='line';
END;
INCLUDE html/cell content='Line';
END;
END;
END;
END;
END;
'
Pivot Column: ';
WRAPPER select id='pivot_col' name='pivot_col';
INCLUDE option value='' content='No Pivot';
END;
'
';
WRAPPER html/table border=0 width='100%';
WRAPPER html/row;
INCLUDE html/cell colspan=4 content="Filterable Attributes
" style="border-top: solid black 2px;";
END;
core_table = params.stage1;
tables = params.filter.keys;
tables.unshift(core_table) IF tables.grep("^$core_table$");
tables = tables.unique;
FOR t = tables;
NEXT UNLESS params.filter.$t.keys;
f_table = INCLUDE find_table_id id=t;
table = config.findnodes( "/reporter/tables/table[@id='$f_table']");
table_label = table.findvalue( 'label' );
WRAPPER html/row;
WRAPPER html/cell colspan=3 align='center' style="border: solid black 1px; background: lightgray;";
IF t != f_table;
link_xpath = '//*[@id="' _ t _ '"]';
dim_link = config.findnodes(link_xpath);
link_label_xpath =
'../../fields/field[@name="' _
dim_link.findvalue('@field') _ '"]/label';
table_label = table_label _ ' -- ' _ dim_link.findvalue(link_label_xpath);
END;
table_label;
END;
END;
FOR f_field = params.filter.$t.keys;
logme([f_table,f_field]);
FOR f_fam = params.filter.$t.$f_field.keys;
logme([f_table,f_field,f_fam]);
f_widget = params.filter.$t.$f_field.$f_fam;
logme([f_table,f_field,f_fam,f_widget]);
WRAPPER html/row;
field = table.findnodes( "fields/field[@name='$f_field']" );
fam = config.findnodes( "/reporter/widgets/widget-family[@name='$f_fam']" );
widget = fam.findnodes( "widget[@name='$f_widget']" );
w_file = 'widgets/' _ fam.findvalue('@name') _ '.' _ widget.findvalue('@name');
INCLUDE html/cell align='left' style="padding-left: 50px;" content=field.findvalue( 'label' );
WRAPPER html/cell align='left';
TRY;
classname = table.findvalue('@id');
fieldname = field.findvalue('@name');
widgetname = widget.findvalue('@name');
famname = fam.findvalue('@name');
table_alias = t;
input_prefix = "filter:$t:$fieldname:$famname:$widgetname";
INCLUDE $w_file widget_family=fam;
CATCH;
%]ARG!! Couldn't render widget [% $w_file %] ([% error.info %])!!![%
END;
END;
END;
END;
END;
END;
WRAPPER html/row;
INCLUDE html/cell colspan=4 content="
";
END;
WRAPPER html/row;
INCLUDE html/cell colspan=4 content="Attributes Available for Output
" style="border-top: solid black 2px;";
END;
table = config.findnodes( "/reporter/tables/table[@id='$core_table']" );
classname = table.findvalue( "@id" );
tname = table.findvalue( "label" );
tdesc = table.findvalue( "desription" );
WRAPPER html/row;
INCLUDE html/cell colspan=4 align='center' content=tname style="border: solid black 1px; background: lightgray;";
END;
pkey_field = table.findnodes('fields/field[@primary = "true"]');
pid = pkey_field.findvalue('@name');
plabel = pkey_field.findvalue('label');
WRAPPER html/row;
WRAPPER html/cell align='left' style="padding-left: 50px;";
INCLUDE checkbox checked='checked' name="output:$classname:$pid" value="include" onclick="field_add_remove(this)";
INCLUDE hidden name="xform:type:$classname:$pid" value="count_dist";
%]
[%
"Per group count of $plabel
";
END;
INCLUDE html/cell align='center';
END;
tables = params.dims.keys;
tables.unshift(core_table);
tables = tables.unique;
core_done = 0;
FOR f_table = tables;
noheader = 0;
noheader = 1 IF f_table == core_table;
INCLUDE show_filter_atts;
WRAPPER html/row;
INCLUDE html/cell colspan=4 content="
";
END;
END;
END;
INCLUDE checkbox name="publicreport" value="t";
'Public Report
';
INCLUDE submit name="action" value="Run Now";
INCLUDE submit name="action" value="Schedule";
END;
END;
BLOCK show_filter_atts;
t = f_table;
f_table = INCLUDE find_table_id id=t;
table = config.findnodes( "/reporter/tables/table[@id='$f_table']");
classname = table.findvalue( "@id" );
tname = table.findvalue( "label" );
tdesc = table.findvalue( "desription" );
IF ! noheader;
WRAPPER html/row;
WRAPPER html/cell colspan=4 align='center' style="border: solid black 1px; background: lightgray;";
IF t != f_table;
link_xpath = '//*[@id="' _ t _ '"]';
dim_link = config.findnodes(link_xpath);
link_label_xpath =
'../../fields/field[@name="' _
dim_link.findvalue('@field') _ '"]/label';
dim_link.findvalue(link_label_xpath);
' -- ';
END;
tname;
END;
END;
END;
fields_xpath = 'fields/field[not(@primary) or @primary != "true"]';
count = 1;
FOR field = table.findnodes(fields_xpath);
link_test = '../../links/link[@field="' _ field.findvalue('@name') _ '"]';
logme(['link_test',link_test]);
NEXT IF field.findnodes( link_test );
fname = field.findvalue( "label" );
fid = field.findvalue( "@name" );
bg_color = 'white';
IF count % 2;
bg_color = 'lightcyan';
END;
WRAPPER html/row;
WRAPPER html/cell align='left' col=bg_color style="padding-left: 50px;";
INCLUDE checkbox name="output:$t:$fid" value="include" onclick="field_add_remove(this)";
%]
[%
fname;
END;
INCLUDE html/cell align='right' content='Output Transformation:' col=bg_color;
WRAPPER html/cell align='left' col=bg_color style="padding-left: 50px;";
dtype = field.findvalue('@transform-group');
IF !dtype;
dtype = field.findvalue('@datatype');
END;
WRAPPER select id="xform:type:$t:$fid" name="xform:type:$t:$fid" onchange="show_hide_params(this)";
INCLUDE option value='' content='None' selected=1;
FOR xform = dtype_xform_map.$dtype;
xform_label = dtype_xforms.$xform.label;
IF dtype_xforms.$xform.param;
xform_label = "$xform_label (*)";
END;
INCLUDE option value=xform content=xform_label;
END;
END;
%]
*Output Tranformation Parameter:
[% INCLUDE text name="xform:param:$t:$fid" %]
[%
END;
END;
count = count + 1;
END;
END;
%]