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