5 [% USE ColumnsSettings %]
9 [%- BLOCK area_name -%]
11 [%- CASE 'CIRC' -%]Circulation
12 [%- CASE 'CAT' -%]Catalog
13 [%- CASE 'PAT' -%]Patrons
14 [%- CASE 'ACQ' -%]Acquisitions
15 [%- CASE 'ACC' -%]Accounts
16 [%- CASE 'SER' -%]Serials
20 [% INCLUDE 'doc-head-open.inc' %]
23 Koha › Reports › Guided reports wizard
25 › Saved reports
26 [%- ELSIF ( create ) -%]
27 › Create from SQL
28 [%- ELSIF ( showsql ) -%]
29 › Saved reports › SQL view
30 [%- ELSIF ( execute ) -%]
31 › Saved reports › [% name | html %] Report
32 [%- ELSIF ( editsql ) -%]
33 › Saved reports › Edit SQL report
36 › Build a report, step 1 of 6: Choose a module
37 [%- ELSIF ( build2 ) -%]
38 › Build a report, step 2 of 6: Pick a report type
39 [%- ELSIF ( build3 ) -%]
40 › Build a report, step 3 of 6: Select columns for display
41 [%- ELSIF ( build4 ) -%]
42 › Build a report, step 4 of 6: Select criteria to limit on
43 [%- ELSIF ( build5 ) -%]
44 › Build a report, step 5 of 6: Pick which columns to total
45 [%- ELSIF ( build6 ) -%]
46 › Build a report, step 6 of 6: Select how you want the report ordered
50 [% INCLUDE 'doc-head-close.inc' %]
51 [% Asset.css("lib/codemirror/codemirror.min.css") | $raw %]
56 #mana_search_errortext { font-family: monospace; font-weight: bold; }
58 [% Asset.css("css/reports.css") | $raw %]
59 [% Asset.css("lib/d3c3/c3.min.css") | $raw %]
62 <body id="rep_guided_reports_start" class="rep">
63 [% INCLUDE 'header.inc' %]
64 [% INCLUDE 'circ-search.inc' %]
66 <div id="breadcrumbs">
67 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
68 › <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
69 › <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
72 › Saved reports
73 [% ELSIF ( create ) %]
74 › Create from SQL
75 [% ELSIF ( showsql ) %]
76 › <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> › SQL view
77 [% ELSIF ( editsql ) %]
78 › <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> › Edit SQL report
79 [% ELSIF ( execute ) %]
80 › <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a> › <em>[% name | html %]</em> Report
81 [% ELSIF ( build1 || build2 || build3 || build4 || build5 || build6 ) %]
82 › <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a report</a>
84 › Step 1 of 6: Choose a module
85 [% ELSIF ( build2 ) %]
86 › Step 2 of 6: Pick a report type
87 [% ELSIF ( build3 ) %]
88 › Step 3 of 6: Select columns for display
89 [% ELSIF ( build4 ) %]
90 › Step 4 of 6: Select criteria to limit on
91 [% ELSIF ( build5 ) %]
92 › Step 5 of 6: Pick which columns to total
93 [% ELSIF ( build6 ) %]
94 › Step 6 of 6: Select how you want the report ordered
99 <div id="update_sql" class="modal" tabindex="-1" role="dialog" aria-labelledby="update_sql_label" aria-hidden="true">
100 <div class="modal-dialog">
101 <div class="modal-content">
102 <div class="modal-header">
103 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
104 <h3 id="update_sql_label">Update SQL</h3>
106 <div class="modal-body">
107 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
109 <div class="modal-footer">
110 <a href="#" class="btn btn-default" id="update_sql_button" role="button" data-toggle="modal">Update</a>
111 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
117 <div class="main container-fluid">
119 <div class="col-sm-10 col-sm-push-2">
122 [% INCLUDE "reports-toolbar.inc" %]
125 <h2>Guided reports</h2>
126 <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>
128 <h3>Build and run reports</h3>
130 [% IF ( CAN_user_reports_create_reports ) %]
131 <form action="/cgi-bin/koha/reports/guided_reports.pl">
132 <input type="hidden" name="phase" value="Build new" />
133 <input type="submit" name="submit" value="Build new"/>
137 [% IF ( CAN_user_reports_execute_reports ) %]
138 <form action="/cgi-bin/koha/reports/guided_reports.pl">
139 <input type="hidden" name="phase" value="Use saved"/>
140 <input type="submit" name="submit" value="Use saved"/>
144 [% IF ( CAN_user_reports_create_reports ) %]
145 <form action="/cgi-bin/koha/reports/guided_reports.pl">
146 <input type="hidden" name="phase" value="Create report from SQL"/>
147 <input type="submit" name="submit" value="Create report from SQL"/>
151 <h3>Reports Dictionary</h3>
152 <p>Use the reports dictionary to define custom criteria to use in your reports</p>
153 <form action="/cgi-bin/koha/reports/dictionary.pl">
154 <input type="hidden" name="phase" value="View Dictionary"/>
155 <input type="submit" name="submit" value="View dictionary"/>
159 [% IF report_converted %]
160 <div class="dialog message">
161 The report "[% report_converted | html %]" has been converted.
165 [% IF report_converted %]
166 <div class="dialog message">
167 The report "[% report_converted | html %]" has been converted.
172 [% IF ( savedreports ) %]
173 <h1>Saved reports</h1>
175 [% IF ( filters.date || filters.author || filters.keyword ) %]
177 <span class="filter">
178 [% IF ( filters.date ) %]
179 <span class="filter_date"><strong>Date:</strong> [% filters.date | html %]</span>
181 [% IF ( filters.author ) %]
182 <span class="filter_author"><strong>Author:</strong> [% filters.author | html %]</span>
184 [% IF ( filters.keyword ) %]
185 <span class="filter_keyword"><strong>Keyword:</strong> [% filters.keyword | html %]</span>
187 <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>
192 <div id="tabs" class="toptabs">
194 <li><a href="#reports">All</a></li>
195 [% FOREACH group IN groups_with_subgroups %]
196 <li><a id="[% group.id | html %]" href="#reports">[% group.name | html %]</a></li>
200 <div id="subgroup_filter_block">
201 <label for="subgroup_filter">Subgroup:</label>
202 <select id="subgroup_filter">
203 <option value="">All</option>
207 [% IF (Koha.Preference('Mana') == 1) %]
209 <div id="mana_search_message" class="dialog message">
210 <p> [% manamsg | html %] </p>
215 <form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
216 <input type="hidden" name="phase" value="Delete Multiple" />
217 <table id="table_reports">
228 <th class="title-string">Creation date</th>
229 <th class="title-string">Last edit</th>
230 <th class="title-string">Last run</th>
231 <th class="report_public">Public</th>
232 <th class="report_json_url">JSON URL</th>
234 <th>Cache expiry (seconds)</th>
236 <th class="hidden"> </th>
238 <th>Saved results</th>
239 [% IF has_obsolete_reports %]
242 <th class="hidden"> </th>
248 [% FOREACH savedreport IN savedreports %]
249 [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
250 <td class="report_checkbox">
251 [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
252 <input type="checkbox" name="ids" value="[% savedreport.id | html %]" />
254 <input type="hidden" class="report_sql" value="[% savedreport.savedsql |html %]">
256 <td class="report_id">
257 <label for="ids">[% savedreport.id | html %]</label>
259 <td class="report_name">
260 [% IF ( savedreport.report_name ) %]
261 [% savedreport.report_name | html %]
266 <td class="report_type">
267 [% savedreport.type | html %]
269 <td class="report_group">
270 [% savedreport.groupname | html %]
273 [% savedreport.subgroupname | html %]
275 <td class="report_notes">
276 [% savedreport.notes | html %]
279 [% savedreport.borrowersurname | html %]
280 [% IF ( savedreport.borrowerfirstname ) %]
281 , [% savedreport.borrowerfirstname | html %]
283 ([% savedreport.borrowernumber | html %])
286 <span title="[% savedreport.date_created | html %]">[% savedreport.date_created | $KohaDates %]</span>
289 <span title="[% savedreport.last_modified | html %]">[% savedreport.last_modified | $KohaDates with_hours => 1 %]</span>
292 <span title="[% savedreport.last_run | html %]">[% savedreport.last_run | $KohaDates with_hours => 1 %]</span>
294 <td class="report_public">
295 [% IF (savedreport.public) %]
301 <td class="report_json_url">
302 [% IF (savedreport.public) %]
303 <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>
305 <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>
309 [% savedreport.cache_expiry | html %]
312 [% FOR result IN savedreport.results %]
313 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=[% result.id | uri %]">[% result.date_run | html %]</a>
318 [% IF savedreport.seems_obsolete %]
319 This report seems obsolete, it uses biblioitems.marcxml field.
320 <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>
325 <div class="btn-group">
326 [%# There should be no space between these two buttons, it would render badly %]
327 <a class="btn btn-default btn-xs" role="button"
328 href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&phase=Run%20this%20report"><i
329 class="fa fa-play"></i> Run</a><a
330 class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown"
331 href="#"><b class="caret"></b></a>
332 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
333 <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL"><i class="fa fa-search"></i> Show</a></li>
334 [% IF ( CAN_user_reports_create_reports ) %]
335 <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>
336 <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from SQL&sql=[% savedreport.savedsql |uri %]&reportname=[% savedreport.report_name |uri %]&notes=[% savedreport.notes |uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
338 [% IF (Koha.Preference('Mana') == 1) %]
339 <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>
341 <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
342 [% IF ( CAN_user_reports_delete_reports ) %]
343 <li><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a></li>
354 [% IF ( CAN_user_reports_delete_reports ) %]
355 <fieldset class="action">
356 <input type="submit" value="Delete selected" />
363 <div class="dialog message">
364 [% IF (filter_set || filters.date || filters.author || filters.keyword) %]
365 <h4>No saved reports match your criteria. </h4>
366 [% IF ( CAN_user_reports_create_reports ) %]
367 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
368 <input type="hidden" name="phase" value="Build new" />
369 <button type="submit" class="new"><i class="fa fa-plus"></i> New guided report</button>
372 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
373 <input type="hidden" name="phase" value="Create report from SQL" />
374 <button type="submit" class="new"><i class="fa fa-plus"></i> New SQL report</button>
377 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
378 <input type="hidden" name="phase" value="Use saved" />
379 <input type="hidden" name="filter_set" value="1" />
380 <input type="hidden" name="filter_keyword" value="" />
381 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> Cancel filter</button>
385 <h4>There are no saved reports. </h4>
386 [% IF ( CAN_user_reports_create_reports ) %]
387 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a new report?</a>
394 [% INCLUDE 'mana/mana-share-report.inc' %]
397 [% IF ( cache_error) %]
398 <div class="dialog alert">
399 <b> Please choose a cache_expiry less than 30 days </b>
403 <h1>Build a report</h1>
404 <form action="/cgi-bin/koha/reports/guided_reports.pl">
405 <fieldset class="rows">
406 <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and choose report visibility </legend>
409 <label for="area">Choose: </label>
410 <select name="area" id="area">
411 [%- FOREACH area IN areas -%]
412 <option value="[% area | html %]">[%- PROCESS area_name area=area -%]</option>
418 <label for="public">Report is public:</label>
419 <select id="public" name="public">
420 <option value="0">No (default)</option>
421 <option value="1" selected="selected">Yes</option>
426 <label for="public">Report is public:</label>
427 <select id="public" name="public">
428 <option value="0" selected="selected">No (default)</option>
429 <option value="1">Yes</option>
436 <label for="cache_expiry">Cache expiry:</label>
437 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
438 <select id="cache_expiry_units" name="cache_expiry_units">
439 <option value="seconds">Seconds (default)</option>
440 <option value="minutes">Minutes</option>
441 <option value="hours">Hours</option>
442 <option value="days">Days</option>
448 <fieldset class="action">
449 <input type="hidden" name="phase" value="Report on this Area" />
450 <input type="submit" name="submit" value="Next >>" />
456 <h1>Build a report</h1>
457 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
458 <input type="hidden" name="area" value="[% area | html %]" />
459 <input type="hidden" name="public" value="[% public | html %]" />
460 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
461 <fieldset class="rows">
462 <legend>Step 2 of 6: Pick a report type</legend>
465 <label for="types">Choose: </label>
466 <select id="types" name="types">
467 <option value="1">Tabular</option>
468 <option value="2" disabled="disabled">Summary</option>
469 <option value="3" disabled="disabled">Matrix</option>
475 <fieldset class="action">
476 <input type="hidden" name="phase" value="Choose this type" />
477 <input type="button" name="back" value="<< Back" class="goback" />
478 <input type="submit" name="submit" value="Next >>" />
484 <h1>Build a report</h1>
485 <h3>Step 3 of 6: Select columns for display</h3>
486 <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>
488 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
489 <input type="hidden" name="area" value="[% area | html %]" />
490 <input type="hidden" name="type" value="[% type | html %]" />
491 <input type="hidden" name="public" value="[% public | html %]" />
492 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
495 <div class="col-sm-6">
496 <div style="float: left;">
497 <select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
498 [% FOREACH column IN columns %]
499 [% IF ( column.table ) %]
500 [% IF ( loop.first ) %]
504 <optgroup label="[% column.table | html %]">
506 <option value="[% column.name | html %]">
507 [% IF ( column.description ) %]
508 [% column.description | html %] / [% column.name | html %]
510 [% column.name | html %]
518 <div style="width: 6.3em; float: right; margin-top: 100px">
519 <input type="button" name="Add" value="Add" class="button" style="width:6em;" id="addColumn" /><br />
520 <input type="button" name="delete" value="<< Delete" class="button" style="width: 6em; margin: 1em 0;" id="delColumn" />
524 <div class="col-sm-6">
525 <select id="selectedColumns" name="columns" multiple="multiple" size="25" style="width:200px; height:300px;">
530 <fieldset class="action">
531 <input type="hidden" name="phase" value="Choose these columns" />
532 <input type="button" name="back" value="<< Back" class="goback" />
533 <input type="submit" name="submit" value="Next >>" />
539 <h1>Build a report</h1>
540 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" >
541 <input type="hidden" name="area" value="[% area | html %]" />
542 <input type="hidden" name="type" value="[% type | html %]" />
543 <input type="hidden" name="column" value="[% column | html %]" />
544 <input type="hidden" name="public" value="[% public | html %]" />
545 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
547 <legend>Step 4 of 6: Select criteria to limit on</legend>
549 [% FOREACH criteri IN criteria %]
552 <input type="checkbox" name="criteria_column" id="[% criteri.name | html %]" value="[% criteri.name | html %]" />
553 <label for="[% criteri.name | html %]">[% criteri.description | html %] </label>
555 [% IF ( criteri.date ) %]
557 <input type="text" size="10" id="[% criteri.name | html %]_value" name="[% criteri.name | html %]_value" value="" class="datepicker" />
558 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
562 [% IF ( criteri.textrange ) %]
565 <input type="text" size="10" id="[% criteri.from | html %]_value" name="[% criteri.from | html %]_value" value="" /> to
566 <input type="text" size="10" id="[% criteri.to | html %]_value" name="[% criteri.to | html %]_value" value="" />
570 [% IF ( criteri.daterange ) %]
573 <input type="text" size="10" id="from_[% criteri.name | html %]_value" name="from_[% criteri.name | html %]_value" value="" class="datepickerfrom" />
575 <input type="text" size="10" id="to_[% criteri.name | html %]_value" name="to_[% criteri.name | html %]_value" value="" class="datepickerto" />
576 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
581 <select name="[% criteri.name | html %]_value">
582 [% FOREACH value IN criteri.values %]
583 <option value="[% value.availablevalues | html %]">
584 [% IF ( value.default ) %]
587 [% value.display_value | html %]
601 [% IF ( definitions ) %]
603 <legend>Dictionary definitions</legend>
605 [% FOREACH definition IN definitions %]
608 <input type="checkbox" name="definition" value="[% definition.id | html %]" />
609 [% definition.name | html %]
617 <fieldset class="action">
618 <input type="hidden" name="phase" value="Choose these criteria" />
619 <input type="button" name="back" value="<< Back" class="goback" />
620 <input type="submit" name="submit" value="Next >>" />
626 <h1>Build a report</h1>
627 <h3>Step 5 of 6: Pick which columns to total</h3>
628 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
629 <input type="hidden" name="area" value="[% area | html %]" />
630 <input type="hidden" name="type" value="[% type | html %]" />
631 <input type="hidden" name="column" value="[% column | html %]" />
632 <input type="hidden" name="definition" value="[% definition | html %]" />
633 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
634 <input type="hidden" name="public" value="[% public | html %]" />
635 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
638 [% FOREACH total_b IN total_by %]
641 <input type="checkbox" name="total_by" id="[% total_b.name | html %]" value="[% total_b.name | html %]" />
642 <label for="[% total_b.name | html %]">[% total_b.name | html %]</label>
645 <select name="[% total_b.name | html %]_tvalue">
646 [% FOREACH selec IN total_b.select %]
647 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
656 <fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
657 <input type="button" name="back" value="<< Back" class="goback" />
658 <input type="submit" name="submit" value="Next >>" />
664 <h1>Build a report</h1>
665 <h3>Step 6 of 6: Choose how you want the report ordered</h3>
666 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
667 <input type="hidden" name="area" value="[% area | html %]" />
668 <input type="hidden" name="type" value="[% type | html %]" />
669 <input type="hidden" name="column" value="[% column | html %]" />
670 <input type="hidden" name="criteria" value="[% criteriastring | html %]" />
671 <input type="hidden" name="definition" value="[% definition | html %]" />
672 <input type="hidden" name="totals" value="[% totals | html %]" />
673 <input type="hidden" name="public" value="[% public | html %]" />
674 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
677 [% FOREACH order_b IN order_by %]
680 <input type="checkbox" id="[% order_b.name | html %]" name="order_by" value="[% order_b.name | html %]" />
681 <label for="[% order_b.name | html %]">[% order_b.name | html %]</label>
684 <select name="[% order_b.name | html %]_ovalue">
685 [% FOREACH selec IN order_b.select %]
686 <option value="[% selec.value | html %]">[% selec.value | html %]</option>
694 <fieldset class="action">
695 <input type="hidden" name="phase" value="Build report" />
696 <input type="submit" name="submit" value="Finish" />
701 [% IF ( showreport ) %]
702 <h1>Confirm custom report</h1>
703 <p>Your report will be generated with the following SQL statement.</p>
708 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
709 <input type="hidden" name="sql" value="[% sql | html %]" />
710 <input type="hidden" name="type" value="[% type | html %]" />
711 <input type="hidden" name="public" value="[% public | html %]" />
712 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
713 <p>You will need to save the report before you can execute it</p>
714 <fieldset class="action"><input type="hidden" name="phase" value="Save" />
715 <input type="submit" name="submit" value="Save" />
721 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
722 <input type="hidden" name="sql" value="[% sql | html %]" />
723 <input type="hidden" name="type" value="[% type | html %]" />
724 <input type="hidden" name="area" value="[% area | html %]" />
725 <input type="hidden" name="public" value="[% public | html %]" />
726 <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
727 <fieldset class="rows">
728 <legend>Save your custom report</legend>
731 <label for="reportname" class="required">Report name: </label>
732 <input type="text" id="reportname" name="reportname" class="required" required="required" />
733 <span class="required">Required</span>
735 [% PROCESS group_and_subgroup_selection %]
737 <label for="notes">Notes:</label>
738 <textarea name="notes" id="notes"></textarea>
742 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
743 <input type="submit" name="submit" value="Save report" />
748 [% IF ( warn_authval_problem ) %]
749 <div class="dialog alert">
750 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
751 [% FOREACH problematic_authval IN problematic_authvals %]
753 <strong>[% problematic_authval.name | html %]:</strong> The authorized value category (<strong>[% problematic_authval.authval | html %]</strong>)
754 you selected does not exist.
757 <!-- Save Anyway Form -->
758 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
759 <!--Every parameter the user issued is provided as a hidden field for recovery-->
760 <input type='hidden' name='id' value='[% id | html %]' />
761 <input type='hidden' name='sql' value='[% sql | html %]' />
762 <input type='hidden' name='reportname' value='[% reportname | html %]' />
763 <input type='hidden' name='group' value='[% group | html %]' />
764 <input type='hidden' name='subgroup' value='[% subgroup | html %]' />
765 <input type='hidden' name='notes' value='[% notes | html %]' />
766 <input type='hidden' name='cache_expiry' value='[% cache_expiry | html %]' />
767 <input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units | html %]' />
768 <input type='hidden' name='public' value='[% public | html %]' />
769 [% IF ( phase_update) %]
770 <input type='hidden' name='phase' value='Update SQL' />
771 <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
772 [% ELSIF ( phase_save) %]
773 <input type='hidden' name='area' value='[% area | html %]' />
774 <input type='hidden' name='phase' value='Save Report' />
775 <button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
778 <!-- Go back to editing -->
779 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
780 <button type="button" class="new goback"><i class="fa fa-fw fa-pencil"></i> Edit SQL</button>
785 [% IF ( enter_params ) %]
786 <form action='/cgi-bin/koha/reports/guided_reports.pl'>
787 <input type='hidden' name='reports' value="[% reports | html %]" />
788 [% IF ( auth_val_error ) %]
789 <input type='hidden' name='phase' value='Edit SQL' />
790 <div class="dialog alert">
791 <h3>Errors found when processing parameters for report: [% name | html %]</h3>
792 [% FOREACH auth_val_error IN auth_val_errors %]
794 <strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
795 you selected does not exist.
799 <fieldset class="action"><input type="submit" value="Edit SQL" /></fieldset>
801 <input type='hidden' name='phase' value='Run this report' />
802 <h1>Enter parameters for report [% name | html %]:</h1>
804 <p>[% notes | html %]</p>
806 <fieldset class="rows">
808 [% FOREACH sql_param IN sql_params %]
809 <input name="param_name" value="[% sql_param.name | html %]" type="hidden" />
810 [% IF sql_param.input == 'date' %]
812 <label for="date_[% sql_param_entry | html %][% loop.count | html %]">[% sql_param.entry | html %]:</label> <input id="date_[% sql_param_entry | html %][% loop.count | html %]" type="text" value="" size="10" name="sql_params" class="datepicker" />
814 [% ELSIF ( sql_param.input == 'text' ) %]
816 <label for="sql_params[% loop.count | html %]">[% sql_param.entry | html %]: </label>
817 <input id="sql_params[% loop.count | html %]" type="text" name="sql_params" />
821 <label for="sql_params_[% sql_param.labelid | html %]">[% sql_param.entry | html %]:</label>
822 <select name="[%- sql_param.input.name | html -%]" tabindex="1" size="1" id="[%- sql_param.input.id | html -%]">
823 [% IF (sql_param.include_all) %]
824 <option value="%">All</option>
826 [% FOREACH value IN sql_param.input.values %]
827 <option value="[%- value | html -%]">[%- sql_param.input.labels.$value | html -%]</option>
835 <fieldset class="action">
836 <input type="submit" value="Run the report" />
843 <h1>[% name | html %]</h1>
845 <p><span class="label">Notes:</span> [% notes | html %]</p>
847 [% IF ( unlimited_total ) %]
849 <span class="label">Total number of results:</span>
850 [% unlimited_total | html %]
851 [% IF unlimited_total > limit %]
852 ([% limit | html %] shown)
857 <div id="sql_output" style="display:none;">
858 <span class="label">Report SQL:</span>
859 <textarea id="sql" readonly="readonly">[% sql | html %]</textarea>
863 <a href="#" id="toggle_chart_settings_hid" class="toggle_chart_settings" style="display:none"><i class="fa fa-eye-slash"></i> Hide chart</a>
864 <a href="#" id="toggle_chart_settings_vis" class="toggle_chart_settings" style="display:none"><i class="fa fa fa-eye"></i> Show chart</a>
866 <div id="chart" class="clearfix"></div>
869 [% UNLESS ( errors ) %]
870 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl" id="batch_record_modification">
871 <input type="hidden" name="recordtype" value="biblio" />
872 <input type="hidden" name="op" value="list" />
873 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
874 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %][% cells.cell | html %][% END %][% END %][% END %]</textarea>
877 <form method="POST" action="/cgi-bin/koha/tools/batch_delete_records.pl" id="batch_record_deletion">
878 <input type="hidden" name="recordtype" value="biblio" />
879 <input type="hidden" name="op" value="list" />
880 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
881 <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %][% cells.cell | html %][% END %][% END %][% END %]</textarea>
884 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_modification">
885 <input type="hidden" name="op" value="show" />
886 [% FOREACH result IN results %]
887 [% FOREACH cells IN result.cells %]
888 [% place = loop.index %]
889 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
890 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
891 [% SET batch_itemnumbers = 1 %]
892 [% SET header_row.$place.has_itemnumbers = 1 %]
893 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
899 <form method="POST" action="/cgi-bin/koha/tools/batchMod.pl" id="batch_item_deletion">
900 <input type="hidden" name="op" value="show" />
901 <input type="hidden" name="del" value="1" />
902 [% FOREACH result IN results %]
903 [% FOREACH cells IN result.cells %]
904 [% place = loop.index %]
905 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
906 [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
907 [% SET batch_itemnumbers = 1 %]
908 [% SET header_row.$place.has_itemnumbers = 1 %]
909 <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
915 <form method="get" action="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl" id="batch_add_to_list">
916 [% FOREACH result IN results %]
917 [% FOREACH cells IN result.cells %]
918 [% place = loop.index %]
919 [% NEXT UNLESS cells.cell.match('^(\d+)$') %]
920 [% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
921 [% SET batch_biblionumbers = 1 %]
922 [% SET header_row.$place.has_biblionumbers = 1 %]
923 <input type="hidden" class="bib_to_list" name="biblionumber" value="[% cells.cell | html %]" />
929 <form method="POST" action="/cgi-bin/koha/tools/modborrowers.pl" id="batch_patron_modification">
930 <input type="hidden" name="op" value="show" />
931 [% # Preserve the whitespace of the following textarea in order to format the values correctly %]
932 <textarea style="display:none" name="cardnumberlist" id="cardnumberlist">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'cardnumber' || header_types.item(header_row.$place.cell) == 'cardnumber' %][% SET batch_cardnumbers = 1 %][% cells.cell | html %][% END %][% END %][% END %]</textarea>
935 [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
937 <div class="dropdown">
938 <button class="btn btn-default dropdown-toggle" type="button" id="batch_mod_menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
939 Batch operations with [% IF unlimited_total > limit %][% limit | html %][% ELSE %][% unlimited_total | html %][% END %] visible records
940 <span class="caret"></span>
942 <ul class="dropdown-menu" aria-labelledby="batch_mod_menu">
943 [% FOREACH header_ro IN header_row %]
944 [% IF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
945 <li class="dropdown-header">Bibliographic records</li>
947 <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>
950 <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>
953 <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>
956 [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
957 [% IF ( batch_biblionumbers ) %]
958 <li role="separator" class="divider"></li>
960 <li class="dropdown-header">Item records</li>
962 <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>
965 <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>
968 [% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
969 [% IF ( batch_biblionumbers || batch_itemnumbers ) %]
970 <li role="separator" class="divider"></li>
972 <li class="dropdown-header">Patron records</li>
974 <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>
978 </ul> <!-- /.dropdown-menu -->
979 </div> <!-- /.dropdown -->
982 [% END # UNLESS ( errors ) %]
983 [% END # IF ( execute ) %]
985 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
986 <input type="hidden" name="phase" value="Run this report"/>
987 <input type="hidden" name="reports" value="[% report_id | html %]"/>
989 [% FOREACH p IN sql_params %]
990 <input type="hidden" name="sql_params" value="[% p | html %]"/>
992 [% FOREACH n IN param_names %]
993 <input type="hidden" name="param_name" value="[% n | html %]"/>
996 <label for="limit">Rows per page: </label>
997 <select name="limit" id="limit">
998 [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
999 [% FOREACH l IN limits %]
1001 <option value="[% l | html %]" selected="selected">[% l | html %]</option>
1003 <option value="[% l | html %]">[% l | html %]</option>
1009 <div class="pages">[% pagination_bar | $raw %]</div>
1010 [% UNLESS ( errors ) %]
1013 [% FOREACH header_ro IN header_row %]
1014 <th>[% header_ro.cell | html %]</th>
1017 [% FOREACH result IN results %]
1019 [% FOREACH cells IN result.cells %]
1020 <td>[% cells.cell | $raw %]</td>
1027 [% INCLUDE 'chart.inc' %]
1032 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1033 <fieldset class="rows">
1034 <legend>Create report from SQL</legend>
1037 <label for="reportname" class="required">Report name:</label>
1038 [% IF ( reportname ) %]
1039 <input type="text" class="required" required="required" id="reportname" name="reportname" value="[% reportname | html %]" size="50"/>
1041 <input type="text" class="required" required="required" id="reportname" name="reportname" size="50" />
1043 <span class="required">Required</span>
1045 [% PROCESS group_and_subgroup_selection %]
1049 <label for="public">Report is public:</label>
1050 <select id="public" name="public">
1051 <option value="0">No (default)</option>
1052 <option value="1" selected="selected">Yes</option>
1057 <label for="public">Report is public:</label>
1058 <select id="public" name="public">
1059 <option value="0" selected="selected">No (default)</option>
1060 <option value="1">Yes</option>
1067 <label for="cache_expiry">Cache expiry:</label>
1068 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]"></input>
1069 <select id="cache_expiry_units" name="cache_expiry_units">
1070 <option value="seconds" selected="selected">Seconds (default)</option>
1071 <option value="minutes">Minutes</option>
1072 <option value="hours">Hours</option>
1073 <option value="days">Days</option>
1078 <label for="notes">Notes:</label>
1079 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1084 <fieldset class="rows">
1085 <legend>SQL:</legend>
1086 <div style="margin:1em;">
1087 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea>
1088 <span class="required">Required</span>
1092 <fieldset class="action">
1093 <input type="hidden" name="phase" value="Save Report" />
1094 <input type="submit" name="submit" value="Save report" />
1095 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1100 [% IF saved_results %]
1101 <h1>Saved report results</h1>
1102 <h2>[% name | html %]</h2>
1103 <p>[% notes | html %]</p>
1105 [% FOREACH rows IN saved_results %]
1107 [% FOREACH col IN rows %]
1108 <td>[% col | html %]</td>
1115 [% IF ( showsql ) %]
1116 <fieldset class="rows">
1117 <legend>[% reportname | html %]</legend>
1121 <span class="label">Notes:</span>
1127 <textarea id="sql">[% sql | html %]</textarea>
1133 [% IF ( save_successful ) %]
1134 [% UNLESS ( errors ) %]
1136 <div id="report_updated">
1137 <div class="dialog message">
1138 <p>Your report "[% reportname | html %]" has been saved</p>
1144 [% IF ( editsql ) %]
1145 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="sql_report_form">
1146 <input type="hidden" name="phase" value="Update SQL" />
1147 <input type="hidden" name="id" value="[% id | html %]"/>
1148 <fieldset class="rows">
1149 <legend>Edit SQL report</legend>
1152 <label for="reportname" class="required">Report name: </label>
1153 <input type="text" id="reportname" name="reportname" value="[% reportname | html %]" size="50" class="required" required="required" />
1154 <span class="required">Required</span>
1156 [% PROCESS group_and_subgroup_selection %]
1159 <label for="public">Report is public:</label>
1160 <select id="public" name="public">
1161 <option value="0">No (default)</option>
1162 <option value="1" selected="selected">Yes</option>
1167 <label for="public">Report is public:</label>
1168 <select id="public" name="public">
1169 <option value="0" selected="selected">No (default)</option>
1170 <option value="1">Yes</option>
1177 <label for="cache_expiry">Cache expiry:</label>
1178 <input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry | html %]" />
1179 <select id="cache_expiry_units" name="cache_expiry_units">
1180 <option value="seconds">Seconds (default)</option>
1181 <option value="minutes">Minutes</option>
1182 <option value="hours">Hours</option>
1183 <option value="days">Days</option>
1188 <label for="notes">Notes:</label>
1189 <textarea id="notes" name="notes" cols="50" rows="2">[% notes | html %]</textarea>
1194 <fieldset class="rows">
1195 <legend>SQL:</legend>
1196 <div style="margin:1em;">
1197 <textarea id="sql" name="sql" class="required" required="required" cols="50" rows="10">[% sql | html %]</textarea>
1198 <span class="required">Required</span>
1202 <fieldset class="action">
1203 <input type="submit" name="submit" value="Update SQL" />
1204 <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
1210 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
1211 <div class="dialog alert">
1212 <b>The following error was encountered:</b><br />
1213 [% FOREACH error IN errors %]
1214 [% IF ( error.sqlerr ) %]
1215 This report contains the SQL keyword <b>[% error.sqlerr | html %]</b>.<br />
1216 Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.<br />
1217 Please return to the "Saved Reports" screen and delete this report or retry creating a new one.
1218 [% ELSIF ( error.queryerr ) %]
1219 The database returned the following error: <br />
1220 [% error.queryerr | html %]<br />Please check the log for further details.
1221 [% ELSIF ( error.cache_expiry ) %]
1222 Please select a cache expiry less than 30 days.
1225 <div id="onerror_actions">
1226 <a href="#" class="button goback">Return to previous page</a>
1230 <fieldset class="action">
1231 <input type="hidden" name="phase" value="Use saved" />
1232 <input type="submit" name="submit" value="Saved reports" />
1238 </div> <!-- /.col-sm-10.col-sm-push-2 -->
1240 <div class="col-sm-2 col-sm-pull-10">
1243 <div id="saved-reports-filter">
1244 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
1245 <input type="hidden" name="phase" value="Use saved" />
1246 <input type="hidden" name="filter_set" value="1" />
1247 <fieldset class="brief">
1251 <label for="filter_date">Date:</label>
1252 <input type="text" id="filter_date" name="filter_date" size="10" value="[% filters.date | html %]" class="datepicker" />
1253 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
1256 <label for="filter_author">Author:</label>
1257 <input type="text" id="filter_author" name="filter_author" value="[% filters.author | html %]" size="16" />
1260 <label for="filter_keyword">Keyword:</label>
1261 <input type="text" id="filter_keyword" name="filter_keyword" value="[% filters.keyword | html %]" size="16" />
1265 <fieldset class="action">
1266 <input type="submit" value="Apply filter" />
1267 <a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1">Clear</a>
1272 [% INCLUDE 'guided-reports-view.inc' %]
1274 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1275 </div> <!-- /.row -->
1277 [% MACRO jsinclude BLOCK %]
1278 [% Asset.js("js/charts.js") | $raw %]
1279 [% Asset.js("lib/d3c3/d3.min.js") | $raw %]
1280 [% Asset.js("lib/d3c3/c3.min.js") | $raw %]
1281 [% INCLUDE 'calendar.inc' %]
1282 [% INCLUDE 'datatables.inc' %]
1284 [% INCLUDE 'columns_settings.inc' %]
1286 [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
1287 [% Asset.js( "lib/codemirror/sql.min.js" ) | $raw %]
1288 [% Asset.js( "js/mana.js" ) | $raw %]
1291 function hide_bar_element() {
1292 $('#chart-column-horizontal').hide()
1293 $('.chart-column-group').each(function( index ) {
1296 $('.chart-column-line').each(function( index ) {
1301 function show_bar_element() {
1302 $('#chart-column-horizontal').show()
1303 $('.chart-column-group').each(function( index ) {
1306 $('.chart-column-line').each(function( index ) {
1311 function removeColumn(id) {
1314 if ( $('.chart-column-conf').length == 1 ) {
1315 $('.chart-column-delete').remove();
1319 var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1320 var group_subgroups = {};
1321 [% FOREACH group IN groups_with_subgroups %]
1322 var gid = "[% group.id | html %]"
1323 group_subgroups[gid] = new Array();
1324 [% FOREACH subgroup IN group.subgroups %]
1325 var sgid = "[% subgroup.id | html %]";
1326 var sgname = "[% subgroup.name | html %]";
1327 group_subgroups[gid].push([sgid, sgname]);
1331 [% IF ( create || editsql || save ) %]
1332 var editor = CodeMirror.fromTextArea(sql, {
1339 // https://stackoverflow.com/questions/2086287/how-to-clear-jquery-validation-error-messages#answer-16025232
1340 function clearValidation( formElement ){
1341 // formElement should be a jQuery object
1342 var validator = formElement.validate();
1343 // Iterate through named elements inside of the form, and mark them as error free
1344 $('[name]',formElement).each(function(){
1345 validator.successList.push(this);//mark as error free
1346 validator.showErrors();//remove error messages if present
1348 validator.resetForm();//remove error class on name elements and clear history
1349 validator.reset();//remove all error and success data
1353 [% IF ( showsql ) %]
1354 var editor = CodeMirror.fromTextArea(sql, {
1362 function load_group_subgroups () {
1363 var group = $("#group_select").val();
1364 var sg = $("#subgroup");
1365 $(sg).find('option[value!=""]').each(function() {
1370 var select = $(sg).find('select')[0];
1371 $.each( group_subgroups[group], function(index, value) {
1372 $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(select);
1374 $("#subgroup, #subgroup *").show();
1378 $(document).ready(function(){
1379 $("body").on('click',".fetch_chart_data",function(){
1380 if( [% unlimited_total || 0 | $raw %] > 1000 ){
1381 if( confirm("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you with to chart this report?") ){
1392 if ( $('.chart-column-conf').length == 1 ) {
1393 $('.chart-column-delete').remove();
1396 $(".chart-column-delete").on('click', function(e){
1398 removeColumn('column_' + $(this).data('column'));
1401 $('#download-chart').click(function() {
1402 var svg = '<svg>' + $('#chart svg').html() + '</svg>';
1403 this.href = 'data:application/octet-stream;base64,' + btoa(svg);
1404 this.setAttribute('download', 'chart.svg');
1407 $('#chart-type').change(function() {
1408 if ($(this).val() == 'bar') {
1416 $('#download-chart').hide();
1419 [% IF results && !errors %]
1420 $('#draw-chart').click(function() {
1422 var x_elements = $('select[name="x"]').val();
1423 var y_elements = [];
1428 headers = [% header_row.json | $raw %];
1431 [% IF allresults.size %]
1432 if ($('input[name="chart-include-all"]').prop('checked')) {
1433 results = [% allresults.json | $raw %]
1436 results = [% results.json | $raw %]
1439 results = [% results.json | $raw %];
1442 if ($('input[name="chart-exclude-last"]').prop('checked')) {
1443 results.splice(-1, 1);
1446 $('select[name="y"]').each(function( index ) {
1447 y_elements.push( $(this).val() );
1449 $('select[name="group"]').each(function( index ) {
1450 groups.push( $(this).val() );
1452 $('.column-line').each(function( index ) {
1453 if ($(this).prop('checked')) {
1454 lines.push( $(this).attr('name') );
1458 // Remove deleted columns from headers and results.
1459 var deleted_indexes = [];
1460 var kept_headers = [];
1461 $.each(headers, function(index, value) {
1462 if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) {
1463 // This header is neither a x element nor in y elements. Don't need it.
1464 deleted_indexes.push(index);
1467 kept_headers.push({cell: value.cell});
1471 // Remove coresponding cells.
1472 var kept_results = [];
1473 $.each(results, function(index, value) {
1476 $.each(value.cells, function(i, val) {
1477 if ($.inArray(i, deleted_indexes) === -1) {
1478 line['cells'].push({cell: val.cell});
1481 kept_results.push(line);
1484 options.type = $('select[name="chart-type"]').val();
1485 options.horizontal = $('input[name="column-horizontal"]').prop('checked');
1486 options.lines = lines;
1488 chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options);
1489 $("#download-chart,#toggle_chart_settings_hid,#chart").show();
1490 $("#toggle_chart_settings_vis").hide();
1491 $("#chartModal").modal("hide");
1495 load_group_subgroups();
1498 $('[data-toggle="tooltip"]').tooltip();
1499 var columns_settings = [% ColumnsSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1501 $('#limit').change(function() {
1502 $('#limitselect').submit();
1505 $(document).click(function() {
1506 $('#report_updated').hide();
1509 $(".goback").on("click",function(e){
1511 window.history.back();
1514 $("body").on("click", ".mana_search_button", function(){
1515 $("#mana-loading").show();
1516 mana_search($("#mana_search_field").val());
1519 $(".ShareButton").on("click", function(){
1520 $("#note-error").hide();
1521 if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
1522 $(".shared_infos").hide();
1523 $("#note-error").show();
1526 $("#reportid").val($(this).closest("tr").find(".report_id").text());
1527 $("#shared_id").html($(this).closest("tr").find(".report_id").text());
1528 $("#shared_name").html($(this).closest("tr").find(".report_name").text());
1529 $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
1530 $("#shared_type").html($(this).closest("tr").find(".report_type").text());
1531 $("#shared_group").html($(this).closest("tr").find(".report_group").text());
1532 $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
1536 $("#ManaCloseButton").on("click", function() {
1537 $(".shared_infos").show();
1540 $("#addColumn").on("click",function(){
1544 $("#delColumn").on("click",function(){
1549 var rtable = KohaTable("table_reports", {
1550 'iDisplayLength': [% Koha.Preference('NumSavedReports') | html %],
1551 'bAutoWidth': false,
1552 'sPaginationType': 'full',
1553 'aaSorting': [[ 1, "asc" ]],
1555 { 'bSortable': false, 'bSearchable':false, 'aTargets': [0, -1] },
1556 { 'bSearchable': false, 'aTargets': [3] },
1557 { "aTargets": [ 1, 2 ], "sType": "natural" },
1558 { "sType": "title-string", "aTargets" : [ "title-string" ] },
1559 { "visible": false, "aTargets" : [ "hidden" ] }
1562 'sZeroRecords': _("No matching reports found")
1564 }, columns_settings);
1566 var rtabs = $("#tabs").tabs();
1567 rtabs.on("tabsactivate", function(e, ui) {
1568 $("#subgroup_filter option").each(function() {
1569 if($(this).val().length > 0) {
1573 rtable.fnFilter('', 4);
1574 rtable.fnFilter('', 5);
1575 rtable.fnSetColumnVis(4, true);
1576 rtable.fnSetColumnVis(5, true);
1578 var g_id = $(ui.newTab).children().attr('id');
1579 var g_name = $(ui.newTab).text();
1580 if ( g_name == _("All") ) {
1585 if (g_id && g_id.length > 0) {
1586 rtable.fnFilter('^' + g_name + '$', 4, true, true, true, false);
1587 rtable.fnSetColumnVis(4, false);
1588 for(var i in group_subgroups[g_id]) {
1589 $("#subgroup_filter").append(
1590 '<option value="' + group_subgroups[g_id][i][0] + '">'
1591 + group_subgroups[g_id][i][1] + '</option>'
1594 $("#subgroup_filter_block").show();
1596 $("#subgroup_filter_block").hide();
1599 $("#subgroup_filter_block").hide();
1601 $("#subgroup_filter").change(function() {
1602 var selected = $(this).find('option:selected');
1603 var sg_id = $(selected).val();
1604 var sg_name = $(selected).text();
1605 if (sg_id.length > 0) {
1606 rtable.fnFilter('^' + sg_name + '$', 5, true, true, true, false);
1607 rtable.fnSetColumnVis(5, false);
1609 rtable.fnFilter('', 5);
1610 rtable.fnSetColumnVis(5, true);
1614 $("#reports_form").submit(function(){
1615 var checkedItems = $("input[name=ids]:checked");
1616 if ($(checkedItems).size() == 0) {
1617 alert(_("You must select one or more reports to delete"));
1620 $(checkedItems).parents('tr').addClass("warn");
1621 if( confirm(_("Are you sure you want to delete the selected reports?")) ) {
1624 $(checkedItems).parents('tr').removeClass("warn");
1629 $("body").on("click", ".update_sql", function(e){
1631 var ltitle = $(this).text();
1632 var report_id = $(this).data("report_id");
1633 var page = $(this).attr("href");
1634 $("#update_sql .modal-body").load(page + " div", function(){
1635 var diff1 = $("#col1 .show_sql").text();
1636 var diff2 = $("#col2 .show_sql").text();
1637 var diffs = diffString( escape(diff1), escape(diff2) );
1638 $("#col1 .show_sql,#col2 .show_sql").html(diffs);
1640 $('#update_sql').modal('show');
1641 $("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?phase=Use saved&op=convert&report_id=" + report_id);
1644 $("#update_sql").on("hidden.bs.modal", function(){
1645 $("#update_sql_label").html("");
1646 $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
1650 [% IF ( showsql ) %]
1651 $("#sql").focus(function() {
1656 $(".toggle_sql").click(function(){
1657 $("#sql_output").toggle();
1658 $("#toggle_sql_hid").toggle();
1659 $("#toggle_sql_vis").toggle();
1661 showsql = CodeMirror.fromTextArea(sql, {
1670 $(".toggle_chart_settings").click(function(){
1671 $("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
1674 $("#table_reports").delegate(".confirmdelete", 'click', function(){
1675 $(this).parents('tr').attr("class","warn");
1676 if(confirm(_("Are you sure you want to delete this saved report?"))){
1679 $(this).parents('tr').attr("class","");
1684 [% IF (create || editsql || save) %]
1686 var validated_form = $("#sql_report_form").validate({
1687 reportname: "required",
1690 depends: function(element) {
1691 return $("#create_group").prop("checked") && $("#groupdesc_input").val() != '';
1697 depends: function(element) {
1698 return $("#create_group").prop("checked") && $("#group_input").val() != '';
1704 $("#select_group").change(function() {
1705 if($(this).prop('checked')) {
1706 $("#group_input").attr("class","").prop('disabled', true).prop("required", false);
1707 $("#groupdesc_input").attr("class","").prop('disabled', true).prop("required", false);
1708 $("#group_select").prop('disabled', false);
1709 clearValidation( $("#sql_report_form") );
1710 if ($("#group_select").val().length > 0) {
1711 $("#select_subgroup").prop('checked', true);
1712 $("#select_subgroup").change();
1713 $("#subgroup, #subgroup *").show();
1715 $("#subgroup").hide();
1719 $("#create_group").change(function() {
1720 if($(this).prop('checked')) {
1721 $("#group_input").prop('disabled', false).prop("required", true );
1722 $("#groupdesc_input").prop('disabled', false).prop("required", true );
1723 $("#group_select").prop('disabled', true);
1724 // $("#create_subgroup").prop('checked', true).change();
1725 $("#subgroup_select").hide();
1726 $("#subgroup input[type='radio']").hide();
1727 $("#subgroup label[for]").hide();
1728 $("#subgroup_input").prop("required", false ).prop("disabled", false).show();
1729 $("#subgroupdesc_input").prop("required", false ).prop("disabled", false).show();
1730 $("#subgroup").show();
1731 // Add validation rules for fields which were previously hidden
1732 $("#subgroup_input").rules("add", {
1734 depends: function(element) {
1735 return $("#create_group").prop("checked") && $("#subgroupdesc_input").val() != '';
1739 $("#subgroupdesc_input").rules("add", {
1741 depends: function(element) {
1742 return $("#create_group").prop("checked") && $("#subgroup_input").val() != '';
1748 $("#select_subgroup").change(function() {
1749 if($(this).prop('checked')) {
1750 $("#subgroup_select").prop('disabled', false);
1751 $("#subgroup_input").prop('disabled', true).prop("required", false );
1752 $("#subgroupdesc_input").prop('disabled', true).prop("required", false );
1753 clearValidation( $("#sql_report_form") );
1756 $("#create_subgroup").change(function() {
1757 if($(this).prop('checked')) {
1758 $("#subgroup_input").prop('disabled', false).prop("required", true );
1759 $("#subgroupdesc_input").prop('disabled', false).prop("required", true );
1760 $("#subgroup_select").val("").prop('disabled', true);
1763 $("#select_group").change();
1764 $("#select_subgroup").change();
1765 $("#group_select").on("change",function(){
1766 load_group_subgroups();
1770 $(".delete").on("click",function(){
1771 return confirmDelete(MSG_CONFIRM_DELETE);
1774 $("#mana_search_form").submit(function(e){
1778 $("#column_submit").submit(function() {
1779 if ($("#selectedColumns option").size() < 1) {
1780 alert(_("No columns selected!"));
1783 $("#selectedColumns option").attr("selected", "selected"); // Select everything still in #selectedColumns
1788 $("body").on("click", ".mana-use", function(e) {
1790 $(this).find("i").attr("class","fa fa-refresh fa-spin");
1791 mana_use( $(this).data("report_id") );
1794 $("#mana_search_result").on("hide.bs.modal", function(){
1795 $("#mana_result_content").html("");
1796 $("#mana_search_field").val("");
1799 $(".batch_op").on("click", function(e){
1801 var target_form = $(this).data("submit");
1802 $("#" + target_form ).submit();
1805 $("#batch_add_to_list").on("submit", function(e){
1811 function addColumn() {
1812 $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected");
1814 function delColumn() {
1815 $("#selectedColumns option:selected").remove();
1819 function mana_use( mana_id ){
1822 url: "/cgi-bin/koha/svc/mana/use",
1823 data: {id:mana_id, resource: 'report', saveinbase: 1},
1826 .done( function (result){
1827 if ( result.errmsg ){
1828 alert( result.errmsg );
1831 window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&phase=Show%20SQL&mana_success=1");
1834 .fail(function( error ) {
1835 $(".mana_use_status").hide();
1836 $("#mana_use_errortext").html( error.status + " " + error.statusText );
1837 $("#mana_use_failed").show();
1838 $(".mana-use i").attr("class","fa fa-download");
1842 function mana_search( textquery ){
1843 $(".mana_search_status").hide();
1844 $("#mana_result_content").load("/cgi-bin/koha/svc/mana/search #mana_results", { resource: 'report', id: textquery, usecomments: 1 }, function( response, status, xhr ) {
1846 if ( status == "error" ) {
1847 $("#mana_search_errortext").html( xhr.status + " " + xhr.statusText );
1848 $("#mana_search_failed").show();
1849 $("#mana-loading").hide();
1851 $(".mana_search_status").hide();
1852 $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
1853 $("#mana-loading").hide();
1854 $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
1855 "sPaginationType":"full",
1858 { "width": "35%", "targets": 1 }
1861 { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
1862 { "sType": "title-string", "aTargets" : [ "title-string" ] },
1863 { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
1867 $(".showbutton").on("click", function(e){
1869 $(this).parent().hide();
1870 $(this).parent().next().show();
1873 $(".hidebutton").on("click", function(e){
1875 $(this).parent().hide();
1876 $(this).parent().prev().show();
1879 if($("td.dataTables_empty").length == 0){
1880 $("#mana_search_message").show();
1886 function addToList() {
1887 var biblionumbers = [];
1888 $(".bib_to_list").each(function() {
1889 var biblionumber = Number( $(this).val() );
1890 if( biblionumbers.indexOf( biblionumber ) < 0 ){
1891 biblionumbers.push( biblionumber );
1894 bibs = biblionumbers.join("/");
1895 var url = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumbers=" + bibs;
1896 window.open(url, 'Add_to_virtualshelf', 'width=500, height=400, toolbar=false, scrollbars=yes');
1902 [% INCLUDE 'intranet-bottom.inc' %]
1904 [% BLOCK group_and_subgroup_selection %]
1906 <label>Report group:</label>
1907 <input type="radio" name="select_or_create_group"
1908 id="select_group" checked="checked" />
1909 <label for="select_group" style="float:none">Select</label>
1910 <select name="group" id="group_select">
1911 <option value="">(None)</option>
1912 [% FOREACH group IN groups_with_subgroups %]
1913 [% IF (group.selected) %]
1914 <option value="[% group.id | html %]" selected="selected">
1916 <option value="[% group.id | html %]">
1918 [% group.name | html %]
1922 <input type="radio" name="select_or_create_group" id="create_group" />
1923 <label for="create_group" style="float:none">or create:</label>
1924 <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" />
1925 <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" />
1928 <label>Report subgroup:</label>
1929 <input type="radio" name="select_or_create_subgroup"
1930 id="select_subgroup" checked="checked" />
1931 <label for="select_subgroup" style="float:none">Select</label>
1932 <select name="subgroup" id="subgroup_select">
1933 <option value="">(None)</option>
1934 [% FOREACH group IN groups_with_subgroups %]
1935 [% IF (group.selected) %]
1936 [% FOREACH subgroup IN group.subgroups %]
1937 [% IF (subgroup.selected) %]
1938 <option value="[% subgroup.id | html %]" selected="selected">
1940 <option value="[% subgroup.id | html %]">
1942 [% subgroup.name | html %]
1948 <input type="radio" name="select_or_create_subgroup"
1949 id="create_subgroup" />
1950 <label for="create_subgroup" style="float:none">or create</label>
1951 <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" />
1952 <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" />