Koha/svc/convert_report
Jonathan Druart f22d2e7200 Bug 17898: Automagically convert SQL reports
Bug 17196 move the marcxml out of the biblioitems table.
That will break SQL reports using it.
It would be handy to propose an automagically way to convert the SQL
reports.

We do not want to update the reports automatically without user inputs,
it will be too hasardous.
However we can lead the user to convert them.

In this patchset I suggest to warn the user if a report is subject to be
updated.

TODO: Add a way to mark this job done (using a pref?) to remove the
check and not to display false positives.

Test plan:
- Create some SQL reports (see https://wiki.koha-community.org/wiki/SQL_Reports_Library)
- Go on the report list page (/reports/guided_reports.pl?phase=Use saved)
- For the reports using biblioitems.marcxml you will see a new column
warning you that it is obsolete
- Click on update link
=> that will open a modal with the converted SQL query
- Click on the update button
=> you will be informed that the query has been updated

If all the reports are updated, the new column "Update" will no longer
be displayed.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-05-19 18:48:26 +00:00

53 lines
1.5 KiB
Perl
Executable file

#!/usr/bin/perl
# This file is part of Koha.
#
# Copyright 2017 Koha Development Team
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Auth;
use C4::Reports::Guided;
use C4::Output;
use CGI qw ( -utf8 );
my $query = CGI->new();
my $report_id = $query->param('report_id');
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "reports/convert_report.tt",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { reports => 'execute_reports' },
}
);
my $report = get_saved_report( $report_id );
my $params;
if ( $report ) {
my $sql = $report->{savedsql};
my $updated_sql = C4::Reports::Guided::convert_sql( $sql );
$params = { msg => 'can_be_updated', updated_sql => $updated_sql, current_sql => $sql };
} else {
$params = { msg => 'no_report' };
}
$template->param( %$params );
output_html_with_http_headers $query, $cookie, $template->output;