Bug 9811: Display email address in patron result list
[koha.git] / acqui / supplier.pl
blob86aad0aa1b502c22298245ce6df1acdb61b9d0fd
1 #!/usr/bin/perl
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
12 # version.
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.
22 =head1 NAME
24 supplier.pl
26 =head1 DESCRIPTION
28 this script shows the details for a bookseller given on input arg.
29 It allows to edit & save information about this bookseller.
31 =head1 CGI PARAMETERS
33 =over 4
35 =item booksellerid
37 To know the bookseller this script has to display details.
39 =back
41 =cut
43 use strict;
44 use warnings;
45 use C4::Auth;
46 use C4::Contract qw/GetContract/;
47 use C4::Biblio;
48 use C4::Output;
49 use CGI;
51 use C4::Bookseller qw( GetBookSellerFromId DelBookseller );
52 use C4::Budgets;
54 my $query = CGI->new;
55 my $booksellerid = $query->param('booksellerid');
56 my $supplier = {};
57 if ($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',
63 query => $query,
64 type => 'intranet',
65 authnotrequired => 0,
66 flagsrequired => { acquisition => '*' },
67 debug => 1,
71 #build array for currencies
72 if ( $op eq 'display' ) {
74 my $contracts = GetContract( { booksellerid => $booksellerid } );
76 $template->param(
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');
116 exit;
117 } else {
118 my @currencies = GetCurrencies();
119 my $loop_currency;
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};
129 for (@currencies) {
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 {
140 option => $_ + 0.0
141 }, split( '\|', C4::Context->preference("gist") );
143 $template->param(
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,
173 enter => 1,
177 output_html_with_http_headers $query, $cookie, $template->output;