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