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