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.
27 this script shows the details for a bookseller given on input arg.
28 It allows to edit & save information about this bookseller.
35 To know the bookseller this script has to display details.
44 use C4
::Contract qw
/GetContract/;
47 use C4
::Dates qw
/format_date /;
54 my $id = $query->param('supplierid');
57 $supplier = GetBookSellerFromId
($id);
59 my $op = $query->param('op') || 'display';
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
61 { template_name
=> 'acqui/supplier.tmpl',
65 flagsrequired
=> { acquisition
=> 'vendors_manage' },
69 my $seller_gstrate = $supplier->{'gstrate'};
71 # ensure the scalar isn't flagged as a string
72 $seller_gstrate = ( defined $seller_gstrate ) ?
$seller_gstrate + 0 : 0;
73 my $tax_rate = $seller_gstrate || C4
::Context
->preference('gist');
76 #build array for currencies
77 if ( $op eq 'display' ) {
79 my $contracts = GetContract
( { booksellerid
=> $id } );
81 for ( @
{$contracts} ) {
82 $_->{contractstartdate
} = format_date
( $_->{contractstartdate
} );
83 $_->{contractenddate
} = format_date
( $_->{contractenddate
} );
86 my $gstrate = defined $supplier->{gstrate
} ?
$supplier->{gstrate
} * 100 : 0;
90 name
=> $supplier->{'name'},
91 postal
=> $supplier->{'postal'},
92 address1
=> $supplier->{'address1'},
93 address2
=> $supplier->{'address2'},
94 address3
=> $supplier->{'address3'},
95 address4
=> $supplier->{'address4'},
96 phone
=> $supplier->{'phone'},
97 fax
=> $supplier->{'fax'},
98 url
=> $supplier->{'url'},
99 contact
=> $supplier->{'contact'},
100 contpos
=> $supplier->{'contpos'},
101 contphone
=> $supplier->{'contphone'},
102 contaltphone
=> $supplier->{'contaltphone'},
103 contfax
=> $supplier->{'contfax'},
104 contemail
=> $supplier->{'contemail'},
105 contnotes
=> $supplier->{'contnotes'},
106 notes
=> $supplier->{'notes'},
107 active
=> $supplier->{'active'},
108 gstreg
=> $supplier->{'gstreg'},
109 listincgst
=> $supplier->{'listincgst'},
110 invoiceincgst
=> $supplier->{'invoiceincgst'},
112 discount
=> $supplier->{'discount'},
113 invoiceprice
=> $supplier->{'invoiceprice'},
114 listprice
=> $supplier->{'listprice'},
116 basketcount
=> $supplier->{'basketcount'},
117 contracts
=> $contracts
119 } elsif ( $op eq 'delete' ) {
121 print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
124 my @currencies = GetCurrencies
();
127 push @
{$loop_currency},
128 { currency
=> $_->{currency
},
129 listprice
=> ( $_->{currency
} eq $supplier->{listprice
} ),
130 invoiceprice
=> ( $_->{currency
} eq $supplier->{invoiceprice
} ),
134 my $gstrate = defined $supplier->{gstrate
} ?
$supplier->{gstrate
} * 100 : 0;
137 name
=> $supplier->{'name'},
138 postal
=> $supplier->{'postal'},
139 address1
=> $supplier->{'address1'},
140 address2
=> $supplier->{'address2'},
141 address3
=> $supplier->{'address3'},
142 address4
=> $supplier->{'address4'},
143 phone
=> $supplier->{'phone'},
144 fax
=> $supplier->{'fax'},
145 url
=> $supplier->{'url'},
146 contact
=> $supplier->{'contact'},
147 contpos
=> $supplier->{'contpos'},
148 contphone
=> $supplier->{'contphone'},
149 contaltphone
=> $supplier->{'contaltphone'},
150 contfax
=> $supplier->{'contfax'},
151 contemail
=> $supplier->{'contemail'},
152 contnotes
=> $supplier->{'contnotes'},
153 notes
=> $supplier->{'notes'},
154 # set active ON by default for supplier add (id empty for add)
155 active
=> $id ?
$supplier->{'active'} : 1,
156 gstreg
=> $supplier->{'gstreg'},
157 listincgst
=> $supplier->{'listincgst'},
158 invoiceincgst
=> $supplier->{'invoiceincgst'},
160 discount
=> $supplier->{'discount'},
161 loop_currency
=> $loop_currency,
167 output_html_with_http_headers
$query, $cookie, $template->output;