5 [% USE TablesSettings %]
9 [%- BLOCK area_name -%]
11 [%- CASE 'CIRC' -%]Circulation
12 [%- CASE 'CAT' -%]Catalog
13 [%- CASE 'PAT' -%]Patrons
14 [%- CASE 'ACQ' -%]Acquisitions
15 [%- CASE 'ACC' -%]Accounts
16 [%- CASE 'SER' -%]Serials
20 [% INCLUDE 'doc-head-open.inc' %]
23 Koha › Reports › Guided reports wizard
25 › Saved reports
26 [%- ELSIF ( create ) -%]
27 › Create from SQL
28 [%- ELSIF ( showsql ) -%]
29 › Saved reports › SQL view
30 [%- ELSIF ( execute ) -%]
31 › Saved reports › Report [% name | html %] ([% id | html %])
32 [%- ELSIF ( editsql ) -%]
33 › Saved reports › Edit report [% reportname | html %] ([% id | html %])
36 › Build a report, step 1 of 6: Choose a module
37 [%- ELSIF ( build2 ) -%]
38 › Build a report, step 2 of 6: Pick a report type
39 [%- ELSIF ( build3 ) -%]
40 › Build a report, step 3 of 6: Select columns for display
41 [%- ELSIF ( build4 ) -%]
42 › Build a report, step 4 of 6: Select criteria to limit on
43 [%- ELSIF ( build5 ) -%]
44 › Build a report, step 5 of 6: Pick which columns to total
45 [%- ELSIF ( build6 ) -%]
46 › Build a report, step 6 of 6: Select how you want the report ordered
50 [% INCLUDE 'doc-head-close.inc' %]
51 [% Asset.css("lib/codemirror/codemirror.min.css") | $raw %]
59 #mana_search_errortext { font-family: monospace; font-weight: bold; }
61 [% Asset.css("css/reports.css") | $raw %]
62 [% Asset.css("lib/d3c3/c3.min.css") | $raw %]
65 <body id="rep_guided_reports_start" class="rep">
66 [% INCLUDE 'header.inc' %]
67 [% INCLUDE 'circ-search.inc' %]
69 <div id="breadcrumbs">
70 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
71 › <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
72 › <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
75 › Saved reports
76 [% ELSIF ( create ) %]
77 › Create from SQL
78 [% ELSIF ( showsql ) %]
79 › <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> › [% reportname | html %] ([% id | html %])
80 [% ELSIF ( editsql ) %]
81 › <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> › <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | uri %]&phase=Show%20SQL">[% reportname | html %] ([% id | html %])</a> › Edit
82 [% ELSIF ( execute ) %]
83 › <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> › <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | uri %]&phase=Show%20SQL">[% name | html %] ([% id | html %])</a> › Run
84 [% ELSIF ( build1 || build2 || build3 || build4 || build5 || build6 ) %]
85 › <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a report</a>
87 › Step 1 of 6: Choose a module
88 [% ELSIF ( build2 ) %]
89 › Step 2 of 6: Pick a report type
90 [% ELSIF ( build3 ) %]
91 › Step 3 of 6: Select columns for display
92 [% ELSIF ( build4 ) %]
93 › Step 4 of 6: Select criteria to limit on
94 [% ELSIF ( build5 ) %]
95 › Step 5 of 6: Pick which columns to total
96 [% ELSIF ( build6 ) %]
97 › Step 6 of 6: Select how you want the report ordered
100 </div> <!-- /#breadcrumbs -->
102 <div id="update_sql" class="modal" tabindex="-1" role="dialog" aria-labelledby="update_sql_label" aria-hidden="true">
103 <div class="modal-dialog">
104 <div class="modal-content">
105 <div class="modal-header">
106 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
107 <h3 id="update_sql_label">Update SQL</h3>
109 <div class="modal-body">
110 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
112 <div class="modal-footer">
113 <a href="#" class="btn btn-default" id="update_sql_button" role="button" data-toggle="modal">Update</a>
114 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
116 </div> <!-- /.modal-content -->
117 </div> <!-- /.modal-dialog -->
118 </div> <!-- #update_sql -->
120 <div class="main container-fluid">
122 <div class="col-sm-10 col-sm-push-2">
125 [% INCLUDE "reports-toolbar.inc" %]
128 <h2>Guided reports</h2>
129 <p>Use the guided reports engine to create non standard reports. This feature aims to provide some middle ground between the built in canned reports and writing custom SQL reports.</p>
131 <h3>Build and run reports</h3>
133 [% IF ( CAN_user_reports_create_reports ) %]
134 <form action="/cgi-bin/koha/reports/guided_reports.pl">
135 <input type="hidden" name="phase" value="Build new" />
136 <input type="submit" name="submit" value="Build new"/>
140 [% IF ( CAN_user_reports_execute_reports ) %]
141 <form action="/cgi-bin/koha/reports/guided_reports.pl">
142 <input type="hidden" name="phase" value="Use saved"/>
143 <input type="submit" name="submit" value="Use saved"/>
147 [% IF ( CAN_user_reports_create_reports ) %]
148 <form action="/cgi-bin/koha/reports/guided_reports.pl">
149 <input type="hidden" name="phase" value="Create report from SQL"/>
150 <input type="submit" name="submit" value="Create report from SQL"/>
154 <h3>Reports Dictionary</h3>
155 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
156 <form action="/cgi-bin/koha/reports/dictionary.pl">
157 <input type="hidden" name="phase" value="View Dictionary"/>
158 <input type="submit" name="submit" value="View dictionary"/>
160 [% END # /IF (start) %]
162 [% IF report_converted %]
163 <div class="dialog message">
164 The report "[% report_converted | html %]" has been converted.
168 [% IF report_converted %]
169 <div class="dialog message">
170 The report "[% report_converted | html %]" has been converted.
175 [% IF ( savedreports ) %]
176 <h1>Saved reports</h1>
178 [% IF ( filters.date || filters.author || filters.keyword ) %]
180 <span class="filter">
181 [% IF ( filters.date ) %]
182 <span class="filter_date"><strong>Date:</strong> [% filters.date | html %]</span>
184 [% IF ( filters.author ) %]
185 <span class="filter_author"><strong>Author:</strong> [% filters.author | html %]</span>
187 [% IF ( filters.keyword ) %]
188 <span class="filter_keyword"><strong>Keyword:</strong> [% filters.keyword | html %]</span>
190 <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>
195 <div id="tabs" class="toptabs">
197 <li><a href="#reports">All</a></li>
198 [% FOREACH group IN groups_with_subgroups %]
199 <li><a id="[% group.id | html %]" href="#reports">[% group.name | html %]</a></li>
203 <div id="subgroup_filter_block">
204 <label for="subgroup_filter">Subgroup:</label>
205 <select id="subgroup_filter">
206 <option value="">All</option>
210 [% IF (Koha.Preference('Mana') == 1) %]
212 <div id="mana_search_message" class="dialog message">
213 <p> [% manamsg | html %] </p>
218 <form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
219 <input type="hidden" name="phase" value="Delete Multiple" />
220 <table id="table_reports">
223 <th class="NoSort"> </th>
231 <th class="title-string">Creation date</th>
232 <th class="title-string">Last edit</th>
233 <th class="title-string">Last run</th>
234 <th class="report_public">Public</th>
235 <th class="report_json_url">JSON URL</th>
237 <th>Cache expiry (seconds)</th>
239 <th class="hidden"> </th>
241 <th>Saved results</th>
242 [% IF has_obsolete_reports %]
245 <th class="hidden"> </th>
247 <th class="NoSort noExport">Actions</th>
251 [% FOREACH savedreport IN savedreports %]
252 [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
253 <td class="report_checkbox">
254 [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
255 <input type="checkbox" name="ids" id="ids[% savedreport.id | html %]" value="[% savedreport.id | html %]" />
257 <input type="hidden" class="report_sql" value="[% savedreport.savedsql |html %]">
259 <td class="report_id">
260 <label for="ids[% savedreport.id | html %]">[% savedreport.id | html %]</label>
262 <td class="report_name">
263 [% IF ( savedreport.report_name ) %]
264 [% savedreport.report_name | html %]
269 <td class="report_type">
270 [% savedreport.type | html %]
272 <td class="report_group">
273 [% savedreport.groupname | html %]
276 [% savedreport.subgroupname | html %]
278 <td class="report_notes">
279 [% savedreport.notes | html %]
282 [% savedreport.borrowersurname | html %]
283 [% IF ( savedreport.borrowerfirstname ) %]
284 , [% savedreport.borrowerfirstname | html %]
286 ([% savedreport.borrowernumber | html %])
289 <span title="[% savedreport.date_created | html %]">[% savedreport.date_created | $KohaDates %]</span>
292 <span title="[% savedreport.last_modified | html %]">[% savedreport.last_modified | $KohaDates with_hours => 1 %]</span>
295 <span title="[% savedreport.last_run | html %]">[% savedreport.last_run | $KohaDates with_hours => 1 %]</span>
297 <td class="report_public">
298 [% IF (savedreport.public) %]
304 <td class="report_json_url">
305 [% IF (savedreport.public) %]
306 <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>
308 <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>
312 [% savedreport.cache_expiry | html %]
315 [% FOR result IN savedreport.results %]
316 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=[% result.id | uri %]">[% result.date_run | html %]</a>
321 [% IF savedreport.seems_obsolete %]
322 This report seems obsolete, it uses biblioitems.marcxml field.
323 <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>
327 <div class="btn-group dropup">
328 [%# There should be no space between these two buttons, it would render badly %]
329 <a class="btn btn-default btn-xs" role="button"
330 href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&phase=Run%20this%20report"><i
331 class="fa fa-play"></i> Run</a><a
332 class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown"
333 href="#"><b class="caret"></b></a>
334 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
335 <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL"><i class="fa fa-search"></i> View</a></li>
337 <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL" class="preview_sql" data-reportid="[% savedreport.id | html %]">
338 <i class="fa fa-eye"></i> Preview SQL
341 [% IF ( CAN_user_reports_create_reports ) %]
342 <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a></li>
343 <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from existing&report_id=[% savedreport.id | uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
345 [% IF (Koha.Preference('Mana') == 1) %]
346 <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>
348 <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
349 [% IF ( CAN_user_reports_delete_reports ) %]
350 <li><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a></li>
354 <input type="hidden" id="previewSql[% savedreport.id | html %]" value="[% savedreport.savedsql | html %]" data-title="[% savedreport.report_name | html %]" />
361 [% IF ( CAN_user_reports_delete_reports ) %]
362 <fieldset class="action">
363 <input type="submit" value="Delete selected" />
369 [% ELSE # IF ( savedreports ) %]
370 <div class="dialog message">
371 [% IF (filter_set || filters.date || filters.author || filters.keyword) %]
372 <h4>No saved reports match your criteria. </h4>
373 [% IF ( CAN_user_reports_create_reports ) %]
374 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
375 <input type="hidden" name="phase" value="Build new" />
376 <button type="submit" class="new"><i class="fa fa-plus"></i> New guided report</button>
379 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
380 <input type="hidden" name="phase" value="Create report from SQL" />
381 <button type="submit" class="new"><i class="fa fa-plus"></i> New SQL report</button>
384 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
385 <input type="hidden" name="phase" value="Use saved" />
386 <input type="hidden" name="filter_set" value="1" />
387 <input type="hidden" name="filter_keyword" value="" />
388 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> Cancel filter</button>
392 <h4>There are no saved reports. </h4>
393 [% IF ( CAN_user_reports_create_reports ) %]
394 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a new report?</a>
396 [% END # IF (filter_set || filters.date || filters.author || filters.keyword) %]
397 </div> <!-- /.dialog.message -->
398 [% END # /IF ( savedreports ) %]
399 [% END # /IF ( saved1 ) %]
401 [% INCLUDE 'mana/mana-share-report.inc' %]
404 [% IF ( cache_error) %]
405 <div class="dialog alert">
406 <strong> Please choose a cache_expiry less than 30 days </strong>
410 <h1>Build a report</h1>
411 <form action="/cgi-bin/koha/reports/guided_reports.pl">
412 <fieldset class="rows">
413 <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and choose report visibility </legend>
416 <label for="area">Choose: </label>
417 <select name="area" id="area">
418 [%- FOREACH area IN areas -%]
419 <option value="[% area | html %]">[%- PROCESS area_name area=area -%]</option>
425 <label for="public">Report is public:</label>
426 <select id="public" name="public">
427 <option value="0">No (default)</option>
428 <option value="1" selected="selected">Yes</option>
433 <label for="public">Report is public:</label>
434 <select id="public" name="public">
435 <option value="0" selected="selected">No (default)</option>
436 <option value="1">Yes</option>
443 <label for="cache_expiry">Cache expiry:</label>
444 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
445 <select id="cache_expiry_units" name="cache_expiry_units">
446 <option value="seconds">Seconds (default)</option>
447 <option value="minutes">Minutes</option>
448 <option value="hours">Hours</option>
449 <option value="days">Days</option>
454 </fieldset> <!-- /.rows -->
455 <fieldset class="action">
456 <input type="hidden" name="phase" value="Report on this Area" />
457 <input type="submit" name="submit" value="Next >>" />
463 <h1>Build a report</h1>
464 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
465 <input type="hidden" name="area" value="[% area | html %]" />
466 <input type="hidden" name="public" value="[% public | html %]" />
467 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
468 <fieldset class="rows">
469 <legend>Step 2 of 6: Pick a report type</legend>
472 <label for="types">Choose: </label>
473 <select id="types" name="types">
474 <option value="1">Tabular</option>
475 <option value="2" disabled="disabled">Summary</option>
476 <option value="3" disabled="disabled">Matrix</option>
482 <fieldset class="action">
483 <input type="hidden" name="phase" value="Choose this type" />
484 <input type="button" name="back" value="<< Back" class="goback" />
485 <input type="submit" name="submit" value="Next >>" />
488 [% END # /IF (build2 ) %]
491 <h1>Build a report</h1>
492 <h3>Step 3 of 6: Select columns for display</h3>
493 <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>
495 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
496 <input type="hidden" name="area" value="[% area | html %]" />
497 <input type="hidden" name="type" value="[% type | html %]" />
498 <input type="hidden" name="public" value="[% public | html %]" />
499 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
502 <div class="col-sm-6">
503 <div style="float: left;">
504 <select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
505 [% FOREACH column IN columns %]
506 [% IF ( column.table ) %]
507 [% IF ( loop.first ) %]
511 <optgroup label="[% column.table | html %]">
513 <option value="[% column.name | html %]">
514 [% IF ( column.description ) %]
515 [% column.description | html %] / [% column.name | html %]
517 [% column.name | html %]
525 <div style="width: 6.3em; float: right; margin-top: 100px">
526 <input type="button" name="Add" value="Add" class="button" style="width:6em;" id="addColumn" /><br />
527 <input type="button" name="delete" value="<< Delete" class="button" style="width: 6em; margin: 1em 0;" id="delColumn" />
529 </div> <!-- /.col-sm-6 -->
531 <div class="col-sm-6">
532 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;">
535 </div> <!-- /.row -->
537 <fieldset class="action">
538 <input type="hidden" name="phase" value="Choose these columns" />
539 <input type="button" name="back" value="<< Back" class="goback" />
540 <input type="submit" name="submit" value="Next >>" />
542 </form> <!-- /#column_submit -->
543 [% END # /IF ( build3 ) %]
546 <h1>Build a report</h1>
547 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
548 <input type="hidden" name="area" value="[% area | html %]" />
549 <input type="hidden" name="type" value="[% type | html %]" />
550 <input type="hidden" name="column" value="[% column | html %]" />
551 <input type="hidden" name="public" value="[% public | html %]" />
552 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
554 <legend>Step 4 of 6: Select criteria to limit on</legend>
556 [% FOREACH criteri IN criteria %]
559 <input type="checkbox" name="criteria_column" id="[% criteri.name | html %]" value="[% criteri.name | html %]" />
560 <label for="[% criteri.name | html %]">[% criteri.description | html %] </label>
562 [% IF ( criteri.date ) %]
564 <input type="text" size="10" id="[% criteri.name | html %]_value" name="[% criteri.name | html %]_value" value="" class="datepicker" />
565 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
569 [% IF ( criteri.textrange ) %]
572 <input type="text" size="10" id="[% criteri.from | html %]_value" name="[% criteri.from | html %]_value" value="" /> to
573 <input type="text" size="10" id="[% criteri.to | html %]_value" name="[% criteri.to | html %]_value" value="" />
577 [% IF ( criteri.daterange ) %]
580 <input type="text" size="10" id="from_[% criteri.name | html %]_value" name="from_[% criteri.name | html %]_value" value="" class="datepickerfrom" />
582 <input type="text" size="10" id="to_[% criteri.name | html %]_value" name="to_[% criteri.name | html %]_value" value="" class="datepickerto" />
583 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
588 <select name="[% criteri.name | html %]_value">
589 [% FOREACH value IN criteri.values %]
590 <option value="[% value.availablevalues | html %]">
591 [% IF ( value.default ) %]
594 [% value.display_value | html %]
608 [% IF ( definitions ) %]
610 <legend>Dictionary definitions</legend>
612 [% FOREACH definition IN definitions %]
615 <input type="checkbox" name="definition" value="[% definition.id | html %]" />
616 [% definition.name | html %]
624 <fieldset class="action">
625 <input type="hidden" name="phase" value="Choose these criteria" />
626 <input type="button" name="back" value="<< Back" class="goback" />
627 <input type="submit" name="submit" value="Next >>" />
630 [% END # /IF ( build4 ) %]
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 %]" />
645 [% FOREACH total_b IN total_by %]
648 <input type="checkbox" name="total_by" id="[% total_b.name | html %]" value="[% total_b.name | html %]" />
649 <label for="[% total_b.name | html %]">[% total_b.name | html %]</label>
652 <select name="[% total_b.name | html %]_tvalue">
653 [% FOREACH selec IN total_b.select %]
654 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
663 <fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
664 <input type="button" name="back" value="<< Back" class="goback" />
665 <input type="submit" name="submit" value="Next >>" />
668 [% END # /IF ( build5 ) %]
671 <h1>Build a report</h1>
672 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
673 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
674 <input type="hidden" name="area" value="[% area | html %]" />
675 <input type="hidden" name="type" value="[% type | html %]" />
676 <input type="hidden" name="column" value="[% column | html %]" />
677 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
678 <input type="hidden" name="definition" value="[% definition | html %]" />
679 <input type="hidden" name="totals" value="[% totals | html %]" />
680 <input type="hidden" name="public" value="[% public | html %]" />
681 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
684 [% FOREACH order_b IN order_by %]
687 <input type="checkbox" id="[% order_b.name | html %]" name="order_by" value="[% order_b.name | html %]" />
688 <label for="[% order_b.name | html %]">[% order_b.name | html %]</label>
691 <select name="[% order_b.name | html %]_ovalue">
692 [% FOREACH selec IN order_b.select %]
693 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
701 <fieldset class="action">
702 <input type="hidden" name="phase" value="Build report" />
703 <input type="submit" name="submit" value="Finish" />
706 [% END #/ IF ( build6 ) %]
708 [% IF ( showreport ) %]
709 <h1>Confirm custom report</h1>
710 <p>Your report will be generated with the following SQL statement.</p>
715 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
716 <input type="hidden" name="sql" value="[% sql | html %]" />
717 <input type="hidden" name="type" value="[% type | html %]" />
718 <input type="hidden" name="public" value="[% public | html %]" />
719 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
720 <p>You will need to save the report before you can execute it</p>
721 <fieldset class="action"><input type="hidden" name="phase" value="Save" />
722 <input type="submit" name="submit" value="Next" />
725 [% END #/ IF ( showreport ) %]
728 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
729 <input type="hidden" name="sql" value="[% sql | html %]" />
730 <input type="hidden" name="type" value="[% type | html %]" />
731 <input type="hidden" name="area" value="[% area | html %]" />
732 <input type="hidden" name="public" value="[% public | html %]" />
733 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
734 <fieldset class="rows">
735 <legend>Save your custom report</legend>
738 <label for="reportname" class="required">Report name: </label>
739 <input type="text" id="reportname" name="reportname" class="required" required="required" />
740 <span class="required">Required</span>
742 [% PROCESS group_and_subgroup_selection %]
744 <label for="notes">Notes:</label>
745 <textarea name="notes" id="notes"></textarea>
749 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
750 <input type="submit" name="submit" value="Save report" />
753 [% END # /IF( save ) %]
755 [% IF ( warn_authval_problem ) %]
756 <div class="dialog alert">
757 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
758 [% FOREACH problematic_authval IN problematic_authvals %]
760 <strong>[% problematic_authval.name | html %]:</strong> The authorized value category (<strong>[% problematic_authval.authval | html %]</strong>)
761 you selected does not exist.
764 <!-- Save Anyway Form -->
765 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
766 <!--Every parameter the user issued is provided as a hidden field for recovery-->
767 <input type='hidden' name='id' value='[% id | html %]' />
768 <input type='hidden' name='sql' value='[% sql | html %]' />
769 <input type='hidden' name='reportname' value='[% reportname | html %]' />
770 <input type='hidden' name='group' value='[% group | html %]' />
771 <input type='hidden' name='subgroup' value='[% subgroup | html %]' />
772 <input type='hidden' name='notes' value='[% notes | html %]' />
773 <input type='hidden' name='cache_expiry' value='[% cache_expiry | html %]' />
774 <input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units | html %]' />
775 <input type='hidden' name='public' value='[% public | html %]' />
776 [% IF ( phase_update) %]
777 <input type='hidden' name='phase' value='Update SQL' />
778 <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
779 [% ELSIF ( phase_save) %]
780 <input type='hidden' name='area' value='[% area | html %]' />
781 <input type='hidden' name='phase' value='Save Report' />
782 <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
785 <!-- Go back to editing -->
786 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
787 <button type="button" class="new goback"><i class="fa fa-fw fa-pencil"></i> Edit SQL</button>
790 [% END # /IF ( warn_authval_problem )%]
792 [% IF ( enter_params ) %]
793 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
794 <input type='hidden' name='reports' value="[% reports | html %]" />
795 [% IF ( auth_val_error ) %]
796 <input type='hidden' name='phase' value='Edit SQL' />
797 <div class="dialog alert">
798 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
799 [% FOREACH auth_val_error IN auth_val_errors %]
801 <strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
802 you selected does not exist.
806 <fieldset class="action"><input type="submit" value="Edit SQL" /></fieldset>
807 [% ELSE # IF ( auth_val_error ) %]
808 <input type='hidden' name='phase' value='Run this report' />
809 <h1>Enter parameters for report [% name | html %]:</h1>
811 <p>[% notes | html %]</p>
813 <fieldset class="rows">
815 [% FOREACH sql_param IN sql_params %]
816 <input name="param_name" value="[% sql_param.name | html %]" type="hidden" />
817 [% IF sql_param.input == 'date' %]
819 <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" />
821 [% ELSIF ( sql_param.input == 'text' ) %]
823 <label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label>
824 <input id="sql_params[% loop.count | html %]" type="text" name="sql_params" />
828 <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
829 <select name="[%- sql_param.input.name | html -%]" tabindex="1" size="1" id="[%- sql_param.input.id | html -%]">
830 [% IF (sql_param.include_all) %]
831 <option value="%">All</option>
833 [% FOREACH value IN sql_param.input.values %]
834 <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
838 [% END # /IF sql_param.input == 'date' %]
839 [% END # /FOREACH sql_param %]
841 </fieldset> <!-- /.rows -->
842 <fieldset class="action">
843 <input type="submit" value="Run the report" />
845 [% END # / IF ( auth_val_error ) %]
847 [% END # /IF ( enter_params ) %]
850 <h1>[% name | html %] <span id="report_id">([% id | html %])</span></h1>
852 <p><span class="label">Notes:</span> [% notes | html %]</p>
854 [% IF ( unlimited_total ) %]
856 <span class="label">Total number of results:</span>
857 [% unlimited_total | html %]
858 [% IF unlimited_total > limit %]
859 ([% limit | html %] shown)
864 <div id="sql_output" style="display:none;">
865 <span class="label">Report SQL:</span>
866 <textarea id="sql" readonly="readonly">[% sql | html %]</textarea>
870 <a href="#" id="toggle_chart_settings_hid" class="toggle_chart_settings" style="display:none"><i class="fa fa-eye-slash"></i> Hide chart</a>
871 <a href="#" id="toggle_chart_settings_vis" class="toggle_chart_settings" style="display:none"><i class="fa fa fa-eye"></i> Show chart</a>
873 <div id="chart" class="clearfix"></div>
876 [% UNLESS ( errors ) %]
877 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl" id="batch_record_modification">
878 <input type="hidden" name="recordtype" value="biblio" />
879 <input type="hidden" name="op" value="list" />
880 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
881 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">
882 [%- recordnumbers = PROCESS batch_list results=results batch_type='biblionumber' | trim | html %][% IF recordnumbers %][% SET batch_biblionumbers = 1 %][% recordnumbers | html %][% END -%]
886 <form method="POST" action="/cgi-bin/koha/tools/batch_delete_records.pl" id="batch_record_deletion">
887 <input type="hidden" name="recordtype" value="biblio" />
888 <input type="hidden" name="op" value="list" />
889 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
890 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">
891 [%- recordnumbers = PROCESS batch_list results=results batch_type='biblionumber' | trim | html %][% IF recordnumbers %][% SET batch_biblionumbers = 1 %][% recordnumbers | html %][% END -%]
895 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_modification">
896 <input type="hidden" name="op" value="show" />
897 [% FOREACH result IN results %]
898 [% FOREACH cells IN result.cells %]
899 [% place = loop.index %]
900 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
901 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
902 [% SET batch_itemnumbers = 1 %]
903 [% SET header_row.$place.has_itemnumbers = 1 %]
904 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
910 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_deletion">
911 <input type="hidden" name="op" value="show" />
912 <input type="hidden" name="del" value="1" />
913 [% FOREACH result IN results %]
914 [% FOREACH cells IN result.cells %]
915 [% place = loop.index %]
916 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
917 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
918 [% SET batch_itemnumbers = 1 %]
919 [% SET header_row.$place.has_itemnumbers = 1 %]
920 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
926 <form method="get" action="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl" id="batch_add_to_list">
927 [% FOREACH result IN results %]
928 [% FOREACH cells IN result.cells %]
929 [% place = loop.index %]
930 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
931 [% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
932 [% SET batch_biblionumbers = 1 %]
933 [% SET header_row.$place.has_biblionumbers = 1 %]
934 <input type="hidden" class="bib_to_list" name="biblionumber" value="[% cells.cell | html %]" />
940 <form method="POST" action="/cgi-bin/koha/tools/modborrowers.pl" id="batch_patron_modification">
941 <input type="hidden" name="op" value="show" />
942 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
943 <textarea style="display:none" name="cardnumberlist" id="cardnumberlist">
944 [%- cardnumbers = PROCESS batch_list results=results batch_type='cardnumber' | trim | html %][% IF cardnumbers %][% SET batch_cardnumbers = 1 %][% cardnumbers | html %][% END -%]
948 [% BLOCK batch_list %]
949 [%- FOREACH result IN results %]
950 [%- FOREACH cells IN result.cells %]
951 [%- place = loop.index %]
952 [%- IF header_row.$place.cell == batch_type || header_types.item(header_row.$place.cell) == batch_type %]
953 [%# We must not add whitespace to the cardnumbers %][% cells.cell | html %]
958 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
960 <div class="btn-group">
961 <button class="btn btn-default dropdown-toggle" type="button" id="batch_mod_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
962 Batch operations with [% IF unlimited_total > limit %][% limit | html %][% ELSE %][% unlimited_total | html %][% END %] visible records
963 <span class="caret"></span>
965 <ul class="dropdown-menu" aria-labelledby="batch_mod_menu">
966 [% FOREACH header_ro IN header_row %]
967 [% IF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
968 <li class="dropdown-header">Bibliographic records</li>
970 <a href="#" data-submit="batch_record_modification" data-toggle="tooltip" data-placement="right" title="Send visible records to batch record modification" class="batch_op send_to_record_mod">Batch record modification</a>
973 <a href="#" data-submit="batch_record_deletion" data-toggle="tooltip" data-placement="right" title="Send visible records to batch record deletion" class="batch_op send_to_record_del">Batch record deletion</a>
976 <a href="#" data-submit="batch_add_to_list" data-toggle="tooltip" data-placement="right" title="Send visible records to a list" class="batch_op send_to_list">Add to list</a>
979 [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
980 [% IF ( batch_biblionumbers ) %]
981 <li role="separator" class="divider"></li>
983 <li class="dropdown-header">Item records</li>
985 <a href="#" data-submit="batch_item_modification" data-toggle="tooltip" data-placement="right" title="Send visible items to batch item modification" class="batch_op send_to_item_mod">Batch item modification</a>
988 <a href="#" data-submit="batch_item_deletion" data-toggle="tooltip" data-placement="right" title="Send visible items to batch item deletion" class="batch_op send_to_item_del">Batch item deletion</a>
991 [% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
992 [% IF ( batch_biblionumbers || batch_itemnumbers ) %]
993 <li role="separator" class="divider"></li>
995 <li class="dropdown-header">Patron records</li>
997 <a href="#" data-submit="batch_patron_modification" data-toggle="tooltip" data-placement="right" title="Send visible results to batch patron modification" class="batch_op send_to_patron_mod">Batch patron modification</a>
1001 </ul> <!-- /.dropdown-menu -->
1002 </div> <!-- /.dropdown -->
1004 [% END # /IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1005 [% END # UNLESS ( errors ) %]
1006 [% END # IF ( execute ) %]
1008 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
1009 <input type="hidden" name="phase" value="Run this report"/>
1010 <input type="hidden" name="reports" value="[% report_id | html %]"/>
1012 [% FOREACH p IN sql_params %]
1013 <input type="hidden" name="sql_params" value="[% p | html %]"/>
1015 [% FOREACH n IN param_names %]
1016 <input type="hidden" name="param_name" value="[% n | html %]"/>
1019 <label for="limit">Rows per page: </label>
1020 <select name="limit" id="limit">
1021 [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
1022 [% FOREACH l IN limits %]
1024 <option value="[% l | html %]" selected="selected">[% l | html %]</option>
1026 <option value="[% l | html %]">[% l | html %]</option>
1030 </form> <!-- /#limitselect -->
1032 <div class="pages">[% pagination_bar | $raw %]</div>
1033 [% UNLESS ( errors ) %]
1036 [% FOREACH header_ro IN header_row %]
1037 <th>[% header_ro.cell | html %]</th>
1040 [% FOREACH result IN results %]
1042 [% FOREACH cells IN result.cells %]
1043 <td>[% cells.cell | $raw %]</td>
1049 <div class="pages">[% pagination_bar | $raw %]</div>
1051 [% INCLUDE 'chart.inc' %]
1053 [% END #/IF ( execute ) %]
1056 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1057 <fieldset class="rows">
1058 <legend>Create report from SQL</legend>
1061 <label for="reportname" class="required">Report name:</label>
1062 [% IF ( reportname ) %]
1063 <input type="text" class="required" required="required" id="reportname" name="reportname" value="[% reportname | html %]" size="50"/>
1065 <input type="text" class="required" required="required" id="reportname" name="reportname" size="50" />
1067 <span class="required">Required</span>
1069 [% PROCESS group_and_subgroup_selection %]
1073 <label for="public">Report is public:</label>
1074 <select id="public" name="public">
1075 <option value="0">No (default)</option>
1076 <option value="1" selected="selected">Yes</option>
1081 <label for="public">Report is public:</label>
1082 <select id="public" name="public">
1083 <option value="0" selected="selected">No (default)</option>
1084 <option value="1">Yes</option>
1087 [% END # /IF (public) %]
1091 <label for="cache_expiry">Cache expiry:</label>
1092 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
1093 <select id="cache_expiry_units" name="cache_expiry_units">
1094 <option value="seconds" selected="selected">Seconds (default)</option>
1095 <option value="minutes">Minutes</option>
1096 <option value="hours">Hours</option>
1097 <option value="days">Days</option>
1100 [% END # /IF (usecache) %]
1102 <label for="notes">Notes:</label>
1103 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1106 </fieldset> <!-- /.rows -->
1108 <fieldset class="rows">
1109 <legend>SQL:</legend>
1110 <div style="margin:1em;">
1111 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea>
1112 <span class="required">Required</span>
1116 <fieldset class="action">
1117 <input type="hidden" name="phase" value="Save Report" />
1118 <input type="submit" name="submit" value="Save report" />
1119 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1122 [% END #/IF ( create ) %]
1124 [% IF saved_results %]
1125 <h1>Saved report results</h1>
1126 <h2>[% name | html %]</h2>
1127 <p>[% notes | html %]</p>
1129 [% FOREACH rows IN saved_results %]
1131 [% FOREACH col IN rows %]
1132 <td>[% col | html %]</td>
1137 [% END # /IF saved_results %]
1139 [% IF ( showsql ) %]
1140 <fieldset class="rows">
1141 <legend>[% reportname | html %]</legend>
1145 <span class="label">Notes:</span>
1151 <textarea id="sql">[% sql | html %]</textarea>
1155 [% END # /IF ( showsql ) %]
1157 [% IF ( save_successful ) %]
1158 [% UNLESS ( errors ) %]
1160 <div id="report_updated">
1161 <div class="dialog message">
1162 <p>Your report "[% reportname | html %]" has been saved</p>
1168 [% IF ( editsql ) %]
1169 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1170 <input type="hidden" name="phase" value="Update SQL" />
1171 <input type="hidden" name="id" value="[% id | html %]"/>
1172 <fieldset class="rows">
1173 <legend>Edit SQL report</legend>
1176 <label for="reportname" class="required">Report name: </label>
1177 <input type="text" id="reportname" name="reportname" value="[% reportname | html %]" size="50" class="required" required="required" />
1178 <span class="required">Required</span>
1180 [% PROCESS group_and_subgroup_selection %]
1183 <label for="public">Report is public:</label>
1184 <select id="public" name="public">
1185 <option value="0">No (default)</option>
1186 <option value="1" selected="selected">Yes</option>
1191 <label for="public">Report is public:</label>
1192 <select id="public" name="public">
1193 <option value="0" selected="selected">No (default)</option>
1194 <option value="1">Yes</option>
1197 [% END # /IF (public) %]
1201 <label for="cache_expiry">Cache expiry:</label>
1202 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]" />
1203 <select id="cache_expiry_units" name="cache_expiry_units">
1204 <option value="seconds">Seconds (default)</option>
1205 <option value="minutes">Minutes</option>
1206 <option value="hours">Hours</option>
1207 <option value="days">Days</option>
1212 <label for="notes">Notes:</label>
1213 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1216 </fieldset> <!-- /.rows -->
1218 <fieldset class="rows">
1219 <legend>SQL:</legend>
1220 <div style="margin:1em;">
1221 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea>
1222 <span class="required">Required</span>
1226 <fieldset class="action">
1227 <input type="submit" name="submit" value="Update SQL" />
1228 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1231 [% END # /IF ( editsql ) %]
1234 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
1235 <div class="dialog alert">
1236 <strong>The following error was encountered:</strong><br />
1237 [% FOREACH error IN errors %]
1238 [% IF ( error.sqlerr ) %]
1239 This report contains the SQL keyword <strong>[% error.sqlerr | html %]</strong>.<br />
1240 Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.<br />
1241 Please return to the "Saved Reports" screen and delete this report or retry creating a new one.
1242 [% ELSIF ( error.queryerr ) %]
1243 The database returned the following error: <br />
1244 [% error.queryerr | html %]<br />Please check the log for further details.
1245 [% ELSIF ( error.cache_expiry ) %]
1246 Please select a cache expiry less than 30 days.
1249 <div id="onerror_actions">
1250 <a href="#" class="button goback">Return to previous page</a>
1254 <fieldset class="action">
1255 <input type="hidden" name="phase" value="Use saved" />
1256 <input type="submit" name="submit" value="Saved reports" />
1259 [% END # /IF ( errors ) %]
1262 </div> <!-- /.col-sm-10.col-sm-push-2 -->
1264 <div class="col-sm-2 col-sm-pull-10">
1267 <div id="saved-reports-filter">
1268 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
1269 <input type="hidden" name="phase" value="Use saved" />
1270 <input type="hidden" name="filter_set" value="1" />
1271 <fieldset class="brief">
1275 <label for="filter_date">Date:</label>
1276 <input type="text" id="filter_date" name="filter_date" size="10" value="[% filters.date | html %]" class="datepicker" />
1277 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
1280 <label for="filter_author">Author:</label>
1281 <input type="text" id="filter_author" name="filter_author" value="[% filters.author | html %]" size="16" />
1284 <label for="filter_keyword">Keyword:</label>
1285 <input type="text" id="filter_keyword" name="filter_keyword" value="[% filters.keyword | html %]" size="16" />
1288 </fieldset> <!-- /.brief -->
1289 <fieldset class="action">
1290 <input type="submit" value="Apply filter" />
1291 <a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1">Clear</a>
1294 </div> <!-- /#saved-reports-filter -->
1296 [% INCLUDE 'guided-reports-view.inc' %]
1298 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1299 </div> <!-- /.row -->
1301 [% MACRO jsinclude BLOCK %]
1302 [% Asset.js("js/charts.js") | $raw %]
1303 [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
1304 [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
1305 [% INCLUDE 'calendar.inc' %]
1306 [% INCLUDE 'datatables.inc' %]
1308 [% INCLUDE 'columns_settings.inc' %]
1310 [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
1311 [% Asset.js( "lib/codemirror/overlay.min.js" ) | $raw %]
1312 [% Asset.js( "lib/codemirror/sql.min.js" ) | $raw %]
1313 [% Asset.js( "js/mana.js" ) | $raw %]
1316 function hide_bar_element() {
1317 $('#chart-column-horizontal').hide()
1318 $('.chart-column-group').each(function( index ) {
1321 $('.chart-column-line').each(function( index ) {
1326 function show_bar_element() {
1327 $('#chart-column-horizontal').show()
1328 $('.chart-column-group').each(function( index ) {
1331 $('.chart-column-line').each(function( index ) {
1336 function removeColumn(id) {
1339 if ( $('.chart-column-conf').length == 1 ) {
1340 $('.chart-column-delete').remove();
1344 /* overlay a syntax-highlighting definition on top of the existing sql one */
1345 CodeMirror.defineMode("sqlParams", function(config, parserConfig) {
1346 var sqlParamsOverlay = {
1347 token: function(stream, state) {
1349 if (stream.match("<<")) {
1350 while ((ch = stream.next()) != null)
1351 if (ch == ">" && stream.next() == ">") {
1356 while (stream.next() != null && !stream.match("<<", false)) {}
1360 return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/x-sql"), sqlParamsOverlay);
1363 var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1364 var group_subgroups = {};
1365 [% FOREACH group IN groups_with_subgroups %]
1366 var gid = "[% group.id | html %]"
1367 group_subgroups[gid] = new Array();
1368 [% FOREACH subgroup IN group.subgroups %]
1369 var sgid = "[% subgroup.id | html %]";
1370 var sgname = "[% subgroup.name | html %]";
1371 group_subgroups[gid].push([sgid, sgname]);
1375 [% IF ( create || editsql || save ) %]
1377 var editor = CodeMirror.fromTextArea(sql, {
1379 mode: "sqlParams", /* text/x-sql plus custom sqlParams configuration */
1384 // https://stackoverflow.com/questions/2086287/how-to-clear-jquery-validation-error-messages#answer-16025232
1385 function clearValidation( formElement ){
1386 // formElement should be a jQuery object
1387 var validator = formElement.validate();
1388 // Iterate through named elements inside of the form, and mark them as error free
1389 $('[name]',formElement).each(function(){
1390 validator.successList.push(this);//mark as error free
1391 validator.showErrors();//remove error messages if present
1393 validator.resetForm();//remove error class on name elements and clear history
1394 validator.reset();//remove all error and success data
1398 [% IF ( showsql ) %]
1399 var editor = CodeMirror.fromTextArea(sql, {
1401 mode: "sqlParams", /* text/x-sql plus custom sqlParams configuration */
1407 function load_group_subgroups () {
1408 var group = $("#group_select").val();
1409 var sg = $("#subgroup");
1410 $(sg).find('option[value!=""]').each(function() {
1415 var select = $(sg).find('select')[0];
1416 $.each( group_subgroups[group], function(index, value) {
1417 $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1419 $("#subgroup, #subgroup *").show();
1423 $(document).ready(function(){
1425 var activeTab = localStorage.getItem("sql_reports_activetab");
1427 $("body").on('click',".fetch_chart_data",function(){
1428 if( [% unlimited_total || 0 | $raw %] > 1000 ){
1429 if( confirm("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you with to chart this report?") ){
1440 if ( $('.chart-column-conf').length == 1 ) {
1441 $('.chart-column-delete').remove();
1444 $(".chart-column-delete").on('click', function(e){
1446 removeColumn('column_' + $(this).data('column'));
1449 $('#download-chart').click(function() {
1450 var svg = '<svg>' + $('#chart svg').html() + '</svg>';
1451 this.href = 'data:application/octet-stream;base64,' + btoa(svg);
1452 this.setAttribute('download', 'chart.svg');
1455 $('#chart-type').change(function() {
1456 if ($(this).val() == 'bar') {
1464 $('#download-chart').hide();
1467 [% IF results && !errors %]
1468 $('#draw-chart').click(function() {
1470 var x_elements = $('select[name="x"]').val();
1471 var y_elements = [];
1476 headers = [% header_row.json | $raw %];
1479 [% IF allresults.size %]
1480 if ($('input[name="chart-include-all"]').prop('checked')) {
1481 results = [% allresults.json | $raw %]
1484 results = [% results.json | $raw %]
1487 results = [% results.json | $raw %];
1490 if ($('input[name="chart-exclude-last"]').prop('checked')) {
1491 results.splice(-1, 1);
1494 $('select[name="y"]').each(function( index ) {
1495 y_elements.push( $(this).val() );
1497 $('select[name="group"]').each(function( index ) {
1498 groups.push( $(this).val() );
1500 $('.column-line').each(function( index ) {
1501 if ($(this).prop('checked')) {
1502 lines.push( $(this).attr('name') );
1506 // Remove deleted columns from headers and results.
1507 var deleted_indexes = [];
1508 var kept_headers = [];
1509 $.each(headers, function(index, value) {
1510 if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) {
1511 // This header is neither a x element nor in y elements. Don't need it.
1512 deleted_indexes.push(index);
1515 kept_headers.push({cell: value.cell});
1519 // Remove coresponding cells.
1520 var kept_results = [];
1521 $.each(results, function(index, value) {
1524 $.each(value.cells, function(i, val) {
1525 if ($.inArray(i, deleted_indexes) === -1) {
1526 line['cells'].push({cell: val.cell});
1529 kept_results.push(line);
1532 options.type = $('select[name="chart-type"]').val();
1533 options.horizontal = $('input[name="column-horizontal"]').prop('checked');
1534 options.lines = lines;
1536 chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options);
1537 $("#download-chart,#toggle_chart_settings_hid,#chart").show();
1538 $("#toggle_chart_settings_vis").hide();
1539 $("#chartModal").modal("hide");
1543 load_group_subgroups();
1546 $('[data-toggle="tooltip"]').tooltip();
1547 var columns_settings = [% TablesSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1549 $('#limit').change(function() {
1550 $('#limitselect').submit();
1553 $(document).click(function() {
1554 $('#report_updated').hide();
1557 $(".goback").on("click",function(e){
1559 window.history.back();
1562 $("body").on("click", ".mana_search_button", function(){
1563 $("#mana-loading").show();
1564 mana_search($("#mana_search_field").val());
1567 $(".ShareButton").on("click", function(){
1568 $("#note-error").hide();
1569 if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
1570 $(".shared_infos").hide();
1571 $("#note-error").show();
1574 $("#reportid").val($(this).closest("tr").find(".report_id").text());
1575 $("#shared_id").html($(this).closest("tr").find(".report_id").text());
1576 $("#shared_name").html($(this).closest("tr").find(".report_name").text());
1577 $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
1578 $("#shared_type").html($(this).closest("tr").find(".report_type").text());
1579 $("#shared_group").html($(this).closest("tr").find(".report_group").text());
1580 $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
1584 $("#ManaCloseButton").on("click", function() {
1585 $(".shared_infos").show();
1588 $("#addColumn").on("click",function(){
1592 $("#delColumn").on("click",function(){
1597 var rtable = KohaTable("table_reports", {
1598 'iDisplayLength': [% Koha.Preference('NumSavedReports') | html %],
1599 'bAutoWidth': false,
1600 'sPaginationType': 'full',
1601 'aaSorting': [[ 1, "asc" ]],
1603 { 'bSearchable': false, 'aTargets': [3] },
1604 { "aTargets": [ 1, 2 ], "sType": "natural" },
1605 { "visible": false, "aTargets" : [ "hidden" ] }
1608 'sZeroRecords': _("No matching reports found")
1610 }, columns_settings);
1612 var rtabs = $("#tabs").tabs({
1613 create: function( e, ui ){
1614 tabsInit( ui, rtable );
1616 activate: function( e, ui ){
1617 tabsInit( ui, rtable );
1621 $("#tabs").tabs("option","active", activeTab );
1623 $("#subgroup_filter_block").hide();
1625 $("#subgroup_filter").change(function() {
1626 var selected = $(this).find('option:selected');
1627 var sg_id = $(selected).val();
1628 var sg_name = $(selected).text();
1629 if (sg_id.length > 0) {
1630 rtable.fnFilter('^' + sg_name + '$', 5, true, true, true, false);
1631 rtable.fnSetColumnVis(5, false);
1633 rtable.fnFilter('', 5);
1634 rtable.fnSetColumnVis(5, true);
1638 $("#reports_form").submit(function(){
1639 var checkedItems = $("input[name=ids]:checked");
1640 if ($(checkedItems).size() == 0) {
1641 alert(_("You must select one or more reports to delete"));
1644 $(checkedItems).parents('tr').addClass("warn");
1645 if( confirm(_("Are you sure you want to delete the selected reports?")) ) {
1648 $(checkedItems).parents('tr').removeClass("warn");
1653 $("body").on("click", ".update_sql", function(e){
1655 var ltitle = $(this).text();
1656 var report_id = $(this).data("report_id");
1657 var page = $(this).attr("href");
1658 $("#update_sql .modal-body").load(page + " div", function(){
1659 var diff1 = $("#col1 .show_sql").text();
1660 var diff2 = $("#col2 .show_sql").text();
1661 var diffs = diffString( escape(diff1), escape(diff2) );
1662 $("#col1 .show_sql,#col2 .show_sql").html(diffs);
1664 $('#update_sql').modal('show');
1665 $("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?phase=Use saved&op=convert&report_id=" + report_id);
1668 $("#update_sql").on("hidden.bs.modal", function(){
1669 $("#update_sql_label").html("");
1670 $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1674 [% IF ( showsql ) %]
1675 $("#sql").focus(function() {
1680 $(".toggle_sql").click(function(){
1681 $("#sql_output").toggle();
1682 $("#toggle_sql_hid").toggle();
1683 $("#toggle_sql_vis").toggle();
1685 showsql = CodeMirror.fromTextArea(sql, {
1694 $(".toggle_chart_settings").click(function(){
1695 $("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
1698 $("#table_reports").delegate(".confirmdelete", 'click', function(){
1699 $(this).parents('tr').attr("class","warn");
1700 if(confirm(_("Are you sure you want to delete this saved report?"))){
1703 $(this).parents('tr').attr("class","");
1708 [% IF (create || editsql || save) %]
1710 var validated_form = $("#sql_report_form").validate({
1711 reportname: "required",
1714 depends: function(element) {
1715 return $("#create_group").prop("checked") && $("#groupdesc_input").val() != '';
1721 depends: function(element) {
1722 return $("#create_group").prop("checked") && $("#group_input").val() != '';
1728 $("#select_group").change(function() {
1729 if($(this).prop('checked')) {
1730 $("#group_input").attr("class","").prop('disabled', true).prop("required", false);
1731 $("#groupdesc_input").attr("class","").prop('disabled', true).prop("required", false);
1732 $("#group_select").prop('disabled', false);
1733 clearValidation( $("#sql_report_form") );
1734 if ($("#group_select").val().length > 0) {
1735 $("#select_subgroup").prop('checked', true);
1736 $("#select_subgroup").change();
1737 $("#subgroup, #subgroup *").show();
1739 $("#subgroup").hide();
1743 $("#create_group").change(function() {
1744 if($(this).prop('checked')) {
1745 $("#group_input").prop('disabled', false).prop("required", true );
1746 $("#groupdesc_input").prop('disabled', false).prop("required", true );
1747 $("#group_select").prop('disabled', true);
1748 // $("#create_subgroup").prop('checked', true).change();
1749 $("#subgroup_select").hide();
1750 $("#subgroup input[type='radio']").hide();
1751 $("#subgroup label[for]").hide();
1752 $("#subgroup_input").prop("required", false ).prop("disabled", false).show();
1753 $("#subgroupdesc_input").prop("required", false ).prop("disabled", false).show();
1754 $("#subgroup").show();
1755 // Add validation rules for fields which were previously hidden
1756 $("#subgroup_input").rules("add", {
1758 depends: function(element) {
1759 return $("#create_group").prop("checked") && $("#subgroupdesc_input").val() != '';
1763 $("#subgroupdesc_input").rules("add", {
1765 depends: function(element) {
1766 return $("#create_group").prop("checked") && $("#subgroup_input").val() != '';
1772 $("#select_subgroup").change(function() {
1773 if($(this).prop('checked')) {
1774 $("#subgroup_select").prop('disabled', false);
1775 $("#subgroup_input").prop('disabled', true).prop("required", false );
1776 $("#subgroupdesc_input").prop('disabled', true).prop("required", false );
1777 clearValidation( $("#sql_report_form") );
1780 $("#create_subgroup").change(function() {
1781 if($(this).prop('checked')) {
1782 $("#subgroup_input").prop('disabled', false).prop("required", true );
1783 $("#subgroupdesc_input").prop('disabled', false).prop("required", true );
1784 $("#subgroup_select").val("").prop('disabled', true);
1787 $("#select_group").change();
1788 $("#select_subgroup").change();
1789 $("#group_select").on("change",function(){
1790 load_group_subgroups();
1794 $(".delete").on("click",function(){
1795 return confirmDelete(MSG_CONFIRM_DELETE);
1798 $("#mana_search_form").submit(function(e){
1802 $("#column_submit").submit(function() {
1803 if ($("#selectedColumns option").size() < 1) {
1804 alert(_("No columns selected!"));
1807 $("#selectedColumns option").attr("selected", "selected"); // Select everything still in #selectedColumns
1812 $("body").on("click", ".mana-use", function(e) {
1814 $(this).find("i").attr("class","fa fa-refresh fa-spin");
1815 mana_use( $(this).data("report_id") );
1818 $("#mana_search_result").on("hide.bs.modal", function(){
1819 $("#mana_result_content").html("");
1820 $("#mana_search_field").val("");
1823 $(".batch_op").on("click", function(e){
1825 var target_form = $(this).data("submit");
1826 $("#" + target_form ).submit();
1829 $("#batch_add_to_list").on("submit", function(e){
1834 $("body").on("click", ".preview_sql", function(e){
1836 var reportid = $(this).data("reportid");
1837 previewSql( reportid );
1841 function tabsInit( ui, rtable ){
1842 var thisTab = ui.newTab ? ui.newTab : ui.tab;
1843 var activeTab = thisTab.index();
1844 localStorage.setItem("sql_reports_activetab", activeTab );
1846 $("#subgroup_filter option").each(function() {
1847 if($(this).val().length > 0) {
1851 rtable.fnFilter('', 4);
1852 rtable.fnFilter('', 5);
1853 rtable.fnSetColumnVis(4, true);
1854 rtable.fnSetColumnVis(5, true);
1856 var g_id = $(ui.newTab).children().attr('id');
1857 var g_name = $(ui.newTab).text();
1858 if ( g_name == _("All") ) {
1863 if (g_id && g_id.length > 0) {
1864 rtable.fnFilter('^' + g_name + '$', 4, true, true, true, false);
1865 rtable.fnSetColumnVis(4, false);
1866 for(var i in group_subgroups[g_id]) {
1867 $("#subgroup_filter").append(
1868 '<option value="' + group_subgroups[g_id][i][0] + '">'
1869 + group_subgroups[g_id][i][1] + '</option>'
1872 $("#subgroup_filter_block").show();
1874 $("#subgroup_filter_block").hide();
1878 function addColumn() {
1879 $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
1881 function delColumn() {
1882 $("#selectedColumns option:selected").remove();
1886 function mana_use( mana_id ){
1889 url: "/cgi-bin/koha/svc/mana/use",
1890 data: {id:mana_id, resource: 'report', saveinbase: 1},
1893 .done( function (result){
1894 if ( result.errmsg ){
1895 alert( result.errmsg );
1898 window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&phase=Show%20SQL&mana_success=1");
1901 .fail(function( error ) {
1902 $(".mana_use_status").hide();
1903 $("#mana_use_errortext").html( error.status + " " + error.statusText );
1904 $("#mana_use_failed").show();
1905 $(".mana-use i").attr("class","fa fa-download");
1909 function mana_search( textquery ){
1910 $(".mana_search_status").hide();
1911 $("#mana_result_content").load("/cgi-bin/koha/svc/mana/search #mana_results", { resource: 'report', id: textquery, usecomments: 1 }, function( response, status, xhr ) {
1913 if ( status == "error" ) {
1914 $("#mana_search_errortext").html( xhr.status + " " + xhr.statusText );
1915 $("#mana_search_failed").show();
1916 $("#mana-loading").hide();
1918 $(".mana_search_status").hide();
1919 $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
1920 $("#mana-loading").hide();
1921 $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
1922 "sPaginationType":"full",
1925 { "width": "35%", "targets": 1 }
1928 { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
1929 { "sType": "title-string", "aTargets" : [ "title-string" ] },
1930 { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
1934 $(".showbutton").on("click", function(e){
1936 $(this).parent().hide();
1937 $(this).parent().next().show();
1940 $(".hidebutton").on("click", function(e){
1942 $(this).parent().hide();
1943 $(this).parent().prev().show();
1946 if($("td.dataTables_empty").length == 0){
1947 $("#mana_search_message").show();
1953 function addToList() {
1954 var biblionumbers = [];
1955 $(".bib_to_list").each(function() {
1956 var biblionumber = Number( $(this).val() );
1957 if( biblionumbers.indexOf( biblionumber ) < 0 ){
1958 biblionumbers.push( biblionumber );
1961 bibs = biblionumbers.join("/");
1962 var url = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumbers=" + bibs;
1963 window.open(url, 'Add_to_virtualshelf', 'width=500, height=400, toolbar=false, scrollbars=yes');
1967 // Adapted from https://gist.github.com/jnormore/7418776
1968 function previewSql(reportid) {
1971 var message = $("#previewSql" + reportid ).val();
1972 var title = $("#previewSql" + reportid ).data("title");
1973 if( $("#preview-sql-modal").length > 0) {
1974 $("#preview-sql-modal").remove();
1976 $("body").append('<div id="preview-sql-modal" tabindex="-1" role="dialog" aria-hidden="true" class="modal">\
1977 <div class="modal-dialog">\
1978 <div class="modal-content">\
1979 <div class="modal-header" style="min-height:40px;">\
1980 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">\
1981 <span aria-hidden="true">×</span>\
1983 <h4 class="modal-title">' + title + '</h4>\
1985 <div class="modal-body"><textarea id="code' + reportid + '">' + message + '</textarea>\
1986 <div class="modal-footer">\
1987 <a id="preview-modal-editreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a>\
1988 <a id="preview-modal-duplicate" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from existing&report_id=' + reportid + '"><i class="fa fa-copy"></i> Duplicate</a>\
1989 <a id="preview-modal-duplicate" class="btn btn-default" href="/cgi-bin/koha/tools/scheduler.pl?id=' + reportid + '"><i class="fa fa-clock-o"></i> Schedule</a>\
1990 <a id="preview-modal-delete" class="delete btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a>\
1991 <a id="preview-modal-runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Run%20this%20report"><i class="fa fa-play"></i> Run report</a>\
1992 <a href="#" id="preview-sql-modal-cancel" data-dismiss="modal" class="btn btn-default"><i class="fa fa-remove" aria-hidden="true"></i> Close</a>\
1998 $("#preview-sql-modal").modal('show');
1999 CodeMirror.fromTextArea( document.getElementById("code" + reportid ), {
2009 [% INCLUDE 'intranet-bottom.inc' %]
2011 [% BLOCK group_and_subgroup_selection %]
2013 <label>Report group:</label>
2014 <input type="radio" name="select_or_create_group"
2015 id="select_group" checked="checked" />
2016 <label for="select_group" style="float:none">Select</label>
2017 <select name="group" id="group_select">
2018 <option value="">(None)</option>
2019 [% FOREACH group IN groups_with_subgroups %]
2020 [% IF (group.selected) %]
2021 <option value="[% group.id | html %]" selected="selected">
2023 <option value="[% group.id | html %]">
2025 [% group.name | html %]
2029 <input type="radio" name="select_or_create_group" id="create_group" />
2030 <label for="create_group" style="float:none">or create:</label>
2031 <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
2032 <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
2035 <label>Report subgroup:</label>
2036 <input type="radio" name="select_or_create_subgroup"
2037 id="select_subgroup" checked="checked" />
2038 <label for="select_subgroup" style="float:none">Select</label>
2039 <select name="subgroup" id="subgroup_select">
2040 <option value="">(None)</option>
2041 [% FOREACH group IN groups_with_subgroups %]
2042 [% IF (group.selected) %]
2043 [% FOREACH subgroup IN group.subgroups %]
2044 [% IF (subgroup.selected) %]
2045 <option value="[% subgroup.id | html %]" selected="selected">
2047 <option value="[% subgroup.id | html %]">
2049 [% subgroup.name | html %]
2055 <input type="radio" name="select_or_create_subgroup"
2056 id="create_subgroup" />
2057 <label for="create_subgroup" style="float:none">or create</label>
2058 <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
2059 <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />