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,
108 dateformat
=> C4
::Context
->preference("dateformat"),
110 } elsif ( $op eq 'delete' ) {
111 # no further message needed for the user
112 # the DELETE button only appears in the template if basketcount == 0
113 if ( $supplier->{'basketcount'} == 0 ) {
114 DelBookseller
($booksellerid);
116 print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
119 my @currencies = GetCurrencies
();
121 my $active_currency = GetCurrency
();
122 my $active_listprice = $supplier->{'listprice'};
123 my $active_invoiceprice = $supplier->{'invoiceprice'};
124 if (!$supplier->{listprice
}) {
125 $active_listprice = $active_currency->{currency
};
127 if (!$supplier->{invoiceprice
}) {
128 $active_invoiceprice = $active_currency->{currency
};
131 push @
{$loop_currency},
133 currency
=> $_->{currency
},
134 listprice
=> ( $_->{currency
} eq $active_listprice ),
135 invoiceprice
=> ( $_->{currency
} eq $active_invoiceprice ),
139 # get option values from gist syspref
140 my @gst_values = map {
142 }, split( '\|', C4
::Context
->preference("gist") );
145 booksellerid
=> $booksellerid,
146 name
=> $supplier->{'name'},
147 postal
=> $supplier->{'postal'},
148 address1
=> $supplier->{'address1'},
149 address2
=> $supplier->{'address2'},
150 address3
=> $supplier->{'address3'},
151 address4
=> $supplier->{'address4'},
152 phone
=> $supplier->{'phone'},
153 accountnumber
=> $supplier->{'accountnumber'},
154 fax
=> $supplier->{'fax'},
155 url
=> $supplier->{'url'},
156 contact
=> $supplier->{'contact'},
157 contpos
=> $supplier->{'contpos'},
158 contphone
=> $supplier->{'contphone'},
159 contaltphone
=> $supplier->{'contaltphone'},
160 contfax
=> $supplier->{'contfax'},
161 contemail
=> $supplier->{'contemail'},
162 contnotes
=> $supplier->{'contnotes'},
163 notes
=> $supplier->{'notes'},
164 # set active ON by default for supplier add (id empty for add)
165 active
=> $booksellerid ?
$supplier->{'active'} : 1,
166 gstreg
=> $supplier->{'gstreg'},
167 listincgst
=> $supplier->{'listincgst'},
168 invoiceincgst
=> $supplier->{'invoiceincgst'},
169 gstrate
=> $supplier->{gstrate
} ?
$supplier->{'gstrate'}+0.0 : 0,
170 gst_values
=> \
@gst_values,
171 discount
=> $supplier->{'discount'},
172 deliverytime
=> $supplier->{deliverytime
},
173 loop_currency
=> $loop_currency,
178 output_html_with_http_headers
$query, $cookie, $template->output;