bugfix : bibliotitems.dewey & deletedbiblioitems.dewey mustn't be double(8,6).
[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
51
52 use C4::Bookseller;
53 use C4::Bookfund;
54
55 my $query=new CGI;
56 my $id=$query->param('supplierid');
57 my @booksellers = GetBookSeller($id) if $id;
58 my $count = scalar @booksellers;
59 my $op=$query->param('op') || "display";
60
61 my ($template, $loggedinuser, $cookie)
62     = get_template_and_user({template_name => "acqui/supplier.tmpl",
63                              query => $query,
64                              type => "intranet",
65                              authnotrequired => 0,
66                              flagsrequired => {acquisition => 1},
67                              debug => 1,
68                 });
69
70 #build array for currencies
71 if ($op eq "display"){
72     $template->param(id => $id,
73                     name => $booksellers[0]->{'name'},
74                     postal =>$booksellers[0]->{'postal'},
75                     address1 => $booksellers[0]->{'address1'},
76                     address2 => $booksellers[0]->{'address2'},
77                     address3 => $booksellers[0]->{'address3'},
78                     address4 => $booksellers[0]->{'address4'},
79                     phone =>$booksellers[0]->{'phone'},
80                     fax => $booksellers[0]->{'fax'},
81                     url => $booksellers[0]->{'url'},
82                     contact => $booksellers[0]->{'contact'},
83                     contpos => $booksellers[0]->{'contpos'},
84                     contphone => $booksellers[0]->{'contphone'},
85                     contaltphone => $booksellers[0]->{'contaltphone'},
86                     contfax => $booksellers[0]->{'contfax'},
87                     contemail => $booksellers[0]->{'contemail'},
88                     contnotes => $booksellers[0]->{'contnotes'},
89                     notes => $booksellers[0]->{'notes'},
90                     active => $booksellers[0]->{'active'},
91                     specialty => $booksellers[0]->{'specialty'},
92                     gstreg => $booksellers[0]->{'gstreg'},
93                     listincgst => $booksellers[0]->{'listincgst'},
94                     invoiceincgst => $booksellers[0]->{'invoiceincgst'},
95                     discount => $booksellers[0]->{'discount'},
96                     invoiceprice=>$booksellers[0]->{'invoiceprice'},
97                     listprice=>$booksellers[0]->{'listprice'},
98                     GST => C4::Context->preference("gist"),
99                     );
100 }else{
101     my @currencies = GetCurrencies();
102     my $count = scalar @currencies;
103     
104     my @loop_pricescurrency;
105     my @loop_invoicecurrency;
106     for (my $i=0;$i<$count;$i++) {
107         if ($booksellers[0]->{'listprice'} eq $currencies[$i]->{'currency'}) {
108             push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>" };
109         } else {
110             push @loop_pricescurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
111         }
112         if ($booksellers[0]->{'invoiceprice'} eq $currencies[$i]->{'currency'}) {
113             push @loop_invoicecurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
114         } else {
115             push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
116         }
117     }
118     $template->param(id => $id,
119                     name => $booksellers[0]->{'name'},
120                     postal =>$booksellers[0]->{'postal'},
121                     address1 => $booksellers[0]->{'address1'},
122                     address2 => $booksellers[0]->{'address2'},
123                     address3 => $booksellers[0]->{'address3'},
124                     address4 => $booksellers[0]->{'address4'},
125                     phone =>$booksellers[0]->{'phone'},
126                     fax => $booksellers[0]->{'fax'},
127                     url => $booksellers[0]->{'url'},
128                     contact => $booksellers[0]->{'contact'},
129                     contpos => $booksellers[0]->{'contpos'},
130                     contphone => $booksellers[0]->{'contphone'},
131                     contaltphone => $booksellers[0]->{'contaltphone'},
132                     contfax => $booksellers[0]->{'contfax'},
133                     contemail => $booksellers[0]->{'contemail'},
134                     contnotes => $booksellers[0]->{'contnotes'},
135                     notes => $booksellers[0]->{'notes'},
136                     active => $booksellers[0]->{'active'},
137                     specialty => $booksellers[0]->{'specialty'},
138                     gstreg => $booksellers[0]->{'gstreg'},
139                     listincgst => $booksellers[0]->{'listincgst'},
140                     invoiceincgst => $booksellers[0]->{'invoiceincgst'},
141                     discount => $booksellers[0]->{'discount'},
142                     loop_pricescurrency => \@loop_pricescurrency,
143                     loop_invoicecurrency => \@loop_invoicecurrency,
144                     GST => C4::Context->preference("gist"),
145                     enter=>1,
146                     );
147 }
148 output_html_with_http_headers $query, $cookie, $template->output;