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