adding/comitting miker's work
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 14 Oct 2005 21:47:41 +0000 (21:47 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 14 Oct 2005 21:47:41 +0000 (21:47 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1915 dcc99617-32d9-48b4-a31d-7c20da2025e4

15 files changed:
Open-ILS/src/reporter/config.sql
Open-ILS/src/reporter/templates/class_manip [new file with mode: 0644]
Open-ILS/src/reporter/templates/dashboard.ttk [new file with mode: 0644]
Open-ILS/src/reporter/templates/header.ttk
Open-ILS/src/reporter/templates/inputs [new file with mode: 0644]
Open-ILS/src/reporter/templates/logic_header.ttk
Open-ILS/src/reporter/templates/logout.ttk
Open-ILS/src/reporter/templates/navbar.ttk [new file with mode: 0644]
Open-ILS/src/reporter/templates/stage1.ttk
Open-ILS/src/reporter/templates/stage2.ttk
Open-ILS/src/reporter/templates/stage3.ttk [new file with mode: 0644]
Open-ILS/src/reporter/templates/widget_manip [new file with mode: 0644]
Open-ILS/src/reporter/templates/widgets/specific-timerange.multimonth [new file with mode: 0644]
Open-ILS/src/reporter/templates/widgets/string-choose.dropdown
Open-ILS/src/reporter/templates/widgets/string-choose.multiselect [new file with mode: 0644]

index 788c920..d8454c6 100644 (file)
@@ -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 (file)
index 0000000..5fdd59b
--- /dev/null
@@ -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%";
+                               %]<b>Name:</b>[%
+                       END;
+                       WRAPPER html/cell;
+                               class.findvalue('label');
+                       END;
+               END;
+               WRAPPER html/row;
+                       WRAPPER html/cell align="right";
+                               %]<b>Description:</b>[%
+                       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";
+                                       %]<b>Actions:</b>[%
+                               END;
+                               WRAPPER html/cell;
+                                       IF CGI.param('detail');
+                                               %]<a href="?detail=0&id=[% fact_table %]">No Details</a>[%
+                                       ELSE;
+                                               %]<a href="?detail=1&id=[% fact_table %]">Details</a>[%
+                                       END;
+                                       %]|<a href="?create_stage2=1&id=[% fact_table %]">New Report Template</a>[%
+                               END;
+                       END;
+                       WRAPPER html/row;
+                               INCLUDE html/cell align="right" valign='top' content='<b>Report Templates:</b>';
+                               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;
+                                                       '<br>';
+                                       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";
+                               %]<b>Report Dimensions<br>and Attributes:</b>[%
+                       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 (file)
index 0000000..09f2700
--- /dev/null
@@ -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;
+
+%]
index a0bee08..7cce23f 100644 (file)
@@ -10,5 +10,8 @@
 
        <title>[% title %]</title>
 
+       <style>
+               .navbar { border-bottom: 1px solid gray; padding-right: 20px; padding-left: 5px; }
+       </style>
 </head>
 
diff --git a/Open-ILS/src/reporter/templates/inputs b/Open-ILS/src/reporter/templates/inputs
new file mode 100644 (file)
index 0000000..db967ac
--- /dev/null
@@ -0,0 +1,89 @@
+[%
+
+BLOCK form;
+       '<form ';
+
+       IF name;
+               'name="' _ name _ '" ';
+       END;
+
+       IF id;
+               'id="' _ id _ '" ';
+       END;
+
+       IF action;
+               'action="' _ action _ '" ';
+       END;
+
+       IF method;
+               'method="' _ method _ '" ';
+       END;
+
+       '>' _ content _ '</form>';
+END;
+
+BLOCK text;
+       %]<INPUT TYPE="text" NAME="[%
+               name;
+               %]" VALUE="[%
+               value;
+               %]" [%
+               IF size;
+                       %]SIZE="[% size %]" [%
+               END;
+               IF max;
+                       %]MAXLENGTH="[% max %]" [%
+               END;
+               %]>[%
+END;
+
+BLOCK textarea;
+       %]<TEXTAREA NAME="[% name %]">[% value %]</TEXTAREA>[%
+END;
+
+BLOCK select;
+       %]<select name="[% name %]" size="[% size %]"[% IF multi %] multiple="multiple" [% END %]>[%
+               content;
+       %]</select>[%
+END;
+
+BLOCK option;
+       %]<option value="[% value %]"[% IF selected %] selected="selected" [% END %]>[%
+               IF content;
+                       content;
+               ELSE;
+                       value;
+               END;
+       %]</option>[%
+END;
+
+BLOCK hidden;
+       %]<INPUT TYPE="hidden" NAME="[% name %]" VALUE="[% value %]">[%
+END;
+
+BLOCK radio;
+       %]<INPUT TYPE="radio" NAME="[% name %]" VALUE="[% value %]" [% IF checked %]CHECKED[% END %]>[%
+END;
+
+BLOCK checkbox;
+       %]<INPUT TYPE="checkbox" NAME="[% name %]" VALUE="[% value %]" [% IF checked %]CHECKED[% END %]>[%
+END;
+
+BLOCK submit;
+       %]<INPUT TYPE="submit" NAME="[% name %]" VALUE="[% value %]">[%
+END;
+
+MACRO link INCLUDE anchor;
+
+BLOCK anchor;
+       %]<a
+               href="[%href%]"
+               title="[%title%]"
+               class="[%class%]"
+               target="[%target%]"
+               onclick="[%onclick%]"
+               alt="[%alt%]">[%content%]</a>[%
+END;
+
+%]
+
index b8e05dd..d7a0804 100644 (file)
@@ -1,3 +1,8 @@
+<style>
+*  {   font-family: sans-serif;
+               font-size: 10pt;
+}
+</style>
 [%
 
 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 ( ?,?,?,?,?,? )';
 %]
