]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/reporter/templates/dashboard.ttk
yay! the reporter spits out csv and excel now ... html tomorrow (with any luck)
[Evergreen.git] / Open-ILS / src / reporter / templates / dashboard.ttk
1 [%
2
3 PROCESS inputs;
4 PROCESS class_manip;
5 PROCESS widget_manip;
6 PROCESS logic_header.ttk;
7
8 pagetype = CGI.param('detail');
9
10 %] <style> table {border-collapse:collapse;}</style> [%
11
12 SWITCH pagetype;
13         CASE 'myreports';
14                 INCLUDE header.ttk title="Reporter Dashboard -- My Recent Reports";
15                 INCLUDE navbar.ttk + my_reports;
16         CASE 'mytemplates';
17                 INCLUDE header.ttk title="Reporter Dashboard -- My Recent Templates";
18                 INCLUDE navbar.ttk + my_templates;
19         CASE 'othersreports';
20                 INCLUDE header.ttk title="Reporter Dashboard -- Others Recent Public Reports";
21                 INCLUDE navbar.ttk + public_reports;
22         CASE 'otherstemplates';
23                 INCLUDE header.ttk title="Reporter Dashboard -- Others Recent Public Templates";
24                 INCLUDE navbar.ttk + public_templates;
25         CASE 'facttables';
26                 INCLUDE header.ttk title="Reporter Dashboard -- Core Fact Tables";
27                 INCLUDE navbar.ttk + fact_tables;
28         CASE;
29                 INCLUDE header.ttk title="Reporter Dashboard";
30                 INCLUDE navbar.ttk + summary;
31 END;
32
33 PROCESS logout.ttk;
34
35 BLOCK summary; 
36         WRAPPER html/table border=0 width='100%';
37                 WRAPPER html/row;
38                         INCLUDE html/cell
39                                 width='50%'
40                                 content=link(content='My Recent Reports',href='dashboard?detail=myreports')
41                                 align='center'
42                                 style='border-bottom:1px solid black';
43                         INCLUDE html/cell
44                                 content=link(content='Others Recent Public Reports',href='dashboard?detail=othersreports')
45                                 align='center'
46                                 style='border-bottom:1px solid black';
47                 END;
48                 WRAPPER html/row;
49                         WRAPPER html/cell valign='top' style='height:200px';
50                                 INCLUDE my_reports limit=5;
51                         END;
52                         WRAPPER html/cell valign='top';
53                                 INCLUDE public_reports limit=5;
54                         END;
55                 END;
56                 WRAPPER html/row;
57                         INCLUDE html/cell
58                                 content=link(content='My Recent Templates',href='dashboard?detail=mytemplates')
59                                 align='center'
60                                 style='border-bottom:1px solid black';
61                         INCLUDE html/cell
62                                 content=link(content='Others Recent Public Templates',href='dashboard?detail=otherstemplates')
63                                 align='center'
64                                 style='border-bottom:1px solid black';
65                 END;
66                 WRAPPER html/row;
67                         WRAPPER html/cell valign='top' style='height:200px';
68                                 INCLUDE my_templates limit=5;
69                         END;
70                         WRAPPER html/cell valign='top';
71                                 INCLUDE public_templates limit=5;
72                         END;
73                 END;
74                 WRAPPER html/row;
75                         INCLUDE html/cell
76                                 colspan=2
77                                 align='center'
78                                 content=link(content='Core Fact Tables',href='dashboard?detail=facttables')
79                                 style='border-bottom:1px solid black';
80                 END;
81                 WRAPPER html/row;
82                         WRAPPER html/cell colspan=2 valign='top';
83                                 INCLUDE fact_tables;
84                         END;
85                 END;
86         END;
87 END;
88
89 BLOCK my_reports;
90         q = "SELECT * FROM reporter.stage3 WHERE owner = " _ user.id() _
91                 " ORDER BY runtime DESC";
92         IF limit > 0;
93                 q = q _ ' LIMIT ' _ limit;
94         END;
95
96         logme(q);
97
98         INCLUDE show_reports;
99
100 END;
101
102 BLOCK public_reports;
103         q = "SELECT * FROM reporter.stage3 WHERE pub is true" _
104                 " and owner != " _ user.id() _ " ORDER BY runtime DESC";
105         IF limit > 0;
106                 q = q _ ' LIMIT ' _ limit;
107         END;
108
109         logme(q);
110
111         INCLUDE show_reports;
112
113 END;
114
115 BLOCK show_reports;
116         WRAPPER html/table width='100%';
117                 WRAPPER html/row;
118                         INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
119                         INCLUDE html/cell content='Report Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
120                         INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
121                         INCLUDE html/cell content='Scheduled Run Date' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
122                         INCLUDE html/cell content='Recurrence' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
123                 END;
124                 FOR report = DBI.query(q);
125                         rid = report.id;
126                         bg='lightblue';
127                         IF loop.count % 2;
128                                 bg='white';
129                         END;
130                         WRAPPER html/row;
131                                 p = utils.JSON2perl( report.params );
132                                 INCLUDE html/cell content=(report.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
133                                 INCLUDE html/cell content=link(content=p.reportname,href="stage3?id=$rid") col=bg style='border:solid gray 1px;';
134                                 INCLUDE html/cell content=report.create_date.chunk(10).0 col=bg style='border:solid gray 1px;';
135                                 INCLUDE html/cell content=report.runtime.chunk(10).0 col=bg style='border:solid gray 1px;';
136                                 INCLUDE html/cell content=report.recurrence col=bg style='border:solid gray 1px;';
137                         END;
138                 END;
139         END;
140 END;
141
142 BLOCK my_templates;
143         q = "SELECT * FROM reporter.stage2 WHERE " _
144                 " owner = " _ user.id() _ " ORDER BY create_date DESC";
145         IF limit > 0;
146                 q = q _ ' LIMIT ' _ limit;
147         END;
148
149         logme(q);
150
151         INCLUDE show_templates;
152
153 END;
154
155 BLOCK public_templates;
156         q = "SELECT * FROM reporter.stage2 WHERE pub is true" _
157                 " and owner != " _ user.id() _ " ORDER BY create_date DESC";
158         IF limit > 0;
159                 q = q _ ' LIMIT ' _ limit;
160         END;
161
162         logme(q);
163
164         INCLUDE show_templates;
165
166 END;
167
168 BLOCK show_templates;
169         WRAPPER html/table width='100%' class='withborder';
170                 WRAPPER html/row;
171                         INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
172                         INCLUDE html/cell content='Template Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
173                         INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
174                 END;
175                 FOR template = DBI.query(q);
176                         tid = template.id;
177                         bg='lightblue';
178                         IF loop.count % 2;
179                                 bg='white';
180                         END;
181                         WRAPPER html/row;
182                                 p = utils.JSON2perl( template.params );
183                                 INCLUDE html/cell content=(template.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
184                                 INCLUDE html/cell content=link(content=p.templatename,href="stage2?id=$tid") col=bg style='border:solid gray 1px;';
185                                 INCLUDE html/cell content=template.create_date.chunk(10).0 col=bg style='border:solid gray 1px;';
186                         END;
187                 END;
188         END;
189 END;
190
191 BLOCK fact_tables;
192         WRAPPER html/table width='100%' class='withborder';
193                 WRAPPER html/row;
194                         INCLUDE html/cell content='Fact table' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
195                         INCLUDE html/cell content='Description' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
196                 END;
197
198                 fact_table_xpath = "/reporter/tables/table[@fact-table='true']";
199                 FOR tab = config.findnodes(fact_table_xpath);
200                         tid = tab.findvalue('@id');
201                         bg='lightblue';
202                         IF loop.count % 2;
203                                 bg='white';
204                         END;
205                         WRAPPER html/row;
206                                 p = utils.JSON2perl( template.params );
207                                 INCLUDE html/cell
208                                         col=bg
209                                         content=link(content=tab.findvalue('label'),href="stage1?id=$tid") style='border:solid gray 1px;';
210                                 INCLUDE html/cell content=tab.findvalue('description') style='border:solid gray 1px;';
211                         END;
212                 END;
213    END;
214 END;
215
216 %]