From de0e532da78e1b516d1608c23edb37098e3d8b30 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 15 Mar 2024 10:12:41 +0100 Subject: [PATCH] Bug 31988: Remove reports/itemtypes.plugin This "plugin system" is only used for the itemtypes report. We can simply remove the reports/manager.pl script and this plugin in favor of a dedicated report. Test plan: Same behaviour expected before and after this patch Signed-off-by: David Nind Signed-off-by: Andrew Fuerste Henry Signed-off-by: Martin Renvoize (cherry picked from commit 499fe0bea7d995358bd45da2bea7058d803f2b4e) Signed-off-by: Fridolin Somers --- .../prog/en/includes/reports-menu.inc | 2 +- .../prog/en/modules/reports/itemtypes.tt | 4 +- .../prog/en/modules/reports/reports-home.tt | 2 +- reports/catalog_by_itemtype.pl | 99 +++++++++++++++++++ reports/itemtypes.plugin | 85 ---------------- reports/manager.pl | 53 ---------- 6 files changed, 103 insertions(+), 142 deletions(-) create mode 100755 reports/catalog_by_itemtype.pl delete mode 100755 reports/itemtypes.plugin delete mode 100755 reports/manager.pl diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc index 3727737311..212313086a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc @@ -52,7 +52,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt index f8e8396c6c..fe36c08e2e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt @@ -27,7 +27,7 @@ [% END %] [% IF ( do_it ) %] [% WRAPPER breadcrumb_item %] - Catalog by item type + Catalog by item type [% END %] [% WRAPPER breadcrumb_item bc_active= 1 %] Results @@ -75,7 +75,7 @@ [% END %] [% ELSE %]

View a count of items held at your library grouped by item type

