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