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