bug hunting and a (small) new set of widget code
[Evergreen.git] / Open-ILS / src / reporter / templates / stage1.ttk
1 [%
2
3 PROCESS inputs;
4 PROCESS class_manip;
5 PROCESS widget_manip;
6 PROCESS logic_header.ttk;
7 INCLUDE logout.ttk;
8
9 WRAPPER html/html;
10         INCLUDE header.ttk + navbar.ttk title="Basic Report Types";
11         WRAPPER html/body html.body.onload=
12                                                                 "if (document.getElementById('templatename')) {" _
13                                                                 "document.getElementById('templatename').focus();" _
14                                                                 "document.getElementById('templatename').select();}";
15                 IF !CGI.param('id');
16                         INCLUDE all_stage1;
17                 ELSE;
18                         INCLUDE one_stage1;
19                 END;
20         END;
21         INCLUDE footer.ttk;
22 END;
23
24
25
26
27 #=============================================================================
28
29
30 BLOCK one_stage1;
31         table_xpath =
32                 '/reporter/tables/table[@id="' _
33                 CGI.param('id') _ '"]';
34         table = config.findnodes(table_xpath);
35
36         fact_table = table.findvalue('@id');
37         logme(fact_table);
38
39         INCLUDE class_table classname=table;
40
41         INCLUDE stage2_new IF CGI.param('create_stage2') == 1;
42
43 END;
44
45
46
47
48 BLOCK all_stage1;
49         '<ul>';
50
51         FOR tab = config.findnodes("/reporter/tables/table[@fact-table='true']");
52
53                 fact_table = tab.findvalue("@id");
54                 logme("Fact Table is $fact_table");
55
56                 '<li>';
57
58                 INCLUDE class_table classname=tab;
59
60                 IF loop.count != loop.size;
61                 '<hr>';
62                 END;
63         END;
64         '</ul>';
65 END;
66
67
68
69
70
71 BLOCK stage2_new;
72         col_xpath = "/reporter/tables/table[@id='" _ fact_table _ "']/fields/field[@core='true']";
73         logme(col_xpath);
74
75         %]<br/><form id="stage2_new" name="stage2_new" action="stage2" method="POST" onsubmit="return require_name(this)">
76                 <script language="javascript">
77                         function require_name (f) {
78                                 if (!f.elements['templatename'].value) {
79                                         alert("Template Name is required!");
80                                         return false;
81                                 }
82                                 return true;
83                         }
84                 </script>
85                 <input type="hidden" name="action" value="save">
86                 <input type="hidden" name="stage1" value="[% CGI.param('id') %]">
87                 <center>
88                         <b>Template name </b> <input type="text" name="templatename" id="templatename" size="40" ><br/><br><br>
89                 </center>
90                 <b>Select Filter Widgets and Output Dimensions</b><br>[%
91
92         
93         WRAPPER html/table width="100%" style='border-top: 1px solid black';
94                 WRAPPER html/row;
95                         WRAPPER html/cell colspan=2  align='left' style="padding-left: 30px; border: solid black 1px; background: lightgray;";
96                                 # hidden input here ...
97                                 table = config.findnodes("/reporter/tables/table[@id='$fact_table']");
98                                 INCLUDE hidden name="filter" value=fact_table;
99                                 table.findvalue('label');
100                                 ' Core Columns';
101                         END;
102                 END;
103                 #WRAPPER html/row;
104                 #       INCLUDE html/cell content='<b>Attribute</b>' align='right';
105                 #       INCLUDE html/cell content='<b>Widget</b>' align='center';
106                 #END;
107                 INCLUDE widget_selector tableid=fact_table columns=config.findnodes(col_xpath) force=1;
108         END;
109
110         dim_xpath = "/reporter/tables/table[@id='$fact_table']/links/link";
111         FOR dim_link = config.findnodes(dim_xpath);
112                 dim_table = dim_link.findvalue('@table');
113                 link_id = dim_link.findvalue('@id');
114                 dimension = config.findnodes("/reporter/tables/table[@id='$dim_table']");
115
116                 '<br/><br/>';
117
118                 WRAPPER html/table width="100%" style='border-top: 1px solid black';
119                         WRAPPER html/row;
120                                 WRAPPER html/cell align='left' width="33%" style="padding-left: 30px; border: solid black 1px; background: lightgray;";
121
122                                         link_label_xpath = '../../fields/field[@name="' _ dim_link.findvalue('@field') _ '"]/label';
123                                         dim_link.findvalue(link_label_xpath);
124
125                                         ' -- ';
126                                         dimension.findvalue('label');
127                                         ' Dimension';
128
129                                 END;
130                                 WRAPPER html/cell align='left' style="padding-left: 30px; border: solid black 1px; background: white;";
131                                         # checkbox input here ...
132                                         INCLUDE checkbox name="filter" value=link_id checked=1;
133                                         'Allow these columns to be used in Report Output';
134                                 END;
135                         END;
136                         INCLUDE widget_selector tableid=link_id;
137                 END;
138         END;
139
140         %]
141                 <input type="checkbox" name="publictemplate" value="t">Public template<br><br>
142         [%
143         INCLUDE submit name='button' value='Save';
144
145         '</form>';
146
147 END;
148
149 %]
150