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 <david@davidnind.com>
Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-03-15 10:12:41 +01:00 committed by Katrin Fischer
parent 45305fe2cb
commit 2998254f1c
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
6 changed files with 103 additions and 142 deletions

View file

@ -52,7 +52,7 @@
<ul>
<li><a href="/cgi-bin/koha/reports/itemslost.pl">Lost items</a></li>
<li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
<li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by item type</a></li>
<li><a href="/cgi-bin/koha/reports/catalog_by_itemtype.pl">Catalog by item type</a></li>
<li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
</ul>
</div>

View file

@ -27,7 +27,7 @@
[% END %]
[% IF ( do_it ) %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by item type</a>
<a href="/cgi-bin/koha/reports/catalog_by_itemtype.pl">Catalog by item type</a>
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Results</span>
@ -75,7 +75,7 @@
[% END %]
[% ELSE %]
<h1>View a count of items held at your library grouped by item type</h1>
<form method="get" action="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">
<form method="get" action="/cgi-bin/koha/reports/catalog_by_itemtype.pl">
<fieldset class="rows">
<ol>
<li>

View file

@ -94,7 +94,7 @@
<ul>
<li><a href="/cgi-bin/koha/reports/itemslost.pl">Items lost</a></li>
<li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
<li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by item type</a></li>
<li><a href="/cgi-bin/koha/reports/catalog_by_itemtype.pl">Catalog by item type</a></li>
<li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
[% SET koha_version = Koha.Version %]
[% IF koha_version.development %]

99
reports/catalog_by_itemtype.pl Executable file
View file

@ -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 <http://www.gnu.org/licenses>.
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;

View file

@ -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 <http://www.gnu.org/licenses>.
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;

View file

@ -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 <http://www.gnu.org/licenses>.
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;