fix "Add Tag" button in MARC framework editor
[koha.git] / serials / acqui-search.pl
blob7461a8a13934dc3f8dcdac6ed0864a206f35046a
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
21 use strict;
22 use CGI;
23 use C4::Auth;
24 use C4::Output;
25 use C4::Bookfund;
27 my $query = new CGI;
29 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31 template_name => "serials/acqui-search.tmpl",
32 query => $query,
33 type => "intranet",
34 authnotrequired => 0,
35 flagsrequired => { serials => 1 },
36 debug => 1,
40 # budget
41 my $dbh = C4::Context->dbh;
42 my $sthtemp =
43 $dbh->prepare(
44 "Select flags, branchcode from borrowers where borrowernumber = ?");
45 $sthtemp->execute($loggedinuser);
46 my ( $flags, $homebranch ) = $sthtemp->fetchrow;
47 my @results = GetBookFunds($homebranch);
48 my $count = scalar(@results);
50 my $classlist = '';
51 my $total = 0;
52 my $totspent = 0;
53 my $totcomtd = 0;
54 my $totavail = 0;
55 my @loop_budget = ();
56 for ( my $i = 0 ; $i < $count ; $i++ ) {
57 my ( $spent, $comtd ) =
58 GetBookFundBreakdown( $results[$i]->{'bookfundid'} );
59 my $avail = $results[$i]->{'budgetamount'} - ( $spent + $comtd );
60 my %line;
61 $line{bookfundname} = $results[$i]->{'bookfundname'};
62 $line{budgetamount} = $results[$i]->{'budgetamount'};
63 $line{spent} = sprintf( "%.2f", $spent );
64 $line{comtd} = sprintf( "%.2f", $comtd );
65 $line{avail} = sprintf( "%.2f", $avail );
66 push @loop_budget, \%line;
67 $total += $results[$i]->{'budgetamount'};
68 $totspent += $spent;
69 $totcomtd += $comtd;
70 $totavail += $avail;
73 #currencies
74 my @rates = GetCurrencies();
75 $count = scalar @rates;
77 my @loop_currency = ();
78 for ( my $i = 0 ; $i < $count ; $i++ ) {
79 my %line;
80 $line{currency} = $rates[$i]->{'currency'};
81 $line{rate} = $rates[$i]->{'rate'};
82 push @loop_currency, \%line;
84 $template->param(
85 classlist => $classlist,
86 type => 'intranet',
87 loop_budget => \@loop_budget,
88 loop_currency => \@loop_currency,
89 total => sprintf( "%.2f", $total ),
90 totspent => sprintf( "%.2f", $totspent ),
91 totcomtd => sprintf( "%.2f", $totcomtd ),
92 totavail => sprintf( "%.2f", $totavail )
95 output_html_with_http_headers $query, $cookie, $template->output;