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