View | Details | Raw Unified | Return to bug 31988
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc (-1 / +1 lines)
Lines 52-58 Link Here
52
        <ul>
52
        <ul>
53
            <li><a href="/cgi-bin/koha/reports/itemslost.pl">Lost items</a></li>
53
            <li><a href="/cgi-bin/koha/reports/itemslost.pl">Lost items</a></li>
54
            <li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
54
            <li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
55
            <li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by item type</a></li>
55
            <li><a href="/cgi-bin/koha/reports/catalog_by_itemtype.pl">Catalog by item type</a></li>
56
            <li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
56
            <li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
57
        </ul>
57
        </ul>
58
    </div>
58
    </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt (-2 / +2 lines)
Lines 27-33 Link Here
27
        [% END %]
27
        [% END %]
28
        [% IF ( do_it ) %]
28
        [% IF ( do_it ) %]
29
            [% WRAPPER breadcrumb_item %]
29
            [% WRAPPER breadcrumb_item %]
30
                <a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by item type</a>
30
                <a href="/cgi-bin/koha/reports/catalog_by_itemtype.pl">Catalog by item type</a>
31
            [% END %]
31
            [% END %]
32
            [% WRAPPER breadcrumb_item bc_active= 1 %]
32
            [% WRAPPER breadcrumb_item bc_active= 1 %]
33
                <span>Results</span>
33
                <span>Results</span>
Lines 75-81 Link Here
75
[% END %]
75
[% END %]
76
[% ELSE %]
76
[% ELSE %]
77
        <h1>View a count of items held at your library grouped by item type</h1>
77
        <h1>View a count of items held at your library grouped by item type</h1>
78
        <form method="get" action="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">
78
        <form method="get" action="/cgi-bin/koha/reports/catalog_by_itemtype.pl">
79
          <fieldset class="rows">
79
          <fieldset class="rows">
80
            <ol>
80
            <ol>
81
              <li>
81
              <li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt (-1 / +1 lines)
Lines 94-100 Link Here
94
        <ul>
94
        <ul>
95
            <li><a href="/cgi-bin/koha/reports/itemslost.pl">Items lost</a></li>
95
            <li><a href="/cgi-bin/koha/reports/itemslost.pl">Items lost</a></li>
96
            <li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
96
            <li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
97
            <li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by item type</a></li>
97
            <li><a href="/cgi-bin/koha/reports/catalog_by_itemtype.pl">Catalog by item type</a></li>
98
            <li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
98
            <li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
99
            [% SET koha_version = Koha.Version %]
99
            [% SET koha_version = Koha.Version %]
100
            [% IF koha_version.development %]
100
            [% IF koha_version.development %]
