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.
44 #use warnings; FIXME - Bug 2505
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 $GST = $booksellers[0]->{'gstrate'} || C4::Context->preference("gist");
73 my @contracts = GetContracts($id);
74 my $contractcount = scalar(@contracts);
75 $template->param(hascontracts => 1) if ($contractcount > 0);
77 #build array for currencies
78 if ($op eq "display") {
81 my @contracts = @{GetContract( { booksellerid => $id } )};
85 $$_{contractstartdate} = format_date($$_{contractstartdate});
86 $$_{contractenddate} = format_date($$_{contractenddate});
91 name => $booksellers[0]->{'name'},
92 postal => $booksellers[0]->{'postal'},
93 address1 => $booksellers[0]->{'address1'},
94 address2 => $booksellers[0]->{'address2'},
95 address3 => $booksellers[0]->{'address3'},
96 address4 => $booksellers[0]->{'address4'},
97 phone => $booksellers[0]->{'phone'},
98 fax => $booksellers[0]->{'fax'},
99 url => $booksellers[0]->{'url'},
100 contact => $booksellers[0]->{'contact'},
101 contpos => $booksellers[0]->{'contpos'},
102 contphone => $booksellers[0]->{'contphone'},
103 contaltphone => $booksellers[0]->{'contaltphone'},
104 contfax => $booksellers[0]->{'contfax'},
105 contemail => $booksellers[0]->{'contemail'},
106 contnotes => $booksellers[0]->{'contnotes'},
107 notes => $booksellers[0]->{'notes'},
108 active => $booksellers[0]->{'active'},
109 gstreg => $booksellers[0]->{'gstreg'},
110 listincgst => $booksellers[0]->{'listincgst'},
111 invoiceincgst => $booksellers[0]->{'invoiceincgst'},
112 gstrate => $booksellers[0]->{'gstrate'}*100,
113 discount => $booksellers[0]->{'discount'},
114 invoiceprice => $booksellers[0]->{'invoiceprice'},
115 listprice => $booksellers[0]->{'listprice'},
117 basketcount => $booksellers[0]->{'basketcount'},
118 contracts => \@contracts
121 elsif ($op eq 'delete') {
123 print $query->redirect("/cgi-bin/koha/acqui/acqui-home.pl");
126 my @currencies = GetCurrencies();
127 my $count = scalar @currencies;
129 my @loop_pricescurrency;
130 my @loop_invoicecurrency;
131 for (my $i=0;$i<$count;$i++) {
132 if ($booksellers[0]->{'listprice'} eq $currencies[$i]->{'currency'}) {
133 push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>" };
135 push @loop_pricescurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
137 if ($booksellers[0]->{'invoiceprice'} eq $currencies[$i]->{'currency'}) {
138 push @loop_invoicecurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
140 push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"};
143 my $GST = $booksellers[0]->{'gstrate'} || C4::Context->preference("gist");
147 name => $booksellers[0]->{'name'},
148 postal => $booksellers[0]->{'postal'},
149 address1 => $booksellers[0]->{'address1'},
150 address2 => $booksellers[0]->{'address2'},
151 address3 => $booksellers[0]->{'address3'},
152 address4 => $booksellers[0]->{'address4'},
153 phone => $booksellers[0]->{'phone'},
154 fax => $booksellers[0]->{'fax'},
155 url => $booksellers[0]->{'url'},
156 contact => $booksellers[0]->{'contact'},
157 contpos => $booksellers[0]->{'contpos'},
158 contphone => $booksellers[0]->{'contphone'},
159 contaltphone => $booksellers[0]->{'contaltphone'},
160 contfax => $booksellers[0]->{'contfax'},
161 contemail => $booksellers[0]->{'contemail'},
162 contnotes => $booksellers[0]->{'contnotes'},
163 notes => $booksellers[0]->{'notes'},
164 active => $id?$booksellers[0]->{'active'}:1, # set active ON by default for supplier add (id empty for add)
165 gstreg => $booksellers[0]->{'gstreg'},
166 listincgst => $booksellers[0]->{'listincgst'},
167 invoiceincgst => $booksellers[0]->{'invoiceincgst'},
168 gstrate => $booksellers[0]->{'gstrate'}*100,
169 discount => $booksellers[0]->{'discount'},
170 loop_pricescurrency => \@loop_pricescurrency,
171 loop_invoicecurrency => \@loop_invoicecurrency,
179 output_html_with_http_headers $query, $cookie, $template->output;