BUGFIX : due to the new template structure, the up.png button has moved
[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                     basketcount =>$booksellers[0]->{'basketcount'},
100                     );
101 } elsif ($op eq 'delete') {
102     &DelBookseller($id);
103     print $query->redirect("/cgi-bin/koha/acqui/acqui-home.pl");
104     exit;
105 } else {
106     my @currencies = GetCurrencies();
107     my $count = scalar @currencies;
108     
109     my @loop_pricescurrency;
110     my @loop_invoicecurrency;
111     for (my $i=0;$i<$count;$i++) {
112         if ($booksellers[0]->{'listprice'} eq $currencies[$i]->{'currency'}) {
113             push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>" };
114         } else {
115             push @loop_pricescurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
116         }
117         if ($booksellers[0]->{'invoiceprice'} eq $currencies[$i]->{'currency'}) {
118             push @loop_invoicecurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
119         } else {
120             push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
121         }
122     }
123     $template->param(id => $id,
124                     name => $booksellers[0]->{'name'},
125                     postal =>$booksellers[0]->{'postal'},
126                     address1 => $booksellers[0]->{'address1'},
127                     address2 => $booksellers[0]->{'address2'},
128                     address3 => $booksellers[0]->{'address3'},
129                     address4 => $booksellers[0]->{'address4'},
130                     phone =>$booksellers[0]->{'phone'},
131                     fax => $booksellers[0]->{'fax'},
132                     url => $booksellers[0]->{'url'},
133                     contact => $booksellers[0]->{'contact'},
134                     contpos => $booksellers[0]->{'contpos'},
135                     contphone => $booksellers[0]->{'contphone'},
136                     contaltphone => $booksellers[0]->{'contaltphone'},
137                     contfax => $booksellers[0]->{'contfax'},
138                     contemail => $booksellers[0]->{'contemail'},
139                     contnotes => $booksellers[0]->{'contnotes'},
140                     notes => $booksellers[0]->{'notes'},
141                     active => $booksellers[0]->{'active'},
142                     specialty => $booksellers[0]->{'specialty'},
143                     gstreg => $booksellers[0]->{'gstreg'},
144                     listincgst => $booksellers[0]->{'listincgst'},
145                     invoiceincgst => $booksellers[0]->{'invoiceincgst'},
146                     discount => $booksellers[0]->{'discount'},
147                     loop_pricescurrency => \@loop_pricescurrency,
148                     loop_invoicecurrency => \@loop_invoicecurrency,
149                     GST => C4::Context->preference("gist"),
150                     enter=>1,
151                     );
152 }
153 output_html_with_http_headers $query, $cookie, $template->output;