index 7fc38ca..17d1a5a 100644 (file)
@@ -22,7 +22,4 @@
 
 </script>
 
-<span>
-       <a href='javascript:void(0);' onclick='doLogout();'>Logout</a>
-</span>
 
diff --git a/Open-ILS/src/reporter/templates/navbar.ttk b/Open-ILS/src/reporter/templates/navbar.ttk
new file mode 100644 (file)
index 0000000..458c1ad
--- /dev/null
@@ -0,0 +1,12 @@
+<span class='navbar'>
+   <a href='javascript:void(0);' onclick='doLogout();'>Logout</a> |
+   <a href='dashboard'>Dashboard</a>
+       [% IF links.list.size > 0;
+                       ' | ';
+                       links.list.join(' | ');
+               END; %]
+</span>
+
+<br>
+<br>
+
index cf5e1d2..82c8f15 100644 (file)
@@ -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');
-                               %]|<a href="?detail=0">No Details (All)</a>[%
+                               %]<a href="?detail=0">No Details (All)</a>[%
                        ELSE;
-                               %]|<a href="?detail=1">Details (All)</a>[%
+                               %]<a href="?detail=1">Details (All)</a>[%
                        END;
                        INCLUDE all_stage1;
                ELSE;
@@ -33,7 +33,7 @@ END;
 
 
 BLOCK one_stage1;
-       %]|<a href="[%
+       %]<a href="[%
        CGI.url('-absolute',1,'-path_info',1,'-query',1)
                .replace('[&\?;]?id=[\w\.]+','')
                .replace('[&\?;]?create_stage2=1','');
index e865eb8..5b1f3a6 100644 (file)
@@ -4,6 +4,7 @@ PROCESS inputs;
 PROCESS class_manip;
 PROCESS widget_manip;
 PROCESS logic_header.ttk;
+INCLUDE logout.ttk;
 
 templates = DBI.tie('reporter.stage2', 'id')
 tmpl = {};
@@ -16,9 +17,8 @@ END;
 
 
 WRAPPER html/html;
-   INCLUDE header.ttk title="Report Templates";
+   INCLUDE header.ttk + navbar.ttk title="Report Templates";
    WRAPPER html/body;
-      INCLUDE logout.ttk;
       IF CGI.param('action') == 'save';
          PROCESS save_stage2;
       ELSIF CGI.param('action') == 'edit';
