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