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.
51 use C4::Bookseller qw( GetBookSellerFromId DelBookseller );
52 use C4::Bookseller::Contact;
56 my $op = $query->param('op') || 'display';
57 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
58 { template_name => 'acqui/supplier.tt',
62 flagsrequired => { acquisition => '*' },
66 my $booksellerid = $query->param('booksellerid');
69 $supplier = GetBookSellerFromId($booksellerid);
70 foreach ( keys $supplier ) {
71 $template->{'VARS'}->{$_} = $supplier->{$_};
73 $template->{'VARS'}->{'booksellerid'} = $booksellerid;
76 #build array for currencies
77 if ( $op eq 'display' ) {
78 my $contracts = GetContracts( { booksellerid => $booksellerid } );
81 active => $supplier->{'active'},
82 gstrate => $supplier->{'gstrate'} + 0.0,
83 invoiceprice => $supplier->{'invoiceprice'},
84 listprice => $supplier->{'listprice'},
85 basketcount => $supplier->{'basketcount'},
86 subscriptioncount => $supplier->{'subscriptioncount'},
87 contracts => $contracts,
89 } elsif ( $op eq 'delete' ) {
90 # no further message needed for the user
91 # the DELETE button only appears in the template if basketcount == 0
92 if ( $supplier->{'basketcount'} == 0 ) {
93 DelBookseller($booksellerid);
95 print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
98 my @currencies = GetCurrencies();
100 my $active_currency = GetCurrency();
101 my $active_listprice = $supplier->{'listprice'};
102 my $active_invoiceprice = $supplier->{'invoiceprice'};
103 if (!$supplier->{listprice}) {
104 $active_listprice = $active_currency->{currency};
106 if (!$supplier->{invoiceprice}) {
107 $active_invoiceprice = $active_currency->{currency};
110 push @{$loop_currency},
112 currency => $_->{currency},
113 listprice => ( $_->{currency} eq $active_listprice ),
114 invoiceprice => ( $_->{currency} eq $active_invoiceprice ),
118 # get option values from gist syspref
119 my @gst_values = map {
121 }, split( '\|', C4::Context->preference("gist") );
124 # set active ON by default for supplier add (id empty for add)
125 active => $booksellerid ? $supplier->{'active'} : 1,
126 gstrate => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
127 gst_values => \@gst_values,
128 loop_currency => $loop_currency,
133 output_html_with_http_headers $query, $cookie, $template->output;