@@ -100,11 +100,11 @@ BLOCK view_stage2;
                        WRAPPER html/cell colspan=5 align='center';
                                s1_name_xpath = '/reporter/tables/table[@id="' _ params.stage1 _ '"]/label';
                                INCLUDE anchor
-                                       text=config.findvalue( s1_name_xpath )
+                                       content=config.findvalue( s1_name_xpath )
                                        href="stage1?id=" _ params.stage1;
                                ' :: ' _ params.templatename _ '<br>';
                                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 );
 
-   %]<br/><form id="stage3_new" name="stage3_new" action="stage3" method="POST">[%
+   '<br/>';
+       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');
+               '<br>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="<b>Filterable Attributes:</b>";
-               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="<b>Filterable Attributes:</b>";
                        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="<br>";
-               END;
-
-               WRAPPER html/row;
-                       INCLUDE html/cell colspan=4 content="<b>Attributes Available for Output</b>";
-               END;
+       
+                       WRAPPER html/row;
+                               INCLUDE html/cell colspan=4 content="<br>";
+                       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="<b>Attributes Available for Output</b>";
                        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;
+                                                       '<br/>';
+                                                       '<small><super>*</super>Output Tranformation Parameter: </small>';
+                                                       INCLUDE text name="xform:param:$classname:$fid";
                                                END;
-                                               '<br/>';
-                                               '<small><super>*</super>Output Tranformation Parameter: </small>';
-                                               INCLUDE text name="xform:param:$classname:$fid";
                                        END;
                                END;
                        END;
                END;
-       END;
-
-       INCLUDE checkbox name="publicreport" value="t";
-       'Public Report<br>';
-       INCLUDE submit name="action" value="Run Now";
-       INCLUDE submit name="action" value="Schedule";
+       
+               INCLUDE checkbox name="publicreport" value="t";
+               'Public Report<br>';
+               INCLUDE submit name="action" value="Run Now";
+               INCLUDE submit name="action" value="Schedule";
 
-       %]</form>[%
+       END;
 END;
 
 %]
diff --git a/Open-ILS/src/reporter/templates/stage3.ttk b/Open-ILS/src/reporter/templates/stage3.ttk
new file mode 100644 (file)
index 0000000..4e251b7
--- /dev/null
@@ -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';
+               '<br>';
+
+               '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;
+               '<br>';
+               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 (file)
index 0000000..1d09eb8
--- /dev/null
@@ -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);
+
+                               '<UL>';
+                               FOR fam IN widget_fams;
+
+                                       fam_input = 'radio';
+                                       IF loop.size == 1;
+                                               fam_input = 'hidden';
+                                       END;
+
+                                       checked = 0;
+                                       IF loop.count == 1;
+                                               checked = 1;
+                                       END;
+
+                                       fam_name = fam.findvalue('@name');
+                                       # radio for widget family here ...
+                                       '<LI>';
+                                       INCLUDE $fam_input
+                                               name="filter:$tableid:$column_name"
+                                               value= fam_name;
+                                       fam.findvalue('label');
+                                       '<UL>';
+                                       
+                                       FOR widget IN fam.findnodes('widget');
+
+                                               fam_input = 'radio';
+                                               IF loop.size == 1;
+                                                       fam_input = 'hidden';
+                                               END;
+
+                                               checked = 0;
+                                               IF loop.count == 1;
+                                                       checked = 1;
+                                               END;
+
+                                               widget_name = widget.findvalue('@name');
+                                               # radio for widget here ...
+                                               '<LI>';
+                                               INCLUDE $fam_input
+                                                       name="filter:$tableid:$column_name:$fam_name"
+                                                       value= widget_name;
+                                               widget.findvalue('label');
+                                               '</LI>';
+                                       END;
+                                       '</UL>';
+                                       '</LI>';
+                               END;
+                               '</UL>';
+                       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 (file)
index 0000000..0d02bd8
--- /dev/null
@@ -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;
+
+%]
index aa6b0cf..3d47bf8 100644 (file)
@@ -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 (file)
index 0000000..c012756
--- /dev/null
@@ -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;
+
+%]