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/;
51 use C4
::Bookseller
qw( GetBookSellerFromId DelBookseller );
55 my $booksellerid = $query->param('booksellerid');
58 $supplier = GetBookSellerFromId
($booksellerid);
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
=> '*' },
71 #build array for currencies
72 if ( $op eq 'display' ) {
74 my $contracts = GetContract
( { booksellerid
=> $booksellerid } );
77 booksellerid
=> $booksellerid,
78 name
=> $supplier->{'name'},
79 postal
=> $supplier->{'postal'},
80 address1
=> $supplier->{'address1'},
81 address2
=> $supplier->{'address2'},
82 address3
=> $supplier->{'address3'},
83 address4
=> $supplier->{'address4'},
84 phone
=> $supplier->{'phone'},
85 accountnumber
=> $supplier->{'accountnumber'},
86 fax
=> $supplier->{'fax'},
87 url
=> $supplier->{'url'},
88 contact
=> $supplier->{'contact'},
89 contpos
=> $supplier->{'contpos'},
90 contphone
=> $supplier->{'contphone'},
91 contaltphone
=> $supplier->{'contaltphone'},
92 contfax
=> $supplier->{'contfax'},
93 contemail
=> $supplier->{'contemail'},
94 contnotes
=> $supplier->{'contnotes'},
95 notes
=> $supplier->{'notes'},
96 active
=> $supplier->{'active'},
97 gstreg
=> $supplier->{'gstreg'},
98 listincgst
=> $supplier->{'listincgst'},
99 invoiceincgst
=> $supplier->{'invoiceincgst'},
100 gstrate
=> $supplier->{'gstrate'} + 0.0,
101 discount
=> $supplier->{'discount'},
102 deliverytime
=> $supplier->{deliverytime
},
103 invoiceprice
=> $supplier->{'invoiceprice'},
104 listprice
=> $supplier->{'listprice'},
105 basketcount
=> $supplier->{'basketcount'},
106 subscriptioncount
=> $supplier->{'subscriptioncount'},
107 contracts
=> $contracts,
109 } elsif ( $op eq 'delete' ) {
110 # no further message needed for the user
111 # the DELETE button only appears in the template if basketcount == 0
112 if ( $supplier->{'basketcount'} == 0 ) {
113 DelBookseller
($booksellerid);
115 print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
118 my @currencies = GetCurrencies
();
120 my $active_currency = GetCurrency
();
121 my $active_listprice = $supplier->{'listprice'};
122 my $active_invoiceprice = $supplier->{'invoiceprice'};
123 if (!$supplier->{listprice
}) {
124 $active_listprice = $active_currency->{currency
};
126 if (!$supplier->{invoiceprice
}) {
127 $active_invoiceprice = $active_currency->{currency
};
130 push @
{$loop_currency},
132 currency
=> $_->{currency
},
133 listprice
=> ( $_->{currency
} eq $active_listprice ),
134 invoiceprice
=> ( $_->{currency
} eq $active_invoiceprice ),
138 # get option values from gist syspref
139 my @gst_values = map {
141 }, split( '\|', C4
::Context
->preference("gist") );
144 booksellerid
=> $booksellerid,
145 name
=> $supplier->{'name'},
146 postal
=> $supplier->{'postal'},
147 address1
=> $supplier->{'address1'},
148 address2
=> $supplier->{'address2'},
149 address3
=> $supplier->{'address3'},
150 address4
=> $supplier->{'address4'},
151 phone
=> $supplier->{'phone'},
152 accountnumber
=> $supplier->{'accountnumber'},
153 fax
=> $supplier->{'fax'},
154 url
=> $supplier->{'url'},
155 contact
=> $supplier->{'contact'},
156 contpos
=> $supplier->{'contpos'},
157 contphone
=> $supplier->{'contphone'},
158 contaltphone
=> $supplier->{'contaltphone'},
159 contfax
=> $supplier->{'contfax'},
160 contemail
=> $supplier->{'contemail'},
161 contnotes
=> $supplier->{'contnotes'},
162 notes
=> $supplier->{'notes'},
163 # set active ON by default for supplier add (id empty for add)
164 active
=> $booksellerid ?
$supplier->{'active'} : 1,
165 gstreg
=> $supplier->{'gstreg'},
166 listincgst
=> $supplier->{'listincgst'},
167 invoiceincgst
=> $supplier->{'invoiceincgst'},
168 gstrate
=> $supplier->{gstrate
} ?
$supplier->{'gstrate'}+0.0 : 0,
169 gst_values
=> \
@gst_values,
170 discount
=> $supplier->{'discount'},
171 deliverytime
=> $supplier->{deliverytime
},
172 loop_currency
=> $loop_currency,
177 output_html_with_http_headers
$query, $cookie, $template->output;