]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/reporter/templates/dashboard.ttk
libraries are now filtered on id (there are duplicate names, such as "Bookmobile")
[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 Time<br>Last Run Time' 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                         INCLUDE html/cell content='Runs' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
124                 END;
125                 FOR report = DBI.query(q);
126                         rid = report.id;
127                         bg='lightblue';
128                         IF loop.count % 2;
129                                 bg='white';
130                         END;
131                         run_q = 'SELECT * FROM reporter.output WHERE stage3 = ? ORDER BY queue_time LIMIT 1';
132                         run_count_q = 'SELECT count(*) as count FROM reporter.output WHERE stage3 = ?';
133
134                         s = DBI.prepare(run_count_q);
135                         run_count = s.execute(rid);
136                         
137                         s = DBI.prepare(run_q);
138                         run = s.execute(rid);
139                         
140                         WRAPPER html/row;
141                                 p = utils.JSON2perl( report.params );
142                                 INCLUDE html/cell content=(report.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
143                                 INCLUDE html/cell content=link(content=p.reportname,href="stage3?id=$rid") col=bg style='border:solid gray 1px;';
144                                 INCLUDE html/cell nowrap='nowrap' content=report.create_date.chunk(19).0 col=bg style='border:solid gray 1px;';
145                                 INCLUDE html/cell
146                                         nowrap='nowrap'
147                                         content=report.runtime.chunk(19).0 _ '<br>' _ run.get.run_time.chunk(19).0
148                                         col=bg
149                                         style='border:solid gray 1px;';
150                                 INCLUDE html/cell content=report.recurrence col=bg style='border:solid gray 1px;';
151                                 INCLUDE html/cell content=run_count.get.count col=bg style='border:solid gray 1px;';
152                         END;
153                 END;
154         END;
155 END;
156
157 BLOCK my_templates;
158         q = "SELECT * FROM reporter.stage2 WHERE " _
159                 " owner = " _ user.id() _ " ORDER BY create_date DESC";
160         IF limit > 0;
161                 q = q _ ' LIMIT ' _ limit;
162         END;
163
164         logme(q);
165
166         INCLUDE show_templates;
167
168 END;
169
170 BLOCK public_templates;
171         q = "SELECT * FROM reporter.stage2 WHERE pub is true" _
172                 " and owner != " _ user.id() _ " ORDER BY create_date DESC";
173         IF limit > 0;
174                 q = q _ ' LIMIT ' _ limit;
175         END;
176
177         logme(q);
178
179         INCLUDE show_templates;
180
181 END;
182
183 BLOCK show_templates;
184         WRAPPER html/table width='100%' class='withborder';
185                 WRAPPER html/row;
186                         INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
187                         INCLUDE html/cell content='Template Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
188                         INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
189                 END;
190                 FOR template = DBI.query(q);
191                         tid = template.id;
192                         bg='lightblue';
193                         IF loop.count % 2;
194                                 bg='white';
195                         END;
196                         WRAPPER html/row;
197                                 p = utils.JSON2perl( template.params );
198                                 INCLUDE html/cell content=(template.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
199                                 INCLUDE html/cell content=link(content=p.templatename,href="stage2?id=$tid") col=bg style='border:solid gray 1px;';
200                                 INCLUDE html/cell content=template.create_date.chunk(10).0 col=bg style='border:solid gray 1px;';
201                         END;
202                 END;
203         END;
204 END;
205
206 BLOCK fact_tables;
207         WRAPPER html/table width='100%' class='withborder';
208                 WRAPPER html/row;
209                         INCLUDE html/cell content='Fact table' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
210                         INCLUDE html/cell content='Description' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
211                 END;
212
213                 fact_table_xpath = "/reporter/tables/table[@fact-table='true']";
214                 FOR tab = config.findnodes(fact_table_xpath);
215                         tid = tab.findvalue('@id');
216                         bg='lightblue';
217                         IF loop.count % 2;
218                                 bg='white';
219                         END;
220                         WRAPPER html/row;
221                                 p = utils.JSON2perl( template.params );
222                                 INCLUDE html/cell
223                                         col=bg
224                                         content=link(content=tab.findvalue('label'),href="stage1?id=$tid") style='border:solid gray 1px;';
225                                 INCLUDE html/cell content=tab.findvalue('description') style='border:solid gray 1px;';
226                         END;
227                 END;
228    END;
229 END;
230
231 %]