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