fixed minor bugs
[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 use CGI;
8 use C4::Acquisitions;
9
10 my $input=new CGI;
11
12 my $type=$input->param('type');
13 #find out what the script is being called for
14 #print $input->header();
15 if ($type ne 'change'){
16   #display, we must fetch the exchange rate data and output it
17   print $input->header();
18   print <<printend
19   <TABLE width="40%" cellspacing=0 cellpadding=5 border=1 >
20   <FORM ACTION="/cgi-bin/koha/currency.pl">
21   <input type=hidden name=type value=change>
22   <TR VALIGN=TOP>
23   <TD  bgcolor="99cc33" background="/images/background-mem.gif" colspan=2 ><b>EXCHANGE RATES </b></TD></TR>
24   <TR VALIGN=TOP>                                                                 
25   <TD>
26 printend
27 ;
28   my ($count,$rates)=getcurrencies();
29   for (my $i=0;$i<$count;$i++){
30     if ($rates->[$i]->{'currency'} ne 'NZD'){
31       print "$rates->[$i]->{'currency'}<INPUT TYPE=\"text\"  SIZE=\"5\"   NAME=\"$rates->[$i]->{'currency'}\" value=$rates->[$i]->{'rate'}>";
32     }
33 #    print $rates->[$i]->{'currency'};
34   }
35   print <<printend
36     <p>                                                                             
37   <input type=image  name=submit src=/images/save-changes.gif border=0 width=187 height=42>
38   
39   </TD></TR>                                                                      
40   </form>                                                                         
41   </table>                                                
42 printend
43 ;
44 } else {
45 #  print $input->Dump;
46   my @params=$input->param;
47   foreach my $param (@params){
48     if ($param ne 'type' && $param !~ /submit/){
49       my $data=$input->param($param);
50       updatecurrencies($param,$data);
51     }
52   }
53   print $input->redirect('/acquisitions/');
54 }