Bug 13618: Add html filters to all the variables
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reports / guided_reports_start.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE Koha %]
5 [% USE ColumnsSettings %]
6 [% SET footerjs = 1 %]
7 [%- BLOCK area_name -%]
8     [%- SWITCH area -%]
9         [%- CASE 'CIRC' -%]Circulation
10         [%- CASE 'CAT'  -%]Catalog
11         [%- CASE 'PAT'  -%]Patrons
12         [%- CASE 'ACQ'  -%]Acquisitions
13         [%- CASE 'ACC'  -%]Accounts
14         [%- CASE 'SER'  -%]Serials
15     [%- END -%]
16 [%- END -%]
17
18 [% INCLUDE 'doc-head-open.inc' %]
19
20 <title>Koha &rsaquo; Reports &rsaquo; Guided reports wizard [%- IF ( saved1 ) -%]&rsaquo; Saved reports
21 [%- ELSIF ( create ) -%]&rsaquo; Create from SQL
22 [%- ELSIF ( showsql ) -%]&rsaquo; Saved reports &rsaquo; SQL view
23 [%- ELSIF ( execute ) -%]&rsaquo; Saved reports &rsaquo; [% name | html %] Report
24 [%- ELSIF ( editsql ) -%]&rsaquo; Saved reports &rsaquo; Edit SQL report
25 [%- END -%]
26 [%- IF ( build1 ) -%]&rsaquo; Build a report, step 1 of 6: Choose a module
27 [%- ELSIF ( build2 ) -%]&rsaquo; Build a report, step 2 of 6: Pick a report type
28 [%- ELSIF ( build3 ) -%]&rsaquo; Build a report, step 3 of 6: Select columns for display
29 [%- ELSIF ( build4 ) -%]&rsaquo; Build a report, step 4 of 6: Select criteria to limit on
30 [%- ELSIF ( build5 ) -%]&rsaquo; Build a report, step 5 of 6: Pick which columns to total
31 [%- ELSIF ( build6 ) -%]&rsaquo; Build a report, step 6 of 6: Select how you want the report ordered
32 [%- END -%]</title>
33
34 [% INCLUDE 'doc-head-close.inc' %]
35 [% IF ( saved1 ) %]
36     [% Asset.css("css/reports.css") %]
37     [% Asset.css("css/datatables.css") | $raw %]
38 [% END %]
39 </head>
40
41 <body id="rep_guided_reports_start" class="rep">
42 [% INCLUDE 'header.inc' %]
43 [% INCLUDE 'circ-search.inc' %]
44
45 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>
46 &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
47 &rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
48
49 [% IF ( saved1 ) %]&rsaquo; Saved reports
50 [% ELSIF ( create ) %]&rsaquo; Create from SQL
51 [% ELSIF ( showsql ) %]&rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> &rsaquo; SQL view
52 [% ELSIF ( editsql ) %]&rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> &rsaquo; Edit SQL report
53 [% ELSIF ( execute ) %]&rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> &rsaquo; <em>[% name | html %]</em> Report
54 [% ELSIF ( build1 || build2 || build3 || build4 || build5 || build6 ) %]&rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a report</a>
55     [% IF ( build1 ) %]&rsaquo; Step 1 of 6: Choose a module
56     [% ELSIF ( build2 ) %]&rsaquo; Step 2 of 6: Pick a report type
57     [% ELSIF ( build3 ) %]&rsaquo; Step 3 of 6: Select columns for display
58     [% ELSIF ( build4 ) %]&rsaquo; Step 4 of 6: Select criteria to limit on
59     [% ELSIF ( build5 ) %]&rsaquo; Step 5 of 6: Pick which columns to total
60     [% ELSIF ( build6 ) %]&rsaquo; Step 6 of 6: Select how you want the report ordered
61     [% END %]
62 [% END %]
63 </div>
64
65 <div id="update_sql" class="modal" tabindex="-1" role="dialog" aria-labelledby="update_sql_label" aria-hidden="true">
66     <div class="modal-dialog">
67     <div class="modal-content">
68     <div class="modal-header">
69         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
70         <h3 id="update_sql_label">Update SQL</h3>
71     </div>
72     <div class="modal-body">
73         <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
74     </div>
75     <div class="modal-footer">
76         <a href="#" class="btn btn-default" id="update_sql_button" role="button" data-toggle="modal">Update</a>
77         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
78     </div>
79     </div>
80     </div>
81 </div>
82
83 <div id="doc3" class="yui-t1">
84 <div id="bd">
85 <div id="yui-main">
86     <div class="yui-b">
87     [% INCLUDE "reports-toolbar.inc" %]
88
89 [% IF ( start ) %]
90     <h2>Guided reports</h2>
91     <p>Use the guided reports engine to create non standard reports.
92 This feature aims to provide some middle ground between the built in
93 canned reports and writing custom SQL reports.</p>
94
95     <h3>Build and run reports</h3>
96         [% IF ( CAN_user_reports_create_reports ) %]
97         <form action="/cgi-bin/koha/reports/guided_reports.pl">
98             <input type="hidden" name="phase" value="Build new" />
99             <input type="submit" name="submit" value="Build new"/>
100         </form>
101         [% END %]
102         [% IF ( CAN_user_reports_execute_reports ) %]
103         <form action="/cgi-bin/koha/reports/guided_reports.pl">
104             <input type="hidden" name="phase" value="Use saved"/>
105             <input type="submit" name="submit" value="Use saved"/>
106         </form>
107         [% END %]
108         [% IF ( CAN_user_reports_create_reports ) %]
109         <form action="/cgi-bin/koha/reports/guided_reports.pl">
110             <input type="hidden" name="phase" value="Create report from SQL"/>
111             <input type="submit" name="submit" value="Create report from SQL"/>
112         </form>
113         [% END %]
114 <h3>Reports Dictionary</h3>
115 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
116 <form action="/cgi-bin/koha/reports/dictionary.pl">
117 <input type="hidden" name="phase" value="View Dictionary"/>
118 <input type="submit" name="submit" value="View dictionary"/>
119 </form>
120 [% END %]
121
122 [% IF report_converted %]
123     <div class="dialog message">
124         The report "[% report_converted | html %]" has been converted.
125     </div>
126 [% END %]
127
128 [% IF ( saved1 ) %]
129 [% IF ( savedreports ) %]<h1>Saved reports</h1>
130
131 [% IF ( filters.date || filters.author || filters.keyword ) %]
132     <p>Filtered by:
133         <span class="filter">
134             [% IF ( filters.date ) %]
135                 <span class="filter_date"><strong>Date:</strong> [% filters.date | html %]</span>
136             [% END %]
137             [% IF ( filters.author ) %]
138                 <span class="filter_author"><strong>Author:</strong> [% filters.author | html %]</span>
139             [% END %]
140             [% IF ( filters.keyword ) %]
141                 <span class="filter_keyword"><strong>Keyword:</strong> [% filters.keyword | html %]</span>
142             [% END %]
143             <a class="clear_filter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1"><i class="fa fa-remove"></i> Clear</a>
144         </span>
145     </p>
146 [% END %]
147
148 <div id="tabs" class="toptabs">
149     <ul>
150         <li><a href="#reports">All</a></li>
151         [% FOREACH group IN groups_with_subgroups %]
152             <li><a id="[% group.id | html %]" href="#reports">[% group.name | html %]</a></li>
153         [% END %]
154     </ul>
155     <div id="reports">
156         <div id="subgroup_filter_block">
157             <label for="subgroup_filter">Subgroup:</label>
158             <select id="subgroup_filter">
159                 <option value="">All</option>
160             </select>
161         </div>
162 <form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
163 <input type="hidden" name="phase" value="Delete Multiple" />
164         <table id="table_reports">
165             <thead>
166                 <tr>
167                     <th>&nbsp;</th>
168                     <th>ID</th>
169                     <th>Report name</th>
170                     <th>Type</th>
171                     <th>Group</th>
172                     <th>Subgroup</th>
173                     <th>Notes</th>
174                     <th>Author</th>
175                     <th class="title-string">Creation date</th>
176                     <th class="title-string">Last edit</th>
177                     <th class="title-string">Last run</th>
178                     <th class="report_public">Public</th>
179                     <th class="report_json_url">JSON URL</th>
180                     [% IF (usecache) %]
181                         <th>Cache expiry (seconds)</th>
182                     [% ELSE %]
183                         <th class="hidden">&nbsp;</th>
184                     [% END %]
185                     <th>Saved results</th>
186                     [% IF has_obsolete_reports %]
187                         <th>Update</th>
188                     [% ELSE %]
189                         <th class="hidden">&nbsp;</th>
190                     [% END %]
191                     <th>Actions</th>
192                 </tr>
193             </thead>
194             <tbody>
195                 [% FOREACH savedreport IN savedreports %]
196                     [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
197                         <td>
198                             [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
199                                 <input type="checkbox" name="ids" value="[% savedreport.id | html %]" />
200                             [% END %]
201                         </td>
202                         <td><label for="ids">[% savedreport.id | html %]</label></td>
203                         <td>
204                             [% IF ( savedreport.report_name ) %]
205                                 [% savedreport.report_name | html %]
206                             [% ELSE %]
207                                 [ no name ]
208                             [% END %]
209                         </td>
210                         <td>[% savedreport.type | html %]</td>
211                         <td>[% savedreport.groupname | html %]</td>
212                         <td>[% savedreport.subgroupname | html %]</td>
213                         <td>[% savedreport.notes | html %]</td>
214                         <td>[% savedreport.borrowersurname | html %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname | html %][% END %] ([% savedreport.borrowernumber | html %])</td>
215                         <td><span title="[% savedreport.date_created | html %]">[% savedreport.date_created | $KohaDates %]</span></td>
216                         <td><span title="[% savedreport.last_modified | html %]">[% savedreport.last_modified | $KohaDates with_hours => 1 | html %]</span></td>
217                         <td><span title="[% savedreport.last_run | html %]">[% savedreport.last_run | $KohaDates with_hours => 1 | html %]</span></td>
218                         <td class="report_public">
219                         [% IF (savedreport.public) %]
220                             Yes
221                         [% ELSE %]
222                             No
223                         [% END %]
224                         </td>
225                         <td class="report_json_url">
226                         [% IF (savedreport.public) %]
227                             <a href="[% OPACBaseURL | html %]/cgi-bin/koha/svc/report?id=[% savedreport.id | uri %]">[% OPACBaseURL | html %]/cgi-bin/koha/svc/report?id=[% savedreport.id | html %]</a>
228                         [% ELSE %]
229                             <a href="/cgi-bin/koha/svc/report?id=[% savedreport.id | uri %]">[% Koha.Preference('staffClientBaseURL') | html %]/cgi-bin/koha/svc/report?id=[% savedreport.id | html %]</a>
230                         [% END %]
231                         </td>
232                         <td>[% savedreport.cache_expiry | html %]</td>
233                         <td>
234                             [% FOR result IN savedreport.results %]
235                                 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&amp;id=[% result.id | html %]">[% result.date_run | html %]</a>
236                                 <br/>
237                             [% END %]
238                         </td>
239                         <td>
240                             [% IF savedreport.seems_obsolete %]
241                                 This report seems obsolete, it uses biblioitems.marcxml field.
242                                 <a href="/cgi-bin/koha/svc/convert_report?report_id=[% savedreport.id | html %]" data-report_id="[% savedreport.id | html %]" class="update_sql btn btn-default btn-xs" title="Update SQL"><i class="fa fa-eye"></i> Update SQL</a>
243                             [% END %]
244                         </td>
245                         <td>
246                             <div class="dropup">
247                                 <div class="btn-group">
248                                     [%# There should be no space between these two buttons, it would render badly %]
249                                     <a class="btn btn-default btn-xs" role="button"
250                                        href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&amp;phase=Run%20this%20report"><i
251                                        class="fa fa-play"></i> Run</a><a
252                                        class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown"
253                                        href="#"><b class="caret"></b></a>
254                                     <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
255                                         <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&amp;phase=Show%20SQL"><i class="fa fa-search"></i> Show</a></li>
256                                         [% IF ( CAN_user_reports_create_reports ) %]
257                                             <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&amp;phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a></li>
258                                             <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from SQL&amp;sql=[% savedreport.savedsql |uri %]&amp;reportname=[% savedreport.report_name |uri %]&amp;notes=[% savedreport.notes |uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
259                                         [% END %]
260                                         <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | html %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
261                                         [% IF ( CAN_user_reports_delete_reports ) %]
262                                             <li><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&amp;phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a></li>
263                                         [% END %]
264                                     </ul>
265                                 </div>
266                             </div>
267                         </td>
268                     </tr>
269                 [% END %]
270             </tbody>
271         </table>
272         [% IF ( CAN_user_reports_delete_reports ) %]
273         <fieldset class="action">
274             <input type="submit" value="Delete selected" />
275         </fieldset>
276         [% END %]
277     </form>
278     </div>
279 </div>
280 [% ELSE %]<div class="dialog message">
281     [% IF (filter_set || filters.date || filters.author || filters.keyword) %]
282     <h4>No saved reports match your criteria. </h4>
283     [% IF ( CAN_user_reports_create_reports ) %]
284     <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
285     <input type="hidden" name="phase" value="Build new" />
286         <button type="submit" class="new"><i class="fa fa-plus"></i> New guided report</button>
287     </form>
288
289     <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
290         <input type="hidden" name="phase" value="Create report from SQL" />
291         <button type="submit" class="new"><i class="fa fa-plus"></i> New SQL report</button>
292     </form>
293
294     <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
295     <input type="hidden" name="phase" value="Use saved" />
296     <input type="hidden" name="filter_set" value="1" />
297     <input type="hidden" name="filter_keyword" value="" />
298         <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> Cancel filter</button>
299     </form>
300
301     [% END %]
302     [% ELSE %]
303     <h4>There are no saved reports. </h4>
304     [% IF ( CAN_user_reports_create_reports ) %]
305         <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a new report?</a>
306     [% END %]
307     [% END %]
308     </div>
309 [% END %]
310 [% END %]
311
312
313 [% IF ( build1 ) %]
314 [% IF ( cache_error) %]
315 <div class="dialog alert">
316 <b> Please choose a cache_expiry less than 30 days </b>
317 </div>
318 [% END %]
319 <h1>Build a report</h1>
320 <form action="/cgi-bin/koha/reports/guided_reports.pl">
321 <fieldset class="rows">
322 <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and choose report visibility </legend>
323 <ol>
324   <li>
325     <label for="area">Choose: </label>
326       <select name="area" id="area">
327     [%- FOREACH area IN areas -%]
328       <option value="[% area | html %]">[%- PROCESS area_name area=area -%]</option>
329     [%- END -%]
330       </select>
331   </li>
332 [% IF (public) %]
333   <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</option> </select></li>
334 [% ELSE %]
335   <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0" selected="selected">No (default)</option> <option value="1">Yes</option> </select></li>
336 [% END %]
337 [% IF (usecache) %] <li>
338 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
339 <select id="cache_expiry_units" name="cache_expiry_units">
340 <option value="seconds">Seconds (default)</option>
341 <option value="minutes">Minutes</option>
342 <option value="hours">Hours</option>
343 <option value="days">Days</option>
344 </select>
345 </li>[% END %]
346 </ol>
347 </fieldset>
348 <fieldset class="action">
349 <input type="hidden" name="phase" value="Report on this Area" />
350 <input type="submit" name="submit" value="Next &gt;&gt;" />
351
352 </fieldset>
353 </form>
354 [% END %]
355
356
357 [% IF ( build2 ) %]
358 <h1>Build a report</h1>
359 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
360 <input type="hidden" name="area" value="[% area | html %]" />
361 <input type="hidden" name="public" value="[% public | html %]" />
362 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
363 <fieldset class="rows"><legend>Step 2 of 6: Pick a report type</legend>
364 <ol><li><label for="types">Choose: </label>
365     <select id="types" name="types">
366         <option value="1">Tabular</option>
367         <option value="2" disabled="disabled">Summary</option>
368         <option value="3" disabled="disabled">Matrix</option>
369     </select>
370 </li></ol></fieldset>
371
372 <fieldset class="action">
373     <input type="hidden" name="phase" value="Choose this type" />
374     <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
375     <input type="submit" name="submit" value="Next &gt;&gt;" />
376 </fieldset>
377 </form>
378 </div>
379 <div class="yui-gb"><div class="yui-u first"></div>
380
381 <!--- Summary and Matrix reports have not yet been implemented-->
382 <!--<div class="yui-u">Summary:
383 <img src="[% interface | html %]/[% theme | html %]/img/reports-summary-graphic.gif" /></div>
384 <div class="yui-u">Matrix:
385 <img src="[% interface | html %]/[% theme | html %]/img/reports-matrix-graphic.gif" /></div>-->
386
387 [% END %]
388
389 [% IF ( build3 ) %]
390 <h1>Build a report</h1>
391 <h3>Step 3 of 6: Select columns for display</h3>
392 <p>Note: Be careful selecting when selecting columns. If your choice is too broad it could result in a very large report that will either not complete, or slow your system down.</p>
393
394 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
395     <input type="hidden" name="area" value="[% area | html %]" />
396     <input type="hidden" name="type" value="[% type | html %]" />
397     <input type="hidden" name="public" value="[% public | html %]" />
398     <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
399     <fieldset>
400 <div class="yui-g">
401 <div class="yui-u first">       <div style="float: left;"><select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
402 [% FOREACH column IN columns %]
403 [% IF ( column.table ) %]
404
405 [% IF ( loop.first ) %]
406 [% ELSE %]
407 </optgroup>
408 [% END %]
409
410 <optgroup label="[% column.table | html %]">
411 [% ELSE %]
412 <option value="[% column.name | html %]">
413 [% IF ( column.description ) %][% column.description | html %] &nbsp; / &nbsp; [% column.name | html %]
414 [% ELSE %]
415 [% column.name | html %]
416 [% END %]
417 </option>
418 [% END %]
419 [% END %]
420 </optgroup>
421 </select></div>
422 <div style="width: 6.3em; float: right; margin-top: 100px"><input type="button" name="Add" value="Add" class="button" style="width:6em;" id="addColumn" /><br />
423 <input type="button" name="delete" value="&lt;&lt; Delete" class="button" style="width: 6em; margin: 1em 0;" id="delColumn" /></div>
424 </div>
425
426 <div class="yui-u">
427 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;"></select>
428 </div>
429 </div>
430 </fieldset>
431 <div class="yui-g">
432 <fieldset class="action">
433     <input type="hidden" name="phase" value="Choose these columns" />
434     <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
435     <input type="submit" name="submit" value="Next &gt;&gt;" />
436 </fieldset>
437 </div>
438 </form>
439
440 [% END %]
441
442 [% IF ( build4 ) %]
443 <h1>Build a report</h1>
444 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
445     <input type="hidden" name="area" value="[% area | html %]" />
446     <input type="hidden" name="type" value="[% type | html %]" />
447     <input type="hidden" name="column" value="[% column | html %]" />
448     <input type="hidden" name="public" value="[% public | html %]" />
449     <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
450     <fieldset><legend>Step 4 of 6: Select criteria to limit on</legend>
451     <table>
452         [% FOREACH criteri IN criteria %]
453         <tr>
454         <td>
455             <input type="checkbox" name="criteria_column" id="[% criteri.name | html %]" value="[% criteri.name | html %]" /> 
456             <label for="[% criteri.name | html %]">[% criteri.description | html %] </label>
457         </td>
458         [% IF ( criteri.date ) %]
459         <td>
460             <input type="text" size="10" id="[% criteri.name | html %]_value" name="[% criteri.name | html %]_value" value="" class="datepicker" />
461                 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
462         </td>
463         </tr>
464         [% ELSE %]
465         [% IF ( criteri.textrange ) %]
466             <td>from
467             <input type="text" size="10" id="[% criteri.from | html %]_value" name="[% criteri.from | html %]_value" value="" /> to 
468             <input type="text" size="10" id="[% criteri.to | html %]_value" name="[% criteri.to | html %]_value" value="" />
469             </td>
470             </tr>
471         [% ELSE %]
472             [% IF ( criteri.daterange ) %]
473             <td>from 
474             <input type="text" size="10" id="from_[% criteri.name | html %]_value" name="from_[% criteri.name | html %]_value" value="" class="datepickerfrom" />
475             to
476             <input type="text" size="10" id="to_[% criteri.name | html %]_value" name="to_[% criteri.name | html %]_value" value="" class="datepickerto" />
477                         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
478             </td>
479         </tr>
480             [% ELSE %]
481             <td>
482                 <select name="[% criteri.name | html %]_value">
483                 [% FOREACH value IN criteri.values %]
484                 <option value="[% value.availablevalues | html %]">[% IF ( value.default ) %]Default[% ELSE %][% value.display_value | html %][% END %]</option>
485                 [% END %]
486                 </select>
487             </td>
488             </tr>
489             [% END %]
490         [% END %]
491         [% END %]
492     [% END %]
493     </table>
494     </fieldset>
495
496 [% IF ( definitions ) %]
497 <fieldset><legend>Dictionary definitions</legend>
498 <table>
499 [% FOREACH definition IN definitions %]
500     <tr><td><input type="checkbox" name="definition" value="[% definition.id | html %]" /> [% definition.name | html %]</td></tr>
501 [% END %]
502 </table>
503 </fieldset>
504 [% END %]
505
506 <fieldset class="action"><input type="hidden" name="phase" value="Choose these criteria" />
507     <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
508     <input type="submit" name="submit" value="Next &gt;&gt;" /> </fieldset>
509 </form>
510 [% END %]
511
512
513 [% IF ( build5 ) %]
514 <h1>Build a report</h1>
515 <h3>Step 5 of 6: Pick which columns to total</h3>
516 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
517 <input type="hidden" name="area" value="[% area | html %]" />
518 <input type="hidden" name="type" value="[% type | html %]" />
519 <input type="hidden" name="column" value="[% column | html %]" />
520 <input type="hidden" name="definition" value="[% definition | html %]" />
521 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
522 <input type="hidden" name="public" value="[% public | html %]" />
523 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
524 <fieldset><table>
525 [% FOREACH total_b IN total_by %]
526 <tr><td><input type="checkbox" name="total_by" id="[% total_b.name | html %]" value="[% total_b.name | html %]" /> <label for="[% total_b.name | html %]">[% total_b.name | html %]</label></td>
527 <td><select name="[% total_b.name | html %]_tvalue">
528
529 [% FOREACH selec IN total_b.select %]
530 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
531 [% END %]
532 </select>
533
534 </td></tr>
535 [% END %]
536 </table></fieldset>
537
538 <fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
539     <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
540     <input type="submit" name="submit" value="Next &gt;&gt;" /></fieldset>
541 </form>
542 [% END %]
543
544
545 [% IF ( build6 ) %]
546 <h1>Build a report</h1>
547 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
548 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
549 <input type="hidden" name="area" value="[% area | html %]" />
550 <input type="hidden" name="type" value="[% type | html %]" />
551 <input type="hidden" name="column" value="[% column | html %]" />
552 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
553 <input type="hidden" name="definition" value="[% definition | html %]" />
554 <input type="hidden" name="totals" value="[% totals | html %]" />
555 <input type="hidden" name="public" value="[% public | html %]" />
556 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
557 <fieldset><table>[% FOREACH order_b IN order_by %]
558 <tr><td><input type="checkbox" id="[% order_b.name | html %]" name="order_by" value="[% order_b.name | html %]" /> <label for="[% order_b.name | html %]">[% order_b.name | html %]</label></td><td>
559 <select name="[% order_b.name | html %]_ovalue">
560
561 [% FOREACH selec IN order_b.select %]
562 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
563 [% END %]
564 </select>
565 </td></tr>
566
567 [% END %]
568 </table></fieldset>
569
570 <fieldset class="action">
571 <input type="hidden" name="phase" value="Build report" />
572 <input type="submit" name="submit" value="Finish" /></fieldset>
573 </form>
574 [% END %]
575
576
577 [% IF ( showreport ) %]
578 <h1>Confirm custom report</h1>
579 <p>Your report will be generated with the following SQL statement.</p>
580 <p> 
581 [% sql | html %]
582 </p>
583
584 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
585 <input type="hidden" name="sql" value="[% sql | html %]" />
586 <input type="hidden" name="type" value="[% type | html %]" />
587 <input type="hidden" name="public" value="[% public | html %]" />
588 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
589 <p>You will need to save the report before you can execute it</p>
590 <fieldset class="action"><input type="hidden" name="phase" value="Save" />  
591 <input type="submit" name="submit" value="Save" />  </fieldset>
592 </form>
593 [% END %]
594
595 [% IF ( save ) %]
596 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" class="validated">
597 <input type="hidden" name="sql" value="[% sql | html %]" />
598 <input type="hidden" name="type" value="[% type | html %]" />
599 <input type="hidden" name="area" value="[% area | html %]" />
600 <input type="hidden" name="public" value="[% public | html %]" />
601 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
602 <fieldset class="rows">
603 <legend>Save your custom report</legend>
604 <ol>
605     <li><label for="reportname" class="required">Report name: </label><input type="text" id="reportname" name="reportname" class="required" required="required" /> <span class="required">Required</span></li>
606     [% PROCESS group_and_subgroup_selection %]
607     <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li>
608 </ol></fieldset>
609 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
610 <input type="submit" name="submit" value="Save report" /></fieldset>
611 </form>
612 [% END %]
613
614 [% IF ( warn_authval_problem ) %]
615     <div class="dialog alert">
616         <h3>Errors found when processing parameters for report: [% name | html %]</h3>
617         [% FOREACH problematic_authval IN problematic_authvals %]
618             <p>
619             <strong>[% problematic_authval.name | html %]:</strong> The authorized value category (<strong>[% problematic_authval.authval | html %]</strong>)
620                 you selected does not exist.
621             </p>
622         [% END %]
623         <!-- Save Anyway Form -->
624         <form action='/cgi-bin/koha/reports/guided_reports.pl'>
625         <!--Every parameter the user issued is provided as a hidden field for recovery-->
626             <input type='hidden' name='id' value='[% id | html %]' />
627             <input type='hidden' name='sql' value='[% sql | html %]' />
628             <input type='hidden' name='reportname' value='[% reportname | html %]' />
629             <input type='hidden' name='group' value='[% group | html %]' />
630             <input type='hidden' name='subgroup' value='[% subgroup | html %]' />
631             <input type='hidden' name='notes' value='[% notes | html %]' />
632             <input type='hidden' name='cache_expiry' value='[% cache_expiry | html %]' />
633             <input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units | html %]' />
634             <input type='hidden' name='public' value='[% public | html %]' />
635         [% IF ( phase_update) %]
636             <input type='hidden' name='phase' value='Update SQL' />
637             <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
638         [% ELSIF ( phase_save) %]
639             <input type='hidden' name='area' value='[% area | html %]' />
640             <input type='hidden' name='phase' value='Save Report' />
641             <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
642         [% END %]
643         </form>
644         <!-- Go back to editing -->
645         <form action='/cgi-bin/koha/reports/guided_reports.pl'>
646             <button type="button" class="new goback"><i class="fa fa-fw fa-pencil"></i> Edit SQL</button>
647         </form>
648     </div>
649 [% END %]
650
651 [% IF ( enter_params ) %]
652     <form action='/cgi-bin/koha/reports/guided_reports.pl'>
653         <input type='hidden' name='reports' value="[% reports | html %]" />
654     [% IF ( auth_val_error ) %]
655         <input type='hidden' name='phase' value='Edit SQL' />
656         <div class="dialog alert">
657             <h3>Errors found when processing parameters for report: [% name | html %]</h3>
658             [% FOREACH auth_val_error IN auth_val_errors %]
659                 <p>
660                     <strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
661                     you selected does not exist.
662                 </p>
663             [% END %]
664         </div>
665         <fieldset class="action"><input type="submit" value="Edit SQL" /></fieldset>
666     [% ELSE %]
667         <input type='hidden' name='phase' value='Run this report' />
668         <h1>Enter parameters for report [% name | html %]:</h1>
669         [% IF ( notes ) %]<p>[% notes | html %]</p>[% END %]
670         <fieldset class="rows">
671             <ol>
672             [% FOREACH sql_param IN sql_params %]
673                 <input name="param_name" value="[% sql_param.name | html %]" type="hidden" />
674                 [% IF sql_param.input == 'date' %]
675                     <li>
676                     <label for="date_[% sql_param_entry | html %][% loop.count | html %]">[% sql_param.entry | html %]:</label> <input id="date_[% sql_param_entry | html %][% loop.count | html %]" type="text" value="" size="10" name="sql_params" class="datepicker" />
677                     </li>
678                 [% ELSIF ( sql_param.input == 'text' ) %]
679                     <li><label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label><input id="sql_params[% loop.count | html %]" type="text" name="sql_params" /></li>
680                 [% ELSE %]
681                     <li><label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
682                         <select name="[%- sql_param.input.name | html -%]" tabindex="1"  size="1" id="[%- sql_param.input.id | html -%]">
683                         [% FOREACH value IN sql_param.input.values %]
684                             <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
685                         [% END %]
686                         </select>
687                     </li>
688                 [% END %]
689             [% END %]
690             </ol>
691         </fieldset>
692         <fieldset class="action"><input type="submit" value="Run the report" /></fieldset>
693     [% END %]
694     </form>
695 [% END %]
696
697 [% IF ( execute ) %]
698 <h1>[% name | html %]</h1>
699 [% IF ( notes ) %]<p><span class="label">Notes:</span> [% notes | html %]</p>[% END %]
700 [% IF ( unlimited_total ) %]<p><span class="label">Total number of results:</span> [% unlimited_total | html %][% IF unlimited_total > limit %] ([% limit | html %] shown)[% END %].</p>[% END %]
701 <div id="sql_output" style="display:none;"><span class="label">Report SQL:</span><pre>[% sql | html %]</pre></div>
702 </br>
703
704 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
705     <input type="hidden" name="phase" value="Run this report"/>
706     <input type="hidden" name="reports" value="[% report_id | html %]"/>
707
708     [% FOREACH p IN sql_params %]
709         <input type="hidden" name="sql_params" value="[% p | html %]"/>
710     [% END %]
711
712     <label for="limit">Rows per page: </label>
713     <select name="limit" id="limit">
714         [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] | html %]
715         [% FOREACH l IN limits %]
716                 [% IF l == limit %]
717                     <option value="[% l | html %]" selected="selected">[% l | html %]</option>
718                 [% ELSE %]
719                     <option value="[% l | html %]">[% l | html %]</option>
720                 [% END %]
721         [% END %]
722     </select>
723 </form>
724
725 <div class="pages">[% pagination_bar | $raw %]</div>
726 [% UNLESS ( errors ) %]
727     <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="report_results">
728         <input type="hidden" name="op" value="show" />
729         <table>
730             <tr>
731                 [% FOREACH header_ro IN header_row %]
732                     [% IF header_ro.cell == 'itemnumber' %]
733                         <th>
734                             [% header_ro.cell | html %] <button type="submit" data-toggle="tooltip" title="Send visible items to batch modification" class="btn btn-xs btn-default send_to_item_mod"><i class="fa fa-pencil"></i> Batch modify</button>
735                         </th>
736                     [% ELSE %]
737                         <th>[% header_ro.cell | html %]</th>
738                     [% END %]
739                 [% END %]
740             </tr>
741             [% FOREACH result IN results %]
742                 <tr>
743                     [% FOREACH cells IN result.cells %]
744                         [% place = loop.index | html %]
745                         [% IF header_row.$place.cell == 'itemnumber' %]
746                             <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
747                         [% END %]
748                         <td>[% cells.cell | html %]</td>
749                     [% END %]
750                 </tr>
751             [% END %]
752         </table>
753     </form>
754 [% END %]
755 [% END %]
756
757 [% IF ( create ) %]
758 <script type="text/javascript">
759 $(document).ready(function() {
760     load_group_subgroups();
761 });
762 </script>
763 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" class="validated">
764 <fieldset class="rows">
765 <legend>Create report from SQL</legend>
766 <ol>
767     <li><label for="reportname" class="required">Report name:</label>
768         [% IF ( reportname ) %]<input type="text" class="required" required="required" id="reportname" name="reportname" value="[% reportname | html %]" size="50"/>
769         [% ELSE %]<input type="text" class="required" required="required" id="reportname" name="reportname" size="50" />[% END %] <span class="required">Required</span>
770     </li>
771     [% PROCESS group_and_subgroup_selection %]
772
773 [% IF (public) %]
774   <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</option> </select></li>
775 [% ELSE %]
776   <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0" selected="selected">No (default)</option> <option value="1">Yes</option> </select></li>
777 [% END %]
778 [% IF (usecache) %] <li>
779 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
780 <select id="cache_expiry_units" name="cache_expiry_units">
781 <option value="seconds" selected="selected">Seconds (default)</option>
782 <option value="minutes">Minutes</option>
783 <option value="hours">Hours</option>
784 <option value="days">Days</option>
785 </select>
786 </li>[% END %]
787     <li><label for="notes">Notes:</label> <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea></li>
788 </ol>
789 </fieldset>
790 <fieldset class="rows">
791 <legend>SQL:</legend>
792 <div style="margin:1em;">
793 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea> <span class="required">Required</span>
794 </div>
795 </fieldset>
796
797 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
798 <input type="submit" name="submit" value="Save report" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
799 </fieldset>
800 </form>
801 [% END %]
802
803 [% IF saved_results %]
804 <h1>Saved report results</h1>
805 <h2>[% name | html %]</h2>
806 <p>[% notes | html %]</p>
807 <table>
808 [% FOREACH rows IN saved_results %]
809 <tr>
810 [% FOREACH col IN rows %]
811 <td>[% col | html %]</td>
812 [% END %]
813 <tr>
814 [% END %]
815 </table>
816 [% END %]
817
818 [% IF ( showsql ) %]
819 <fieldset class="rows">
820     <legend>[% reportname | html %]</legend>
821     <ol>
822         [% IF ( notes ) %]<li><span class="label">Notes:</span> [% notes | html %]</li>[% ELSE %][% END %]
823         <li><textarea id="sql">[% sql | html %]</textarea></li>
824     </ol>
825 </fieldset>
826 [% END %]
827
828 [% IF ( save_successful ) %]
829 [% UNLESS ( errors ) %]
830 </br>
831 <div id="report_updated">
832     <div class="dialog message">
833         <p>Your report "[% reportname | html %]" has been saved</p>
834     </div>
835 </div>
836 [% END %]
837 [% END %]
838
839 [% IF ( editsql ) %]
840 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" class="validated">
841 <input type="hidden" name="phase" value="Update SQL" />
842 <input type="hidden" name="id" value="[% id | html %]"/>
843 <fieldset class="rows">
844 <legend>Edit SQL report</legend>
845 <ol>
846 <li><label for="reportname" class="required">Report name: </label><input type="text" id="reportname" name="reportname" value="[% reportname | html %]" size="50" class="required" required="required" /> <span class="required">Required</span></li>
847 [% PROCESS group_and_subgroup_selection %]
848 [% IF (public) %]
849   <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</option> </select></li>
850 [% ELSE %]
851   <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0" selected="selected">No (default)</option> <option value="1">Yes</option> </select></li>
852 [% END %]
853 [% IF (usecache) %] <li>
854 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
855 <select id="cache_expiry_units" name="cache_expiry_units">
856 <option value="seconds">Seconds (default)</option>
857 <option value="minutes">Minutes</option>
858 <option value="hours">Hours</option>
859 <option value="days">Days</option>
860 </select>
861 </li>[% END %]
862 <li><label for="notes">Notes:</label><textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea></li>
863 </ol>
864 </fieldset>
865
866 <fieldset class="rows">
867     <legend>SQL:</legend>
868     <div style="margin:1em;">
869         <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea> <span class="required">Required</span>
870     </div>
871 </fieldset>
872
873 <fieldset class="action">
874 <input type="submit" name="submit" value="Update SQL" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
875 </fieldset>
876 </form>
877
878
879 [% END %]
880
881 [% IF ( errors ) %]
882 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
883 <div class="dialog alert">
884 <b>The following error was encountered:</b><br />
885 [% FOREACH error IN errors %]
886     [% IF ( error.sqlerr ) %]This report contains the SQL keyword <b>[% error.sqlerr | html %]</b>.
887     <br />Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.
888     <br />Please return to the &quot;Saved Reports&quot; screen and delete this report or retry creating a new one.
889     [% ELSIF ( error.queryerr ) %]The database returned the following error: <br />[% error.queryerr | html %]<br />Please check the log for further details.
890     [% ELSIF ( error.cache_expiry ) %]Please select a cache expiry less than 30 days.
891     [% ELSE %]
892     [% END %]
893     <div id="onerror_actions">
894         <a href="#" class="button goback">Return to previous page</a>
895     </div>
896 [% END %]
897 </div>
898 <fieldset class="action"><input type="hidden" name="phase" value="Use saved" />
899 <input type="submit" name="submit" value="Saved reports" /></fieldset>
900 </form>
901 [% END %]
902
903 </div>
904 </div>
905 <div class="yui-b">
906
907 [% IF ( saved1 ) %]
908 <div id="saved-reports-filter">
909 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
910   <input type="hidden" name="phase" value="Use saved" />
911   <input type="hidden" name="filter_set" value="1" />
912   <fieldset class="brief">
913   <h3>Filter</h3>
914   <ol>
915     <li><label for="filter_date">Date:</label> <input type="text" id="filter_date" name="filter_date" size="10" value="[% filters.date | html %]" class="datepicker" />
916     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
917
918     </li>
919     <li><label for="filter_author">Author:</label> <input type="text" id="filter_author" name="filter_author" value="[% filters.author | html %]" size="16" /></li>
920     <li><label for="filter_keyword">Keyword:</label> <input type="text" id="filter_keyword" name="filter_keyword" value="[% filters.keyword | html %]" size="16" /></li>
921   </ol>
922   </fieldset>
923   <fieldset class="action">
924     <input type="submit" value="Apply filter" />
925     <a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1">Clear</a>
926   </fieldset>
927 </form>
928 </div>
929 [% END %]
930
931
932 [% INCLUDE 'guided-reports-view.inc' %]
933 </div>
934 </div>
935
936 [% MACRO jsinclude BLOCK %]
937     [% INCLUDE 'calendar.inc' %]
938     [% IF ( saved1 ) %]
939         [% INCLUDE 'datatables.inc' %]
940         [% INCLUDE 'columns_settings.inc' %]
941     [% END %]
942     <script>
943         var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
944         var group_subgroups = {};
945         [% FOREACH group IN groups_with_subgroups %]
946             var gid = "[% group.id | html %]"
947             group_subgroups[gid] = new Array();
948             [% FOREACH subgroup IN group.subgroups %]
949                 var sgid = "[% subgroup.id | html %]";
950                 var sgname = "[% subgroup.name | html %]";
951                 group_subgroups[gid].push([sgid, sgname]);
952             [% END %]
953         [% END %]
954
955         function load_group_subgroups () {
956             var group = $("#group_select").val();
957             var sg = $("#subgroup");
958             $(sg).find('option[value!=""]').each(function() {
959                 $(this).remove();
960             });
961             $(sg).hide();
962             if (group) {
963                 var select = $(sg).find('select')[0];
964                 $.each( group_subgroups[group], function(index, value) {
965                     $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
966                 } );
967                 $("#subgroup, #subgroup *").show();
968             }
969         }
970
971         $(document).ready(function(){
972
973             $('[data-toggle="tooltip"]').tooltip();
974             var columns_settings = [% ColumnsSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ).raw %];
975
976             $('#limit').change(function() {
977                 $('#limitselect').submit();
978             });
979
980             $(document).click(function() {
981                 $('#report_updated').hide();
982             });
983
984             $(".goback").on("click",function(e){
985                 e.preventDefault();
986                 window.history.back();
987             });
988
989             $("#addColumn").on("click",function(){
990                 addColumn();
991             });
992
993             $("#delColumn").on("click",function(){
994                 delColumn();
995             });
996
997             [% IF (saved1) %]
998                 var rtable = KohaTable("table_reports", {
999                     'iDisplayLength': [% Koha.Preference('NumSavedReports') | html %],
1000                     'bAutoWidth': false,
1001                     'sPaginationType': 'four_button',
1002                     'aaSorting': [[ 1, "asc" ]],
1003                     'aoColumnDefs': [
1004                         { 'bSortable': false, 'bSearchable':false, 'aTargets': [0, -1] },
1005                         { 'bSearchable': false, 'aTargets': [3] },
1006                         { "aTargets": [ 1, 2 ], "sType": "natural"  },
1007                         { "sType": "title-string", "aTargets" : [ "title-string" ] },
1008                         { "visible": false, "aTargets" : [ "hidden" ] }
1009                     ],
1010                     'oLanguage': {
1011                         'sZeroRecords': _("No matching reports found")
1012                     },
1013                 }, columns_settings);
1014
1015                 var rtabs = $("#tabs").tabs();
1016                 rtabs.on("tabsactivate", function(e, ui) {
1017                     $("#subgroup_filter option").each(function() {
1018                         if($(this).val().length > 0) {
1019                             $(this).remove();
1020                         }
1021                     });
1022                     rtable.fnFilter('', 4);
1023                     rtable.fnFilter('', 5);
1024                     rtable.fnSetColumnVis(4, true);
1025                     rtable.fnSetColumnVis(5, true);
1026
1027                     var g_id = $(ui.newTab).children().attr('id');
1028                     var g_name = $(ui.newTab).text();
1029                     if ( g_name == _("All") ) {
1030                         g_id = "";
1031                         g_name = "";
1032                     }
1033
1034                     if (g_id && g_id.length > 0) {
1035                         rtable.fnFilter('^' + g_name + '$', 4, true, true, true, false);
1036                         rtable.fnSetColumnVis(4, false);
1037                         for(var i in group_subgroups[g_id]) {
1038                             $("#subgroup_filter").append(
1039                                 '<option value="' + group_subgroups[g_id][i][0] + '">'
1040                                 + group_subgroups[g_id][i][1] + '</option>'
1041                             );
1042                         }
1043                         $("#subgroup_filter_block").show();
1044                     } else {
1045                         $("#subgroup_filter_block").hide();
1046                     }
1047                 });
1048                 $("#subgroup_filter_block").hide();
1049
1050                 $("#subgroup_filter").change(function() {
1051                     var selected = $(this).find('option:selected');
1052                     var sg_id = $(selected).val();
1053                     var sg_name = $(selected).text();
1054                     if (sg_id.length > 0) {
1055                         rtable.fnFilter('^' + sg_name + '$', 5, true, true, true, false);
1056                         rtable.fnSetColumnVis(5, false);
1057                     } else {
1058                         rtable.fnFilter('', 5);
1059                         rtable.fnSetColumnVis(5, true);
1060                     }
1061                 });
1062
1063                 $("#reports_form").submit(function(){
1064                     var checkedItems = $("input[name=ids]:checked");
1065                     if ($(checkedItems).size() == 0) {
1066                         alert(_("You must select one or more reports to delete"));
1067                         return false;
1068                     }
1069                     $(checkedItems).parents('tr').addClass("warn");
1070                     if( confirm(_("Are you sure you want to delete the selected reports?")) ) {
1071                         return true;
1072                     } else {
1073                         $(checkedItems).parents('tr').removeClass("warn");
1074                         return false;
1075                     }
1076                 });
1077
1078                 $("body").on("click", ".update_sql", function(e){
1079                     e.preventDefault();
1080                     var ltitle = $(this).text();
1081                     var report_id = $(this).data("report_id");
1082                     var page = $(this).attr("href");
1083                     $("#update_sql .modal-body").load(page + " div", function(){
1084                         var diff1 = $("#col1 .show_sql").text();
1085                         var diff2 = $("#col2 .show_sql").text();
1086                         var diffs = diffString( escape(diff1), escape(diff2) );
1087                         $("#col1 .show_sql,#col2 .show_sql").html(diffs);
1088                     });
1089                     $('#update_sql').modal('show');
1090                     $("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?phase=Use saved&op=convert&report_id=" + report_id);
1091                 });
1092
1093                 $("#update_sql").on("hidden.bs.modal", function(){
1094                     $("#update_sql_label").html("");
1095                     $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1096                 });
1097             [% END %]
1098
1099             [% IF ( showsql ) %]
1100                 $("#sql").focus(function() {
1101                     $(this).select();
1102                 });
1103             [% END %]
1104
1105                 $(".toggle_sql").click(function(){
1106                     $("#sql_output").toggle();
1107                     $("#toggle_sql_hid").toggle();
1108                     $("#toggle_sql_vis").toggle();
1109                 });
1110
1111                 $("#table_reports").delegate(".confirmdelete", 'click', function(){
1112                     $(this).parents('tr').attr("class","warn");
1113                     if(confirm(_("Are you sure you want to delete this saved report?"))){
1114                         return true;
1115                     } else {
1116                         $(this).parents('tr').attr("class","");
1117                         return false;
1118                     }
1119                 });
1120
1121             [% IF (create || editsql || save) %]
1122                 $("#select_group").change(function() {
1123                     if($(this).prop('checked')) {
1124                         $("#group_input").prop('disabled', true);
1125                         $("#groupdesc_input").prop('disabled', true);
1126                         $("#group_select").prop('disabled', false);
1127                         if ($("#group_select").val().length > 0) {
1128                             $("#select_subgroup").prop('checked', true);
1129                             $("#select_subgroup").change();
1130                             $("#subgroup, #subgroup *").show();
1131                         } else {
1132                             $("#subgroup").hide();
1133                         }
1134                     }
1135                 });
1136                 $("#create_group").change(function() {
1137                     if($(this).prop('checked')) {
1138                         $("#group_input").prop('disabled', false);
1139                         $("#groupdesc_input").prop('disabled', false);
1140                         $("#group_select").prop('disabled', true);
1141                         $("#create_subgroup").prop('checked', true).change();
1142                         $("#subgroup_select").hide();
1143                         $("#subgroup input[type='radio']").hide();
1144                         $("#subgroup label[for]").hide();
1145                         $("#subgroup_input").show();
1146                         $("#subgroupdesc_input").show();
1147                         $("#subgroup").show();
1148                     }
1149                 });
1150                 $("#select_subgroup").change(function() {
1151                     if($(this).prop('checked')) {
1152                         $("#subgroup_select").prop('disabled', false);
1153                         $("#subgroup_input").prop('disabled', true);
1154                         $("#subgroupdesc_input").prop('disabled', true);
1155                     }
1156                 });
1157                 $("#create_subgroup").change(function() {
1158                     if($(this).prop('checked')) {
1159                         $("#subgroup_input").prop('disabled', false);
1160                         $("#subgroupdesc_input").prop('disabled', false);
1161                         $("#subgroup_select").prop('disabled', true);
1162                     }
1163                 });
1164                 $("#select_group").change();
1165                 $("#select_subgroup").change();
1166                 $("#group_select").on("change",function(){
1167                     load_group_subgroups();
1168                 });
1169             [% END %]
1170             $(".delete").on("click",function(){
1171                 return confirmDelete(MSG_CONFIRM_DELETE);
1172             });
1173         });
1174         function addColumn() {
1175             $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
1176         }
1177         function delColumn() {
1178             $("#selectedColumns option:selected").remove();
1179         }
1180         $("#column_submit").submit(function() {
1181             if ($("#selectedColumns option").size() < 1) {
1182                 alert(_("No columns selected!"));
1183                 return false;
1184             }
1185             $("#selectedColumns option").attr("selected", "selected");  // Select everything still in #selectedColumns
1186             return true;
1187         });
1188     </script>
1189 [% END %]
1190
1191 [% INCLUDE 'intranet-bottom.inc' %]
1192
1193 [% BLOCK group_and_subgroup_selection %]
1194     <li id="group">
1195         <label>Report group:</label>
1196         <input type="radio" name="select_or_create_group"
1197             id="select_group" checked="checked" />
1198         <label for="select_group" style="float:none">Select</label>
1199         <select name="group" id="group_select">
1200             <option value="">(None)</option>
1201             [% FOREACH group IN groups_with_subgroups %]
1202                 [% IF (group.selected) %]
1203                     <option value="[% group.id | html %]" selected="selected">
1204                 [% ELSE %]
1205                     <option value="[% group.id | html %]">
1206                 [% END %]
1207                     [% group.name | html %]
1208                 </option>
1209             [% END %]
1210         </select>
1211         <input type="radio" name="select_or_create_group" id="create_group" />
1212         <label for="create_group" style="float:none">or create:</label>
1213         <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
1214         <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
1215     </li>
1216     <li id="subgroup">
1217         <label>Report subgroup:</label>
1218         <input type="radio" name="select_or_create_subgroup"
1219             id="select_subgroup" checked="checked" />
1220         <label for="select_subgroup" style="float:none">Select</label>
1221         <select name="subgroup" id="subgroup_select">
1222             <option value="">(None)</option>
1223             [% FOREACH group IN groups_with_subgroups %]
1224                 [% IF (group.selected) %]
1225                     [% FOREACH subgroup IN group.subgroups %]
1226                         [% IF (subgroup.selected) %]
1227                             <option value="[% subgroup.id | html %]" selected="selected">
1228                         [% ELSE %]
1229                             <option value="[% subgroup.id | html %]">
1230                         [% END %]
1231                             [% subgroup.name | html %]
1232                         </option>
1233                     [% END %]
1234                 [% END %]
1235             [% END %]
1236         </select>
1237         <input type="radio" name="select_or_create_subgroup"
1238             id="create_subgroup" />
1239         <label for="create_subgroup" style="float:none">or create</label>
1240         <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
1241         <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />
1242     </li>
1243 [% END %]