(-)a/reports/catalog_by_itemtype.pl (+99 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use C4::Auth qw( get_template_and_user );
22
use CGI qw ( -utf8 );
23
use C4::Context;
24
use C4::Output qw( output_html_with_http_headers );
25
26
my $input          = CGI->new;
27
my $report_name    = $input->param("report_name");
28
my $do_it          = $input->param('do_it');
29
my $fullreportname = "reports/itemtypes.tt";
30
my @values         = $input->multi_param("value");
31
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
32
    {
33
        template_name => $fullreportname,
34
        query         => $input,
35
        type          => "intranet",
36
        flagsrequired => { reports => '*' },
37
    }
38
);
39
$template->param(
40
    do_it => $do_it,
41
);
42
if ($do_it) {
43
    my $results = calculate( \@values );
44
    $template->param( mainloop => $results );
45
}
46
output_html_with_http_headers $input, $cookie, $template->output;
47
48
sub calculate {
49
    my ($parameters) = @_;
50
    my @results      = ();
51
    my $branch       = @$parameters[0];
52
    my $dbh          = C4::Context->dbh;
53
    my $sth;
54
    if ( C4::Context->preference('item-level_itypes') ) {
55
        $sth = $dbh->prepare(
56
            q|
57
            SELECT itemtypes.itemtype, description, COUNT(*) AS total
58
            FROM itemtypes, items
59
            WHERE items.itype=itemtypes.itemtype
60
            | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q|
61
            GROUP BY itemtypes.itemtype, description, items.itype
62
            ORDER BY itemtypes.description
63
        |
64
        );
65
    } else {
66
        $sth = $dbh->prepare(
67
            q|
68
            SELECT itemtypes.itemtype, description, COUNT(*) AS total
69
            FROM itemtypes, biblioitems, items
70
            WHERE biblioitems.itemtype=itemtypes.itemtype
71
            AND items.biblioitemnumber=biblioitems.biblioitemnumber
72
            | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q|
73
            GROUP BY itemtypes.itemtype, description
74
            ORDER BY itemtypes.description
75
        |
76
        );
77
    }
78
    $sth->execute( $branch || () );
79
    my ( $itemtype, $description, $total );
80
    my $grantotal = 0;
81
    my $count     = 0;
82
    while ( ( $itemtype, $description, $total ) = $sth->fetchrow ) {
83
        my %line;
84
        $line{itemtype} = $itemtype;
85
        $line{count}    = $total;
86
        $grantotal += $total;
87
        push @results, \%line;
88
        $count++;
89
    }
90
    my @mainloop;
91
    my %globalline;
92
    $globalline{loopitemtype} = \@results;
93
    $globalline{total}        = $grantotal;
94
    $globalline{branch}       = $branch;
95
    push @mainloop, \%globalline;
96
    return \@mainloop;
97
}
98
99
1;
(-)a/reports/itemtypes.plugin (-85 lines)
Lines 1-85 Link Here
1
#!/usr/bin/perl
2
3
4
# Copyright 2000-2002 Katipo Communications
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# Koha is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21
use strict;
22
use C4::Auth;
23
use CGI qw ( -utf8 );
24
use C4::Context;
25
use C4::Search;
26
use C4::Output;
27
use C4::Koha;
28
=head1
29
30
=cut
31
32
sub set_parameters {
33
    my ($template) = @_;
34
    return $template;
35
}
36
37
sub calculate {
38
	my ($parameters) = @_;
39
	my @results =();
40
	my $branch = @$parameters[0];
41
	my $dbh = C4::Context->dbh;
42
	my $sth;
43
    if ( C4::Context->preference('item-level_itypes') ) {
44
        $sth = $dbh->prepare( q|
45
            SELECT itemtypes.itemtype, description, COUNT(*) AS total
46
            FROM itemtypes, items
47
            WHERE items.itype=itemtypes.itemtype
48
            | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q|
49
            GROUP BY itemtypes.itemtype, description, items.itype
50
            ORDER BY itemtypes.description
51
        |);
52
    }
53
    else {
54
        $sth = $dbh->prepare( q|
55
            SELECT itemtypes.itemtype, description, COUNT(*) AS total
56
            FROM itemtypes, biblioitems, items
57
            WHERE biblioitems.itemtype=itemtypes.itemtype
58
            AND items.biblioitemnumber=biblioitems.biblioitemnumber
59
            | . ( $branch ? q| AND items.holdingbranch=? | : () ) . q|
60
            GROUP BY itemtypes.itemtype, description
61
            ORDER BY itemtypes.description
62
        |);
63
    }
64
    $sth->execute($branch || ());
65
    my ($itemtype, $description,$total);
66
	my $grantotal = 0;
67
	my $count = 0;
68
    while (($itemtype, $description,$total) = $sth->fetchrow) {
69
		my %line;
70
        $line{itemtype} = $itemtype;
71
		$line{count} = $total;
72
		$grantotal += $total;
73
		push @results,\%line;
74
		$count ++;
75
	}
76
	my @mainloop;
77
	my %globalline;
78
	$globalline{loopitemtype} = \@results;
79
	$globalline{total} = $grantotal;
80
	$globalline{branch} = $branch;
81
	push @mainloop,\%globalline;
82
	return \@mainloop;
83
}
84
85
1;
(-)a/reports/manager.pl (-54 lines)
Lines 1-53 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use CGI qw ( -utf8 );
22
use C4::Auth qw( get_template_and_user );
23
use C4::Context;
24
use C4::Output qw( output_html_with_http_headers );
25
26
27
my $input = CGI->new;
28
my $report_name=$input->param("report_name");
29
my $do_it=$input->param('do_it');
30
my $fullreportname = "reports/".$report_name.".tt";
31
my @values = $input->multi_param("value");
32
my ($template, $borrowernumber, $cookie)
33
	= get_template_and_user({template_name => $fullreportname,
34
				query => $input,
35
				type => "intranet",
36
				flagsrequired => {reports => '*'},
37
				});
38
$template->param(do_it => $do_it,
39
		report_name => $report_name,
40
		);
41
my $cgidir = C4::Context->config('intranetdir')."/cgi-bin/reports/";
42
unless (-r $cgidir and -d $cgidir) {
43
    $cgidir = C4::Context->config('intranetdir')."/reports/";
44
} 
45
my $plugin = $cgidir.$report_name.".plugin";
46
require $plugin;
47
if ($do_it) {
48
	my $results = calculate(\@values);
49
	$template->param(mainloop => $results);
50
} else {
51
	$template = set_parameters($template);
52
}
53
output_html_with_http_headers $input, $cookie, $template->output;
54
- 

Return to bug 31988