Merge remote branch 'kc/new/bug_6126' into kcmaster
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reports / guided_reports_start.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Reports &rsaquo; Guided Reports Wizard 
3 [% IF ( saved1 ) %]&rsaquo; Saved Reports
4 [% ELSIF ( create ) %]&rsaquo; Create from SQL
5 [% ELSIF ( showsql ) %]&rsaquo; Saved Reports &rsaquo; SQL View
6 [% ELSIF ( execute ) %]&rsaquo; Saved Reports &rsaquo; [% name %] Report
7 [% ELSIF ( buildx ) %]&rsaquo; Build A Report, Step [% buildx %] of 6:
8 [% IF ( build1 ) %]Choose a Module
9 [% ELSIF ( build2 ) %]Pick a Report Type
10 [% ELSIF ( build3 ) %]Select Columns for Display
11 [% ELSIF ( build4 ) %]Select Criteria to Limit on
12 [% ELSIF ( build5 ) %]Pick which columns to total
13 [% ELSIF ( build6 ) %]Select how you want the report ordered
14 [% END %]
15 [% END %]
16 </title>
17 [% INCLUDE 'doc-head-close.inc' %]
18 [% INCLUDE 'calendar.inc' %]
19 <style type="text/css">
20     #sql { width: 90%; height: 9em;}
21 </style>
22 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
23 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.pager.js"></script>
24
25 <script type="text/javascript">
26 //<![CDATA[
27 $(document).ready(function(){
28 [% IF ( showsql ) %]
29     $("#sql").focus(function() {
30         $(this).select();
31     });
32 [% END %]
33 [% IF ( saved1 ) %]
34     $(".confirmdelete").click(function(){
35         $(this).parents('tr').attr("class","warn");
36         if(confirm("Are you sure you want to "+$(this).attr("title")+"?")){
37             return true;
38         } else {
39             $(this).parents('tr').attr("class","");
40             return false;
41         }
42     });
43 [% END %]
44   // call the tablesorter plugin
45   $("#table_reports").tablesorter({
46     sortList: [[1,0]],
47     headers: {
48        6: { sorter: false},
49        7: { sorter: false},
50        8: { sorter: false},
51        9: { sorter: false},
52       10: { sorter: false}
53     }
54   }).tablesorterPager({
55     container:     $("#pagertable_reports"),
56     positionFixed: false,
57     size:          50
58   });
59 });
60 //]]>
61 </script>
62 </head>
63 <body>
64 [% INCLUDE 'header.inc' %]
65 [% INCLUDE 'circ-search.inc' %]
66
67 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>
68 &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
69 &rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided Reports Wizard</a>
70 &rsaquo; 
71 [% IF ( saved1 ) %]Saved Reports
72 [% ELSIF ( create ) %]Create from SQL
73 [% ELSIF ( showsql ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved Reports</a> &rsaquo; SQL View
74 [% ELSIF ( execute ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved Reports</a> &rsaquo; <em>[% name %]</em> Report
75 [% ELSIF ( buildx ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build A Report</a> &rsaquo; Step [% buildx %] of 6:
76     [% IF ( build1 ) %]Choose a Module
77     [% ELSIF ( build2 ) %]Pick a Report Type
78     [% ELSIF ( build3 ) %]Select Columns for Display
79     [% ELSIF ( build4 ) %]Select Criteria to Limit on
80     [% ELSIF ( build5 ) %]Pick which columns to total
81     [% ELSIF ( build6 ) %]Select how you want the report ordered
82     [% END %]
83 [% END %]
84 </div>
85
86 <div id="doc3" class="yui-t1">
87 <div id="bd">
88 <div id="yui-main">
89     <div class="yui-b">
90
91 [% IF ( start ) %]
92     <h2>Guided Reports</h2>
93     <p>Use the guided reports engine to create non standard reports.
94 This feature aims to provide some middle ground between the built in
95 canned reports and writing custom SQL reports.</p>
96
97     <h3>Build And Run Reports</h3>
98         [% IF ( CAN_user_reports_create_reports ) %]
99         <form action="/cgi-bin/koha/reports/guided_reports.pl">
100             <input type="hidden" name="phase" value="Build new" />
101             <input type="submit" name="submit" value="Build new"/>
102         </form>
103         [% END %]
104         [% IF ( CAN_user_reports_execute_reports ) %]
105         <form action="/cgi-bin/koha/reports/guided_reports.pl">
106             <input type="hidden" name="phase" value="Use saved"/>
107             <input type="submit" name="submit" value="Use saved"/>
108         </form>
109         [% END %]
110         [% IF ( CAN_user_reports_create_reports ) %]
111         <form action="/cgi-bin/koha/reports/guided_reports.pl">
112             <input type="hidden" name="phase" value="Create report from SQL"/>
113             <input type="submit" name="submit" value="Create report from SQL"/>
114         </form>
115         [% END %]
116 <h3>Reports Dictionary</h3>
117 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
118 <form action="/cgi-bin/koha/reports/dictionary.pl">
119 <input type="hidden" name="phase" value="View Dictionary"/>
120 <input type="submit" name="submit" value="View Dictionary"/>
121 </form>
122 [% END %]
123
124 [% IF ( saved1 ) %]
125 [% IF ( savedreports ) %]<h1>Saved Reports</h1>
126 <p>Choose the report to run from the list</p>
127
128 <span id="pagertable_reports" class="pager">
129  <form class="formpager">&nbsp;<strong>page(s)</strong>&nbsp;:
130   <img src="[% interface %]/prog/img/first.png" class="first"/>
131   <img src="[% interface %]/prog/img/prev.png" class="prev"/>
132   <input type="text" size="5" class="pagedisplay"/>
133   <img src="[% interface %]/prog/img/next.png" class="next"/>
134   <img src="[% interface %]/prog/img/last.png" class="last"/>
135   , entries/page:
136   <select class="pagesize">
137    <option value="10">10</option>
138    <option value="25" selected="selected">25</option>
139    <option value="50">50</option>
140    <option value="100">100</option>
141    <option value="200">200</option>
142   </select>
143  </form>
144 </span>
145
146 <table id="table_reports" class="tablesorter">
147 <thead>
148  <tr>
149   <th>ID</th>
150   <th>Report Name</th>
151   <th>Type</th>
152   <th>Notes</th>
153   <th>Author</th>
154   <th>Creation Date</th>
155   <th>Saved Results</th>
156   <th>Saved SQL</th>
157   <th>&nbsp;</th>
158   <th>&nbsp;</th>
159  </tr>
160 </thead>
161 <tbody>
162 [% FOREACH savedreport IN savedreports %]
163 [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
164 <td>[% savedreport.id %]</td>
165 <td>[% savedreport.report_name %]</td>
166 <td>[% savedreport.type %]</td>
167 <td>[% savedreport.notes %]</td>
168 <td>[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %])</td>
169 <td>[% savedreport.date_created %]</td>
170 <td>[% IF ( savedreport.date_run ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=[% savedreport.id %]">[% savedreport.date_run %]</a>[% END %]
171 </td>
172     <td>
173         <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Show%20SQL">Show</a> 
174         [% IF ( CAN_user_reports_create_reports ) %]
175             &nbsp; <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Edit%20SQL">Edit</a>
176         [% END %]
177     </td>
178 <td><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Run%20this%20report">Run</a>
179 <a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id %]">Schedule</a></td>
180     [% IF ( CAN_user_reports_create_reports ) %]
181         <td><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Delete%20Saved">Delete</a></td>
182     [% END %]
183 </tr>
184 [% END %]
185 </tbody>
186 </table>
187 [% ELSE %]<h4>There are no saved reports. 
188     [% IF ( CAN_user_reports_create_reports ) %]
189         <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build new?</a>
190     [% END %]
191 </h4>
192 [% END %]
193 [% END %]
194
195
196 [% IF ( build1 ) %]
197 <h1>Build A Report</h1>
198 <form action="/cgi-bin/koha/reports/guided_reports.pl">
199 <fieldset class="rows">
200 <legend>Step 1 of 6: Choose a Module to Report on</legend>
201 <ol><li><label for="areas">Choose: </label><select name="areas" id="areas">
202 [% FOREACH area IN areas %]
203 <option value="[% area.id %]">[% area.name %]</option>
204 [% END %]
205 </select></li></ol>
206 </fieldset>
207 <fieldset class="action">
208 <input type="hidden" name="phase" value="Report on this Area" />
209 <input type="submit" name="submit" value="Next &gt;&gt;" />
210
211 </fieldset>
212 </form>
213 [% END %]
214
215
216 [% IF ( build2 ) %]
217 <h1>Build A Report</h1>
218 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
219 <input type="hidden" name="area" value="[% area %]" />
220 <fieldset class="rows"><legend>Step 2 of 6: Pick a Report Type</legend>
221 <ol><li><label for="types">Choose: </label>
222     <select id="types" name="types">
223         <option value="1">Tabular</option>
224         <option value="2" disabled="disabled">Summary</option>
225         <option value="3" disabled="disabled">Matrix</option>
226     </select>
227 </li></ol></fieldset>
228
229 <fieldset class="action">
230     <input type="hidden" name="phase" value="Choose this type" />
231     <input type="button" name="back" value="&lt;&lt; Back" onclick="javascript:history.back()" />
232     <input type="submit" name="submit" value="Next &gt;&gt;" />
233 </fieldset>
234 </form>
235 </div>
236 <div class="yui-gb"><div class="yui-u first"></div>
237
238 <!--- Summary and Matrix reports have not yet been implemented-->
239 <!--<div class="yui-u">Summary:
240 <img src="/intranet-tmpl/prog/img/reports-summary-graphic.gif" /></div>
241 <div class="yui-u">Matrix:
242 <img src="/intranet-tmpl/prog/img/reports-matrix-graphic.gif" /></div>-->
243
244 [% END %]
245
246 [% IF ( build3 ) %]
247 <h3>Step 3 of 6: Select Columns for Display</h3>
248 <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>
249
250 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
251     <input type="hidden" name="area" value="[% area %]" />
252     <input type="hidden" name="type" value="[% type %]" />
253     <fieldset>
254 <div class="yui-g">
255 <div class="yui-u first">       <div style="float: left;"><select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
256 [% FOREACH column IN columns %]
257 [% IF ( column.table ) %]
258
259 [% IF ( loop.first ) %]
260 [% ELSE %]
261 </optgroup>
262 [% END %]
263
264 <optgroup label="[% column.table %]">
265 [% ELSE %]
266 <option value="[% column.name %]">
267 [% IF ( column.description ) %][% column.description %]
268 [% ELSE %]
269 [% column.name %]
270 [% END %]
271 </option>
272 [% END %]
273 [% END %]
274 </optgroup>
275 </select></div>
276 <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 />
277 <input type="button" name="delete" value="&lt;&lt; Delete" class="button" style="width: 6em; margin: 1em 0;" onclick="delColumn()" /></div>
278 </div>
279
280 <div class="yui-u">
281 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;"></select>
282 </div>
283 </div>
284 </fieldset>
285 <div class="yui-g">
286 <fieldset class="action">
287     <input type="hidden" name="phase" value="Choose these columns" />
288     <input type="button" name="back" value="&lt;&lt; Back" onclick="javascript:history.back()" />
289     <input type="submit" name="submit" value="Next &gt;&gt;" />
290 </fieldset>
291 </div>
292 </form>
293
294 [% END %]
295
296 [% IF ( build4 ) %]
297 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
298     <input type="hidden" name="area" value="[% area %]" />
299     <input type="hidden" name="type" value="[% type %]" />
300     <input type="hidden" name="column" value="[% column %]" />
301     <fieldset><legend>Step 4 of 6: Select Criteria to Limit on</legend>
302     <table>
303         [% FOREACH criteri IN criteria %]
304         <tr>
305         <td>
306             <input type="checkbox" name="criteria_column" id="[% criteri.name %]" value="[% criteri.name %]" /> 
307             <label for="[% criteri.name %]">[% criteri.description %] </label>
308         </td>
309         [% IF ( criteri.date ) %]
310         <td>
311             <input type="text" size="10" id="[% criteri.name %]_value" name="[% criteri.name %]_value" value="" />
312             <img src="[% themelang %]/lib/calendar/cal.gif" id="buttonfrom[% criteri.name %]" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />                 
313             <script type="text/javascript">   
314             Calendar.setup({  
315             inputField     : "[% criteri.name %]_value",
316             ifFormat       : "[% criteri.DHTMLcalendar_dateformat %]",
317             button         : "buttonfrom[% criteri.name %]",
318             align          : "Tl" 
319             });     
320             </script>          
321                 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
322         </td>
323         </tr>
324         [% ELSE %]
325         [% IF ( criteri.textrange ) %]
326             <td>from
327             <input type="text" size="10" id="[% criteri.from %]_value" name="[% criteri.from %]_value" value="" /> to 
328             <input type="text" size="10" id="[% criteri.to %]_value" name="[% criteri.to %]_value" value="" />
329             </td>
330             </tr>
331         [% ELSE %]
332             [% IF ( criteri.daterange ) %]
333             <td>from 
334             <input type="text" size="10" id="from_[% criteri.name %]_value" name="from_[% criteri.name %]_value" value="" />
335             <img src="[% themelang %]/lib/calendar/cal.gif" id="buttonfromfrom_[% criteri.name %]" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />                 
336             <script type="text/javascript">   
337                 Calendar.setup({  
338                 inputField     : "from_[% criteri.name %]_value",
339                 ifFormat       : "[% criteri.DHTMLcalendar_dateformat %]",
340                 button         : "buttonfromfrom_[% criteri.name %]",
341                 align          : "Tl" 
342                 });     
343             </script>         
344             to
345             <input type="text" size="10" id="to_[% criteri.name %]_value" name="to_[% criteri.name %]_value" value="" />
346             <img src="[% themelang %]/lib/calendar/cal.gif" id="buttonfromto_[% criteri.name %]" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />                 
347             <script type="text/javascript">   
348                 Calendar.setup({  
349                 inputField     : "to_[% criteri.name %]_value",
350                 ifFormat       : "[% criteri.DHTMLcalendar_dateformat %]",
351                 button         : "buttonfromto_[% criteri.name %]",
352                 align          : "Tl" 
353                 });     
354             </script>        
355                         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
356             </td>
357         </tr>
358             [% ELSE %]
359             <td>
360                 <select name="[% criteri.name %]_value">
361                 [% FOREACH value IN criteri.values %]
362                 <option value="[% value.availablevalues %]">[% IF ( value.default ) %]Default[% ELSE %][% value.availablevalues |html %][% END %]</option>
363                 [% END %]
364                 </select>
365             </td>
366             </tr>
367             [% END %]
368         [% END %]
369         [% END %]
370     [% END %]
371     </table>
372     </fieldset>
373
374 [% IF ( definitions ) %]
375 <fieldset><legend>Dictionary Definitions</legend><table>
376 [% FOREACH definition IN definitions %]
377     <tr><td><input type="checkbox" name="definition" value="<!--
378 TMPL_VAR NAME="id" -->" /> [% definition.name %]</td></tr>
379 [% END %]
380 </table>
381 [% END %]
382
383 <fieldset class="action"><input type="hidden" name="phase" value="Choose these criteria" />
384     <input type="button" name="back" value="&lt;&lt; Back" onclick="javascript:history.back()" />
385     <input type="submit" name="submit" value="Next &gt;&gt;" /> </fieldset>
386 </form>
387 [% END %]
388
389
390 [% IF ( build5 ) %]
391 <h3>Step 5 of 6: Pick which columns to total</h3>
392 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
393 <input type="hidden" name="area" value="[% area %]" />
394 <input type="hidden" name="type" value="[% type %]" />
395 <input type="hidden" name="column" value="[% column %]" />
396 <input type="hidden" name="definition" value="[% definition %]" />
397 <input type="hidden" name="criteria" value="[% criteriastring %]" />
398 <fieldset><table>
399 [% FOREACH total_b IN total_by %]
400 <tr><td><input type="checkbox" name="total_by" id="<!-- TMPL_VAR
401 NAME="name" -->" value="<!-- TMPL_VAR
402 NAME="name" -->" /> <label for="<!-- TMPL_VAR
403 NAME="name" -->">[% total_b.name %]</label></td>
404 <td><select name="[% total_b.name %]_tvalue">
405
406 [% FOREACH selec IN total_b.select %]
407 <option value="[% selec.value %]">[% selec.value %]</option>
408 [% END %]
409 </select>
410
411 </td></tr>
412 [% END %]
413 </table></fieldset>
414
415 <fieldset class="action"><input type="hidden" name="phase" value="Choose These Operations" />
416     <input type="button" name="back" value="&lt;&lt; Back" onclick="javascript:history.back()" />
417     <input type="submit" name="submit" value="Next &gt;&gt;" /></fieldset>
418 </form>
419 [% END %]
420
421
422 [% IF ( build6 ) %]
423 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
424 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
425 <input type="hidden" name="area" value="[% area %]" />
426 <input type="hidden" name="type" value="[% type %]" />
427 <input type="hidden" name="column" value="[% column %]" />
428 <input type="hidden" name="criteria" value="[% criteriastring %]" />
429 <input type="hidden" name="definition" value="[% definition %]" />
430 <input type="hidden" name="totals" value="[% totals %]" />
431 <fieldset><table>[% FOREACH order_b IN order_by %]
432 <tr><td><input type="checkbox" id="<!-- TMPL_VAR
433 NAME="name" -->" name="order_by" value="<!-- TMPL_VAR
434 NAME="name" -->" /> <label for="<!-- TMPL_VAR
435 NAME="name" -->">[% order_b.name %]</label></td><td>
436 <select name="[% order_b.name %]_ovalue">
437
438 [% FOREACH selec IN order_b.select %]
439 <option value="[% selec.value %]">[% selec.value %]</option>
440 [% END %]
441 </select>
442 </td></tr>
443
444 [% END %]
445 </table></fieldset>
446
447 <fieldset class="action">
448 <input type="hidden" name="phase" value="Build Report" />
449 <input type="submit" name="submit" value="Finish" /></fieldset>
450 </form>
451 [% END %]
452
453
454 [% IF ( showreport ) %]
455 <h1>Confirm Custom Report</h1>
456 <p>Your report will be generated with the following SQL statement.</p>
457 <p> 
458 [% sql |html %]
459 </p>
460
461 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
462 <input type="hidden" name="sql" value="[% sql %]" />
463 <input type="hidden" name="type" value="[% type %]" />
464 <p>You will need to save the report before you can execute it</p>
465 <fieldset class="action"><input type="hidden" name="phase" value="Save" />  
466 <input type="submit" name="submit" value="Save" />  </fieldset>
467 </form>
468 [% END %]
469
470 [% IF ( save ) %]
471 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
472 <input type="hidden" name="sql" value="[% sql |html %]" />
473 <input type="hidden" name="type" value="[% type %]" />
474 <fieldset class="rows">
475 <legend>Save Your Custom Report</legend>
476 <ol>
477     <li><label for="reportname">Report Name: </label><input type="text" id="reportname" name="reportname" /></li>
478     <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li>
479 </ol></fieldset>
480 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
481 <input type="submit" name="submit" value="Save Report" /></fieldset>
482 </form>
483 [% END %]
484
485 [% IF ( enter_params ) %]
486     <form action='/cgi-bin/koha/reports/guided_reports.pl'>
487         <input type='hidden' name='phase' value='Run this report' />
488         <input type='hidden' name='reports' value="[% reports %]" />
489         <h1>Enter parameters for report [% name %]:</h1>
490         [% IF ( notes ) %]<p>[% notes %]</p>[% END %]
491         [% FOREACH sql_param IN sql_params %]
492             <p>[% sql_param.entry %]: [% sql_param.input %]</p>
493         [% END %]
494         <input type='submit' value='Run the report'/>
495     </form>
496 [% END %]
497
498 [% IF ( execute ) %]
499 <h1>[% name %]</h1>
500 [% IF ( notes ) %]<p>[% notes %]</p>[% END %]
501 [% IF ( unlimited_total ) %]<p>Total number of rows matching the (unlimited) query is [% unlimited_total %].</p>[% END %]
502 <pre id="sql_output">[% sql %]</pre>
503 <div class="pages">[% DEFAULT pagination_bar="" %]</div>
504 [% UNLESS ( errors ) %]
505 <table>
506 <tr>[% FOREACH header_ro IN header_row %]<th>[% header_ro.cell %]</th>[% END %]</tr>
507 [% FOREACH result IN results %]
508 <tr>
509     [% FOREACH cell IN result.cells %]<td>[% cell.cell %]</td>[% END %]
510 </tr>
511 [% END %]
512 </table>
513 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
514 <fieldset class="action">
515 <label for="format">Download the report: </label>
516 <select name="format" id="format">
517 <option value="csv">Comma Separated Text</option>
518 <option value="tab">Tab Separated Text</option>
519 </select>
520 <input type="hidden" name="sql" value="[% sql |html %]" />
521 <input type="hidden" name="phase" value="Export" />
522 <input type="submit" name="submit" value="Download" /></fieldset>
523 </form>
524 [% END %]
525 [% END %]
526
527 [% IF ( create ) %]
528 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
529 <fieldset class="rows">
530 <legend>Create Report From SQL</legend>
531 <ol>
532     <li><label for="reportname">Report Name:</label> <input type="text" id="reportname" name="reportname" [% IF ( reportname ) %] value="[% reportname %]"[% END %] /> </li>
533     <li><label for="notes">Notes:</label> <textarea id="notes" name="notes" cols="50" rows="2">[% DEFAULT notes="" %]</textarea></li>
534     <li><label for="types">Type:</label>
535         <select id="types" name="types">
536             <option value="1">Tabular</option>
537             <option value="2" disabled="disabled">Summary</option>
538             <option value="3" disabled="disabled">Matrix</option>
539         </select>
540     </li>
541 </ol>
542 </fieldset>
543 <fieldset class="rows">
544 <legend>SQL:</legend>
545 <div style="margin:1em;">
546 <textarea  id="sql" name="sql" cols="50" rows="10">[% DEFAULT sql="" %]</textarea>
547 </div>
548 </fieldset>
549
550 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
551 <input type="submit" name="submit" value="Save Report" /></fieldset>
552 </form>
553 [% END %]
554
555 [% IF ( compound ) %]
556 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
557 Master: <select name="master">
558 [% FOREACH savedreport IN savedreports %]
559 <option value="[% savedreport.id %]">[% savedreport.report_name %]</option>
560 [% END %]
561 </select>
562 &nbsp;
563 Sub report:<select name="subreport">
564 [% FOREACH savedreport IN savedreports %]
565 <option value="[% savedreport.id %]">[% savedreport.report_name %]</option>
566 [% END %]
567 </select>
568 <br />
569 <input type="hidden" name="phase" value="Save Compound" />
570 <input type="submit" name="submit" value="Save Compound" />
571 </form>
572 [% END %]
573
574 [% IF ( save_compound ) %]
575 [% master %] <br />
576 [% subsql %]
577 [% END %]
578
579
580 [% IF ( retresults ) %]
581 <h1>Saved Report Results</h1>
582 <h2>[% name %]</h2>
583 <p>[% notes %]</p>
584 <table>
585 [% FOREACH result IN results %]
586 [% result.row %]
587 [% END %]
588 </table>
589 [% END %]
590
591 [% IF ( showsql ) %]
592 <textarea id="sql">[% sql %]</textarea>
593 [% END %]
594
595 [% IF ( editsql ) %]
596 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
597 <input type="hidden" name="phase" value="Update SQL" />
598 <input type="hidden" name="id" value="[% id %]"/>
599 <fieldset class="rows">
600 <legend>Edit SQL</legend>
601 <ol>
602 <li><label for="reportname">Report Name:</label><input type="text" id="reportname" name="reportname" value="[% reportname %]" /></li>
603 <li><label for="notes">Notes:</label><textarea id="notes" name="notes" cols="50" rows="2">[% notes %]</textarea></li>
604 <li><textarea id="sql" name="sql" rows="10" cols="60">[% sql %]</textarea></li>
605 </ol>
606 </fieldset>
607
608 <fieldset class="action">
609 <input type="submit" name="submit" value="Update SQL" /></fieldset>
610 </form>
611
612
613 [% END %]
614
615 [% IF ( save_successful ) %]
616 [% UNLESS ( errors ) %]
617 <h2>Your report has been saved</h2>
618 <p>The report you have created has now been saved. You can now</p>
619 <ul>
620     [% IF ( id ) %]
621     <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&amp;phase=Run%20this%20report">Run this report</a></li>
622     [% END %]
623     <li>Access this report from the: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved Reports Page</a></li>
624     <li>Schedule this report to run using the: <a href="/cgi-bin/koha/tools/scheduler.pl">Scheduler Tool</a></li>
625     <li>Return to: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Guided Reports</a></li>
626 </ul>
627 [% END %]
628 [% END %]
629
630 [% IF ( errors ) %]
631 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
632 <div class="dialog alert">
633 <b>The following error was encountered:</b><br />
634 [% FOREACH error IN errors %]
635     [% IF ( error.sqlerr ) %]This report contains the SQL keyword <b>[% error.sqlerr %]</b>.
636     <br />Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.
637     <br />Please return to the &quot;Saved Reports&quot; screen and delete this report or retry creating a new one.
638     [% ELSIF ( error.queryerr ) %]The database returned the following error: <br />[% error.queryerr %]<br />Please check the log for further details.
639     [% ELSE %]
640     [% END %]
641 [% END %]
642 </div>
643 <fieldset class="action"><input type="hidden" name="phase" value="Use saved" />
644 <input type="submit" name="submit" value="Saved Reports" /></fieldset>
645 </form>
646 [% END %]
647
648 </div>
649 </div>
650 <div class="yui-b">
651 [% INCLUDE 'guided-reports-view.inc' %]
652 </div>
653 </div>
654 <script type="text/javascript">
655 //<![CDATA[
656 function addColumn() {
657     $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
658 }
659 function delColumn() {
660     $("#selectedColumns option:selected").remove();
661 }
662 $("#column_submit").submit(function() {
663     if ($("#selectedColumns option").size() < 1) {
664         alert(_("No columns selected!"));
665         return false;
666     }
667     $("#selectedColumns option").attr("selected", "selected");  // Select everything still in #selectedColumns
668     return true;
669 });
670 //]]>
671 </script>
672 [% INCLUDE 'intranet-bottom.inc' %]