From d30c63262d93617cb3cbd07ab1698ef0a7c63e6e Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 14 Oct 2005 21:47:41 +0000 Subject: [PATCH] adding/comitting miker's work git-svn-id: svn://svn.open-ils.org/ILS/trunk@1915 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/reporter/config.sql | 4 +- Open-ILS/src/reporter/templates/class_manip | 177 +++++++++++++++ Open-ILS/src/reporter/templates/dashboard.ttk | 213 ++++++++++++++++++ Open-ILS/src/reporter/templates/header.ttk | 3 + Open-ILS/src/reporter/templates/inputs | 89 ++++++++ .../src/reporter/templates/logic_header.ttk | 9 +- Open-ILS/src/reporter/templates/logout.ttk | 3 - Open-ILS/src/reporter/templates/navbar.ttk | 12 + Open-ILS/src/reporter/templates/stage1.ttk | 10 +- Open-ILS/src/reporter/templates/stage2.ttk | 201 +++++++++-------- Open-ILS/src/reporter/templates/stage3.ttk | 190 ++++++++++++++++ Open-ILS/src/reporter/templates/widget_manip | 104 +++++++++ .../widgets/specific-timerange.multimonth | 47 ++++ .../templates/widgets/string-choose.dropdown | 4 +- .../widgets/string-choose.multiselect | 13 ++ 15 files changed, 967 insertions(+), 112 deletions(-) create mode 100644 Open-ILS/src/reporter/templates/class_manip create mode 100644 Open-ILS/src/reporter/templates/dashboard.ttk create mode 100644 Open-ILS/src/reporter/templates/inputs create mode 100644 Open-ILS/src/reporter/templates/navbar.ttk create mode 100644 Open-ILS/src/reporter/templates/stage3.ttk create mode 100644 Open-ILS/src/reporter/templates/widget_manip create mode 100644 Open-ILS/src/reporter/templates/widgets/specific-timerange.multimonth create mode 100644 Open-ILS/src/reporter/templates/widgets/string-choose.multiselect diff --git a/Open-ILS/src/reporter/config.sql b/Open-ILS/src/reporter/config.sql index 788c92082b..d8454c6df3 100644 --- a/Open-ILS/src/reporter/config.sql +++ b/Open-ILS/src/reporter/config.sql @@ -41,7 +41,9 @@ CREATE TABLE reporter.stage3 ( pub bool not null default false, create_date timestamp with time zone not null - default now() + default now(), + runtime timestamp with time zone default now(), + recurrence interval ); COMMIT; diff --git a/Open-ILS/src/reporter/templates/class_manip b/Open-ILS/src/reporter/templates/class_manip new file mode 100644 index 0000000000..5fdd59b318 --- /dev/null +++ b/Open-ILS/src/reporter/templates/class_manip @@ -0,0 +1,177 @@ +[% + +PROCESS inputs; + +dtype_xforms = { + 'avg' => { + 'name' => 'Average per group', + 'select' => 'AVG(?COLNAME?)', + 'group' => 0 }, + 'stddev' => { + 'label' => 'Standard Deviation per group', + 'select' => 'STDDEV(?COLNAME?)', + 'group' => 0 }, + 'sum' => { + 'label' => 'Sum per group', + 'select' => 'SUM(?COLNAME?)', + 'group' => 0 }, + 'count' => { + 'label' => 'Count per group', + 'select' => 'COUNT(?COLNAME?)', + 'group' => 0 }, + 'count_dist' => { + 'label' => 'Distinct Count per group', + 'select' => 'COUNT(DISTINCT ?COLNAME?)', + 'group' => 0 }, + 'lower' => { + 'label' => 'Transform string to lower case', + 'select' => 'LOWER(?COLNAME?)', + 'group' => 1 }, + 'upper' => { + 'label' => 'Transform string to upper case', + 'select' => 'UPPER(?COLNAME?)', + 'group' => 1 }, + 'substr' => { + 'label' => 'Trim string length', + 'select' => 'substr(?COLNAME?,1,?PARAM?)', + 'param' => 1, + 'group' => 1 }, + 'age' => { + 'label' => 'Age as of runtime -- day granularity', + 'select' => 'AGE(?COLNAME?::DATE)', + 'group' => 1 }, + 'dateformat' => { # see http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html + 'label' => 'Format date and time', + 'select' => 'TO_CHAR(?COLNAME?,?PARAM?)', + 'param' => 1, + 'group' => 1 }, + 'numformat' => { # see http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html + 'label' => 'Format Numeric data', + 'select' => 'TO_CHAR(?COLNAME?,?PARAM?)', + 'param' => 1, + 'group' => 1 }, +}; + +dtype_xform_map = { + 'int' => [ 'avg','stddev','sum','count','count_dist','numformat'], + 'numeric' => [ 'avg','stddev','sum','count','count_dist','numformat'], + 'float' => [ 'avg','stddev','sum','count','count_dist','numformat'], + 'time' => [ 'count', 'dateformat'], + 'date' => [ 'count', 'age','dateformat'], + 'timestamp' => [ 'count', 'age','dateformat'], + 'timestamptz' => [ 'count', 'age','dateformat'], + 'text' => [ 'count','count_dist','lower','upper','substr'], +}; + +BLOCK class_table; + WRAPPER html/table width='100%' style='border-top: 1px solid black'; + WRAPPER html/row; + WRAPPER html/cell align="right" width="30%"; + %]Name:[% + END; + WRAPPER html/cell; + class.findvalue('label'); + END; + END; + WRAPPER html/row; + WRAPPER html/cell align="right"; + %]Description:[% + END; + WRAPPER html/cell; + class.findvalue('description'); + END; + END; + IF class.findvalue('@fact-table') == 'true' AND CGI.param('create_stage2') != 1; + 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 + content=utils.JSON2perl(r.params).templatename; + '
'; + END; + END; + END; + END; + + INCLUDE class_detail IF CGI.param('detail') == 1; + END; +END; + + + + + + +BLOCK class_fields; + FOR f IN class.findnodes('fields/field'); + WRAPPER html/row; + WRAPPER html/cell align="right"; + f.findvalue('label'); + END; + WRAPPER html/cell; + %] ([% + IF f.findvalue('description'); + f.findvalue('description'); + %] -- [% + END; + f.findvalue('@name')%]::[%f.findvalue('@datatype') %])[% + END; + END; + END; +END; + + + + + + +BLOCK class_detail; + + INCLUDE class_fields; + + IF class.findvalue('@fact-table') == 'true' AND nosub != 1; + WRAPPER html/row; + WRAPPER html/cell align="right"; + %]Report Dimensions
and Attributes:
[% + END; + WRAPPER html/cell; + incs = class.findnodes('links/link/@field'); + + 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); + + INCLUDE class_table class = dim_def; + END; + END; + END; + END; +END; + +%] + diff --git a/Open-ILS/src/reporter/templates/dashboard.ttk b/Open-ILS/src/reporter/templates/dashboard.ttk new file mode 100644 index 0000000000..09f2700aa5 --- /dev/null +++ b/Open-ILS/src/reporter/templates/dashboard.ttk @@ -0,0 +1,213 @@ +[% + +PROCESS inputs; +PROCESS class_manip; +PROCESS widget_manip; +PROCESS logic_header.ttk; + +pagetype = CGI.param('detail'); + + +SWITCH pagetype; + CASE 'myreports'; + INCLUDE header.ttk title="Reporter Dashboard -- My Recent Reports"; + INCLUDE navbar.ttk + my_reports; + CASE 'mytemplates'; + INCLUDE header.ttk title="Reporter Dashboard -- My Recent Templates"; + INCLUDE navbar.ttk + my_templates; + CASE 'othersreports'; + INCLUDE header.ttk title="Reporter Dashboard -- Others Recent Public Reports"; + INCLUDE navbar.ttk + public_reports; + CASE 'otherstemplates'; + INCLUDE header.ttk title="Reporter Dashboard -- Others Recent Public Templates"; + INCLUDE navbar.ttk + public_templates; + CASE 'facttables'; + INCLUDE header.ttk title="Reporter Dashboard -- Core Fact Tables"; + INCLUDE navbar.ttk + fact_tables; + CASE; + INCLUDE header.ttk title="Reporter Dashboard"; + INCLUDE navbar.ttk + summary; +END; + +PROCESS logout.ttk; + +BLOCK summary; + WRAPPER html/table border=0 width='100%'; + WRAPPER html/row; + INCLUDE html/cell + width='50%' + content=link(content='My Recent Reports',href='dashboard?detail=myreports') + align='center' + style='border-bottom:1px solid black'; + INCLUDE html/cell + content=link(content='Others Recent Public Reports',href='dashboard?detail=othersreports') + align='center' + style='border-bottom:1px solid black'; + END; + WRAPPER html/row; + WRAPPER html/cell valign='top' style='height:200px'; + INCLUDE my_reports limit=5; + END; + WRAPPER html/cell valign='top'; + INCLUDE public_reports limit=5; + END; + END; + WRAPPER html/row; + INCLUDE html/cell + content=link(content='My Recent Templates',href='dashboard?detail=mytemplates') + align='center' + style='border-bottom:1px solid black'; + INCLUDE html/cell + content=link(content='Others Recent Public Templates',href='dashboard?detail=otherstemplates') + align='center' + style='border-bottom:1px solid black'; + END; + WRAPPER html/row; + WRAPPER html/cell valign='top' style='height:200px'; + INCLUDE my_templates limit=5; + END; + WRAPPER html/cell valign='top'; + INCLUDE public_templates limit=5; + END; + END; + WRAPPER html/row; + INCLUDE html/cell + colspan=2 + align='center' + content=link(content='Core Fact Tables',href='dashboard?detail=facttables') + style='border-bottom:1px solid black'; + END; + WRAPPER html/row; + WRAPPER html/cell colspan=2 valign='top' style='height:200px'; + INCLUDE fact_tables; + END; + END; + END; +END; + +BLOCK my_reports; + q = "SELECT * FROM reporter.stage3 WHERE owner = " _ user.id() _ + " ORDER BY runtime DESC"; + IF limit > 0; + q = q _ ' LIMIT ' _ limit; + END; + + logme(q); + + INCLUDE show_reports; + +END; + +BLOCK public_reports; + q = "SELECT * FROM reporter.stage3 WHERE pub is true" _ + " and owner != " _ user.id() _ " ORDER BY runtime DESC"; + IF limit > 0; + q = q _ ' LIMIT ' _ limit; + END; + + logme(q); + + INCLUDE show_reports; + +END; + +BLOCK show_reports; + WRAPPER html/table width='100%'; + WRAPPER html/row; + INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray'; + INCLUDE html/cell content='Report Name' nowrap='nowrap' col='lightgray'; + INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray'; + INCLUDE html/cell content='Scheduled Run Date' nowrap='nowrap' col='lightgray'; + INCLUDE html/cell content='Recurrence' nowrap='nowrap' col='lightgray'; + END; + FOR report = DBI.query(q); + bg='lightblue'; + IF loop.count % 2; + bg='white'; + END; + WRAPPER html/row; + p = utils.JSON2perl( report.params ); + INCLUDE html/cell content=(report.pub ? 'Y' : 'N') col=bg; + INCLUDE html/cell content=p.reportname col=bg; + INCLUDE html/cell content=report.create_date.chunk(10).0 col=bg; + INCLUDE html/cell content=report.runtime.chunk(10).0 col=bg; + INCLUDE html/cell content=report.recurrence col=bg; + END; + END; + END; +END; + +BLOCK my_templates; + q = "SELECT * FROM reporter.stage2 WHERE " _ + " owner = " _ user.id() _ " ORDER BY create_date DESC"; + IF limit > 0; + q = q _ ' LIMIT ' _ limit; + END; + + logme(q); + + INCLUDE show_templates; + +END; + +BLOCK public_templates; + q = "SELECT * FROM reporter.stage2 WHERE pub is true" _ + " and owner != " _ user.id() _ " ORDER BY create_date DESC"; + IF limit > 0; + q = q _ ' LIMIT ' _ limit; + END; + + logme(q); + + INCLUDE show_templates; + +END; + +BLOCK show_templates; + WRAPPER html/table width='100%'; + WRAPPER html/row; + INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray'; + INCLUDE html/cell content='Template Name' nowrap='nowrap' col='lightgray'; + INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray'; + END; + FOR template = DBI.query(q); + tid = template.id; + bg='lightblue'; + IF loop.count % 2; + bg='white'; + END; + WRAPPER html/row; + p = utils.JSON2perl( template.params ); + INCLUDE html/cell content=(template.pub ? 'Y' : 'N') col=bg; + INCLUDE html/cell content=link(content=p.templatename,href="stage2?id=$tid") col=bg; + INCLUDE html/cell content=template.create_date.chunk(10).0 col=bg; + INCLUDE html/cell content=template.recurrence col=bg; + END; + END; + END; +END; + +BLOCK fact_tables; + WRAPPER html/table width='100%'; + WRAPPER html/row; + INCLUDE html/cell content='Fact table' nowrap='nowrap' col='lightgray'; + INCLUDE html/cell content='Description' nowrap='nowrap' col='lightgray'; + END; + FOR tab IN config.findnodes("/reporter/tables/table[@fact-table='true']"); + tid = tab.findvalue('@id'); + bg='lightblue'; + IF loop.count % 2; + bg='white'; + END; + WRAPPER html/row; + p = utils.JSON2perl( template.params ); + INCLUDE html/cell + col=bg + content=link(content=tab.findvalue('tablename'),href="stage1?id=$tid"); + INCLUDE html/cell content=tab.findvalue('description'); + END; + END; + END; +END; + +%] diff --git a/Open-ILS/src/reporter/templates/header.ttk b/Open-ILS/src/reporter/templates/header.ttk index a0bee0899a..7cce23f024 100644 --- a/Open-ILS/src/reporter/templates/header.ttk +++ b/Open-ILS/src/reporter/templates/header.ttk @@ -10,5 +10,8 @@ [% title %] + diff --git a/Open-ILS/src/reporter/templates/inputs b/Open-ILS/src/reporter/templates/inputs new file mode 100644 index 0000000000..db967acc4c --- /dev/null +++ b/Open-ILS/src/reporter/templates/inputs @@ -0,0 +1,89 @@ +[% + +BLOCK form; + '
' _ content _ '
'; +END; + +BLOCK text; + %][% +END; + +BLOCK textarea; + %][% +END; + +BLOCK select; + %][% +END; + +BLOCK option; + %][% +END; + +BLOCK hidden; + %][% +END; + +BLOCK radio; + %][% +END; + +BLOCK checkbox; + %][% +END; + +BLOCK submit; + %][% +END; + +MACRO link INCLUDE anchor; + +BLOCK anchor; + %][%content%][% +END; + +%] + diff --git a/Open-ILS/src/reporter/templates/logic_header.ttk b/Open-ILS/src/reporter/templates/logic_header.ttk index b8e05ddc2f..d7a0804530 100644 --- a/Open-ILS/src/reporter/templates/logic_header.ttk +++ b/Open-ILS/src/reporter/templates/logic_header.ttk @@ -1,3 +1,8 @@ + [% BLOCK logme_block; @@ -29,6 +34,6 @@ DBI.connect(dsn,d_u,d_p); stage2_insert = 'INSERT INTO reporter.stage2 (stage1, params, owner, pub)' _ ' VALUES ( ?,?,?,? )'; -stage3_insert = 'INSERT INTO reporter.stage3 (stage2, params, owner, pub, runtime)' _ - ' VALUES ( ?,?,?,?,? )'; +stage3_insert = 'INSERT INTO reporter.stage3 (stage2, params, owner, pub, runtime, recurrence)' _ + ' VALUES ( ?,?,?,?,?,? )'; %] diff --git a/Open-ILS/src/reporter/templates/logout.ttk b/Open-ILS/src/reporter/templates/logout.ttk index 7fc38ca9ef..17d1a5a47f 100644 --- a/Open-ILS/src/reporter/templates/logout.ttk +++ b/Open-ILS/src/reporter/templates/logout.ttk @@ -22,7 +22,4 @@ - - Logout - diff --git a/Open-ILS/src/reporter/templates/navbar.ttk b/Open-ILS/src/reporter/templates/navbar.ttk new file mode 100644 index 0000000000..458c1ad2e2 --- /dev/null +++ b/Open-ILS/src/reporter/templates/navbar.ttk @@ -0,0 +1,12 @@ + + Logout | + Dashboard + [% IF links.list.size > 0; + ' | '; + links.list.join(' | '); + END; %] + + +
+
+ diff --git a/Open-ILS/src/reporter/templates/stage1.ttk b/Open-ILS/src/reporter/templates/stage1.ttk index cf5e1d2328..82c8f15ab2 100644 --- a/Open-ILS/src/reporter/templates/stage1.ttk +++ b/Open-ILS/src/reporter/templates/stage1.ttk @@ -4,19 +4,19 @@ PROCESS inputs; PROCESS class_manip; PROCESS widget_manip; PROCESS logic_header.ttk; +INCLUDE logout.ttk; WRAPPER html/html; - INCLUDE header.ttk title="Basic Report Types"; + INCLUDE header.ttk + navbar.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)[% + %]No Details (All)[% ELSE; - %]|Details (All)[% + %]Details (All)[% END; INCLUDE all_stage1; ELSE; @@ -33,7 +33,7 @@ END; BLOCK one_stage1; - %]|'; INCLUDE anchor - text="Create a report from this template" + content="Create a report from this template" href=CGI.url('-path', 1) _ '?action=run&id=' _ tmpl.id; END; END; @@ -187,130 +187,133 @@ BLOCK run_stage2; logme(tmpl.params); params = utils.JSON2perl( tmpl.params ); - %]
[% + '
'; + WRAPPER form id="stage3_new" name="stage3_new" action="stage3" method="POST"; + INCLUDE hidden name='stage2' value=CGI.param('id'); - INCLUDE hidden name='stage2' value=CGI.param('id'); + '
Name:'; + INCLUDE text name='reportname'; - WRAPPER html/table border=0 width='100%'; - WRAPPER html/row; - WRAPPER html/cell colspan=4 align='center'; - s1_name_xpath = '/reporter/tables/table[@id="' _ params.stage1 _ '"]/label'; - INCLUDE anchor - text=config.findvalue( s1_name_xpath ) - href="stage1?id=" _ params.stage1; - ' :: ' _ params.templatename; + WRAPPER html/table border=0 width='100%'; + WRAPPER html/row; + WRAPPER html/cell colspan=4 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 html/row; - INCLUDE html/cell colspan=4 content="Filterable Attributes:"; - END; - - FOR f_table IN params.filter.keys; - logme([f_table]); - table = config.findnodes( "/reporter/tables/table[@id='$f_table']"); WRAPPER html/row; - INCLUDE html/cell colspan=3 align='left' content=table.findvalue( 'label' ); + INCLUDE html/cell colspan=4 content="Filterable Attributes:"; END; - FOR f_field IN params.filter.$f_table.keys; - logme([f_table,f_field]); - FOR f_fam IN params.filter.$f_table.$f_field.keys; - logme([f_table,f_field,f_fam]); - f_widget = params.filter.$f_table.$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; - INCLUDE html/cell align='right' content=field.findvalue( 'label' ); - - WRAPPER html/cell align='center'; - TRY; - classname = table.findvalue('@id'); - fieldname = field.findvalue('@name'); - widgetname = widget.findvalue('@name'); - famname = fam.findvalue('@name'); - - input_prefix = "filter:$famname:$widgetname:$classname:$fieldname"; + FOR f_table IN params.filter.keys; + logme([f_table]); + table = config.findnodes( "/reporter/tables/table[@id='$f_table']"); + WRAPPER html/row; + INCLUDE html/cell colspan=3 align='left' content=table.findvalue( 'label' ); + END; - INCLUDE $w_file widget_family=fam; - CATCH; - %]ARG!! Couldn't render widget [% $w_file %] ([% error.info %])!!![% + FOR f_field IN params.filter.$f_table.keys; + logme([f_table,f_field]); + FOR f_fam IN params.filter.$f_table.$f_field.keys; + logme([f_table,f_field,f_fam]); + f_widget = params.filter.$f_table.$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; + INCLUDE html/cell align='right' content=field.findvalue( 'label' ); + + WRAPPER html/cell align='center'; + TRY; + classname = table.findvalue('@id'); + fieldname = field.findvalue('@name'); + widgetname = widget.findvalue('@name'); + famname = fam.findvalue('@name'); + + input_prefix = "filter:$classname:$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; - END; - - WRAPPER html/row; - INCLUDE html/cell colspan=4 content="
"; - END; - - WRAPPER html/row; - INCLUDE html/cell colspan=4 content="Attributes Available for Output"; - END; + + WRAPPER html/row; + INCLUDE html/cell colspan=4 content="
"; + END; - FOR f_table IN params.dims.keys; - table = config.findnodes( "/reporter/tables/table[@id='$f_table']"); - classname = table.findvalue( "@id" ); - tname = table.findvalue( "label" ); - tdesc = table.findvalue( "desription" ); - WRAPPER html/row; - INCLUDE html/cell colspan=4 align='left' content=tname; + INCLUDE html/cell colspan=4 content="Attributes Available for Output"; END; + FOR f_table IN params.dims.keys; + table = config.findnodes( "/reporter/tables/table[@id='$f_table']"); + classname = table.findvalue( "@id" ); + tname = table.findvalue( "label" ); + tdesc = table.findvalue( "desription" ); + + WRAPPER html/row; + INCLUDE html/cell colspan=4 align='left' content=tname; + END; - fields_xpath = - 'fields/field[not(@primary) or @primary != "true"]'; - FOR field IN 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" ); + fields_xpath = + 'fields/field[not(@primary) or @primary != "true"]'; + FOR field IN 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" ); - WRAPPER html/row; + WRAPPER html/row; - WRAPPER html/cell align='right'; - INCLUDE checkbox name="output:$classname:$fid" value="include"; - END; - INCLUDE html/cell align='right' content=fname; - WRAPPER html/cell align='center'; - 'Output Transformation: '; - dtype = field.findvalue('@datatype'); - WRAPPER select name="xform:type:$classname:$fid"; - INCLUDE option value='' content='None' selected=1; - FOR xform IN dtype_xform_map.$dtype; - xform_label = dtype_xforms.$xform.label; - IF dtype_xforms.$xform.param; - xform_label = "$xform_label (*)"; + WRAPPER html/cell align='right'; + INCLUDE checkbox name="output:$classname:$fid" value="include"; + END; + INCLUDE html/cell align='right' content=fname; + WRAPPER html/cell align='center'; + 'Output Transformation: '; + dtype = field.findvalue('@datatype'); + WRAPPER select name="xform:type:$classname:$fid"; + INCLUDE option value='' content='None' selected=1; + FOR xform IN 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; - INCLUDE option value=xform content=xform_label; END; + '
'; + '*Output Tranformation Parameter: '; + INCLUDE text name="xform:param:$classname:$fid"; END; - '
'; - '*Output Tranformation Parameter: '; - INCLUDE text name="xform:param:$classname:$fid"; END; END; END; END; - END; - - INCLUDE checkbox name="publicreport" value="t"; - 'Public Report
'; - INCLUDE submit name="action" value="Run Now"; - INCLUDE submit name="action" value="Schedule"; + + INCLUDE checkbox name="publicreport" value="t"; + 'Public Report
'; + INCLUDE submit name="action" value="Run Now"; + INCLUDE submit name="action" value="Schedule"; - %]
[% + END; END; %] diff --git a/Open-ILS/src/reporter/templates/stage3.ttk b/Open-ILS/src/reporter/templates/stage3.ttk new file mode 100644 index 0000000000..4e251b7239 --- /dev/null +++ b/Open-ILS/src/reporter/templates/stage3.ttk @@ -0,0 +1,190 @@ +[% + +PROCESS inputs; +PROCESS class_manip; +PROCESS widget_manip; +PROCESS logic_header.ttk; +INCLUDE logout.ttk; + +templates = DBI.tie('reporter.stage2', 'id') +reports = DBI.tie('reporter.stage3', 'id') +rpt = {}; +tmpl = {}; + + +IF CGI.param('id'); + tid = CGI.param('stage2'); + tmpl = templates.$tid; + rid = CGI.param('id'); + rpt = reports.$rid; +END; + + +WRAPPER html/html; + INCLUDE header.ttk + navbar.ttk title="Reports"; + WRAPPER html/body; + IF CGI.param('action') == 'Schedule'; + PROCESS schedule_stage3; + ELSIF CGI.param('action') == 'Save'; + PROCESS save_stage3; + ELSIF CGI.param('action') == 'Run Now'; + PROCESS save_stage3; + ELSIF CGI.param('id'); + PROCESS view_stage3; + ELSE; + PROCESS list_stage3s; + END; + END; + INCLUDE footer.ttk; +END; + + +BLOCK schedule_stage3; + WRAPPER form method='POST'; + 'Run Date:'; + INCLUDE text name='runtime' value='yyyy/mm/dd'; + '
'; + + 'Optional Recurrence:'; + INCLUDE text name='recurrence-count' value='0'; + WRAPPER select name='recurrence-interval'; + INCLUDE option value='days' content='Day(s)'; + INCLUDE option value='weeks' content='Weeks(s)'; + INCLUDE option value='months' content='Months(s)'; + END; + + FOR p IN CGI.param(); + NEXT IF p == 'action'; + NEXT IF p == 'runtime'; + INCLUDE hidden name=p value=CGI.param(p); + END; + '
'; + INCLUDE submit name='action' value='Save'; + END; +END; + +BLOCK list_stage3s; +END; + + +BLOCK save_stage3; + stage2 = CGI.param('stage2'); + runtime = CGI.param('runtime') OR 'now'; + pub = CGI.param('publicreport') OR 'f'; + owner = user.id(); + + p_obj = {}; + FOR p IN CGI.param(); + + logme([p,CGI.param(p)]); + + parts = p.split(':'); + p1 = parts.0; + p2 = parts.1; + p3 = parts.2; + p4 = parts.3; + p5 = parts.4; + p6 = parts.5; + + IF p6; + + IF p_obj.$p1.$p2.$p3.$p4.$p5.$p6.defined; + IF p_obj.$p1.$p2.$p3.$p4.$p5.$p6.size > 1; + p_obj.$p1.$p2.$p3.$p4.$p5.$p6.push(CGI.param(p)); + ELSE; + tmp = [ p_obj.$p1.$p2.$p3.$p4.$p5.$p6, CGI.param(p) ]; + p_obj.$p1.$p2.$p3.$p4.$p5.$p6 = tmp; + END; + ELSE; + p_obj.$p1.$p2.$p3.$p4.$p5.$p6 = CGI.param(p); + END; + + ELSIF p5; + + IF p_obj.$p1.$p2.$p3.$p4.$p5.defined; + IF p_obj.$p1.$p2.$p3.$p4.$p5.size > 1; + p_obj.$p1.$p2.$p3.$p4.$p5.push(CGI.param(p)); + ELSE; + tmp = [ p_obj.$p1.$p2.$p3.$p4.$p5, CGI.param(p) ]; + p_obj.$p1.$p2.$p3.$p4.$p5 = tmp; + END; + ELSE; + p_obj.$p1.$p2.$p3.$p4.$p5 = CGI.param(p); + END; + + ELSIF p4; + + IF p_obj.$p1.$p2.$p3.$p4.defined; + IF p_obj.$p1.$p2.$p3.$p4.size > 1; + p_obj.$p1.$p2.$p3.$p4.push(CGI.param(p)); + ELSE; + tmp = [ p_obj.$p1.$p2.$p3.$p4, CGI.param(p) ]; + p_obj.$p1.$p2.$p3.$p4 = tmp; + END; + ELSE; + p_obj.$p1.$p2.$p3.$p4 = CGI.param(p); + END; + + ELSIF p3; + + IF p_obj.$p1.$p2.$p3.defined; + IF p_obj.$p1.$p2.$p3.size > 1; + p_obj.$p1.$p2.$p3.push(CGI.param(p)); + ELSE; + tmp = [ p_obj.$p1.$p2.$p3, CGI.param(p) ]; + p_obj.$p1.$p2.$p3 = tmp; + END; + ELSE; + p_obj.$p1.$p2.$p3 = CGI.param(p); + END; + + ELSIF p2; + + IF p_obj.$p1.$p2.defined; + IF p_obj.$p1.$p2.size > 1; + p_obj.$p1.$p2.push(CGI.param(p)); + ELSE; + tmp = [ p_obj.$p1.$p2, CGI.param(p) ]; + p_obj.$p1.$p2 = tmp; + END; + ELSE; + p_obj.$p1.$p2 = CGI.param(p); + END; + + ELSE; + + p_obj.$p = CGI.param(p); + + END; + END; + + params = utils.perl2JSON( p_obj ); + + recurrence = '0 sec'; + IF CGI.param('recurrence-count') > 0; + recurrence = CGI.param('recurrence-count') _ ' ' _ CGI.param('recurrence-interval'); + END; + + logme([stage2, params, owner, pub]); + + q = DBI.prepare( stage3_insert ); + CALL q.execute(stage2, params, owner, pub, runtime, recurrence); + + FOR new_s3 = DBI.query("SELECT * FROM reporter.stage3_id_seq;"); + tid = new_s3.last_value; + INCLUDE view_stage3 rpt = reports.$tid; + END; +END; + + + + +BLOCK view_stage3; + logme(rpt.params); + params = utils.JSON2perl( rpt.params ); + + # stuff goes here ... + +END; + +%] diff --git a/Open-ILS/src/reporter/templates/widget_manip b/Open-ILS/src/reporter/templates/widget_manip new file mode 100644 index 0000000000..1d09eb88af --- /dev/null +++ b/Open-ILS/src/reporter/templates/widget_manip @@ -0,0 +1,104 @@ +[% + +PROCESS inputs; + +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; + +%] + diff --git a/Open-ILS/src/reporter/templates/widgets/specific-timerange.multimonth b/Open-ILS/src/reporter/templates/widgets/specific-timerange.multimonth new file mode 100644 index 0000000000..0d02bd858b --- /dev/null +++ b/Open-ILS/src/reporter/templates/widgets/specific-timerange.multimonth @@ -0,0 +1,47 @@ +[% + +USE date; +USE start = DateTime(now = 1); +USE end = DateTime(now = 1); + +PROCESS inputs; + +WRAPPER html/table ; + WRAPPER html/row; + INCLUDE html/cell colspan=2 align='center' content='Start time'; + END; + + WRAPPER html/row; + INCLUDE html/cell content='Year'; + INCLUDE html/cell content='Month'; + END; + + WRAPPER html/row; + WRAPPER html/cell; + INCLUDE text name=input_prefix _ ':start-year' size=4 value=start.year; + END; + WRAPPER html/cell; + INCLUDE text name=input_prefix _ ':start-month' size=4 value=start.month; + END; + END; + + WRAPPER html/row; + INCLUDE html/cell colspan=2 align='center' content='End time'; + END; + + WRAPPER html/row; + INCLUDE html/cell content='Year'; + INCLUDE html/cell content='Month'; + END; + + WRAPPER html/row; + WRAPPER html/cell; + INCLUDE text name=input_prefix _ ':end-year' size=4 value=end.year; + END; + WRAPPER html/cell; + INCLUDE text name=input_prefix _ ':end-month' size=4 value=end.month; + END; + END; +END; + +%] diff --git a/Open-ILS/src/reporter/templates/widgets/string-choose.dropdown b/Open-ILS/src/reporter/templates/widgets/string-choose.dropdown index aa6b0cf8c9..3d47bf8fa0 100644 --- a/Open-ILS/src/reporter/templates/widgets/string-choose.dropdown +++ b/Open-ILS/src/reporter/templates/widgets/string-choose.dropdown @@ -5,8 +5,8 @@ PROCESS inputs; q = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' ORDER BY ' _ fieldname _ ';'; WRAPPER select name=input_prefix; - FOR name = DBI.query(q); - INCLUDE option value=name.$fieldname; + FOR f = DBI.query(q); + INCLUDE option value=f.$fieldname; END; END; diff --git a/Open-ILS/src/reporter/templates/widgets/string-choose.multiselect b/Open-ILS/src/reporter/templates/widgets/string-choose.multiselect new file mode 100644 index 0000000000..c012756f11 --- /dev/null +++ b/Open-ILS/src/reporter/templates/widgets/string-choose.multiselect @@ -0,0 +1,13 @@ +[% + +PROCESS inputs; + +q = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' ORDER BY ' _ fieldname _ ';'; + +WRAPPER select name=input_prefix multi=1 size=3; + FOR f = DBI.query(q); + INCLUDE option value=f.$fieldname; + END; +END; + +%] -- 2.43.2