4cd0728ca3bbb009dfd0a5a1f3cb7a88cce3490a
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reports / guided_reports_start.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Reports &rsaquo; Guided reports wizard
3 [% IF ( saved1 ) %]&rsaquo; Saved Reports
4 [% ELSIF ( create ) %]&rsaquo; Create from SQL
5 [% ELSIF ( showsql ) %]&rsaquo; Saved reports &rsaquo; SQL view
6 [% ELSIF ( execute ) %]&rsaquo; Saved reports &rsaquo; [% name %] Report
7 [% ELSIF ( buildx ) %]&rsaquo; Build a report, step [% buildx %] of 6:
8 [% IF ( build1 ) %]Choose a module
9 [% ELSIF ( build2 ) %]Pick a report type
10 [% ELSIF ( build3 ) %]Select columns for display
11 [% ELSIF ( build4 ) %]Select criteria to limit on
12 [% ELSIF ( build5 ) %]Pick which columns to total
13 [% ELSIF ( build6 ) %]Select how you want the report ordered
14 [% END %]
15 [% END %]
16 </title>
17 [% INCLUDE 'doc-head-close.inc' %]
18 [% INCLUDE 'calendar.inc' %]
19 <style type="text/css">
20     #sql { width: 90%; height: 9em;}
21 </style>
22 [% IF ( saved1 ) %]
23 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
24 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
25 [% INCLUDE 'datatables-strings.inc' %]
26 <script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
27 [% END %]
28
29 <script type="text/javascript">
30 //<![CDATA[
31 [% IF (dateformat == 'metric' && saved1) %]
32 dt_add_type_uk_date();
33 [% END %]
34 var group_subgroups = {};
35 [% FOREACH group IN groups_with_subgroups %]
36     var gid = "[% group.id %]"
37     group_subgroups[gid] = new Array();
38     [% FOREACH subgroup IN group.subgroups %]
39         var sgid = "[% subgroup.id %]";
40         var sgname = "[% subgroup.name %]";
41         group_subgroups[gid].push([sgid, sgname]);
42     [% END %]
43 [% END %]
44
45 function load_group_subgroups () {
46     var group = $("#group_select").val();
47     var sg = $("#subgroup");
48     $(sg).find('option[value!=""]').each(function() {
49         $(this).remove();
50     });
51     $(sg).hide();
52     if (group) {
53         var select = $(sg).find('select')[0];
54         $.each( group_subgroups[group], function(index, value) {
55             $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
56         } );
57         $("#subgroup, #subgroup *").show();
58     }
59 }
60
61 $(document).ready(function(){
62
63 [% IF (saved1) %]
64     [% IF (dateformat == "metric") %]
65         dt_add_type_uk_date();
66     [% END %]
67     var rtable = $("#table_reports").dataTable($.extend(true, {}, dataTablesDefaults, {
68         'bAutoWidth': false,
69         'sDom': 't<"bottom pager"ilpf>',
70         'sPaginationType': 'four_button',
71         'aLengthMenu': [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
72         'iDisplayLength': 20,
73         'aaSorting': [[ 1, "asc" ]],
74         'aoColumnDefs': [
75             { 'bSortable': false, 'bSearchable':false, 'aTargets': [-1, -2, -3, -4] },
76             { 'bSearchable': false, 'aTargets': [3, 4] }
77         ],
78         'oLanguage': {
79             'sZeroRecords': _("No matching reports found")
80         }
81     }));
82
83     var rtabs = $("#tabs").tabs();
84     rtabs.bind("tabsshow", function(e, ui) {
85         $("#subgroup_filter option").each(function() {
86             if($(this).val().length > 0) {
87                 $(this).remove();
88             }
89         });
90         rtable.fnFilter('', 3);
91         rtable.fnFilter('', 4);
92         rtable.fnSetColumnVis(3, true);
93         rtable.fnSetColumnVis(4, true);
94
95         var g_id = $(ui.tab).attr('id')
96         var g_name = $(ui.tab).text();
97         if (g_id && g_id.length > 0) {
98             rtable.fnFilter('^' + g_name + '$', 3, true, true, true, false);
99             rtable.fnSetColumnVis(3, false);
100             for(var i in group_subgroups[g_id]) {
101                 $("#subgroup_filter").append(
102                     '<option value="' + group_subgroups[g_id][i][0] + '">'
103                     + group_subgroups[g_id][i][1] + '</option>'
104                 );
105             }
106             $("#subgroup_filter_block").show();
107         } else {
108             $("#subgroup_filter_block").hide();
109         }
110     });
111     $("#subgroup_filter_block").hide();
112
113     $("#subgroup_filter").change(function() {
114         var selected = $(this).find('option:selected');
115         var sg_id = $(selected).val();
116         var sg_name = $(selected).text();
117         if (sg_id.length > 0) {
118             rtable.fnFilter('^' + sg_name + '$', 4, true, true, true, false);
119             rtable.fnSetColumnVis(4, false);
120         } else {
121             rtable.fnFilter('', 4);
122             rtable.fnSetColumnVis(4, true);
123         }
124     });
125 [% END %]
126
127 [% IF ( showsql ) %]
128     $("#sql").focus(function() {
129         $(this).select();
130     });
131 [% END %]
132 [% IF ( saved1 ) %]
133     $(".confirmdelete").click(function(){
134         $(this).parents('tr').attr("class","warn");
135         if(confirm("Are you sure you want to "+$(this).attr("title")+"?")){
136             return true;
137         } else {
138             $(this).parents('tr').attr("class","");
139             return false;
140         }
141     });
142 [% END %]
143   // redefine the datepicker's default because reports require ISO
144   // http://jqueryui.com/demos/datepicker/#option-dateFormat
145   $( ".datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
146
147 [% IF (create || editsql || save) %]
148     $("#select_group").change(function() {
149         if($(this).attr('checked')) {
150             $("#group_input").attr('disabled', 'disabled');
151             $("#groupdesc_input").attr('disabled', 'disabled');
152             $("#group_select").attr('disabled', false);
153             if ($("#group_select").val().length > 0) {
154                 $("#select_subgroup").attr('checked', 'checked');
155                 $("#select_subgroup").change();
156                 $("#subgroup, #subgroup *").show();
157             } else {
158                 $("#subgroup").hide();
159             }
160         }
161     });
162     $("#create_group").change(function() {
163         if($(this).attr('checked')) {
164             $("#group_input").attr('disabled', false);
165             $("#groupdesc_input").attr('disabled', false);
166             $("#group_select").attr('disabled', 'disabled');
167             $("#create_subgroup").attr('checked', 'checked').change();
168             $("#subgroup_select").hide();
169             $("#subgroup input[type='radio']").hide();
170             $("#subgroup label[for]").hide();
171             $("#subgroup_input").show();
172             $("#subgroupdesc_input").show();
173             $("#subgroup").show();
174         }
175     });
176     $("#select_subgroup").change(function() {
177         if($(this).attr('checked')) {
178             $("#subgroup_select").attr('disabled', false);
179             $("#subgroup_input").attr('disabled', 'disabled');
180             $("#subgroupdesc_input").attr('disabled', 'disabled');
181         }
182     });
183     $("#create_subgroup").change(function() {
184         if($(this).attr('checked')) {
185             $("#subgroup_input").attr('disabled', false);
186             $("#subgroupdesc_input").attr('disabled', false);
187             $("#subgroup_select").attr('disabled', 'disabled');
188         }
189     });
190     $("#select_group").change();
191     $("#select_subgroup").change();
192 [% END %]
193 });
194 //]]>
195 </script>
196 </head>
197 <body id="rep_guided_reports_start" class="rep">
198 [% INCLUDE 'header.inc' %]
199 [% INCLUDE 'circ-search.inc' %]
200
201 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>
202 &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
203 &rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
204 &rsaquo; 
205 [% IF ( saved1 ) %]Saved reports
206 [% ELSIF ( create ) %]Create from SQL
207 [% ELSIF ( showsql ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> &rsaquo; SQL view
208 [% ELSIF ( execute ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> &rsaquo; <em>[% name %]</em> Report
209 [% ELSIF ( buildx ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a report</a> &rsaquo; Step [% buildx %] of 6:
210     [% IF ( build1 ) %]Choose a module
211     [% ELSIF ( build2 ) %]Pick a report type
212     [% ELSIF ( build3 ) %]Select columns for display
213     [% ELSIF ( build4 ) %]Select criteria to limit on
214     [% ELSIF ( build5 ) %]Pick which columns to total
215     [% ELSIF ( build6 ) %]Select how you want the report ordered
216     [% END %]
217 [% END %]
218 </div>
219
220 <div id="doc3" class="yui-t1">
221 <div id="bd">
222 <div id="yui-main">
223     <div class="yui-b">
224     [% INCLUDE "reports-toolbar.inc" %]
225
226 [% IF ( start ) %]
227     <h2>Guided reports</h2>
228     <p>Use the guided reports engine to create non standard reports.
229 This feature aims to provide some middle ground between the built in
230 canned reports and writing custom SQL reports.</p>
231
232     <h3>Build and run reports</h3>
233         [% IF ( CAN_user_reports_create_reports ) %]
234         <form action="/cgi-bin/koha/reports/guided_reports.pl">
235             <input type="hidden" name="phase" value="Build new" />
236             <input type="submit" name="submit" value="Build new"/>
237         </form>
238         [% END %]
239         [% IF ( CAN_user_reports_execute_reports ) %]
240         <form action="/cgi-bin/koha/reports/guided_reports.pl">
241             <input type="hidden" name="phase" value="Use saved"/>
242             <input type="submit" name="submit" value="Use saved"/>
243         </form>
244         [% END %]
245         [% IF ( CAN_user_reports_create_reports ) %]
246         <form action="/cgi-bin/koha/reports/guided_reports.pl">
247             <input type="hidden" name="phase" value="Create report from SQL"/>
248             <input type="submit" name="submit" value="Create report from SQL"/>
249         </form>
250         [% END %]
251 <h3>Reports Dictionary</h3>
252 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
253 <form action="/cgi-bin/koha/reports/dictionary.pl">
254 <input type="hidden" name="phase" value="View Dictionary"/>
255 <input type="submit" name="submit" value="View dictionary"/>
256 </form>
257 [% END %]
258
259 [% IF ( saved1 ) %]
260 [% IF ( savedreports ) %]<h1>Saved reports</h1>
261
262 <div id="tabs" class="toptabs">
263     <ul>
264         <li><a href="#reports">All</a></li>
265         [% FOREACH group IN groups_with_subgroups %]
266             <li><a id="[% group.id %]" href="#reports">[% group.name %]</a></li>
267         [% END %]
268     </ul>
269     <div id="reports">
270         <div id="subgroup_filter_block">
271             <label for="subgroup_filter">Subgroup:</label>
272             <select id="subgroup_filter">
273                 <option value="">All</option>
274             </select>
275         </div>
276         <table id="table_reports">
277             <thead>
278                 <tr>
279                     <th>ID</th>
280                     <th>Report name</th>
281                     <th>Type</th>
282                     <th>Group</th>
283                     <th>Subgroup</th>
284                     <th>Notes</th>
285                     <th>Author</th>
286                     <th>Creation date</th>
287                     <th>Public</th>
288                     [% IF (usecache) %] <th>Cache expiry (seconds)</th> [% END %]
289                     <th>Saved results</th>
290                     <th>Saved SQL</th>
291                     <th>&nbsp;</th>
292                     [% IF ( CAN_user_reports_create_reports ) %]
293                         <th>&nbsp;</th>
294                     [% END %]
295                 </tr>
296             </thead>
297             <tbody>
298                 [% FOREACH savedreport IN savedreports %]
299                     [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
300                         <td>[% savedreport.id %]</td>
301                         <td>[% savedreport.report_name %]</td>
302                         <td>[% savedreport.type %]</td>
303                         <td>[% savedreport.groupname %]</td>
304                         <td>[% savedreport.subgroupname %]</td>
305                         <td>[% savedreport.notes %]</td>
306                         <td>[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %])</td>
307                         <td>[% savedreport.date_created %]</td>
308                         [% IF (savedreport.public) %]
309                         <td>Yes</td>
310                         [% ELSE %]
311                         <td>No</td>
312                         [% END %]
313                         [% IF (usecache) %] <td>[% savedreport.cache_expiry %]</td> [% END %]
314                         <td>[% IF ( savedreport.date_run ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&amp;id=[% savedreport.id %]">[% savedreport.date_run %]</a>[% END %]
315                         </td>
316                         <td>
317                             <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Show%20SQL">Show</a>
318                             [% IF ( CAN_user_reports_create_reports ) %]
319                                 <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Edit%20SQL">Edit</a>
320                                 <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 %]">Duplicate</a>
321                             [% END %]
322                         </td>
323                         <td>
324                             <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Run%20this%20report">Run</a>
325                             <a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id %]">Schedule</a>
326                         </td>
327                         [% IF ( CAN_user_reports_create_reports ) %]
328                             <td><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Delete%20Saved">Delete</a></td>
329                         [% END %]
330                     </tr>
331                 [% END %]
332             </tbody>
333         </table>
334     </div>
335 </div>
336 [% ELSE %]<div class="dialog message">
337     [% IF (filter_set) %]
338     <h4>No saved reports match your criteria. </h4>
339     [% IF ( CAN_user_reports_create_reports ) %]
340     <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
341     <input type="hidden" name="phase" value="Build new" />
342     <input type="submit" class="edit" value="Build a new report" accesskey="y" />
343     </form>
344
345     <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
346     <input type="hidden" name="phase" value="Use saved" />
347     <input type="hidden" name="filter_set" value="1" />
348     <input type="hidden" name="filter_keyword" value="" />
349     <input type="submit" class="deny" value="Cancel filter" accesskey="n" />
350     </form>
351
352     [% END %]
353     [% ELSE %]
354     <h4>There are no saved reports. </h4>
355     [% IF ( CAN_user_reports_create_reports ) %]
356         <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a new report?</a>
357     [% END %]
358     [% END %]
359     </div>
360 [% END %]
361 [% END %]
362
363
364 [% IF ( build1 ) %]
365 [% IF ( cache_error) %]
366 <div class="dialog alert">
367 <b> Please choose a cache_expiry less than 30 days </b>
368 </div>
369 [% END %]
370 <h1>Build a report</h1>
371 <form action="/cgi-bin/koha/reports/guided_reports.pl">
372 <fieldset class="rows">
373 <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and Choose report visibility </legend>
374 <ol><li><label for="area">Choose: </label><select name="area" id="area">
375 [% FOREACH area IN areas %]
376 <option value="[% area.id %]">[% area.name %]</option>
377 [% END %]
378 </select></li>
379 [% IF (public) %]
380   <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>
381 [% ELSE %]
382   <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>
383 [% END %]
384 [% IF (usecache) %] <li>
385 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry %]"></input>
386 <select id="cache_expiry_units" name="cache_expiry_units">
387 <option value="seconds">Seconds (default)</option>
388 <option value="minutes">Minutes</option>
389 <option value="hours">Hours</option>
390 <option value="days">Days</option>
391 </select>
392 </li>[% END %]
393 </ol>
394 </fieldset>
395 <fieldset class="action">
396 <input type="hidden" name="phase" value="Report on this Area" />
397 <input type="submit" name="submit" value="Next &gt;&gt;" />
398
399 </fieldset>
400 </form>
401 [% END %]
402
403
404 [% IF ( build2 ) %]
405 <h1>Build A Report</h1>
406 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
407 <input type="hidden" name="area" value="[% area %]" />
408 <input type="hidden" name="public" value="[% public %]" />
409 <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
410 <fieldset class="rows"><legend>Step 2 of 6: Pick a report type</legend>
411 <ol><li><label for="types">Choose: </label>
412     <select id="types" name="types">
413         <option value="1">Tabular</option>
414         <option value="2" disabled="disabled">Summary</option>
415         <option value="3" disabled="disabled">Matrix</option>
416     </select>
417 </li></ol></fieldset>
418
419 <fieldset class="action">
420     <input type="hidden" name="phase" value="Choose this type" />
421     <input type="button" name="back" value="&lt;&lt; Back" onclick="javascript:history.back()" />
422     <input type="submit" name="submit" value="Next &gt;&gt;" />
423 </fieldset>
424 </form>
425 </div>
426 <div class="yui-gb"><div class="yui-u first"></div>
427
428 <!--- Summary and Matrix reports have not yet been implemented-->
429 <!--<div class="yui-u">Summary:
430 <img src="/intranet-tmpl/prog/img/reports-summary-graphic.gif" /></div>
431 <div class="yui-u">Matrix:
432 <img src="/intranet-tmpl/prog/img/reports-matrix-graphic.gif" /></div>-->
433
434 [% END %]
435
436 [% IF ( build3 ) %]
437 <h3>Step 3 of 6: Select columns for display</h3>
438 <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>
439
440 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
441     <input type="hidden" name="area" value="[% area %]" />
442     <input type="hidden" name="type" value="[% type %]" />
443     <input type="hidden" name="public" value="[% public %]" />
444     <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
445     <fieldset>
446 <div class="yui-g">
447 <div class="yui-u first">       <div style="float: left;"><select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
448 [% FOREACH column IN columns %]
449 [% IF ( column.table ) %]
450
451 [% IF ( loop.first ) %]
452 [% ELSE %]
453 </optgroup>
454 [% END %]
455
456 <optgroup label="[% column.table %]">
457 [% ELSE %]
458 <option value="[% column.name %]">
459 [% IF ( column.description ) %][% column.description %] &nbsp; / &nbsp; [% column.name %]
460 [% ELSE %]
461 [% column.name %]
462 [% END %]
463 </option>
464 [% END %]
465 [% END %]
466 </optgroup>
467 </select></div>
468 <div style="width: 6.3em; float: right; margin-top: 100px"><input type="button" name="Add" value="Add" class="button" style="width:6em;" onclick="addColumn()" /><br />
469 <input type="button" name="delete" value="&lt;&lt; Delete" class="button" style="width: 6em; margin: 1em 0;" onclick="delColumn()" /></div>
470 </div>
471
472 <div class="yui-u">
473 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;"></select>
474 </div>
475 </div>
476 </fieldset>
477 <div class="yui-g">
478 <fieldset class="action">
479     <input type="hidden" name="phase" value="Choose these columns" />
480     <input type="button" name="back" value="&lt;&lt; Back" onclick="javascript:history.back()" />
481     <input type="submit" name="submit" value="Next &gt;&gt;" />
482 </fieldset>
483 </div>
484 </form>
485
486 [% END %]
487
488 [% IF ( build4 ) %]
489 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
490     <input type="hidden" name="area" value="[% area %]" />
491     <input type="hidden" name="type" value="[% type %]" />
492     <input type="hidden" name="column" value="[% column %]" />
493     <input type="hidden" name="public" value="[% public %]" />
494     <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
495     <fieldset><legend>Step 4 of 6: Select criteria to limit on</legend>
496     <table>
497         [% FOREACH criteri IN criteria %]
498         <tr>
499         <td>
500             <input type="checkbox" name="criteria_column" id="[% criteri.name %]" value="[% criteri.name %]" /> 
501             <label for="[% criteri.name %]">[% criteri.description %] </label>
502         </td>
503         [% IF ( criteri.date ) %]
504         <td>
505             <input type="text" size="10" id="[% criteri.name %]_value" name="[% criteri.name %]_value" value="" class="datepicker" />
506                 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
507         </td>
508         </tr>
509         [% ELSE %]
510         [% IF ( criteri.textrange ) %]
511             <td>from
512             <input type="text" size="10" id="[% criteri.from %]_value" name="[% criteri.from %]_value" value="" /> to 
513             <input type="text" size="10" id="[% criteri.to %]_value" name="[% criteri.to %]_value" value="" />
514             </td>
515             </tr>
516         [% ELSE %]
517             [% IF ( criteri.daterange ) %]
518             <td>from 
519             <input type="text" size="10" id="from_[% criteri.name %]_value" name="from_[% criteri.name %]_value" value="" class="datepickerfrom" />
520             to
521             <input type="text" size="10" id="to_[% criteri.name %]_value" name="to_[% criteri.name %]_value" value="" class="datepickerto" />
522                         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
523             </td>
524         </tr>
525             [% ELSE %]
526             <td>
527                 <select name="[% criteri.name %]_value">
528                 [% FOREACH value IN criteri.values %]
529                 <option value="[% value.availablevalues %]">[% IF ( value.default ) %]Default[% ELSE %][% value.availablevalues |html %][% END %]</option>
530                 [% END %]
531                 </select>
532             </td>
533             </tr>
534             [% END %]
535         [% END %]
536         [% END %]
537     [% END %]
538     </table>
539     </fieldset>
540
541 [% IF ( definitions ) %]
542 <fieldset><legend>Dictionary definitions</legend>
543 <table>
544 [% FOREACH definition IN definitions %]
545     <tr><td><input type="checkbox" name="definition" value="[% definition.id %]" /> [% definition.name %]</td></tr>
546 [% END %]
547 </table>
548 </fieldset>
549 [% END %]
550
551 <fieldset class="action"><input type="hidden" name="phase" value="Choose these criteria" />
552     <input type="button" name="back" value="&lt;&lt; Back" onclick="javascript:history.back()" />
553     <input type="submit" name="submit" value="Next &gt;&gt;" /> </fieldset>
554 </form>
555 [% END %]
556
557
558 [% IF ( build5 ) %]
559 <h3>Step 5 of 6: Pick which columns to total</h3>
560 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
561 <input type="hidden" name="area" value="[% area %]" />
562 <input type="hidden" name="type" value="[% type %]" />
563 <input type="hidden" name="column" value="[% column %]" />
564 <input type="hidden" name="definition" value="[% definition %]" />
565 <input type="hidden" name="criteria" value="[% criteriastring %]" />
566 <input type="hidden" name="public" value="[% public %]" />
567 <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
568 <fieldset><table>
569 [% FOREACH total_b IN total_by %]
570 <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>
571 <td><select name="[% total_b.name %]_tvalue">
572
573 [% FOREACH selec IN total_b.select %]
574 <option value="[% selec.value %]">[% selec.value %]</option>
575 [% END %]
576 </select>
577
578 </td></tr>
579 [% END %]
580 </table></fieldset>
581
582 <fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
583     <input type="button" name="back" value="&lt;&lt; Back" onclick="javascript:history.back()" />
584     <input type="submit" name="submit" value="Next &gt;&gt;" /></fieldset>
585 </form>
586 [% END %]
587
588
589 [% IF ( build6 ) %]
590 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
591 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
592 <input type="hidden" name="area" value="[% area %]" />
593 <input type="hidden" name="type" value="[% type %]" />
594 <input type="hidden" name="column" value="[% column %]" />
595 <input type="hidden" name="criteria" value="[% criteriastring %]" />
596 <input type="hidden" name="definition" value="[% definition %]" />
597 <input type="hidden" name="totals" value="[% totals %]" />
598 <input type="hidden" name="public" value="[% public %]" />
599 <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
600 <fieldset><table>[% FOREACH order_b IN order_by %]
601 <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>
602 <select name="[% order_b.name %]_ovalue">
603
604 [% FOREACH selec IN order_b.select %]
605 <option value="[% selec.value %]">[% selec.value %]</option>
606 [% END %]
607 </select>
608 </td></tr>
609
610 [% END %]
611 </table></fieldset>
612
613 <fieldset class="action">
614 <input type="hidden" name="phase" value="Build report" />
615 <input type="submit" name="submit" value="Finish" /></fieldset>
616 </form>
617 [% END %]
618
619
620 [% IF ( showreport ) %]
621 <h1>Confirm custom report</h1>
622 <p>Your report will be generated with the following SQL statement.</p>
623 <p> 
624 [% sql |html %]
625 </p>
626
627 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
628 <input type="hidden" name="sql" value="[% sql %]" />
629 <input type="hidden" name="type" value="[% type %]" />
630 <input type="hidden" name="public" value="[% public %]" />
631 <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
632 <p>You will need to save the report before you can execute it</p>
633 <fieldset class="action"><input type="hidden" name="phase" value="Save" />  
634 <input type="submit" name="submit" value="Save" />  </fieldset>
635 </form>
636 [% END %]
637
638 [% IF ( save ) %]
639 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
640 <input type="hidden" name="sql" value="[% sql |html %]" />
641 <input type="hidden" name="type" value="[% type %]" />
642 <input type="hidden" name="area" value="[% area %]" />
643 <input type="hidden" name="public" value="[% public %]" />
644 <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
645 <fieldset class="rows">
646 <legend>Save your custom report</legend>
647 <ol>
648     <li><label for="reportname">Report name: </label><input type="text" id="reportname" name="reportname" /></li>
649     [% PROCESS group_and_subgroup_selection %]
650     <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li>
651 </ol></fieldset>
652 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
653 <input type="submit" name="submit" value="Save Report" /></fieldset>
654 </form>
655 [% END %]
656
657 [% IF ( warn_authval_problem ) %]
658      <form action='/cgi-bin/koha/reports/guided_reports.pl'>
659         <!--Every parameter the user issued is provided as a hidden field for recovery-->
660         <input type='hidden' name='id' value='[% id %]' />
661         <input type='hidden' name='sql' value='[% sql %]' />
662         <input type='hidden' name='reportname' value='[% reportname %]' />
663         <input type='hidden' name='group' value='[% group %]' />
664         <input type='hidden' name='subgroup' value='[% subgroup %]' />
665         <input type='hidden' name='notes' value='[% notes %]' />
666         <input type='hidden' name='cache_expiry' value='[% cache_expiry %]' />
667         <input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units %]' />
668         <input type='hidden' name='public' value='[% public %]' />
669
670         <div class="dialog alert">
671             <h3>Errors found when processing parameters for report: [% name %]</h3>
672             [% FOREACH problematic_authval IN problematic_authvals %]
673                 <p>
674                 <strong>[% problematic_authval.name %]:</strong> The authorised value category (<strong>[% problematic_authval.authval %]</strong>)
675                     you selected does not exist.
676                 </p>
677             [% END %]
678             <!-- Save Anyway Form -->
679             <form action='/cgi-bin/koha/reports/guided_reports.pl'>
680             <!--Every parameter the user issued is provided as a hidden field for recovery-->
681                 <input type='hidden' name='id' value='[% id %]' />
682                 <input type='hidden' name='sql' value='[% sql %]' />
683                 <input type='hidden' name='reportname' value='[% reportname %]' />
684                 <input type='hidden' name='group' value='[% group %]' />
685                 <input type='hidden' name='subgroup' value='[% subgroup %]' />
686                 <input type='hidden' name='notes' value='[% notes %]' />
687                 <input type='hidden' name='cache_expiry' value='[% cache_expiry %]' />
688                 <input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units %]' />
689                 <input type='hidden' name='public' value='[% public %]' />
690             [% IF ( phase_update) %]
691                 <input type='hidden' name='phase' value='Update SQL' />
692                 <input type="submit" name="save_anyway" class="approve" value="Save anyway" />
693             [% ELSIF ( phase_save) %]
694                 <input type='hidden' name='area' value='[% area %]' />
695                 <input type='hidden' name='phase' value='Save Report' />
696                 <input type="submit" name="save_anyway" class="approve" value="Save anyway" />
697             [% END %]
698             </form>
699             <!-- Go back to editing -->
700             <form action='/cgi-bin/koha/reports/guided_reports.pl'>
701                 <input type="button" name='back' class="deny" value="Edit SQL"
702                                     onclick="javascript:history.back()" />
703             </form>
704         </div>
705     </form>
706 [% END %]
707
708 [% IF ( enter_params ) %]
709     <form action='/cgi-bin/koha/reports/guided_reports.pl'>
710         <input type='hidden' name='reports' value="[% reports %]" />
711     [% IF ( auth_val_error ) %]
712         <input type='hidden' name='phase' value='Edit SQL' />
713         <div class="dialog alert">
714             <h3>Errors found when processing parameters for report: [% name %]</h3>
715             [% FOREACH auth_val_error IN auth_val_errors %]
716                 <p>
717                     <strong>[% auth_val_error.entry %]:</strong> The authorised value category (<strong>[% auth_val_error.auth_val %]</strong>)
718                     you selected does not exist.
719                 </p>
720             [% END %]
721         </div>
722         <fieldset class="action"><input type="submit" value="Edit SQL" /></fieldset>
723     [% ELSE %]
724         <input type='hidden' name='phase' value='Run this report' />
725         <h1>Enter parameters for report [% name %]:</h1>
726         [% IF ( notes ) %]<p>[% notes %]</p>[% END %]
727         <fieldset class="rows">
728             <ol>
729             [% FOREACH sql_param IN sql_params %]
730                 [% IF sql_param.input == 'date' %]
731                     <li>
732                     <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" />
733                     </li>
734                 [% ELSIF ( sql_param.input == 'text' ) %]
735                     <li><label for="sql_params[% loop.count %]">[% sql_param.entry %]: </label><input id="sql_params[% loop.count %]" type="text" name="sql_params" /></li>
736                 [% ELSE %]
737                     <li><label for="sql_params_[% sql_param.labelid %]">[% sql_param.entry %]:</label> [% sql_param.input %]</li>
738                 [% END %]
739             [% END %]
740             </ol>
741         </fieldset>
742         <fieldset class="action"><input type="submit" value="Run the report" /></fieldset>
743     [% END %]
744     </form>
745 [% END %]
746
747 [% IF ( execute ) %]
748 <h1>[% name %]</h1>
749 [% IF ( notes ) %]<p>[% notes %]</p>[% END %]
750 [% IF ( unlimited_total ) %]<p>Total number of rows matching the (unlimited) query is [% unlimited_total %].</p>[% END %]
751 <pre id="sql_output">[% sql |html %]</pre>
752
753 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
754     <input type="hidden" name="phase" value="Run this report"/>
755     <input type="hidden" name="reports" value="[% report_id %]"/>
756
757     [% FOREACH p IN sql_params %]
758         <input type="hidden" name="sql_params" value="[% p %]"/>
759     [% END %]
760
761     <label for="limit">Rows per page: </label>
762     <select name="limit">
763         [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
764         [% FOREACH l IN limits %]
765                 [% IF l == limit %]
766                     <option value="[% l %]" selected="selected">[% l %]</option>
767                 [% ELSE %]
768                     <option value="[% l %]">[% l %]</option>
769                 [% END %]
770         [% END %]
771     </select>
772
773     <input type="submit" value="Update" />
774 </form>
775
776 <div class="pages">[% pagination_bar %]</div>
777 [% UNLESS ( errors ) %]
778 <table>
779 <tr>[% FOREACH header_ro IN header_row %]<th>[% header_ro.cell %]</th>[% END %]</tr>
780 [% FOREACH result IN results %]
781 <tr>
782     [% FOREACH cell IN result.cells %]<td>[% cell.cell %]</td>[% END %]
783 </tr>
784 [% END %]
785 </table>
786 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
787 <fieldset class="action">
788 <label for="format">Download the report: </label>
789 <select name="format" id="format">
790 <option value="csv">Comma separated text</option>
791 <option value="tab">Tab separated text</option>
792 </select>
793 <input type="hidden" name="sql" value="[% sql |html %]" />
794 <input type="hidden" name="phase" value="Export" />
795 <input type="submit" name="submit" value="Download" /></fieldset>
796 </form>
797 [% END %]
798 [% END %]
799
800 [% IF ( create ) %]
801 <script type="text/javascript">
802 $(document).ready(function() {
803     load_group_subgroups();
804 });
805 </script>
806 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
807 <fieldset class="rows">
808 <legend>Create report from SQL</legend>
809 <ol>
810     <li><label for="reportname">Report name:</label>
811         [% IF ( reportname ) %]<input type="text" id="reportname" name="reportname" value="[% reportname %]" />
812         [% ELSE %]<input type="text" id="reportname" name="reportname" />[% END %] 
813     </li>
814     [% PROCESS group_and_subgroup_selection %]
815
816 [% IF (public) %]
817   <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>
818 [% ELSE %]
819   <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>
820 [% END %]
821 [% IF (usecache) %] <li>
822 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry %]"></input>
823 <select id="cache_expiry_units" name="cache_expiry_units">
824 <option value="seconds" selected="selected">Seconds (default)</option>
825 <option value="minutes">Minutes</option>
826 <option value="hours">Hours</option>
827 <option value="days">Days</option>
828 </select>
829 </li>[% END %]
830     <li><label for="notes">Notes:</label> <textarea id="notes" name="notes" cols="50" rows="2">[% notes %]</textarea></li>
831     <li><label for="types">Type:</label>
832         <select id="types" name="types">
833             <option value="1">Tabular</option>
834             <option value="2" disabled="disabled">Summary</option>
835             <option value="3" disabled="disabled">Matrix</option>
836         </select>
837     </li>
838 </ol>
839 </fieldset>
840 <fieldset class="rows">
841 <legend>SQL:</legend>
842 <div style="margin:1em;">
843 <textarea  id="sql" name="sql" cols="50" rows="10">[% sql %]</textarea>
844 </div>
845 </fieldset>
846
847 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
848 <input type="submit" name="submit" value="Save Report" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
849 </fieldset>
850 </form>
851 [% END %]
852
853 [% IF ( compound ) %]
854 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
855 Master: <select name="master">
856 [% FOREACH savedreport IN savedreports %]
857 <option value="[% savedreport.id %]">[% savedreport.report_name %]</option>
858 [% END %]
859 </select>
860 &nbsp;
861 Sub report:<select name="subreport">
862 [% FOREACH savedreport IN savedreports %]
863 <option value="[% savedreport.id %]">[% savedreport.report_name %]</option>
864 [% END %]
865 </select>
866 <br />
867 <input type="hidden" name="phase" value="Save Compound" />
868 <input type="submit" name="submit" value="Save compound" />
869 </form>
870 [% END %]
871
872 [% IF ( save_compound ) %]
873 [% master %] <br />
874 [% subsql %]
875 [% END %]
876
877
878 [% IF ( retresults ) %]
879 <h1>Saved report results</h1>
880 <h2>[% name %]</h2>
881 <p>[% notes %]</p>
882 <table>
883 [% FOREACH result IN results %]
884 [% result.row %]
885 [% END %]
886 </table>
887 [% END %]
888
889 [% IF ( showsql ) %]
890 <fieldset class="rows">
891     <legend>[% reportname %]</legend>
892     <ol>
893         [% IF ( notes ) %]<li><span class="label">Notes:</span> [% notes %]</li>[% ELSE %][% END %]
894         <li><textarea id="sql">[% sql %]</textarea></li>
895     </ol>
896 </fieldset>
897 [% END %]
898
899 [% IF ( editsql ) %]
900 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
901 <input type="hidden" name="phase" value="Update SQL" />
902 <input type="hidden" name="id" value="[% id %]"/>
903 <fieldset class="rows">
904 <legend>Edit SQL report</legend>
905 <ol>
906 <li><label for="reportname">Report name:</label><input type="text" id="reportname" name="reportname" value="[% reportname %]" size="50" /></li>
907 [% PROCESS group_and_subgroup_selection %]
908 [% IF (public) %]
909   <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>
910 [% ELSE %]
911   <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>
912 [% END %]
913 [% IF (usecache) %] <li>
914 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry %]"></input>
915 <select id="cache_expiry_units" name="cache_expiry_units">
916 <option value="seconds">Seconds (default)</option>
917 <option value="minutes">Minutes</option>
918 <option value="hours">Hours</option>
919 <option value="days">Days</option>
920 </select>
921 </li>[% END %]
922 <li><label for="notes">Notes:</label><textarea id="notes" name="notes" cols="50" rows="2">[% notes %]</textarea></li>
923 <li><textarea id="sql" name="sql" rows="10" cols="60">[% sql %]</textarea></li>
924 </ol>
925 </fieldset>
926
927 <fieldset class="action">
928 <input type="submit" name="submit" value="Update SQL" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
929 </fieldset>
930 </form>
931
932
933 [% END %]
934
935 [% IF ( save_successful ) %]
936 [% UNLESS ( errors ) %]
937 <h2>Your report has been saved</h2>
938 <h4>[% reportname %]</h4>
939 <ul>
940     [% IF ( id ) %]
941     <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&amp;phase=Run%20this%20report">Run this report</a></li>
942     [% END %]
943     <li>Access this report from the: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports page</a></li>
944     <li>Schedule this report to run using the: <a href="/cgi-bin/koha/tools/scheduler.pl">Scheduler tool</a></li>
945     <li>Return to: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Guided reports</a></li>
946 </ul>
947 [% END %]
948 [% END %]
949
950 [% IF ( errors ) %]
951 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
952 <div class="dialog alert">
953 <b>The following error was encountered:</b><br />
954 [% FOREACH error IN errors %]
955     [% IF ( error.sqlerr ) %]This report contains the SQL keyword <b>[% error.sqlerr %]</b>.
956     <br />Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.
957     <br />Please return to the &quot;Saved Reports&quot; screen and delete this report or retry creating a new one.
958     [% ELSIF ( error.queryerr ) %]The database returned the following error: <br />[% error.queryerr %]<br />Please check the log for further details.
959     [% ELSIF ( error.cache_expiry ) %]Please select a cache expiry less than 30 days.
960     [% ELSE %]
961     [% END %]
962 [% END %]
963 </div>
964 <fieldset class="action"><input type="hidden" name="phase" value="Use saved" />
965 <input type="submit" name="submit" value="Saved reports" /></fieldset>
966 </form>
967 [% END %]
968
969 </div>
970 </div>
971 <div class="yui-b">
972
973 [% IF ( saved1 ) %]
974 <div id="saved-reports-filter">
975 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
976   <input type="hidden" name="phase" value="Use saved" />
977   <input type="hidden" name="filter_set" value="1" />
978   <fieldset class="brief">
979   <h3>Filter</h3>
980   <ol>
981     <li><label for="filter_date">Date:</label> <input type="text" id="filter_date" name="filter_date" size="10" value="[% filter_date %]" class="datepicker" />
982     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
983
984     </li>
985     <li><label for="filter_author">Author:</label> <input type="text" id="filter_author" name="filter_author" value="[% filter_author %]" /></li>
986     <li><label for="filter_keyword">Keyword:</label> <input type="text" id="filter_keyword" name="filter_keyword" value="[% filter_keyword %]" /></li>
987   </ol>
988   </fieldset>
989   <fieldset class="action"><input type="submit" value="Apply filter" /></fieldset>
990 </form>
991 </div>
992 [% END %]
993
994
995 [% INCLUDE 'guided-reports-view.inc' %]
996 </div>
997 </div>
998 <script type="text/javascript">
999 //<![CDATA[
1000 function addColumn() {
1001     $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
1002 }
1003 function delColumn() {
1004     $("#selectedColumns option:selected").remove();
1005 }
1006 $("#column_submit").submit(function() {
1007     if ($("#selectedColumns option").size() < 1) {
1008         alert(_("No columns selected!"));
1009         return false;
1010     }
1011     $("#selectedColumns option").attr("selected", "selected");  // Select everything still in #selectedColumns
1012     return true;
1013 });
1014 //]]>
1015 </script>
1016 [% INCLUDE 'intranet-bottom.inc' %]
1017
1018
1019 [% BLOCK group_and_subgroup_selection %]
1020     <li id="group">
1021         <label>Report group:</label>
1022         <input type="radio" name="select_or_create_group"
1023             id="select_group" checked="checked" />
1024         <label for="select_group" style="float:none">Select</label>
1025         <select name="group" onChange="load_group_subgroups();" id="group_select">
1026             <option value="">(None)</option>
1027             [% FOREACH group IN groups_with_subgroups %]
1028                 [% IF (group.selected) %]
1029                     <option value="[% group.id %]" selected="selected">
1030                 [% ELSE %]
1031                     <option value="[% group.id %]">
1032                 [% END %]
1033                     [% group.name %]
1034                 </option>
1035             [% END %]
1036         </select>
1037         <input type="radio" name="select_or_create_group" id="create_group" />
1038         <label for="create_group" style="float:none">or create</label>
1039         <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
1040         <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
1041     </li>
1042     <li id="subgroup">
1043         <label>Report subgroup:</label>
1044         <input type="radio" name="select_or_create_subgroup"
1045             id="select_subgroup" checked="checked" />
1046         <label for="select_subgroup" style="float:none">Select</label>
1047         <select name="subgroup" id="subgroup_select">
1048             <option value="">(None)</option>
1049             [% FOREACH group IN groups_with_subgroups %]
1050                 [% IF (group.selected) %]
1051                     [% FOREACH subgroup IN group.subgroups %]
1052                         [% IF (subgroup.selected) %]
1053                             <option value="[% subgroup.id %]" selected="selected">
1054                         [% ELSE %]
1055                             <option value="[% subgroup.id %]">
1056                         [% END %]
1057                             [% subgroup.name %]
1058                         </option>
1059                     [% END %]
1060                 [% END %]
1061             [% END %]
1062         </select>
1063         <input type="radio" name="select_or_create_subgroup"
1064             id="create_subgroup" />
1065         <label for="create_subgroup" style="float:none">or create</label>
1066         <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
1067         <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />
1068     </li>
1069 [% END %]