Existing sql
+[% current_sql %]+
Updated sql
+[% updated_sql %]+ [% ELSE %] + Something went wrong. + [% END %] +
@@ -, +, @@ - 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 - Click on update link - Click on the update button --- C4/Reports/Guided.pm | 21 +++++++- .../prog/en/modules/reports/convert_report.tt | 19 ++++++++ .../en/modules/reports/guided_reports_start.tt | 44 +++++++++++++++++ reports/guided_reports.pl | 30 ++++++++++++ svc/convert_report | 53 ++++++++++++++++++++ t/db_dependent/Reports/Guided.t | 57 +++++++++++++++++++++- 6 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/reports/convert_report.tt create mode 100755 svc/convert_report --- a/C4/Reports/Guided.pm +++ a/C4/Reports/Guided.pm @@ -854,7 +854,6 @@ sub get_sql { sub get_results { my ( $report_id ) = @_; my $dbh = C4::Context->dbh; - warn $report_id; return $dbh->selectall_arrayref(q| SELECT id, report, date_run FROM saved_reports @@ -988,6 +987,26 @@ sub _get_display_value { return $original_value; } + +=head3 convert_sql + +my $updated_sql = C4::Reports::Guided::convert_sql( $sql ); + +Convert a sql query using biblioitems.marcxml to use the new +biblio_metadata.metadata field instead + +=cut + +sub convert_sql { + my ( $sql ) = @_; + my $updated_sql = $sql; + if ( $sql =~ m|biblioitems| and $sql =~ m|marcxml| ) { + $updated_sql =~ s|biblioitems|biblio_metadata|; + $updated_sql =~ s|marcxml|metadata|; + } + return $updated_sql; +} + 1; __END__ --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/convert_report.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/convert_report.tt @@ -0,0 +1,19 @@ +[% INCLUDE 'doc-head-open.inc' %] +
[% current_sql %]+
[% updated_sql %]+ [% ELSE %] + Something went wrong. + [% END %] +