altering template path
[koha.git] / serials / acqui-search.pl
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 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.
11 #
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.
15 #
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
19
20 # $Id$
21
22 use strict;
23 use CGI;
24 use C4::Auth;
25 use C4::Output;
26 use C4::Interface::CGI::Output;
27 use C4::Database;
28 use HTML::Template;
29 use C4::Acquisition;
30 my $query = new CGI;
31 my ($template, $loggedinuser, $cookie)
32     = get_template_and_user({template_name => "serials/acqui-search.tmpl",
33                              query => $query,
34                              type => "intranet",
35                              authnotrequired => 0,
36                              flagsrequired => {acquisition => 1},
37                              debug => 1,
38                              });
39
40 # FIXME : Is this page still used ????
41 # looks like no.
42
43 # budget
44 my $dbh = C4::Context->dbh;
45 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
46 $sthtemp->execute($loggedinuser);
47 my ($flags, $homebranch)=$sthtemp->fetchrow;
48 my ($count,@results)=bookfunds($homebranch);
49 my $classlist='';
50 my $total=0;
51 my $totspent=0;
52 my $totcomtd=0;
53 my $totavail=0;
54 my @loop_budget = ();
55 for (my $i=0;$i<$count;$i++){
56         my ($spent,$comtd)=bookfundbreakdown($results[$i]->{'bookfundid'});
57         my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
58         my %line;
59         $line{bookfundname} = $results[$i]->{'bookfundname'};
60         $line{budgetamount} = $results[$i]->{'budgetamount'};
61         $line{spent} = sprintf  ("%.2f", $spent);
62         $line{comtd} = sprintf  ("%.2f",$comtd);
63         $line{avail}  = sprintf  ("%.2f",$avail);
64         push @loop_budget, \%line;
65         $total+=$results[$i]->{'budgetamount'};
66         $totspent+=$spent;
67         $totcomtd+=$comtd;
68         $totavail+=$avail;
69 }
70 #currencies
71 my ($count,$rates)=getcurrencies();
72 my @loop_currency = ();
73 for (my $i=0;$i<$count;$i++){
74         my %line;
75         $line{currency} = $rates->[$i]->{'currency'};
76         $line{rate} = $rates->[$i]->{'rate'};
77         push @loop_currency, \%line;
78 }
79 $template->param(classlist => $classlist,
80                                                 type => 'intranet',
81                                                 loop_budget => \@loop_budget,
82                                                 loop_currency => \@loop_currency,
83                                                 total => sprintf("%.2f",$total),
84                                                 totspent => sprintf("%.2f",$totspent),
85                                                 totcomtd => sprintf("%.2f",$totcomtd),
86                                                 totavail => sprintf("%.2f",$totavail));
87
88 output_html_with_http_headers $query, $cookie, $template->output;