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 /;
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 : 0;
75 my $tax_rate = $seller_gstrate || C4
::Context
->preference('gist');
78 #build array for currencies
79 if ( $op eq 'display' ) {
81 my $contracts = GetContract
( { booksellerid
=> $id } );
83 for ( @
{$contracts} ) {
84 $_->{contractstartdate
} = format_date
( $_->{contractstartdate
} );
85 $_->{contractenddate
} = format_date
( $_->{contractenddate
} );
88 my $gstrate = defined $supplier->{gstrate
} ?
$supplier->{gstrate
} * 100 : 0;
92 name
=> $supplier->{'name'},
93 postal
=> $supplier->{'postal'},
94 address1
=> $supplier->{'address1'},
95 address2
=> $supplier->{'address2'},
96 address3
=> $supplier->{'address3'},
97 address4
=> $supplier->{'address4'},
98 phone
=> $supplier->{'phone'},
99 fax
=> $supplier->{'fax'},
100 url
=> $supplier->{'url'},
101 contact
=> $supplier->{'contact'},
102 contpos
=> $supplier->{'contpos'},
103 contphone
=> $supplier->{'contphone'},
104 contaltphone
=> $supplier->{'contaltphone'},
105 contfax
=> $supplier->{'contfax'},
106 contemail
=> $supplier->{'contemail'},
107 contnotes
=> $supplier->{'contnotes'},
108 notes
=> $supplier->{'notes'},
109 active
=> $supplier->{'active'},
110 gstreg
=> $supplier->{'gstreg'},
111 listincgst
=> $supplier->{'listincgst'},
112 invoiceincgst
=> $supplier->{'invoiceincgst'},
114 discount
=> $supplier->{'discount'},
115 invoiceprice
=> $supplier->{'invoiceprice'},
116 listprice
=> $supplier->{'listprice'},
118 basketcount
=> $supplier->{'basketcount'},
119 contracts
=> $contracts
121 } elsif ( $op eq 'delete' ) {
123 print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
126 my @currencies = GetCurrencies
();
129 push @
{$loop_currency},
130 { currency
=> $_->{currency
},
131 listprice
=> ( $_->{currency
} eq $supplier->{listprice
} ),
132 invoiceprice
=> ( $_->{currency
} eq $supplier->{invoiceprice
} ),
136 my $gstrate = defined $supplier->{gstrate
} ?
$supplier->{gstrate
} * 100 : 0;
139 name
=> $supplier->{'name'},
140 postal
=> $supplier->{'postal'},
141 address1
=> $supplier->{'address1'},
142 address2
=> $supplier->{'address2'},
143 address3
=> $supplier->{'address3'},
144 address4
=> $supplier->{'address4'},
145 phone
=> $supplier->{'phone'},
146 fax
=> $supplier->{'fax'},
147 url
=> $supplier->{'url'},
148 contact
=> $supplier->{'contact'},
149 contpos
=> $supplier->{'contpos'},
150 contphone
=> $supplier->{'contphone'},
151 contaltphone
=> $supplier->{'contaltphone'},
152 contfax
=> $supplier->{'contfax'},
153 contemail
=> $supplier->{'contemail'},
154 contnotes
=> $supplier->{'contnotes'},
155 notes
=> $supplier->{'notes'},
156 # set active ON by default for supplier add (id empty for add)
157 active
=> $id ?
$supplier->{'active'} : 1,
158 gstreg
=> $supplier->{'gstreg'},
159 listincgst
=> $supplier->{'listincgst'},
160 invoiceincgst
=> $supplier->{'invoiceincgst'},
162 discount
=> $supplier->{'discount'},
163 loop_currency
=> $loop_currency,
169 output_html_with_http_headers
$query, $cookie, $template->output;