progressing to stage 2 now
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Sep 2005 19:30:17 +0000 (19:30 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Sep 2005 19:30:17 +0000 (19:30 +0000)
focus username on login.ttk

git-svn-id: svn://svn.open-ils.org/ILS/trunk@1879 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/reporter/templates/login.ttk
Open-ILS/src/reporter/templates/stage1.ttk
Open-ILS/src/reporter/templates/stage2.ttk [new file with mode: 0644]

index 5ccef68..f03b526 100644 (file)
@@ -10,6 +10,7 @@
                        var cookie = new cookieObject("ses", 1, "/", COOKIE_SES);
 
                        function initPage() {
+                       document.getElementById("reports_login_username").focus();
                        document.getElementById("reports_login_username").onkeypress = checkInputClicks;
                        document.getElementById("reports_login_password").onkeypress = checkInputClicks;
                        }
@@ -56,7 +57,8 @@
 
                </script>
 
-               <br/><br/>
+               <br/>
+               <center>
                <h3> Reports Login </h3>
                <table style='padding: 4px; border: 2px solid #E0E0E0;'>
                        <tr>
                                <td><input type='submit' value='Login' onclick='doLogin();'/></td>
                        </tr>
                </table>
-
-               <br/><br/>
-               <span> Org Test </span>
-               <br/><br/>
-               [% INCLUDE orgtree.ttk %]
+               </center>
 
        </body>
 
index f6d1763..9399911 100644 (file)
@@ -1,35 +1,14 @@
 [%
 
-BLOCK logme_block;
-       "\n\t<!-- " _ x _ " -->\n";
-END;
-
-MACRO logme(a) PROCESS logme_block x = a.list.join(', ');
-
-USE CGI;
-USE DBI;
-USE WebSession;
-USE utils = WebUtils;
-USE config = XML.LibXML(config_xml, expand_xinclude => 1);
-
-dir = '/reporter/setup/files/' _ stage_dir;
-dir = config.findvalue(dir);
-
-dbname = config.findvalue('/reporter/setup/database/name');
-dbhost = config.findvalue('/reporter/setup/database/host');
-d_u = config.findvalue('/reporter/setup/database/user');
-d_p = config.findvalue('/reporter/setup/database/password');
-
-dsn = "dbi:Pg:dbname=" _ dbname _';host=' _ dbhost;
-
-logme([dsn,d_u,d_p]);
-       
-DBI.connect(dsn,d_u,d_p);
-
+PROCESS inputs;
+PROCESS logic_header.ttk;
 
 WRAPPER html/html;
        INCLUDE header.ttk title="Basic Report Types";
-       WRAPPER html/body;
+       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');
@@ -126,6 +105,22 @@ BLOCK stage1_summary links=0;
                                %]|<a href="?create_stage2=1&id=[% fact_table %]">New Report Template</a>[%
                        END;
                END;
+               WRAPPER html/row;
+                       WRAPPER html/cell align="right" valign='top';
+                               %]Report Templates:[%
+                       END;
+                       WRAPPER html/cell;
+                               q = 'select * from reporter.stage2 ' _
+                                       'where pub is true or owner = ' _ DBI.quote(user.id());
+                               FOR r IN DBI.query(q);
+                                       INCLUDE anchor
+                                               href="stage2?id=" _ r.id
+                                               text=utils.JSON2perl(r.params).templatename;
+                                               '<br>';
+                               END;
+                       END;
+               END;
+
                PROCESS stage1_detail IF CGI.param('detail') == 1;
        END;
 END;
@@ -137,12 +132,21 @@ BLOCK stage2_new;
        col_xpath = "/reporter/tables/table[@id='" _ fact_table _ "']/fields/field[@core='true']";
        logme(col_xpath);
 
+       %]<br/><form id="stage2_new" name="stage2_new" action="stage2" method="POST">
+               <input type="hidden" name="action" value="save">
+                       <input type="hidden" name="stage1" value="[% CGI.param('id') %]">
+                       <input type="text" name="templatename" id="templatename"
+                               size="40" value="Template name (required)"><br/>
+                       <input type="checkbox" name="publictemplate" value="t">
+                               Public template<br><br>[%
+
+       
        WRAPPER html/table width="100%" border=1;
                WRAPPER html/row;
                        WRAPPER html/cell colspan=2;
                                # hidden input here ...
                                table = config.findnodes("/reporter/tables/table[@id='$fact_table']");
-                               INCLUDE hidden name="filtertable" value=fact_table;
+                               INCLUDE hidden name="filter" value=fact_table;
                                table.findvalue('label');
                                ' Core Columns';
                        END;
@@ -159,7 +163,7 @@ BLOCK stage2_new;
                        WRAPPER html/row;
                                WRAPPER html/cell colspan=2;
                                        # checkbox input here ...
-                                       INCLUDE checkbox name="filtertable" value=dim_table checked=1;
+                                       INCLUDE checkbox name="filter" value=dim_table checked=1;
                                        dimension.findvalue('label');
                                        ' Dimension';
                                END;
@@ -168,6 +172,10 @@ BLOCK stage2_new;
                END;
        END;
 
+       INCLUDE submit name='button' value='Save';
+
+       %]</form>[%
+
 END;
 
 
@@ -193,10 +201,10 @@ BLOCK widget_selector;
                column_name=column.findvalue('@name');
 
                WRAPPER html/row;
-                       WRAPPER html/cell valign='top';
+                       WRAPPER html/cell valign='top' align='right';
                                # checkbox for column filter here ...
                                INCLUDE $column_input_type
-                                       name="filtercolumn:$tableid"
+                                       name="filter:$tableid"
                                        value=column_name
                                        checked=1; 
                                column.findvalue('label');
@@ -234,7 +242,7 @@ BLOCK widget_selector;
                                        # radio for widget family here ...
                                        '<LI>';
                                        INCLUDE $fam_input
-                                               name="filterfamily:$tableid:$column_name"
+                                               name="filter:$tableid:$column_name"
                                                value= fam_name;
                                        fam.findvalue('label');
                                        '<UL>';
@@ -309,6 +317,20 @@ BLOCK checkbox;
        %]<INPUT TYPE="checkbox" NAME="[% name %]" VALUE="[% value %]" [% IF checked %]CHECKED[% END %]>[%
 END;
 
+BLOCK submit;
+       %]<INPUT TYPE="submit" NAME="[% name %]" VALUE="[% value %]">[%
+END;
+
+BLOCK anchor;
+       %]<a
+               href="[%href%]"
+               title="[%title%]"
+               class="[%class%]"
+               target="[%target%]"
+               onclick="[%onclick%]"
+               alt="[%alt%]">[%text%]</a>[%
+END;
+
 
 
 
@@ -365,19 +387,6 @@ END;
 
 
 BLOCK stage1_detail;
-       WRAPPER html/row;
-               WRAPPER html/cell align="right";
-                       %]Visible Stage2 reports:[%
-               END;
-               WRAPPER html/cell;
-                       q = 'select count(*) as x from reporter.stage2 ' _
-                               'where pub is true or owner = ' _ DBI.quote(user.id());
-                       FOR r IN DBI.query(q);
-                               r.x;
-                       END;
-               END;
-       END;
-
        PROCESS table_fields table = config.findnodes("/reporter/tables/table[@id='$fact_table']");
 
        WRAPPER html/row;
@@ -401,7 +410,7 @@ BLOCK stage1_detail;
 
                                dim_table = config.findvalue(link_xpath);
 
-                               dim_xpath = '/reporter/tables/table[@id="' _ dim_table _'"]';
+                               dim_xpath = '/reporter/tables/table[@id="' _ dim_table _ '"]';
                                logme(dim_xpath);
                                                        
                                dim_def = config.findnodes(dim_xpath);
diff --git a/Open-ILS/src/reporter/templates/stage2.ttk b/Open-ILS/src/reporter/templates/stage2.ttk
new file mode 100644 (file)
index 0000000..90919af
--- /dev/null
@@ -0,0 +1,152 @@
+[%
+
+PROCESS inputs;
+PROCESS logic_header.ttk;
+
+templates = DBI.tie('reporter.stage2', 'id')
+tmpl = {};
+
+
+IF CGI.param('id');
+       tid = CGI.param('id');
+       tmpl = templates.$tid;
+END;
+
+
+WRAPPER html/html;
+   INCLUDE header.ttk title="Report Templates";
+   WRAPPER html/body;
+      INCLUDE logout.ttk;
+      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 IN 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:$p2:$p3") == p4)
+                       AND (CGI.param("$p1:$p2").list.grep("^$p3$"))
+                       AND (CGI.param("$p1").list.grep("^$p2$"));
+
+                       p_obj.$p1.$p2.$p3.$p4 = CGI.param(p);
+
+               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 );
+       junk = 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
+                                       text=config.findvalue( s1_name_xpath )
+                                       href="stage1?id=" _ params.stage1;
+                               ' :: ' _ params.templatename;
+                       END;
+               END;
+
+               WRAPPER html/row;
+                       INCLUDE html/cell colspan=5 content="Filters:";
+               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;
+                               INCLUDE html/cell colspan=4 align='left' content=table.findvalue( 'label' );
+                       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']" );
+
+                                               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="Available Attributes:";
+               END;
+
+       END;
+END;
+
+
+
+
+
+BLOCK run_stage2;
+
+END;
+
+%]