Bug 17047: add a dedicated page for Mana setup
[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 [% IF ( saved1 ) %]
44     [% Asset.css("css/reports.css") | $raw %]
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 [% INCLUDE 'chart.inc' %]
822 [% IF ( notes ) %]<p><span class="label">Notes:</span> [% notes | html %]</p>[% END %]
823 [% 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 %]
824 <div id="sql_output" style="display:none;"><span class="label">Report SQL:</span><pre>[% sql | html %]</pre></div>
825 </br>
826
827 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
828     <input type="hidden" name="phase" value="Run this report"/>
829     <input type="hidden" name="reports" value="[% report_id | html %]"/>
830
831     [% FOREACH p IN sql_params %]
832         <input type="hidden" name="sql_params" value="[% p | html %]"/>
833     [% END %]
834     [% FOREACH n IN param_names %]
835         <input type="hidden" name="param_name" value="[% n | html %]"/>
836     [% END %]
837
838     <label for="limit">Rows per page: </label>
839     <select name="limit" id="limit">
840         [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
841         [% FOREACH l IN limits %]
842                 [% IF l == limit %]
843                     <option value="[% l | html %]" selected="selected">[% l | html %]</option>
844                 [% ELSE %]
845                     <option value="[% l | html %]">[% l | html %]</option>
846                 [% END %]
847         [% END %]
848     </select>
849 </form>
850
851 <div class="pages">[% pagination_bar | $raw %]</div>
852 [% UNLESS ( errors ) %]
853     <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="report_results">
854         <input type="hidden" name="op" value="show" />
855         <table>
856             <tr>
857                 [% FOREACH header_ro IN header_row %]
858                     [% IF header_ro.cell == 'itemnumber' %]
859                         <th>
860                             [% header_ro.cell | html %] <button type="submit" data-toggle="tooltip" title="Send visible items to batch modification" class="btn btn-xs btn-default send_to_item_mod"><i class="fa fa-pencil"></i> Batch modify</button>
861                         </th>
862                     [% ELSE %]
863                         <th>[% header_ro.cell | html %]</th>
864                     [% END %]
865                 [% END %]
866             </tr>
867             [% FOREACH result IN results %]
868                 <tr>
869                     [% FOREACH cells IN result.cells %]
870                         [% place = loop.index %]
871                         [% IF header_row.$place.cell == 'itemnumber' %]
872                             <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
873                         [% END %]
874                         <td>[% cells.cell | $raw %]</td>
875                     [% END %]
876                 </tr>
877             [% END %]
878         </table>
879     </form>
880
881 [% END %]
882 [% END %]
883
884 [% IF ( create ) %]
885 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" class="validated">
886 <fieldset class="rows">
887 <legend>Create report from SQL</legend>
888 <ol>
889     <li><label for="reportname" class="required">Report name:</label>
890         [% IF ( reportname ) %]<input type="text" class="required" required="required" id="reportname" name="reportname" value="[% reportname | html %]" size="50"/>
891         [% ELSE %]<input type="text" class="required" required="required" id="reportname" name="reportname" size="50" />[% END %] <span class="required">Required</span>
892     </li>
893     [% PROCESS group_and_subgroup_selection %]
894
895 [% IF (public) %]
896   <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>
897 [% ELSE %]
898   <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>
899 [% END %]
900 [% IF (usecache) %] <li>
901 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
902 <select id="cache_expiry_units" name="cache_expiry_units">
903 <option value="seconds" selected="selected">Seconds (default)</option>
904 <option value="minutes">Minutes</option>
905 <option value="hours">Hours</option>
906 <option value="days">Days</option>
907 </select>
908 </li>[% END %]
909     <li><label for="notes">Notes:</label> <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea></li>
910 </ol>
911 </fieldset>
912 <fieldset class="rows">
913 <legend>SQL:</legend>
914 <div style="margin:1em;">
915 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea> <span class="required">Required</span>
916 </div>
917 </fieldset>
918
919 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
920 <input type="submit" name="submit" value="Save report" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
921 </fieldset>
922 </form>
923 [% END %]
924
925 [% IF saved_results %]
926 <h1>Saved report results</h1>
927 <h2>[% name | html %]</h2>
928 <p>[% notes | html %]</p>
929 <table>
930 [% FOREACH rows IN saved_results %]
931 <tr>
932 [% FOREACH col IN rows %]
933 <td>[% col | html %]</td>
934 [% END %]
935 <tr>
936 [% END %]
937 </table>
938 [% END %]
939
940 [% IF ( showsql ) %]
941 <fieldset class="rows">
942     <legend>[% reportname | html %]</legend>
943     <ol>
944         [% IF ( notes ) %]<li><span class="label">Notes:</span> [% notes | html %]</li>[% ELSE %][% END %]
945         <li><textarea id="sql">[% sql | html %]</textarea></li>
946     </ol>
947 </fieldset>
948 [% END %]
949
950 [% IF ( save_successful ) %]
951 [% UNLESS ( errors ) %]
952 </br>
953 <div id="report_updated">
954     <div class="dialog message">
955         <p>Your report "[% reportname | html %]" has been saved</p>
956     </div>
957 </div>
958 [% END %]
959 [% END %]
960
961 [% IF ( editsql ) %]
962 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" class="validated">
963 <input type="hidden" name="phase" value="Update SQL" />
964 <input type="hidden" name="id" value="[% id | html %]"/>
965 <fieldset class="rows">
966 <legend>Edit SQL report</legend>
967 <ol>
968 <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>
969 [% PROCESS group_and_subgroup_selection %]
970 [% IF (public) %]
971   <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>
972 [% ELSE %]
973   <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>
974 [% END %]
975 [% IF (usecache) %] <li>
976 <label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
977 <select id="cache_expiry_units" name="cache_expiry_units">
978 <option value="seconds">Seconds (default)</option>
979 <option value="minutes">Minutes</option>
980 <option value="hours">Hours</option>
981 <option value="days">Days</option>
982 </select>
983 </li>[% END %]
984 <li><label for="notes">Notes:</label><textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea></li>
985 </ol>
986 </fieldset>
987
988 <fieldset class="rows">
989     <legend>SQL:</legend>
990     <div style="margin:1em;">
991         <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea> <span class="required">Required</span>
992     </div>
993 </fieldset>
994
995 <fieldset class="action">
996 <input type="submit" name="submit" value="Update SQL" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
997 </fieldset>
998 </form>
999
1000
1001 [% END %]
1002
1003 [% IF ( errors ) %]
1004 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
1005 <div class="dialog alert">
1006 <b>The following error was encountered:</b><br />
1007 [% FOREACH error IN errors %]
1008     [% IF ( error.sqlerr ) %]This report contains the SQL keyword <b>[% error.sqlerr | html %]</b>.
1009     <br />Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.
1010     <br />Please return to the &quot;Saved Reports&quot; screen and delete this report or retry creating a new one.
1011     [% ELSIF ( error.queryerr ) %]The database returned the following error: <br />[% error.queryerr | html %]<br />Please check the log for further details.
1012     [% ELSIF ( error.cache_expiry ) %]Please select a cache expiry less than 30 days.
1013     [% ELSE %]
1014     [% END %]
1015     <div id="onerror_actions">
1016         <a href="#" class="button goback">Return to previous page</a>
1017     </div>
1018 [% END %]
1019 </div>
1020 <fieldset class="action"><input type="hidden" name="phase" value="Use saved" />
1021 <input type="submit" name="submit" value="Saved reports" /></fieldset>
1022 </form>
1023 [% END %]
1024
1025             </main>
1026         </div> <!-- /.col-sm-10.col-sm-push-2 -->
1027
1028         <div class="col-sm-2 col-sm-pull-10">
1029             <aside>
1030
1031
1032 [% IF ( saved1 ) %]
1033 <div id="saved-reports-filter">
1034 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
1035   <input type="hidden" name="phase" value="Use saved" />
1036   <input type="hidden" name="filter_set" value="1" />
1037   <fieldset class="brief">
1038   <h3>Filter</h3>
1039   <ol>
1040     <li><label for="filter_date">Date:</label> <input type="text" id="filter_date" name="filter_date" size="10" value="[% filters.date | html %]" class="datepicker" />
1041     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
1042
1043     </li>
1044     <li><label for="filter_author">Author:</label> <input type="text" id="filter_author" name="filter_author" value="[% filters.author | html %]" size="16" /></li>
1045     <li><label for="filter_keyword">Keyword:</label> <input type="text" id="filter_keyword" name="filter_keyword" value="[% filters.keyword | html %]" size="16" /></li>
1046   </ol>
1047   </fieldset>
1048   <fieldset class="action">
1049     <input type="submit" value="Apply filter" />
1050     <a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1">Clear</a>
1051   </fieldset>
1052 </form>
1053 </div>
1054 [% END %]
1055
1056
1057 [% INCLUDE 'guided-reports-view.inc' %]
1058             </aside>
1059         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1060      </div> <!-- /.row -->
1061
1062
1063 [% MACRO jsinclude BLOCK %]
1064     [% Asset.js("js/charts.js") | $raw %]
1065     [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
1066     [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
1067     [% INCLUDE 'calendar.inc' %]
1068     [% INCLUDE 'mana.inc' %]
1069     [% IF ( saved1 ) %]
1070         [% INCLUDE 'datatables.inc' %]
1071         [% INCLUDE 'columns_settings.inc' %]
1072     [% END %]
1073     [% Asset.js( "lib/codemirror/codemirror-compressed.js" ) | $raw %]
1074     [% Asset.js( "lib/codemirror/sql.min.js" ) | $raw %]
1075     <script>
1076
1077         function hide_bar_element() {
1078             $('#chart-column-horizontal').hide()
1079             $('.chart-column-group').each(function( index ) {
1080                 $( this ).hide();
1081             });
1082             $('.chart-column-line').each(function( index ) {
1083                 $( this ).hide()
1084             });
1085         }
1086
1087         function show_bar_element() {
1088             $('#chart-column-horizontal').show()
1089             $('.chart-column-group').each(function( index ) {
1090                 $( this ).show()
1091             });
1092             $('.chart-column-line').each(function( index ) {
1093                 $( this ).show()
1094             });
1095         }
1096
1097         function removeColumn(id) {
1098             $('#'+id).remove();
1099
1100             if ( $('.chart-column-conf').length == 1 ) {
1101                 $('.chart-column-delete').remove();
1102             }
1103         }
1104
1105         var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1106         var group_subgroups = {};
1107         [% FOREACH group IN groups_with_subgroups %]
1108             var gid = "[% group.id | html %]"
1109             group_subgroups[gid] = new Array();
1110             [% FOREACH subgroup IN group.subgroups %]
1111                 var sgid = "[% subgroup.id | html %]";
1112                 var sgname = "[% subgroup.name | html %]";
1113                 group_subgroups[gid].push([sgid, sgname]);
1114             [% END %]
1115         [% END %]
1116
1117         [% IF ( create || editsql || save ) %]
1118             var editor = CodeMirror.fromTextArea(sql, {
1119                 lineNumbers: true,
1120                 mode: "text/x-sql",
1121                 lineWrapping: true
1122             });
1123         [% END %]
1124
1125         [% IF ( showsql ) %]
1126             var editor = CodeMirror.fromTextArea(sql, {
1127                 lineNumbers: false,
1128                 mode: "text/x-sql",
1129                 lineWrapping: true,
1130                 readOnly: true
1131             });
1132         [% END %]
1133
1134         function load_group_subgroups () {
1135             var group = $("#group_select").val();
1136             var sg = $("#subgroup");
1137             $(sg).find('option[value!=""]').each(function() {
1138                 $(this).remove();
1139             });
1140             $(sg).hide();
1141             if (group) {
1142                 var select = $(sg).find('select')[0];
1143                 $.each( group_subgroups[group], function(index, value) {
1144                     $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1145                 } );
1146                 $("#subgroup, #subgroup *").show();
1147             }
1148         }
1149
1150         $(document).ready(function(){
1151
1152             hide_bar_element();
1153
1154             if ( $('.chart-column-conf').length == 1 ) {
1155                 $('.chart-column-delete').remove();
1156             }
1157
1158             $(".chart-column-delete").on('click', function(e){
1159                 e.preventDefault();
1160                 removeColumn('column_' + $(this).data('column'));
1161             })
1162
1163             $('#download-chart').click(function() {
1164                 var svg = '<svg>' + $('#chart svg').html() + '</svg>';
1165                 this.href = 'data:application/octet-stream;base64,' + btoa(svg);
1166                 this.setAttribute('download', 'chart.svg');
1167             });
1168
1169             $('#chart-type').change(function() {
1170                 if ($(this).val() == 'bar') {
1171                     show_bar_element();
1172                 }
1173                 else {
1174                     hide_bar_element();
1175                 }
1176             });
1177
1178             $('#download-chart').hide();
1179             var chart;
1180
1181             [% IF results && !errors %]
1182                 $('#draw-chart').click(function() {
1183
1184                     var btn_text = $("#draw-chart").html();
1185                     $("#draw-chart").html(_("Loading..."));
1186
1187                     var x_elements = $('select[name="x"]').val();
1188                     var y_elements = [];
1189                     var groups = [];
1190                     var lines = [];
1191                     var options = {};
1192
1193                     headers = [% header_row.json | $raw %];
1194
1195                     var results;
1196                     if ($('input[name="chart-include-all"]').prop('checked')) {
1197                         results = [% allresults.json | $raw %]
1198                     }
1199                     else {
1200                         results = [% results.json | $raw %]
1201                     }
1202
1203                     if ($('input[name="chart-exclude-last"]').prop('checked')) {
1204                         results.splice(-1, 1);
1205                     }
1206
1207                     $('select[name="y"]').each(function( index ) {
1208                         y_elements.push( $(this).val() );
1209                     });
1210                     $('select[name="group"]').each(function( index ) {
1211                         groups.push( $(this).val() );
1212                     });
1213                     $('.column-line').each(function( index ) {
1214                         if ($(this).prop('checked')) {
1215                             lines.push( $(this).attr('name') );
1216                         }
1217                     });
1218
1219                     // Remove deleted columns from headers and results.
1220                     var deleted_indexes = [];
1221                     var kept_headers = [];
1222                     $.each(headers, function(index, value) {
1223                         if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) {
1224                             // This header is neither a x element nor in y elements. Don't need it.
1225                             deleted_indexes.push(index);
1226                         }
1227                         else {
1228                             kept_headers.push({cell: value.cell});
1229                         }
1230                     });
1231
1232                     // Remove coresponding cells.
1233                     var kept_results = [];
1234                     $.each(results, function(index, value) {
1235                         var line = {};
1236                         line['cells'] = [];
1237                         $.each(value.cells, function(i, val) {
1238                             if ($.inArray(i, deleted_indexes) === -1) {
1239                                 line['cells'].push({cell: val.cell});
1240                             }
1241                         });
1242                         kept_results.push(line);
1243                     });
1244
1245                     options.type = $('select[name="chart-type"]').val();
1246                     options.horizontal = $('input[name="column-horizontal"]').prop('checked');
1247                     options.lines = lines;
1248
1249                     chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options);
1250                     $('#chart').prepend('<div style="font-size: 1rem; text-align: center;">' + "[% name | html %]" + '</div>');
1251                     $('#download-chart').show();
1252                     $("#draw-chart").html(_(btn_text));
1253                     $("html, body").animate({ scrollTop: $(document).height() }, "slow");
1254                 });
1255             [% END %]
1256             [% IF ( create ) %]
1257                 load_group_subgroups();
1258             [% END %]
1259
1260             $('[data-toggle="tooltip"]').tooltip();
1261             var columns_settings = [% ColumnsSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1262
1263             $('#limit').change(function() {
1264                 $('#limitselect').submit();
1265             });
1266
1267             $(document).click(function() {
1268                 $('#report_updated').hide();
1269             });
1270
1271             $(".goback").on("click",function(e){
1272                 e.preventDefault();
1273                 window.history.back();
1274             });
1275
1276             $(".mana_search_button").on("click",function(){
1277                 mana_search($("#mana_search_field").val());
1278             });
1279
1280             $(".ShareButton").on("click", function(){
1281                 $("#note-error").hide();
1282                 if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
1283                     $(".shared_infos").hide();
1284                     $("#note-error").show();
1285                 }
1286                 else{
1287                     $("#reportid").val($(this).closest("tr").find(".report_id").text());
1288                     $("#shared_id").html($(this).closest("tr").find(".report_id").text());
1289                     $("#shared_name").html($(this).closest("tr").find(".report_name").text());
1290                     $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
1291                     $("#shared_type").html($(this).closest("tr").find(".report_type").text());
1292                     $("#shared_group").html($(this).closest("tr").find(".report_group").text());
1293                     $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
1294                 }
1295             });
1296
1297             $("#ManaCloseButton").on("click", function() {
1298                 $(".shared_infos").show();
1299             });
1300
1301             $("#addColumn").on("click",function(){
1302                 addColumn();
1303             });
1304
1305             $("#delColumn").on("click",function(){
1306                 delColumn();
1307             });
1308
1309             [% IF (saved1) %]
1310                 var rtable = KohaTable("table_reports", {
1311                     'iDisplayLength': [% Koha.Preference('NumSavedReports') | html %],
1312                     'bAutoWidth': false,
1313                     'sPaginationType': 'four_button',
1314                     'aaSorting': [[ 1, "asc" ]],
1315                     'aoColumnDefs': [
1316                         { 'bSortable': false, 'bSearchable':false, 'aTargets': [0, -1] },
1317                         { 'bSearchable': false, 'aTargets': [3] },
1318                         { "aTargets": [ 1, 2 ], "sType": "natural"  },
1319                         { "sType": "title-string", "aTargets" : [ "title-string" ] },
1320                         { "visible": false, "aTargets" : [ "hidden" ] }
1321                     ],
1322                     'oLanguage': {
1323                         'sZeroRecords': _("No matching reports found")
1324                     },
1325                 }, columns_settings);
1326
1327                 var rtabs = $("#tabs").tabs();
1328                 rtabs.on("tabsactivate", function(e, ui) {
1329                     $("#subgroup_filter option").each(function() {
1330                         if($(this).val().length > 0) {
1331                             $(this).remove();
1332                         }
1333                     });
1334                     rtable.fnFilter('', 4);
1335                     rtable.fnFilter('', 5);
1336                     rtable.fnSetColumnVis(4, true);
1337                     rtable.fnSetColumnVis(5, true);
1338
1339                     var g_id = $(ui.newTab).children().attr('id');
1340                     var g_name = $(ui.newTab).text();
1341                     if ( g_name == _("All") ) {
1342                         g_id = "";
1343                         g_name = "";
1344                     }
1345
1346                     if (g_id && g_id.length > 0) {
1347                         rtable.fnFilter('^' + g_name + '$', 4, true, true, true, false);
1348                         rtable.fnSetColumnVis(4, false);
1349                         for(var i in group_subgroups[g_id]) {
1350                             $("#subgroup_filter").append(
1351                                 '<option value="' + group_subgroups[g_id][i][0] + '">'
1352                                 + group_subgroups[g_id][i][1] + '</option>'
1353                             );
1354                         }
1355                         $("#subgroup_filter_block").show();
1356                     } else {
1357                         $("#subgroup_filter_block").hide();
1358                     }
1359                 });
1360                 $("#subgroup_filter_block").hide();
1361
1362                 $("#subgroup_filter").change(function() {
1363                     var selected = $(this).find('option:selected');
1364                     var sg_id = $(selected).val();
1365                     var sg_name = $(selected).text();
1366                     if (sg_id.length > 0) {
1367                         rtable.fnFilter('^' + sg_name + '$', 5, true, true, true, false);
1368                         rtable.fnSetColumnVis(5, false);
1369                     } else {
1370                         rtable.fnFilter('', 5);
1371                         rtable.fnSetColumnVis(5, true);
1372                     }
1373                 });
1374
1375                 $("#reports_form").submit(function(){
1376                     var checkedItems = $("input[name=ids]:checked");
1377                     if ($(checkedItems).size() == 0) {
1378                         alert(_("You must select one or more reports to delete"));
1379                         return false;
1380                     }
1381                     $(checkedItems).parents('tr').addClass("warn");
1382                     if( confirm(_("Are you sure you want to delete the selected reports?")) ) {
1383                         return true;
1384                     } else {
1385                         $(checkedItems).parents('tr').removeClass("warn");
1386                         return false;
1387                     }
1388                 });
1389
1390                 $("body").on("click", ".update_sql", function(e){
1391                     e.preventDefault();
1392                     var ltitle = $(this).text();
1393                     var report_id = $(this).data("report_id");
1394                     var page = $(this).attr("href");
1395                     $("#update_sql .modal-body").load(page + " div", function(){
1396                         var diff1 = $("#col1 .show_sql").text();
1397                         var diff2 = $("#col2 .show_sql").text();
1398                         var diffs = diffString( escape(diff1), escape(diff2) );
1399                         $("#col1 .show_sql,#col2 .show_sql").html(diffs);
1400                     });
1401                     $('#update_sql').modal('show');
1402                     $("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?phase=Use saved&op=convert&report_id=" + report_id);
1403                 });
1404
1405                 $("#update_sql").on("hidden.bs.modal", function(){
1406                     $("#update_sql_label").html("");
1407                     $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1408                 });
1409             [% END %]
1410
1411             [% IF ( showsql ) %]
1412                 $("#sql").focus(function() {
1413                     $(this).select();
1414                 });
1415             [% END %]
1416
1417                 $(".toggle_sql").click(function(){
1418                     $("#sql_output").toggle();
1419                     $("#toggle_sql_hid").toggle();
1420                     $("#toggle_sql_vis").toggle();
1421                 });
1422
1423                 $(".toggle_chart_settings").click(function(){
1424                     $("#makechart").toggle();
1425                     $("#toggle_chart_settings_hid").toggle();
1426                     $("#toggle_chart_settings_vis").toggle();
1427                 });
1428
1429                 $("#table_reports").delegate(".confirmdelete", 'click', function(){
1430                     $(this).parents('tr').attr("class","warn");
1431                     if(confirm(_("Are you sure you want to delete this saved report?"))){
1432                         return true;
1433                     } else {
1434                         $(this).parents('tr').attr("class","");
1435                         return false;
1436                     }
1437                 });
1438
1439             [% IF (create || editsql || save) %]
1440                 $("#select_group").change(function() {
1441                     if($(this).prop('checked')) {
1442                         $("#group_input").prop('disabled', true);
1443                         $("#groupdesc_input").prop('disabled', true);
1444                         $("#group_select").prop('disabled', false);
1445                         if ($("#group_select").val().length > 0) {
1446                             $("#select_subgroup").prop('checked', true);
1447                             $("#select_subgroup").change();
1448                             $("#subgroup, #subgroup *").show();
1449                         } else {
1450                             $("#subgroup").hide();
1451                         }
1452                     }
1453                 });
1454                 $("#create_group").change(function() {
1455                     if($(this).prop('checked')) {
1456                         $("#group_input").prop('disabled', false);
1457                         $("#groupdesc_input").prop('disabled', false);
1458                         $("#group_select").prop('disabled', true);
1459                         $("#create_subgroup").prop('checked', true).change();
1460                         $("#subgroup_select").hide();
1461                         $("#subgroup input[type='radio']").hide();
1462                         $("#subgroup label[for]").hide();
1463                         $("#subgroup_input").show();
1464                         $("#subgroupdesc_input").show();
1465                         $("#subgroup").show();
1466                     }
1467                 });
1468                 $("#select_subgroup").change(function() {
1469                     if($(this).prop('checked')) {
1470                         $("#subgroup_select").prop('disabled', false);
1471                         $("#subgroup_input").prop('disabled', true);
1472                         $("#subgroupdesc_input").prop('disabled', true);
1473                     }
1474                 });
1475                 $("#create_subgroup").change(function() {
1476                     if($(this).prop('checked')) {
1477                         $("#subgroup_input").prop('disabled', false);
1478                         $("#subgroupdesc_input").prop('disabled', false);
1479                         $("#subgroup_select").prop('disabled', true);
1480                     }
1481                 });
1482                 $("#select_group").change();
1483                 $("#select_subgroup").change();
1484                 $("#group_select").on("change",function(){
1485                     load_group_subgroups();
1486                 });
1487             [% END %]
1488             $(".delete").on("click",function(){
1489                 return confirmDelete(MSG_CONFIRM_DELETE);
1490             });
1491
1492             $('div#ManaShareButton').click(function() {
1493                 $("#mana_share_form").submit();
1494             });
1495
1496             $("#mana_search_form").submit(function(e){
1497                 e.preventDefault();
1498             });
1499         });
1500
1501         function addColumn() {
1502             $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
1503         }
1504         function delColumn() {
1505             $("#selectedColumns option:selected").remove();
1506         }
1507         $("#column_submit").submit(function() {
1508             if ($("#selectedColumns option").size() < 1) {
1509                 alert(_("No columns selected!"));
1510                 return false;
1511             }
1512             $("#selectedColumns option").attr("selected", "selected");  // Select everything still in #selectedColumns
1513             return true;
1514         });
1515     </script>
1516 [% END %]
1517
1518 [% INCLUDE 'intranet-bottom.inc' %]
1519
1520 [% BLOCK group_and_subgroup_selection %]
1521     <li id="group">
1522         <label>Report group:</label>
1523         <input type="radio" name="select_or_create_group"
1524             id="select_group" checked="checked" />
1525         <label for="select_group" style="float:none">Select</label>
1526         <select name="group" id="group_select">
1527             <option value="">(None)</option>
1528             [% FOREACH group IN groups_with_subgroups %]
1529                 [% IF (group.selected) %]
1530                     <option value="[% group.id | html %]" selected="selected">
1531                 [% ELSE %]
1532                     <option value="[% group.id | html %]">
1533                 [% END %]
1534                     [% group.name | html %]
1535                 </option>
1536             [% END %]
1537         </select>
1538         <input type="radio" name="select_or_create_group" id="create_group" />
1539         <label for="create_group" style="float:none">or create:</label>
1540         <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
1541         <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
1542     </li>
1543     <li id="subgroup">
1544         <label>Report subgroup:</label>
1545         <input type="radio" name="select_or_create_subgroup"
1546             id="select_subgroup" checked="checked" />
1547         <label for="select_subgroup" style="float:none">Select</label>
1548         <select name="subgroup" id="subgroup_select">
1549             <option value="">(None)</option>
1550             [% FOREACH group IN groups_with_subgroups %]
1551                 [% IF (group.selected) %]
1552                     [% FOREACH subgroup IN group.subgroups %]
1553                         [% IF (subgroup.selected) %]
1554                             <option value="[% subgroup.id | html %]" selected="selected">
1555                         [% ELSE %]
1556                             <option value="[% subgroup.id | html %]">
1557                         [% END %]
1558                             [% subgroup.name | html %]
1559                         </option>
1560                     [% END %]
1561                 [% END %]
1562             [% END %]
1563         </select>
1564         <input type="radio" name="select_or_create_subgroup"
1565             id="create_subgroup" />
1566         <label for="create_subgroup" style="float:none">or create</label>
1567         <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
1568         <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />
1569     </li>
1570 [% END %]