Removed the dependency on Set::Scalar.
[koha.git] / currency.pl
1 #!/usr/bin/perl
2
3 #written by chris@katipo.co.nz
4 #9/10/2000
5 #script to display and update currency rates
6
7
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA  02111-1307 USA
24
25 use CGI;
26 use C4::Acquisitions;
27 use C4::Biblio;
28
29 my $input=new CGI;
30
31 my $type=$input->param('type');
32 #find out what the script is being called for
33 #print $input->header();
34 if ($type ne 'change'){
35   #display, we must fetch the exchange rate data and output it
36   print $input->header();
37   print <<printend
38   <TABLE width="40%" cellspacing=0 cellpadding=5 border=1 >
39   <FORM ACTION="/cgi-bin/koha/currency.pl">
40   <input type=hidden name=type value=change>
41   <TR VALIGN=TOP>
42   <TD  bgcolor="99cc33" background="/images/background-mem.gif" colspan=2 ><b>EXCHANGE RATES </b></TD></TR>
43   <TR VALIGN=TOP>                                                                 
44   <TD>
45 printend
46 ;
47   my ($count,$rates)=getcurrencies();
48   for (my $i=0;$i<$count;$i++){
49     if ($rates->[$i]->{'currency'} ne 'NZD'){
50       print "$rates->[$i]->{'currency'}<INPUT TYPE=\"text\"  SIZE=\"5\"   NAME=\"$rates->[$i]->{'currency'}\" value=$rates->[$i]->{'rate'}>";
51     }
52 #    print $rates->[$i]->{'currency'};
53   }
54   print <<printend
55     <p>                                                                             
56   <input type=image  name=submit src=/images/save-changes.gif border=0 width=187 height=42>
57   
58   </TD></TR>                                                                      
59   </form>                                                                         
60   </table>                                                
61 printend
62 ;
63 } else {
64 #  print $input->Dump;
65   my @params=$input->param;
66   foreach my $param (@params){
67     if ($param ne 'type' && $param !~ /submit/){
68       my $data=$input->param($param);
69       updatecurrencies($param,$data);
70     }
71   }
72   print $input->redirect('/acquisitions/');
73 }