bug 3765: move road type after address
[koha.git] / acqui / supplier.pl
blobb8afe0d48dcb8c0058c90e294394d37c5a4fc7f4
1 #!/usr/bin/perl
4 #script to show display basket of orders
6 # Copyright 2000-2002 Katipo Communications
7 # Copyright 2008-2009 BibLibre SARL
9 # This file is part of Koha.
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.
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.
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
24 =head1 NAME
26 supplier.pl
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.
32 =head1 CGI PARAMETERS
34 =over 4
36 =item supplierid
37 To know the bookseller this script has to display details.
39 =back
41 =cut
43 use strict;
44 use C4::Auth;
45 use C4::Acquisition;
46 use C4::Biblio;
47 use C4::Output;
48 use CGI;
50 use C4::Bookseller;
51 use C4::Budgets;
53 my $query = new CGI;
54 my $id = $query->param('supplierid');
55 my @booksellers = GetBookSellerFromId($id) if $id;
56 my $count = scalar @booksellers;
57 my $op = $query->param('op') || "display";
58 my ($template, $loggedinuser, $cookie) = get_template_and_user(
59 { template_name => "acqui/supplier.tmpl",
60 query => $query,
61 type => "intranet",
62 authnotrequired => 0,
63 flagsrequired => { acquisition => 'vendors_manage' },
64 debug => 1,
67 my $GST = $booksellers[0]->{'gstrate'} || C4::Context->preference("gist");
68 $GST *= 100;
69 #build array for currencies
70 if ($op eq "display") {
71 $template->param(
72 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 gstreg => $booksellers[0]->{'gstreg'},
92 listincgst => $booksellers[0]->{'listincgst'},
93 invoiceincgst => $booksellers[0]->{'invoiceincgst'},
94 gstrate => $booksellers[0]->{'gstrate'}*100,
95 discount => $booksellers[0]->{'discount'},
96 invoiceprice => $booksellers[0]->{'invoiceprice'},
97 listprice => $booksellers[0]->{'listprice'},
98 GST => $GST,
99 basketcount => $booksellers[0]->{'basketcount'},
102 elsif ($op eq 'delete') {
103 &DelBookseller($id);
104 print $query->redirect("/cgi-bin/koha/acqui/acqui-home.pl");
105 exit;
106 } else {
107 my @currencies = GetCurrencies();
108 my $count = scalar @currencies;
110 my @loop_pricescurrency;
111 my @loop_invoicecurrency;
112 for (my $i=0;$i<$count;$i++) {
113 if ($booksellers[0]->{'listprice'} eq $currencies[$i]->{'currency'}) {
114 push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>" };
115 } else {
116 push @loop_pricescurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
118 if ($booksellers[0]->{'invoiceprice'} eq $currencies[$i]->{'currency'}) {
119 push @loop_invoicecurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
120 } else {
121 push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
124 my $GST = $booksellers[0]->{'gstrate'} || C4::Context->preference("gist");
125 $GST *= 100;
126 $template->param(
127 id => $id,
128 name => $booksellers[0]->{'name'},
129 postal => $booksellers[0]->{'postal'},
130 address1 => $booksellers[0]->{'address1'},
131 address2 => $booksellers[0]->{'address2'},
132 address3 => $booksellers[0]->{'address3'},
133 address4 => $booksellers[0]->{'address4'},
134 phone => $booksellers[0]->{'phone'},
135 fax => $booksellers[0]->{'fax'},
136 url => $booksellers[0]->{'url'},
137 contact => $booksellers[0]->{'contact'},
138 contpos => $booksellers[0]->{'contpos'},
139 contphone => $booksellers[0]->{'contphone'},
140 contaltphone => $booksellers[0]->{'contaltphone'},
141 contfax => $booksellers[0]->{'contfax'},
142 contemail => $booksellers[0]->{'contemail'},
143 contnotes => $booksellers[0]->{'contnotes'},
144 notes => $booksellers[0]->{'notes'},
145 active => $id?$booksellers[0]->{'active'}:1, # set active ON by default for supplier add (id empty for add)
146 gstreg => $booksellers[0]->{'gstreg'},
147 listincgst => $booksellers[0]->{'listincgst'},
148 invoiceincgst => $booksellers[0]->{'invoiceincgst'},
149 gstrate => $booksellers[0]->{'gstrate'}*100,
150 discount => $booksellers[0]->{'discount'},
151 loop_pricescurrency => \@loop_pricescurrency,
152 loop_invoicecurrency => \@loop_invoicecurrency,
153 GST => $GST,
154 enter => 1,
160 output_html_with_http_headers $query, $cookie, $template->output;