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
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
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 this script shows the details for a bookseller given on input arg.
30 It allows to edit & save information about this bookseller.
37 To know the bookseller this script has to display details.
50 use C4::Dates qw/format_date /;
57 my $id = $query->param('supplierid');
58 my @booksellers = GetBookSellerFromId($id) if $id;
59 my $count = scalar @booksellers;
60 my $op = $query->param('op') || "display";
61 my ($template, $loggedinuser, $cookie) = get_template_and_user(
62 { template_name => "acqui/supplier.tmpl",
66 flagsrequired => { acquisition => 'vendors_manage' },
70 my $seller_gstrate = $booksellers[0]->{'gstrate'};
71 # A perl-ism: '0'==false, '0.000'==true, but 0=='0.000' - this accounts for that
72 undef $seller_gstrate if ($seller_gstrate == 0);
73 my $GST = $seller_gstrate || C4::Context->preference("gist");
76 my @contracts = GetContracts($id);
77 my $contractcount = scalar(@contracts);
78 $template->param(hascontracts => 1) if ($contractcount > 0);
80 #build array for currencies
81 if ($op eq "display") {
84 my @contracts = @{GetContract( { booksellerid => $id } )};
88 $$_{contractstartdate} = format_date($$_{contractstartdate});
89 $$_{contractenddate} = format_date($$_{contractenddate});
94 name => $booksellers[0]->{'name'},
95 postal => $booksellers[0]->{'postal'},
96 address1 => $booksellers[0]->{'address1'},
97 address2 => $booksellers[0]->{'address2'},
98 address3 => $booksellers[0]->{'address3'},
99 address4 => $booksellers[0]->{'address4'},
100 phone => $booksellers[0]->{'phone'},
101 fax => $booksellers[0]->{'fax'},
102 url => $booksellers[0]->{'url'},
103 contact => $booksellers[0]->{'contact'},
104 contpos => $booksellers[0]->{'contpos'},
105 contphone => $booksellers[0]->{'contphone'},
106 contaltphone => $booksellers[0]->{'contaltphone'},
107 contfax => $booksellers[0]->{'contfax'},
108 contemail => $booksellers[0]->{'contemail'},
109 contnotes => $booksellers[0]->{'contnotes'},
110 notes => $booksellers[0]->{'notes'},
111 active => $booksellers[0]->{'active'},
112 gstreg => $booksellers[0]->{'gstreg'},
113 listincgst => $booksellers[0]->{'listincgst'},
114 invoiceincgst => $booksellers[0]->{'invoiceincgst'},
115 gstrate => $booksellers[0]->{'gstrate'}*100,
116 discount => $booksellers[0]->{'discount'},
117 invoiceprice => $booksellers[0]->{'invoiceprice'},
118 listprice => $booksellers[0]->{'listprice'},
120 basketcount => $booksellers[0]->{'basketcount'},
121 contracts => \@contracts
124 elsif ($op eq 'delete') {
126 print $query->redirect("/cgi-bin/koha/acqui/acqui-home.pl");
129 my @currencies = GetCurrencies();
130 my $count = scalar @currencies;
132 my @loop_pricescurrency;
133 my @loop_invoicecurrency;
134 for (my $i=0;$i<$count;$i++) {
135 if ($booksellers[0]->{'listprice'} eq $currencies[$i]->{'currency'}) {
136 push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>" };
138 push @loop_pricescurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
140 if ($booksellers[0]->{'invoiceprice'} eq $currencies[$i]->{'currency'}) {
141 push @loop_invoicecurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
143 push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
148 name => $booksellers[0]->{'name'},
149 postal => $booksellers[0]->{'postal'},
150 address1 => $booksellers[0]->{'address1'},
151 address2 => $booksellers[0]->{'address2'},
152 address3 => $booksellers[0]->{'address3'},
153 address4 => $booksellers[0]->{'address4'},
154 phone => $booksellers[0]->{'phone'},
155 fax => $booksellers[0]->{'fax'},
156 url => $booksellers[0]->{'url'},
157 contact => $booksellers[0]->{'contact'},
158 contpos => $booksellers[0]->{'contpos'},
159 contphone => $booksellers[0]->{'contphone'},
160 contaltphone => $booksellers[0]->{'contaltphone'},
161 contfax => $booksellers[0]->{'contfax'},
162 contemail => $booksellers[0]->{'contemail'},
163 contnotes => $booksellers[0]->{'contnotes'},
164 notes => $booksellers[0]->{'notes'},
165 active => $id?$booksellers[0]->{'active'}:1, # set active ON by default for supplier add (id empty for add)
166 gstreg => $booksellers[0]->{'gstreg'},
167 listincgst => $booksellers[0]->{'listincgst'},
168 invoiceincgst => $booksellers[0]->{'invoiceincgst'},
169 gstrate => $booksellers[0]->{'gstrate'}*100,
170 discount => $booksellers[0]->{'discount'},
171 loop_pricescurrency => \@loop_pricescurrency,
172 loop_invoicecurrency => \@loop_invoicecurrency,
180 output_html_with_http_headers $query, $cookie, $template->output;