Bug 34478: Add 'op' to reports/guided_reports - WIP
Bug 34478: [TO SQUASH] Add 'op' to reports/guided_reports Found bug 36071 when working on this. This is not a regression from this patch. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
c16e579d48
commit
8a20e0cb6a
7 changed files with 378 additions and 391 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
<h5>Run reports</h5>
|
||||
<ul>
|
||||
[% IF ( CAN_user_reports_execute_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a></li>[% END %]
|
||||
[% IF ( CAN_user_reports_execute_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?op=list">Saved reports</a></li>[% END %]
|
||||
</ul>
|
||||
<h5>Reports dictionary</h5>
|
||||
<ul>
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
<ul>
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports</a></li>
|
||||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build new</a></li>
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form">Build new</a></li>
|
||||
[% END %]
|
||||
[% IF ( CAN_user_reports_execute_reports ) %]
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Use saved</a></li>
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?op=list">Use saved</a></li>
|
||||
[% END %]
|
||||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">Create from SQL</a></li>
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form_sql">Create from SQL</a></li>
|
||||
[% END %]
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<div class="btn-group">
|
||||
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New report <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li id="newmenuc"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">New guided report</a> </li>
|
||||
<li id="newsql"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">New SQL report</a> </li>
|
||||
<li id="newmenuc"><a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form">New guided report</a> </li>
|
||||
<li id="newsql"><a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form_sql">New SQL report</a> </li>
|
||||
[% IF Koha.Preference('Mana')==1 %]
|
||||
<li id="new_mana_sql"><a href="#" data-toggle="modal" data-target="#mana_search_result">New SQL from Mana</a> </li>
|
||||
[% END %]
|
||||
|
@ -15,9 +15,13 @@
|
|||
[% IF ( showsql || execute || editsql || save_successful ) %]
|
||||
[% IF ( CAN_user_reports_delete_reports && !CAN_user_reports_create_reports ) %]
|
||||
<div class="btn-group">
|
||||
<a class="delete btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Delete%20Saved">
|
||||
<i class="fa fa-trash-can"></i> Delete
|
||||
</a>
|
||||
<form>
|
||||
<input type="hidden" name="op" value="cud-delete" />
|
||||
<input type="hidden" name="id" value="[% id | html %]" />
|
||||
<button type="submit" class="delete btn btn-default">
|
||||
<i class="fa fa-trash-can"></i> Delete
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
[% IF ( CAN_user_reports_create_reports || CAN_user_reports_delete_reports ) %]
|
||||
|
@ -30,13 +34,13 @@
|
|||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
[% UNLESS ( editsql ) # Do not show edit button on edit page %]
|
||||
<li>
|
||||
<a id="editreport" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Edit%20SQL">
|
||||
<a id="editreport" href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | html %]&op=edit_form">
|
||||
Edit
|
||||
</a>
|
||||
</li>
|
||||
[% END %]
|
||||
<li>
|
||||
<a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from existing&report_id=[% id | uri %]">
|
||||
<a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?op=duplicate&id=[% id | uri %]">
|
||||
Duplicate
|
||||
</a>
|
||||
</li>
|
||||
|
@ -44,9 +48,12 @@
|
|||
|
||||
[% IF ( CAN_user_reports_delete_reports ) %]
|
||||
<li>
|
||||
<a class="delete" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Delete%20Saved">
|
||||
Delete
|
||||
</a>
|
||||
<form method="post" action="/cgi-bin/koha/reports/guided_reports.pl">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-delete" />
|
||||
<input type="hidden" name="id" value="[% id | html %]" />
|
||||
</form>
|
||||
<a href="#" class="delete">Delete</button>
|
||||
</li>
|
||||
[% END %]
|
||||
</ul>
|
||||
|
@ -58,7 +65,7 @@
|
|||
[% IF ( showsql || execute || editsql || save_successful ) %]
|
||||
[% UNLESS ( errors ) # Unless there are errors saving a report %]
|
||||
<div class="btn-group">
|
||||
<a id="runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Run%20this%20report">
|
||||
<a id="runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | html %]&op=run">
|
||||
<i class="fa fa-play"></i> Run report
|
||||
</a>
|
||||
</div>
|
||||
|
@ -71,7 +78,7 @@
|
|||
<ul class="dropdown-menu">
|
||||
[% FOREACH t IN templates %]
|
||||
<li>
|
||||
<a id="runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Run%20this%20report&template=[% t.id | html %][% PROCESS params %]">
|
||||
<a id="runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | html %]&op=run&template=[% t.id | html %][% PROCESS params %]">
|
||||
[% t.name | html %]
|
||||
</a>
|
||||
</li>
|
||||
|
@ -130,11 +137,11 @@
|
|||
<div class="btn-group">
|
||||
<button class="btn btn-default dropdown-toggle" aria-haspopup="menu" aria-label="Select format and download report results" data-toggle="dropdown" id="format"><i class="fa fa-download"></i> Download <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a id="csv" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&format=csv&report_id=[% id | html %]&reportname=[% name |uri %][% PROCESS params %]">[% PROCESS 'delimiter_text.inc' %]</a></li>
|
||||
<li><a id="tab" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&format=tab&report_id=[% id | html %]&reportname=[% name |uri %][% PROCESS params %]">Tab separated text</a></li>
|
||||
<li><a id="ods" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&format=ods&report_id=[% id | html %]&reportname=[% name |uri %][% PROCESS params %]">Open Document Spreadsheet</a></li>
|
||||
<li><a id="csv" href="/cgi-bin/koha/reports/guided_reports.pl?op=export&format=csv&id=[% id | html %]&reportname=[% name |uri %][% PROCESS params %]">[% PROCESS 'delimiter_text.inc' %]</a></li>
|
||||
<li><a id="tab" href="/cgi-bin/koha/reports/guided_reports.pl?op=export&format=tab&id=[% id | html %]&reportname=[% name |uri %][% PROCESS params %]">Tab separated text</a></li>
|
||||
<li><a id="ods" href="/cgi-bin/koha/reports/guided_reports.pl?op=export&format=ods&id=[% id | html %]&reportname=[% name |uri %][% PROCESS params %]">Open Document Spreadsheet</a></li>
|
||||
[% IF processed_notice_title %]
|
||||
<li><a id="template" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&format=template&report_id=[% id | html %]&template=[% template_id | html %]&reportname=[% name |uri %][% PROCESS params %]">Rendered template ([% processed_notice_title | html %])</a></li>
|
||||
<li><a id="template" href="/cgi-bin/koha/reports/guided_reports.pl?op=export&format=template&id=[% id | html %]&template=[% template_id | html %]&reportname=[% name |uri %][% PROCESS params %]">Rendered template ([% processed_notice_title | html %])</a></li>
|
||||
[% END %]
|
||||
[% IF (results.json) %]
|
||||
<li><a id="download-chart" href="#">Chart (.svg)</a></li>
|
||||
|
@ -151,7 +158,7 @@
|
|||
<a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-chart-bar"></i> Create chart</a>
|
||||
[% ELSE %]
|
||||
<a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-chart-bar"></i> Create chart</a>
|
||||
<a class="btn btn-default fetch_chart_data" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Run this report&reportname=[% name |uri %][% PROCESS params %]&want_full_chart=1"><i class="fa fa-chart-bar"></i> Fetch all data for chart</a>
|
||||
<a class="btn btn-default fetch_chart_data" href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | html %]&op=run&reportname=[% name |uri %][% PROCESS params %]&want_full_chart=1"><i class="fa fa-chart-bar"></i> Fetch all data for chart</a>
|
||||
[% END %]
|
||||
|
||||
</div>
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
[% END %]
|
||||
[% IF ( showsql || editsql || execute ) %]
|
||||
[% WRAPPER breadcrumb_item %]
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=list">Saved reports</a>
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% IF ( saved1 ) %]
|
||||
|
@ -111,21 +111,21 @@
|
|||
[% END %]
|
||||
[% ELSIF ( editsql ) %]
|
||||
[% WRAPPER breadcrumb_item %]
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | uri %]&phase=Show%20SQL">[% reportname | html %] ([% id | html %])</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | uri %]&op=show">[% reportname | html %] ([% id | html %])</a>
|
||||
[% END %]
|
||||
[% WRAPPER breadcrumb_item bc_active= 1 %]
|
||||
<span>Edit</span>
|
||||
[% END %]
|
||||
[% ELSIF ( execute ) %]
|
||||
[% WRAPPER breadcrumb_item %]
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | uri %]&phase=Show%20SQL">[% name | html %] ([% id | html %])</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | uri %]&op=show">[% name | html %] ([% id | html %])</a>
|
||||
[% END %]
|
||||
[% WRAPPER breadcrumb_item bc_active= 1 %]
|
||||
<span>Run</span>
|
||||
[% END %]
|
||||
[% ELSIF ( build1 || build2 || build3 || build4 || build5 || build6 ) %]
|
||||
[% WRAPPER breadcrumb_item %]
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a report</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form">Build a report</a>
|
||||
[% END %]
|
||||
[% WRAPPER breadcrumb_item bc_active= 1 %]
|
||||
[% IF ( build1 ) %]
|
||||
|
@ -179,32 +179,20 @@
|
|||
<h3>Build and run reports</h3>
|
||||
|
||||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
<form method="get" action="/cgi-bin/koha/reports/guided_reports.pl">
|
||||
<input type="hidden" name="phase" value="Build new" />
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="Build new" />
|
||||
</form>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form" class="btn btn-primary"/>Build new</a>
|
||||
[% END %]
|
||||
|
||||
[% IF ( CAN_user_reports_execute_reports ) %]
|
||||
<form method="get" action="/cgi-bin/koha/reports/guided_reports.pl">
|
||||
<input type="hidden" name="phase" value="Use saved"/>
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="Use saved" />
|
||||
</form>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=list" class="btn btn-primary"/>Used saved</a>
|
||||
[% END %]
|
||||
|
||||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
<form method="get" action="/cgi-bin/koha/reports/guided_reports.pl">
|
||||
<input type="hidden" name="phase" value="Create report from SQL"/>
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="Create report from SQL" />
|
||||
</form>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form_sql" class="btn btn-primary"/>Create report from SQL</a>
|
||||
[% END %]
|
||||
|
||||
<h3>Reports Dictionary</h3>
|
||||
<p>Use the reports dictionary to define custom criteria to use in your reports</p>
|
||||
<form method="get" action="/cgi-bin/koha/reports/dictionary.pl">
|
||||
<input type="hidden" name="phase" value="View Dictionary"/>
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="View dictionary" />
|
||||
</form>
|
||||
<a href="/cgi-bin/koha/reports/dictionary.pl?op=list" class="btn btn-primary"/>View dictionary</a>
|
||||
[% END # /IF (start) %]
|
||||
|
||||
[% IF report_converted %]
|
||||
|
@ -235,7 +223,7 @@
|
|||
[% IF ( filters.keyword ) %]
|
||||
<span class="filter_keyword"><strong>Keyword:</strong> [% filters.keyword | html %]</span>
|
||||
[% END %]
|
||||
<a class="clear_filter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1"><i class="fa fa-times"></i> Clear</a>
|
||||
<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>
|
||||
</span>
|
||||
</p>
|
||||
[% END %]
|
||||
|
@ -268,7 +256,7 @@
|
|||
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="phase" value="Delete Multiple" />
|
||||
<input type="hidden" name="op" value="cud-delete" />
|
||||
<table id="table_reports">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -304,12 +292,12 @@
|
|||
[% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
|
||||
<td class="report_checkbox">
|
||||
[% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
|
||||
<input type="checkbox" name="ids" id="ids[% savedreport.id | html %]" value="[% savedreport.id | html %]" />
|
||||
<input type="checkbox" name="id" id="id_[% savedreport.id | html %]" value="[% savedreport.id | html %]" />
|
||||
[% END %]
|
||||
<input type="hidden" class="report_sql" value="[% savedreport.savedsql |html %]">
|
||||
</td>
|
||||
<td class="report_id">
|
||||
<label for="ids[% savedreport.id | html %]">[% savedreport.id | html %]</label>
|
||||
<label for="id_[% savedreport.id | html %]">[% savedreport.id | html %]</label>
|
||||
</td>
|
||||
<td class="report_name">
|
||||
[% IF ( savedreport.report_name ) %]
|
||||
|
@ -362,41 +350,48 @@
|
|||
</td>
|
||||
<td>
|
||||
[% FOR result IN savedreport.results %]
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=[% result.id | uri %]">[% result.date_run | html %]</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=retrieve_results&id=[% result.id | uri %]">[% result.date_run | html %]</a>
|
||||
<br/>
|
||||
[% END %]
|
||||
</td>
|
||||
<td>
|
||||
[% IF savedreport.seems_obsolete %]
|
||||
This report seems obsolete, it uses biblioitems.marcxml field.
|
||||
<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-solid fa-eye"></i> Update SQL</a>
|
||||
<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>
|
||||
[% END %]
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group dropup">
|
||||
[%# There should be no space between these two buttons, it would render badly %]
|
||||
<a class="btn btn-default btn-xs" role="button"
|
||||
href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | html %]&phase=Run%20this%20report"><i
|
||||
href="/cgi-bin/koha/reports/guided_reports.pl?id=[% savedreport.id | html %]&op=run"><i
|
||||
class="fa fa-play"></i> Run</a><a
|
||||
class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown"
|
||||
href="#"><b class="caret"></b></a>
|
||||
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL"><i class="fa fa-search"></i> View</a></li>
|
||||
<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>
|
||||
<li>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL" class="preview_sql" data-reportid="[% savedreport.id | html %]">
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?id=[% savedreport.id | uri %]&op=show" class="preview_sql" data-reportid="[% savedreport.id | html %]">
|
||||
<i class="fa-solid fa-eye"></i> Preview SQL
|
||||
</a>
|
||||
</li>
|
||||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
<li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Edit%20SQL"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li>
|
||||
<li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from existing&report_id=[% savedreport.id | uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
|
||||
<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>
|
||||
<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>
|
||||
[% END %]
|
||||
[% IF (Koha.Preference('Mana') == 1) %]
|
||||
<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>
|
||||
[% END %]
|
||||
<li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id | uri %]"><i class="fa-solid fa-clock"></i> Schedule</a></li>
|
||||
[% IF ( CAN_user_reports_delete_reports ) %]
|
||||
<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-can"></i> Delete</a></li>
|
||||
<li>
|
||||
<form method="post" action="/cgi-bin/koha/reports/guided_reports.pl">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-delete" />
|
||||
<input type="hidden" name="id" value="[% savedreport.id | html %]" />
|
||||
</form>
|
||||
<a href="#" class="delete" title="Delete this saved report"><i class="fa fa-trash-can"></i> Delete</a>
|
||||
</li>
|
||||
[% END %]
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -425,27 +420,16 @@
|
|||
[% IF (filter_set || filters.date || filters.author || filters.keyword) %]
|
||||
<h4>No saved reports match your criteria. </h4>
|
||||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
|
||||
<input type="hidden" name="phase" value="Build new" />
|
||||
<button type="submit" class="new"><i class="fa fa-plus"></i> New guided report</button>
|
||||
</form>
|
||||
<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>
|
||||
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
|
||||
<input type="hidden" name="phase" value="Create report from SQL" />
|
||||
<button type="submit" class="new"><i class="fa fa-plus"></i> New SQL report</button>
|
||||
</form>
|
||||
<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>
|
||||
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
|
||||
<input type="hidden" name="phase" value="Use saved" />
|
||||
<input type="hidden" name="filter_set" value="1" />
|
||||
<input type="hidden" name="filter_keyword" value="" />
|
||||
<button type="submit" class="deny"><i class="fa fa-fw fa-times"></i> Cancel filter</button>
|
||||
</form>
|
||||
<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>
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
<h4>There are no saved reports. </h4>
|
||||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build a new report?</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form">Build a new report?</a>
|
||||
[% END %]
|
||||
[% END # IF (filter_set || filters.date || filters.author || filters.keyword) %]
|
||||
</div> <!-- /.dialog.message -->
|
||||
|
@ -462,7 +446,8 @@
|
|||
[% END %]
|
||||
|
||||
<h1>Build a report</h1>
|
||||
<form method="get" action="/cgi-bin/koha/reports/guided_reports.pl">
|
||||
<form method="post" action="/cgi-bin/koha/reports/guided_reports.pl">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<fieldset class="rows">
|
||||
<legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and choose report visibility </legend>
|
||||
<ol>
|
||||
|
@ -507,8 +492,8 @@
|
|||
</ol>
|
||||
</fieldset> <!-- /.rows -->
|
||||
<fieldset class="action">
|
||||
<input type="hidden" name="phase" value="Report on this Area" />
|
||||
<input type="submit" name="submit" value="Next >>" />
|
||||
<input type="hidden" name="op" value="cud-report" />
|
||||
<button type="submit" class="btn btn-primary" />Next >></button>
|
||||
</fieldset>
|
||||
</form>
|
||||
[% END # /build1 %]
|
||||
|
@ -535,9 +520,9 @@
|
|||
</fieldset>
|
||||
|
||||
<fieldset class="action">
|
||||
<input type="hidden" name="phase" value="Choose this type" />
|
||||
<input type="button" name="back" value="<< Back" class="goback" />
|
||||
<input type="submit" name="submit" value="Next >>" />
|
||||
<input type="hidden" name="op" value="cud-choose_type" />
|
||||
<button type="submit" class="btn btn-default goback" name="back"><< Back</button>
|
||||
<button type="submit" class="btn btn-primary" />Next >></button>
|
||||
</fieldset>
|
||||
</form>
|
||||
[% END # /IF (build2 ) %]
|
||||
|
@ -591,9 +576,9 @@
|
|||
</div> <!-- /.row -->
|
||||
</fieldset>
|
||||
<fieldset class="action">
|
||||
<input type="hidden" name="phase" value="Choose these columns" />
|
||||
<input type="button" name="back" value="<< Back" class="goback" />
|
||||
<input type="submit" name="submit" value="Next >>" />
|
||||
<input type="hidden" name="op" value="cud-choose_columns" />
|
||||
<button type="submit" class="btn btn-default goback" name="back"><< Back</button>
|
||||
<button type="submit" class="btn btn-primary" />Next >></button>
|
||||
</fieldset>
|
||||
</form> <!-- /#column_submit -->
|
||||
[% END # /IF ( build3 ) %]
|
||||
|
@ -679,9 +664,9 @@
|
|||
[% END %]
|
||||
|
||||
<fieldset class="action">
|
||||
<input type="hidden" name="phase" value="Choose these criteria" />
|
||||
<input type="button" name="back" value="<< Back" class="goback" />
|
||||
<input type="submit" name="submit" value="Next >>" />
|
||||
<input type="hidden" name="op" value="cud-choose_criteria" />
|
||||
<button type="submit" class="btn btn-default goback" name="back"><< Back</button>
|
||||
<button type="submit" class="btn btn-primary" />Next >></button>
|
||||
</fieldset>
|
||||
</form>
|
||||
[% END # /IF ( build4 ) %]
|
||||
|
@ -718,9 +703,9 @@
|
|||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="action"><input type="hidden" name="phase" value="Choose these operations" />
|
||||
<input type="button" name="back" value="<< Back" class="goback" />
|
||||
<input type="submit" name="submit" value="Next >>" />
|
||||
<fieldset class="action"><input type="hidden" name="op" value="cud-choose_operations" />
|
||||
<button type="submit" class="btn btn-default goback" name="back"><< Back</button>
|
||||
<button type="submit" class="btn btn-primary" />Next >></button>
|
||||
</fieldset>
|
||||
</form>
|
||||
[% END # /IF ( build5 ) %]
|
||||
|
@ -758,7 +743,7 @@
|
|||
</table>
|
||||
</fieldset>
|
||||
<fieldset class="action">
|
||||
<input type="hidden" name="phase" value="Build report" />
|
||||
<input type="hidden" name="op" value="cud-build_report" />
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="Finish" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
@ -778,7 +763,7 @@
|
|||
<input type="hidden" name="public" value="[% public | html %]" />
|
||||
<input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" />
|
||||
<p>You will need to save the report before you can execute it</p>
|
||||
<fieldset class="action"><input type="hidden" name="phase" value="Save" />
|
||||
<fieldset class="action"><input type="hidden" name="op" value="cud-save" />
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="Next" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
@ -807,7 +792,7 @@
|
|||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
<fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
|
||||
<fieldset class="action"><input type="hidden" name="op" value="cud-save" />
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="Save report" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
@ -835,39 +820,38 @@
|
|||
<input type='hidden' name='cache_expiry' value='[% cache_expiry | html %]' />
|
||||
<input type='hidden' name='cache_expiry_units' value='[% cache_expiry_units | html %]' />
|
||||
<input type='hidden' name='public' value='[% public | html %]' />
|
||||
[% IF ( phase_update) %]
|
||||
<input type='hidden' name='phase' value='update_sql' />
|
||||
[% IF ( op == 'update') %]
|
||||
<input type='hidden' name='op' value='cud-update' />
|
||||
<button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
|
||||
[% ELSIF ( phase_save) %]
|
||||
[% ELSIF ( op == 'save') %]
|
||||
<input type='hidden' name='area' value='[% area | html %]' />
|
||||
<input type='hidden' name='phase' value='Save Report' />
|
||||
<input type='hidden' name='op' value='cud-save' />
|
||||
<button type="submit" name="save_anyway" value="Save anyway" class="approve"><i class="fa fa-fw fa-check"></i> Save anyway</button>
|
||||
[% END %]
|
||||
</form>
|
||||
<!-- Go back to editing -->
|
||||
<form method="get" action='/cgi-bin/koha/reports/guided_reports.pl'>
|
||||
<button type="button" class="new goback"><i class="fa-fw fa-solid fa-pencil" aria-hidden="true"></i> Edit SQL</button>
|
||||
</form>
|
||||
<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>
|
||||
</div>
|
||||
[% END # /IF ( warn_authval_problem )%]
|
||||
|
||||
[% IF ( enter_params ) %]
|
||||
<form method="get" action='/cgi-bin/koha/reports/guided_reports.pl'>
|
||||
<input type='hidden' name='reports' value="[% reports | html %]" />
|
||||
[% IF ( auth_val_error ) %]
|
||||
<input type='hidden' name='phase' value='Edit SQL' />
|
||||
<div class="dialog alert">
|
||||
<h3>Errors found when processing parameters for report: [% name | html %]</h3>
|
||||
[% FOREACH auth_val_error IN auth_val_errors %]
|
||||
<p>
|
||||
<strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
|
||||
you selected does not exist.
|
||||
</p>
|
||||
[% END %]
|
||||
</div>
|
||||
<fieldset class="action"><input type="submit" class="btn btn-primary" value="Edit SQL" /></fieldset>
|
||||
[% ELSE # IF ( auth_val_error ) %]
|
||||
<input type='hidden' name='phase' value='Run this report' />
|
||||
[% IF ( auth_val_error ) %]
|
||||
<div class="dialog alert">
|
||||
<h3>Errors found when processing parameters for report: [% name | html %]</h3>
|
||||
[% FOREACH auth_val_error IN auth_val_errors %]
|
||||
<p>
|
||||
<strong>[% auth_val_error.entry | html %]:</strong> The authorized value category (<strong>[% auth_val_error.auth_val | html %]</strong>)
|
||||
you selected does not exist.
|
||||
</p>
|
||||
[% END %]
|
||||
</div>
|
||||
<fieldset class="action">
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=edit_formid=[% id | uri %]" class="btn btn-primary">Edit SQL</a>
|
||||
</fieldset>
|
||||
[% ELSE # IF ( auth_val_error ) %]
|
||||
<form method="post" action='/cgi-bin/koha/reports/guided_reports.pl'>
|
||||
<input type='hidden' name='id' value="[% id | html %]" />
|
||||
<input type='hidden' name='op' value='cud-run' />
|
||||
<h1>Enter parameters for report [% name | html %]:</h1>
|
||||
[% IF ( notes ) %]
|
||||
<p>[% notes | html %]</p>
|
||||
|
@ -907,10 +891,11 @@
|
|||
</ol>
|
||||
</fieldset> <!-- /.rows -->
|
||||
<fieldset class="action">
|
||||
<input type="submit" class="btn btn-primary" value="Run the report" />
|
||||
<input type="hidden" name="op" value="cud-run" />
|
||||
<button type="submit" class="btn btn-primary">Run the report</button>
|
||||
</fieldset>
|
||||
[% END # / IF ( auth_val_error ) %]
|
||||
</form>
|
||||
</form>
|
||||
[% END # / IF ( auth_val_error ) %]
|
||||
[% END # /IF ( enter_params ) %]
|
||||
|
||||
[% IF processed_notice %]
|
||||
|
@ -1011,9 +996,9 @@
|
|||
[% END %]
|
||||
</form>
|
||||
|
||||
<form method="POST" action="/cgi-bin/koha/tools/modborrowers.pl" id="batch_patron_modification" target="_blank">
|
||||
<form method="get" action="/cgi-bin/koha/tools/modborrowers.pl" id="batch_patron_modification" target="_blank">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-show" />
|
||||
<input type="hidden" name="op" value="show" />
|
||||
[% # Preserve the whitespace of the following textarea in order to format the values correctly %]
|
||||
<textarea style="display:none" name="cardnumberlist" id="cardnumberlist">
|
||||
[%- cardnumbers = PROCESS batch_list results=results batch_type='cardnumber' | trim | html %][% IF cardnumbers %][% SET batch_cardnumbers = 1 %][% cardnumbers | html %][% END -%]
|
||||
|
@ -1041,9 +1026,9 @@
|
|||
[%- END -%]
|
||||
[% END %]
|
||||
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect">
|
||||
<input type="hidden" name="phase" value="Run this report"/>
|
||||
<input type="hidden" name="reports" value="[% report_id | html %]"/>
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="post" id="limitselect">
|
||||
<input type="hidden" name="op" value="cud-run"/>
|
||||
<input type="hidden" name="reports" value="[% id | html %]"/>
|
||||
[% FOREACH p IN sql_params %]
|
||||
<input type="hidden" name="sql_params" value="[% p | html %]"/>
|
||||
[% END %]
|
||||
|
@ -1309,9 +1294,9 @@
|
|||
</fieldset>
|
||||
|
||||
<fieldset class="action">
|
||||
<input type="hidden" name="phase" value="Save Report" />
|
||||
<input type="hidden" name="op" value="cud-save" />
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="Save report" />
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=list" class="cancel">Cancel</a>
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
|
@ -1422,9 +1407,9 @@
|
|||
</fieldset>
|
||||
|
||||
<fieldset class="action">
|
||||
<button class="btn btn-primary" type="submit" name="phase" value="update_sql">Update SQL</button>
|
||||
<button class="btn btn-default" type="submit" name="phase" value="update_and_run_sql">Update and run SQL</button>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
|
||||
<button class="btn btn-primary" type="submit" name="op" value="cud-update_sql">Update SQL</button>
|
||||
<button class="btn btn-default" type="submit" name="op" value="cud-update_and_run_sql">Update and run SQL</button>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=list" class="cancel">Cancel</a>
|
||||
</fieldset>
|
||||
</form>
|
||||
[% END # /IF ( editsql ) %]
|
||||
|
@ -1452,7 +1437,7 @@
|
|||
[% END %]
|
||||
</div>
|
||||
<fieldset class="action">
|
||||
<input type="hidden" name="phase" value="Use saved" />
|
||||
<input type="hidden" name="op" value="list" />
|
||||
<input type="submit" name="submit" class="btn btn-primary" value="Saved reports" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
@ -1466,7 +1451,7 @@
|
|||
[% IF ( saved1 ) %]
|
||||
<div id="saved-reports-filter">
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
|
||||
<input type="hidden" name="phase" value="Use saved" />
|
||||
<input type="hidden" name="op" value="list" />
|
||||
<input type="hidden" name="filter_set" value="1" />
|
||||
<fieldset class="brief">
|
||||
<h3>Filter</h3>
|
||||
|
@ -1488,7 +1473,7 @@
|
|||
</fieldset> <!-- /.brief -->
|
||||
<fieldset class="action">
|
||||
<input type="submit" class="btn btn-primary" value="Apply filter" />
|
||||
<a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&clear_filters=1">Clear</a>
|
||||
<a id="resetReportsFilter" href="/cgi-bin/koha/reports/guided_reports.pl?op=list&clear_filters=1">Clear</a>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div> <!-- /#saved-reports-filter -->
|
||||
|
@ -1997,7 +1982,7 @@
|
|||
});
|
||||
|
||||
$("#reports_form").submit(function(){
|
||||
var checkedItems = $("input[name=ids]:checked");
|
||||
var checkedItems = $("input[name=id]:checked");
|
||||
if ($(checkedItems).size() == 0) {
|
||||
alert(_("You must select one or more reports to delete"));
|
||||
return false;
|
||||
|
@ -2023,7 +2008,7 @@
|
|||
$("#col1 .show_sql,#col2 .show_sql").html(diffs);
|
||||
});
|
||||
$('#update_sql').modal('show');
|
||||
$("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?phase=Use saved&op=convert&report_id=" + report_id);
|
||||
$("#update_sql_button").attr("href", "/cgi-bin/koha/reports/guided_reports.pl?op=convert&id=" + report_id);
|
||||
});
|
||||
|
||||
$("#update_sql").on("hidden.bs.modal", function(){
|
||||
|
@ -2060,16 +2045,6 @@
|
|||
$("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
|
||||
});
|
||||
|
||||
$("#table_reports").delegate(".confirmdelete", 'click', function(){
|
||||
$(this).parents('tr').attr("class","warn");
|
||||
if(confirm(_("Are you sure you want to delete this saved report?"))){
|
||||
return true;
|
||||
} else {
|
||||
$(this).parents('tr').attr("class","");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
[% IF (create || editsql || save) %]
|
||||
|
||||
var validated_form = $("#sql_report_form").validate({
|
||||
|
@ -2212,8 +2187,11 @@
|
|||
|
||||
[% END %]
|
||||
|
||||
$(".delete").on("click",function(){
|
||||
return confirmDelete(MSG_CONFIRM_DELETE);
|
||||
$(".delete").on("click",function(e){
|
||||
e.preventDefault();
|
||||
if ( confirmDelete(MSG_CONFIRM_DELETE) ) {
|
||||
return $(this).siblings('form').submit();
|
||||
}
|
||||
});
|
||||
|
||||
$("#mana_search_form").submit(function(e){
|
||||
|
@ -2266,7 +2244,6 @@
|
|||
$("#limit").val( limit );
|
||||
$("#limitselect").submit();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$("#toggle_auto_links").on("click", function(e){
|
||||
|
@ -2341,7 +2318,7 @@
|
|||
alert( result.errmsg );
|
||||
}
|
||||
else{
|
||||
window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&phase=Show%20SQL&mana_success=1");
|
||||
window.location = ("/cgi-bin/koha/reports/guided_reports.pl?id=").concat(result.id).concat("&op=show&mana_success=1");
|
||||
}
|
||||
})
|
||||
.fail(function( error ) {
|
||||
|
@ -2430,11 +2407,16 @@
|
|||
<div class="modal-body"><textarea id="code' + reportid + '">' + message + '</textarea>\
|
||||
</div>\
|
||||
<div class="modal-footer">\
|
||||
<a id="preview-modal-editreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Edit%20SQL"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + _("Edit") + '</a>\
|
||||
<a id="preview-modal-duplicate" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from existing&report_id=' + reportid + '"><i class="fa fa-copy"></i> ' + _("Duplicate") + '</a>\
|
||||
<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>\
|
||||
<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>\
|
||||
<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>\
|
||||
<a id="preview-modal-delete" class="delete btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Delete%20Saved"><i class="fa fa-trash-can"></i> ' + _("Delete") + '</a>\
|
||||
<a id="preview-modal-runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Run%20this%20report"><i class="fa fa-play"></i> ' + _("Run report") + '</a>\
|
||||
<form method="post" action="/cgi-bin/koha/reports/guided_reports.pl">\
|
||||
[% INCLUDE 'csrf-token.inc' | collapse %]\
|
||||
<input type="hidden" name="op" value="cud-delete" />\
|
||||
<input type="hidden" name="id" value="' + reportid + '" />\
|
||||
</form>\
|
||||
<a id="preview-modal-delete"href="#" class="btn btn-default" title="Delete this saved report"><i class="fa fa-trash-can"></i> ' + _("Delete") + '</a>\
|
||||
<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>\
|
||||
<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>\
|
||||
</div>\
|
||||
</div>\
|
||||
|
@ -2448,6 +2430,13 @@
|
|||
lineWrapping: true,
|
||||
readOnly: true
|
||||
});
|
||||
$("#preview-modal-delete").on("click",function(e){
|
||||
e.preventDefault();
|
||||
if ( confirmDelete(MSG_CONFIRM_DELETE) ) {
|
||||
return $(this).siblings('form').submit();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
@ -30,25 +30,27 @@
|
|||
<div class="col-xs-6">
|
||||
|
||||
[% IF ( CAN_user_reports_execute_reports || CAN_user_reports_create_reports ) %]
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
|
||||
<fieldset class="brief">
|
||||
<h2>Guided reports</h2>
|
||||
<input name="phase" value="Use saved" type="hidden">
|
||||
<input name="filter_set" value="1" type="hidden">
|
||||
[% IF ( CAN_user_reports_create_reports ) %]
|
||||
<p>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new"><i class="fa-solid fa-code-branch"></i> Create guided report</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form"><i class="fa-solid fa-code-branch"></i> Create guided report</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL"><i class="fa fa-plus"></i> Create from SQL</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=add_form_sql"><i class="fa fa-plus"></i> Create from SQL</a>
|
||||
</p>
|
||||
[% END %]
|
||||
<p>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved"><i class="fa fa-list"></i> Use saved</a>
|
||||
<a href="/cgi-bin/koha/reports/guided_reports.pl?op=list"><i class="fa fa-list"></i> Use saved</a>
|
||||
</p>
|
||||
<label for="filter_keyword">Search by keyword:</label> <input id="filter_keyword" name="filter_keyword" value="" size="16" type="text" /> <input type="submit" class="btn btn-primary" value="Search" />
|
||||
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
|
||||
<input name="op" value="list" type="hidden">
|
||||
<input name="filter_set" value="1" type="hidden">
|
||||
<label for="filter_keyword">Search by keyword:</label>
|
||||
<input id="filter_keyword" name="filter_keyword" value="" size="16" type="text" />
|
||||
<input type="submit" class="btn btn-primary" value="Search" />
|
||||
</form>
|
||||
</fieldset>
|
||||
</form>
|
||||
[% END %]
|
||||
|
||||
<h5>Reports dictionary</h5>
|
||||
|
|
|
@ -54,16 +54,16 @@ Script to control the guided report creation
|
|||
my $input = CGI->new;
|
||||
my $usecache = Koha::Caches->get_instance->memcached_cache;
|
||||
|
||||
my $phase = $input->param('phase') // '';
|
||||
my $op = $input->param('op') // '';
|
||||
my $flagsrequired;
|
||||
if ( ( $phase eq 'Build new' ) || ( $phase eq 'Create report from SQL' ) || ( $phase eq 'Edit SQL' )
|
||||
|| ( $phase eq 'Build new from existing' ) ) {
|
||||
if ( ( $op eq 'add_form' ) || ( $op eq 'add_form_sql' ) || ( $op eq 'edit_form' )
|
||||
|| ( $op eq 'duplicate' ) ) {
|
||||
$flagsrequired = 'create_reports';
|
||||
}
|
||||
elsif ( $phase eq 'Use saved' ) {
|
||||
elsif ( $op eq 'list' ) {
|
||||
$flagsrequired = 'execute_reports';
|
||||
}
|
||||
elsif ( $phase eq 'Delete Saved' ) {
|
||||
elsif ( $op eq 'delete' ) {
|
||||
$flagsrequired = 'delete_reports';
|
||||
}
|
||||
else {
|
||||
|
@ -94,14 +94,12 @@ elsif ($session and not $input->param('clear_filters')) {
|
|||
$filter = $session->param('report_filter');
|
||||
}
|
||||
|
||||
my $op = $input->param('op') || q||;
|
||||
|
||||
my @errors = ();
|
||||
if ( !$phase ) {
|
||||
if ( !$op ) {
|
||||
$template->param( 'start' => 1 );
|
||||
# show welcome page
|
||||
}
|
||||
elsif ( $phase eq 'Build new' ) {
|
||||
elsif ( $op eq 'add_form' ) {
|
||||
# build a new report
|
||||
$template->param( 'build1' => 1 );
|
||||
$template->param(
|
||||
|
@ -110,74 +108,16 @@ elsif ( $phase eq 'Build new' ) {
|
|||
'cache_expiry' => 300,
|
||||
'public' => '0',
|
||||
);
|
||||
} elsif ( $phase eq 'Use saved' ) {
|
||||
|
||||
if ( $op eq 'convert' ) {
|
||||
my $report_id = $input->param('report_id');
|
||||
my $report = Koha::Reports->find($report_id);
|
||||
if ($report) {
|
||||
my $updated_sql = C4::Reports::Guided::convert_sql( $report->savedsql );
|
||||
C4::Reports::Guided::update_sql(
|
||||
$report_id,
|
||||
{
|
||||
sql => $updated_sql,
|
||||
name => $report->report_name,
|
||||
group => $report->report_group,
|
||||
subgroup => $report->report_subgroup,
|
||||
notes => $report->notes,
|
||||
public => $report->public,
|
||||
cache_expiry => $report->cache_expiry,
|
||||
}
|
||||
);
|
||||
$template->param( report_converted => $report->report_name );
|
||||
}
|
||||
}
|
||||
|
||||
# use a saved report
|
||||
# get list of reports and display them
|
||||
my $group = $input->param('group');
|
||||
my $subgroup = $input->param('subgroup');
|
||||
$filter->{group} = $group;
|
||||
$filter->{subgroup} = $subgroup;
|
||||
my $reports = get_saved_reports($filter);
|
||||
my $has_obsolete_reports;
|
||||
for my $report ( @$reports ) {
|
||||
$report->{results} = C4::Reports::Guided::get_results( $report->{id} );
|
||||
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) {
|
||||
$report->{seems_obsolete} = 1;
|
||||
$has_obsolete_reports++;
|
||||
}
|
||||
}
|
||||
$template->param(
|
||||
'manamsg' => $input->param('manamsg') || '',
|
||||
'saved1' => 1,
|
||||
'savedreports' => $reports,
|
||||
'usecache' => $usecache,
|
||||
'groups_with_subgroups' => groups_with_subgroups( $group, $subgroup ),
|
||||
filters => $filter,
|
||||
has_obsolete_reports => $has_obsolete_reports,
|
||||
);
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Delete Multiple') {
|
||||
my @ids = $input->multi_param('ids');
|
||||
elsif ( $op eq 'cud-delete') {
|
||||
my @ids = $input->multi_param('id');
|
||||
delete_report( @ids );
|
||||
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved");
|
||||
exit;
|
||||
$op = 'list';
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Delete Saved') {
|
||||
elsif ( $op eq 'show'){
|
||||
|
||||
# delete a report from the saved reports list
|
||||
my $ids = $input->param('reports');
|
||||
delete_report($ids);
|
||||
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved");
|
||||
exit;
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Show SQL'){
|
||||
|
||||
my $id = $input->param('reports');
|
||||
my $id = $input->param('id');
|
||||
my $report = Koha::Reports->find($id);
|
||||
$template->param(
|
||||
'id' => $id,
|
||||
|
@ -191,8 +131,8 @@ elsif ( $phase eq 'Show SQL'){
|
|||
);
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Edit SQL'){
|
||||
my $id = $input->param('reports');
|
||||
elsif ( $op eq 'edit_form'){
|
||||
my $id = $input->param('id');
|
||||
my $report = Koha::Reports->find($id);
|
||||
my $group = $report->report_group;
|
||||
my $subgroup = $report->report_subgroup;
|
||||
|
@ -213,7 +153,7 @@ elsif ( $phase eq 'Edit SQL'){
|
|||
);
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'update_sql' || $phase eq 'update_and_run_sql' ){
|
||||
elsif ( $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ){
|
||||
my $id = $input->param('id');
|
||||
my $sql = $input->param('sql');
|
||||
my $reportname = $input->param('reportname');
|
||||
|
@ -305,13 +245,13 @@ elsif ( $phase eq 'update_sql' || $phase eq 'update_and_run_sql' ){
|
|||
cache_expiry_units => $cache_expiry_units,
|
||||
);
|
||||
}
|
||||
if ( $phase eq 'update_and_run_sql' ) {
|
||||
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?reports=$id&phase=Run%20this%20report");
|
||||
if ( $op eq 'cud-update_and_run_sql' ) {
|
||||
$op = 'cud-run';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elsif ($phase eq 'retrieve results') {
|
||||
elsif ($op eq 'retrieve_results') {
|
||||
my $id = $input->param('id');
|
||||
my $result = format_results( $id );
|
||||
$template->param(
|
||||
|
@ -322,7 +262,7 @@ elsif ($phase eq 'retrieve results') {
|
|||
);
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Report on this Area' ) {
|
||||
elsif ( $op eq 'cud-report' ) {
|
||||
my $cache_expiry_units = $input->param('cache_expiry_units'),
|
||||
my $cache_expiry = $input->param('cache_expiry');
|
||||
|
||||
|
@ -357,7 +297,7 @@ elsif ( $phase eq 'Report on this Area' ) {
|
|||
}
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Choose this type' ) {
|
||||
elsif ( $op eq 'cud-choose_type' ) {
|
||||
# they have chosen type and area
|
||||
# get area and type and pass them to the template
|
||||
my $area = $input->param('area');
|
||||
|
@ -372,7 +312,7 @@ elsif ( $phase eq 'Choose this type' ) {
|
|||
);
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Choose these columns' ) {
|
||||
elsif ( $op eq 'cud-choose_columns' ) {
|
||||
# we now know type, area, and columns
|
||||
# next step is the constraints
|
||||
my $area = $input->param('area');
|
||||
|
@ -398,7 +338,7 @@ elsif ( $phase eq 'Choose these columns' ) {
|
|||
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Choose these criteria' ) {
|
||||
elsif ( $op eq 'cud-choose_criteria' ) {
|
||||
my $area = $input->param('area');
|
||||
my $type = $input->param('type');
|
||||
my $column = $input->param('column');
|
||||
|
@ -452,14 +392,14 @@ elsif ( $phase eq 'Choose these criteria' ) {
|
|||
foreach my $col (@columns) {
|
||||
my %total = (name => $col);
|
||||
my @selects = map {+{ value => $_ }} (qw(sum min max avg count));
|
||||
$total{'cud-select'} = \@selects;
|
||||
$total{'select'} = \@selects;
|
||||
push @total_by, \%total;
|
||||
}
|
||||
|
||||
$template->param( 'total_by' => \@total_by );
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Choose these operations' ) {
|
||||
elsif ( $op eq 'cud-choose_operations' ) {
|
||||
my $area = $input->param('area');
|
||||
my $type = $input->param('type');
|
||||
my $column = $input->param('column');
|
||||
|
@ -493,14 +433,14 @@ elsif ( $phase eq 'Choose these operations' ) {
|
|||
foreach my $col (@columns) {
|
||||
my %order = (name => $col);
|
||||
my @selects = map {+{ value => $_ }} (qw(asc desc));
|
||||
$order{'cud-select'} = \@selects;
|
||||
$order{'select'} = \@selects;
|
||||
push @order_by, \%order;
|
||||
}
|
||||
|
||||
$template->param( 'order_by' => \@order_by );
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Build report' ) {
|
||||
elsif ( $op eq 'cud-build_report' ) {
|
||||
|
||||
# now we have all the info we need and can build the sql
|
||||
my $area = $input->param('area');
|
||||
|
@ -538,13 +478,13 @@ elsif ( $phase eq 'Build report' ) {
|
|||
);
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Save' ) {
|
||||
elsif ( $op eq 'save' ) {
|
||||
# Save the report that has just been built
|
||||
my $area = $input->param('area');
|
||||
my $sql = $input->param('sql');
|
||||
my $type = $input->param('type');
|
||||
$template->param(
|
||||
'cud-save' => 1,
|
||||
'save' => 1,
|
||||
'area' => $area,
|
||||
'sql' => $sql,
|
||||
'type' => $type,
|
||||
|
@ -554,7 +494,7 @@ elsif ( $phase eq 'Save' ) {
|
|||
);
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Save Report' ) {
|
||||
elsif ( $op eq 'cud-save' ) {
|
||||
# save the sql pasted in by a user
|
||||
my $area = $input->param('area');
|
||||
my $group = $input->param('group');
|
||||
|
@ -658,21 +598,169 @@ elsif ( $phase eq 'Save Report' ) {
|
|||
}
|
||||
}
|
||||
|
||||
elsif ($phase eq 'Share'){
|
||||
elsif ($op eq 'share'){
|
||||
my $lang = $input->param('mana_language') || '';
|
||||
my $reportid = $input->param('reportid');
|
||||
my $result = Koha::SharedContent::send_entity($lang, $borrowernumber, $reportid, 'report');
|
||||
if ( $result ) {
|
||||
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=".$result->{msg});
|
||||
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?op=listmanamsg=".$result->{msg});
|
||||
}else{
|
||||
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=noanswer");
|
||||
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?op=list&manamsg=noanswer");
|
||||
}
|
||||
}
|
||||
elsif ($phase eq 'Run this report'){
|
||||
|
||||
elsif ($op eq 'export'){
|
||||
|
||||
# export results to tab separated text or CSV
|
||||
my $report_id = $input->param('id');
|
||||
my $report = Koha::Reports->find($report_id);
|
||||
my $sql = $report->savedsql;
|
||||
my @param_names = $input->multi_param('param_name');
|
||||
my @sql_params = $input->multi_param('sql_params');
|
||||
my $format = $input->param('format');
|
||||
my $reportname = $input->param('reportname');
|
||||
my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ;
|
||||
|
||||
($sql, undef) = $report->prep_report( \@param_names, \@sql_params );
|
||||
my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } );
|
||||
unless ($q_errors and @$q_errors) {
|
||||
my ( $type, $content );
|
||||
if ($format eq 'tab') {
|
||||
$type = 'application/octet-stream';
|
||||
$content .= join("\t", header_cell_values($sth)) . "\n";
|
||||
$content = Encode::decode('UTF-8', $content);
|
||||
while (my $row = $sth->fetchrow_arrayref()) {
|
||||
$content .= join("\t", map { $_ // '' } @$row) . "\n";
|
||||
}
|
||||
} else {
|
||||
if ( $format eq 'csv' ) {
|
||||
my $delimiter = C4::Context->csv_delimiter;
|
||||
$type = 'application/csv';
|
||||
my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter});
|
||||
$csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
|
||||
if ($csv->combine(header_cell_values($sth))) {
|
||||
$content .= Encode::decode('UTF-8', $csv->string()) . "\n";
|
||||
} else {
|
||||
push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ;
|
||||
}
|
||||
while (my $row = $sth->fetchrow_arrayref()) {
|
||||
if ($csv->combine(@$row)) {
|
||||
$content .= $csv->string() . "\n";
|
||||
} else {
|
||||
push @$q_errors, { combine => $csv->error_diag() } ;
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ( $format eq 'ods' ) {
|
||||
$type = 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
my $ods_fh = File::Temp->new( UNLINK => 0 );
|
||||
my $ods_filepath = $ods_fh->filename;
|
||||
my $ods_content;
|
||||
|
||||
# First line is headers
|
||||
my @headers = header_cell_values($sth);
|
||||
push @$ods_content, \@headers;
|
||||
|
||||
# Other line in Unicode
|
||||
my $sql_rows = $sth->fetchall_arrayref();
|
||||
foreach my $sql_row ( @$sql_rows ) {
|
||||
my @content_row;
|
||||
foreach my $sql_cell ( @$sql_row ) {
|
||||
push @content_row, Encode::encode( 'UTF8', $sql_cell );
|
||||
}
|
||||
push @$ods_content, \@content_row;
|
||||
}
|
||||
|
||||
# Process
|
||||
generate_ods($ods_filepath, $ods_content);
|
||||
|
||||
# Output
|
||||
binmode(STDOUT);
|
||||
open $ods_fh, '<', $ods_filepath;
|
||||
$content .= $_ while <$ods_fh>;
|
||||
unlink $ods_filepath;
|
||||
}
|
||||
elsif ( $format eq 'template' ) {
|
||||
my $template_id = $input->param('template');
|
||||
my $notice_template = Koha::Notice::Templates->find($template_id);
|
||||
my $data = $sth->fetchall_arrayref( {} );
|
||||
$content = process_tt(
|
||||
$notice_template->content,
|
||||
{
|
||||
data => $data,
|
||||
report_id => $report_id,
|
||||
for_download => 1,
|
||||
}
|
||||
);
|
||||
$reportfilename = process_tt(
|
||||
$notice_template->title,
|
||||
{
|
||||
data => $data,
|
||||
report_id => $report_id,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
print $input->header(
|
||||
-type => $type,
|
||||
-attachment=> $reportfilename
|
||||
);
|
||||
print $content;
|
||||
|
||||
foreach my $err (@$q_errors, @errors) {
|
||||
print "# ERROR: " . (map {$_ . ": " . $err->{$_}} keys %$err) . "\n";
|
||||
} # here we print all the non-fatal errors at the end. Not super smooth, but better than nothing.
|
||||
exit;
|
||||
}
|
||||
$template->param(
|
||||
'sql' => $sql,
|
||||
'execute' => 1,
|
||||
'name' => 'Error exporting report!',
|
||||
'notes' => '',
|
||||
'errors' => $q_errors,
|
||||
);
|
||||
}
|
||||
|
||||
elsif ( $op eq 'add_form_sql' || $op eq 'duplicate' ) {
|
||||
|
||||
my ($group, $subgroup, $sql, $reportname, $notes);
|
||||
if ( $input->param('sql') ) {
|
||||
$group = $input->param('report_group');
|
||||
$subgroup = $input->param('report_subgroup');
|
||||
$sql = $input->param('sql') // '';
|
||||
$reportname = $input->param('reportname') // '';
|
||||
$notes = $input->param('notes') // '';
|
||||
}
|
||||
elsif ( my $report_id = $input->param('id') ) {
|
||||
my $report = Koha::Reports->find($report_id);
|
||||
$group = $report->report_group;
|
||||
$subgroup = $report->report_subgroup;
|
||||
$sql = $report->savedsql // '';
|
||||
$reportname = $report->report_name // '';
|
||||
$notes = $report->notes // '';
|
||||
}
|
||||
|
||||
my $tables = get_tables();
|
||||
|
||||
$template->param(
|
||||
sql => $sql,
|
||||
reportname => $reportname,
|
||||
notes => $notes,
|
||||
'create' => 1,
|
||||
'groups_with_subgroups' => groups_with_subgroups($group, $subgroup),
|
||||
'public' => '0',
|
||||
'cache_expiry' => 300,
|
||||
'usecache' => $usecache,
|
||||
'tables' => $tables,
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
if ($op eq 'cud-run'){
|
||||
# execute a saved report
|
||||
my $limit = $input->param('limit') || 20;
|
||||
my $offset = 0;
|
||||
my $report_id = $input->param('reports');
|
||||
my $report_id = $input->param('id');
|
||||
my @sql_params = $input->multi_param('sql_params');
|
||||
my @param_names = $input->multi_param('param_name');
|
||||
my $template_id = $input->param('template');
|
||||
|
@ -685,8 +773,8 @@ elsif ($phase eq 'Run this report'){
|
|||
}
|
||||
|
||||
$template->param(
|
||||
'limit' => $limit,
|
||||
'report_id' => $report_id,
|
||||
'limit' => $limit,
|
||||
'id' => $report_id,
|
||||
);
|
||||
|
||||
my ( $sql, $original_sql, $type, $name, $notes );
|
||||
|
@ -837,7 +925,7 @@ elsif ($phase eq 'Run this report'){
|
|||
'sql_params' => \@tmpl_parameters,
|
||||
'auth_val_errors' => \@authval_errors,
|
||||
'enter_params' => 1,
|
||||
'reports' => $report_id,
|
||||
'id' => $report_id,
|
||||
);
|
||||
} else {
|
||||
my ($sql,$header_types) = $report->prep_report( \@param_names, \@sql_params );
|
||||
|
@ -870,7 +958,7 @@ elsif ($phase eq 'Run this report'){
|
|||
}
|
||||
|
||||
my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
|
||||
my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&phase=Run%20this%20report&limit=$limit&want_full_chart=$want_full_chart";
|
||||
my $url = "/cgi-bin/koha/reports/guided_reports.pl?id=$report_id&op=run&limit=$limit&want_full_chart=$want_full_chart";
|
||||
if (@param_names) {
|
||||
$url = join('&param_name=', $url, map { URI::Escape::uri_escape_utf8($_) } @param_names);
|
||||
}
|
||||
|
@ -918,153 +1006,54 @@ elsif ($phase eq 'Run this report'){
|
|||
}
|
||||
}
|
||||
|
||||
elsif ($phase eq 'Export'){
|
||||
if ( $op eq 'list' || $op eq 'convert') {
|
||||
|
||||
# export results to tab separated text or CSV
|
||||
my $report_id = $input->param('report_id');
|
||||
my $report = Koha::Reports->find($report_id);
|
||||
my $sql = $report->savedsql;
|
||||
my @param_names = $input->multi_param('param_name');
|
||||
my @sql_params = $input->multi_param('sql_params');
|
||||
my $format = $input->param('format');
|
||||
my $reportname = $input->param('reportname');
|
||||
my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ;
|
||||
|
||||
($sql, undef) = $report->prep_report( \@param_names, \@sql_params );
|
||||
my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } );
|
||||
unless ($q_errors and @$q_errors) {
|
||||
my ( $type, $content );
|
||||
if ($format eq 'tab') {
|
||||
$type = 'application/octet-stream';
|
||||
$content .= join("\t", header_cell_values($sth)) . "\n";
|
||||
$content = Encode::decode('UTF-8', $content);
|
||||
while (my $row = $sth->fetchrow_arrayref()) {
|
||||
$content .= join("\t", map { $_ // '' } @$row) . "\n";
|
||||
}
|
||||
} else {
|
||||
if ( $format eq 'csv' ) {
|
||||
my $delimiter = C4::Context->csv_delimiter;
|
||||
$type = 'application/csv';
|
||||
my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter});
|
||||
$csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
|
||||
if ($csv->combine(header_cell_values($sth))) {
|
||||
$content .= Encode::decode('UTF-8', $csv->string()) . "\n";
|
||||
} else {
|
||||
push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ;
|
||||
if ( $op eq 'convert' ) {
|
||||
my $report_id = $input->param('id');
|
||||
my $report = Koha::Reports->find($report_id);
|
||||
if ($report) {
|
||||
my $updated_sql = C4::Reports::Guided::convert_sql( $report->savedsql );
|
||||
C4::Reports::Guided::update_sql(
|
||||
$report_id,
|
||||
{
|
||||
sql => $updated_sql,
|
||||
name => $report->report_name,
|
||||
group => $report->report_group,
|
||||
subgroup => $report->report_subgroup,
|
||||
notes => $report->notes,
|
||||
public => $report->public,
|
||||
cache_expiry => $report->cache_expiry,
|
||||
}
|
||||
while (my $row = $sth->fetchrow_arrayref()) {
|
||||
if ($csv->combine(@$row)) {
|
||||
$content .= $csv->string() . "\n";
|
||||
} else {
|
||||
push @$q_errors, { combine => $csv->error_diag() } ;
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ( $format eq 'ods' ) {
|
||||
$type = 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
my $ods_fh = File::Temp->new( UNLINK => 0 );
|
||||
my $ods_filepath = $ods_fh->filename;
|
||||
my $ods_content;
|
||||
|
||||
# First line is headers
|
||||
my @headers = header_cell_values($sth);
|
||||
push @$ods_content, \@headers;
|
||||
|
||||
# Other line in Unicode
|
||||
my $sql_rows = $sth->fetchall_arrayref();
|
||||
foreach my $sql_row ( @$sql_rows ) {
|
||||
my @content_row;
|
||||
foreach my $sql_cell ( @$sql_row ) {
|
||||
push @content_row, Encode::encode( 'UTF8', $sql_cell );
|
||||
}
|
||||
push @$ods_content, \@content_row;
|
||||
}
|
||||
|
||||
# Process
|
||||
generate_ods($ods_filepath, $ods_content);
|
||||
|
||||
# Output
|
||||
binmode(STDOUT);
|
||||
open $ods_fh, '<', $ods_filepath;
|
||||
$content .= $_ while <$ods_fh>;
|
||||
unlink $ods_filepath;
|
||||
}
|
||||
elsif ( $format eq 'template' ) {
|
||||
my $template_id = $input->param('template');
|
||||
my $notice_template = Koha::Notice::Templates->find($template_id);
|
||||
my $data = $sth->fetchall_arrayref( {} );
|
||||
$content = process_tt(
|
||||
$notice_template->content,
|
||||
{
|
||||
data => $data,
|
||||
report_id => $report_id,
|
||||
for_download => 1,
|
||||
}
|
||||
);
|
||||
$reportfilename = process_tt(
|
||||
$notice_template->title,
|
||||
{
|
||||
data => $data,
|
||||
report_id => $report_id,
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
$template->param( report_converted => $report->report_name );
|
||||
}
|
||||
print $input->header(
|
||||
-type => $type,
|
||||
-attachment=> $reportfilename
|
||||
);
|
||||
print $content;
|
||||
}
|
||||
|
||||
foreach my $err (@$q_errors, @errors) {
|
||||
print "# ERROR: " . (map {$_ . ": " . $err->{$_}} keys %$err) . "\n";
|
||||
} # here we print all the non-fatal errors at the end. Not super smooth, but better than nothing.
|
||||
exit;
|
||||
# use a saved report
|
||||
# get list of reports and display them
|
||||
my $group = $input->param('group');
|
||||
my $subgroup = $input->param('subgroup');
|
||||
$filter->{group} = $group;
|
||||
$filter->{subgroup} = $subgroup;
|
||||
my $reports = get_saved_reports($filter);
|
||||
my $has_obsolete_reports;
|
||||
for my $report ( @$reports ) {
|
||||
$report->{results} = C4::Reports::Guided::get_results( $report->{id} );
|
||||
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) {
|
||||
$report->{seems_obsolete} = 1;
|
||||
$has_obsolete_reports++;
|
||||
}
|
||||
}
|
||||
$template->param(
|
||||
'sql' => $sql,
|
||||
'execute' => 1,
|
||||
'name' => 'Error exporting report!',
|
||||
'notes' => '',
|
||||
'errors' => $q_errors,
|
||||
'manamsg' => $input->param('manamsg') || '',
|
||||
'saved1' => 1,
|
||||
'savedreports' => $reports,
|
||||
'usecache' => $usecache,
|
||||
'groups_with_subgroups' => groups_with_subgroups( $group, $subgroup ),
|
||||
filters => $filter,
|
||||
has_obsolete_reports => $has_obsolete_reports,
|
||||
);
|
||||
}
|
||||
|
||||
elsif ( $phase eq 'Create report from SQL' || $phase eq 'Create report from existing' ) {
|
||||
|
||||
my ($group, $subgroup, $sql, $reportname, $notes);
|
||||
if ( $input->param('sql') ) {
|
||||
$group = $input->param('report_group');
|
||||
$subgroup = $input->param('report_subgroup');
|
||||
$sql = $input->param('sql') // '';
|
||||
$reportname = $input->param('reportname') // '';
|
||||
$notes = $input->param('notes') // '';
|
||||
}
|
||||
elsif ( my $report_id = $input->param('report_id') ) {
|
||||
my $report = Koha::Reports->find($report_id);
|
||||
$group = $report->report_group;
|
||||
$subgroup = $report->report_subgroup;
|
||||
$sql = $report->savedsql // '';
|
||||
$reportname = $report->report_name // '';
|
||||
$notes = $report->notes // '';
|
||||
}
|
||||
|
||||
my $tables = get_tables();
|
||||
|
||||
$template->param(
|
||||
sql => $sql,
|
||||
reportname => $reportname,
|
||||
notes => $notes,
|
||||
'create' => 1,
|
||||
'groups_with_subgroups' => groups_with_subgroups($group, $subgroup),
|
||||
'public' => '0',
|
||||
'cache_expiry' => 300,
|
||||
'usecache' => $usecache,
|
||||
'tables' => $tables,
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
# pass $sth, get back an array of names for the column headers
|
||||
sub header_cell_values {
|
||||
my $sth = shift or return ();
|
||||
|
|
|
@ -26,7 +26,7 @@ use C4::Output qw( output_html_with_http_headers );
|
|||
use CGI qw ( -utf8 );
|
||||
|
||||
my $query = CGI->new();
|
||||
my $report_id = $query->param('report_id');
|
||||
my $report_id = $query->param('id');
|
||||
|
||||
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue