3 # Copyright 2000-2002 Katipo Communications
4 # Copyright 2008-2009 BibLibre SARL
5 # Copyright 2010 PTFS Europe Ltd
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 this script shows the details for a bookseller given on input arg.
29 It allows to edit & save information about this bookseller.
37 To know the bookseller this script has to display details.
46 use C4::Contract qw/GetContract/;
49 use C4::Dates qw/format_date /;
52 use C4::Bookseller qw( GetBookSellerFromId DelBookseller );
56 my $id = $query->param('supplierid');
59 $supplier = GetBookSellerFromId($id);
61 my $op = $query->param('op') || 'display';
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
63 { template_name => 'acqui/supplier.tmpl',
67 flagsrequired => { acquisition => 'vendors_manage' },
71 my $seller_gstrate = $supplier->{'gstrate'};
73 # ensure the scalar isn't flagged as a string
74 $seller_gstrate = ( defined $seller_gstrate ) ? $seller_gstrate + 0 : undef;
75 my $tax_rate = $seller_gstrate // C4::Context->preference('gist') // 0;
77 #build array for currencies
78 if ( $op eq 'display' ) {
80 my $contracts = GetContract( { booksellerid => $id } );
82 for ( @{$contracts} ) {
83 $_->{contractstartdate} = format_date( $_->{contractstartdate} );
84 $_->{contractenddate} = format_date( $_->{contractenddate} );
89 name => $supplier->{'name'},
90 postal => $supplier->{'postal'},
91 address1 => $supplier->{'address1'},
92 address2 => $supplier->{'address2'},
93 address3 => $supplier->{'address3'},
94 address4 => $supplier->{'address4'},
95 phone => $supplier->{'phone'},
96 fax => $supplier->{'fax'},
97 url => $supplier->{'url'},
98 contact => $supplier->{'contact'},
99 contpos => $supplier->{'contpos'},
100 contphone => $supplier->{'contphone'},
101 contaltphone => $supplier->{'contaltphone'},
102 contfax => $supplier->{'contfax'},
103 contemail => $supplier->{'contemail'},
104 contnotes => $supplier->{'contnotes'},
105 notes => $supplier->{'notes'},
106 active => $supplier->{'active'},
107 gstreg => $supplier->{'gstreg'},
108 listincgst => $supplier->{'listincgst'},
109 invoiceincgst => $supplier->{'invoiceincgst'},
110 discount => $supplier->{'discount'},
111 invoiceprice => $supplier->{'invoiceprice'},
112 listprice => $supplier->{'listprice'},
114 default_tax => defined($seller_gstrate),
115 basketcount => $supplier->{'basketcount'},
116 contracts => $contracts,
118 } elsif ( $op eq 'delete' ) {
120 print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
123 my @currencies = GetCurrencies();
126 push @{$loop_currency},
127 { currency => $_->{currency},
128 listprice => ( $_->{currency} eq $supplier->{listprice} ),
129 invoiceprice => ( $_->{currency} eq $supplier->{invoiceprice} ),
133 my $default_gst_rate = (C4::Context->preference('gist') * 100) || '0.0';
135 my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : '';
138 name => $supplier->{'name'},
139 postal => $supplier->{'postal'},
140 address1 => $supplier->{'address1'},
141 address2 => $supplier->{'address2'},
142 address3 => $supplier->{'address3'},
143 address4 => $supplier->{'address4'},
144 phone => $supplier->{'phone'},
145 fax => $supplier->{'fax'},
146 url => $supplier->{'url'},
147 contact => $supplier->{'contact'},
148 contpos => $supplier->{'contpos'},
149 contphone => $supplier->{'contphone'},
150 contaltphone => $supplier->{'contaltphone'},
151 contfax => $supplier->{'contfax'},
152 contemail => $supplier->{'contemail'},
153 contnotes => $supplier->{'contnotes'},
154 notes => $supplier->{'notes'},
155 # set active ON by default for supplier add (id empty for add)
156 active => $id ? $supplier->{'active'} : 1,
157 gstreg => $supplier->{'gstreg'},
158 listincgst => $supplier->{'listincgst'},
159 invoiceincgst => $supplier->{'invoiceincgst'},
161 discount => $supplier->{'discount'},
162 loop_currency => $loop_currency,
165 default_gst_rate => $default_gst_rate,
169 output_html_with_http_headers $query, $cookie, $template->output;