-
+
  1. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt index 8731bdb98f..ec84c11586 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt @@ -92,7 +92,7 @@
    • Items lost
    • Orders by fund
    • -
    • Catalog by item type
    • +
    • Catalog by item type
    • Average loan time
    • [% SET koha_version = Koha.Version %] [% IF koha_version.development %] diff --git a/reports/catalog_by_itemtype.pl b/reports/catalog_by_itemtype.pl new file mode 100755 index 0000000000..fcaf5f17ef --- /dev/null +++ b/reports/catalog_by_itemtype.pl @@ -0,0 +1,99 @@ +#!/usr/bin/perl + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# 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 . + +use Modern::Perl; +use C4::Auth qw( get_template_and_user ); +use CGI qw ( -utf8 ); +use C4::Context; +use C4::Output qw( output_html_with_http_headers ); + +my $input = CGI->new; +my $report_name = $input->param("report_name"); +my $do_it = $input->param('do_it'); +my $fullreportname = "reports/itemtypes.tt"; +my @values = $input->multi_param("value"); +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => $fullreportname, + query => $input, + type => "intranet", + flagsrequired => { reports => '*' }, + } +); +$template->param( + do_it => $do_it, +); +if ($do_it) { + my $results = calculate( \@values ); + $template->param( mainloop => $results ); +} +output_html_with_http_headers $input, $cookie, $template->output; + +sub calculate { + my ($parameters) = @_; + my @results = (); + my $branch = @$parameters[0]; + my $dbh = C4::Context->dbh; + my $sth; + if ( C4::Context->preference('item-level_itypes') ) { + $sth = $dbh->prepare( + q| + SELECT itemtypes.itemtype, description, COUNT(*) AS total + FROM itemtypes, items + WHERE items.itype=itemtypes.itemtype + | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q| + GROUP BY itemtypes.itemtype, description, items.itype + ORDER BY itemtypes.description + | + ); + } else { + $sth = $dbh->prepare( + q| + SELECT itemtypes.itemtype, description, COUNT(*) AS total + FROM itemtypes, biblioitems, items + WHERE biblioitems.itemtype=itemtypes.itemtype + AND items.biblioitemnumber=biblioitems.biblioitemnumber + | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q| + GROUP BY itemtypes.itemtype, description + ORDER BY itemtypes.description + | + ); + } + $sth->execute( $branch || () ); + my ( $itemtype, $description, $total ); + my $grantotal = 0; + my $count = 0; + while ( ( $itemtype, $description, $total ) = $sth->fetchrow ) { + my %line; + $line{itemtype} = $itemtype; + $line{count} = $total; + $grantotal += $total; + push @results, \%line; + $count++; + } + my @mainloop; + my %globalline; + $globalline{loopitemtype} = \@results; + $globalline{total} = $grantotal; + $globalline{branch} = $branch; + push @mainloop, \%globalline; + return \@mainloop; +} + +1; diff --git a/reports/itemtypes.plugin b/reports/itemtypes.plugin deleted file mode 100755 index ec2c535182..0000000000 --- a/reports/itemtypes.plugin +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/perl - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# 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 . - -use strict; -use C4::Auth; -use CGI qw ( -utf8 ); -use C4::Context; -use C4::Search; -use C4::Output; -use C4::Koha; -=head1 - -=cut - -sub set_parameters { - my ($template) = @_; - return $template; -} - -sub calculate { - my ($parameters) = @_; - my @results =(); - my $branch = @$parameters[0]; - my $dbh = C4::Context->dbh; - my $sth; - if ( C4::Context->preference('item-level_itypes') ) { - $sth = $dbh->prepare( q| - SELECT itemtypes.itemtype, description, COUNT(*) AS total - FROM itemtypes, items - WHERE items.itype=itemtypes.itemtype - | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q| - GROUP BY itemtypes.itemtype, description, items.itype - ORDER BY itemtypes.description - |); - } - else { - $sth = $dbh->prepare( q| - SELECT itemtypes.itemtype, description, COUNT(*) AS total - FROM itemtypes, biblioitems, items - WHERE biblioitems.itemtype=itemtypes.itemtype - AND items.biblioitemnumber=biblioitems.biblioitemnumber - | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q| - GROUP BY itemtypes.itemtype, description - ORDER BY itemtypes.description - |); - } - $sth->execute($branch || ()); - my ($itemtype, $description,$total); - my $grantotal = 0; - my $count = 0; - while (($itemtype, $description,$total) = $sth->fetchrow) { - my %line; - $line{itemtype} = $itemtype; - $line{count} = $total; - $grantotal += $total; - push @results,\%line; - $count ++; - } - my @mainloop; - my %globalline; - $globalline{loopitemtype} = \@results; - $globalline{total} = $grantotal; - $globalline{branch} = $branch; - push @mainloop,\%globalline; - return \@mainloop; -} - -1; diff --git a/reports/manager.pl b/reports/manager.pl deleted file mode 100755 index ff174f00d3..0000000000 --- a/reports/manager.pl +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# 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 . - -use Modern::Perl; -use CGI qw ( -utf8 ); -use C4::Auth qw( get_template_and_user ); -use C4::Context; -use C4::Output qw( output_html_with_http_headers ); - - -my $input = CGI->new; -my $report_name=$input->param("report_name"); -my $do_it=$input->param('do_it'); -my $fullreportname = "reports/".$report_name.".tt"; -my @values = $input->multi_param("value"); -my ($template, $borrowernumber, $cookie) - = get_template_and_user({template_name => $fullreportname, - query => $input, - type => "intranet", - flagsrequired => {reports => '*'}, - }); -$template->param(do_it => $do_it, - report_name => $report_name, - ); -my $cgidir = C4::Context->config('intranetdir')."/cgi-bin/reports/"; -unless (-r $cgidir and -d $cgidir) { - $cgidir = C4::Context->config('intranetdir')."/reports/"; -} -my $plugin = $cgidir.$report_name.".plugin"; -require $plugin; -if ($do_it) { - my $results = calculate(\@values); - $template->param(mainloop => $results); -} else { - $template = set_parameters($template); -} -output_html_with_http_headers $input, $cookie, $template->output; -- 2.39.5