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' %]
25 <title>[% FILTER collapse %]
27 [% t("Saved reports") | html %] ›
28 [% ELSIF ( create ) %]
29 [% t("Create from SQL") | html %] ›
30 [% ELSIF ( showsql ) %]
31 [% t("SQL view") | html %] ›
32 [% t("Saved reports") | html %] ›
33 [% ELSIF ( execute ) %]
34 [% tx("Report {reportname} ({id})", { reportname = name, id = id }) | html %] ›
35 [% t("Saved reports") | html %] ›
36 [% ELSIF ( editsql ) %]
37 [% tx("Edit report {reportname} ({id})", { reportname = reportname, id = id }) | html %] ›
38 [% t("Saved reports") | html %] ›
42 [% t("Build a report, step 1 of 6: Choose a module") | html %] ›
43 [% ELSIF ( build2 ) %]
44 [% t("Build a report, step 2 of 6: Pick a report type") | html %] ›
45 [% ELSIF ( build3 ) %]
46 [% t("Build a report, step 3 of 6: Select columns for display") | html %] ›
47 [% ELSIF ( build4 ) %]
48 [% t("Build a report, step 4 of 6: Select criteria to limit on") | html %] ›
49 [% ELSIF ( build5 ) %]
50 [% t("Build a report, step 5 of 6: Pick which columns to total") | html %] ›
51 [% ELSIF ( build6 ) %]
52 [% t("Build a report, step 6 of 6: Select how you want the report ordered") | html %] ›
54 [% t("Guided reports wizard") | html %] ›
55 [% t("Reports") | html %] ›
56 [% t("Koha") | html %]
59 [% INCLUDE 'doc-head-close.inc' %]
60 [% Asset.css("lib/codemirror/codemirror.min.css") | $raw %]
68 .cm-columnPlaceholder {
71 #mana_search_errortext {
72 font-family: monospace; font-weight: bold;
78 [% Asset.css("css/reports.css") | $raw %]
79 [% Asset.css("lib/d3c3/c3.min.css") | $raw %]
82 <body id="rep_guided_reports_start" class="rep">
83 [% WRAPPER 'header.inc' %]
84 [% INCLUDE 'circ-search.inc' %]
87 [% WRAPPER 'sub-header.inc' %]
88 [% WRAPPER breadcrumbs %]
89 [% WRAPPER breadcrumb_item %]
90 <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
92 [% WRAPPER breadcrumb_item %]
93 <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
95 [% IF ( showsql || editsql || execute ) %]
96 [% WRAPPER breadcrumb_item %]
97 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=list">Saved reports</a>
101 [% WRAPPER breadcrumb_item bc_active= 1 %]
102 <span>Saved reports</span>
104 [% ELSIF ( create ) %]
105 [% WRAPPER breadcrumb_item bc_active= 1 %]
106 <span>Create from SQL</span>
108 [% ELSIF ( showsql ) %]
109 [% WRAPPER breadcrumb_item bc_active= 1 %]
110 [% reportname | html %] ([% id | html %])
112 [% ELSIF ( editsql ) %]
113 [% WRAPPER breadcrumb_item %]
114 <a href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | uri %]&op=show">[% reportname | html %] ([% id | html %])</a>
116 [% WRAPPER breadcrumb_item bc_active= 1 %]
119 [% ELSIF ( execute ) %]
120 [% WRAPPER breadcrumb_item %]
121 <a href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | uri %]&op=show">[% name | html %] ([% id | html %])</a>
123 [% WRAPPER breadcrumb_item bc_active= 1 %]
126 [% ELSIF ( build1 || build2 || build3 || build4 || build5 || build6 ) %]
127 [% WRAPPER breadcrumb_item %]
128 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form">Build a report</a>
130 [% WRAPPER breadcrumb_item bc_active= 1 %]
132 <span>Step 1 of 6: Choose a module</span>
133 [% ELSIF ( build2 ) %]
134 <span>Step 2 of 6: Pick a report type</span>
135 [% ELSIF ( build3 ) %]
136 <span>Step 3 of 6: Select columns for display</span>
137 [% ELSIF ( build4 ) %]
138 <span>Step 4 of 6: Select criteria to limit on</span>
139 [% ELSIF ( build5 ) %]
140 <span>Step 5 of 6: Pick which columns to total</span>
141 [% ELSIF ( build6 ) %]
142 <span>Step 6 of 6: Select how you want the report ordered</span>
143 [% END # /IF ( build1 ) %]
144 [% END # /WRAPPER breadcrumb_item %]
145 [% END # /IF ( saved1 ) %]
146 [% END # /WRAPPER breadcrumbs %]
147 [% END # /WRAPPER 'sub-header.inc' %]
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">
171 [% INCLUDE 'messages.inc' %]
173 [% INCLUDE "reports-toolbar.inc" %]
176 <h1>Guided reports</h1>
177 <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>
179 <h3>Build and run reports</h3>
181 [% IF ( CAN_user_reports_create_reports ) %]
182 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form" class="btn btn-primary"/>Build new</a>
185 [% IF ( CAN_user_reports_execute_reports ) %]
186 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=list" class="btn btn-primary"/>Use saved</a>
189 [% IF ( CAN_user_reports_create_reports ) %]
190 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form_sql" class="btn btn-primary"/>Create report from SQL</a>
193 <h3>Reports Dictionary</h3>
194 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
195 <a href="/cgi-bin/koha/reports/dictionary.pl?op=list" class="btn btn-primary"/>View dictionary</a>
196 [% END # /IF (start) %]
198 [% IF report_converted %]
199 <div class="dialog message">
200 The report "[% report_converted | html %]" has been converted.
204 [% IF report_converted %]
205 <div class="dialog message">
206 The report "[% report_converted | html %]" has been converted.
211 <h1>Saved reports</h1>
212 [% IF ( savedreports ) %]
214 [% IF ( filters.date || filters.author || filters.keyword ) %]
216 <span class="filter">
217 [% IF ( filters.date ) %]
218 <span class="filter_date"><strong>Date:</strong> [% filters.date | html %]</span>
220 [% IF ( filters.author ) %]
221 <span class="filter_author"><strong>Author:</strong> [% filters.author | html %]</span>
223 [% IF ( filters.keyword ) %]
224 <span class="filter_keyword"><strong>Keyword:</strong> [% filters.keyword | html %]</span>
226 <a class="clear_filter" href="/cgi-bin/koha/reports/guided_reports.pl?op=list&clear_filters=1"><i class="fa fa-times"></i> Clear</a>
231 [% WRAPPER tabs id= "tabs" %]
232 [% WRAPPER tabs_nav %]
233 [% WRAPPER tab_item tabname= "reports" bt_active= 1 %] <span>All</span> [% END %]
234 [% FOREACH group IN groups_with_subgroups %]
235 [% WRAPPER tab_item tabname= group.id %] <span>[% group.name | html %]</span> [% END %]
237 [% END # /WRAPPER tabs_nav %]
239 [% WRAPPER tab_panels %]
240 [% WRAPPER tab_panel tabname="reports" bt_active= 1 %]
242 <div id="subgroup_filter_block">
243 <label for="subgroup_filter">Subgroup:</label>
244 <select id="subgroup_filter">
245 <option value="">All</option>
249 [% IF (Koha.Preference('Mana') == 1) %]
251 <div id="mana_search_message" class="dialog message">
252 <p> [% manamsg | html %] </p>
257 <form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
258 [% INCLUDE 'csrf-token.inc' %]
259 <input type="hidden" name="op" value="cud-delete" />
260 <table id="table_reports">
263 <th class="NoSort"> </th>
271 <th>Creation date</th>
274 <th class="report_public">Public</th>
275 <th class="report_json_url">JSON URL</th>
277 <th>Cache expiry (seconds)</th>
279 <th class="NoVisible">Cache expiry (seconds)</th>
281 <th>Saved results</th>
282 [% IF has_obsolete_reports %]
285 <th class="NoVisible">Update</th>
287 <th class="NoSort noExport">Actions</th>
291 [% FOREACH savedreport IN savedreports %]
292 [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
293 <td class="report_checkbox">
294 [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
295 <input type="checkbox" name="id" id="id_[% savedreport.id | html %]" value="[% savedreport.id | html %]" />
297 <input type="hidden" class="report_sql" value="[% savedreport.savedsql |html %]">
299 <td class="report_id">
300 <label for="id_[% savedreport.id | html %]">[% savedreport.id | html %]</label>
302 <td class="report_name">
303 [% IF ( savedreport.report_name ) %]
304 [% savedreport.report_name | html %]
309 <td class="report_type">
310 [% savedreport.type | html %]
312 <td data-search="[% savedreport.report_group | html %]" class="report_group">
313 [% savedreport.groupname | html %]
315 <td data-search="[% savedreport.report_subgroup | html %]">
316 [% savedreport.subgroupname | html %]
318 <td class="report_notes">
319 [% savedreport.notes | html %]
322 [%- savedreport.borrowersurname | html -%][%- IF ( savedreport.borrowerfirstname ) -%], [%- savedreport.borrowerfirstname | html -%][%- END -%]
323 ([% savedreport.borrowernumber | html %])
325 <td data-order="[% savedreport.date_created | html %]">
326 [% savedreport.date_created | $KohaDates %]
328 <td data-order="[% savedreport.last_modified | html %]">
329 [% savedreport.last_modified | $KohaDates with_hours => 1 %]
331 <td data-order="[% savedreport.last_run | html %]">
332 [% savedreport.last_run | $KohaDates with_hours => 1 %]
334 <td class="report_public">
335 [% IF (savedreport.public) %]
341 <td class="report_json_url">
342 [% IF (savedreport.public) %]
343 <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>
345 <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>
349 [% savedreport.cache_expiry | html %]
352 [% FOR result IN savedreport.results %]
353 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=retrieve_results&id=[% result.id | uri %]">[% result.date_run | html %]</a>
358 [% IF savedreport.seems_obsolete %]
359 This report seems obsolete, it uses biblioitems.marcxml field.
360 <a href="/cgi-bin/koha/svc/convert_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-solid fa-eye"></i> Update SQL</a>
364 <div class="btn-group dropup">
365 [%# There should be no space between these two buttons, it would render badly %]
366 <a class="btn btn-default btn-xs" role="button"
367 href="/cgi-bin/koha/reports/guided_reports.pl?id=[% savedreport.id | html %]&op=run"><i
368 class="fa fa-play"></i> Run</a><a
369 class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown"
370 href="#"><b class="caret"></b></a>
371 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
372 <li><a href="/cgi-bin/koha/reports/guided_reports.pl?id=[% savedreport.id | uri %]&op=show"><i class="fa fa-search"></i> View</a></li>
374 <a href="/cgi-bin/koha/reports/guided_reports.pl?id=[% savedreport.id | uri %]&op=show" class="preview_sql" data-reportid="[% savedreport.id | html %]">
375 <i class="fa-solid fa-eye"></i> Preview SQL
378 [% IF ( CAN_user_reports_create_reports ) %]
379 <li><a href="/cgi-bin/koha/reports/guided_reports.pl?id=[% savedreport.id | uri %]&op=edit_form"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li>
380 <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?op=duplicate&id=[% savedreport.id | uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
382 [% IF (Koha.Preference('Mana') == 1) %]
383 <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>
385 <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa-solid fa-clock"></i> Schedule</a></li>
386 [% IF ( CAN_user_reports_delete_reports ) %]
388 <form method="post" action="/cgi-bin/koha/reports/guided_reports.pl">
389 [% INCLUDE 'csrf-token.inc' %]
390 <input type="hidden" name="op" value="cud-delete" />
391 <input type="hidden" name="id" value="[% savedreport.id | html %]" />
393 <a href="#" class="delete" title="Delete this saved report"><i class="fa fa-trash-can"></i> Delete</a>
398 <input type="hidden" id="previewSql[% savedreport.id | html %]" value="[% savedreport.savedsql | html %]" data-title="[% savedreport.report_name | html %]" />
405 [% IF ( CAN_user_reports_delete_reports ) %]
406 <fieldset class="action">
407 <input type="submit" class="btn btn-primary" value="Delete selected" />
411 [% END # /tab_panel# %]
412 [% END # /WRAPPER tab_panels %]
413 [% END # /WRAPPER tabs %]
418 [% ELSE # IF ( savedreports ) %]
419 <div class="dialog message">
420 [% IF (filter_set || filters.date || filters.author || filters.keyword) %]
421 <h4>No saved reports match your criteria. </h4>
422 [% IF ( CAN_user_reports_create_reports ) %]
423 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form" class="new btn btn-default"><i class="fa fa-plus"></i> New guided report</a>
425 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form_sql" class="new btn btn-default"><i class="fa fa-plus"></i> New SQL report</a>
427 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=list&filter_set=1&filter_keywork=" class="deny btn btn-default"><i class="fa fa-fw fa-times"></i> Cancel filter</a>
430 <h4>There are no saved reports. </h4>
431 [% IF ( CAN_user_reports_create_reports ) %]
432 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form">Build a new report?</a>
434 [% END # IF (filter_set || filters.date || filters.author || filters.keyword) %]
435 </div> <!-- /.dialog.message -->
436 [% END # /IF ( savedreports ) %]
437 [% END # /IF ( saved1 ) %]
439 [% INCLUDE 'mana/mana-share-report.inc' %]
442 [% IF ( cache_error) %]
443 <div class="dialog alert">
444 <strong> Please choose a cache_expiry less than 30 days </strong>
448 <h1>Build a report</h1>
449 <form method="post" action="/cgi-bin/koha/reports/guided_reports.pl">
450 [% INCLUDE 'csrf-token.inc' %]
451 <fieldset class="rows">
452 <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and choose report visibility </legend>
455 <label for="area">Choose: </label>
456 <select name="area" id="area">
457 [%- FOREACH area IN areas -%]
458 <option value="[% area | html %]">[%- PROCESS area_name area=area -%]</option>
464 <label for="public">Report is public:</label>
465 <select id="public" name="public">
466 <option value="0">No (default)</option>
467 <option value="1" selected="selected">Yes</option>
472 <label for="public">Report is public:</label>
473 <select id="public" name="public">
474 <option value="0" selected="selected">No (default)</option>
475 <option value="1">Yes</option>
482 <label for="cache_expiry">Cache expiry:</label>
483 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
484 <select id="cache_expiry_units" name="cache_expiry_units">
485 <option value="seconds">Seconds (default)</option>
486 <option value="minutes">Minutes</option>
487 <option value="hours">Hours</option>
488 <option value="days">Days</option>
493 </fieldset> <!-- /.rows -->
494 <fieldset class="action">
495 <input type="hidden" name="op" value="cud-report" />
496 <button type="submit" class="btn btn-primary" />Next >></button>
502 <h1>Build a report</h1>
503 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
504 [% INCLUDE 'csrf-token.inc' %]
505 <input type="hidden" name="area" value="[% area | html %]" />
506 <input type="hidden" name="public" value="[% public | html %]" />
507 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
508 <fieldset class="rows">
509 <legend>Step 2 of 6: Pick a report type</legend>
512 <label for="types">Choose: </label>
513 <select id="types" name="types">
514 <option value="1">Tabular</option>
515 <option value="2" disabled="disabled">Summary</option>
516 <option value="3" disabled="disabled">Matrix</option>
522 <fieldset class="action">
523 <input type="hidden" name="op" value="cud-choose_type" />
524 <button type="submit" class="btn btn-default goback" name="back"><< Back</button>
525 <button type="submit" class="btn btn-primary" />Next >></button>
528 [% END # /IF (build2 ) %]
531 <h1>Build a report</h1>
532 <h3>Step 3 of 6: Select columns for display</h3>
533 <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>
535 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
536 [% INCLUDE 'csrf-token.inc' %]
537 <input type="hidden" name="area" value="[% area | html %]" />
538 <input type="hidden" name="type" value="[% type | html %]" />
539 <input type="hidden" name="public" value="[% public | html %]" />
540 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
543 <div class="col-sm-6">
544 <div style="float: left;">
545 <select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
546 [% FOREACH column IN columns %]
547 [% IF ( column.table ) %]
548 [% IF ( loop.first ) %]
552 <optgroup label="[% column.table | html %]">
554 <option value="[% column.name | html %]">
555 [% IF ( column.description ) %]
556 [% column.description | html %] / [% column.name | html %]
558 [% column.name | html %]
566 <div style="width: 6.3em; float: right; margin-top: 100px">
567 <input type="button" name="Add" value="Add" class="button" style="width:6em;" id="addColumn" /><br />
568 <input type="button" name="delete" value="<< Delete" class="button" style="width: 6em; margin: 1em 0;" id="delColumn" />
570 </div> <!-- /.col-sm-6 -->
572 <div class="col-sm-6">
573 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;">
576 </div> <!-- /.row -->
578 <fieldset class="action">
579 <input type="hidden" name="op" value="cud-choose_columns" />
580 <button type="submit" class="btn btn-default goback" name="back"><< Back</button>
581 <button type="submit" class="btn btn-primary" />Next >></button>
583 </form> <!-- /#column_submit -->
584 [% END # /IF ( build3 ) %]
587 <h1>Build a report</h1>
588 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
589 [% INCLUDE 'csrf-token.inc' %]
590 <input type="hidden" name="area" value="[% area | html %]" />
591 <input type="hidden" name="type" value="[% type | html %]" />
592 <input type="hidden" name="column" value="[% column | html %]" />
593 <input type="hidden" name="public" value="[% public | html %]" />
594 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
596 <legend>Step 4 of 6: Select criteria to limit on</legend>
598 [% FOREACH criteri IN criteria %]
601 <input type="checkbox" name="criteria_column" id="[% criteri.name | html %]" value="[% criteri.name | html %]" />
602 <label for="[% criteri.name | html %]">[% criteri.description | html %] </label>
604 [% IF ( criteri.date ) %]
606 <input type="text" size="10" id="[% criteri.name | html %]_value" name="[% criteri.name | html %]_value" value="" class="flatpickr" />
607 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
611 [% IF ( criteri.textrange ) %]
614 <input type="text" size="10" id="[% criteri.from | html %]_value" name="[% criteri.from | html %]_value" value="" /> to
615 <input type="text" size="10" id="[% criteri.to | html %]_value" name="[% criteri.to | html %]_value" value="" />
619 [% IF ( criteri.daterange ) %]
622 <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" />
624 <input type="text" size="10" id="to_[% criteri.name.remove('\.') | html %]_value" name="to_[% criteri.name | html %]_value" value="" class="flatpickr" />
625 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
630 <select name="[% criteri.name | html %]_value">
631 [% FOREACH value IN criteri.values %]
632 <option value="[% value.availablevalues | html %]">
633 [% IF ( value.default ) %]
636 [% value.display_value | html %]
650 [% IF ( definitions ) %]
652 <legend>Dictionary definitions</legend>
654 [% FOREACH definition IN definitions %]
657 <input type="checkbox" name="definition" value="[% definition.id | html %]" />
658 [% definition.name | html %]
666 <fieldset class="action">
667 <input type="hidden" name="op" value="cud-choose_criteria" />
668 <button type="submit" class="btn btn-default goback" name="back"><< Back</button>
669 <button type="submit" class="btn btn-primary" />Next >></button>
672 [% END # /IF ( build4 ) %]
675 <h1>Build a report</h1>
676 <h3>Step 5 of 6: Pick which columns to total</h3>
677 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
678 [% INCLUDE 'csrf-token.inc' %]
679 <input type="hidden" name="area" value="[% area | html %]" />
680 <input type="hidden" name="type" value="[% type | html %]" />
681 <input type="hidden" name="column" value="[% column | html %]" />
682 <input type="hidden" name="definition" value="[% definition | html %]" />
683 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
684 <input type="hidden" name="public" value="[% public | html %]" />
685 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
688 [% FOREACH total_b IN total_by %]
691 <input type="checkbox" name="total_by" id="[% total_b.name | html %]" value="[% total_b.name | html %]" />
692 <label for="[% total_b.name | html %]">[% total_b.name | html %]</label>
695 <select name="[% total_b.name | html %]_tvalue">
696 [% FOREACH selec IN total_b.select %]
697 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
706 <fieldset class="action"><input type="hidden" name="op" value="cud-choose_operations" />
707 <button type="submit" class="btn btn-default goback" name="back"><< Back</button>
708 <button type="submit" class="btn btn-primary" />Next >></button>
711 [% END # /IF ( build5 ) %]
714 <h1>Build a report</h1>
715 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
716 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
717 [% INCLUDE 'csrf-token.inc' %]
718 <input type="hidden" name="area" value="[% area | html %]" />
719 <input type="hidden" name="type" value="[% type | html %]" />
720 <input type="hidden" name="column" value="[% column | html %]" />
721 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
722 <input type="hidden" name="definition" value="[% definition | html %]" />
723 <input type="hidden" name="totals" value="[% totals | html %]" />
724 <input type="hidden" name="public" value="[% public | html %]" />
725 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
728 [% FOREACH order_b IN order_by %]
731 <input type="checkbox" id="[% order_b.name | html %]" name="order_by" value="[% order_b.name | html %]" />
732 <label for="[% order_b.name | html %]">[% order_b.name | html %]</label>
735 <select name="[% order_b.name | html %]_ovalue">
736 [% FOREACH selec IN order_b.select %]
737 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
745 <fieldset class="action">
746 <input type="hidden" name="op" value="cud-build_report" />
747 <input type="submit" name="submit" class="btn btn-primary" value="Finish" />
750 [% END #/ IF ( build6 ) %]
752 [% IF ( showreport ) %]
753 <h1>Confirm custom report</h1>
754 <p>Your report will be generated with the following SQL statement.</p>
759 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
760 [% INCLUDE 'csrf-token.inc' %]
761 <input type="hidden" name="sql" value="[% sql | html %]" />
762 <input type="hidden" name="type" value="[% type | html %]" />
763 <input type="hidden" name="public" value="[% public | html %]" />
764 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
765 <p>You will need to save the report before you can execute it</p>
766 <fieldset class="action"><input type="hidden" name="op" value="cud-save" />
767 <input type="submit" name="submit" class="btn btn-primary" value="Next" />
770 [% END #/ IF ( showreport ) %]
773 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
774 [% INCLUDE 'csrf-token.inc' %]
775 <input type="hidden" name="sql" value="[% sql | html %]" />
776 <input type="hidden" name="type" value="[% type | html %]" />
777 <input type="hidden" name="area" value="[% area | html %]" />
778 <input type="hidden" name="public" value="[% public | html %]" />
779 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
780 <fieldset class="rows">
781 <legend><h1>Save your custom report</h1></legend>
784 <label for="reportname" class="required">Report name: </label>
785 <input type="text" id="reportname" name="reportname" class="required" required="required" />
786 <span class="required">Required</span>
788 [% PROCESS group_and_subgroup_selection %]
790 <label for="notes">Notes:</label>
791 <textarea name="notes" id="notes"></textarea>
795 <fieldset class="action"><input type="hidden" name="op" value="cud-save" />
796 <input type="submit" name="submit" class="btn btn-primary" value="Save report" />
799 [% END # /IF( save ) %]
801 [% IF ( warn_authval_problem ) %]
802 <div class="dialog alert">
803 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
804 [% FOREACH problematic_authval IN problematic_authvals %]
806 <strong>[% problematic_authval.name | html %]:</strong> The authorized value category (<strong>[% problematic_authval.authval | html %]</strong>)
807 you selected does not exist.
810 <!-- Save Anyway Form -->
811 <form method="post" action='/cgi-bin/koha/reports/guided_reports.pl'>
812 <!--Every parameter the user issued is provided as a hidden field for recovery-->
813 [% INCLUDE 'csrf-token.inc' %]
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 ( op == 'update') %]
824 <input type='hidden' name='op' value='cud-update' />
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 ( op == 'save') %]
827 <input type='hidden' name='area' value='[% area | html %]' />
828 <input type='hidden' name='op' value='cud-save' />
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 <a href="/cgi-bin/koha/reports/guided_reports.pl" class="btn btn-default new goback"><i class="fa-fw fa-solid fa-pencil" aria-hidden="true"></i> Edit SQL</a>
835 [% END # /IF ( warn_authval_problem )%]
837 [% IF ( enter_params ) %]
838 [% IF ( auth_val_error ) %]
839 <div class="dialog alert">
840 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
841 [% FOREACH auth_val_error IN auth_val_errors %]
843 <strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
844 you selected does not exist.
848 <fieldset class="action">
849 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=edit_formid=[% id | uri %]" class="btn btn-primary">Edit SQL</a>
851 [% ELSE # IF ( auth_val_error ) %]
852 <form method="get" action='/cgi-bin/koha/reports/guided_reports.pl'>
853 <input type='hidden' name='id' value="[% id | html %]" />
854 <h1>Enter parameters for report [% name | html %]:</h1>
856 <p>[% notes | html %]</p>
858 <fieldset class="rows">
860 [% FOREACH sql_param IN sql_params %]
861 <input name="param_name" value="[% sql_param.name | html %]" type="hidden" />
862 [% IF sql_param.input == 'date' %]
864 <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" />
866 [% ELSIF ( sql_param.input == 'text' ) %]
868 <label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label>
869 <input id="sql_params[% loop.count | html %]" type="text" name="sql_params" />
871 [% ELSIF ( sql_param.input == 'textarea' ) %]
873 <label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label>
874 <textarea id="sql_params[% loop.count | html %]" name="sql_params" rows="5"></textarea>
878 <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
879 <select name="[%- sql_param.input.name | html -%]" tabindex="1" id="[%- sql_param.input.id | html -%]">
880 [% IF (sql_param.include_all) %]
881 <option value="%">All</option>
883 [% FOREACH value IN sql_param.input.values %]
884 <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
888 [% END # /IF sql_param.input == 'date' %]
889 [% END # /FOREACH sql_param %]
891 </fieldset> <!-- /.rows -->
892 <fieldset class="action">
893 <input type="hidden" name="op" value="run" />
894 <button type="submit" class="btn btn-primary">Run the report</button>
897 [% END # / IF ( auth_val_error ) %]
898 [% END # /IF ( enter_params ) %]
900 [% IF processed_notice %]
901 [% processed_notice | $raw %]
902 [% ELSIF ( execute ) %]
903 <h1>[% name | html %] <span class="report_heading_id"><span class="report_label">Report ID:</span> <span class="report_number">[% id | html %]</span></span></h1>
904 <div class="page-section">
906 <p><span class="label">Notes:</span> [% notes | html %]</p>
908 [% IF ( unlimited_total ) %]
910 <span class="label">Total number of results:</span>
911 [% unlimited_total | html %]
912 [% IF unlimited_total >= limit %]
913 ([% results.size | html %] shown)
918 <div id="sql_output" style="display:none;">
919 <span class="label">Report SQL:</span>
920 <textarea id="sql" readonly="readonly">[% sql | html %]</textarea>
924 <a href="#" id="toggle_chart_settings_hid" class="toggle_chart_settings" style="display:none"><i class="fa-solid fa-eye-slash"></i> Hide chart</a>
925 <a href="#" id="toggle_chart_settings_vis" class="toggle_chart_settings" style="display:none"><i class="fa-solid fa-eye"></i> Show chart</a>
927 <div id="chart" class="clearfix"></div>
930 [% UNLESS ( errors ) %]
931 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl" id="batch_record_modification" target="_blank">
932 [% INCLUDE 'csrf-token.inc' %]
933 <input type="hidden" name="recordtype" value="biblio" />
934 <input type="hidden" name="op" value="cud-list" />
935 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
936 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">
937 [%- recordnumbers = PROCESS batch_list results=results batch_type='biblionumber' | trim | html %][% IF recordnumbers %][% SET batch_biblionumbers = 1 %][% recordnumbers | html %][% END -%]
941 <form method="POST" action="/cgi-bin/koha/tools/batch_delete_records.pl" id="batch_record_deletion" target="_blank">
942 [% INCLUDE 'csrf-token.inc' %]
943 <input type="hidden" name="recordtype" value="biblio" />
944 <input type="hidden" name="op" value="cud-list" />
945 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
946 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">
947 [%- recordnumbers = PROCESS batch_list results=results batch_type='biblionumber' | trim | html %][% IF recordnumbers %][% SET batch_biblionumbers = 1 %][% recordnumbers | html %][% END -%]
951 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_modification" target="_blank">
952 [% INCLUDE 'csrf-token.inc' %]
953 <input type="hidden" name="op" value="cud-show" />
954 [% FOREACH result IN results %]
955 [% FOREACH cells IN result.cells %]
956 [% place = loop.index %]
957 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
958 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
959 [% SET batch_itemnumbers = 1 %]
960 [% SET header_row.$place.has_itemnumbers = 1 %]
961 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
967 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_deletion" target="_blank">
968 [% INCLUDE 'csrf-token.inc' %]
969 <input type="hidden" name="op" value="cud-show" />
970 <input type="hidden" name="del" value="1" />
971 [% FOREACH result IN results %]
972 [% FOREACH cells IN result.cells %]
973 [% place = loop.index %]
974 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
975 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
976 [% SET batch_itemnumbers = 1 %]
977 [% SET header_row.$place.has_itemnumbers = 1 %]
978 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
984 <form method="get" action="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl" id="batch_add_to_list" target="_blank">
985 [% FOREACH result IN results %]
986 [% FOREACH cells IN result.cells %]
987 [% place = loop.index %]
988 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
989 [% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
990 [% SET batch_biblionumbers = 1 %]
991 [% SET header_row.$place.has_biblionumbers = 1 %]
992 <input type="hidden" class="bib_to_list" name="biblionumber" value="[% cells.cell | html %]" />
998 <form method="get" action="/cgi-bin/koha/tools/modborrowers.pl" id="batch_patron_modification" target="_blank">
999 <input type="hidden" name="op" value="show" />
1000 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
1001 [%- cardnumbers = PROCESS batch_list results=results batch_type='cardnumber' | trim | html %]
1002 [% IF cardnumbers %]
1003 [% SET batch_cardnumbers = cardnumbers.length %]
1004 [% FOR b IN cardnumbers.split("\n") %]
1005 <input type="hidden" name="cardnumber" value="[% b | uri %]" />
1011 <form action="/cgi-bin/koha/patroncards/edit-batch.pl" id="patron_card_creator" method="post" target="_blank">
1012 [% INCLUDE 'csrf-token.inc' %]
1013 <input type="hidden" name="op" value="cud-add" />
1014 <input type="hidden" name="batch_id" value="0" />
1015 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
1016 <textarea style="display:none;" name="bor_num_list" id="bor_num_list">
1017 [%- borrowernumbers = PROCESS batch_list results=results batch_type='borrowernumber' | trim | html %][% IF borrowernumbers %][% SET batch_borrowernumbers = 1 %][% borrowernumbers | html %][% END -%]
1021 [% BLOCK batch_list %]
1022 [%- FOREACH result IN results %]
1023 [%- FOREACH cells IN result.cells %]
1024 [%- place = loop.index %]
1025 [%- IF header_row.$place.cell == batch_type || header_types.item(header_row.$place.cell) == batch_type %]
1026 [%# We must not add whitespace to the cardnumbers %][% cells.cell | html %]
1032 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
1033 <input type="hidden" name="op" value="run"/>
1034 <input type="hidden" name="id" value="[% id | html %]"/>
1035 [% FOREACH p IN sql_params %]
1036 <input type="hidden" name="sql_params" value="[% p | html %]"/>
1038 [% FOREACH n IN param_names %]
1039 <input type="hidden" name="param_name" value="[% n | html %]"/>
1041 <input type="hidden" name="limit" id="limit" value="20" />
1042 </form> <!-- /#limitselect -->
1044 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers || batch_borrowernumbers ) || ( unlimited_total > 10 && limit <= 1000 ) %]
1045 <div id="toolbar" class="btn-toolbar">
1046 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers || batch_borrowernumbers ) %]
1047 <div class="btn-group">
1048 <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="batch_mod_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
1049 Batch operations with [% IF unlimited_total >= limit %][% limit | html %][% ELSE %][% unlimited_total | html %][% END %] visible records
1050 <span class="caret"></span>
1052 <ul class="dropdown-menu" aria-labelledby="batch_mod_menu">
1053 [% FOREACH header_ro IN header_row %]
1054 [% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' || header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %]
1055 [% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
1056 [% SET show_cardnumber_ops = 1 %]
1058 [% IF header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %]
1059 [% SET show_borrowernumber_ops = 1 %]
1063 [% IF show_cardnumber_ops || show_borrowernumber_ops %]
1064 <li class="dropdown-header">Patron records</li>
1065 [% IF show_cardnumber_ops %]
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 [% IF show_borrowernumber_ops %]
1072 <a href="#" data-submit="patron_card_creator" data-toggle="tooltip" data-placement="right" title="Send visible results to a new patron card batch" class="batch_op send_to_patron_card_batch">Patron card creator</a>
1076 [% FOREACH header_ro IN header_row %]
1077 [% IF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
1078 <li class="dropdown-header">Bibliographic records</li>
1080 <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>
1083 <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>
1086 <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>
1089 [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
1090 <li class="dropdown-header">Item records</li>
1092 <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>
1095 <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>
1098 [% END # /FOREACH header_ro %]
1099 </ul> <!-- /.dropdown-menu -->
1100 </div> <!-- /.dropdown -->
1101 [% END # /IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1103 [% IF ( unlimited_total > 10 && limit <= 1000 ) %]
1104 <div class="btn-group">
1105 <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
1107 Rows per page: <strong>[% limit | html %]</strong>
1111 <span class="caret"></span>
1113 <ul class="dropdown-menu">
1114 [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
1115 [% FOREACH l IN limits %]
1118 <a class="limitselect" data-limit="[% l | html %]" href="#"><i class="fa fa-fw fa-check"></i> [% l | html %]</a>
1122 <a class="limitselect" data-limit="[% l | html %]" href="#"><i class="fa fa-fw"></i> [% l | html %]</a>
1128 [% END # /IF ( unlimited_total > 10 && limit <= 1000 ) %]
1130 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
1131 <a href="#" class="btn btn-link" id="toggle_auto_links">
1132 <i class="fa-solid fa-eye autolink" style="display:none"></i>
1133 <i class="fa-solid fa-eye-slash autolink"></i>
1134 <span class="autolink" style="display:none">Show data menus</span>
1135 <span class="autolink">Hide data menus</span>
1138 </div> <!-- /#toolbar.btn-toolbar -->
1139 [% END # /IF batch operations || ( unlimited_total > 10 && limit <= 1000 ) %]
1142 [% pagination_bar | $raw %]
1145 [% END # UNLESS ( errors ) %]
1146 [% END # IF ( execute ) %]
1148 [% UNLESS ( errors ) %]
1149 <table id="report_results">
1152 [% FOREACH header_ro IN header_row %]
1153 [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
1154 <th class="itemnumber">[% header_ro.cell | html %]</th>
1155 [% ELSIF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
1156 <th class="biblionumber">[% header_ro.cell | html %]</th>
1157 [% ELSIF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
1158 <th class="cardnumber">[% header_ro.cell | html %]</th>
1159 [% ELSIF header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %]
1160 <th class="borrowernumber">[% header_ro.cell | html %]</th>
1162 <th>[% header_ro.cell | html %]</th>
1168 [% FOREACH result IN results %]
1170 [% FOREACH cells IN result.cells %]
1171 [% place = loop.index %]
1172 [%- IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
1173 <td class="batch-op itemnumber" data-number="itemnumber">
1174 <span class="data-plain">[% cells.cell | $raw %]</span>
1175 <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>
1176 <ul class="dropdown-menu pull-right" role="menu">
1177 <li><a target="_blank" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&itemnumber=[% cells.cell | $raw %]"><i class="fa-fw fa-solid fa-pencil" aria-hidden="true"></i> Edit record</a></li>
1178 <li role="separator" class="divider"></li>
1179 <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>
1183 [% ELSIF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
1184 <td class="batch-op biblionumber" data-number="biblionumber">
1185 <span class="data-plain">[% cells.cell | $raw %]</span>
1186 <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>
1187 <ul class="dropdown-menu pull-right" role="menu">
1188 <li><a target="_blank" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% cells.cell | $raw %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit record</a></li>
1189 <li role="separator" class="divider"></li>
1190 <li><a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cells.cell | $raw %]"><i class="fa-solid fa-eye"></i> View record</a></li>
1194 [% ELSIF header_row.$place.cell == 'borrowernumber' || header_types.item(header_row.$place.cell) == 'borrowernumber' %]
1195 <td class="batch-op borrowernumber" data-number="borrowernumber">
1196 <span class="data-plain">[% cells.cell | $raw %]</span>
1197 <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>
1198 <ul class="dropdown-menu pull-right" role="menu">
1199 <li><a target="_blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% cells.cell | $raw %]"><i class="fa-solid fa-eye"></i> View patron</a></li>
1200 <li role="separator" class="divider"></li>
1201 <li><a target="_blank" href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&borrowernumber=[% cells.cell | $raw %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit patron</a></li>
1202 <li role="separator" class="divider"></li>
1203 <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>
1207 [% ELSIF header_row.$place.cell == 'cardnumber' || header_types.item(header_row.$place.cell) == 'cardnumber' %]
1208 <td class="batch-op cardnumber" data-number="cardnumber">
1209 <span class="data-plain">[% cells.cell | $raw %]</span>
1210 <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>
1211 <ul class="dropdown-menu pull-right" role="menu">
1212 <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>
1218 [% cells.cell | $raw %]
1227 <div class="pages">[% pagination_bar | $raw %]</div>
1229 [% INCLUDE 'chart.inc' %]
1231 [% END #/IF ( execute ) %]
1234 <h1>Create from SQL</h1>
1235 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1236 [% INCLUDE 'csrf-token.inc' %]
1237 <fieldset class="rows">
1238 <legend>Create report from SQL</legend>
1241 <label for="reportname" class="required">Report name:</label>
1242 [% IF ( reportname ) %]
1243 <input type="text" class="required" required="required" id="reportname" name="reportname" value="[% reportname | html %]" size="50"/>
1245 <input type="text" class="required focus" required="required" id="reportname" name="reportname" size="50" />
1247 <span class="required">Required</span>
1249 [% PROCESS group_and_subgroup_selection %]
1253 <label for="public">Report is public:</label>
1254 <select id="public" name="public">
1255 <option value="0">No (default)</option>
1256 <option value="1" selected="selected">Yes</option>
1261 <label for="public">Report is public:</label>
1262 <select id="public" name="public">
1263 <option value="0" selected="selected">No (default)</option>
1264 <option value="1">Yes</option>
1267 [% END # /IF (public) %]
1271 <label for="cache_expiry">Cache expiry:</label>
1272 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
1273 <select id="cache_expiry_units" name="cache_expiry_units">
1274 <option value="seconds" selected="selected">Seconds (default)</option>
1275 <option value="minutes">Minutes</option>
1276 <option value="hours">Hours</option>
1277 <option value="days">Days</option>
1280 [% END # /IF (usecache) %]
1282 <label for="notes">Notes:</label>
1283 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1286 </fieldset> <!-- /.rows -->
1288 <fieldset class="rows">
1289 <legend>SQL:</legend>
1290 <div style="margin:1em;">
1291 [% PROCESS insert_runtime_parameter %]
1292 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10" >[% sql | html %]</textarea>
1293 <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>
1295 <span class="required">Required</span>
1299 <fieldset class="action">
1300 <input type="hidden" name="op" value="cud-save" />
1301 <input type="submit" name="submit" class="btn btn-primary" value="Save report" />
1302 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=list" class="cancel">Cancel</a>
1306 [% END #/IF ( create ) %]
1308 [% IF saved_results %]
1309 <h1>Saved report results</h1>
1310 <h2>[% name | html %]</h2>
1311 <p>[% notes | html %]</p>
1313 [% FOREACH rows IN saved_results %]
1315 [% FOREACH col IN rows %]
1316 <td>[% col | html %]</td>
1321 [% END # /IF saved_results %]
1323 [% IF ( showsql ) %]
1324 <h1>Saved reports - SQL</h1>
1325 <fieldset class="rows">
1326 <legend>[% reportname | html %]</legend>
1330 <span class="label">Notes:</span>
1336 <textarea id="sql">[% sql | html %]</textarea>
1340 [% END # /IF ( showsql ) %]
1342 [% IF ( save_successful ) %]
1343 [% UNLESS ( errors ) %]
1345 <div id="report_updated">
1346 <div class="dialog message">
1347 <p>Your report "[% reportname | html %]" has been saved</p>
1353 [% IF ( editsql ) %]
1354 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1355 [% INCLUDE 'csrf-token.inc' %]
1356 <input type="hidden" name="id" value="[% id | html %]"/>
1357 <fieldset class="rows">
1358 <legend><h1>Edit SQL report</h1></legend>
1361 <label for="reportname" class="required">Report name: </label>
1362 <input type="text" id="reportname" name="reportname" value="[% reportname | html %]" size="50" class="required" required="required" />
1363 <span class="required">Required</span>
1365 [% PROCESS group_and_subgroup_selection %]
1368 <label for="public">Report is public:</label>
1369 <select id="public" name="public">
1370 <option value="0">No (default)</option>
1371 <option value="1" selected="selected">Yes</option>
1376 <label for="public">Report is public:</label>
1377 <select id="public" name="public">
1378 <option value="0" selected="selected">No (default)</option>
1379 <option value="1">Yes</option>
1382 [% END # /IF (public) %]
1386 <label for="cache_expiry">Cache expiry:</label>
1387 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]" />
1388 <select id="cache_expiry_units" name="cache_expiry_units">
1389 <option value="seconds">Seconds (default)</option>
1390 <option value="minutes">Minutes</option>
1391 <option value="hours">Hours</option>
1392 <option value="days">Days</option>
1397 <label for="notes">Notes:</label>
1398 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1401 </fieldset> <!-- /.rows -->
1403 <fieldset class="rows">
1404 <legend>SQL:</legend>
1405 [% PROCESS insert_runtime_parameter %]
1406 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea>
1407 <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>
1409 <span class="required" style="margin-left:30px;">Required</span>
1412 <fieldset class="action">
1413 <button class="btn btn-primary" type="submit" name="op" value="cud-update_sql">Update SQL</button>
1414 <button class="btn btn-default" type="submit" name="op" value="cud-update_and_run_sql">Update and run SQL</button>
1415 <a href="/cgi-bin/koha/reports/guided_reports.pl?op=list" class="cancel">Cancel</a>
1418 [% END # /IF ( editsql ) %]
1421 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
1422 <div class="dialog alert">
1423 <strong>The following error was encountered:</strong><br />
1424 [% FOREACH error IN errors %]
1425 [% IF ( error.sqlerr ) %]
1426 This report contains the SQL keyword <strong>[% error.sqlerr | html %]</strong>.<br />
1427 Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.<br />
1428 Please return to the "Saved Reports" screen and delete this report or retry creating a new one.
1429 [% ELSIF ( error.queryerr ) %]
1430 <span>The database returned the following error:</span> <br />
1431 [% error.queryerr | html %]<br />Please check the log for further details.
1432 [% ELSIF ( error.cache_expiry ) %]
1433 Please select a cache expiry less than 30 days.
1436 <div id="onerror_actions">
1437 <a href="#" class="button goback">Return to previous page</a>
1441 <fieldset class="action">
1442 <input type="hidden" name="op" value="list" />
1443 <input type="submit" name="submit" class="btn btn-primary" value="Saved reports" />
1446 [% END # /IF ( errors ) %]
1449 </div> <!-- /.col-sm-10.col-sm-push-2 -->
1451 <div class="col-sm-2 col-sm-pull-10">
1454 <div id="saved-reports-filter">
1455 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
1456 <input type="hidden" name="op" value="list" />
1457 <input type="hidden" name="filter_set" value="1" />
1458 <fieldset class="brief">
1462 <label for="filter_date">Date:</label>
1463 <input type="text" id="filter_date" name="filter_date" size="10" value="[% filters.date | html %]" class="flatpickr" />
1464 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
1467 <label for="filter_author">Author:</label>
1468 <input type="text" id="filter_author" name="filter_author" value="[% filters.author | html %]" size="16" />
1471 <label for="filter_keyword">Keyword:</label>
1472 <input type="text" id="filter_keyword" name="filter_keyword" value="[% filters.keyword | html %]" size="16" />
1475 </fieldset> <!-- /.brief -->
1476 <fieldset class="action">
1477 <input type="submit" class="btn btn-primary" value="Apply filter" />
1478 <a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?op=list&clear_filters=1">Clear</a>
1481 </div> <!-- /#saved-reports-filter -->
1483 [% INCLUDE 'guided-reports-view.inc' %]
1485 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1486 </div> <!-- /.row -->
1488 <!-- Runtime Parameters Modal -->
1489 <div class="modal" id="runtime_parameters" tabindex="-1" role="dialog" aria-labelledby="runtime_parametersLabel">
1490 <div class="modal-dialog" role="document">
1491 <div class="modal-content">
1492 <div class="modal-header">
1493 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
1494 <h4 class="modal-title" id="runtime_parametersLabel">Runtime parameter options</h4>
1496 <form method="get" id="send_runtime_parameter">
1497 <input type="hidden" name="param_category" id="param_category" />
1498 <div class="modal-body">
1499 <div class="form-group">
1500 <label for="paramLabel" class="required">Parameter label: </label>
1501 <input class="form-control required" type="text" name="paramLabel" id="paramLabel" required="required" />
1502 <div class="hint">The label for the field shown when the report is run, e.g. "Select a library."</div>
1504 <div id="authorised_value_category" class="form-group" style="display:none">
1505 <label for="authorised_value">Authorized value category:</label>
1506 <select class="form-control" name="authorised_value" id="authorised_value">
1507 <option value=""></option>
1508 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories() %]
1510 <div class="hint">Select which authorized value category the user will choose from.</div>
1512 </div> <!-- /.modal-body -->
1513 <div class="modal-footer">
1514 <button type="submit" id="sendParam" class="btn btn-default approve">Insert parameter</button>
1515 <button type="button" class="btn btn-default deny" data-dismiss="modal">Cancel</button>
1516 </div> <!-- /.modal-footer -->
1517 </form> <!-- /#send_runtime_parameter -->
1518 </div> <!-- /.modal-content -->
1519 </div> <!-- /.modal-dialog -->
1520 </div> <!-- /#runtime_parameters -->
1522 [% MACRO jsinclude BLOCK %]
1523 [% Asset.js("js/charts.js") | $raw %]
1524 [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
1525 [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
1526 [% INCLUDE 'calendar.inc' %]
1527 [% INCLUDE 'datatables.inc' %]
1529 [% INCLUDE 'columns_settings.inc' %]
1530 [% Asset.js( "lib/jsdiff/jsdiff.min.js" ) | $raw %]
1532 [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
1533 [% Asset.js( "lib/codemirror/overlay.min.js" ) | $raw %]
1534 [% Asset.js( "lib/codemirror/sql.js" ) | $raw %]
1535 [% Asset.js( "lib/codemirror/show-hint.js" ) | $raw %]
1536 [% Asset.css("lib/codemirror/show-hint.css") | $raw %]
1537 [% Asset.js( "lib/codemirror/sql-hint.js" ) | $raw %]
1538 [% Asset.js( "lib/codemirror/highlight.js" ) | $raw %]
1539 [% Asset.css("lib/codemirror/highlight.css") | $raw %]
1540 [% Asset.js( "js/mana.js" ) | $raw %]
1544 function hide_bar_element() {
1545 $('#chart-column-horizontal').hide()
1546 $('.chart-column-group').each(function( index ) {
1549 $('.chart-column-line').each(function( index ) {
1554 function show_bar_element() {
1555 $('#chart-column-horizontal').show()
1556 $('.chart-column-group').each(function( index ) {
1559 $('.chart-column-line').each(function( index ) {
1564 function removeColumn(id) {
1567 if ( $('.chart-column-conf').length == 1 ) {
1568 $('.chart-column-delete').remove();
1572 var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1573 var group_subgroups = {};
1574 [% FOREACH group IN groups_with_subgroups %]
1575 var gid = "[% group.id | html %]"
1576 group_subgroups[gid] = new Array();
1577 [% FOREACH subgroup IN group.subgroups %]
1578 var sgid = "[% subgroup.id | html %]";
1579 var sgname = "[% subgroup.name | html %]";
1580 group_subgroups[gid].push([sgid, sgname]);
1584 [% IF ( create || editsql || save ) %]
1586 var editor = CodeMirror.fromTextArea(sql, {
1591 keyword: { // Custom highlighting for items bounded in [[ ]] or << >>.
1592 "\\[\\[(.*?)\\]\\]":"style1",
1593 "<<(.*?)>>":"style1"
1595 hint: CodeMirror.hint.sql,
1597 tables: [% To.json(tables) | $raw %]
1600 var ExcludedTriggerKeys = { //key-code combinations of keys that will not fire the auto-complete script
1623 "91": "left window key",
1624 "92": "right window key",
1629 "110": "decimal point",
1644 "145": "scrolllock",
1650 "192": "graveaccent",
1654 //Trigger auto-complete on all keys not in dictionary of exclusions above.
1655 editor.on("keyup", function(cm, e) {
1656 if (ExcludedTriggerKeys[e.keyCode] == undefined) {
1657 CodeMirror.commands.autocomplete(editor, null, { completeSingle: false });
1661 // https://stackoverflow.com/questions/2086287/how-to-clear-jquery-validation-error-messages#answer-16025232
1662 function clearValidation( formElement ){
1663 // formElement should be a jQuery object
1664 var validator = formElement.validate();
1665 // Iterate through named elements inside of the form, and mark them as error free
1666 $('[name]',formElement).each(function(){
1667 validator.successList.push(this);//mark as error free
1668 validator.showErrors();//remove error messages if present
1670 validator.resetForm();//remove error class on name elements and clear history
1671 validator.reset();//remove all error and success data
1675 [% IF ( showsql ) %]
1677 var editor = CodeMirror.fromTextArea(sql, {
1682 keyword: { // Custom highlighting for items bounded in [[ ]] or << >>.
1683 "\\[\\[(.*?)\\]\\]":"style2",
1684 "<<(.*?)>>":"style1"
1689 function showParamModal( category ){
1690 var modal = $("#runtime_parameters");
1691 var modalTitle = $("#runtime_parametersLabel");
1692 switch ( category ){
1693 case "insertAuthVal":
1694 modalTitle.text( _("Insert authorized value parameter") );
1695 $("#paramLabel").val( _("Authorized value") );
1696 $("#authorised_value_category").show();
1697 $("label[for='authorised_value']").addClass("required");
1698 $("#authorised_value").prop("required", true ).attr("required", "required").addClass("required");
1700 case "insertCnSource":
1701 modalTitle.text( _("Insert classification source parameter") );
1702 $("#paramLabel").val( _("Source of classification or shelving scheme") );
1703 $("#param_category").val("cn_source");
1705 case "insertFramework":
1706 modalTitle.text( _("Insert bibliographic framework parameter") );
1707 $("#paramLabel").val( _("Framework") );
1708 $("#param_category").val("biblio_framework");
1711 modalTitle.text( _("Insert date parameter") );
1712 $("#paramLabel").val( _("Date") );
1713 $("#param_category").val("date");
1715 case "insertItemtypes":
1716 modalTitle.text( _("Insert item types parameter") );
1717 $("#paramLabel").val( _("Item type") );
1718 $("#param_category").val("itemtypes");
1720 case "insertBranches":
1721 modalTitle.text( _("Insert libraries parameter") );
1722 $("#paramLabel").val( _("Library") );
1723 $("#param_category").val("branches");
1725 case "insertCategorycode":
1726 modalTitle.text( _("Insert patron category parameter") );
1727 $("#paramLabel").val( _("Patron category") );
1728 $("#param_category").val("categorycode");
1730 case "insertCashregister":
1731 modalTitle.text( _("Insert cash register parameter") );
1732 $("#paramLabel").val( _("Cash register") );
1733 $("#param_category").val("cash_registers");
1735 case "insertDebittypes":
1736 modalTitle.text( _("Insert debit type parameter") );
1737 $("#paramLabel").val( _("Debit type") );
1738 $("#param_category").val("debit_types");
1740 case "insertCredittypes":
1741 modalTitle.text( _("Insert credit type parameter") );
1742 $("#paramLabel").val( _("Credit type") );
1743 $("#param_category").val("credit_types");
1746 modalTitle.text( _("Insert list parameter") );
1747 $("#paramLabel").val( _("List of values") );
1748 $("#param_category").val("list");
1751 modalTitle.text( _("Insert text parameter") );
1752 $("#paramLabel").val( _("Text") );
1753 $("#param_category").val("");
1756 $("#paramLabel").select();
1757 modal.modal("show");
1760 function load_group_subgroups () {
1761 var group = $("#group_select").val();
1762 var subgroup = $("#subgroup_select").val();
1763 var sg = $("#subgroup");
1764 $(sg).find('option[value!=""]').each(function() {
1769 var select = $(sg).find('select')[0];
1770 $.each( group_subgroups[group], function(index, value) {
1771 if ( value[0] == subgroup ) {
1772 $('<option selected="selected" value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1774 $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1777 $("#subgroup, #subgroup *").show();
1781 $(document).ready(function(){
1783 var activeTab = localStorage.getItem("sql_reports_activetab");
1785 $("body").on('click',".fetch_chart_data",function(){
1786 if( [% unlimited_total || 0 | $raw %] > 1000 ){
1787 if( confirm( _("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you want to chart this report?") ) ){
1798 if ( $('.chart-column-conf').length == 1 ) {
1799 $('.chart-column-delete').remove();
1802 $(".chart-column-delete").on('click', function(e){
1804 removeColumn('column_' + $(this).data('column'));
1807 $('#download-chart').click(function() {
1808 var svg = '<svg>' + $('#chart svg').html() + '</svg>';
1809 this.href = 'data:application/octet-stream;base64,' + btoa(svg);
1810 this.setAttribute('download', 'chart.svg');
1813 $('#chart-type').change(function() {
1814 if ($(this).val() == 'bar') {
1822 $('#download-chart').hide();
1825 [% IF results && !errors %]
1826 $('#draw-chart').click(function() {
1828 var x_elements = $('select[name="x"]').val();
1829 var y_elements = [];
1834 headers = [% header_row.json | $raw %];
1837 [% IF allresults.size %]
1838 if ($('input[name="chart-include-all"]').prop('checked')) {
1839 results = [% allresults.json | $raw %]
1842 results = [% results.json | $raw %]
1845 results = [% results.json | $raw %];
1848 if ($('input[name="chart-exclude-last"]').prop('checked')) {
1849 results.splice(-1, 1);
1852 $('select[name="y"]').each(function( index ) {
1853 y_elements.push( $(this).val() );
1855 $('select[name="group"]').each(function( index ) {
1856 groups.push( $(this).val() );
1858 $('.column-line').each(function( index ) {
1859 if ($(this).prop('checked')) {
1860 lines.push( $(this).attr('name') );
1864 // Remove deleted columns from headers and results.
1865 var deleted_indexes = [];
1866 var kept_headers = [];
1867 $.each(headers, function(index, value) {
1868 if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) {
1869 // This header is neither a x element nor in y elements. Don't need it.
1870 deleted_indexes.push(index);
1873 kept_headers.push({cell: value.cell});
1877 // Remove coresponding cells.
1878 var kept_results = [];
1879 $.each(results, function(index, value) {
1882 $.each(value.cells, function(i, val) {
1883 if ($.inArray(i, deleted_indexes) === -1) {
1884 line['cells'].push({cell: val.cell});
1887 kept_results.push(line);
1890 options.type = $('select[name="chart-type"]').val();
1891 options.horizontal = $('input[name="column-horizontal"]').prop('checked');
1892 options.lines = lines;
1894 chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options);
1895 $("#download-chart,#toggle_chart_settings_hid,#chart").show();
1896 $("#toggle_chart_settings_vis").hide();
1897 $("#chartModal").modal("hide");
1901 load_group_subgroups();
1904 $('[data-toggle="tooltip"]').tooltip();
1906 $('#limit').change(function() {
1907 $('#limitselect').submit();
1910 $(document).click(function() {
1911 $('#report_updated').hide();
1914 $(".goback").on("click",function(e){
1916 window.history.back();
1919 $("body").on("click", ".mana_search_button", function(){
1920 $("#mana-loading").show();
1921 mana_search($("#mana_search_field").val());
1924 $(".ShareButton").on("click", function(){
1925 $("#note-error").hide();
1926 if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
1927 $(".shared_infos").hide();
1928 $("#note-error").show();
1931 $("#reportid").val($(this).closest("tr").find(".report_id").text());
1932 $("#shared_id").html($(this).closest("tr").find(".report_id").text());
1933 $("#shared_name").html($(this).closest("tr").find(".report_name").text());
1934 $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
1935 $("#shared_type").html($(this).closest("tr").find(".report_type").text());
1936 $("#shared_group").html($(this).closest("tr").find(".report_group").text());
1937 $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
1941 $("#ManaCloseButton").on("click", function() {
1942 $(".shared_infos").show();
1945 $("#addColumn").on("click",function(){
1949 $("#delColumn").on("click",function(){
1954 var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1955 var rtable = KohaTable("table_reports", {
1957 "pagingType": 'full',
1958 "order": [[ 1, "asc" ]],
1960 "zeroRecords": _("No matching reports found")
1965 $("#tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) {
1966 tabsInit( $(e.target).parent(), rtable );
1970 $("#tabs li:eq(" + activeTab + ") a").tab("show");
1973 $("#subgroup_filter").change(function() {
1974 var selected = $(this).find('option:selected');
1975 var sg_id = $(selected).val();
1976 if (sg_id.length > 0) {
1977 const input = '^' + $.fn.dataTable.util.escapeRegex(sg_id) + '$';
1978 rtable.fnFilter(input, 5, true, false, true, false);
1979 rtable.fnSetColumnVis(5, false);
1981 rtable.fnFilter('', 5);
1982 rtable.fnSetColumnVis(5, true);
1986 $("#reports_form").submit(function(){
1987 var checkedItems = $("input[name=id]:checked");
1988 if ($(checkedItems).size() == 0) {
1989 alert(_("You must select one or more reports to delete"));
1992 $(checkedItems).parents('tr').addClass("warn");
1993 if( confirm(_("Are you sure you want to delete the selected reports?")) ) {
1996 $(checkedItems).parents('tr').removeClass("warn");
2001 $("body").on("click", ".update_sql", function(e){
2003 var ltitle = $(this).text();
2004 var report_id = $(this).data("report_id");
2005 var page = $(this).attr("href");
2006 $("#update_sql .modal-body").load(page + " div", function(){
2007 var diff1 = $("#col1 .show_sql").text();
2008 var diff2 = $("#col2 .show_sql").text();
2009 var diffs = diffString( escape(diff1), escape(diff2) );
2010 $("#col1 .show_sql,#col2 .show_sql").html(diffs);
2012 $('#update_sql').modal('show');
2013 $("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?op=convert&id=" + report_id);
2016 $("#update_sql").on("hidden.bs.modal", function(){
2017 $("#update_sql_label").html("");
2018 $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
2022 [% IF ( showsql ) %]
2023 $("#sql").focus(function() {
2028 $("#toggle_sql").click(function(){
2029 var sql_output = $("#sql_output");
2030 sql_output.toggle();
2031 if( sql_output.is(":visible") ){
2032 $(this).button('complete');
2034 $(this).button('reset');
2037 showsql = CodeMirror.fromTextArea(sql, {
2046 $(".toggle_chart_settings").click(function(){
2047 $("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
2050 [% IF (create || editsql || save) %]
2052 var validated_form = $("#sql_report_form").validate({
2053 reportname: "required",
2056 depends: function(element) {
2057 return $("#create_group").prop("checked") && $("#groupdesc_input").val() != '';
2063 depends: function(element) {
2064 return $("#create_group").prop("checked") && $("#group_input").val() != '';
2070 $("#select_group").change(function() {
2071 if($(this).prop('checked')) {
2072 $("#group_input").attr("class","").prop('disabled', true).prop("required", false);
2073 $("#groupdesc_input").attr("class","").prop('disabled', true).prop("required", false);
2074 $("#group_select").prop('disabled', false);
2075 clearValidation( $("#sql_report_form") );
2076 if ($("#group_select").val().length > 0) {
2077 $("#select_subgroup").prop('checked', true);
2078 $("#select_subgroup").change();
2079 $("#subgroup, #subgroup *").show();
2081 $("#subgroup").hide();
2085 $("#create_group").change(function() {
2086 if($(this).prop('checked')) {
2087 $("#group_input").prop('disabled', false).prop("required", true );
2088 $("#groupdesc_input").prop('disabled', false).prop("required", true );
2089 $("#group_select").prop('disabled', true);
2090 // $("#create_subgroup").prop('checked', true).change();
2091 $("#subgroup_select").hide();
2092 $("#subgroup input[type='radio']").hide();
2093 $("#subgroup label[for]").hide();
2094 $("#subgroup_input").prop("required", false ).prop("disabled", false).show();
2095 $("#subgroupdesc_input").prop("required", false ).prop("disabled", false).show();
2096 $("#subgroup").show();
2097 // Add validation rules for fields which were previously hidden
2098 $("#subgroup_input").rules("add", {
2100 depends: function(element) {
2101 return $("#create_group").prop("checked") && $("#subgroupdesc_input").val() != '';
2105 $("#subgroupdesc_input").rules("add", {
2107 depends: function(element) {
2108 return $("#create_group").prop("checked") && $("#subgroup_input").val() != '';
2114 $("#select_subgroup").change(function() {
2115 if($(this).prop('checked')) {
2116 $("#subgroup_select").prop('disabled', false);
2117 $("#subgroup_input").prop('disabled', true).prop("required", false );
2118 $("#subgroupdesc_input").prop('disabled', true).prop("required", false );
2119 clearValidation( $("#sql_report_form") );
2122 $("#create_subgroup").change(function() {
2123 if($(this).prop('checked')) {
2124 $("#subgroup_input").prop('disabled', false).prop("required", true );
2125 $("#subgroupdesc_input").prop('disabled', false).prop("required", true );
2126 $("#subgroup_select").val("").prop('disabled', true);
2129 $("#select_group").change();
2130 $("#select_subgroup").change();
2131 $("#group_select").on("change",function(){
2132 load_group_subgroups();
2135 $(".insertParam").on("click", function(e){
2137 var category = this.id;
2138 showParamModal( category );
2141 $("#runtime_parameters").on("shown.bs.modal", function(){
2142 $("#paramLabel").focus();
2145 $("#runtime_parameters").on("hide.bs.modal", function(){
2146 $("#send_runtime_parameter")[0].reset();
2147 $("#authorised_value_category").val("").hide();
2148 $("label[for='authorised_value']").removeClass("required");
2149 $("#authorised_value").prop("required", false ).removeAttr("required").removeClass("required");
2152 $("#send_runtime_parameter").on("submit", function(e){
2154 /* Get form values */
2155 var paramLabel = $("#paramLabel").val();
2156 var param_category = $("#param_category").val();
2157 var categoryLabel = $("#authorised_value").val();
2158 // Get CodeMirror environment variables
2159 var selection = editor.getSelection();
2160 var doc = editor.getDoc();
2161 var cursor = doc.getCursor();
2166 /* Build runtime parameter text string */
2168 if( paramLabel && param_category ){
2169 text += paramLabel + "|" + param_category;
2170 } else if( paramLabel ) {
2172 } else if( param_category ){
2173 text += param_category;
2176 text = " <<" + text + ">> ";
2177 if( selection.length > 0){
2178 editor.replaceSelection(text);
2180 doc.replaceRange(text, pos);
2183 $("#runtime_parameters").modal("hide");
2186 $("#authorised_value").on("change", function(){
2187 $("#param_category").val( $(this).val() );
2192 $(".delete").on("click",function(e){
2194 if ( confirmDelete(MSG_CONFIRM_DELETE) ) {
2195 return $(this).siblings('form').submit();
2199 $("#mana_search_form").submit(function(e){
2203 $("#column_submit").submit(function() {
2204 if ($("#selectedColumns option").size() < 1) {
2205 alert(_("No columns selected!"));
2208 $("#selectedColumns option").attr("selected", "selected"); // Select everything still in #selectedColumns
2213 $("body").on("click", ".mana-use", function(e) {
2215 $(this).find("i").attr("class","fa-solid fa-rotate fa-spin");
2216 mana_use( $(this).data("report_id") );
2219 $("#mana_search_result").on("shown.bs.modal", function(){
2220 $("#mana_search_field").focus();
2223 $("#mana_search_result").on("hide.bs.modal", function(){
2224 $("#mana_result_content").html("");
2225 $("#mana_search_field").val("");
2228 $(".batch_op").on("click", function(e){
2230 var target_form = $(this).data("submit");
2231 $("#" + target_form ).submit();
2234 $("#batch_add_to_list").on("submit", function(e){
2239 $("body").on("click", ".preview_sql", function(e){
2241 var reportid = $(this).data("reportid");
2242 previewSql( reportid );
2244 $(".limitselect").on("click", function(){
2245 var limit = $(this).data("limit");
2246 $("#limit").val( limit );
2247 $("#limitselect").submit();
2251 $("#toggle_auto_links").on("click", function(e){
2253 if( $(".data-plain").is(":visible") ){
2254 /* if a data-plain element is visible, this click hides it and shows auto-links */
2255 localStorage.removeItem("reports_auto_link_off");
2257 /* if a data-plain element is hidden, this click shows it and hides auto-links */
2258 localStorage.setItem("reports_auto_link_off", 1);
2260 $(".data-plain,.autolink").toggle();
2262 if ( localStorage.getItem("reports_auto_link_off") == 1 ){
2263 $("#toggle_auto_links").click();
2266 function tabsInit( tab, rtable ){
2267 var activeTab = tab.index();
2268 localStorage.setItem("sql_reports_activetab", activeTab );
2270 $("#subgroup_filter option").each(function() {
2271 if($(this).val().length > 0) {
2275 rtable.fnFilter('', 4);
2276 rtable.fnFilter('', 5);
2277 rtable.fnSetColumnVis(4, true);
2278 rtable.fnSetColumnVis(5, true);
2280 var g_id = tab.find("a").data("tabname");
2281 if (g_id === 'reports') {
2285 if (g_id && g_id.length > 0) {
2286 const input = '^' + $.fn.dataTable.util.escapeRegex(g_id) + '$';
2287 rtable.fnFilter(input, 4, true, false, true, false);
2288 rtable.fnSetColumnVis(4, false);
2289 for(var i in group_subgroups[g_id]) {
2290 $("#subgroup_filter").append(
2291 '<option value="' + group_subgroups[g_id][i][0] + '">'
2292 + group_subgroups[g_id][i][1] + '</option>'
2295 $("#subgroup_filter_block").show();
2297 $("#subgroup_filter_block").hide();
2301 function addColumn() {
2302 $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
2304 function delColumn() {
2305 $("#selectedColumns option:selected").remove();
2309 function mana_use( mana_id ){
2312 url: "/cgi-bin/koha/svc/mana/use",
2313 data: {id:mana_id, resource: 'report', saveinbase: 1, csrf_token: $('meta[name="csrf-token"]').attr('content')},
2316 .done( function (result){
2317 if ( result.errmsg ){
2318 alert( result.errmsg );
2321 window.location = ("/cgi-bin/koha/reports/guided_reports.pl?id=").concat(result.id).concat("&op=show&mana_success=1");
2324 .fail(function( error ) {
2325 $(".mana_use_status").hide();
2326 $("#mana_use_errortext").html( error.status + " " + error.statusText );
2327 $("#mana_use_failed").show();
2328 $(".mana-use i").attr("class","fa fa-download");
2332 function mana_search( textquery ){
2333 $(".mana_search_status").hide();
2334 $("#mana_result_content").load("/cgi-bin/koha/svc/mana/search #mana_results", { resource: 'report', id: textquery, usecomments: 1 }, function( response, status, xhr ) {
2336 if ( status == "error" ) {
2337 $("#mana_search_errortext").html( xhr.status + " " + xhr.statusText );
2338 $("#mana_search_failed").show();
2339 $("#mana-loading").hide();
2341 $(".mana_search_status").hide();
2342 $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
2343 $("#mana-loading").hide();
2344 $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
2345 "pagingType": "full",
2348 { "width": "35%", "targets": 1 }
2351 { "orderable": false, "searchable": false, "targets": [ 'NoSort' ] },
2352 { "type": "anti-the", "targets": [ 'anti-the'] }
2356 $(".showbutton").on("click", function(e){
2358 $(this).parent().hide();
2359 $(this).parent().next().show();
2362 $(".hidebutton").on("click", function(e){
2364 $(this).parent().hide();
2365 $(this).parent().prev().show();
2368 if($("td.dataTables_empty").length == 0){
2369 $("#mana_search_message").show();
2375 function addToList() {
2376 var biblionumbers = [];
2377 $(".bib_to_list").each(function() {
2378 var biblionumber = Number( $(this).val() );
2379 if( biblionumbers.indexOf( biblionumber ) < 0 ){
2380 biblionumbers.push( biblionumber );
2383 bibs = biblionumbers.join("/");
2384 var url = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumbers=" + bibs;
2385 window.open(url, 'Add_to_virtualshelf', 'width=500, height=400, toolbar=false, scrollbars=yes');
2389 // Adapted from https://gist.github.com/jnormore/7418776
2390 function previewSql(reportid) {
2393 var message = $("#previewSql" + reportid ).val();
2394 var title = $("#previewSql" + reportid ).data("title");
2395 if( $("#preview-sql-modal").length > 0) {
2396 $("#preview-sql-modal").remove();
2398 $("body").append('<div id="preview-sql-modal" tabindex="-1" role="dialog" aria-hidden="true" class="modal">\
2399 <div class="modal-dialog">\
2400 <div class="modal-content">\
2401 <div class="modal-header" style="min-height:40px;">\
2402 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">\
2403 <span aria-hidden="true">×</span>\
2405 <h4 class="modal-title">' + title + '</h4>\
2407 <div class="modal-body"><textarea id="code' + reportid + '">' + message + '</textarea>\
2409 <div class="modal-footer">\
2410 <a id="preview-modal-editreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?id=' + reportid + '&op=edit_form"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + _("Edit") + '</a>\
2411 <a id="preview-modal-duplicate" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?op=duplicate&id=' + reportid + '"><i class="fa fa-copy"></i> ' + _("Duplicate") + '</a>\
2412 <a id="preview-modal-duplicate" class="btn btn-default" href="/cgi-bin/koha/tools/scheduler.pl?id=' + reportid + '"><i class="fa-solid fa-clock"></i> ' + _("Schedule") + '</a>\
2413 <form method="post" action="/cgi-bin/koha/reports/guided_reports.pl">\
2414 [% INCLUDE 'csrf-token.inc' | collapse %]\
2415 <input type="hidden" name="op" value="cud-delete" />\
2416 <input type="hidden" name="id" value="' + reportid + '" />\
2418 <a id="preview-modal-delete"href="#" class="btn btn-default" title="Delete this saved report"><i class="fa fa-trash-can"></i> ' + _("Delete") + '</a>\
2419 <a id="preview-modal-runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?id=' + reportid + '&op=run"><i class="fa fa-play"></i> ' + _("Run report") + '</a>\
2420 <a href="#" id="preview-sql-modal-cancel" data-dismiss="modal" class="btn btn-default"><i class="fa fa-times" aria-hidden="true"></i> ' + _("Close") + '</a>\
2426 $("#preview-sql-modal").modal('show');
2427 CodeMirror.fromTextArea( document.getElementById("code" + reportid ), {
2433 $("#preview-modal-delete").on("click",function(e){
2435 if ( confirmDelete(MSG_CONFIRM_DELETE) ) {
2436 return $(this).siblings('form').submit();
2444 [% INCLUDE 'intranet-bottom.inc' %]
2446 [% BLOCK group_and_subgroup_selection %]
2448 <label>Report group:</label>
2449 <input type="radio" name="select_or_create_group"
2450 id="select_group" checked="checked" />
2451 <label for="select_group" class="radio">Select</label>
2452 <select name="group" id="group_select">
2453 <option value="">(None)</option>
2454 [% FOREACH group IN groups_with_subgroups %]
2455 [% IF (group.selected) %]
2456 <option value="[% group.id | html %]" selected="selected">
2458 <option value="[% group.id | html %]">
2460 [% group.name | html %]
2464 <input type="radio" name="select_or_create_group" id="create_group" />
2465 <label for="create_group" class="radio">or create:</label>
2466 <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
2467 <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
2470 <label>Report subgroup:</label>
2471 <input type="radio" name="select_or_create_subgroup"
2472 id="select_subgroup" checked="checked" />
2473 <label for="select_subgroup" style="float:none">Select</label>
2474 <select name="subgroup" id="subgroup_select">
2475 <option value="">(None)</option>
2476 [% FOREACH group IN groups_with_subgroups %]
2477 [% IF (group.selected) %]
2478 [% FOREACH subgroup IN group.subgroups %]
2479 [% IF (subgroup.selected) %]
2480 <option value="[% subgroup.id | html %]" selected="selected">
2482 <option value="[% subgroup.id | html %]">
2484 [% subgroup.name | html %]
2490 <input type="radio" name="select_or_create_subgroup"
2491 id="create_subgroup" />
2492 <label for="create_subgroup" style="float:none">or create</label>
2493 <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
2494 <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />
2498 [% BLOCK insert_runtime_parameter %]
2499 <div class="btn-group" style="margin-left:30px;">
2500 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
2501 Insert runtime parameter <span class="caret"></span>
2503 <ul class="dropdown-menu">
2504 <li><a href="#" class="insertParam" id="insertAuthVal">Authorized values</a></li>
2505 <li><a href="#" class="insertParam" id="insertFramework">Bibliographic framework</a></li>
2506 <li><a href="#" class="insertParam" id="insertCnSource">Classification sources</a></li>
2507 <li><a href="#" class="insertParam" id="insertDate">Date</a></li>
2508 <li><a href="#" class="insertParam" id="insertItemtypes">Item types</a></li>
2509 <li><a href="#" class="insertParam" id="insertBranches">Libraries</a></li>
2510 <li><a href="#" class="insertParam" id="insertList">List</a></li>
2511 <li><a href="#" class="insertParam" id="insertCategorycode">Patron categories</a></li>
2512 <li><a href="#" class="insertParam" id="insertCashregister">Cash registers</a></li>
2513 <li><a href="#" class="insertParam" id="insertDebittypes">Debit types</a></li>
2514 <li><a href="#" class="insertParam" id="insertCredittypes">Credit types</a></li>
2515 <li><a href="#" class="insertParam" id="insertText">Text field</a></li>