Bug 22147: Hidden 'Batch modify' button on report print layout
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reports / guided_reports_start.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE Koha %]
5 [% USE ColumnsSettings %]
6 [% USE JSON.Escape %]
7 [% SET footerjs = 1 %]
8
9 [%- BLOCK area_name -%]
10     [%- SWITCH area -%]
11         [%- CASE 'CIRC' -%]Circulation
12         [%- CASE 'CAT'  -%]Catalog
13         [%- CASE 'PAT'  -%]Patrons
14         [%- CASE 'ACQ'  -%]Acquisitions
15         [%- CASE 'ACC'  -%]Accounts
16         [%- CASE 'SER'  -%]Serials
17     [%- END -%]
18 [%- END -%]
19
20 [% INCLUDE 'doc-head-open.inc' %]
21
22 <title>Koha &rsaquo; Reports &rsaquo; Guided reports wizard [%- IF ( saved1 ) -%]&rsaquo; Saved reports
23 [%- ELSIF ( create ) -%]&rsaquo; Create from SQL
24 [%- ELSIF ( showsql ) -%]&rsaquo; Saved reports &rsaquo; SQL view
25 [%- ELSIF ( execute ) -%]&rsaquo; Saved reports &rsaquo; [% name | html %] Report
26 [%- ELSIF ( editsql ) -%]&rsaquo; Saved reports &rsaquo; Edit SQL report
27 [%- END -%]
28 [%- IF ( build1 ) -%]&rsaquo; Build a report, step 1 of 6: Choose a module
29 [%- ELSIF ( build2 ) -%]&rsaquo; Build a report, step 2 of 6: Pick a report type
30 [%- ELSIF ( build3 ) -%]&rsaquo; Build a report, step 3 of 6: Select columns for display
31 [%- ELSIF ( build4 ) -%]&rsaquo; Build a report, step 4 of 6: Select criteria to limit on
32 [%- ELSIF ( build5 ) -%]&rsaquo; Build a report, step 5 of 6: Pick which columns to total
33 [%- ELSIF ( build6 ) -%]&rsaquo; Build a report, step 6 of 6: Select how you want the report ordered
34 [%- END -%]</title>
35
36 [% INCLUDE 'doc-head-close.inc' %]
37 [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
38 <style>
39 .CodeMirror {
40     resize:  vertical;
41 }
42 </style>
43 [% Asset.css("css/reports.css") | $raw %]
44 [% IF ( saved1 ) %]
45     [% Asset.css("css/datatables.css") | $raw %]
46 [% END %]
47 [% Asset.css("lib/d3c3/c3.min.css") | $raw %]
48 </head>
49
50 <body id="rep_guided_reports_start" class="rep">
51 [% INCLUDE 'header.inc' %]
52 [% INCLUDE 'circ-search.inc' %]
53
54 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a>
55 &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
56 &rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
57
58 [% IF ( saved1 ) %]&rsaquo; Saved reports
59 [% ELSIF ( create ) %]&rsaquo; Create from SQL
60 [% ELSIF ( showsql ) %]&rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> &rsaquo; SQL view
61 [% ELSIF ( editsql ) %]&rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> &rsaquo; Edit SQL report
62 [% ELSIF ( execute ) %]&rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> &rsaquo; <em>[% name | html %]</em> Report
63 [% ELSIF ( build1 || build2 || build3 || build4 || build5 || build6 ) %]&rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a report</a>
64     [% IF ( build1 ) %]&rsaquo; Step 1 of 6: Choose a module
65     [% ELSIF ( build2 ) %]&rsaquo; Step 2 of 6: Pick a report type
66     [% ELSIF ( build3 ) %]&rsaquo; Step 3 of 6: Select columns for display
67     [% ELSIF ( build4 ) %]&rsaquo; Step 4 of 6: Select criteria to limit on
68     [% ELSIF ( build5 ) %]&rsaquo; Step 5 of 6: Pick which columns to total
69     [% ELSIF ( build6 ) %]&rsaquo; Step 6 of 6: Select how you want the report ordered
70     [% END %]
71 [% END %]
72 </div>
73
74 <div id="update_sql" class="modal" tabindex="-1" role="dialog" aria-labelledby="update_sql_label" aria-hidden="true">
75     <div class="modal-dialog">
76     <div class="modal-content">
77     <div class="modal-header">
78         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
79         <h3 id="update_sql_label">Update SQL</h3>
80     </div>
81     <div class="modal-body">
82         <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
83     </div>
84     <div class="modal-footer">
85         <a href="#" class="btn btn-default" id="update_sql_button" role="button" data-toggle="modal">Update</a>
86         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
87     </div>
88     </div>
89     </div>
90 </div>
91
92 <div class="main container-fluid">
93     <div class="row">
94         <div class="col-sm-10 col-sm-push-2">
95             <main>
96
97     [% INCLUDE "reports-toolbar.inc" %]
98
99 [% IF ( start ) %]
100     <h2>Guided reports</h2>
101     <p>Use the guided reports engine to create non standard reports.
102 This feature aims to provide some middle ground between the built in
103 canned reports and writing custom SQL reports.</p>
104
105     <h3>Build and run reports</h3>
106         [% IF ( CAN_user_reports_create_reports ) %]
107         <form action="/cgi-bin/koha/reports/guided_reports.pl">
108             <input type="hidden" name="phase" value="Build new" />
109             <input type="submit" name="submit" value="Build new"/>
110         </form>
111         [% END %]
112         [% IF ( CAN_user_reports_execute_reports ) %]
113         <form action="/cgi-bin/koha/reports/guided_reports.pl">
114             <input type="hidden" name="phase" value="Use saved"/>
115             <input type="submit" name="submit" value="Use saved"/>
116         </form>
117         [% END %]
118         [% IF ( CAN_user_reports_create_reports ) %]
119         <form action="/cgi-bin/koha/reports/guided_reports.pl">
120             <input type="hidden" name="phase" value="Create report from SQL"/>
121             <input type="submit" name="submit" value="Create report from SQL"/>
122         </form>
123         [% END %]
124 <h3>Reports Dictionary</h3>
125 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
126 <form action="/cgi-bin/koha/reports/dictionary.pl">
127 <input type="hidden" name="phase" value="View Dictionary"/>
128 <input type="submit" name="submit" value="View dictionary"/>
129 </form>
130 [% END %]
131
132 [% IF report_converted %]
133     <div class="dialog message">
134         The report "[% report_converted | html %]" has been converted.
135     </div>
136 [% END %]
137
138 [% IF report_converted %]
139     <div class="dialog message">
140         The report "[% report_converted | html %]" has been converted.
141     </div>
142 [% END %]
143
144
145 [% IF ( saved1 ) %]
146 [% IF ( savedreports ) %]<h1>Saved reports</h1>
147
148 [% IF ( filters.date || filters.author || filters.keyword ) %]
149     <p>Filtered by:
150         <span class="filter">
151             [% IF ( filters.date ) %]
152                 <span class="filter_date"><strong>Date:</strong> [% filters.date | html %]</span>
153             [% END %]
154             [% IF ( filters.author ) %]
155                 <span class="filter_author"><strong>Author:</strong> [% filters.author | html %]</span>
156             [% END %]
157             [% IF ( filters.keyword ) %]
158                 <span class="filter_keyword"><strong>Keyword:</strong> [% filters.keyword | html %]</span>
159             [% END %]
160             <a class="clear_filter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1"><i class="fa fa-remove"></i> Clear</a>
161         </span>
162     </p>
163 [% END %]
164
165 <div id="tabs" class="toptabs">
166     <ul>
167         <li><a href="#reports">All</a></li>
168         [% FOREACH group IN groups_with_subgroups %]
169             <li><a id="[% group.id | html %]" href="#reports">[% group.name | html %]</a></li>
170         [% END %]
171     </ul>
172     <div id="reports">
173         <div id="subgroup_filter_block">
174             <label for="subgroup_filter">Subgroup:</label>
175             <select id="subgroup_filter">
176                 <option value="">All</option>
177             </select>
178         </div>
179 <div style="display:inline-block">
180     [% IF manamsg %]
181      <div id="mana_search" class="dialog message">
182         <p> [% manamsg | html %] </p>
183     </div>
184     [% END %]
185
186 </script>
187
188 <form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
189 <input type="hidden" name="phase" value="Delete Multiple" />
190         <table id="table_reports">
191             <thead>
192                 <tr>
193                     <th>&nbsp;</th>
194                     <th>ID</th>
195                     <th>Report name</th>
196                     <th>Type</th>
197                     <th>Group</th>
198                     <th>Subgroup</th>
199                     <th>Notes</th>
200                     <th>Author</th>
201                     <th class="title-string">Creation date</th>
202                     <th class="title-string">Last edit</th>
203                     <th class="title-string">Last run</th>
204                     <th class="report_public">Public</th>
205                     <th class="report_json_url">JSON URL</th>
206                     [% IF (usecache) %]
207                         <th>Cache expiry (seconds)</th>
208                     [% ELSE %]
209                         <th class="hidden">&nbsp;</th>
210                     [% END %]
211                     <th>Saved results</th>
212                     [% IF has_obsolete_reports %]
213                         <th>Update</th>
214                     [% ELSE %]
215                         <th class="hidden">&nbsp;</th>
216                     [% END %]
217                     <th>Actions</th>
218                 </tr>
219             </thead>
220             <tbody>
221                 [% FOREACH savedreport IN savedreports %]
222                     [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
223                         <td class="report_checkbox">
224                             [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
225                                 <input type="checkbox" name="ids" value="[% savedreport.id | html %]" />
226                             [% END %]
227                         <input hidden class="report_sql" value="[% savedreport.savedsql |html %]">
228                         </td>
229                         <td class="report_id"><label for="ids">[% savedreport.id | html %]</label></td>
230                         <td class="report_name">
231                             [% IF ( savedreport.report_name ) %]
232                                 [% savedreport.report_name | html %]
233                             [% ELSE %]
234                                 [ no name ]
235                             [% END %]
236                         </td>
237                         <td class="report_type">[% savedreport.type | html %]</td>
238                         <td class="report_group">[% savedreport.groupname | html %]</td>
239                         <td>[% savedreport.subgroupname | html %]</td>
240                         <td class="report_notes">[% savedreport.notes | html %]</td>
241                         <td>[% savedreport.borrowersurname | html %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname | html %][% END %] ([% savedreport.borrowernumber | html %])</td>
242                         <td><span title="[% savedreport.date_created | html %]">[% savedreport.date_created | $KohaDates %]</span></td>
243                         <td><span title="[% savedreport.last_modified | html %]">[% savedreport.last_modified | $KohaDates  with_hours => 1 %]</span></td>
244                         <td><span title="[% savedreport.last_run | html %]">[% savedreport.last_run | $KohaDates  with_hours => 1 %]</span></td>
245                         <td class="report_public">
246                         [% IF (savedreport.public) %]
247                             Yes
248                         [% ELSE %]
249                             No
250                         [% END %]
251                         </td>
252                         <td class="report_json_url">
253                         [% IF (savedreport.public) %]
254                             <a href="[% OPACBaseURL | url %]/cgi-bin/koha/svc/report?id=[% savedreport.id | uri %]">[% OPACBaseURL | html %]/cgi-bin/koha/svc/report?id=[% savedreport.id | html %]</a>
255                         [% ELSE %]
256                             <a href="/cgi-bin/koha/svc/report?id=[% savedreport.id | uri %]">[% Koha.Preference('staffClientBaseURL') | html %]/cgi-bin/koha/svc/report?id=[% savedreport.id | html %]</a>
257                         [% END %]
258                         </td>
259                         <td>[% savedreport.cache_expiry | html %]</td>
260                         <td>
261                             [% FOR result IN savedreport.results %]
262                                 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&amp;id=[% result.id | uri %]">[% result.date_run | html %]</a>
263                                 <br/>
264                             [% END %]
265                         </td>
266                         <td>
267                             [% IF savedreport.seems_obsolete %]
268                                 This report seems obsolete, it uses biblioitems.marcxml field.
269                                 <a href="/cgi-bin/koha/svc/convert_report?report_id=[% savedreport.id | uri %]" data-report_id="[% savedreport.id | html %]" class="update_sql btn btn-default btn-xs" title="Update SQL"><i class="fa fa-eye"></i> Update SQL</a>
270                             [% END %]
271                         </td>
272                         <td>
273                             <div class="dropup">
274                                 <div class="btn-group">
275                                     [%# There should be no space between these two buttons, it would render badly %]
276                                     <a class="btn btn-default btn-xs" role="button"
277                                        href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&amp;phase=Run%20this%20report"><i
278                                        class="fa fa-play"></i> Run</a><a
279                                        class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown"
280                                        href="#"><b class="caret"></b></a>
281                                     <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
282                                         <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&amp;phase=Show%20SQL"><i class="fa fa-search"></i> Show</a></li>
283                                         [% IF ( CAN_user_reports_create_reports ) %]
284                                             <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&amp;phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a></li>
285                                             <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="fa fa-copy"></i> Duplicate</a></li>
286                                         [% END %]
287                                         [% IF (Koha.Preference('Mana') == 1) %]
288                                             <li><a class="ShareButton" data-toggle="modal" href="#mana_share_report" title="Share your report with Mana Knowledge Base"><i class="fa fa-share-alt"></i> Share</a></li>
289                                         [% END %]
290                                         <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
291                                         [% IF ( CAN_user_reports_delete_reports ) %]
292                                             <li><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&amp;phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a></li>
293                                         [% END %]
294                                     </ul>
295                                 </div>
296                             </div>
297                         </td>
298                     </tr>
299                 [% END %]
300             </tbody>
301         </table>
302 </div>
303         [% IF ( CAN_user_reports_delete_reports ) %]
304         <fieldset class="action">
305             <input type="submit" value="Delete selected" />
306         </fieldset>
307         [% END %]
308     </form>
309     </div>
310 </div>
311 [% ELSE %]<div class="dialog message">
312     [% IF (filter_set || filters.date || filters.author || filters.keyword) %]
313     <h4>No saved reports match your criteria. </h4>
314     [% IF ( CAN_user_reports_create_reports ) %]
315     <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
316     <input type="hidden" name="phase" value="Build new" />
317         <button type="submit" class="new"><i class="fa fa-plus"></i> New guided report</button>
318     </form>
319
320     <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
321         <input type="hidden" name="phase" value="Create report from SQL" />
322         <button type="submit" class="new"><i class="fa fa-plus"></i> New SQL report</button>
323     </form>
324
325     <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
326     <input type="hidden" name="phase" value="Use saved" />
327     <input type="hidden" name="filter_set" value="1" />
328     <input type="hidden" name="filter_keyword" value="" />
329         <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> Cancel filter</button>
330     </form>
331
332     [% END %]
333     [% ELSE %]
334     <h4>There are no saved reports. </h4>
335     [% IF ( CAN_user_reports_create_reports ) %]
336         <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a new report?</a>
337     [% END %]
338     [% END %]
339     </div>
340 [% END %]
341 [% END %]
342
343 <div id="mana_share_report" class="modal fade" tabindex="-1" role="dialog" arialabelledby="mana_share_modal_label" style="display: none;">
344     <div class="modal-dialog">
345         <div class="modal-content">
346             <div class="modal-header">
347                 <h3 id="mana_share_modal_label">Share with Mana</h3>
348             </div>
349             <div class="modal-body">
350                 [% IF (mana_id) %]
351                     <div class="alert">
352                         <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p>
353                     </div>
354                 [% END %]
355                 <div id="note-error" class="alert alert-danger" role="alert">
356                     Please enter a report name and descriptive note before sharing (minimum 20 characters)
357                 </div>
358                 <div class="shared_infos rows">
359                     <li><span class="label">Id: </span><div id="shared_id"></div></li>
360                     <li><span class="label">Name: </span><div id="shared_name"></div></li>
361                     <li><span class="label">SQL: </span><div id="shared_sql"></div></li>
362                     <li><span class="label">Group: </span><div id="shared_group"></div></li>
363                     <li><span class="label">Type: </span><div id="shared_type"></div></li>
364                     <li><span class="label">Notes: </span><div id="shared_notes"></div></li>
365                 </div>
366                 <div class="rows">
367                     <form method="post" id="mana_share_form" action="/cgi-bin/koha/reports/guided_reports.pl" class="validated" >
368                         <input type="hidden" name="phase" value="Share">
369
370                         [% IF (languages_loop) %]
371                             <fieldset class="shared_infos">
372                                 <label for="mana_language">Language:</label>
373                                 <select id="mana_language" name="mana_language">
374                                     [% FOREACH languages_loo IN languages_loop %]
375                                         [% IF ( languages_loo.group_enabled ) %]
376                                             [% IF ( languages_loo.plural ) %]
377                                                 [% FOREACH sublanguages_loo IN languages_loo.sublanguages_loop %]
378                                                     [% IF ( sublanguages_loo.enabled ) %]
379                                                         [% IF ( sublanguages_loo.sublanguage_current ) %]
380                                                             <option value="[% languages_loo.rfc4646_subtag | html %]" selected>
381                                                                 [% sublanguages_loo.native_description | html %]
382                                                                 [% sublanguages_loo.script_description | html %]
383                                                                 [% sublanguages_loo.region_description | html %]
384
385                                                                 [% sublanguages_loo.variant_description | html %]
386                                                                 ([% sublanguages_loo.rfc4646_subtag | html %])
387                                                             </option>
388                                                         [% ELSE %]
389                                                             <option value="[% languages_loo.rfc4646_subtag | html %]">
390                                                                 [% sublanguages_loo.native_description | html %]
391                                                                 [% sublanguages_loo.script_description | html %]
392                                                                 [% sublanguages_loo.region_description | html %]
393                                                                 [% sublanguages_loo.variant_description | html %]
394                                                                 ([% sublanguages_loo.rfc4646_subtag | html %])
395                                                             </option>
396                                                         [% END %]
397                                                     [% END %]
398                                                 [% END %]
399                                             [% ELSE %]
400                                                 [% IF ( languages_loo.group_enabled ) %]
401                                                     [% IF ( languages_loo.current ) %]
402                                                         <option value="[% languages_loo.rfc4646_subtag | html %]" selected>
403                                                             [% IF ( languages_loo.native_description ) %]
404                                                                 [% languages_loo.native_description | html %]
405                                                             [% ELSE %]
406                                                                 [% languages_loo.rfc4646_subtag | html %]
407                                                             [% END %]
408                                                         </option>
409                                                     [% ELSE %]
410                                                         <option value="[% languages_loo.rfc4646_subtag | html %]">
411                                                             [% IF ( languages_loo.native_description ) %]
412                                                                 [% languages_loo.native_description | html %]
413                                                             [% ELSE %]
414                                                                 [% languages_loo.rfc4646_subtag | html %]
415                                                             [% END %]
416                                                         </option>
417                                                     [% END %]
418                                                 [% END %]
419                                             [% END %]
420                                         [% END %]
421                                     [% END %]
422                                 </select>
423                             </fieldset>
424                         [% ELSE %]
425                             <input type="hidden" name="mana_language" value="[% lang | html %]">
426                         [% END %]
427                         <input type="hidden" id="reportid" name="reportid"/>
428                     </form>
429                 </div>
430             </div>
431             <div class="modal-footer">
432                 <button class="btn" id="ManaCloseButton" data-dismiss="modal" aria-hidden="true">Close</button>
433                 [% IF one_language_enabled==0 %]
434                     <button id="ManaShareButton" type="submit" form="mana_share_form" class="btn btn-primary shared_infos">Share</button>
435                 [% ELSE %]
436                     <div id="ManaShareButton" class="btn-group"><a class="btn btn-primary shared_infos">Share</a></div>
437                 [% END %]
438             </div>
439         </div>
440     </div>
441 </div>
442
443
444 [% IF ( build1 ) %]
445 [% IF ( cache_error) %]
446 <div class="dialog alert">
447 <b> Please choose a cache_expiry less than 30 days </b>
448 </div>
449 [% END %]
450 <h1>Build a report</h1>
451 <form action="/cgi-bin/koha/reports/guided_reports.pl">
452 <fieldset class="rows">
453 <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and choose report visibility </legend>
454 <ol>
455   <li>
456     <label for="area">Choose: </label>
457       <select name="area" id="area">
458     [%- FOREACH area IN areas -%]
459       <option value="[% area | html %]">[%- PROCESS area_name area=area -%]</option>
460     [%- END -%]
461       </select>
462   </li>
463 [% IF (public) %]
464   <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>
465 [% ELSE %]
466   <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>
467 [% END %]
468 [% IF (usecache) %] <li>
469 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
470 <select id="cache_expiry_units" name="cache_expiry_units">
471 <option value="seconds">Seconds (default)</option>
472 <option value="minutes">Minutes</option>
473 <option value="hours">Hours</option>
474 <option value="days">Days</option>
475 </select>
476 </li>[% END %]
477 </ol>
478 </fieldset>
479 <fieldset class="action">
480 <input type="hidden" name="phase" value="Report on this Area" />
481 <input type="submit" name="submit" value="Next &gt;&gt;" />
482
483 </fieldset>
484 </form>
485 [% END %]
486
487
488 [% IF ( build2 ) %]
489 <h1>Build a report</h1>
490 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
491 <input type="hidden" name="area" value="[% area | html %]" />
492 <input type="hidden" name="public" value="[% public | html %]" />
493 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
494 <fieldset class="rows"><legend>Step 2 of 6: Pick a report type</legend>
495 <ol><li><label for="types">Choose: </label>
496     <select id="types" name="types">
497         <option value="1">Tabular</option>
498         <option value="2" disabled="disabled">Summary</option>
499         <option value="3" disabled="disabled">Matrix</option>
500     </select>
501 </li></ol></fieldset>
502
503 <fieldset class="action">
504     <input type="hidden" name="phase" value="Choose this type" />
505     <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
506     <input type="submit" name="submit" value="Next &gt;&gt;" />
507 </fieldset>
508 </form>
509
510 [% END %]
511
512 [% IF ( build3 ) %]
513 <h1>Build a report</h1>
514 <h3>Step 3 of 6: Select columns for display</h3>
515 <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>
516
517 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
518     <input type="hidden" name="area" value="[% area | html %]" />
519     <input type="hidden" name="type" value="[% type | html %]" />
520     <input type="hidden" name="public" value="[% public | html %]" />
521     <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
522     <fieldset>
523 <div class="row">
524 <div class="col-sm-6">
525     <div style="float: left;"><select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
526 [% FOREACH column IN columns %]
527 [% IF ( column.table ) %]
528
529 [% IF ( loop.first ) %]
530 [% ELSE %]
531 </optgroup>
532 [% END %]
533
534 <optgroup label="[% column.table | html %]">
535 [% ELSE %]
536 <option value="[% column.name | html %]">
537 [% IF ( column.description ) %][% column.description | html %] &nbsp; / &nbsp; [% column.name | html %]
538 [% ELSE %]
539 [% column.name | html %]
540 [% END %]
541 </option>
542 [% END %]
543 [% END %]
544 </optgroup>
545 </select></div>
546 <div style="width: 6.3em; float: right; margin-top: 100px"><input type="button" name="Add" value="Add" class="button" style="width:6em;" id="addColumn" /><br />
547 <input type="button" name="delete" value="&lt;&lt; Delete" class="button" style="width: 6em; margin: 1em 0;" id="delColumn" /></div>
548 </div>
549
550 <div class="col-sm-6">
551 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;"></select>
552 </div>
553 </div>
554 </fieldset>
555 <fieldset class="action">
556     <input type="hidden" name="phase" value="Choose these columns" />
557     <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
558     <input type="submit" name="submit" value="Next &gt;&gt;" />
559 </fieldset>
560 </form>
561
562 [% END %]
563
564 [% IF ( build4 ) %]
565 <h1>Build a report</h1>
566 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
567     <input type="hidden" name="area" value="[% area | html %]" />
568     <input type="hidden" name="type" value="[% type | html %]" />
569     <input type="hidden" name="column" value="[% column | html %]" />
570     <input type="hidden" name="public" value="[% public | html %]" />
571     <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
572     <fieldset><legend>Step 4 of 6: Select criteria to limit on</legend>
573     <table>
574         [% FOREACH criteri IN criteria %]
575         <tr>
576         <td>
577             <input type="checkbox" name="criteria_column" id="[% criteri.name | html %]" value="[% criteri.name | html %]" /> 
578             <label for="[% criteri.name | html %]">[% criteri.description | html %] </label>
579         </td>
580         [% IF ( criteri.date ) %]
581         <td>
582             <input type="text" size="10" id="[% criteri.name | html %]_value" name="[% criteri.name | html %]_value" value="" class="datepicker" />
583                 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
584         </td>
585         </tr>
586         [% ELSE %]
587         [% IF ( criteri.textrange ) %]
588             <td>from
589             <input type="text" size="10" id="[% criteri.from | html %]_value" name="[% criteri.from | html %]_value" value="" /> to 
590             <input type="text" size="10" id="[% criteri.to | html %]_value" name="[% criteri.to | html %]_value" value="" />
591             </td>
592             </tr>
593         [% ELSE %]
594             [% IF ( criteri.daterange ) %]
595             <td>from 
596             <input type="text" size="10" id="from_[% criteri.name | html %]_value" name="from_[% criteri.name | html %]_value" value="" class="datepickerfrom" />
597             to
598             <input type="text" size="10" id="to_[% criteri.name | html %]_value" name="to_[% criteri.name | html %]_value" value="" class="datepickerto" />
599                         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
600             </td>
601         </tr>
602             [% ELSE %]
603             <td>
604                 <select name="[% criteri.name | html %]_value">
605                 [% FOREACH value IN criteri.values %]
606                 <option value="[% value.availablevalues | html %]">[% IF ( value.default ) %]Default[% ELSE %][% value.display_value | html %][% END %]</option>
607                 [% END %]
608                 </select>
609             </td>
610             </tr>
611             [% END %]
612         [% END %]
613         [% END %]
614     [% END %]
615     </table>
616     </fieldset>
617
618 [% IF ( definitions ) %]
619 <fieldset><legend>Dictionary definitions</legend>
620 <table>
621 [% FOREACH definition IN definitions %]
622     <tr><td><input type="checkbox" name="definition" value="[% definition.id | html %]" /> [% definition.name | html %]</td></tr>
623 [% END %]
624 </table>
625 </fieldset>
626 [% END %]
627
628 <fieldset class="action"><input type="hidden" name="phase" value="Choose these criteria" />
629     <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
630     <input type="submit" name="submit" value="Next &gt;&gt;" /> </fieldset>
631 </form>
632 [% END %]
633
634
635 [% IF ( build5 ) %]
636 <h1>Build a report</h1>
637 <h3>Step 5 of 6: Pick which columns to total</h3>
638 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
639 <input type="hidden" name="area" value="[% area | html %]" />
640 <input type="hidden" name="type" value="[% type | html %]" />
641 <input type="hidden" name="column" value="[% column | html %]" />
642 <input type="hidden" name="definition" value="[% definition | html %]" />
643 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
644 <input type="hidden" name="public" value="[% public | html %]" />
645 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
646 <fieldset><table>
647 [% FOREACH total_b IN total_by %]
648 <tr><td><input type="checkbox" name="total_by" id="[% total_b.name | html %]" value="[% total_b.name | html %]" /> <label for="[% total_b.name | html %]">[% total_b.name | html %]</label></td>
649 <td><select name="[% total_b.name | html %]_tvalue">
650
651 [% FOREACH selec IN total_b.select %]
652 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
653 [% END %]
654 </select>
655
656 </td></tr>
657 [% END %]
658 </table></fieldset>
659
660 <fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
661     <input type="button" name="back" value="&lt;&lt; Back" class="goback" />
662     <input type="submit" name="submit" value="Next &gt;&gt;" /></fieldset>
663 </form>
664 [% END %]
665
666
667 [% IF ( build6 ) %]
668 <h1>Build a report</h1>
669 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
670 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
671 <input type="hidden" name="area" value="[% area | html %]" />
672 <input type="hidden" name="type" value="[% type | html %]" />
673 <input type="hidden" name="column" value="[% column | html %]" />
674 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
675 <input type="hidden" name="definition" value="[% definition | html %]" />
676 <input type="hidden" name="totals" value="[% totals | html %]" />
677 <input type="hidden" name="public" value="[% public | html %]" />
678 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
679 <fieldset><table>[% FOREACH order_b IN order_by %]
680 <tr><td><input type="checkbox" id="[% order_b.name | html %]" name="order_by" value="[% order_b.name | html %]" /> <label for="[% order_b.name | html %]">[% order_b.name | html %]</label></td><td>
681 <select name="[% order_b.name | html %]_ovalue">
682
683 [% FOREACH selec IN order_b.select %]
684 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
685 [% END %]
686 </select>
687 </td></tr>
688
689 [% END %]
690 </table></fieldset>
691
692 <fieldset class="action">
693 <input type="hidden" name="phase" value="Build report" />
694 <input type="submit" name="submit" value="Finish" /></fieldset>
695 </form>
696 [% END %]
697
698
699 [% IF ( showreport ) %]
700 <h1>Confirm custom report</h1>
701 <p>Your report will be generated with the following SQL statement.</p>
702 <p> 
703 [% sql | html %]
704 </p>
705
706 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
707 <input type="hidden" name="sql" value="[% sql | html %]" />
708 <input type="hidden" name="type" value="[% type | html %]" />
709 <input type="hidden" name="public" value="[% public | html %]" />
710 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
711 <p>You will need to save the report before you can execute it</p>
712 <fieldset class="action"><input type="hidden" name="phase" value="Save" />  
713 <input type="submit" name="submit" value="Save" />  </fieldset>
714 </form>
715 [% END %]
716
717 [% IF ( save ) %]
718 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" class="validated">
719 <input type="hidden" name="sql" value="[% sql | html %]" />
720 <input type="hidden" name="type" value="[% type | html %]" />
721 <input type="hidden" name="area" value="[% area | html %]" />
722 <input type="hidden" name="public" value="[% public | html %]" />
723 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
724 <fieldset class="rows">
725 <legend>Save your custom report</legend>
726 <ol>
727     <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>
728     [% PROCESS group_and_subgroup_selection %]
729     <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li>
730 </ol></fieldset>
731 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
732 <input type="submit" name="submit" value="Save report" /></fieldset>
733 </form>
734 [% END %]
735
736 [% IF ( warn_authval_problem ) %]
737     <div class="dialog alert">
738         <h3>Errors found when processing parameters for report: [% name | html %]</h3>
739         [% FOREACH problematic_authval IN problematic_authvals %]
740             <p>
741             <strong>[% problematic_authval.name | html %]:</strong> The authorized value category (<strong>[% problematic_authval.authval | html %]</strong>)
742                 you selected does not exist.
743             </p>
744         [% END %]
745         <!-- Save Anyway Form -->
746         <form action='/cgi-bin/koha/reports/guided_reports.pl'>
747         <!--Every parameter the user issued is provided as a hidden field for recovery-->
748             <input type='hidden' name='id' value='[% id | html %]' />
749             <input type='hidden' name='sql' value='[% sql | html %]' />
750             <input type='hidden' name='reportname' value='[% reportname | html %]' />
751             <input type='hidden' name='group' value='[% group | html %]' />
752             <input type='hidden' name='subgroup' value='[% subgroup | html %]' />
753             <input type='hidden' name='notes' value='[% notes | html %]' />
754             <input type='hidden' name='cache_expiry' value='[% cache_expiry | html %]' />
755             <input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units | html %]' />
756             <input type='hidden' name='public' value='[% public | html %]' />
757         [% IF ( phase_update) %]
758             <input type='hidden' name='phase' value='Update SQL' />
759             <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
760         [% ELSIF ( phase_save) %]
761             <input type='hidden' name='area' value='[% area | html %]' />
762             <input type='hidden' name='phase' value='Save Report' />
763             <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
764         [% END %]
765         </form>
766         <!-- Go back to editing -->
767         <form action='/cgi-bin/koha/reports/guided_reports.pl'>
768             <button type="button" class="new goback"><i class="fa fa-fw fa-pencil"></i> Edit SQL</button>
769         </form>
770     </div>
771 [% END %]
772
773 [% IF ( enter_params ) %]
774     <form action='/cgi-bin/koha/reports/guided_reports.pl'>
775         <input type='hidden' name='reports' value="[% reports | html %]" />
776     [% IF ( auth_val_error ) %]
777         <input type='hidden' name='phase' value='Edit SQL' />
778         <div class="dialog alert">
779             <h3>Errors found when processing parameters for report: [% name | html %]</h3>
780             [% FOREACH auth_val_error IN auth_val_errors %]
781                 <p>
782                     <strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
783                     you selected does not exist.
784                 </p>
785             [% END %]
786         </div>
787         <fieldset class="action"><input type="submit" value="Edit SQL" /></fieldset>
788     [% ELSE %]
789         <input type='hidden' name='phase' value='Run this report' />
790         <h1>Enter parameters for report [% name | html %]:</h1>
791         [% IF ( notes ) %]<p>[% notes | html %]</p>[% END %]
792         <fieldset class="rows">
793             <ol>
794             [% FOREACH sql_param IN sql_params %]
795                 <input name="param_name" value="[% sql_param.name | html %]" type="hidden" />
796                 [% IF sql_param.input == 'date' %]
797                     <li>
798                     <label for="date_[% sql_param_entry | html %][% loop.count | html %]">[% sql_param.entry | html %]:</label> <input id="date_[% sql_param_entry | html %][% loop.count | html %]" type="text" value="" size="10" name="sql_params" class="datepicker" />
799                     </li>
800                 [% ELSIF ( sql_param.input == 'text' ) %]
801                     <li><label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label><input id="sql_params[% loop.count | html %]" type="text" name="sql_params" /></li>
802                 [% ELSE %]
803                     <li><label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
804                         <select name="[%- sql_param.input.name | html -%]" tabindex="1"  size="1" id="[%- sql_param.input.id | html -%]">
805                         [% FOREACH value IN sql_param.input.values %]
806                             <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
807                         [% END %]
808                         </select>
809                     </li>
810                 [% END %]
811             [% END %]
812             </ol>
813         </fieldset>
814         <fieldset class="action"><input type="submit" value="Run the report" /></fieldset>
815     [% END %]
816     </form>
817 [% END %]
818
819 [% IF ( execute ) %]
820 <h1>[% name | html %]</h1>
821 [% IF ( notes ) %]<p><span class="label">Notes:</span> [% notes | html %]</p>[% END %]
822 [% IF ( unlimited_total ) %]<p><span class="label">Total number of results:</span> [% unlimited_total | html %][% IF unlimited_total > limit %] ([% limit | html %] shown)[% END %].</p>[% END %]
823 <div id="sql_output" style="display:none;"><span class="label">Report SQL:</span><pre>[% sql | html %]</pre></div>
824
825 <div>
826     <a href="#" id="toggle_chart_settings_hid" class="toggle_chart_settings" style="display:none"><i class="fa fa-eye-slash"></i> Hide chart</a>
827     <a href="#" id="toggle_chart_settings_vis" class="toggle_chart_settings" style="display:none"><i class="fa fa fa-eye"></i> Show chart</a>
828 </div>
829 <div id="chart" class="clearfix"></div>
830
831 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
832     <input type="hidden" name="phase" value="Run this report"/>
833     <input type="hidden" name="reports" value="[% report_id | html %]"/>
834
835     [% FOREACH p IN sql_params %]
836         <input type="hidden" name="sql_params" value="[% p | html %]"/>
837     [% END %]
838     [% FOREACH n IN param_names %]
839         <input type="hidden" name="param_name" value="[% n | html %]"/>
840     [% END %]
841
842     <label for="limit">Rows per page: </label>
843     <select name="limit" id="limit">
844         [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
845         [% FOREACH l IN limits %]
846                 [% IF l == limit %]
847                     <option value="[% l | html %]" selected="selected">[% l | html %]</option>
848                 [% ELSE %]
849                     <option value="[% l | html %]">[% l | html %]</option>
850                 [% END %]
851         [% END %]
852     </select>
853 </form>
854
855 <div class="pages">[% pagination_bar | $raw %]</div>
856 [% UNLESS ( errors ) %]
857     <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="report_results">
858         <input type="hidden" name="op" value="show" />
859         <table>
860             <tr>
861                 [% FOREACH header_ro IN header_row %]
862                     [% IF header_ro.cell == 'itemnumber' %]
863                         <th>
864                             [% header_ro.cell | html %] <button type="submit" data-toggle="tooltip" title="Send visible items to batch modification" id="batchModify" class="btn btn-xs btn-default send_to_item_mod"><i class="fa fa-pencil"></i> Batch modify</button>
865                         </th>
866                     [% ELSE %]
867                         <th>[% header_ro.cell | html %]</th>
868                     [% END %]
869                 [% END %]
870             </tr>
871             [% FOREACH result IN results %]
872                 <tr>
873                     [% FOREACH cells IN result.cells %]
874                         [% place = loop.index %]
875                         [% IF header_row.$place.cell == 'itemnumber' %]
876                             <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
877                         [% END %]
878                         <td>[% cells.cell | $raw %]</td>
879                     [% END %]
880                 </tr>
881             [% END %]
882         </table>
883     </form>
884
885 [% END %]
886
887 [% INCLUDE 'chart.inc' %]
888
889 [% END %]
890
891 [% IF ( create ) %]
892 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" class="validated">
893 <fieldset class="rows">
894 <legend>Create report from SQL</legend>
895 <ol>
896     <li><label for="reportname" class="required">Report name:</label>
897         [% IF ( reportname ) %]<input type="text" class="required" required="required" id="reportname" name="reportname" value="[% reportname | html %]" size="50"/>
898         [% ELSE %]<input type="text" class="required" required="required" id="reportname" name="reportname" size="50" />[% END %] <span class="required">Required</span>
899     </li>
900     [% PROCESS group_and_subgroup_selection %]
901
902 [% IF (public) %]
903   <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>
904 [% ELSE %]
905   <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>
906 [% END %]
907 [% IF (usecache) %] <li>
908 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
909 <select id="cache_expiry_units" name="cache_expiry_units">
910 <option value="seconds" selected="selected">Seconds (default)</option>
911 <option value="minutes">Minutes</option>
912 <option value="hours">Hours</option>
913 <option value="days">Days</option>
914 </select>
915 </li>[% END %]
916     <li><label for="notes">Notes:</label> <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea></li>
917 </ol>
918 </fieldset>
919 <fieldset class="rows">
920 <legend>SQL:</legend>
921 <div style="margin:1em;">
922 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea> <span class="required">Required</span>
923 </div>
924 </fieldset>
925
926 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
927 <input type="submit" name="submit" value="Save report" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
928 </fieldset>
929 </form>
930 [% END %]
931
932 [% IF saved_results %]
933 <h1>Saved report results</h1>
934 <h2>[% name | html %]</h2>
935 <p>[% notes | html %]</p>
936 <table>
937 [% FOREACH rows IN saved_results %]
938 <tr>
939 [% FOREACH col IN rows %]
940 <td>[% col | html %]</td>
941 [% END %]
942 <tr>
943 [% END %]
944 </table>
945 [% END %]
946
947 [% IF ( showsql ) %]
948 <fieldset class="rows">
949     <legend>[% reportname | html %]</legend>
950     <ol>
951         [% IF ( notes ) %]<li><span class="label">Notes:</span> [% notes | html %]</li>[% ELSE %][% END %]
952         <li><textarea id="sql">[% sql | html %]</textarea></li>
953     </ol>
954 </fieldset>
955 [% END %]
956
957 [% IF ( save_successful ) %]
958 [% UNLESS ( errors ) %]
959 </br>
960 <div id="report_updated">
961     <div class="dialog message">
962         <p>Your report "[% reportname | html %]" has been saved</p>
963     </div>
964 </div>
965 [% END %]
966 [% END %]
967
968 [% IF ( editsql ) %]
969 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" class="validated">
970 <input type="hidden" name="phase" value="Update SQL" />
971 <input type="hidden" name="id" value="[% id | html %]"/>
972 <fieldset class="rows">
973 <legend>Edit SQL report</legend>
974 <ol>
975 <li><label for="reportname" class="required">Report name: </label><input type="text" id="reportname" name="reportname" value="[% reportname | html %]" size="50" class="required" required="required" /> <span class="required">Required</span></li>
976 [% PROCESS group_and_subgroup_selection %]
977 [% IF (public) %]
978   <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>
979 [% ELSE %]
980   <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>
981 [% END %]
982 [% IF (usecache) %] <li>
983 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
984 <select id="cache_expiry_units" name="cache_expiry_units">
985 <option value="seconds">Seconds (default)</option>
986 <option value="minutes">Minutes</option>
987 <option value="hours">Hours</option>
988 <option value="days">Days</option>
989 </select>
990 </li>[% END %]
991 <li><label for="notes">Notes:</label><textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea></li>
992 </ol>
993 </fieldset>
994
995 <fieldset class="rows">
996     <legend>SQL:</legend>
997     <div style="margin:1em;">
998         <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea> <span class="required">Required</span>
999     </div>
1000 </fieldset>
1001
1002 <fieldset class="action">
1003 <input type="submit" name="submit" value="Update SQL" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1004 </fieldset>
1005 </form>
1006
1007
1008 [% END %]
1009
1010 [% IF ( errors ) %]
1011 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
1012 <div class="dialog alert">
1013 <b>The following error was encountered:</b><br />
1014 [% FOREACH error IN errors %]
1015     [% IF ( error.sqlerr ) %]This report contains the SQL keyword <b>[% error.sqlerr | html %]</b>.
1016     <br />Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.
1017     <br />Please return to the &quot;Saved Reports&quot; screen and delete this report or retry creating a new one.
1018     [% ELSIF ( error.queryerr ) %]The database returned the following error: <br />[% error.queryerr | html %]<br />Please check the log for further details.
1019     [% ELSIF ( error.cache_expiry ) %]Please select a cache expiry less than 30 days.
1020     [% ELSE %]
1021     [% END %]
1022     <div id="onerror_actions">
1023         <a href="#" class="button goback">Return to previous page</a>
1024     </div>
1025 [% END %]
1026 </div>
1027 <fieldset class="action"><input type="hidden" name="phase" value="Use saved" />
1028 <input type="submit" name="submit" value="Saved reports" /></fieldset>
1029 </form>
1030 [% END %]
1031
1032             </main>
1033         </div> <!-- /.col-sm-10.col-sm-push-2 -->
1034
1035         <div class="col-sm-2 col-sm-pull-10">
1036             <aside>
1037
1038
1039 [% IF ( saved1 ) %]
1040 <div id="saved-reports-filter">
1041 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
1042   <input type="hidden" name="phase" value="Use saved" />
1043   <input type="hidden" name="filter_set" value="1" />
1044   <fieldset class="brief">
1045   <h3>Filter</h3>
1046   <ol>
1047     <li><label for="filter_date">Date:</label> <input type="text" id="filter_date" name="filter_date" size="10" value="[% filters.date | html %]" class="datepicker" />
1048     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
1049
1050     </li>
1051     <li><label for="filter_author">Author:</label> <input type="text" id="filter_author" name="filter_author" value="[% filters.author | html %]" size="16" /></li>
1052     <li><label for="filter_keyword">Keyword:</label> <input type="text" id="filter_keyword" name="filter_keyword" value="[% filters.keyword | html %]" size="16" /></li>
1053   </ol>
1054   </fieldset>
1055   <fieldset class="action">
1056     <input type="submit" value="Apply filter" />
1057     <a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1">Clear</a>
1058   </fieldset>
1059 </form>
1060 </div>
1061 [% END %]
1062
1063
1064 [% INCLUDE 'guided-reports-view.inc' %]
1065             </aside>
1066         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1067      </div> <!-- /.row -->
1068
1069
1070 [% MACRO jsinclude BLOCK %]
1071     [% Asset.js("js/charts.js") | $raw %]
1072     [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
1073     [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
1074     [% INCLUDE 'calendar.inc' %]
1075     [% INCLUDE 'mana.inc' %]
1076     [% IF ( saved1 ) %]
1077         [% INCLUDE 'datatables.inc' %]
1078         [% INCLUDE 'columns_settings.inc' %]
1079     [% END %]
1080     [% Asset.js( "lib/codemirror/codemirror-compressed.js" ) | $raw %]
1081     [% Asset.js( "lib/codemirror/sql.min.js" ) | $raw %]
1082     <script>
1083
1084         function hide_bar_element() {
1085             $('#chart-column-horizontal').hide()
1086             $('.chart-column-group').each(function( index ) {
1087                 $( this ).hide();
1088             });
1089             $('.chart-column-line').each(function( index ) {
1090                 $( this ).hide()
1091             });
1092         }
1093
1094         function show_bar_element() {
1095             $('#chart-column-horizontal').show()
1096             $('.chart-column-group').each(function( index ) {
1097                 $( this ).show()
1098             });
1099             $('.chart-column-line').each(function( index ) {
1100                 $( this ).show()
1101             });
1102         }
1103
1104         function removeColumn(id) {
1105             $('#'+id).remove();
1106
1107             if ( $('.chart-column-conf').length == 1 ) {
1108                 $('.chart-column-delete').remove();
1109             }
1110         }
1111
1112         var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1113         var group_subgroups = {};
1114         [% FOREACH group IN groups_with_subgroups %]
1115             var gid = "[% group.id | html %]"
1116             group_subgroups[gid] = new Array();
1117             [% FOREACH subgroup IN group.subgroups %]
1118                 var sgid = "[% subgroup.id | html %]";
1119                 var sgname = "[% subgroup.name | html %]";
1120                 group_subgroups[gid].push([sgid, sgname]);
1121             [% END %]
1122         [% END %]
1123
1124         [% IF ( create || editsql || save ) %]
1125             var editor = CodeMirror.fromTextArea(sql, {
1126                 lineNumbers: true,
1127                 mode: "text/x-sql",
1128                 lineWrapping: true
1129             });
1130         [% END %]
1131
1132         [% IF ( showsql ) %]
1133             var editor = CodeMirror.fromTextArea(sql, {
1134                 lineNumbers: false,
1135                 mode: "text/x-sql",
1136                 lineWrapping: true,
1137                 readOnly: true
1138             });
1139         [% END %]
1140
1141         function load_group_subgroups () {
1142             var group = $("#group_select").val();
1143             var sg = $("#subgroup");
1144             $(sg).find('option[value!=""]').each(function() {
1145                 $(this).remove();
1146             });
1147             $(sg).hide();
1148             if (group) {
1149                 var select = $(sg).find('select')[0];
1150                 $.each( group_subgroups[group], function(index, value) {
1151                     $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1152                 } );
1153                 $("#subgroup, #subgroup *").show();
1154             }
1155         }
1156
1157         $(document).ready(function(){
1158
1159             hide_bar_element();
1160
1161             if ( $('.chart-column-conf').length == 1 ) {
1162                 $('.chart-column-delete').remove();
1163             }
1164
1165             $(".chart-column-delete").on('click', function(e){
1166                 e.preventDefault();
1167                 removeColumn('column_' + $(this).data('column'));
1168             })
1169
1170             $('#download-chart').click(function() {
1171                 var svg = '<svg>' + $('#chart svg').html() + '</svg>';
1172                 this.href = 'data:application/octet-stream;base64,' + btoa(svg);
1173                 this.setAttribute('download', 'chart.svg');
1174             });
1175
1176             $('#chart-type').change(function() {
1177                 if ($(this).val() == 'bar') {
1178                     show_bar_element();
1179                 }
1180                 else {
1181                     hide_bar_element();
1182                 }
1183             });
1184
1185             $('#download-chart').hide();
1186             var chart;
1187
1188             [% IF results && !errors %]
1189                 $('#draw-chart').click(function() {
1190
1191                     var x_elements = $('select[name="x"]').val();
1192                     var y_elements = [];
1193                     var groups = [];
1194                     var lines = [];
1195                     var options = {};
1196
1197                     headers = [% header_row.json | $raw %];
1198
1199                     var results;
1200                     if ($('input[name="chart-include-all"]').prop('checked')) {
1201                         results = [% allresults.json | $raw %]
1202                     }
1203                     else {
1204                         results = [% results.json | $raw %]
1205                     }
1206
1207                     if ($('input[name="chart-exclude-last"]').prop('checked')) {
1208                         results.splice(-1, 1);
1209                     }
1210
1211                     $('select[name="y"]').each(function( index ) {
1212                         y_elements.push( $(this).val() );
1213                     });
1214                     $('select[name="group"]').each(function( index ) {
1215                         groups.push( $(this).val() );
1216                     });
1217                     $('.column-line').each(function( index ) {
1218                         if ($(this).prop('checked')) {
1219                             lines.push( $(this).attr('name') );
1220                         }
1221                     });
1222
1223                     // Remove deleted columns from headers and results.
1224                     var deleted_indexes = [];
1225                     var kept_headers = [];
1226                     $.each(headers, function(index, value) {
1227                         if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) {
1228                             // This header is neither a x element nor in y elements. Don't need it.
1229                             deleted_indexes.push(index);
1230                         }
1231                         else {
1232                             kept_headers.push({cell: value.cell});
1233                         }
1234                     });
1235
1236                     // Remove coresponding cells.
1237                     var kept_results = [];
1238                     $.each(results, function(index, value) {
1239                         var line = {};
1240                         line['cells'] = [];
1241                         $.each(value.cells, function(i, val) {
1242                             if ($.inArray(i, deleted_indexes) === -1) {
1243                                 line['cells'].push({cell: val.cell});
1244                             }
1245                         });
1246                         kept_results.push(line);
1247                     });
1248
1249                     options.type = $('select[name="chart-type"]').val();
1250                     options.horizontal = $('input[name="column-horizontal"]').prop('checked');
1251                     options.lines = lines;
1252
1253                     chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options);
1254                     $("#download-chart,#toggle_chart_settings_hid,#chart").show();
1255                     $("#toggle_chart_settings_vis").hide();
1256                     $("#chartModal").modal("hide");
1257                 });
1258             [% END %]
1259             [% IF ( create ) %]
1260                 load_group_subgroups();
1261             [% END %]
1262
1263             $('[data-toggle="tooltip"]').tooltip();
1264             var columns_settings = [% ColumnsSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1265
1266             $('#limit').change(function() {
1267                 $('#limitselect').submit();
1268             });
1269
1270             $(document).click(function() {
1271                 $('#report_updated').hide();
1272             });
1273
1274             $(".goback").on("click",function(e){
1275                 e.preventDefault();
1276                 window.history.back();
1277             });
1278
1279             $(".mana_search_button").on("click",function(){
1280                 mana_search($("#mana_search_field").val());
1281             });
1282
1283             $(".ShareButton").on("click", function(){
1284                 $("#note-error").hide();
1285                 if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
1286                     $(".shared_infos").hide();
1287                     $("#note-error").show();
1288                 }
1289                 else{
1290                     $("#reportid").val($(this).closest("tr").find(".report_id").text());
1291                     $("#shared_id").html($(this).closest("tr").find(".report_id").text());
1292                     $("#shared_name").html($(this).closest("tr").find(".report_name").text());
1293                     $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
1294                     $("#shared_type").html($(this).closest("tr").find(".report_type").text());
1295                     $("#shared_group").html($(this).closest("tr").find(".report_group").text());
1296                     $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
1297                 }
1298             });
1299
1300             $("#ManaCloseButton").on("click", function() {
1301                 $(".shared_infos").show();
1302             });
1303
1304             $("#addColumn").on("click",function(){
1305                 addColumn();
1306             });
1307
1308             $("#delColumn").on("click",function(){
1309                 delColumn();
1310             });
1311
1312             [% IF (saved1) %]
1313                 var rtable = KohaTable("table_reports", {
1314                     'iDisplayLength': [% Koha.Preference('NumSavedReports') | html %],
1315                     'bAutoWidth': false,
1316                     'sPaginationType': 'four_button',
1317                     'aaSorting': [[ 1, "asc" ]],
1318                     'aoColumnDefs': [
1319                         { 'bSortable': false, 'bSearchable':false, 'aTargets': [0, -1] },
1320                         { 'bSearchable': false, 'aTargets': [3] },
1321                         { "aTargets": [ 1, 2 ], "sType": "natural"  },
1322                         { "sType": "title-string", "aTargets" : [ "title-string" ] },
1323                         { "visible": false, "aTargets" : [ "hidden" ] }
1324                     ],
1325                     'oLanguage': {
1326                         'sZeroRecords': _("No matching reports found")
1327                     },
1328                 }, columns_settings);
1329
1330                 var rtabs = $("#tabs").tabs();
1331                 rtabs.on("tabsactivate", function(e, ui) {
1332                     $("#subgroup_filter option").each(function() {
1333                         if($(this).val().length > 0) {
1334                             $(this).remove();
1335                         }
1336                     });
1337                     rtable.fnFilter('', 4);
1338                     rtable.fnFilter('', 5);
1339                     rtable.fnSetColumnVis(4, true);
1340                     rtable.fnSetColumnVis(5, true);
1341
1342                     var g_id = $(ui.newTab).children().attr('id');
1343                     var g_name = $(ui.newTab).text();
1344                     if ( g_name == _("All") ) {
1345                         g_id = "";
1346                         g_name = "";
1347                     }
1348
1349                     if (g_id && g_id.length > 0) {
1350                         rtable.fnFilter('^' + g_name + '$', 4, true, true, true, false);
1351                         rtable.fnSetColumnVis(4, false);
1352                         for(var i in group_subgroups[g_id]) {
1353                             $("#subgroup_filter").append(
1354                                 '<option value="' + group_subgroups[g_id][i][0] + '">'
1355                                 + group_subgroups[g_id][i][1] + '</option>'
1356                             );
1357                         }
1358                         $("#subgroup_filter_block").show();
1359                     } else {
1360                         $("#subgroup_filter_block").hide();
1361                     }
1362                 });
1363                 $("#subgroup_filter_block").hide();
1364
1365                 $("#subgroup_filter").change(function() {
1366                     var selected = $(this).find('option:selected');
1367                     var sg_id = $(selected).val();
1368                     var sg_name = $(selected).text();
1369                     if (sg_id.length > 0) {
1370                         rtable.fnFilter('^' + sg_name + '$', 5, true, true, true, false);
1371                         rtable.fnSetColumnVis(5, false);
1372                     } else {
1373                         rtable.fnFilter('', 5);
1374                         rtable.fnSetColumnVis(5, true);
1375                     }
1376                 });
1377
1378                 $("#reports_form").submit(function(){
1379                     var checkedItems = $("input[name=ids]:checked");
1380                     if ($(checkedItems).size() == 0) {
1381                         alert(_("You must select one or more reports to delete"));
1382                         return false;
1383                     }
1384                     $(checkedItems).parents('tr').addClass("warn");
1385                     if( confirm(_("Are you sure you want to delete the selected reports?")) ) {
1386                         return true;
1387                     } else {
1388                         $(checkedItems).parents('tr').removeClass("warn");
1389                         return false;
1390                     }
1391                 });
1392
1393                 $("body").on("click", ".update_sql", function(e){
1394                     e.preventDefault();
1395                     var ltitle = $(this).text();
1396                     var report_id = $(this).data("report_id");
1397                     var page = $(this).attr("href");
1398                     $("#update_sql .modal-body").load(page + " div", function(){
1399                         var diff1 = $("#col1 .show_sql").text();
1400                         var diff2 = $("#col2 .show_sql").text();
1401                         var diffs = diffString( escape(diff1), escape(diff2) );
1402                         $("#col1 .show_sql,#col2 .show_sql").html(diffs);
1403                     });
1404                     $('#update_sql').modal('show');
1405                     $("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?phase=Use saved&op=convert&report_id=" + report_id);
1406                 });
1407
1408                 $("#update_sql").on("hidden.bs.modal", function(){
1409                     $("#update_sql_label").html("");
1410                     $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1411                 });
1412             [% END %]
1413
1414             [% IF ( showsql ) %]
1415                 $("#sql").focus(function() {
1416                     $(this).select();
1417                 });
1418             [% END %]
1419
1420             $(".toggle_sql").click(function(){
1421                 $("#sql_output").toggle();
1422                 $("#toggle_sql_hid").toggle();
1423                 $("#toggle_sql_vis").toggle();
1424             });
1425
1426             $(".toggle_chart_settings").click(function(){
1427                 $("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
1428             });
1429
1430             $("#table_reports").delegate(".confirmdelete", 'click', function(){
1431                 $(this).parents('tr').attr("class","warn");
1432                 if(confirm(_("Are you sure you want to delete this saved report?"))){
1433                     return true;
1434                 } else {
1435                     $(this).parents('tr').attr("class","");
1436                     return false;
1437                 }
1438             });
1439
1440             [% IF (create || editsql || save) %]
1441                 $("#select_group").change(function() {
1442                     if($(this).prop('checked')) {
1443                         $("#group_input").prop('disabled', true);
1444                         $("#groupdesc_input").prop('disabled', true);
1445                         $("#group_select").prop('disabled', false);
1446                         if ($("#group_select").val().length > 0) {
1447                             $("#select_subgroup").prop('checked', true);
1448                             $("#select_subgroup").change();
1449                             $("#subgroup, #subgroup *").show();
1450                         } else {
1451                             $("#subgroup").hide();
1452                         }
1453                     }
1454                 });
1455                 $("#create_group").change(function() {
1456                     if($(this).prop('checked')) {
1457                         $("#group_input").prop('disabled', false);
1458                         $("#groupdesc_input").prop('disabled', false);
1459                         $("#group_select").prop('disabled', true);
1460                         $("#create_subgroup").prop('checked', true).change();
1461                         $("#subgroup_select").hide();
1462                         $("#subgroup input[type='radio']").hide();
1463                         $("#subgroup label[for]").hide();
1464                         $("#subgroup_input").show();
1465                         $("#subgroupdesc_input").show();
1466                         $("#subgroup").show();
1467                     }
1468                 });
1469                 $("#select_subgroup").change(function() {
1470                     if($(this).prop('checked')) {
1471                         $("#subgroup_select").prop('disabled', false);
1472                         $("#subgroup_input").prop('disabled', true);
1473                         $("#subgroupdesc_input").prop('disabled', true);
1474                     }
1475                 });
1476                 $("#create_subgroup").change(function() {
1477                     if($(this).prop('checked')) {
1478                         $("#subgroup_input").prop('disabled', false);
1479                         $("#subgroupdesc_input").prop('disabled', false);
1480                         $("#subgroup_select").prop('disabled', true);
1481                     }
1482                 });
1483                 $("#select_group").change();
1484                 $("#select_subgroup").change();
1485                 $("#group_select").on("change",function(){
1486                     load_group_subgroups();
1487                 });
1488             [% END %]
1489             $(".delete").on("click",function(){
1490                 return confirmDelete(MSG_CONFIRM_DELETE);
1491             });
1492
1493             $('div#ManaShareButton').click(function() {
1494                 $("#mana_share_form").submit();
1495             });
1496
1497             $("#mana_search_form").submit(function(e){
1498                 e.preventDefault();
1499             });
1500
1501             $("#column_submit").submit(function() {
1502                 if ($("#selectedColumns option").size() < 1) {
1503                     alert(_("No columns selected!"));
1504                     return false;
1505                 }
1506                 $("#selectedColumns option").attr("selected", "selected");  // Select everything still in #selectedColumns
1507                 return true;
1508             });
1509         });
1510
1511         function addColumn() {
1512             $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
1513         }
1514         function delColumn() {
1515             $("#selectedColumns option:selected").remove();
1516         }
1517     </script>
1518 [% END %]
1519
1520 [% INCLUDE 'intranet-bottom.inc' %]
1521
1522 [% BLOCK group_and_subgroup_selection %]
1523     <li id="group">
1524         <label>Report group:</label>
1525         <input type="radio" name="select_or_create_group"
1526             id="select_group" checked="checked" />
1527         <label for="select_group" style="float:none">Select</label>
1528         <select name="group" id="group_select">
1529             <option value="">(None)</option>
1530             [% FOREACH group IN groups_with_subgroups %]
1531                 [% IF (group.selected) %]
1532                     <option value="[% group.id | html %]" selected="selected">
1533                 [% ELSE %]
1534                     <option value="[% group.id | html %]">
1535                 [% END %]
1536                     [% group.name | html %]
1537                 </option>
1538             [% END %]
1539         </select>
1540         <input type="radio" name="select_or_create_group" id="create_group" />
1541         <label for="create_group" style="float:none">or create:</label>
1542         <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
1543         <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
1544     </li>
1545     <li id="subgroup">
1546         <label>Report subgroup:</label>
1547         <input type="radio" name="select_or_create_subgroup"
1548             id="select_subgroup" checked="checked" />
1549         <label for="select_subgroup" style="float:none">Select</label>
1550         <select name="subgroup" id="subgroup_select">
1551             <option value="">(None)</option>
1552             [% FOREACH group IN groups_with_subgroups %]
1553                 [% IF (group.selected) %]
1554                     [% FOREACH subgroup IN group.subgroups %]
1555                         [% IF (subgroup.selected) %]
1556                             <option value="[% subgroup.id | html %]" selected="selected">
1557                         [% ELSE %]
1558                             <option value="[% subgroup.id | html %]">
1559                         [% END %]
1560                             [% subgroup.name | html %]
1561                         </option>
1562                     [% END %]
1563                 [% END %]
1564             [% END %]
1565         </select>
1566         <input type="radio" name="select_or_create_subgroup"
1567             id="create_subgroup" />
1568         <label for="create_subgroup" style="float:none">or create</label>
1569         <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
1570         <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />
1571     </li>
1572 [% END %]