moved s1.ttk to stage1.ttk
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 22 Sep 2005 19:38:28 +0000 (19:38 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 22 Sep 2005 19:38:28 +0000 (19:38 +0000)
loading and displaying some more report info now (dimensions)

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

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

diff --git a/Open-ILS/src/reporter/templates/s1.ttk b/Open-ILS/src/reporter/templates/s1.ttk
deleted file mode 100644 (file)
index b28dbd9..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-[%
-       USE DBI;
-       USE WebSession;
-       USE utils = WebUtils;
-       USE testdoc = XML::LibXML(config_xml);
-
-       userid = 1;
-
-       dbname = testdoc.findvalue('/reporter/setup/database/name');
-       dbhost = testdoc.findvalue('/reporter/setup/database/host');
-       d_u = testdoc.findvalue('/reporter/setup/database/user');
-       d_p = testdoc.findvalue('/reporter/setup/database/password');
-
-       dsn = "dbi:Pg:dbname=" _ dbname _';host=' _ dbhost;
-
-       '<!-- ' _ dsn _ ', ' _ d_u _ ', ' _ d_p _ ' -->';
-       
-       DBI.connect(dsn,d_u,d_p);
-%]
-
-<html>
-       <body>
-               <h1>Reports: yay!</h1>
-               [% PROCESS PRINT_STAGE1 %]
-       </body>
-</html>
-
-
-
-
-[% BLOCK PRINT_STAGE1 %]
-               <table border=1>
-[%                     FOR s1 IN DBI.query("select * from reporter.stage1 where pub is true;");
-                               USE doc = XML::LibXML(s1.filename); %]
-
-                               <tr>
-                                       <td>
-                                               Name:
-                                       </td>
-                                       <td>
-                                               [%doc.findvalue('/reporter/report/@name')%]
-                                       </td>
-                                       <td>
-                                               Description:
-                                       </td>
-                                       <td>
-                                               [%doc.findvalue('/reporter/report/description')%]
-                                       </td>
-                                       <td>
-                                               Visible Stage2 reports:
-                                       </td>
-                                       <td>
-                                               [% q = 'select count(*) as x from reporter.stage2 ' _
-                                                               'where pub is true or owner = ' _ userid;
-                                               FOR r IN DBI.query(q);
-                                                       r.x;
-                                               END %]
-                                       </td>
-                               </tr>
-
-[%                     END %]
-               </table>
-[% END %]
diff --git a/Open-ILS/src/reporter/templates/stage1.ttk b/Open-ILS/src/reporter/templates/stage1.ttk
new file mode 100644 (file)
index 0000000..fa770ea
--- /dev/null
@@ -0,0 +1,131 @@
+[%
+
+BLOCK logme_block;
+       "\n\t<!-- " _ x _ " -->\n";
+END;
+
+MACRO logme(a) PROCESS logme_block x = a.list.join(', ');
+
+%]
+
+[%
+       USE DBI;
+       USE WebSession;
+       USE utils = WebUtils;
+       USE config = XML.LibXML(config_xml);
+
+       userid = 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);
+%]
+
+<html>
+       <body>
+               [% PROCESS PRINT_STAGE1 %]
+       </body>
+</html>
+
+
+
+
+[% BLOCK PRINT_STAGE1 %]
+               <table border=1>
+[%                     FOR s1 IN DBI.query("select * from reporter.stage1 where pub is true;");
+                               file = dir _ '/' _ s1.filename;
+                               USE doc = XML.LibXML(file);
+                               fact_table = doc.findvalue('//report/@fact-table');
+                               logme(fact_table);
+%]
+
+                               <tr>
+                                       <td>
+                                               Name:
+                                       </td>
+                                       <td>
+                                               [%doc.findvalue('/reporter/report/@name')%]
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               Description:
+                                       </td>
+                                       <td>
+                                               [%doc.findvalue('/reporter/report/description')%]
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               Visible Stage2 reports:
+                                       </td>
+                                       <td>
+                                               [% q = 'select count(*) as x from reporter.stage2 ' _
+                                                               'where pub is true or owner = ' _ userid;
+                                               FOR r IN DBI.query(q);
+                                                       r.x;
+                                               END %]
+                                       </td>
+                               </tr>
+[% INCLUDE table_fields table = config.findnodes("/reporter/tables/table[@id='$fact_table']") %]
+                               <tr>
+                                       <td>
+                                               Report Attributes<br/>(dimensions):
+                                       </td>
+                                       <td>
+[%
+                                               incs = doc.findnodes('//report/dims/dim/@include');
+
+                                               FOR dim IN incs;
+                                                       '<table border=1>';
+
+                                                       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 dim_description dim = dim_def;
+                                                       '</table>';
+                                               END
+%]
+                                       </td>
+                               </tr>
+
+[%                     END %]
+               </table>
+[% END %]
+
+[% BLOCK dim_description %]
+
+<tr>
+       <td>Name:</td>
+       <td>[% dim.findvalue('name') %]</td>
+</tr>
+[% INCLUDE table_fields table = dim %]
+[% END %]
+
+[% BLOCK table_fields %]
+[%             FOR f IN table.findnodes('fields/field') %]
+<tr>
+       <td>Field:</td>
+       <td>[% f.findvalue('@name') %] ([% f.findvalue('@datatype') %])</td>
+</tr>
+[%             END %]
+
+[% END %]