3 [% USE AuthorisedValues %]
6 [% USE TablesSettings %]
8 [% PROCESS 'i18n.inc' %]
12 [%- BLOCK area_name -%]
14 [%- CASE 'CIRC' -%]<span>Circulation</span>
15 [%- CASE 'CAT' -%]<span>Catalog</span>
16 [%- CASE 'PAT' -%]<span>Patrons</span>
17 [%- CASE 'ACQ' -%]<span>Acquisitions</span>
18 [%- CASE 'ACC' -%]<span>Accounts</span>
19 [%- CASE 'SER' -%]<span>Serials</span>
23 [% INCLUDE 'doc-head-open.inc' %]
27 Saved reports › [%- ELSIF ( create ) -%]
28 Create from SQL › [%- ELSIF ( showsql ) -%]
29 SQL view › Saved reports › [%- ELSIF ( execute ) -%]
30 Report [% name | html %] ([% id | html %]) › Saved reports › [%- ELSIF ( editsql ) -%]
31 Edit report [% reportname | html %] ([% id | html %]) › Saved reports › [%- END -%]
34 Build a report, step 1 of 6: Choose a module › [%- ELSIF ( build2 ) -%]
35 Build a report, step 2 of 6: Pick a report type › [%- ELSIF ( build3 ) -%]
36 Build a report, step 3 of 6: Select columns for display › [%- ELSIF ( build4 ) -%]
37 Build a report, step 4 of 6: Select criteria to limit on › [%- ELSIF ( build5 ) -%]
38 Build a report, step 5 of 6: Pick which columns to total › [%- ELSIF ( build6 ) -%]
39 Build a report, step 6 of 6: Select how you want the report ordered › [%- END -%]
40 Guided reports wizard › Reports › Koha
43 [% INCLUDE 'doc-head-close.inc' %]
44 [% Asset.css("lib/codemirror/codemirror.min.css") | $raw %]
52 .cm-columnPlaceholder {
55 #mana_search_errortext {
56 font-family: monospace; font-weight: bold;
62 [% Asset.css("css/reports.css") | $raw %]
63 [% Asset.css("lib/d3c3/c3.min.css") | $raw %]
66 <body id="rep_guided_reports_start" class="rep">
67 [% WRAPPER 'header.inc' %]
68 [% INCLUDE 'circ-search.inc' %]
71 [% WRAPPER 'sub-header.inc' %]
72 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
75 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
78 <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
81 <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
86 <a href="#" aria-current="page">
90 [% ELSIF ( create ) %]
92 <a href="#" aria-current="page">
96 [% ELSIF ( showsql ) %]
98 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a>
101 <a href="#" aria-current="page">
102 [% reportname | html %] ([% id | html %])
105 [% ELSIF ( editsql ) %]
107 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a>
110 <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | uri %]&phase=Show%20SQL">[% reportname | html %] ([% id | html %])</a>
113 <a href="#" aria-current="page">
117 [% ELSIF ( execute ) %]
119 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a>
122 <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | uri %]&phase=Show%20SQL">[% name | html %] ([% id | html %])</a>
125 <a href="#" aria-current="page">
129 [% ELSIF ( build1 || build2 || build3 || build4 || build5 || build6 ) %]
131 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a report</a>
134 <a href="#" aria-current="page">
136 <span>Step 1 of 6: Choose a module</span>
137 [% ELSIF ( build2 ) %]
138 <span>Step 2 of 6: Pick a report type</span>
139 [% ELSIF ( build3 ) %]
140 <span>Step 3 of 6: Select columns for display</span>
141 [% ELSIF ( build4 ) %]
142 <span>Step 4 of 6: Select criteria to limit on</span>
143 [% ELSIF ( build5 ) %]
144 <span>Step 5 of 6: Pick which columns to total</span>
145 [% ELSIF ( build6 ) %]
146 <span>Step 6 of 6: Select how you want the report ordered</span>
151 </nav> <!-- /#breadcrumbs -->
154 <div id="update_sql" class="modal" tabindex="-1" role="dialog" aria-labelledby="update_sql_label" aria-hidden="true">
155 <div class="modal-dialog">
156 <div class="modal-content">
157 <div class="modal-header">
158 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
159 <h3 id="update_sql_label">Update SQL</h3>
161 <div class="modal-body">
162 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
164 <div class="modal-footer">
165 <a href="#" class="btn btn-default" id="update_sql_button" role="button" data-toggle="modal">Update</a>
166 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
168 </div> <!-- /.modal-content -->
169 </div> <!-- /.modal-dialog -->
170 </div> <!-- #update_sql -->
172 <div class="main container-fluid">
174 <div class="col-sm-10 col-sm-push-2">
177 [% INCLUDE "reports-toolbar.inc" %]
180 <h1>Guided reports</h1>
181 <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>
183 <h3>Build and run reports</h3>
185 [% IF ( CAN_user_reports_create_reports ) %]
186 <form action="/cgi-bin/koha/reports/guided_reports.pl">
187 <input type="hidden" name="phase" value="Build new" />
188 <input type="submit" name="submit" class="btn btn-primary" value="Build new" />
192 [% IF ( CAN_user_reports_execute_reports ) %]
193 <form action="/cgi-bin/koha/reports/guided_reports.pl">
194 <input type="hidden" name="phase" value="Use saved"/>
195 <input type="submit" name="submit" class="btn btn-primary" value="Use saved" />
199 [% IF ( CAN_user_reports_create_reports ) %]
200 <form action="/cgi-bin/koha/reports/guided_reports.pl">
201 <input type="hidden" name="phase" value="Create report from SQL"/>
202 <input type="submit" name="submit" class="btn btn-primary" value="Create report from SQL" />
206 <h3>Reports Dictionary</h3>
207 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
208 <form action="/cgi-bin/koha/reports/dictionary.pl">
209 <input type="hidden" name="phase" value="View Dictionary"/>
210 <input type="submit" name="submit" class="btn btn-primary" value="View dictionary" />
212 [% END # /IF (start) %]
214 [% IF report_converted %]
215 <div class="dialog message">
216 The report "[% report_converted | html %]" has been converted.
220 [% IF report_converted %]
221 <div class="dialog message">
222 The report "[% report_converted | html %]" has been converted.
227 <h1>Saved reports</h1>
228 [% IF ( savedreports ) %]
230 [% IF ( filters.date || filters.author || filters.keyword ) %]
232 <span class="filter">
233 [% IF ( filters.date ) %]
234 <span class="filter_date"><strong>Date:</strong> [% filters.date | html %]</span>
236 [% IF ( filters.author ) %]
237 <span class="filter_author"><strong>Author:</strong> [% filters.author | html %]</span>
239 [% IF ( filters.keyword ) %]
240 <span class="filter_keyword"><strong>Keyword:</strong> [% filters.keyword | html %]</span>
242 <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>
247 <div id="tabs" class="toptabs">
248 <ul class="nav nav-tabs" role="tablist">
249 <li role="presentation" class="active">
250 <a href="#reports" aria-controls="reports" role="tab" data-toggle="tab">All</a>
252 [% FOREACH group IN groups_with_subgroups %]
253 <li role="presentation">
254 <a id="[% group.id | html %]" href="#reports" aria-controls="reports" role="tab" data-toggle="tab">[% group.name | html %]</a>
259 <div class="tab-content">
260 <div id="reports" role="tabpanel" class="tab-pane active">
261 <div id="subgroup_filter_block">
262 <label for="subgroup_filter">Subgroup:</label>
263 <select id="subgroup_filter">
264 <option value="">All</option>
268 [% IF (Koha.Preference('Mana') == 1) %]
270 <div id="mana_search_message" class="dialog message">
271 <p> [% manamsg | html %] </p>
276 <form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
277 <input type="hidden" name="phase" value="Delete Multiple" />
278 <table id="table_reports">
281 <th class="NoSort"> </th>
289 <th>Creation date</th>
292 <th class="report_public">Public</th>
293 <th class="report_json_url">JSON URL</th>
295 <th>Cache expiry (seconds)</th>
297 <th class="NoVisible">Cache expiry (seconds)</th>
299 <th>Saved results</th>
300 [% IF has_obsolete_reports %]
303 <th class="NoVisible">Update</th>
305 <th class="NoSort noExport">Actions</th>
309 [% FOREACH savedreport IN savedreports %]
310 [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
311 <td class="report_checkbox">
312 [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
313 <input type="checkbox" name="ids" id="ids[% savedreport.id | html %]" value="[% savedreport.id | html %]" />
315 <input type="hidden" class="report_sql" value="[% savedreport.savedsql |html %]">
317 <td class="report_id">
318 <label for="ids[% savedreport.id | html %]">[% savedreport.id | html %]</label>
320 <td class="report_name">
321 [% IF ( savedreport.report_name ) %]
322 [% savedreport.report_name | html %]
327 <td class="report_type">
328 [% savedreport.type | html %]
330 <td class="report_group">
331 [% savedreport.groupname | html %]
334 [% savedreport.subgroupname | html %]
336 <td class="report_notes">
337 [% savedreport.notes | html %]
340 [%- savedreport.borrowersurname | html -%][%- IF ( savedreport.borrowerfirstname ) -%], [%- savedreport.borrowerfirstname | html -%][%- END -%]
341 ([% savedreport.borrowernumber | html %])
343 <td data-order="[% savedreport.date_created | html %]">
344 [% savedreport.date_created | $KohaDates %]
346 <td data-order="[% savedreport.last_modified | html %]">
347 [% savedreport.last_modified | $KohaDates with_hours => 1 %]
349 <td data-order="[% savedreport.last_run | html %]">
350 [% savedreport.last_run | $KohaDates with_hours => 1 %]
352 <td class="report_public">
353 [% IF (savedreport.public) %]
359 <td class="report_json_url">
360 [% IF (savedreport.public) %]
361 <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>
363 <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>
367 [% savedreport.cache_expiry | html %]
370 [% FOR result IN savedreport.results %]
371 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=[% result.id | uri %]">[% result.date_run | html %]</a>
376 [% IF savedreport.seems_obsolete %]
377 This report seems obsolete, it uses biblioitems.marcxml field.
378 <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>
382 <div class="btn-group dropup">
383 [%# There should be no space between these two buttons, it would render badly %]
384 <a class="btn btn-default btn-xs" role="button"
385 href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&phase=Run%20this%20report"><i
386 class="fa fa-play"></i> Run</a><a
387 class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown"
388 href="#"><b class="caret"></b></a>
389 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
390 <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>
392 <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL" class="preview_sql" data-reportid="[% savedreport.id | html %]">
393 <i class="fa fa-eye"></i> Preview SQL
396 [% IF ( CAN_user_reports_create_reports ) %]
397 <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>
398 <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>
400 [% IF (Koha.Preference('Mana') == 1) %]
401 <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>
403 <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
404 [% IF ( CAN_user_reports_delete_reports ) %]
405 <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>
409 <input type="hidden" id="previewSql[% savedreport.id | html %]" value="[% savedreport.savedsql | html %]" data-title="[% savedreport.report_name | html %]" />
416 [% IF ( CAN_user_reports_delete_reports ) %]
417 <fieldset class="action">
418 <input type="submit" class="btn btn-primary" value="Delete selected" />
422 </div> <!-- /#reports -->
423 </div> <!-- /.tab-content -->
425 [% ELSE # IF ( savedreports ) %]
426 <div class="dialog message">
427 [% IF (filter_set || filters.date || filters.author || filters.keyword) %]
428 <h4>No saved reports match your criteria. </h4>
429 [% IF ( CAN_user_reports_create_reports ) %]
430 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
431 <input type="hidden" name="phase" value="Build new" />
432 <button type="submit" class="new"><i class="fa fa-plus"></i> New guided report</button>
435 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
436 <input type="hidden" name="phase" value="Create report from SQL" />
437 <button type="submit" class="new"><i class="fa fa-plus"></i> New SQL report</button>
440 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
441 <input type="hidden" name="phase" value="Use saved" />
442 <input type="hidden" name="filter_set" value="1" />
443 <input type="hidden" name="filter_keyword" value="" />
444 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> Cancel filter</button>
448 <h4>There are no saved reports. </h4>
449 [% IF ( CAN_user_reports_create_reports ) %]
450 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a new report?</a>
452 [% END # IF (filter_set || filters.date || filters.author || filters.keyword) %]
453 </div> <!-- /.dialog.message -->
454 [% END # /IF ( savedreports ) %]
455 [% END # /IF ( saved1 ) %]
457 [% INCLUDE 'mana/mana-share-report.inc' %]
460 [% IF ( cache_error) %]
461 <div class="dialog alert">
462 <strong> Please choose a cache_expiry less than 30 days </strong>
466 <h1>Build a report</h1>
467 <form action="/cgi-bin/koha/reports/guided_reports.pl">
468 <fieldset class="rows">
469 <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and choose report visibility </legend>
472 <label for="area">Choose: </label>
473 <select name="area" id="area">
474 [%- FOREACH area IN areas -%]
475 <option value="[% area | html %]">[%- PROCESS area_name area=area -%]</option>
481 <label for="public">Report is public:</label>
482 <select id="public" name="public">
483 <option value="0">No (default)</option>
484 <option value="1" selected="selected">Yes</option>
489 <label for="public">Report is public:</label>
490 <select id="public" name="public">
491 <option value="0" selected="selected">No (default)</option>
492 <option value="1">Yes</option>
499 <label for="cache_expiry">Cache expiry:</label>
500 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
501 <select id="cache_expiry_units" name="cache_expiry_units">
502 <option value="seconds">Seconds (default)</option>
503 <option value="minutes">Minutes</option>
504 <option value="hours">Hours</option>
505 <option value="days">Days</option>
510 </fieldset> <!-- /.rows -->
511 <fieldset class="action">
512 <input type="hidden" name="phase" value="Report on this Area" />
513 <input type="submit" name="submit" value="Next >>" />
519 <h1>Build a report</h1>
520 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
521 <input type="hidden" name="area" value="[% area | html %]" />
522 <input type="hidden" name="public" value="[% public | html %]" />
523 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
524 <fieldset class="rows">
525 <legend>Step 2 of 6: Pick a report type</legend>
528 <label for="types">Choose: </label>
529 <select id="types" name="types">
530 <option value="1">Tabular</option>
531 <option value="2" disabled="disabled">Summary</option>
532 <option value="3" disabled="disabled">Matrix</option>
538 <fieldset class="action">
539 <input type="hidden" name="phase" value="Choose this type" />
540 <input type="button" name="back" value="<< Back" class="goback" />
541 <input type="submit" name="submit" value="Next >>" />
544 [% END # /IF (build2 ) %]
547 <h1>Build a report</h1>
548 <h3>Step 3 of 6: Select columns for display</h3>
549 <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>
551 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
552 <input type="hidden" name="area" value="[% area | html %]" />
553 <input type="hidden" name="type" value="[% type | html %]" />
554 <input type="hidden" name="public" value="[% public | html %]" />
555 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
558 <div class="col-sm-6">
559 <div style="float: left;">
560 <select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
561 [% FOREACH column IN columns %]
562 [% IF ( column.table ) %]
563 [% IF ( loop.first ) %]
567 <optgroup label="[% column.table | html %]">
569 <option value="[% column.name | html %]">
570 [% IF ( column.description ) %]
571 [% column.description | html %] / [% column.name | html %]
573 [% column.name | html %]
581 <div style="width: 6.3em; float: right; margin-top: 100px">
582 <input type="button" name="Add" value="Add" class="button" style="width:6em;" id="addColumn" /><br />
583 <input type="button" name="delete" value="<< Delete" class="button" style="width: 6em; margin: 1em 0;" id="delColumn" />
585 </div> <!-- /.col-sm-6 -->
587 <div class="col-sm-6">
588 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;">
591 </div> <!-- /.row -->
593 <fieldset class="action">
594 <input type="hidden" name="phase" value="Choose these columns" />
595 <input type="button" name="back" value="<< Back" class="goback" />
596 <input type="submit" name="submit" value="Next >>" />
598 </form> <!-- /#column_submit -->
599 [% END # /IF ( build3 ) %]
602 <h1>Build a report</h1>
603 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
604 <input type="hidden" name="area" value="[% area | html %]" />
605 <input type="hidden" name="type" value="[% type | html %]" />
606 <input type="hidden" name="column" value="[% column | html %]" />
607 <input type="hidden" name="public" value="[% public | html %]" />
608 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
610 <legend>Step 4 of 6: Select criteria to limit on</legend>
612 [% FOREACH criteri IN criteria %]
615 <input type="checkbox" name="criteria_column" id="[% criteri.name | html %]" value="[% criteri.name | html %]" />
616 <label for="[% criteri.name | html %]">[% criteri.description | html %] </label>
618 [% IF ( criteri.date ) %]
620 <input type="text" size="10" id="[% criteri.name | html %]_value" name="[% criteri.name | html %]_value" value="" class="flatpickr" />
621 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
625 [% IF ( criteri.textrange ) %]
628 <input type="text" size="10" id="[% criteri.from | html %]_value" name="[% criteri.from | html %]_value" value="" /> to
629 <input type="text" size="10" id="[% criteri.to | html %]_value" name="[% criteri.to | html %]_value" value="" />
633 [% IF ( criteri.daterange ) %]
636 <input type="text" size="10" id="from_[% criteri.name.remove('\.') | html %]_value" name="from_[% criteri.name | html %]_value" value="" data-date_to="to_[% criteri.name.remove('\.') | html %]_value" class="flatpickr" />
638 <input type="text" size="10" id="to_[% criteri.name.remove('\.') | html %]_value" name="to_[% criteri.name | html %]_value" value="" class="flatpickr" />
639 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
644 <select name="[% criteri.name | html %]_value">
645 [% FOREACH value IN criteri.values %]
646 <option value="[% value.availablevalues | html %]">
647 [% IF ( value.default ) %]
650 [% value.display_value | html %]
664 [% IF ( definitions ) %]
666 <legend>Dictionary definitions</legend>
668 [% FOREACH definition IN definitions %]
671 <input type="checkbox" name="definition" value="[% definition.id | html %]" />
672 [% definition.name | html %]
680 <fieldset class="action">
681 <input type="hidden" name="phase" value="Choose these criteria" />
682 <input type="button" name="back" value="<< Back" class="goback" />
683 <input type="submit" name="submit" value="Next >>" />
686 [% END # /IF ( build4 ) %]
689 <h1>Build a report</h1>
690 <h3>Step 5 of 6: Pick which columns to total</h3>
691 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
692 <input type="hidden" name="area" value="[% area | html %]" />
693 <input type="hidden" name="type" value="[% type | html %]" />
694 <input type="hidden" name="column" value="[% column | html %]" />
695 <input type="hidden" name="definition" value="[% definition | html %]" />
696 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
697 <input type="hidden" name="public" value="[% public | html %]" />
698 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
701 [% FOREACH total_b IN total_by %]
704 <input type="checkbox" name="total_by" id="[% total_b.name | html %]" value="[% total_b.name | html %]" />
705 <label for="[% total_b.name | html %]">[% total_b.name | html %]</label>
708 <select name="[% total_b.name | html %]_tvalue">
709 [% FOREACH selec IN total_b.select %]
710 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
719 <fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
720 <input type="button" name="back" value="<< Back" class="goback" />
721 <input type="submit" name="submit" value="Next >>" />
724 [% END # /IF ( build5 ) %]
727 <h1>Build a report</h1>
728 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
729 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
730 <input type="hidden" name="area" value="[% area | html %]" />
731 <input type="hidden" name="type" value="[% type | html %]" />
732 <input type="hidden" name="column" value="[% column | html %]" />
733 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
734 <input type="hidden" name="definition" value="[% definition | html %]" />
735 <input type="hidden" name="totals" value="[% totals | html %]" />
736 <input type="hidden" name="public" value="[% public | html %]" />
737 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
740 [% FOREACH order_b IN order_by %]
743 <input type="checkbox" id="[% order_b.name | html %]" name="order_by" value="[% order_b.name | html %]" />
744 <label for="[% order_b.name | html %]">[% order_b.name | html %]</label>
747 <select name="[% order_b.name | html %]_ovalue">
748 [% FOREACH selec IN order_b.select %]
749 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
757 <fieldset class="action">
758 <input type="hidden" name="phase" value="Build report" />
759 <input type="submit" name="submit" class="btn btn-primary" value="Finish" />
762 [% END #/ IF ( build6 ) %]
764 [% IF ( showreport ) %]
765 <h1>Confirm custom report</h1>
766 <p>Your report will be generated with the following SQL statement.</p>
771 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
772 <input type="hidden" name="sql" value="[% sql | html %]" />
773 <input type="hidden" name="type" value="[% type | html %]" />
774 <input type="hidden" name="public" value="[% public | html %]" />
775 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
776 <p>You will need to save the report before you can execute it</p>
777 <fieldset class="action"><input type="hidden" name="phase" value="Save" />
778 <input type="submit" name="submit" class="btn btn-primary" value="Next" />
781 [% END #/ IF ( showreport ) %]
784 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
785 <input type="hidden" name="sql" value="[% sql | html %]" />
786 <input type="hidden" name="type" value="[% type | html %]" />
787 <input type="hidden" name="area" value="[% area | html %]" />
788 <input type="hidden" name="public" value="[% public | html %]" />
789 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
790 <fieldset class="rows">
791 <legend><h1>Save your custom report</h1></legend>
794 <label for="reportname" class="required">Report name: </label>
795 <input type="text" id="reportname" name="reportname" class="required" required="required" />
796 <span class="required">Required</span>
798 [% PROCESS group_and_subgroup_selection %]
800 <label for="notes">Notes:</label>
801 <textarea name="notes" id="notes"></textarea>
805 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
806 <input type="submit" name="submit" class="btn btn-primary" value="Save report" />
809 [% END # /IF( save ) %]
811 [% IF ( warn_authval_problem ) %]
812 <div class="dialog alert">
813 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
814 [% FOREACH problematic_authval IN problematic_authvals %]
816 <strong>[% problematic_authval.name | html %]:</strong> The authorized value category (<strong>[% problematic_authval.authval | html %]</strong>)
817 you selected does not exist.
820 <!-- Save Anyway Form -->
821 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
822 <!--Every parameter the user issued is provided as a hidden field for recovery-->
823 <input type='hidden' name='id' value='[% id | html %]' />
824 <input type='hidden' name='sql' value='[% sql | html %]' />
825 <input type='hidden' name='reportname' value='[% reportname | html %]' />
826 <input type='hidden' name='group' value='[% group | html %]' />
827 <input type='hidden' name='subgroup' value='[% subgroup | html %]' />
828 <input type='hidden' name='notes' value='[% notes | html %]' />
829 <input type='hidden' name='cache_expiry' value='[% cache_expiry | html %]' />
830 <input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units | html %]' />
831 <input type='hidden' name='public' value='[% public | html %]' />
832 [% IF ( phase_update) %]
833 <input type='hidden' name='phase' value='Update SQL' />
834 <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
835 [% ELSIF ( phase_save) %]
836 <input type='hidden' name='area' value='[% area | html %]' />
837 <input type='hidden' name='phase' value='Save Report' />
838 <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
841 <!-- Go back to editing -->
842 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
843 <button type="button" class="new goback"><i class="fa fa-fw fa-pencil"></i> Edit SQL</button>
846 [% END # /IF ( warn_authval_problem )%]
848 [% IF ( enter_params ) %]
849 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
850 <input type='hidden' name='reports' value="[% reports | html %]" />
851 [% IF ( auth_val_error ) %]
852 <input type='hidden' name='phase' value='Edit SQL' />
853 <div class="dialog alert">
854 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
855 [% FOREACH auth_val_error IN auth_val_errors %]
857 <strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
858 you selected does not exist.
862 <fieldset class="action"><input type="submit" class="btn btn-primary" value="Edit SQL" /></fieldset>
863 [% ELSE # IF ( auth_val_error ) %]
864 <input type='hidden' name='phase' value='Run this report' />
865 <h1>Enter parameters for report [% name | html %]:</h1>
867 <p>[% notes | html %]</p>
869 <fieldset class="rows">
871 [% FOREACH sql_param IN sql_params %]
872 <input name="param_name" value="[% sql_param.name | html %]" type="hidden" />
873 [% IF sql_param.input == 'date' %]
875 <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="flatpickr" />
877 [% ELSIF ( sql_param.input == 'text' ) %]
879 <label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label>
880 <input id="sql_params[% loop.count | html %]" type="text" name="sql_params" />
882 [% ELSIF ( sql_param.input == 'textarea' ) %]
884 <label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label>
885 <textarea id="sql_params[% loop.count | html %]" name="sql_params" rows="5"></textarea>
889 <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
890 <select name="[%- sql_param.input.name | html -%]" tabindex="1" id="[%- sql_param.input.id | html -%]">
891 [% IF (sql_param.include_all) %]
892 <option value="%">All</option>
894 [% FOREACH value IN sql_param.input.values %]
895 <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
899 [% END # /IF sql_param.input == 'date' %]
900 [% END # /FOREACH sql_param %]
902 </fieldset> <!-- /.rows -->
903 <fieldset class="action">
904 <input type="submit" class="btn btn-primary" value="Run the report" />
906 [% END # / IF ( auth_val_error ) %]
908 [% END # /IF ( enter_params ) %]
911 <h1>[% name | html %] <span class="report_heading_id"><span class="report_label">Report ID:</span> <span class="report_number">[% id | html %]</span></span></h1>
912 <div class="page-section">
914 <p><span class="label">Notes:</span> [% notes | html %]</p>
916 [% IF ( unlimited_total ) %]
918 <span class="label">Total number of results:</span>
919 [% unlimited_total | html %]
920 [% IF unlimited_total >= limit %]
921 ([% results.size | html %] shown)
926 <div id="sql_output" style="display:none;">
927 <span class="label">Report SQL:</span>
928 <textarea id="sql" readonly="readonly">[% sql | html %]</textarea>
932 <a href="#" id="toggle_chart_settings_hid" class="toggle_chart_settings" style="display:none"><i class="fa fa-eye-slash"></i> Hide chart</a>
933 <a href="#" id="toggle_chart_settings_vis" class="toggle_chart_settings" style="display:none"><i class="fa fa fa-eye"></i> Show chart</a>
935 <div id="chart" class="clearfix"></div>
938 [% UNLESS ( errors ) %]
939 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl" id="batch_record_modification">
940 <input type="hidden" name="recordtype" value="biblio" />
941 <input type="hidden" name="op" value="list" />
942 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
943 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">
944 [%- recordnumbers = PROCESS batch_list results=results batch_type='biblionumber' | trim | html %][% IF recordnumbers %][% SET batch_biblionumbers = 1 %][% recordnumbers | html %][% END -%]
948 <form method="POST" action="/cgi-bin/koha/tools/batch_delete_records.pl" id="batch_record_deletion">
949 <input type="hidden" name="recordtype" value="biblio" />
950 <input type="hidden" name="op" value="list" />
951 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
952 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">
953 [%- recordnumbers = PROCESS batch_list results=results batch_type='biblionumber' | trim | html %][% IF recordnumbers %][% SET batch_biblionumbers = 1 %][% recordnumbers | html %][% END -%]
957 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_modification">
958 <input type="hidden" name="op" value="show" />
959 [% FOREACH result IN results %]
960 [% FOREACH cells IN result.cells %]
961 [% place = loop.index %]
962 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
963 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
964 [% SET batch_itemnumbers = 1 %]
965 [% SET header_row.$place.has_itemnumbers = 1 %]
966 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
972 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_deletion">
973 <input type="hidden" name="op" value="show" />
974 <input type="hidden" name="del" value="1" />
975 [% FOREACH result IN results %]
976 [% FOREACH cells IN result.cells %]
977 [% place = loop.index %]
978 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
979 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
980 [% SET batch_itemnumbers = 1 %]
981 [% SET header_row.$place.has_itemnumbers = 1 %]
982 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
988 <form method="get" action="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl" id="batch_add_to_list">
989 [% FOREACH result IN results %]
990 [% FOREACH cells IN result.cells %]
991 [% place = loop.index %]
992 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
993 [% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
994 [% SET batch_biblionumbers = 1 %]
995 [% SET header_row.$place.has_biblionumbers = 1 %]
996 <input type="hidden" class="bib_to_list" name="biblionumber" value="[% cells.cell | html %]" />
1002 <form method="POST" action="/cgi-bin/koha/tools/modborrowers.pl" id="batch_patron_modification">
1003 <input type="hidden" name="op" value="show" />
1004 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
1005 <textarea style="display:none" name="cardnumberlist" id="cardnumberlist">
1006 [%- cardnumbers = PROCESS batch_list results=results batch_type='cardnumber' | trim | html %][% IF cardnumbers %][% SET batch_cardnumbers = 1 %][% cardnumbers | html %][% END -%]
1010 [% BLOCK batch_list %]
1011 [%- FOREACH result IN results %]
1012 [%- FOREACH cells IN result.cells %]
1013 [%- place = loop.index %]
1014 [%- IF header_row.$place.cell == batch_type || header_types.item(header_row.$place.cell) == batch_type %]
1015 [%# We must not add whitespace to the cardnumbers %][% cells.cell | html %]
1021 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
1022 <input type="hidden" name="phase" value="Run this report"/>
1023 <input type="hidden" name="reports" value="[% report_id | html %]"/>
1024 [% FOREACH p IN sql_params %]
1025 <input type="hidden" name="sql_params" value="[% p | html %]"/>
1027 [% FOREACH n IN param_names %]
1028 <input type="hidden" name="param_name" value="[% n | html %]"/>
1030 <input type="hidden" name="limit" id="limit" value="20" />
1031 </form> <!-- /#limitselect -->
1033 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) || ( unlimited_total > 10 && limit <= 1000 ) %]
1034 <div id="toolbar" class="btn-toolbar">
1035 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1036 <div class="btn-group">
1037 <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="batch_mod_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
1038 Batch operations with [% IF unlimited_total >= limit %][% limit | html %][% ELSE %][% unlimited_total | html %][% END %] visible records
1039 <span class="caret"></span>
1041 <ul class="dropdown-menu" aria-labelledby="batch_mod_menu">
1042 [% FOREACH header_ro IN header_row %]
1043 [% IF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
1044 <li class="dropdown-header">Bibliographic records</li>
1046 <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>
1049 <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>
1052 <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>
1055 [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
1056 <li class="dropdown-header">Item records</li>
1058 <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>
1061 <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>
1064 [% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
1065 <li class="dropdown-header">Patron records</li>
1067 <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>
1070 [% END # /FOREACH header_ro %]
1071 </ul> <!-- /.dropdown-menu -->
1072 </div> <!-- /.dropdown -->
1073 [% END # /IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1075 [% IF ( unlimited_total > 10 && limit <= 1000 ) %]
1076 <div class="btn-group">
1077 <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
1079 Rows per page: <strong>[% limit | html %]</strong>
1083 <span class="caret"></span>
1085 <ul class="dropdown-menu">
1086 [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
1087 [% FOREACH l IN limits %]
1090 <a class="limitselect" data-limit="[% l | html %]" href="#"><i class="fa fa-fw fa-check"></i> [% l | html %]</a>
1094 <a class="limitselect" data-limit="[% l | html %]" href="#"><i class="fa fa-fw"></i> [% l | html %]</a>
1100 [% END # /IF ( unlimited_total > 10 && limit <= 1000 ) %]
1102 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1103 <a href="#" class="btn btn-link" id="toggle_auto_links">
1104 <i class="fa fa-eye autolink" style="display:none"></i>
1105 <i class="fa fa-eye-slash autolink"></i>
1106 <span class="autolink" style="display:none">Show data menus</span>
1107 <span class="autolink">Hide data menus</span>
1110 </div> <!-- /#toolbar.btn-toolbar -->
1111 [% END # /IF batch operations || ( unlimited_total > 10 && limit <= 1000 ) %]
1114 [% pagination_bar | $raw %]
1117 [% END # UNLESS ( errors ) %]
1118 [% END # IF ( execute ) %]
1120 [% UNLESS ( errors ) %]
1121 <table id="report_results">
1124 [% FOREACH header_ro IN header_row %]
1125 [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
1126 <th class="itemnumber">[% header_ro.cell | html %]</th>
1127 [% ELSIF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
1128 <th class="biblionumber">[% header_ro.cell | html %]</th>
1129 [% ELSIF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
1130 <th class="cardnumber">[% header_ro.cell | html %]</th>
1131 [% ELSIF header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %]
1132 <th class="borrowernumber">[% header_ro.cell | html %]</th>
1134 <th>[% header_ro.cell | html %]</th>
1140 [% FOREACH result IN results %]
1142 [% FOREACH cells IN result.cells %]
1143 [% place = loop.index %]
1144 [%- IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
1145 <td class="batch-op itemnumber" data-number="itemnumber">
1146 <span class="data-plain">[% cells.cell | $raw %]</span>
1147 <div id="itemnumber_autolink" class="btn-group dropup autolink"><a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">[% cells.cell | $raw %] <b class="caret"></b></a>
1148 <ul class="dropdown-menu pull-right" role="menu">
1149 <li><a target="_blank" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&itemnumber=[% cells.cell | $raw %]"><i class="fa fa-fw fa-pencil"></i> Edit record</a></li>
1150 <li role="separator" class="divider"></li>
1151 <li><a target="_blank" href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% cells.cell | $raw %]"><i class="fa fa-fw fa-eye"></i> View record</a></li>
1155 [% ELSIF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
1156 <td class="batch-op biblionumber" data-number="biblionumber">
1157 <span class="data-plain">[% cells.cell | $raw %]</span>
1158 <div id="biblionumber_autolink" class="btn-group dropup autolink"><a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">[% cells.cell | $raw %] <b class="caret"></b></a>
1159 <ul class="dropdown-menu pull-right" role="menu">
1160 <li><a target="_blank" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% cells.cell | $raw %]"><i class="fa fa-pencil"></i> Edit record</a></li>
1161 <li role="separator" class="divider"></li>
1162 <li><a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cells.cell | $raw %]"><i class="fa fa-eye"></i> View record</a></li>
1166 [% ELSIF header_row.$place.cell == 'borrowernumber' || header_types.item(header_row.$place.cell) == 'borrowernumber' %]
1167 <td class="batch-op borrowernumber" data-number="borrowernumber">
1168 <span class="data-plain">[% cells.cell | $raw %]</span>
1169 <div id="borrowernumber_autolink" class="btn-group dropup autolink"><a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">[% cells.cell | $raw %] <b class="caret"></b></a>
1170 <ul class="dropdown-menu pull-right" role="menu">
1171 <li><a target="_blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% cells.cell | $raw %]"><i class="fa fa-eye"></i> View patron</a></li>
1172 <li role="separator" class="divider"></li>
1173 <li><a target="_blank" href="/cgi-bin/koha/members/memberentry.pl?op=modify&borrowernumber=[% cells.cell | $raw %]"><i class="fa fa-pencil"></i> Edit patron</a></li>
1174 <li role="separator" class="divider"></li>
1175 <li><a target="_blank" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% cells.cell | $raw %]"><i class="fa fa-barcode"></i> Check out</a></li>
1179 [% ELSIF header_row.$place.cell == 'cardnumber' || header_types.item(header_row.$place.cell) == 'cardnumber' %]
1180 <td class="batch-op cardnumber" data-number="cardnumber">
1181 <span class="data-plain">[% cells.cell | $raw %]</span>
1182 <div id="cardnumber_autolink" class="btn-group dropup autolink"><a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">[% cells.cell | $raw %] <b class="caret"></b></a>
1183 <ul class="dropdown-menu pull-right" role="menu">
1184 <li><a target="_blank" href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% cells.cell | $raw %]"><i class="fa fa-barcode"></i> Check out</a></li>
1190 [% cells.cell | $raw %]
1199 <div class="pages">[% pagination_bar | $raw %]</div>
1201 [% INCLUDE 'chart.inc' %]
1203 [% END #/IF ( execute ) %]
1206 <h1>Create from SQL</h1>
1207 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1208 <fieldset class="rows">
1209 <legend>Create report from SQL</legend>
1212 <label for="reportname" class="required">Report name:</label>
1213 [% IF ( reportname ) %]
1214 <input type="text" class="required" required="required" id="reportname" name="reportname" value="[% reportname | html %]" size="50"/>
1216 <input type="text" class="required focus" required="required" id="reportname" name="reportname" size="50" />
1218 <span class="required">Required</span>
1220 [% PROCESS group_and_subgroup_selection %]
1224 <label for="public">Report is public:</label>
1225 <select id="public" name="public">
1226 <option value="0">No (default)</option>
1227 <option value="1" selected="selected">Yes</option>
1232 <label for="public">Report is public:</label>
1233 <select id="public" name="public">
1234 <option value="0" selected="selected">No (default)</option>
1235 <option value="1">Yes</option>
1238 [% END # /IF (public) %]
1242 <label for="cache_expiry">Cache expiry:</label>
1243 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
1244 <select id="cache_expiry_units" name="cache_expiry_units">
1245 <option value="seconds" selected="selected">Seconds (default)</option>
1246 <option value="minutes">Minutes</option>
1247 <option value="hours">Hours</option>
1248 <option value="days">Days</option>
1251 [% END # /IF (usecache) %]
1253 <label for="notes">Notes:</label>
1254 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1257 </fieldset> <!-- /.rows -->
1259 <fieldset class="rows">
1260 <legend>SQL:</legend>
1261 <div style="margin:1em;">
1262 [% PROCESS insert_runtime_parameter %]
1263 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10" >[% sql | html %]</textarea>
1264 <span style='color:#383838; font-style:italic'>* In order to achieve auto-complete for columns, please prepend the column name with the table name, followed by a period. For example: 'borrowers.surname'</span>
1266 <span class="required">Required</span>
1270 <fieldset class="action">
1271 <input type="hidden" name="phase" value="Save Report" />
1272 <input type="submit" name="submit" class="btn btn-primary" value="Save report" />
1273 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1277 [% END #/IF ( create ) %]
1279 [% IF saved_results %]
1280 <h1>Saved report results</h1>
1281 <h2>[% name | html %]</h2>
1282 <p>[% notes | html %]</p>
1284 [% FOREACH rows IN saved_results %]
1286 [% FOREACH col IN rows %]
1287 <td>[% col | html %]</td>
1292 [% END # /IF saved_results %]
1294 [% IF ( showsql ) %]
1295 <h1>Saved reports - SQL</h1>
1296 <fieldset class="rows">
1297 <legend>[% reportname | html %]</legend>
1301 <span class="label">Notes:</span>
1307 <textarea id="sql">[% sql | html %]</textarea>
1311 [% END # /IF ( showsql ) %]
1313 [% IF ( save_successful ) %]
1314 [% UNLESS ( errors ) %]
1316 <div id="report_updated">
1317 <div class="dialog message">
1318 <p>Your report "[% reportname | html %]" has been saved</p>
1324 [% IF ( editsql ) %]
1325 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1326 <input type="hidden" name="phase" value="Update SQL" />
1327 <input type="hidden" name="id" value="[% id | html %]"/>
1328 <fieldset class="rows">
1329 <legend><h1>Edit SQL report</h1></legend>
1332 <label for="reportname" class="required">Report name: </label>
1333 <input type="text" id="reportname" name="reportname" value="[% reportname | html %]" size="50" class="required" required="required" />
1334 <span class="required">Required</span>
1336 [% PROCESS group_and_subgroup_selection %]
1339 <label for="public">Report is public:</label>
1340 <select id="public" name="public">
1341 <option value="0">No (default)</option>
1342 <option value="1" selected="selected">Yes</option>
1347 <label for="public">Report is public:</label>
1348 <select id="public" name="public">
1349 <option value="0" selected="selected">No (default)</option>
1350 <option value="1">Yes</option>
1353 [% END # /IF (public) %]
1357 <label for="cache_expiry">Cache expiry:</label>
1358 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]" />
1359 <select id="cache_expiry_units" name="cache_expiry_units">
1360 <option value="seconds">Seconds (default)</option>
1361 <option value="minutes">Minutes</option>
1362 <option value="hours">Hours</option>
1363 <option value="days">Days</option>
1368 <label for="notes">Notes:</label>
1369 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1372 </fieldset> <!-- /.rows -->
1374 <fieldset class="rows">
1375 <legend>SQL:</legend>
1376 [% PROCESS insert_runtime_parameter %]
1377 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea>
1378 <span style='color:#383838; font-style:italic'>* In order to achieve auto-complete for columns, please prepend the column name with the table name, followed by a period. For example: 'borrowers.surname'</span>
1380 <span class="required" style="margin-left:30px;">Required</span>
1383 <fieldset class="action">
1384 <input type="submit" name="submit" class="btn btn-primary" value="Update SQL" />
1385 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1388 [% END # /IF ( editsql ) %]
1391 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
1392 <div class="dialog alert">
1393 <strong>The following error was encountered:</strong><br />
1394 [% FOREACH error IN errors %]
1395 [% IF ( error.sqlerr ) %]
1396 This report contains the SQL keyword <strong>[% error.sqlerr | html %]</strong>.<br />
1397 Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.<br />
1398 Please return to the "Saved Reports" screen and delete this report or retry creating a new one.
1399 [% ELSIF ( error.queryerr ) %]
1400 <span>The database returned the following error:</span> <br />
1401 [% error.queryerr | html %]<br />Please check the log for further details.
1402 [% ELSIF ( error.cache_expiry ) %]
1403 Please select a cache expiry less than 30 days.
1406 <div id="onerror_actions">
1407 <a href="#" class="button goback">Return to previous page</a>
1411 <fieldset class="action">
1412 <input type="hidden" name="phase" value="Use saved" />
1413 <input type="submit" name="submit" class="btn btn-primary" value="Saved reports" />
1416 [% END # /IF ( errors ) %]
1419 </div> <!-- /.col-sm-10.col-sm-push-2 -->
1421 <div class="col-sm-2 col-sm-pull-10">
1424 <div id="saved-reports-filter">
1425 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
1426 <input type="hidden" name="phase" value="Use saved" />
1427 <input type="hidden" name="filter_set" value="1" />
1428 <fieldset class="brief">
1432 <label for="filter_date">Date:</label>
1433 <input type="text" id="filter_date" name="filter_date" size="10" value="[% filters.date | html %]" class="flatpickr" />
1434 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
1437 <label for="filter_author">Author:</label>
1438 <input type="text" id="filter_author" name="filter_author" value="[% filters.author | html %]" size="16" />
1441 <label for="filter_keyword">Keyword:</label>
1442 <input type="text" id="filter_keyword" name="filter_keyword" value="[% filters.keyword | html %]" size="16" />
1445 </fieldset> <!-- /.brief -->
1446 <fieldset class="action">
1447 <input type="submit" class="btn btn-primary" value="Apply filter" />
1448 <a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1">Clear</a>
1451 </div> <!-- /#saved-reports-filter -->
1453 [% INCLUDE 'guided-reports-view.inc' %]
1455 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1456 </div> <!-- /.row -->
1458 <!-- Runtime Parameters Modal -->
1459 <div class="modal" id="runtime_parameters" tabindex="-1" role="dialog" aria-labelledby="runtime_parametersLabel">
1460 <div class="modal-dialog" role="document">
1461 <div class="modal-content">
1462 <div class="modal-header">
1463 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
1464 <h4 class="modal-title" id="runtime_parametersLabel">Runtime parameter options</h4>
1466 <form id="send_runtime_parameter">
1467 <input type="hidden" name="param_category" id="param_category" />
1468 <div class="modal-body">
1469 <div class="form-group">
1470 <label for="paramLabel" class="required">Parameter label: </label>
1471 <input class="form-control required" type="text" name="paramLabel" id="paramLabel" required="required" />
1472 <div class="hint">The label for the field shown when the report is run, e.g. "Select a library."</div>
1474 <div id="authorised_value_category" class="form-group" style="display:none">
1475 <label for="authorised_value">Authorized value category:</label>
1476 <select class="form-control" name="authorised_value" id="authorised_value">
1477 <option value=""></option>
1478 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories() %]
1480 <div class="hint">Select which authorized value category the user will choose from.</div>
1482 </div> <!-- /.modal-body -->
1483 <div class="modal-footer">
1484 <button type="submit" id="sendParam" class="btn btn-default approve">Insert parameter</button>
1485 <button type="button" class="btn btn-default deny" data-dismiss="modal">Cancel</button>
1486 </div> <!-- /.modal-footer -->
1487 </form> <!-- /#send_runtime_parameter -->
1488 </div> <!-- /.modal-content -->
1489 </div> <!-- /.modal-dialog -->
1490 </div> <!-- /#runtime_parameters -->
1492 [% MACRO jsinclude BLOCK %]
1493 [% Asset.js("js/charts.js") | $raw %]
1494 [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
1495 [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
1496 [% INCLUDE 'calendar.inc' %]
1497 [% INCLUDE 'datatables.inc' %]
1499 [% INCLUDE 'columns_settings.inc' %]
1501 [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
1502 [% Asset.js( "lib/codemirror/overlay.min.js" ) | $raw %]
1503 [% Asset.js( "lib/codemirror/sql.js" ) | $raw %]
1504 [% Asset.js( "lib/codemirror/show-hint.js" ) | $raw %]
1505 [% Asset.css("lib/codemirror/show-hint.css") | $raw %]
1506 [% Asset.js( "lib/codemirror/sql-hint.js" ) | $raw %]
1507 [% Asset.js( "lib/codemirror/highlight.js" ) | $raw %]
1508 [% Asset.css("lib/codemirror/highlight.css") | $raw %]
1509 [% Asset.js( "js/mana.js" ) | $raw %]
1513 function hide_bar_element() {
1514 $('#chart-column-horizontal').hide()
1515 $('.chart-column-group').each(function( index ) {
1518 $('.chart-column-line').each(function( index ) {
1523 function show_bar_element() {
1524 $('#chart-column-horizontal').show()
1525 $('.chart-column-group').each(function( index ) {
1528 $('.chart-column-line').each(function( index ) {
1533 function removeColumn(id) {
1536 if ( $('.chart-column-conf').length == 1 ) {
1537 $('.chart-column-delete').remove();
1541 var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1542 var group_subgroups = {};
1543 [% FOREACH group IN groups_with_subgroups %]
1544 var gid = "[% group.id | html %]"
1545 group_subgroups[gid] = new Array();
1546 [% FOREACH subgroup IN group.subgroups %]
1547 var sgid = "[% subgroup.id | html %]";
1548 var sgname = "[% subgroup.name | html %]";
1549 group_subgroups[gid].push([sgid, sgname]);
1553 [% IF ( create || editsql || save ) %]
1555 var editor = CodeMirror.fromTextArea(sql, {
1560 keyword: { // Custom highlighting for items bounded in [[ ]] or << >>.
1561 "\\[\\[(.*?)\\]\\]":"style1",
1562 "<<(.*?)>>":"style1"
1564 extraKeys: {"Tab": "autocomplete"}, //enable tab to accept auto-complete
1565 hint: CodeMirror.hint.sql,
1567 tables: [% To.json(tables) | $raw %]
1570 var ExcludedTriggerKeys = { //key-code combinations of keys that will not fire the auto-complete script
1593 "91": "left window key",
1594 "92": "right window key",
1599 "110": "decimal point",
1614 "145": "scrolllock",
1620 "192": "graveaccent",
1624 //Trigger auto-complete on all keys not in dictionary of exclusions above.
1625 editor.on("keyup", function(cm, e) {
1626 if (ExcludedTriggerKeys[e.keyCode] == undefined) {
1627 CodeMirror.commands.autocomplete(editor, null, { completeSingle: false });
1631 // https://stackoverflow.com/questions/2086287/how-to-clear-jquery-validation-error-messages#answer-16025232
1632 function clearValidation( formElement ){
1633 // formElement should be a jQuery object
1634 var validator = formElement.validate();
1635 // Iterate through named elements inside of the form, and mark them as error free
1636 $('[name]',formElement).each(function(){
1637 validator.successList.push(this);//mark as error free
1638 validator.showErrors();//remove error messages if present
1640 validator.resetForm();//remove error class on name elements and clear history
1641 validator.reset();//remove all error and success data
1645 [% IF ( showsql ) %]
1647 var editor = CodeMirror.fromTextArea(sql, {
1652 keyword: { // Custom highlighting for items bounded in [[ ]] or << >>.
1653 "\\[\\[(.*?)\\]\\]":"style2",
1654 "<<(.*?)>>":"style1"
1659 function showParamModal( category ){
1660 var modal = $("#runtime_parameters");
1661 var modalTitle = $("#runtime_parametersLabel");
1662 switch ( category ){
1663 case "insertAuthVal":
1664 modalTitle.text( _("Insert authorized value parameter") );
1665 $("#paramLabel").val( _("Authorized value") );
1666 $("#authorised_value_category").show();
1667 $("label[for='authorised_value']").addClass("required");
1668 $("#authorised_value").prop("required", true ).attr("required", "required").addClass("required");
1670 case "insertCnSource":
1671 modalTitle.text( _("Insert classification source parameter") );
1672 $("#paramLabel").val( _("Source of classification or shelving scheme") );
1673 $("#param_category").val("cn_source");
1675 case "insertFramework":
1676 modalTitle.text( _("Insert bibliographic framework parameter") );
1677 $("#paramLabel").val( _("Framework") );
1678 $("#param_category").val("biblio_framework");
1681 modalTitle.text( _("Insert date parameter") );
1682 $("#paramLabel").val( _("Date") );
1683 $("#param_category").val("date");
1685 case "insertItemtypes":
1686 modalTitle.text( _("Insert item types parameter") );
1687 $("#paramLabel").val( _("Item type") );
1688 $("#param_category").val("itemtypes");
1690 case "insertBranches":
1691 modalTitle.text( _("Insert libraries parameter") );
1692 $("#paramLabel").val( _("Library") );
1693 $("#param_category").val("branches");
1695 case "insertCategorycode":
1696 modalTitle.text( _("Insert patron category parameter") );
1697 $("#paramLabel").val( _("Patron category") );
1698 $("#param_category").val("categorycode");
1700 case "insertCashregister":
1701 modalTitle.text( _("Insert cash register parameter") );
1702 $("#paramLabel").val( _("Cash register") );
1703 $("#param_category").val("cash_registers");
1705 case "insertDebittypes":
1706 modalTitle.text( _("Insert debit type parameter") );
1707 $("#paramLabel").val( _("Debit type") );
1708 $("#param_category").val("debit_types");
1710 case "insertCredittypes":
1711 modalTitle.text( _("Insert credit type parameter") );
1712 $("#paramLabel").val( _("Credit type") );
1713 $("#param_category").val("credit_types");
1716 modalTitle.text( _("Insert list parameter") );
1717 $("#paramLabel").val( _("List of values") );
1718 $("#param_category").val("list");
1721 modalTitle.text( _("Insert text parameter") );
1722 $("#paramLabel").val( _("Text") );
1723 $("#param_category").val("");
1726 $("#paramLabel").select();
1727 modal.modal("show");
1730 function load_group_subgroups () {
1731 var group = $("#group_select").val();
1732 var subgroup = $("#subgroup_select").val();
1733 var sg = $("#subgroup");
1734 $(sg).find('option[value!=""]').each(function() {
1739 var select = $(sg).find('select')[0];
1740 $.each( group_subgroups[group], function(index, value) {
1741 if ( value[0] == subgroup ) {
1742 $('<option selected="selected" value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1744 $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1747 $("#subgroup, #subgroup *").show();
1751 $(document).ready(function(){
1753 var activeTab = localStorage.getItem("sql_reports_activetab");
1755 $("body").on('click',".fetch_chart_data",function(){
1756 if( [% unlimited_total || 0 | $raw %] > 1000 ){
1757 if( confirm( _("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you want to chart this report?") ) ){
1768 if ( $('.chart-column-conf').length == 1 ) {
1769 $('.chart-column-delete').remove();
1772 $(".chart-column-delete").on('click', function(e){
1774 removeColumn('column_' + $(this).data('column'));
1777 $('#download-chart').click(function() {
1778 var svg = '<svg>' + $('#chart svg').html() + '</svg>';
1779 this.href = 'data:application/octet-stream;base64,' + btoa(svg);
1780 this.setAttribute('download', 'chart.svg');
1783 $('#chart-type').change(function() {
1784 if ($(this).val() == 'bar') {
1792 $('#download-chart').hide();
1795 [% IF results && !errors %]
1796 $('#draw-chart').click(function() {
1798 var x_elements = $('select[name="x"]').val();
1799 var y_elements = [];
1804 headers = [% header_row.json | $raw %];
1807 [% IF allresults.size %]
1808 if ($('input[name="chart-include-all"]').prop('checked')) {
1809 results = [% allresults.json | $raw %]
1812 results = [% results.json | $raw %]
1815 results = [% results.json | $raw %];
1818 if ($('input[name="chart-exclude-last"]').prop('checked')) {
1819 results.splice(-1, 1);
1822 $('select[name="y"]').each(function( index ) {
1823 y_elements.push( $(this).val() );
1825 $('select[name="group"]').each(function( index ) {
1826 groups.push( $(this).val() );
1828 $('.column-line').each(function( index ) {
1829 if ($(this).prop('checked')) {
1830 lines.push( $(this).attr('name') );
1834 // Remove deleted columns from headers and results.
1835 var deleted_indexes = [];
1836 var kept_headers = [];
1837 $.each(headers, function(index, value) {
1838 if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) {
1839 // This header is neither a x element nor in y elements. Don't need it.
1840 deleted_indexes.push(index);
1843 kept_headers.push({cell: value.cell});
1847 // Remove coresponding cells.
1848 var kept_results = [];
1849 $.each(results, function(index, value) {
1852 $.each(value.cells, function(i, val) {
1853 if ($.inArray(i, deleted_indexes) === -1) {
1854 line['cells'].push({cell: val.cell});
1857 kept_results.push(line);
1860 options.type = $('select[name="chart-type"]').val();
1861 options.horizontal = $('input[name="column-horizontal"]').prop('checked');
1862 options.lines = lines;
1864 chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options);
1865 $("#download-chart,#toggle_chart_settings_hid,#chart").show();
1866 $("#toggle_chart_settings_vis").hide();
1867 $("#chartModal").modal("hide");
1871 load_group_subgroups();
1874 $('[data-toggle="tooltip"]').tooltip();
1876 $('#limit').change(function() {
1877 $('#limitselect').submit();
1880 $(document).click(function() {
1881 $('#report_updated').hide();
1884 $(".goback").on("click",function(e){
1886 window.history.back();
1889 $("body").on("click", ".mana_search_button", function(){
1890 $("#mana-loading").show();
1891 mana_search($("#mana_search_field").val());
1894 $(".ShareButton").on("click", function(){
1895 $("#note-error").hide();
1896 if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
1897 $(".shared_infos").hide();
1898 $("#note-error").show();
1901 $("#reportid").val($(this).closest("tr").find(".report_id").text());
1902 $("#shared_id").html($(this).closest("tr").find(".report_id").text());
1903 $("#shared_name").html($(this).closest("tr").find(".report_name").text());
1904 $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
1905 $("#shared_type").html($(this).closest("tr").find(".report_type").text());
1906 $("#shared_group").html($(this).closest("tr").find(".report_group").text());
1907 $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
1911 $("#ManaCloseButton").on("click", function() {
1912 $(".shared_infos").show();
1915 $("#addColumn").on("click",function(){
1919 $("#delColumn").on("click",function(){
1924 var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1925 var rtable = KohaTable("table_reports", {
1926 'bAutoWidth': false,
1927 'sPaginationType': 'full',
1928 'aaSorting': [[ 1, "asc" ]],
1930 'sZeroRecords': _("No matching reports found")
1934 $("#tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) {
1935 tabsInit( $(e.target).parent(), rtable );
1939 $("#tabs li:eq(" + activeTab + ") a").tab("show");
1942 $("#subgroup_filter").change(function() {
1943 var selected = $(this).find('option:selected');
1944 var sg_id = $(selected).val();
1945 var sg_name = $(selected).text();
1946 if (sg_id.length > 0) {
1947 rtable.fnFilter('^' + sg_name + '$', 5, true, true, true, false);
1948 rtable.fnSetColumnVis(5, false);
1950 rtable.fnFilter('', 5);
1951 rtable.fnSetColumnVis(5, true);
1955 $("#reports_form").submit(function(){
1956 var checkedItems = $("input[name=ids]:checked");
1957 if ($(checkedItems).size() == 0) {
1958 alert(_("You must select one or more reports to delete"));
1961 $(checkedItems).parents('tr').addClass("warn");
1962 if( confirm(_("Are you sure you want to delete the selected reports?")) ) {
1965 $(checkedItems).parents('tr').removeClass("warn");
1970 $("body").on("click", ".update_sql", function(e){
1972 var ltitle = $(this).text();
1973 var report_id = $(this).data("report_id");
1974 var page = $(this).attr("href");
1975 $("#update_sql .modal-body").load(page + " div", function(){
1976 var diff1 = $("#col1 .show_sql").text();
1977 var diff2 = $("#col2 .show_sql").text();
1978 var diffs = diffString( escape(diff1), escape(diff2) );
1979 $("#col1 .show_sql,#col2 .show_sql").html(diffs);
1981 $('#update_sql').modal('show');
1982 $("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?phase=Use saved&op=convert&report_id=" + report_id);
1985 $("#update_sql").on("hidden.bs.modal", function(){
1986 $("#update_sql_label").html("");
1987 $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1991 [% IF ( showsql ) %]
1992 $("#sql").focus(function() {
1997 $("#toggle_sql").click(function(){
1998 var sql_output = $("#sql_output");
1999 sql_output.toggle();
2000 if( sql_output.is(":visible") ){
2001 $(this).button('complete');
2003 $(this).button('reset');
2006 showsql = CodeMirror.fromTextArea(sql, {
2015 $(".toggle_chart_settings").click(function(){
2016 $("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
2019 $("#table_reports").delegate(".confirmdelete", 'click', function(){
2020 $(this).parents('tr').attr("class","warn");
2021 if(confirm(_("Are you sure you want to delete this saved report?"))){
2024 $(this).parents('tr').attr("class","");
2029 [% IF (create || editsql || save) %]
2031 var validated_form = $("#sql_report_form").validate({
2032 reportname: "required",
2035 depends: function(element) {
2036 return $("#create_group").prop("checked") && $("#groupdesc_input").val() != '';
2042 depends: function(element) {
2043 return $("#create_group").prop("checked") && $("#group_input").val() != '';
2049 $("#select_group").change(function() {
2050 if($(this).prop('checked')) {
2051 $("#group_input").attr("class","").prop('disabled', true).prop("required", false);
2052 $("#groupdesc_input").attr("class","").prop('disabled', true).prop("required", false);
2053 $("#group_select").prop('disabled', false);
2054 clearValidation( $("#sql_report_form") );
2055 if ($("#group_select").val().length > 0) {
2056 $("#select_subgroup").prop('checked', true);
2057 $("#select_subgroup").change();
2058 $("#subgroup, #subgroup *").show();
2060 $("#subgroup").hide();
2064 $("#create_group").change(function() {
2065 if($(this).prop('checked')) {
2066 $("#group_input").prop('disabled', false).prop("required", true );
2067 $("#groupdesc_input").prop('disabled', false).prop("required", true );
2068 $("#group_select").prop('disabled', true);
2069 // $("#create_subgroup").prop('checked', true).change();
2070 $("#subgroup_select").hide();
2071 $("#subgroup input[type='radio']").hide();
2072 $("#subgroup label[for]").hide();
2073 $("#subgroup_input").prop("required", false ).prop("disabled", false).show();
2074 $("#subgroupdesc_input").prop("required", false ).prop("disabled", false).show();
2075 $("#subgroup").show();
2076 // Add validation rules for fields which were previously hidden
2077 $("#subgroup_input").rules("add", {
2079 depends: function(element) {
2080 return $("#create_group").prop("checked") && $("#subgroupdesc_input").val() != '';
2084 $("#subgroupdesc_input").rules("add", {
2086 depends: function(element) {
2087 return $("#create_group").prop("checked") && $("#subgroup_input").val() != '';
2093 $("#select_subgroup").change(function() {
2094 if($(this).prop('checked')) {
2095 $("#subgroup_select").prop('disabled', false);
2096 $("#subgroup_input").prop('disabled', true).prop("required", false );
2097 $("#subgroupdesc_input").prop('disabled', true).prop("required", false );
2098 clearValidation( $("#sql_report_form") );
2101 $("#create_subgroup").change(function() {
2102 if($(this).prop('checked')) {
2103 $("#subgroup_input").prop('disabled', false).prop("required", true );
2104 $("#subgroupdesc_input").prop('disabled', false).prop("required", true );
2105 $("#subgroup_select").val("").prop('disabled', true);
2108 $("#select_group").change();
2109 $("#select_subgroup").change();
2110 $("#group_select").on("change",function(){
2111 load_group_subgroups();
2114 $(".insertParam").on("click", function(e){
2116 var category = this.id;
2117 showParamModal( category );
2120 $("#runtime_parameters").on("shown.bs.modal", function(){
2121 $("#paramLabel").focus();
2124 $("#runtime_parameters").on("hide.bs.modal", function(){
2125 $("#send_runtime_parameter")[0].reset();
2126 $("#authorised_value_category").val("").hide();
2127 $("label[for='authorised_value']").removeClass("required");
2128 $("#authorised_value").prop("required", false ).removeAttr("required").removeClass("required");
2131 $("#send_runtime_parameter").on("submit", function(e){
2133 /* Get form values */
2134 var paramLabel = $("#paramLabel").val();
2135 var param_category = $("#param_category").val();
2136 var categoryLabel = $("#authorised_value").val();
2137 // Get CodeMirror environment variables
2138 var selection = editor.getSelection();
2139 var doc = editor.getDoc();
2140 var cursor = doc.getCursor();
2145 /* Build runtime parameter text string */
2147 if( paramLabel && param_category ){
2148 text += paramLabel + "|" + param_category;
2149 } else if( paramLabel ) {
2151 } else if( param_category ){
2152 text += param_category;
2155 text = " <<" + text + ">> ";
2156 if( selection.length > 0){
2157 editor.replaceSelection(text);
2159 doc.replaceRange(text, pos);
2162 $("#runtime_parameters").modal("hide");
2165 $("#authorised_value").on("change", function(){
2166 $("#param_category").val( $(this).val() );
2171 $(".delete").on("click",function(){
2172 return confirmDelete(MSG_CONFIRM_DELETE);
2175 $("#mana_search_form").submit(function(e){
2179 $("#column_submit").submit(function() {
2180 if ($("#selectedColumns option").size() < 1) {
2181 alert(_("No columns selected!"));
2184 $("#selectedColumns option").attr("selected", "selected"); // Select everything still in #selectedColumns
2189 $("body").on("click", ".mana-use", function(e) {
2191 $(this).find("i").attr("class","fa fa-refresh fa-spin");
2192 mana_use( $(this).data("report_id") );
2195 $("#mana_search_result").on("shown.bs.modal", function(){
2196 $("#mana_search_field").focus();
2199 $("#mana_search_result").on("hide.bs.modal", function(){
2200 $("#mana_result_content").html("");
2201 $("#mana_search_field").val("");
2204 $(".batch_op").on("click", function(e){
2206 var target_form = $(this).data("submit");
2207 $("#" + target_form ).submit();
2210 $("#batch_add_to_list").on("submit", function(e){
2215 $("body").on("click", ".preview_sql", function(e){
2217 var reportid = $(this).data("reportid");
2218 previewSql( reportid );
2220 $(".limitselect").on("click", function(){
2221 var limit = $(this).data("limit");
2222 $("#limit").val( limit );
2223 $("#limitselect").submit();
2228 $("#toggle_auto_links").on("click", function(e){
2230 if( $(".data-plain").is(":visible") ){
2231 /* if a data-plain element is visible, this click hides it and shows auto-links */
2232 localStorage.removeItem("reports_auto_link_off");
2234 /* if a data-plain element is hidden, this click shows it and hides auto-links */
2235 localStorage.setItem("reports_auto_link_off", 1);
2237 $(".data-plain,.autolink").toggle();
2239 if ( localStorage.getItem("reports_auto_link_off") == 1 ){
2240 $("#toggle_auto_links").click();
2243 function tabsInit( tab, rtable ){
2244 var thisTab = tab; // ui.newTab ? ui.newTab : ui.tab;
2245 var activeTab = thisTab.index();
2246 localStorage.setItem("sql_reports_activetab", activeTab );
2248 $("#subgroup_filter option").each(function() {
2249 if($(this).val().length > 0) {
2253 rtable.fnFilter('', 4);
2254 rtable.fnFilter('', 5);
2255 rtable.fnSetColumnVis(4, true);
2256 rtable.fnSetColumnVis(5, true);
2258 var g_id = $( tab ).children().attr('id');
2259 var g_name = $( tab ).children().text();
2260 if ( g_name == _("All") ) {
2265 if (g_id && g_id.length > 0) {
2266 rtable.fnFilter('^' + g_name + '$', 4, true, true, true, false);
2267 rtable.fnSetColumnVis(4, false);
2268 for(var i in group_subgroups[g_id]) {
2269 $("#subgroup_filter").append(
2270 '<option value="' + group_subgroups[g_id][i][0] + '">'
2271 + group_subgroups[g_id][i][1] + '</option>'
2274 $("#subgroup_filter_block").show();
2276 $("#subgroup_filter_block").hide();
2280 function addColumn() {
2281 $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
2283 function delColumn() {
2284 $("#selectedColumns option:selected").remove();
2288 function mana_use( mana_id ){
2291 url: "/cgi-bin/koha/svc/mana/use",
2292 data: {id:mana_id, resource: 'report', saveinbase: 1},
2295 .done( function (result){
2296 if ( result.errmsg ){
2297 alert( result.errmsg );
2300 window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&phase=Show%20SQL&mana_success=1");
2303 .fail(function( error ) {
2304 $(".mana_use_status").hide();
2305 $("#mana_use_errortext").html( error.status + " " + error.statusText );
2306 $("#mana_use_failed").show();
2307 $(".mana-use i").attr("class","fa fa-download");
2311 function mana_search( textquery ){
2312 $(".mana_search_status").hide();
2313 $("#mana_result_content").load("/cgi-bin/koha/svc/mana/search #mana_results", { resource: 'report', id: textquery, usecomments: 1 }, function( response, status, xhr ) {
2315 if ( status == "error" ) {
2316 $("#mana_search_errortext").html( xhr.status + " " + xhr.statusText );
2317 $("#mana_search_failed").show();
2318 $("#mana-loading").hide();
2320 $(".mana_search_status").hide();
2321 $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
2322 $("#mana-loading").hide();
2323 $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
2324 "sPaginationType":"full",
2327 { "width": "35%", "targets": 1 }
2330 { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
2331 { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
2335 $(".showbutton").on("click", function(e){
2337 $(this).parent().hide();
2338 $(this).parent().next().show();
2341 $(".hidebutton").on("click", function(e){
2343 $(this).parent().hide();
2344 $(this).parent().prev().show();
2347 if($("td.dataTables_empty").length == 0){
2348 $("#mana_search_message").show();
2354 function addToList() {
2355 var biblionumbers = [];
2356 $(".bib_to_list").each(function() {
2357 var biblionumber = Number( $(this).val() );
2358 if( biblionumbers.indexOf( biblionumber ) < 0 ){
2359 biblionumbers.push( biblionumber );
2362 bibs = biblionumbers.join("/");
2363 var url = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumbers=" + bibs;
2364 window.open(url, 'Add_to_virtualshelf', 'width=500, height=400, toolbar=false, scrollbars=yes');
2368 // Adapted from https://gist.github.com/jnormore/7418776
2369 function previewSql(reportid) {
2372 var message = $("#previewSql" + reportid ).val();
2373 var title = $("#previewSql" + reportid ).data("title");
2374 if( $("#preview-sql-modal").length > 0) {
2375 $("#preview-sql-modal").remove();
2377 $("body").append('<div id="preview-sql-modal" tabindex="-1" role="dialog" aria-hidden="true" class="modal">\
2378 <div class="modal-dialog">\
2379 <div class="modal-content">\
2380 <div class="modal-header" style="min-height:40px;">\
2381 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">\
2382 <span aria-hidden="true">×</span>\
2384 <h4 class="modal-title">' + title + '</h4>\
2386 <div class="modal-body"><textarea id="code' + reportid + '">' + message + '</textarea>\
2388 <div class="modal-footer">\
2389 <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>\
2390 <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>\
2391 <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>\
2392 <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>\
2393 <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>\
2394 <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>\
2400 $("#preview-sql-modal").modal('show');
2401 CodeMirror.fromTextArea( document.getElementById("code" + reportid ), {
2411 [% INCLUDE 'intranet-bottom.inc' %]
2413 [% BLOCK group_and_subgroup_selection %]
2415 <label>Report group:</label>
2416 <input type="radio" name="select_or_create_group"
2417 id="select_group" checked="checked" />
2418 <label for="select_group" class="radio">Select</label>
2419 <select name="group" id="group_select">
2420 <option value="">(None)</option>
2421 [% FOREACH group IN groups_with_subgroups %]
2422 [% IF (group.selected) %]
2423 <option value="[% group.id | html %]" selected="selected">
2425 <option value="[% group.id | html %]">
2427 [% group.name | html %]
2431 <input type="radio" name="select_or_create_group" id="create_group" />
2432 <label for="create_group" class="radio">or create:</label>
2433 <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
2434 <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
2437 <label>Report subgroup:</label>
2438 <input type="radio" name="select_or_create_subgroup"
2439 id="select_subgroup" checked="checked" />
2440 <label for="select_subgroup" style="float:none">Select</label>
2441 <select name="subgroup" id="subgroup_select">
2442 <option value="">(None)</option>
2443 [% FOREACH group IN groups_with_subgroups %]
2444 [% IF (group.selected) %]
2445 [% FOREACH subgroup IN group.subgroups %]
2446 [% IF (subgroup.selected) %]
2447 <option value="[% subgroup.id | html %]" selected="selected">
2449 <option value="[% subgroup.id | html %]">
2451 [% subgroup.name | html %]
2457 <input type="radio" name="select_or_create_subgroup"
2458 id="create_subgroup" />
2459 <label for="create_subgroup" style="float:none">or create</label>
2460 <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
2461 <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />
2465 [% BLOCK insert_runtime_parameter %]
2466 <div class="btn-group" style="margin-left:30px;">
2467 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
2468 Insert runtime parameter <span class="caret"></span>
2470 <ul class="dropdown-menu">
2471 <li><a href="#" class="insertParam" id="insertAuthVal">Authorized values</a></li>
2472 <li><a href="#" class="insertParam" id="insertFramework">Bibliographic framework</a></li>
2473 <li><a href="#" class="insertParam" id="insertCnSource">Classification sources</a></li>
2474 <li><a href="#" class="insertParam" id="insertDate">Date</a></li>
2475 <li><a href="#" class="insertParam" id="insertItemtypes">Item types</a></li>
2476 <li><a href="#" class="insertParam" id="insertBranches">Libraries</a></li>
2477 <li><a href="#" class="insertParam" id="insertList">List</a></li>
2478 <li><a href="#" class="insertParam" id="insertCategorycode">Patron categories</a></li>
2479 <li><a href="#" class="insertParam" id="insertCashregister">Cash registers</a></li>
2480 <li><a href="#" class="insertParam" id="insertDebittypes">Debit types</a></li>
2481 <li><a href="#" class="insertParam" id="insertCredittypes">Credit types</a></li>
2482 <li><a href="#" class="insertParam" id="insertText">Text field</a></li>