Head & rel_2_2 merged
[wip/koha-chris_n.git] / acqui / supplier.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to show display basket of orders
6 #written by chris@katipo.co.nz 24/2/2000
7
8
9 # Copyright 2000-2002 Katipo Communications
10 #
11 # This file is part of Koha.
12 #
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
16 # version.
17 #
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA  02111-1307 USA
25
26 use C4::Auth;
27 use C4::Acquisition;
28 use C4::Biblio;
29 use C4::Output;
30 use CGI;
31 use C4::Interface::CGI::Output;
32 use C4::Database;
33 use HTML::Template;
34 use strict;
35
36 my $query=new CGI;
37 my $id=$query->param('supplierid');
38 my $op=$query->param('op');
39
40 my ($count,@booksellers)=bookseller($id);
41 my ($template, $loggedinuser, $cookie)
42     = get_template_and_user({template_name => "acqui/supplier.tmpl",
43                              query => $query,
44                              type => "intranet",
45                              authnotrequired => 0,
46                              flagsrequired => {acquisition => 1},
47                              debug => 1,
48                              });
49 #build array for currencies
50 my  ($count, $currencies) = &getcurrencies();
51 my @loop_pricescurrency;
52 my @loop_invoicecurrency;
53 for (my $i=0;$i<$count;$i++) {
54         if ($booksellers[0]->{'listprice'} eq $currencies->[$i]->{'currency'}) {
55                 push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies->[$i]->{'currency'}\">$currencies->[$i]->{'currency'}</option>" };
56         } else {
57                 push @loop_pricescurrency, { currency => "<option value=\"$currencies->[$i]->{'currency'}\">$currencies->[$i]->{'currency'}</option>"};
58         }
59         if ($booksellers[0]->{'invoiceprice'} eq $currencies->[$i]->{'currency'}) {
60                 push @loop_invoicecurrency, { currency => "<option selected=\"selected\" value=\"$currencies->[$i]->{'currency'}\">$currencies->[$i]->{'currency'}</option>"};
61         } else {
62                 push @loop_invoicecurrency, { currency => "<option value=\"$currencies->[$i]->{'currency'}\">$currencies->[$i]->{'currency'}</option>"};
63         }
64 }
65 $template->param(id => $id,
66                                         name => $booksellers[0]->{'name'},
67                                         postal =>$booksellers[0]->{'postal'},
68                                         address1 => $booksellers[0]->{'address1'},
69                                         address2 => $booksellers[0]->{'address2'},
70                                         address3 => $booksellers[0]->{'address3'},
71                                         address4 => $booksellers[0]->{'address4'},
72                                         phone =>$booksellers[0]->{'phone'},
73                                         fax => $booksellers[0]->{'fax'},
74                                         url => $booksellers[0]->{'url'},
75                                         contact => $booksellers[0]->{'contact'},
76                                         contpos => $booksellers[0]->{'contpos'},
77                                         contphone => $booksellers[0]->{'contphone'},
78                                         contaltphone => $booksellers[0]->{'contaltphone'},
79                                         contfax => $booksellers[0]->{'contfax'},
80                                         contemail => $booksellers[0]->{'contemail'},
81                                         contnotes => $booksellers[0]->{'contnotes'},
82                                         notes => $booksellers[0]->{'notes'},
83                                         active => $booksellers[0]->{'active'},
84                                         specialty => $booksellers[0]->{'specialty'},
85                                         gstreg => $booksellers[0]->{'gstreg'},
86                                         listincgst => $booksellers[0]->{'listincgst'},
87                                         invoiceincgst => $booksellers[0]->{'invoiceincgst'},
88                                         discount => $booksellers[0]->{'discount'},
89                                         invoiceprice=>$booksellers[0]->{'invoiceprice'},
90                                         listprice=>$booksellers[0]->{'listprice'},
91                                         intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
92                                         intranetstylesheet => C4::Context->preference("intranetstylesheet"),
93                                         IntranetNav => C4::Context->preference("IntranetNav"),
94                                         );
95 }else{
96         my  ($count, $currencies) = &getcurrencies();
97         my @loop_pricescurrency;
98         my @loop_invoicecurrency;
99         for (my $i=0;$i<$count;$i++) {
100                 if ($booksellers[0]->{'listprice'} eq $currencies->[$i]->{'currency'}) {
101                         push @loop_pricescurrency, { currency => "<option selected value=\"$currencies->[$i]->{'currency'}\">$currencies->[$i]->{'currency'}</option>" };
102                 } else {
103                         push @loop_pricescurrency, { currency => "<option value=\"$currencies->[$i]->{'currency'}\">$currencies->[$i]->{'currency'}</option>"};
104                 }
105                 if ($booksellers[0]->{'invoiceprice'} eq $currencies->[$i]->{'currency'}) {
106                         push @loop_invoicecurrency, { currency => "<option selected value=\"$currencies->[$i]->{'currency'}\">$currencies->[$i]->{'currency'}</option>"};
107                 } else {
108                         push @loop_invoicecurrency, { currency => "<option value=\"$currencies->[$i]->{'currency'}\">$currencies->[$i]->{'currency'}</option>"};
109                 }
110         }
111         $template->param(id => $id,
112                                                 name => $booksellers[0]->{'name'},
113                                                 postal =>$booksellers[0]->{'postal'},
114                                                 address1 => $booksellers[0]->{'address1'},
115                                                 address2 => $booksellers[0]->{'address2'},
116                                                 address3 => $booksellers[0]->{'address3'},
117                                                 address4 => $booksellers[0]->{'address4'},
118                                                 phone =>$booksellers[0]->{'phone'},
119                                                 fax => $booksellers[0]->{'fax'},
120                                                 url => $booksellers[0]->{'url'},
121                                                 contact => $booksellers[0]->{'contact'},
122                                                 contpos => $booksellers[0]->{'contpos'},
123                                                 contphone => $booksellers[0]->{'contphone'},
124                                                 contaltphone => $booksellers[0]->{'contaltphone'},
125                                                 contfax => $booksellers[0]->{'contfax'},
126                                                 contemail => $booksellers[0]->{'contemail'},
127                                                 notes => $booksellers[0]->{'notes'},
128                                                 contnotes => $booksellers[0]->{'contnotes'},
129                                                 active => $booksellers[0]->{'active'},
130                                                 specialty => $booksellers[0]->{'specialty'},
131                                                 gstreg => $booksellers[0]->{'gstreg'},
132                                                 listincgst => $booksellers[0]->{'listincgst'},
133                                                 invoiceincgst => $booksellers[0]->{'invoiceincgst'},
134                                                 discount => $booksellers[0]->{'discount'},
135                                                 loop_pricescurrency => \@loop_pricescurrency,
136                                                 loop_invoicecurrency => \@loop_invoicecurrency,
137                                                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
138                         intranetstylesheet => C4::Context->preference("intranetstylesheet"),
139                         IntranetNav => C4::Context->preference("IntranetNav"),
140                         enter=>1,
141                                                 );
142 }
143 output_html_with_http_headers $query, $cookie, $template->output;