Bug Fixing :
[koha.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 # 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 =head1 NAME
26
27 supplier.pl
28
29 =head1 DESCRIPTION
30 this script shows the details for a bookseller given on input arg.
31 It allows to edit & save information about this bookseller.
32
33 =head1 CGI PARAMETERS
34
35 =over 4
36
37 =item supplierid
38 To know the bookseller this script has to display details.
39
40 =back
41
42 =cut
43
44 use strict;
45 use C4::Auth;
46 use C4::Acquisition;
47 use C4::Biblio;
48 use C4::Output;
49 use CGI;
50 use C4::Interface::CGI::Output;
51
52
53 use C4::Bookseller;
54 use C4::Bookfund;
55
56 my $query=new CGI;
57 my $id=$query->param('supplierid');
58 my @booksellers = GetBookSeller($id) if $id;
59 my $count = scalar @booksellers;
60 my $op=$query->param('op') || "display";
61
62 my ($template, $loggedinuser, $cookie)
63     = get_template_and_user({template_name => "acqui/supplier.tmpl",
64                              query => $query,
65                              type => "intranet",
66                              authnotrequired => 0,
67                              flagsrequired => {acquisition => 1},
68                              debug => 1,
69                 });
70
71 #build array for currencies
72 if ($op eq "display"){
73     $template->param(id => $id,
74                     name => $booksellers[0]->{'name'},
75                     postal =>$booksellers[0]->{'postal'},
76                     address1 => $booksellers[0]->{'address1'},
77                     address2 => $booksellers[0]->{'address2'},
78                     address3 => $booksellers[0]->{'address3'},
79                     address4 => $booksellers[0]->{'address4'},
80                     phone =>$booksellers[0]->{'phone'},
81                     fax => $booksellers[0]->{'fax'},
82                     url => $booksellers[0]->{'url'},
83                     contact => $booksellers[0]->{'contact'},
84                     contpos => $booksellers[0]->{'contpos'},
85                     contphone => $booksellers[0]->{'contphone'},
86                     contaltphone => $booksellers[0]->{'contaltphone'},
87                     contfax => $booksellers[0]->{'contfax'},
88                     contemail => $booksellers[0]->{'contemail'},
89                     contnotes => $booksellers[0]->{'contnotes'},
90                     notes => $booksellers[0]->{'notes'},
91                     active => $booksellers[0]->{'active'},
92                     specialty => $booksellers[0]->{'specialty'},
93                     gstreg => $booksellers[0]->{'gstreg'},
94                     listincgst => $booksellers[0]->{'listincgst'},
95                     invoiceincgst => $booksellers[0]->{'invoiceincgst'},
96                     discount => $booksellers[0]->{'discount'},
97                     invoiceprice=>$booksellers[0]->{'invoiceprice'},
98                     listprice=>$booksellers[0]->{'listprice'},
99                     GST => C4::Context->preference("gist"),
100                     );
101 }else{
102     my @currencies = GetCurrencies();
103     my $count = scalar @currencies;
104     
105     my @loop_pricescurrency;
106     my @loop_invoicecurrency;
107     for (my $i=0;$i<$count;$i++) {
108         if ($booksellers[0]->{'listprice'} eq $currencies[$i]->{'currency'}) {
109             push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>" };
110         } else {
111             push @loop_pricescurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
112         }
113         if ($booksellers[0]->{'invoiceprice'} eq $currencies[$i]->{'currency'}) {
114             push @loop_invoicecurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
115         } else {
116             push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
117         }
118     }
119     $template->param(id => $id,
120                     name => $booksellers[0]->{'name'},
121                     postal =>$booksellers[0]->{'postal'},
122                     address1 => $booksellers[0]->{'address1'},
123                     address2 => $booksellers[0]->{'address2'},
124                     address3 => $booksellers[0]->{'address3'},
125                     address4 => $booksellers[0]->{'address4'},
126                     phone =>$booksellers[0]->{'phone'},
127                     fax => $booksellers[0]->{'fax'},
128                     url => $booksellers[0]->{'url'},
129                     contact => $booksellers[0]->{'contact'},
130                     contpos => $booksellers[0]->{'contpos'},
131                     contphone => $booksellers[0]->{'contphone'},
132                     contaltphone => $booksellers[0]->{'contaltphone'},
133                     contfax => $booksellers[0]->{'contfax'},
134                     contemail => $booksellers[0]->{'contemail'},
135                     contnotes => $booksellers[0]->{'contnotes'},
136                     notes => $booksellers[0]->{'notes'},
137                     active => $booksellers[0]->{'active'},
138                     specialty => $booksellers[0]->{'specialty'},
139                     gstreg => $booksellers[0]->{'gstreg'},
140                     listincgst => $booksellers[0]->{'listincgst'},
141                     invoiceincgst => $booksellers[0]->{'invoiceincgst'},
142                     discount => $booksellers[0]->{'discount'},
143                     loop_pricescurrency => \@loop_pricescurrency,
144                     loop_invoicecurrency => \@loop_invoicecurrency,
145                     GST => C4::Context->preference("gist"),
146                     enter=>1,
147                     );
148 }
149 output_html_with_http_headers $query, $cookie, $template->output;