3 [% USE AuthorisedValues %]
6 [% USE TablesSettings %]
10 [%- BLOCK area_name -%]
12 [%- CASE 'CIRC' -%]Circulation
13 [%- CASE 'CAT' -%]Catalog
14 [%- CASE 'PAT' -%]Patrons
15 [%- CASE 'ACQ' -%]Acquisitions
16 [%- CASE 'ACC' -%]Accounts
17 [%- CASE 'SER' -%]Serials
21 [% INCLUDE 'doc-head-open.inc' %]
25 Saved reports › [%- ELSIF ( create ) -%]
26 Create from SQL › [%- ELSIF ( showsql ) -%]
27 SQL view › Saved reports › [%- ELSIF ( execute ) -%]
28 Report [% name | html %] ([% id | html %]) › Saved reports › [%- ELSIF ( editsql ) -%]
29 Edit report [% reportname | html %] ([% id | html %]) › Saved reports › [%- END -%]
32 Build a report, step 1 of 6: Choose a module › [%- ELSIF ( build2 ) -%]
33 Build a report, step 2 of 6: Pick a report type › [%- ELSIF ( build3 ) -%]
34 Build a report, step 3 of 6: Select columns for display › [%- ELSIF ( build4 ) -%]
35 Build a report, step 4 of 6: Select criteria to limit on › [%- ELSIF ( build5 ) -%]
36 Build a report, step 5 of 6: Pick which columns to total › [%- ELSIF ( build6 ) -%]
37 Build a report, step 6 of 6: Select how you want the report ordered › [%- END -%]
38 Guided reports wizard › Reports › Koha
41 [% INCLUDE 'doc-head-close.inc' %]
42 [% Asset.css("lib/codemirror/codemirror.min.css") | $raw %]
50 .cm-columnPlaceholder {
53 #mana_search_errortext {
54 font-family: monospace; font-weight: bold;
60 [% Asset.css("css/reports.css") | $raw %]
61 [% Asset.css("lib/d3c3/c3.min.css") | $raw %]
64 <body id="rep_guided_reports_start" class="rep">
65 [% INCLUDE 'header.inc' %]
66 [% INCLUDE 'circ-search.inc' %]
68 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
71 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
74 <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
77 <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
82 <a href="#" aria-current="page">
86 [% ELSIF ( create ) %]
88 <a href="#" aria-current="page">
92 [% ELSIF ( showsql ) %]
94 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a>
97 <a href="#" aria-current="page">
98 [% reportname | html %] ([% id | html %])
101 [% ELSIF ( editsql ) %]
103 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a>
106 <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | uri %]&phase=Show%20SQL">[% reportname | html %] ([% id | html %])</a>
109 <a href="#" aria-current="page">
113 [% ELSIF ( execute ) %]
115 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a>
118 <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | uri %]&phase=Show%20SQL">[% name | html %] ([% id | html %])</a>
121 <a href="#" aria-current="page">
125 [% ELSIF ( build1 || build2 || build3 || build4 || build5 || build6 ) %]
127 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a report</a>
130 <a href="#" aria-current="page">
132 Step 1 of 6: Choose a module
133 [% ELSIF ( build2 ) %]
134 Step 2 of 6: Pick a report type
135 [% ELSIF ( build3 ) %]
136 Step 3 of 6: Select columns for display
137 [% ELSIF ( build4 ) %]
138 Step 4 of 6: Select criteria to limit on
139 [% ELSIF ( build5 ) %]
140 Step 5 of 6: Pick which columns to total
141 [% ELSIF ( build6 ) %]
142 Step 6 of 6: Select how you want the report ordered
147 </nav> <!-- /#breadcrumbs -->
149 <div id="update_sql" class="modal" tabindex="-1" role="dialog" aria-labelledby="update_sql_label" aria-hidden="true">
150 <div class="modal-dialog">
151 <div class="modal-content">
152 <div class="modal-header">
153 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
154 <h3 id="update_sql_label">Update SQL</h3>
156 <div class="modal-body">
157 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
159 <div class="modal-footer">
160 <a href="#" class="btn btn-default" id="update_sql_button" role="button" data-toggle="modal">Update</a>
161 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
163 </div> <!-- /.modal-content -->
164 </div> <!-- /.modal-dialog -->
165 </div> <!-- #update_sql -->
167 <div class="main container-fluid">
169 <div class="col-sm-10 col-sm-push-2">
172 [% INCLUDE "reports-toolbar.inc" %]
175 <h2>Guided reports</h2>
176 <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>
178 <h3>Build and run reports</h3>
180 [% IF ( CAN_user_reports_create_reports ) %]
181 <form action="/cgi-bin/koha/reports/guided_reports.pl">
182 <input type="hidden" name="phase" value="Build new" />
183 <input type="submit" name="submit" value="Build new"/>
187 [% IF ( CAN_user_reports_execute_reports ) %]
188 <form action="/cgi-bin/koha/reports/guided_reports.pl">
189 <input type="hidden" name="phase" value="Use saved"/>
190 <input type="submit" name="submit" value="Use saved"/>
194 [% IF ( CAN_user_reports_create_reports ) %]
195 <form action="/cgi-bin/koha/reports/guided_reports.pl">
196 <input type="hidden" name="phase" value="Create report from SQL"/>
197 <input type="submit" name="submit" value="Create report from SQL"/>
201 <h3>Reports Dictionary</h3>
202 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
203 <form action="/cgi-bin/koha/reports/dictionary.pl">
204 <input type="hidden" name="phase" value="View Dictionary"/>
205 <input type="submit" name="submit" value="View dictionary"/>
207 [% END # /IF (start) %]
209 [% IF report_converted %]
210 <div class="dialog message">
211 The report "[% report_converted | html %]" has been converted.
215 [% IF report_converted %]
216 <div class="dialog message">
217 The report "[% report_converted | html %]" has been converted.
222 [% IF ( savedreports ) %]
223 <h1>Saved reports</h1>
225 [% IF ( filters.date || filters.author || filters.keyword ) %]
227 <span class="filter">
228 [% IF ( filters.date ) %]
229 <span class="filter_date"><strong>Date:</strong> [% filters.date | html %]</span>
231 [% IF ( filters.author ) %]
232 <span class="filter_author"><strong>Author:</strong> [% filters.author | html %]</span>
234 [% IF ( filters.keyword ) %]
235 <span class="filter_keyword"><strong>Keyword:</strong> [% filters.keyword | html %]</span>
237 <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>
242 <div id="tabs" class="toptabs">
244 <li><a href="#reports">All</a></li>
245 [% FOREACH group IN groups_with_subgroups %]
246 <li><a id="[% group.id | html %]" href="#reports">[% group.name | html %]</a></li>
250 <div id="subgroup_filter_block">
251 <label for="subgroup_filter">Subgroup:</label>
252 <select id="subgroup_filter">
253 <option value="">All</option>
257 [% IF (Koha.Preference('Mana') == 1) %]
259 <div id="mana_search_message" class="dialog message">
260 <p> [% manamsg | html %] </p>
265 <form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
266 <input type="hidden" name="phase" value="Delete Multiple" />
267 <table id="table_reports">
270 <th class="NoSort"> </th>
278 <th>Creation date</th>
281 <th class="report_public">Public</th>
282 <th class="report_json_url">JSON URL</th>
284 <th>Cache expiry (seconds)</th>
286 <th class="NoVisible">Cache expiry (seconds)</th>
288 <th>Saved results</th>
289 [% IF has_obsolete_reports %]
292 <th class="NoVisible">Update</th>
294 <th class="NoSort noExport">Actions</th>
298 [% FOREACH savedreport IN savedreports %]
299 [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
300 <td class="report_checkbox">
301 [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
302 <input type="checkbox" name="ids" id="ids[% savedreport.id | html %]" value="[% savedreport.id | html %]" />
304 <input type="hidden" class="report_sql" value="[% savedreport.savedsql |html %]">
306 <td class="report_id">
307 <label for="ids[% savedreport.id | html %]">[% savedreport.id | html %]</label>
309 <td class="report_name">
310 [% IF ( savedreport.report_name ) %]
311 [% savedreport.report_name | html %]
316 <td class="report_type">
317 [% savedreport.type | html %]
319 <td class="report_group">
320 [% savedreport.groupname | html %]
323 [% savedreport.subgroupname | html %]
325 <td class="report_notes">
326 [% savedreport.notes | html %]
329 [% savedreport.borrowersurname | html %]
330 [% IF ( savedreport.borrowerfirstname ) %]
331 , [% savedreport.borrowerfirstname | html %]
333 ([% savedreport.borrowernumber | html %])
335 <td data-order="[% savedreport.date_created | html %]">
336 [% savedreport.date_created | $KohaDates %]
338 <td data-order="[% savedreport.last_modified | html %]">
339 [% savedreport.last_modified | $KohaDates with_hours => 1 %]
341 <td data-order="[% savedreport.last_run | html %]">
342 [% savedreport.last_run | $KohaDates with_hours => 1 %]
344 <td class="report_public">
345 [% IF (savedreport.public) %]
351 <td class="report_json_url">
352 [% IF (savedreport.public) %]
353 <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>
355 <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>
359 [% savedreport.cache_expiry | html %]
362 [% FOR result IN savedreport.results %]
363 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=[% result.id | uri %]">[% result.date_run | html %]</a>
368 [% IF savedreport.seems_obsolete %]
369 This report seems obsolete, it uses biblioitems.marcxml field.
370 <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>
374 <div class="btn-group dropup">
375 [%# There should be no space between these two buttons, it would render badly %]
376 <a class="btn btn-default btn-xs" role="button"
377 href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&phase=Run%20this%20report"><i
378 class="fa fa-play"></i> Run</a><a
379 class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown"
380 href="#"><b class="caret"></b></a>
381 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
382 <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>
384 <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL" class="preview_sql" data-reportid="[% savedreport.id | html %]">
385 <i class="fa fa-eye"></i> Preview SQL
388 [% IF ( CAN_user_reports_create_reports ) %]
389 <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>
390 <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>
392 [% IF (Koha.Preference('Mana') == 1) %]
393 <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>
395 <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
396 [% IF ( CAN_user_reports_delete_reports ) %]
397 <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>
401 <input type="hidden" id="previewSql[% savedreport.id | html %]" value="[% savedreport.savedsql | html %]" data-title="[% savedreport.report_name | html %]" />
408 [% IF ( CAN_user_reports_delete_reports ) %]
409 <fieldset class="action">
410 <input type="submit" value="Delete selected" />
416 [% ELSE # IF ( savedreports ) %]
417 <div class="dialog message">
418 [% IF (filter_set || filters.date || filters.author || filters.keyword) %]
419 <h4>No saved reports match your criteria. </h4>
420 [% IF ( CAN_user_reports_create_reports ) %]
421 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
422 <input type="hidden" name="phase" value="Build new" />
423 <button type="submit" class="new"><i class="fa fa-plus"></i> New guided report</button>
426 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
427 <input type="hidden" name="phase" value="Create report from SQL" />
428 <button type="submit" class="new"><i class="fa fa-plus"></i> New SQL report</button>
431 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
432 <input type="hidden" name="phase" value="Use saved" />
433 <input type="hidden" name="filter_set" value="1" />
434 <input type="hidden" name="filter_keyword" value="" />
435 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> Cancel filter</button>
439 <h4>There are no saved reports. </h4>
440 [% IF ( CAN_user_reports_create_reports ) %]
441 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a new report?</a>
443 [% END # IF (filter_set || filters.date || filters.author || filters.keyword) %]
444 </div> <!-- /.dialog.message -->
445 [% END # /IF ( savedreports ) %]
446 [% END # /IF ( saved1 ) %]
448 [% INCLUDE 'mana/mana-share-report.inc' %]
451 [% IF ( cache_error) %]
452 <div class="dialog alert">
453 <strong> Please choose a cache_expiry less than 30 days </strong>
457 <h1>Build a report</h1>
458 <form action="/cgi-bin/koha/reports/guided_reports.pl">
459 <fieldset class="rows">
460 <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and choose report visibility </legend>
463 <label for="area">Choose: </label>
464 <select name="area" id="area">
465 [%- FOREACH area IN areas -%]
466 <option value="[% area | html %]">[%- PROCESS area_name area=area -%]</option>
472 <label for="public">Report is public:</label>
473 <select id="public" name="public">
474 <option value="0">No (default)</option>
475 <option value="1" selected="selected">Yes</option>
480 <label for="public">Report is public:</label>
481 <select id="public" name="public">
482 <option value="0" selected="selected">No (default)</option>
483 <option value="1">Yes</option>
490 <label for="cache_expiry">Cache expiry:</label>
491 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
492 <select id="cache_expiry_units" name="cache_expiry_units">
493 <option value="seconds">Seconds (default)</option>
494 <option value="minutes">Minutes</option>
495 <option value="hours">Hours</option>
496 <option value="days">Days</option>
501 </fieldset> <!-- /.rows -->
502 <fieldset class="action">
503 <input type="hidden" name="phase" value="Report on this Area" />
504 <input type="submit" name="submit" value="Next >>" />
510 <h1>Build a report</h1>
511 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
512 <input type="hidden" name="area" value="[% area | html %]" />
513 <input type="hidden" name="public" value="[% public | html %]" />
514 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
515 <fieldset class="rows">
516 <legend>Step 2 of 6: Pick a report type</legend>
519 <label for="types">Choose: </label>
520 <select id="types" name="types">
521 <option value="1">Tabular</option>
522 <option value="2" disabled="disabled">Summary</option>
523 <option value="3" disabled="disabled">Matrix</option>
529 <fieldset class="action">
530 <input type="hidden" name="phase" value="Choose this type" />
531 <input type="button" name="back" value="<< Back" class="goback" />
532 <input type="submit" name="submit" value="Next >>" />
535 [% END # /IF (build2 ) %]
538 <h1>Build a report</h1>
539 <h3>Step 3 of 6: Select columns for display</h3>
540 <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>
542 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
543 <input type="hidden" name="area" value="[% area | html %]" />
544 <input type="hidden" name="type" value="[% type | html %]" />
545 <input type="hidden" name="public" value="[% public | html %]" />
546 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
549 <div class="col-sm-6">
550 <div style="float: left;">
551 <select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
552 [% FOREACH column IN columns %]
553 [% IF ( column.table ) %]
554 [% IF ( loop.first ) %]
558 <optgroup label="[% column.table | html %]">
560 <option value="[% column.name | html %]">
561 [% IF ( column.description ) %]
562 [% column.description | html %] / [% column.name | html %]
564 [% column.name | html %]
572 <div style="width: 6.3em; float: right; margin-top: 100px">
573 <input type="button" name="Add" value="Add" class="button" style="width:6em;" id="addColumn" /><br />
574 <input type="button" name="delete" value="<< Delete" class="button" style="width: 6em; margin: 1em 0;" id="delColumn" />
576 </div> <!-- /.col-sm-6 -->
578 <div class="col-sm-6">
579 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;">
582 </div> <!-- /.row -->
584 <fieldset class="action">
585 <input type="hidden" name="phase" value="Choose these columns" />
586 <input type="button" name="back" value="<< Back" class="goback" />
587 <input type="submit" name="submit" value="Next >>" />
589 </form> <!-- /#column_submit -->
590 [% END # /IF ( build3 ) %]
593 <h1>Build a report</h1>
594 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
595 <input type="hidden" name="area" value="[% area | html %]" />
596 <input type="hidden" name="type" value="[% type | html %]" />
597 <input type="hidden" name="column" value="[% column | html %]" />
598 <input type="hidden" name="public" value="[% public | html %]" />
599 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
601 <legend>Step 4 of 6: Select criteria to limit on</legend>
603 [% FOREACH criteri IN criteria %]
606 <input type="checkbox" name="criteria_column" id="[% criteri.name | html %]" value="[% criteri.name | html %]" />
607 <label for="[% criteri.name | html %]">[% criteri.description | html %] </label>
609 [% IF ( criteri.date ) %]
611 <input type="text" size="10" id="[% criteri.name | html %]_value" name="[% criteri.name | html %]_value" value="" class="flatpickr" />
612 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
616 [% IF ( criteri.textrange ) %]
619 <input type="text" size="10" id="[% criteri.from | html %]_value" name="[% criteri.from | html %]_value" value="" /> to
620 <input type="text" size="10" id="[% criteri.to | html %]_value" name="[% criteri.to | html %]_value" value="" />
624 [% IF ( criteri.daterange ) %]
627 <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" />
629 <input type="text" size="10" id="to_[% criteri.name.remove('\.') | html %]_value" name="to_[% criteri.name | html %]_value" value="" class="flatpickr" />
630 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
635 <select name="[% criteri.name | html %]_value">
636 [% FOREACH value IN criteri.values %]
637 <option value="[% value.availablevalues | html %]">
638 [% IF ( value.default ) %]
641 [% value.display_value | html %]
655 [% IF ( definitions ) %]
657 <legend>Dictionary definitions</legend>
659 [% FOREACH definition IN definitions %]
662 <input type="checkbox" name="definition" value="[% definition.id | html %]" />
663 [% definition.name | html %]
671 <fieldset class="action">
672 <input type="hidden" name="phase" value="Choose these criteria" />
673 <input type="button" name="back" value="<< Back" class="goback" />
674 <input type="submit" name="submit" value="Next >>" />
677 [% END # /IF ( build4 ) %]
680 <h1>Build a report</h1>
681 <h3>Step 5 of 6: Pick which columns to total</h3>
682 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
683 <input type="hidden" name="area" value="[% area | html %]" />
684 <input type="hidden" name="type" value="[% type | html %]" />
685 <input type="hidden" name="column" value="[% column | html %]" />
686 <input type="hidden" name="definition" value="[% definition | html %]" />
687 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
688 <input type="hidden" name="public" value="[% public | html %]" />
689 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
692 [% FOREACH total_b IN total_by %]
695 <input type="checkbox" name="total_by" id="[% total_b.name | html %]" value="[% total_b.name | html %]" />
696 <label for="[% total_b.name | html %]">[% total_b.name | html %]</label>
699 <select name="[% total_b.name | html %]_tvalue">
700 [% FOREACH selec IN total_b.select %]
701 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
710 <fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
711 <input type="button" name="back" value="<< Back" class="goback" />
712 <input type="submit" name="submit" value="Next >>" />
715 [% END # /IF ( build5 ) %]
718 <h1>Build a report</h1>
719 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
720 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
721 <input type="hidden" name="area" value="[% area | html %]" />
722 <input type="hidden" name="type" value="[% type | html %]" />
723 <input type="hidden" name="column" value="[% column | html %]" />
724 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
725 <input type="hidden" name="definition" value="[% definition | html %]" />
726 <input type="hidden" name="totals" value="[% totals | html %]" />
727 <input type="hidden" name="public" value="[% public | html %]" />
728 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
731 [% FOREACH order_b IN order_by %]
734 <input type="checkbox" id="[% order_b.name | html %]" name="order_by" value="[% order_b.name | html %]" />
735 <label for="[% order_b.name | html %]">[% order_b.name | html %]</label>
738 <select name="[% order_b.name | html %]_ovalue">
739 [% FOREACH selec IN order_b.select %]
740 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
748 <fieldset class="action">
749 <input type="hidden" name="phase" value="Build report" />
750 <input type="submit" name="submit" value="Finish" />
753 [% END #/ IF ( build6 ) %]
755 [% IF ( showreport ) %]
756 <h1>Confirm custom report</h1>
757 <p>Your report will be generated with the following SQL statement.</p>
762 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
763 <input type="hidden" name="sql" value="[% sql | html %]" />
764 <input type="hidden" name="type" value="[% type | html %]" />
765 <input type="hidden" name="public" value="[% public | html %]" />
766 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
767 <p>You will need to save the report before you can execute it</p>
768 <fieldset class="action"><input type="hidden" name="phase" value="Save" />
769 <input type="submit" name="submit" value="Next" />
772 [% END #/ IF ( showreport ) %]
775 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
776 <input type="hidden" name="sql" value="[% sql | html %]" />
777 <input type="hidden" name="type" value="[% type | html %]" />
778 <input type="hidden" name="area" value="[% area | html %]" />
779 <input type="hidden" name="public" value="[% public | html %]" />
780 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
781 <fieldset class="rows">
782 <legend>Save your custom report</legend>
785 <label for="reportname" class="required">Report name: </label>
786 <input type="text" id="reportname" name="reportname" class="required" required="required" />
787 <span class="required">Required</span>
789 [% PROCESS group_and_subgroup_selection %]
791 <label for="notes">Notes:</label>
792 <textarea name="notes" id="notes"></textarea>
796 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
797 <input type="submit" name="submit" value="Save report" />
800 [% END # /IF( save ) %]
802 [% IF ( warn_authval_problem ) %]
803 <div class="dialog alert">
804 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
805 [% FOREACH problematic_authval IN problematic_authvals %]
807 <strong>[% problematic_authval.name | html %]:</strong> The authorized value category (<strong>[% problematic_authval.authval | html %]</strong>)
808 you selected does not exist.
811 <!-- Save Anyway Form -->
812 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
813 <!--Every parameter the user issued is provided as a hidden field for recovery-->
814 <input type='hidden' name='id' value='[% id | html %]' />
815 <input type='hidden' name='sql' value='[% sql | html %]' />
816 <input type='hidden' name='reportname' value='[% reportname | html %]' />
817 <input type='hidden' name='group' value='[% group | html %]' />
818 <input type='hidden' name='subgroup' value='[% subgroup | html %]' />
819 <input type='hidden' name='notes' value='[% notes | html %]' />
820 <input type='hidden' name='cache_expiry' value='[% cache_expiry | html %]' />
821 <input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units | html %]' />
822 <input type='hidden' name='public' value='[% public | html %]' />
823 [% IF ( phase_update) %]
824 <input type='hidden' name='phase' value='Update SQL' />
825 <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
826 [% ELSIF ( phase_save) %]
827 <input type='hidden' name='area' value='[% area | html %]' />
828 <input type='hidden' name='phase' value='Save Report' />
829 <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
832 <!-- Go back to editing -->
833 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
834 <button type="button" class="new goback"><i class="fa fa-fw fa-pencil"></i> Edit SQL</button>
837 [% END # /IF ( warn_authval_problem )%]
839 [% IF ( enter_params ) %]
840 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
841 <input type='hidden' name='reports' value="[% reports | html %]" />
842 [% IF ( auth_val_error ) %]
843 <input type='hidden' name='phase' value='Edit SQL' />
844 <div class="dialog alert">
845 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
846 [% FOREACH auth_val_error IN auth_val_errors %]
848 <strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
849 you selected does not exist.
853 <fieldset class="action"><input type="submit" value="Edit SQL" /></fieldset>
854 [% ELSE # IF ( auth_val_error ) %]
855 <input type='hidden' name='phase' value='Run this report' />
856 <h1>Enter parameters for report [% name | html %]:</h1>
858 <p>[% notes | html %]</p>
860 <fieldset class="rows">
862 [% FOREACH sql_param IN sql_params %]
863 <input name="param_name" value="[% sql_param.name | html %]" type="hidden" />
864 [% IF sql_param.input == 'date' %]
866 <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" />
868 [% ELSIF ( sql_param.input == 'text' ) %]
870 <label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label>
871 <input id="sql_params[% loop.count | html %]" type="text" name="sql_params" />
873 [% ELSIF ( sql_param.input == 'textarea' ) %]
875 <label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label>
876 <textarea id="sql_params[% loop.count | html %]" name="sql_params" rows="5"></textarea>
880 <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
881 <select name="[%- sql_param.input.name | html -%]" tabindex="1" id="[%- sql_param.input.id | html -%]">
882 [% IF (sql_param.include_all) %]
883 <option value="%">All</option>
885 [% FOREACH value IN sql_param.input.values %]
886 <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
890 [% END # /IF sql_param.input == 'date' %]
891 [% END # /FOREACH sql_param %]
893 </fieldset> <!-- /.rows -->
894 <fieldset class="action">
895 <input type="submit" value="Run the report" />
897 [% END # / IF ( auth_val_error ) %]
899 [% END # /IF ( enter_params ) %]
902 <h1>[% name | html %] <span id="report_id">([% id | html %])</span></h1>
904 <p><span class="label">Notes:</span> [% notes | html %]</p>
906 [% IF ( unlimited_total ) %]
908 <span class="label">Total number of results:</span>
909 [% unlimited_total | html %]
910 [% IF unlimited_total >= limit %]
911 ([% limit | html %] shown)
916 <div id="sql_output" style="display:none;">
917 <span class="label">Report SQL:</span>
918 <textarea id="sql" readonly="readonly">[% sql | html %]</textarea>
922 <a href="#" id="toggle_chart_settings_hid" class="toggle_chart_settings" style="display:none"><i class="fa fa-eye-slash"></i> Hide chart</a>
923 <a href="#" id="toggle_chart_settings_vis" class="toggle_chart_settings" style="display:none"><i class="fa fa fa-eye"></i> Show chart</a>
925 <div id="chart" class="clearfix"></div>
928 [% UNLESS ( errors ) %]
929 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl" id="batch_record_modification">
930 <input type="hidden" name="recordtype" value="biblio" />
931 <input type="hidden" name="op" value="list" />
932 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
933 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">
934 [%- recordnumbers = PROCESS batch_list results=results batch_type='biblionumber' | trim | html %][% IF recordnumbers %][% SET batch_biblionumbers = 1 %][% recordnumbers | html %][% END -%]
938 <form method="POST" action="/cgi-bin/koha/tools/batch_delete_records.pl" id="batch_record_deletion">
939 <input type="hidden" name="recordtype" value="biblio" />
940 <input type="hidden" name="op" value="list" />
941 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
942 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">
943 [%- recordnumbers = PROCESS batch_list results=results batch_type='biblionumber' | trim | html %][% IF recordnumbers %][% SET batch_biblionumbers = 1 %][% recordnumbers | html %][% END -%]
947 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_modification">
948 <input type="hidden" name="op" value="show" />
949 [% FOREACH result IN results %]
950 [% FOREACH cells IN result.cells %]
951 [% place = loop.index %]
952 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
953 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
954 [% SET batch_itemnumbers = 1 %]
955 [% SET header_row.$place.has_itemnumbers = 1 %]
956 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
962 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_deletion">
963 <input type="hidden" name="op" value="show" />
964 <input type="hidden" name="del" value="1" />
965 [% FOREACH result IN results %]
966 [% FOREACH cells IN result.cells %]
967 [% place = loop.index %]
968 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
969 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
970 [% SET batch_itemnumbers = 1 %]
971 [% SET header_row.$place.has_itemnumbers = 1 %]
972 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
978 <form method="get" action="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl" id="batch_add_to_list">
979 [% FOREACH result IN results %]
980 [% FOREACH cells IN result.cells %]
981 [% place = loop.index %]
982 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
983 [% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
984 [% SET batch_biblionumbers = 1 %]
985 [% SET header_row.$place.has_biblionumbers = 1 %]
986 <input type="hidden" class="bib_to_list" name="biblionumber" value="[% cells.cell | html %]" />
992 <form method="POST" action="/cgi-bin/koha/tools/modborrowers.pl" id="batch_patron_modification">
993 <input type="hidden" name="op" value="show" />
994 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
995 <textarea style="display:none" name="cardnumberlist" id="cardnumberlist">
996 [%- cardnumbers = PROCESS batch_list results=results batch_type='cardnumber' | trim | html %][% IF cardnumbers %][% SET batch_cardnumbers = 1 %][% cardnumbers | html %][% END -%]
1000 [% BLOCK batch_list %]
1001 [%- FOREACH result IN results %]
1002 [%- FOREACH cells IN result.cells %]
1003 [%- place = loop.index %]
1004 [%- IF header_row.$place.cell == batch_type || header_types.item(header_row.$place.cell) == batch_type %]
1005 [%# We must not add whitespace to the cardnumbers %][% cells.cell | html %]
1011 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
1012 <input type="hidden" name="phase" value="Run this report"/>
1013 <input type="hidden" name="reports" value="[% report_id | html %]"/>
1014 [% FOREACH p IN sql_params %]
1015 <input type="hidden" name="sql_params" value="[% p | html %]"/>
1017 [% FOREACH n IN param_names %]
1018 <input type="hidden" name="param_name" value="[% n | html %]"/>
1020 <input type="hidden" name="limit" id="limit" value="20" />
1021 </form> <!-- /#limitselect -->
1023 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) || ( unlimited_total > 10 && limit <= 1000 ) %]
1024 <div id="toolbar" class="btn-toolbar">
1025 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1026 <div class="btn-group">
1027 <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="batch_mod_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
1028 Batch operations with [% IF unlimited_total >= limit %][% limit | html %][% ELSE %][% unlimited_total | html %][% END %] visible records
1029 <span class="caret"></span>
1031 <ul class="dropdown-menu" aria-labelledby="batch_mod_menu">
1032 [% FOREACH header_ro IN header_row %]
1033 [% IF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
1034 <li class="dropdown-header">Bibliographic records</li>
1036 <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>
1039 <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>
1042 <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>
1045 [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
1046 <li class="dropdown-header">Item records</li>
1048 <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>
1051 <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>
1054 [% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
1055 <li class="dropdown-header">Patron records</li>
1057 <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>
1060 [% END # /FOREACH header_ro %]
1061 </ul> <!-- /.dropdown-menu -->
1062 </div> <!-- /.dropdown -->
1063 [% END # /IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1065 [% IF ( unlimited_total > 10 && limit <= 1000 ) %]
1066 <div class="btn-group">
1067 <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
1069 Rows per page: <strong>[% limit | html %]</strong>
1073 <span class="caret"></span>
1075 <ul class="dropdown-menu">
1076 [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
1077 [% FOREACH l IN limits %]
1080 <a class="limitselect" data-limit="[% l | html %]" href="#"><i class="fa fa-fw fa-check"></i> [% l | html %]</a>
1084 <a class="limitselect" data-limit="[% l | html %]" href="#"><i class="fa fa-fw"></i> [% l | html %]</a>
1090 [% END # /IF ( unlimited_total > 10 && limit <= 1000 ) %]
1092 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1093 <a href="#" class="btn btn-link" id="toggle_auto_links">
1094 <i class="fa fa-eye autolink" style="display:none"></i>
1095 <i class="fa fa-eye-slash autolink"></i>
1096 <span class="autolink" style="display:none">Show data menus</span>
1097 <span class="autolink">Hide data menus</span>
1100 </div> <!-- /#toolbar.btn-toolbar -->
1101 [% END # /IF batch operations || ( unlimited_total > 10 && limit <= 1000 ) %]
1104 [% pagination_bar | $raw %]
1107 [% END # UNLESS ( errors ) %]
1108 [% END # IF ( execute ) %]
1110 [% UNLESS ( errors ) %]
1111 <table id="report_results">
1114 [% FOREACH header_ro IN header_row %]
1115 [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
1116 <th class="itemnumber">[% header_ro.cell | html %]</th>
1117 [% ELSIF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
1118 <th class="biblionumber">[% header_ro.cell | html %]</th>
1119 [% ELSIF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
1120 <th class="cardnumber">[% header_ro.cell | html %]</th>
1121 [% ELSIF header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %]
1122 <th class="borrowernumber">[% header_ro.cell | html %]</th>
1124 <th>[% header_ro.cell | html %]</th>
1130 [% FOREACH result IN results %]
1132 [% FOREACH cells IN result.cells %]
1133 [% place = loop.index %]
1134 [%- IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
1135 <td class="batch-op itemnumber" data-number="itemnumber">
1136 <span class="data-plain">[% cells.cell | $raw %]</span>
1137 <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>
1138 <ul class="dropdown-menu pull-right" role="menu">
1139 <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>
1140 <li role="separator" class="divider"></li>
1141 <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>
1145 [% ELSIF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
1146 <td class="batch-op biblionumber" data-number="biblionumber">
1147 <span class="data-plain">[% cells.cell | $raw %]</span>
1148 <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>
1149 <ul class="dropdown-menu pull-right" role="menu">
1150 <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>
1151 <li role="separator" class="divider"></li>
1152 <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>
1156 [% ELSIF header_row.$place.cell == 'borrowernumber' || header_types.item(header_row.$place.cell) == 'borrowernumber' %]
1157 <td class="batch-op borrowernumber" data-number="borrowernumber">
1158 <span class="data-plain">[% cells.cell | $raw %]</span>
1159 <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>
1160 <ul class="dropdown-menu pull-right" role="menu">
1161 <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>
1162 <li role="separator" class="divider"></li>
1163 <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>
1164 <li role="separator" class="divider"></li>
1165 <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>
1169 [% ELSIF header_row.$place.cell == 'cardnumber' || header_types.item(header_row.$place.cell) == 'cardnumber' %]
1170 <td class="batch-op cardnumber" data-number="cardnumber">
1171 <span class="data-plain">[% cells.cell | $raw %]</span>
1172 <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>
1173 <ul class="dropdown-menu pull-right" role="menu">
1174 <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>
1180 [% cells.cell | $raw %]
1189 <div class="pages">[% pagination_bar | $raw %]</div>
1191 [% INCLUDE 'chart.inc' %]
1193 [% END #/IF ( execute ) %]
1196 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1197 <fieldset class="rows">
1198 <legend>Create report from SQL</legend>
1201 <label for="reportname" class="required">Report name:</label>
1202 [% IF ( reportname ) %]
1203 <input type="text" class="required" required="required" id="reportname" name="reportname" value="[% reportname | html %]" size="50"/>
1205 <input type="text" class="required" required="required" id="reportname" name="reportname" size="50" />
1207 <span class="required">Required</span>
1209 [% PROCESS group_and_subgroup_selection %]
1213 <label for="public">Report is public:</label>
1214 <select id="public" name="public">
1215 <option value="0">No (default)</option>
1216 <option value="1" selected="selected">Yes</option>
1221 <label for="public">Report is public:</label>
1222 <select id="public" name="public">
1223 <option value="0" selected="selected">No (default)</option>
1224 <option value="1">Yes</option>
1227 [% END # /IF (public) %]
1231 <label for="cache_expiry">Cache expiry:</label>
1232 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
1233 <select id="cache_expiry_units" name="cache_expiry_units">
1234 <option value="seconds" selected="selected">Seconds (default)</option>
1235 <option value="minutes">Minutes</option>
1236 <option value="hours">Hours</option>
1237 <option value="days">Days</option>
1240 [% END # /IF (usecache) %]
1242 <label for="notes">Notes:</label>
1243 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1246 </fieldset> <!-- /.rows -->
1248 <fieldset class="rows">
1249 <legend>SQL:</legend>
1250 <div style="margin:1em;">
1251 [% PROCESS insert_runtime_parameter %]
1252 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea>
1253 <span class="required">Required</span>
1257 <fieldset class="action">
1258 <input type="hidden" name="phase" value="Save Report" />
1259 <input type="submit" name="submit" value="Save report" />
1260 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1263 [% END #/IF ( create ) %]
1265 [% IF saved_results %]
1266 <h1>Saved report results</h1>
1267 <h2>[% name | html %]</h2>
1268 <p>[% notes | html %]</p>
1270 [% FOREACH rows IN saved_results %]
1272 [% FOREACH col IN rows %]
1273 <td>[% col | html %]</td>
1278 [% END # /IF saved_results %]
1280 [% IF ( showsql ) %]
1281 <fieldset class="rows">
1282 <legend>[% reportname | html %]</legend>
1286 <span class="label">Notes:</span>
1292 <textarea id="sql">[% sql | html %]</textarea>
1296 [% END # /IF ( showsql ) %]
1298 [% IF ( save_successful ) %]
1299 [% UNLESS ( errors ) %]
1301 <div id="report_updated">
1302 <div class="dialog message">
1303 <p>Your report "[% reportname | html %]" has been saved</p>
1309 [% IF ( editsql ) %]
1310 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1311 <input type="hidden" name="phase" value="Update SQL" />
1312 <input type="hidden" name="id" value="[% id | html %]"/>
1313 <fieldset class="rows">
1314 <legend>Edit SQL report</legend>
1317 <label for="reportname" class="required">Report name: </label>
1318 <input type="text" id="reportname" name="reportname" value="[% reportname | html %]" size="50" class="required" required="required" />
1319 <span class="required">Required</span>
1321 [% PROCESS group_and_subgroup_selection %]
1324 <label for="public">Report is public:</label>
1325 <select id="public" name="public">
1326 <option value="0">No (default)</option>
1327 <option value="1" selected="selected">Yes</option>
1332 <label for="public">Report is public:</label>
1333 <select id="public" name="public">
1334 <option value="0" selected="selected">No (default)</option>
1335 <option value="1">Yes</option>
1338 [% END # /IF (public) %]
1342 <label for="cache_expiry">Cache expiry:</label>
1343 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]" />
1344 <select id="cache_expiry_units" name="cache_expiry_units">
1345 <option value="seconds">Seconds (default)</option>
1346 <option value="minutes">Minutes</option>
1347 <option value="hours">Hours</option>
1348 <option value="days">Days</option>
1353 <label for="notes">Notes:</label>
1354 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1357 </fieldset> <!-- /.rows -->
1359 <fieldset class="rows">
1360 <legend>SQL:</legend>
1361 [% PROCESS insert_runtime_parameter %]
1362 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea>
1363 <span class="required" style="margin-left:30px;">Required</span>
1366 <fieldset class="action">
1367 <input type="submit" name="submit" value="Update SQL" />
1368 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1371 [% END # /IF ( editsql ) %]
1374 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
1375 <div class="dialog alert">
1376 <strong>The following error was encountered:</strong><br />
1377 [% FOREACH error IN errors %]
1378 [% IF ( error.sqlerr ) %]
1379 This report contains the SQL keyword <strong>[% error.sqlerr | html %]</strong>.<br />
1380 Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.<br />
1381 Please return to the "Saved Reports" screen and delete this report or retry creating a new one.
1382 [% ELSIF ( error.queryerr ) %]
1383 The database returned the following error: <br />
1384 [% error.queryerr | html %]<br />Please check the log for further details.
1385 [% ELSIF ( error.cache_expiry ) %]
1386 Please select a cache expiry less than 30 days.
1389 <div id="onerror_actions">
1390 <a href="#" class="button goback">Return to previous page</a>
1394 <fieldset class="action">
1395 <input type="hidden" name="phase" value="Use saved" />
1396 <input type="submit" name="submit" value="Saved reports" />
1399 [% END # /IF ( errors ) %]
1402 </div> <!-- /.col-sm-10.col-sm-push-2 -->
1404 <div class="col-sm-2 col-sm-pull-10">
1407 <div id="saved-reports-filter">
1408 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
1409 <input type="hidden" name="phase" value="Use saved" />
1410 <input type="hidden" name="filter_set" value="1" />
1411 <fieldset class="brief">
1415 <label for="filter_date">Date:</label>
1416 <input type="text" id="filter_date" name="filter_date" size="10" value="[% filters.date | html %]" class="flatpickr" />
1417 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
1420 <label for="filter_author">Author:</label>
1421 <input type="text" id="filter_author" name="filter_author" value="[% filters.author | html %]" size="16" />
1424 <label for="filter_keyword">Keyword:</label>
1425 <input type="text" id="filter_keyword" name="filter_keyword" value="[% filters.keyword | html %]" size="16" />
1428 </fieldset> <!-- /.brief -->
1429 <fieldset class="action">
1430 <input type="submit" value="Apply filter" />
1431 <a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1">Clear</a>
1434 </div> <!-- /#saved-reports-filter -->
1436 [% INCLUDE 'guided-reports-view.inc' %]
1438 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1439 </div> <!-- /.row -->
1441 <!-- Runtime Parameters Modal -->
1442 <div class="modal" id="runtime_parameters" tabindex="-1" role="dialog" aria-labelledby="runtime_parametersLabel">
1443 <div class="modal-dialog" role="document">
1444 <div class="modal-content">
1445 <div class="modal-header">
1446 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
1447 <h4 class="modal-title" id="runtime_parametersLabel">Runtime parameter options</h4>
1449 <form id="send_runtime_parameter">
1450 <input type="hidden" name="param_category" id="param_category" />
1451 <div class="modal-body">
1452 <div class="form-group">
1453 <label for="paramLabel" class="required">Parameter label: </label>
1454 <input class="form-control required" type="text" name="paramLabel" id="paramLabel" required="required" />
1455 <div class="hint">The label for the field shown when the report is run, e.g. "Select a library."</div>
1457 <div id="authorised_value_category" class="form-group" style="display:none">
1458 <label for="authorised_value">Authorized value category:</label>
1459 <select class="form-control" name="authorised_value" id="authorised_value">
1460 <option value=""></option>
1461 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories() %]
1463 <div class="hint">Select which authorized value category the user will choose from.</div>
1465 </div> <!-- /.modal-body -->
1466 <div class="modal-footer">
1467 <button type="submit" id="sendParam" class="btn btn-default approve">Insert parameter</button>
1468 <button type="button" class="btn btn-default deny" data-dismiss="modal">Cancel</button>
1469 </div> <!-- /.modal-footer -->
1470 </form> <!-- /#send_runtime_parameter -->
1471 </div> <!-- /.modal-content -->
1472 </div> <!-- /.modal-dialog -->
1473 </div> <!-- /#runtime_parameters -->
1475 [% MACRO jsinclude BLOCK %]
1476 [% Asset.js("js/charts.js") | $raw %]
1477 [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
1478 [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
1479 [% INCLUDE 'calendar.inc' %]
1480 [% INCLUDE 'datatables.inc' %]
1482 [% INCLUDE 'columns_settings.inc' %]
1484 [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
1485 [% Asset.js( "lib/codemirror/overlay.min.js" ) | $raw %]
1486 [% Asset.js( "lib/codemirror/sql.min.js" ) | $raw %]
1487 [% Asset.js( "js/mana.js" ) | $raw %]
1490 function hide_bar_element() {
1491 $('#chart-column-horizontal').hide()
1492 $('.chart-column-group').each(function( index ) {
1495 $('.chart-column-line').each(function( index ) {
1500 function show_bar_element() {
1501 $('#chart-column-horizontal').show()
1502 $('.chart-column-group').each(function( index ) {
1505 $('.chart-column-line').each(function( index ) {
1510 function removeColumn(id) {
1513 if ( $('.chart-column-conf').length == 1 ) {
1514 $('.chart-column-delete').remove();
1518 /* overlay a syntax-highlighting definition on top of the existing sql one */
1519 CodeMirror.defineMode("sqlPlaceholders", function(config, parserConfig) {
1520 var sqlPlaceholdersOverlay = {
1521 token: function(stream, state) {
1524 if (stream.match("<<")) {
1525 while ((ch = stream.next()) != null) {
1526 if (ch == ">" && stream.next() == ">") {
1533 if (stream.match("[[")) {
1534 while ((ch = stream.next()) != null) {
1535 if (ch == "]" && stream.next() == "]") {
1537 return "columnPlaceholder";
1542 else if (stream.next() != null) {
1547 return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/x-sql"), sqlPlaceholdersOverlay);
1550 var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1551 var group_subgroups = {};
1552 [% FOREACH group IN groups_with_subgroups %]
1553 var gid = "[% group.id | html %]"
1554 group_subgroups[gid] = new Array();
1555 [% FOREACH subgroup IN group.subgroups %]
1556 var sgid = "[% subgroup.id | html %]";
1557 var sgname = "[% subgroup.name | html %]";
1558 group_subgroups[gid].push([sgid, sgname]);
1562 [% IF ( create || editsql || save ) %]
1564 var editor = CodeMirror.fromTextArea(sql, {
1566 mode: "sqlPlaceholders", /* text/x-sql plus custom sqlPlaceholders configuration */
1571 // https://stackoverflow.com/questions/2086287/how-to-clear-jquery-validation-error-messages#answer-16025232
1572 function clearValidation( formElement ){
1573 // formElement should be a jQuery object
1574 var validator = formElement.validate();
1575 // Iterate through named elements inside of the form, and mark them as error free
1576 $('[name]',formElement).each(function(){
1577 validator.successList.push(this);//mark as error free
1578 validator.showErrors();//remove error messages if present
1580 validator.resetForm();//remove error class on name elements and clear history
1581 validator.reset();//remove all error and success data
1585 [% IF ( showsql ) %]
1586 var editor = CodeMirror.fromTextArea(sql, {
1588 mode: "sqlPlaceholders", /* text/x-sql plus custom sqlPlaceholders configuration */
1594 function showParamModal( category ){
1595 var modal = $("#runtime_parameters");
1596 var modalTitle = $("#runtime_parametersLabel");
1597 switch ( category ){
1598 case "insertAuthVal":
1599 modalTitle.text( _("Insert authorized value parameter") );
1600 $("#paramLabel").val( _("Authorized value") );
1601 $("#authorised_value_category").show();
1602 $("label[for='authorised_value']").addClass("required");
1603 $("#authorised_value").prop("required", true ).attr("required", "required").addClass("required");
1605 case "insertCnSource":
1606 modalTitle.text( _("Insert classification source parameter") );
1607 $("#paramLabel").val( _("Source of classification or shelving scheme") );
1608 $("#param_category").val("cn_source");
1610 case "insertFramework":
1611 modalTitle.text( _("Insert bibliographic framework parameter") );
1612 $("#paramLabel").val( _("Framework") );
1613 $("#param_category").val("biblio_framework");
1616 modalTitle.text( _("Insert date parameter") );
1617 $("#paramLabel").val( _("Date") );
1618 $("#param_category").val("date");
1620 case "insertItemtypes":
1621 modalTitle.text( _("Insert item types parameter") );
1622 $("#paramLabel").val( _("Item type") );
1623 $("#param_category").val("itemtypes");
1625 case "insertBranches":
1626 modalTitle.text( _("Insert libraries parameter") );
1627 $("#paramLabel").val( _("Library") );
1628 $("#param_category").val("branches");
1630 case "insertCategorycode":
1631 modalTitle.text( _("Insert patron category parameter") );
1632 $("#paramLabel").val( _("Patron category") );
1633 $("#param_category").val("categorycode");
1635 case "insertCashregister":
1636 modalTitle.text( _("Insert cash register parameter") );
1637 $("#paramLabel").val( _("Cash register") );
1638 $("#param_category").val("cash_registers");
1640 case "insertDebittypes":
1641 modalTitle.text( _("Insert debit types parameter") );
1642 $("#paramLabel").val( _("Debit types") );
1643 $("#param_category").val("debit_types");
1645 case "insertCredittypes":
1646 modalTitle.text( _("Insert credit types parameter") );
1647 $("#paramLabel").val( _("Credit types") );
1648 $("#param_category").val("credit_types");
1651 modalTitle.text( _("Insert list parameter") );
1652 $("#paramLabel").val( _("List of values") );
1653 $("#param_category").val("list");
1656 modalTitle.text( _("Insert text parameter") );
1657 $("#paramLabel").val( _("Text") );
1658 $("#param_category").val("");
1661 $("#paramLabel").select();
1662 modal.modal("show");
1665 function load_group_subgroups () {
1666 var group = $("#group_select").val();
1667 var sg = $("#subgroup");
1668 $(sg).find('option[value!=""]').each(function() {
1673 var select = $(sg).find('select')[0];
1674 $.each( group_subgroups[group], function(index, value) {
1675 $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1677 $("#subgroup, #subgroup *").show();
1682 * Process the value of the NumSavedReports system preference for use as
1683 a DataTable pageLenth option
1684 * @param {string} pageLength - The value of the NumSavedReports system
1685 preference, passed via the template during table initiation
1686 * @return {number} - The number of results to show by default in the
1687 DataTable (-1 for "all")
1689 function getPageLength( pageLength ){
1690 if( pageLength !== "" ){
1691 if( Number( pageLength ) > 0 ){
1692 return Number( pageLength );
1694 return 20; /* Negative or non-numeric value passed. Use default 20 */
1702 * Rebuild the DataTable's lengthMenu array, adding the value of the NumSavedReports
1704 * @param {string} pageLength - The value of the NumSavedReports system
1705 preference, passed via the template during table initiation
1706 * @return {Array} - An array of two arrays: 1. The numeric values for
1707 options in the pageLenth <select>; 2. The text values for options in
1708 the pageLength <select>;
1710 function buildLengthMenu( num ){
1711 var lengthMenu = dataTablesDefaults.lengthMenu;
1712 var pageLength = getPageLength( num );
1713 if( !lengthMenu[0].includes( pageLength ) ){
1714 /* extend lengthMenu with custom value */
1715 lengthMenu.forEach( function( item ){
1716 item.pop(); /* Remove the last entry, "all" */
1717 item.push( Number( pageLength ) ); /* Add the value from NumSavedReports */
1718 item.sort(function( a, b ){ /* Re-sort the values */
1722 lengthMenu[0].push(-1); /* Add the numeric "all" option */
1723 lengthMenu[1].push( _("All") ); /* Add the textual "all" option */
1728 $(document).ready(function(){
1730 var activeTab = localStorage.getItem("sql_reports_activetab");
1732 $("body").on('click',".fetch_chart_data",function(){
1733 if( [% unlimited_total || 0 | $raw %] > 1000 ){
1734 if( confirm( _("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you want to chart this report?") ) ){
1745 if ( $('.chart-column-conf').length == 1 ) {
1746 $('.chart-column-delete').remove();
1749 $(".chart-column-delete").on('click', function(e){
1751 removeColumn('column_' + $(this).data('column'));
1754 $('#download-chart').click(function() {
1755 var svg = '<svg>' + $('#chart svg').html() + '</svg>';
1756 this.href = 'data:application/octet-stream;base64,' + btoa(svg);
1757 this.setAttribute('download', 'chart.svg');
1760 $('#chart-type').change(function() {
1761 if ($(this).val() == 'bar') {
1769 $('#download-chart').hide();
1772 [% IF results && !errors %]
1773 $('#draw-chart').click(function() {
1775 var x_elements = $('select[name="x"]').val();
1776 var y_elements = [];
1781 headers = [% header_row.json | $raw %];
1784 [% IF allresults.size %]
1785 if ($('input[name="chart-include-all"]').prop('checked')) {
1786 results = [% allresults.json | $raw %]
1789 results = [% results.json | $raw %]
1792 results = [% results.json | $raw %];
1795 if ($('input[name="chart-exclude-last"]').prop('checked')) {
1796 results.splice(-1, 1);
1799 $('select[name="y"]').each(function( index ) {
1800 y_elements.push( $(this).val() );
1802 $('select[name="group"]').each(function( index ) {
1803 groups.push( $(this).val() );
1805 $('.column-line').each(function( index ) {
1806 if ($(this).prop('checked')) {
1807 lines.push( $(this).attr('name') );
1811 // Remove deleted columns from headers and results.
1812 var deleted_indexes = [];
1813 var kept_headers = [];
1814 $.each(headers, function(index, value) {
1815 if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) {
1816 // This header is neither a x element nor in y elements. Don't need it.
1817 deleted_indexes.push(index);
1820 kept_headers.push({cell: value.cell});
1824 // Remove coresponding cells.
1825 var kept_results = [];
1826 $.each(results, function(index, value) {
1829 $.each(value.cells, function(i, val) {
1830 if ($.inArray(i, deleted_indexes) === -1) {
1831 line['cells'].push({cell: val.cell});
1834 kept_results.push(line);
1837 options.type = $('select[name="chart-type"]').val();
1838 options.horizontal = $('input[name="column-horizontal"]').prop('checked');
1839 options.lines = lines;
1841 chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options);
1842 $("#download-chart,#toggle_chart_settings_hid,#chart").show();
1843 $("#toggle_chart_settings_vis").hide();
1844 $("#chartModal").modal("hide");
1848 load_group_subgroups();
1851 $('[data-toggle="tooltip"]').tooltip();
1852 var columns_settings = [% TablesSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1854 $('#limit').change(function() {
1855 $('#limitselect').submit();
1858 $(document).click(function() {
1859 $('#report_updated').hide();
1862 $(".goback").on("click",function(e){
1864 window.history.back();
1867 $("body").on("click", ".mana_search_button", function(){
1868 $("#mana-loading").show();
1869 mana_search($("#mana_search_field").val());
1872 $(".ShareButton").on("click", function(){
1873 $("#note-error").hide();
1874 if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
1875 $(".shared_infos").hide();
1876 $("#note-error").show();
1879 $("#reportid").val($(this).closest("tr").find(".report_id").text());
1880 $("#shared_id").html($(this).closest("tr").find(".report_id").text());
1881 $("#shared_name").html($(this).closest("tr").find(".report_name").text());
1882 $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
1883 $("#shared_type").html($(this).closest("tr").find(".report_type").text());
1884 $("#shared_group").html($(this).closest("tr").find(".report_group").text());
1885 $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
1889 $("#ManaCloseButton").on("click", function() {
1890 $(".shared_infos").show();
1893 $("#addColumn").on("click",function(){
1897 $("#delColumn").on("click",function(){
1902 var rtable = KohaTable("table_reports", {
1903 "pageLength": getPageLength( "[% Koha.Preference('NumSavedReports') | html %]" ),
1904 "lengthMenu": buildLengthMenu( "[% Koha.Preference('NumSavedReports') | html %]" ),
1905 'bAutoWidth': false,
1906 'sPaginationType': 'full',
1907 'aaSorting': [[ 1, "asc" ]],
1909 'sZeroRecords': _("No matching reports found")
1911 }, columns_settings);
1913 var rtabs = $("#tabs").tabs({
1914 create: function( e, ui ){
1915 tabsInit( ui, rtable );
1917 activate: function( e, ui ){
1918 tabsInit( ui, rtable );
1922 $("#tabs").tabs("option","active", activeTab );
1925 $("#subgroup_filter").change(function() {
1926 var selected = $(this).find('option:selected');
1927 var sg_id = $(selected).val();
1928 var sg_name = $(selected).text();
1929 if (sg_id.length > 0) {
1930 rtable.fnFilter('^' + sg_name + '$', 5, true, true, true, false);
1931 rtable.fnSetColumnVis(5, false);
1933 rtable.fnFilter('', 5);
1934 rtable.fnSetColumnVis(5, true);
1938 $("#reports_form").submit(function(){
1939 var checkedItems = $("input[name=ids]:checked");
1940 if ($(checkedItems).size() == 0) {
1941 alert(_("You must select one or more reports to delete"));
1944 $(checkedItems).parents('tr').addClass("warn");
1945 if( confirm(_("Are you sure you want to delete the selected reports?")) ) {
1948 $(checkedItems).parents('tr').removeClass("warn");
1953 $("body").on("click", ".update_sql", function(e){
1955 var ltitle = $(this).text();
1956 var report_id = $(this).data("report_id");
1957 var page = $(this).attr("href");
1958 $("#update_sql .modal-body").load(page + " div", function(){
1959 var diff1 = $("#col1 .show_sql").text();
1960 var diff2 = $("#col2 .show_sql").text();
1961 var diffs = diffString( escape(diff1), escape(diff2) );
1962 $("#col1 .show_sql,#col2 .show_sql").html(diffs);
1964 $('#update_sql').modal('show');
1965 $("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?phase=Use saved&op=convert&report_id=" + report_id);
1968 $("#update_sql").on("hidden.bs.modal", function(){
1969 $("#update_sql_label").html("");
1970 $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1974 [% IF ( showsql ) %]
1975 $("#sql").focus(function() {
1980 $(".toggle_sql").click(function(){
1981 $("#sql_output").toggle();
1982 $("#toggle_sql_hid").toggle();
1983 $("#toggle_sql_vis").toggle();
1985 showsql = CodeMirror.fromTextArea(sql, {
1994 $(".toggle_chart_settings").click(function(){
1995 $("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
1998 $("#table_reports").delegate(".confirmdelete", 'click', function(){
1999 $(this).parents('tr').attr("class","warn");
2000 if(confirm(_("Are you sure you want to delete this saved report?"))){
2003 $(this).parents('tr').attr("class","");
2008 [% IF (create || editsql || save) %]
2010 var validated_form = $("#sql_report_form").validate({
2011 reportname: "required",
2014 depends: function(element) {
2015 return $("#create_group").prop("checked") && $("#groupdesc_input").val() != '';
2021 depends: function(element) {
2022 return $("#create_group").prop("checked") && $("#group_input").val() != '';
2028 $("#select_group").change(function() {
2029 if($(this).prop('checked')) {
2030 $("#group_input").attr("class","").prop('disabled', true).prop("required", false);
2031 $("#groupdesc_input").attr("class","").prop('disabled', true).prop("required", false);
2032 $("#group_select").prop('disabled', false);
2033 clearValidation( $("#sql_report_form") );
2034 if ($("#group_select").val().length > 0) {
2035 $("#select_subgroup").prop('checked', true);
2036 $("#select_subgroup").change();
2037 $("#subgroup, #subgroup *").show();
2039 $("#subgroup").hide();
2043 $("#create_group").change(function() {
2044 if($(this).prop('checked')) {
2045 $("#group_input").prop('disabled', false).prop("required", true );
2046 $("#groupdesc_input").prop('disabled', false).prop("required", true );
2047 $("#group_select").prop('disabled', true);
2048 // $("#create_subgroup").prop('checked', true).change();
2049 $("#subgroup_select").hide();
2050 $("#subgroup input[type='radio']").hide();
2051 $("#subgroup label[for]").hide();
2052 $("#subgroup_input").prop("required", false ).prop("disabled", false).show();
2053 $("#subgroupdesc_input").prop("required", false ).prop("disabled", false).show();
2054 $("#subgroup").show();
2055 // Add validation rules for fields which were previously hidden
2056 $("#subgroup_input").rules("add", {
2058 depends: function(element) {
2059 return $("#create_group").prop("checked") && $("#subgroupdesc_input").val() != '';
2063 $("#subgroupdesc_input").rules("add", {
2065 depends: function(element) {
2066 return $("#create_group").prop("checked") && $("#subgroup_input").val() != '';
2072 $("#select_subgroup").change(function() {
2073 if($(this).prop('checked')) {
2074 $("#subgroup_select").prop('disabled', false);
2075 $("#subgroup_input").prop('disabled', true).prop("required", false );
2076 $("#subgroupdesc_input").prop('disabled', true).prop("required", false );
2077 clearValidation( $("#sql_report_form") );
2080 $("#create_subgroup").change(function() {
2081 if($(this).prop('checked')) {
2082 $("#subgroup_input").prop('disabled', false).prop("required", true );
2083 $("#subgroupdesc_input").prop('disabled', false).prop("required", true );
2084 $("#subgroup_select").val("").prop('disabled', true);
2087 $("#select_group").change();
2088 $("#select_subgroup").change();
2089 $("#group_select").on("change",function(){
2090 load_group_subgroups();
2093 $(".insertParam").on("click", function(e){
2095 var category = this.id;
2096 showParamModal( category );
2099 $("#runtime_parameters").on("shown.bs.modal", function(){
2100 $("#paramLabel").focus();
2103 $("#runtime_parameters").on("hide.bs.modal", function(){
2104 $("#send_runtime_parameter")[0].reset();
2105 $("#authorised_value_category").val("").hide();
2106 $("label[for='authorised_value']").removeClass("required");
2107 $("#authorised_value").prop("required", false ).removeAttr("required").removeClass("required");
2110 $("#send_runtime_parameter").on("submit", function(e){
2112 /* Get form values */
2113 var paramLabel = $("#paramLabel").val();
2114 var param_category = $("#param_category").val();
2115 var categoryLabel = $("#authorised_value").val();
2116 // Get CodeMirror environment variables
2117 var selection = editor.getSelection();
2118 var doc = editor.getDoc();
2119 var cursor = doc.getCursor();
2124 /* Build runtime parameter text string */
2126 if( paramLabel && param_category ){
2127 text += paramLabel + "|" + param_category;
2128 } else if( paramLabel ) {
2130 } else if( param_category ){
2131 text += param_category;
2134 text = " <<" + text + ">> ";
2135 if( selection.length > 0){
2136 editor.replaceSelection(text);
2138 doc.replaceRange(text, pos);
2141 $("#runtime_parameters").modal("hide");
2144 $("#authorised_value").on("change", function(){
2145 $("#param_category").val( $(this).val() );
2150 $(".delete").on("click",function(){
2151 return confirmDelete(MSG_CONFIRM_DELETE);
2154 $("#mana_search_form").submit(function(e){
2158 $("#column_submit").submit(function() {
2159 if ($("#selectedColumns option").size() < 1) {
2160 alert(_("No columns selected!"));
2163 $("#selectedColumns option").attr("selected", "selected"); // Select everything still in #selectedColumns
2168 $("body").on("click", ".mana-use", function(e) {
2170 $(this).find("i").attr("class","fa fa-refresh fa-spin");
2171 mana_use( $(this).data("report_id") );
2174 $("#mana_search_result").on("hide.bs.modal", function(){
2175 $("#mana_result_content").html("");
2176 $("#mana_search_field").val("");
2179 $(".batch_op").on("click", function(e){
2181 var target_form = $(this).data("submit");
2182 $("#" + target_form ).submit();
2185 $("#batch_add_to_list").on("submit", function(e){
2190 $("body").on("click", ".preview_sql", function(e){
2192 var reportid = $(this).data("reportid");
2193 previewSql( reportid );
2195 $(".limitselect").on("click", function(){
2196 var limit = $(this).data("limit");
2197 $("#limit").val( limit );
2198 $("#limitselect").submit();
2203 $("#toggle_auto_links").on("click", function(e){
2205 if( $(".data-plain").is(":visible") ){
2206 /* if a data-plain element is visible, this click hides it and shows auto-links */
2207 localStorage.removeItem("reports_auto_link_off");
2209 /* if a data-plain element is hidden, this click shows it and hides auto-links */
2210 localStorage.setItem("reports_auto_link_off", 1);
2212 $(".data-plain,.autolink").toggle();
2214 if ( localStorage.getItem("reports_auto_link_off") == 1 ){
2215 $("#toggle_auto_links").click();
2218 function tabsInit( ui, rtable ){
2219 var thisTab = ui.newTab ? ui.newTab : ui.tab;
2220 var activeTab = thisTab.index();
2221 localStorage.setItem("sql_reports_activetab", activeTab );
2223 $("#subgroup_filter option").each(function() {
2224 if($(this).val().length > 0) {
2228 rtable.fnFilter('', 4);
2229 rtable.fnFilter('', 5);
2230 rtable.fnSetColumnVis(4, true);
2231 rtable.fnSetColumnVis(5, true);
2233 var g_id = $(ui.newTab).children().attr('id');
2234 var g_name = $(ui.newTab).text();
2235 if ( g_name == _("All") ) {
2240 if (g_id && g_id.length > 0) {
2241 rtable.fnFilter('^' + g_name + '$', 4, true, true, true, false);
2242 rtable.fnSetColumnVis(4, false);
2243 for(var i in group_subgroups[g_id]) {
2244 $("#subgroup_filter").append(
2245 '<option value="' + group_subgroups[g_id][i][0] + '">'
2246 + group_subgroups[g_id][i][1] + '</option>'
2249 $("#subgroup_filter_block").show();
2251 $("#subgroup_filter_block").hide();
2255 function addColumn() {
2256 $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
2258 function delColumn() {
2259 $("#selectedColumns option:selected").remove();
2263 function mana_use( mana_id ){
2266 url: "/cgi-bin/koha/svc/mana/use",
2267 data: {id:mana_id, resource: 'report', saveinbase: 1},
2270 .done( function (result){
2271 if ( result.errmsg ){
2272 alert( result.errmsg );
2275 window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&phase=Show%20SQL&mana_success=1");
2278 .fail(function( error ) {
2279 $(".mana_use_status").hide();
2280 $("#mana_use_errortext").html( error.status + " " + error.statusText );
2281 $("#mana_use_failed").show();
2282 $(".mana-use i").attr("class","fa fa-download");
2286 function mana_search( textquery ){
2287 $(".mana_search_status").hide();
2288 $("#mana_result_content").load("/cgi-bin/koha/svc/mana/search #mana_results", { resource: 'report', id: textquery, usecomments: 1 }, function( response, status, xhr ) {
2290 if ( status == "error" ) {
2291 $("#mana_search_errortext").html( xhr.status + " " + xhr.statusText );
2292 $("#mana_search_failed").show();
2293 $("#mana-loading").hide();
2295 $(".mana_search_status").hide();
2296 $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
2297 $("#mana-loading").hide();
2298 $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
2299 "sPaginationType":"full",
2302 { "width": "35%", "targets": 1 }
2305 { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
2306 { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
2310 $(".showbutton").on("click", function(e){
2312 $(this).parent().hide();
2313 $(this).parent().next().show();
2316 $(".hidebutton").on("click", function(e){
2318 $(this).parent().hide();
2319 $(this).parent().prev().show();
2322 if($("td.dataTables_empty").length == 0){
2323 $("#mana_search_message").show();
2329 function addToList() {
2330 var biblionumbers = [];
2331 $(".bib_to_list").each(function() {
2332 var biblionumber = Number( $(this).val() );
2333 if( biblionumbers.indexOf( biblionumber ) < 0 ){
2334 biblionumbers.push( biblionumber );
2337 bibs = biblionumbers.join("/");
2338 var url = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumbers=" + bibs;
2339 window.open(url, 'Add_to_virtualshelf', 'width=500, height=400, toolbar=false, scrollbars=yes');
2343 // Adapted from https://gist.github.com/jnormore/7418776
2344 function previewSql(reportid) {
2347 var message = $("#previewSql" + reportid ).val();
2348 var title = $("#previewSql" + reportid ).data("title");
2349 if( $("#preview-sql-modal").length > 0) {
2350 $("#preview-sql-modal").remove();
2352 $("body").append('<div id="preview-sql-modal" tabindex="-1" role="dialog" aria-hidden="true" class="modal">\
2353 <div class="modal-dialog">\
2354 <div class="modal-content">\
2355 <div class="modal-header" style="min-height:40px;">\
2356 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">\
2357 <span aria-hidden="true">×</span>\
2359 <h4 class="modal-title">' + title + '</h4>\
2361 <div class="modal-body"><textarea id="code' + reportid + '">' + message + '</textarea>\
2362 <div class="modal-footer">\
2363 <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>\
2364 <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>\
2365 <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>\
2366 <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>\
2367 <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>\
2368 <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>\
2374 $("#preview-sql-modal").modal('show');
2375 CodeMirror.fromTextArea( document.getElementById("code" + reportid ), {
2385 [% INCLUDE 'intranet-bottom.inc' %]
2387 [% BLOCK group_and_subgroup_selection %]
2389 <label>Report group:</label>
2390 <input type="radio" name="select_or_create_group"
2391 id="select_group" checked="checked" />
2392 <label for="select_group" style="float:none">Select</label>
2393 <select name="group" id="group_select">
2394 <option value="">(None)</option>
2395 [% FOREACH group IN groups_with_subgroups %]
2396 [% IF (group.selected) %]
2397 <option value="[% group.id | html %]" selected="selected">
2399 <option value="[% group.id | html %]">
2401 [% group.name | html %]
2405 <input type="radio" name="select_or_create_group" id="create_group" />
2406 <label for="create_group" style="float:none">or create:</label>
2407 <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
2408 <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
2411 <label>Report subgroup:</label>
2412 <input type="radio" name="select_or_create_subgroup"
2413 id="select_subgroup" checked="checked" />
2414 <label for="select_subgroup" style="float:none">Select</label>
2415 <select name="subgroup" id="subgroup_select">
2416 <option value="">(None)</option>
2417 [% FOREACH group IN groups_with_subgroups %]
2418 [% IF (group.selected) %]
2419 [% FOREACH subgroup IN group.subgroups %]
2420 [% IF (subgroup.selected) %]
2421 <option value="[% subgroup.id | html %]" selected="selected">
2423 <option value="[% subgroup.id | html %]">
2425 [% subgroup.name | html %]
2431 <input type="radio" name="select_or_create_subgroup"
2432 id="create_subgroup" />
2433 <label for="create_subgroup" style="float:none">or create</label>
2434 <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
2435 <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />
2439 [% BLOCK insert_runtime_parameter %]
2440 <div class="btn-group" style="margin-left:30px;">
2441 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
2442 Insert runtime parameter <span class="caret"></span>
2444 <ul class="dropdown-menu">
2445 <li><a href="#" class="insertParam" id="insertAuthVal">Authorized values</a></li>
2446 <li><a href="#" class="insertParam" id="insertFramework">Bibliographic framework</a></li>
2447 <li><a href="#" class="insertParam" id="insertCnSource">Classification sources</a></li>
2448 <li><a href="#" class="insertParam" id="insertDate">Date</a></li>
2449 <li><a href="#" class="insertParam" id="insertItemtypes">Item types</a></li>
2450 <li><a href="#" class="insertParam" id="insertBranches">Libraries</a></li>
2451 <li><a href="#" class="insertParam" id="insertList">List</a></li>
2452 <li><a href="#" class="insertParam" id="insertCategorycode">Patron categories</a></li>
2453 <li><a href="#" class="insertParam" id="insertCashregister">Cash register</a></li>
2454 <li><a href="#" class="insertParam" id="insertDebittypes">Debit types</a></li>
2455 <li><a href="#" class="insertParam" id="insertCredittypes">Credit types</a></li>
2456 <li><a href="#" class="insertParam" id="insertText">Text field</a></li>