Lines 1-10
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
|
|
|
4 |
#script to show display basket of orders |
5 |
|
6 |
# Copyright 2000-2002 Katipo Communications |
3 |
# Copyright 2000-2002 Katipo Communications |
7 |
# Copyright 2008-2009 BibLibre SARL |
4 |
# Copyright 2008-2009 BibLibre SARL |
|
|
5 |
# Copyright 2010 PTFS Europe Ltd |
8 |
# |
6 |
# |
9 |
# This file is part of Koha. |
7 |
# This file is part of Koha. |
10 |
# |
8 |
# |
Lines 43-50
To know the bookseller this script has to display details.
Link Here
|
43 |
use strict; |
41 |
use strict; |
44 |
use warnings; |
42 |
use warnings; |
45 |
use C4::Auth; |
43 |
use C4::Auth; |
46 |
use C4::Acquisition; |
44 |
use C4::Contract qw/GetContract/; |
47 |
use C4::Contract; |
|
|
48 |
use C4::Biblio; |
45 |
use C4::Biblio; |
49 |
use C4::Output; |
46 |
use C4::Output; |
50 |
use C4::Dates qw/format_date /; |
47 |
use C4::Dates qw/format_date /; |
Lines 53-180
use CGI;
Link Here
|
53 |
use C4::Bookseller; |
50 |
use C4::Bookseller; |
54 |
use C4::Budgets; |
51 |
use C4::Budgets; |
55 |
|
52 |
|
56 |
my $query = new CGI; |
53 |
my $query = CGI->new; |
57 |
my $id = $query->param('supplierid'); |
54 |
my $id = $query->param('supplierid'); |
58 |
my @booksellers = GetBookSellerFromId($id) if $id; |
55 |
my $supplier = {}; |
59 |
my $count = scalar @booksellers; |
56 |
if ($id) { |
60 |
my $op = $query->param('op') || "display"; |
57 |
$supplier = GetBookSellerFromId($id); |
61 |
my ($template, $loggedinuser, $cookie) = get_template_and_user( |
58 |
} |
62 |
{ template_name => "acqui/supplier.tmpl", |
59 |
my $op = $query->param('op') || 'display'; |
63 |
query => $query, |
60 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
64 |
type => "intranet", |
61 |
{ template_name => 'acqui/supplier.tmpl', |
65 |
authnotrequired => 0, |
62 |
query => $query, |
66 |
flagsrequired => { acquisition => 'vendors_manage' }, |
63 |
type => 'intranet', |
67 |
debug => 1, |
64 |
authnotrequired => 0, |
68 |
} |
65 |
flagsrequired => { acquisition => 'vendors_manage' }, |
|
|
66 |
debug => 1, |
67 |
} |
69 |
); |
68 |
); |
70 |
my $seller_gstrate = $booksellers[0]->{'gstrate'}; |
69 |
my $seller_gstrate = $supplier->{'gstrate'}; |
71 |
# A perl-ism: '0'==false, '0.000'==true, but 0=='0.000' - this accounts for that |
|
|
72 |
undef $seller_gstrate if ($seller_gstrate == 0); |
73 |
my $GST = $seller_gstrate || C4::Context->preference("gist"); |
74 |
$GST *= 100; |
75 |
|
70 |
|
76 |
my @contracts = GetContracts($id); |
71 |
# ensure the scalar isn't flagged as a string |
77 |
my $contractcount = scalar(@contracts); |
72 |
$seller_gstrate = ( defined $seller_gstrate ) ? $seller_gstrate + 0 : 0; |
78 |
$template->param(hascontracts => 1) if ($contractcount > 0); |
73 |
my $tax_rate = $seller_gstrate || C4::Context->preference('gist'); |
|
|
74 |
$tax_rate *= 100; |
79 |
|
75 |
|
80 |
#build array for currencies |
76 |
#build array for currencies |
81 |
if ($op eq "display") { |
77 |
if ( $op eq 'display' ) { |
82 |
|
78 |
|
83 |
# get contracts |
79 |
my $contracts = GetContract( { booksellerid => $id } ); |
84 |
my @contracts = @{GetContract( { booksellerid => $id } )}; |
|
|
85 |
|
80 |
|
86 |
# format dates |
81 |
for ( @{$contracts} ) { |
87 |
for ( @contracts ) { |
82 |
$_->{contractstartdate} = format_date( $_->{contractstartdate} ); |
88 |
$$_{contractstartdate} = format_date($$_{contractstartdate}); |
83 |
$_->{contractenddate} = format_date( $_->{contractenddate} ); |
89 |
$$_{contractenddate} = format_date($$_{contractenddate}); |
|
|
90 |
} |
84 |
} |
91 |
|
85 |
|
92 |
$template->param( |
86 |
my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : 0; |
93 |
id => $id, |
87 |
|
94 |
name => $booksellers[0]->{'name'}, |
88 |
$template->param( |
95 |
postal => $booksellers[0]->{'postal'}, |
89 |
id => $id, |
96 |
address1 => $booksellers[0]->{'address1'}, |
90 |
name => $supplier->{'name'}, |
97 |
address2 => $booksellers[0]->{'address2'}, |
91 |
postal => $supplier->{'postal'}, |
98 |
address3 => $booksellers[0]->{'address3'}, |
92 |
address1 => $supplier->{'address1'}, |
99 |
address4 => $booksellers[0]->{'address4'}, |
93 |
address2 => $supplier->{'address2'}, |
100 |
phone => $booksellers[0]->{'phone'}, |
94 |
address3 => $supplier->{'address3'}, |
101 |
fax => $booksellers[0]->{'fax'}, |
95 |
address4 => $supplier->{'address4'}, |
102 |
url => $booksellers[0]->{'url'}, |
96 |
phone => $supplier->{'phone'}, |
103 |
contact => $booksellers[0]->{'contact'}, |
97 |
fax => $supplier->{'fax'}, |
104 |
contpos => $booksellers[0]->{'contpos'}, |
98 |
url => $supplier->{'url'}, |
105 |
contphone => $booksellers[0]->{'contphone'}, |
99 |
contact => $supplier->{'contact'}, |
106 |
contaltphone => $booksellers[0]->{'contaltphone'}, |
100 |
contpos => $supplier->{'contpos'}, |
107 |
contfax => $booksellers[0]->{'contfax'}, |
101 |
contphone => $supplier->{'contphone'}, |
108 |
contemail => $booksellers[0]->{'contemail'}, |
102 |
contaltphone => $supplier->{'contaltphone'}, |
109 |
contnotes => $booksellers[0]->{'contnotes'}, |
103 |
contfax => $supplier->{'contfax'}, |
110 |
notes => $booksellers[0]->{'notes'}, |
104 |
contemail => $supplier->{'contemail'}, |
111 |
active => $booksellers[0]->{'active'}, |
105 |
contnotes => $supplier->{'contnotes'}, |
112 |
gstreg => $booksellers[0]->{'gstreg'}, |
106 |
notes => $supplier->{'notes'}, |
113 |
listincgst => $booksellers[0]->{'listincgst'}, |
107 |
active => $supplier->{'active'}, |
114 |
invoiceincgst => $booksellers[0]->{'invoiceincgst'}, |
108 |
gstreg => $supplier->{'gstreg'}, |
115 |
gstrate => $booksellers[0]->{'gstrate'}*100, |
109 |
listincgst => $supplier->{'listincgst'}, |
116 |
discount => $booksellers[0]->{'discount'}, |
110 |
invoiceincgst => $supplier->{'invoiceincgst'}, |
117 |
invoiceprice => $booksellers[0]->{'invoiceprice'}, |
111 |
gstrate => $gstrate, |
118 |
listprice => $booksellers[0]->{'listprice'}, |
112 |
discount => $supplier->{'discount'}, |
119 |
GST => $GST, |
113 |
invoiceprice => $supplier->{'invoiceprice'}, |
120 |
basketcount => $booksellers[0]->{'basketcount'}, |
114 |
listprice => $supplier->{'listprice'}, |
121 |
contracts => \@contracts |
115 |
GST => $tax_rate, |
122 |
); |
116 |
basketcount => $supplier->{'basketcount'}, |
123 |
} |
117 |
contracts => $contracts |
124 |
elsif ($op eq 'delete') { |
118 |
); |
125 |
&DelBookseller($id); |
119 |
} elsif ( $op eq 'delete' ) { |
126 |
print $query->redirect("/cgi-bin/koha/acqui/acqui-home.pl"); |
120 |
DelBookseller($id); |
127 |
exit; |
121 |
print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl'); |
|
|
122 |
exit; |
128 |
} else { |
123 |
} else { |
129 |
my @currencies = GetCurrencies(); |
124 |
my @currencies = GetCurrencies(); |
130 |
my $count = scalar @currencies; |
125 |
my $loop_currency; |
131 |
|
126 |
for (@currencies) { |
132 |
my @loop_pricescurrency; |
127 |
push @{$loop_currency}, |
133 |
my @loop_invoicecurrency; |
128 |
{ currency => $_->{currency}, |
134 |
for (my $i=0;$i<$count;$i++) { |
129 |
listprice => ( $_->{currency} eq $supplier->{listprice} ), |
135 |
if ($booksellers[0]->{'listprice'} eq $currencies[$i]->{'currency'}) { |
130 |
invoiceprice => ( $_->{currency} eq $supplier->{invoiceprice} ), |
136 |
push @loop_pricescurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>" }; |
131 |
}; |
137 |
} else { |
|
|
138 |
push @loop_pricescurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"}; |
139 |
} |
140 |
if ($booksellers[0]->{'invoiceprice'} eq $currencies[$i]->{'currency'}) { |
141 |
push @loop_invoicecurrency, { currency => "<option selected=\"selected\" value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"}; |
142 |
} else { |
143 |
push @loop_invoicecurrency, { currency => "<option value=\"$currencies[$i]->{'currency'}\">$currencies[$i]->{'currency'}</option>"}; |
144 |
} |
145 |
} |
132 |
} |
146 |
$template->param( |
|
|
147 |
id => $id, |
148 |
name => $booksellers[0]->{'name'}, |
149 |
postal => $booksellers[0]->{'postal'}, |
150 |
address1 => $booksellers[0]->{'address1'}, |
151 |
address2 => $booksellers[0]->{'address2'}, |
152 |
address3 => $booksellers[0]->{'address3'}, |
153 |
address4 => $booksellers[0]->{'address4'}, |
154 |
phone => $booksellers[0]->{'phone'}, |
155 |
fax => $booksellers[0]->{'fax'}, |
156 |
url => $booksellers[0]->{'url'}, |
157 |
contact => $booksellers[0]->{'contact'}, |
158 |
contpos => $booksellers[0]->{'contpos'}, |
159 |
contphone => $booksellers[0]->{'contphone'}, |
160 |
contaltphone => $booksellers[0]->{'contaltphone'}, |
161 |
contfax => $booksellers[0]->{'contfax'}, |
162 |
contemail => $booksellers[0]->{'contemail'}, |
163 |
contnotes => $booksellers[0]->{'contnotes'}, |
164 |
notes => $booksellers[0]->{'notes'}, |
165 |
active => $id?$booksellers[0]->{'active'}:1, # set active ON by default for supplier add (id empty for add) |
166 |
gstreg => $booksellers[0]->{'gstreg'}, |
167 |
listincgst => $booksellers[0]->{'listincgst'}, |
168 |
invoiceincgst => $booksellers[0]->{'invoiceincgst'}, |
169 |
gstrate => $booksellers[0]->{'gstrate'}*100, |
170 |
discount => $booksellers[0]->{'discount'}, |
171 |
loop_pricescurrency => \@loop_pricescurrency, |
172 |
loop_invoicecurrency => \@loop_invoicecurrency, |
173 |
GST => $GST, |
174 |
enter => 1, |
175 |
); |
176 |
} |
177 |
|
178 |
|
133 |
|
|
|
134 |
my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : 0; |
135 |
$template->param( |
136 |
id => $id, |
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'}, |
159 |
gstrate => $gstrate, |
160 |
discount => $supplier->{'discount'}, |
161 |
loop_currency => $loop_currency, |
162 |
GST => $tax_rate, |
163 |
enter => 1, |
164 |
); |
165 |
} |
179 |
|
166 |
|
180 |
output_html_with_http_headers $query, $cookie, $template->output; |
167 |
output_html_with_http_headers $query, $cookie, $template->output; |