|
Lines 38-45
It permit to write a new order as 'received'.
Link Here
|
| 38 |
|
38 |
|
| 39 |
to know on what supplier this script has to display receive order. |
39 |
to know on what supplier this script has to display receive order. |
| 40 |
|
40 |
|
| 41 |
=item receive |
|
|
| 42 |
|
| 43 |
=item invoiceid |
41 |
=item invoiceid |
| 44 |
|
42 |
|
| 45 |
the id of this invoice. |
43 |
the id of this invoice. |
|
Lines 88-99
my $booksellerid = $invoice->{booksellerid};
Link Here
|
| 88 |
my $freight = $invoice->{shipmentcost}; |
86 |
my $freight = $invoice->{shipmentcost}; |
| 89 |
my $datereceived = $invoice->{shipmentdate}; |
87 |
my $datereceived = $invoice->{shipmentdate}; |
| 90 |
my $ordernumber = $input->param('ordernumber'); |
88 |
my $ordernumber = $input->param('ordernumber'); |
| 91 |
my $search = $input->param('receive'); |
|
|
| 92 |
|
89 |
|
| 93 |
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new(); |
90 |
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new(); |
| 94 |
|
91 |
|
| 95 |
my $bookseller = GetBookSellerFromId($booksellerid); |
92 |
my $bookseller = GetBookSellerFromId($booksellerid); |
| 96 |
my $results = SearchOrder($ordernumber,$search); |
93 |
my $results; |
|
|
94 |
$results = SearchOrder($ordernumber) if $ordernumber; |
| 97 |
|
95 |
|
| 98 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
96 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 99 |
{ |
97 |
{ |
|
Lines 106-253
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
| 106 |
} |
104 |
} |
| 107 |
); |
105 |
); |
| 108 |
|
106 |
|
| 109 |
my $count = scalar @$results; |
107 |
unless ( $results and @$results) { |
|
|
108 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 109 |
exit; |
| 110 |
} |
| 111 |
|
| 110 |
# prepare the form for receiving |
112 |
# prepare the form for receiving |
| 111 |
if ( $count == 1 ) { |
113 |
my $order = $results->[0]; |
| 112 |
my $order = $results->[0]; |
|
|
| 113 |
|
114 |
|
| 114 |
# Check if ACQ framework exists |
115 |
# Check if ACQ framework exists |
| 115 |
my $acq_fw = GetMarcStructure(1, 'ACQ'); |
116 |
my $acq_fw = GetMarcStructure(1, 'ACQ'); |
| 116 |
unless($acq_fw) { |
117 |
unless($acq_fw) { |
| 117 |
$template->param('NoACQframework' => 1); |
118 |
$template->param('NoACQframework' => 1); |
| 118 |
} |
119 |
} |
| 119 |
|
120 |
|
| 120 |
my $AcqCreateItem = C4::Context->preference('AcqCreateItem'); |
121 |
my $AcqCreateItem = C4::Context->preference('AcqCreateItem'); |
| 121 |
if ($AcqCreateItem eq 'receiving') { |
122 |
if ($AcqCreateItem eq 'receiving') { |
| 122 |
$template->param( |
123 |
$template->param( |
| 123 |
AcqCreateItemReceiving => 1, |
124 |
AcqCreateItemReceiving => 1, |
| 124 |
UniqueItemFields => C4::Context->preference('UniqueItemFields'), |
125 |
UniqueItemFields => C4::Context->preference('UniqueItemFields'), |
| 125 |
); |
126 |
); |
| 126 |
} elsif ($AcqCreateItem eq 'ordering') { |
127 |
} elsif ($AcqCreateItem eq 'ordering') { |
| 127 |
my $fw = ($acq_fw) ? 'ACQ' : ''; |
128 |
my $fw = ($acq_fw) ? 'ACQ' : ''; |
| 128 |
my @itemnumbers = GetItemnumbersFromOrder($order->{ordernumber}); |
129 |
my @itemnumbers = GetItemnumbersFromOrder($order->{ordernumber}); |
| 129 |
my @items; |
130 |
my @items; |
| 130 |
foreach (@itemnumbers) { |
131 |
foreach (@itemnumbers) { |
| 131 |
my $item = GetItem($_); |
132 |
my $item = GetItem($_); |
| 132 |
if($item->{homebranch}) { |
133 |
if($item->{homebranch}) { |
| 133 |
$item->{homebranchname} = GetBranchName($item->{homebranch}); |
134 |
$item->{homebranchname} = GetBranchName($item->{homebranch}); |
| 134 |
} |
|
|
| 135 |
if($item->{holdingbranch}) { |
| 136 |
$item->{holdingbranchname} = GetBranchName($item->{holdingbranch}); |
| 137 |
} |
| 138 |
if(my $code = GetAuthValCode("items.notforloan", $fw)) { |
| 139 |
$item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); |
| 140 |
} |
| 141 |
if(my $code = GetAuthValCode("items.restricted", $fw)) { |
| 142 |
$item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); |
| 143 |
} |
| 144 |
if(my $code = GetAuthValCode("items.location", $fw)) { |
| 145 |
$item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); |
| 146 |
} |
| 147 |
if(my $code = GetAuthValCode("items.ccode", $fw)) { |
| 148 |
$item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); |
| 149 |
} |
| 150 |
if(my $code = GetAuthValCode("items.materials", $fw)) { |
| 151 |
$item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials}); |
| 152 |
} |
| 153 |
my $itemtype = getitemtypeinfo($item->{itype}); |
| 154 |
$item->{itemtype} = $itemtype->{description}; |
| 155 |
push @items, $item; |
| 156 |
} |
135 |
} |
| 157 |
$template->param(items => \@items); |
136 |
if($item->{holdingbranch}) { |
| 158 |
} |
137 |
$item->{holdingbranchname} = GetBranchName($item->{holdingbranch}); |
| 159 |
|
|
|
| 160 |
$order->{quantityreceived} = '' if $order->{quantityreceived} == 0; |
| 161 |
$order->{unitprice} = '' if $order->{unitprice} == 0; |
| 162 |
|
| 163 |
my $rrp; |
| 164 |
my $ecost; |
| 165 |
my $unitprice; |
| 166 |
if ( $bookseller->{listincgst} ) { |
| 167 |
if ( $bookseller->{invoiceincgst} ) { |
| 168 |
$rrp = $order->{rrp}; |
| 169 |
$ecost = $order->{ecost}; |
| 170 |
$unitprice = $order->{unitprice}; |
| 171 |
} else { |
| 172 |
$rrp = $order->{rrp} / ( 1 + $order->{gstrate} ); |
| 173 |
$ecost = $order->{ecost} / ( 1 + $order->{gstrate} ); |
| 174 |
$unitprice = $order->{unitprice} / ( 1 + $order->{gstrate} ); |
| 175 |
} |
138 |
} |
| 176 |
} else { |
139 |
if(my $code = GetAuthValCode("items.notforloan", $fw)) { |
| 177 |
if ( $bookseller->{invoiceincgst} ) { |
140 |
$item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); |
| 178 |
$rrp = $order->{rrp} * ( 1 + $order->{gstrate} ); |
|
|
| 179 |
$ecost = $order->{ecost} * ( 1 + $order->{gstrate} ); |
| 180 |
$unitprice = $order->{unitprice} * ( 1 + $order->{gstrate} ); |
| 181 |
} else { |
| 182 |
$rrp = $order->{rrp}; |
| 183 |
$ecost = $order->{ecost}; |
| 184 |
$unitprice = $order->{unitprice}; |
| 185 |
} |
141 |
} |
| 186 |
} |
142 |
if(my $code = GetAuthValCode("items.restricted", $fw)) { |
| 187 |
|
143 |
$item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); |
| 188 |
my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber}); |
144 |
} |
| 189 |
|
145 |
if(my $code = GetAuthValCode("items.location", $fw)) { |
| 190 |
my $authorisedby = $order->{authorisedby}; |
146 |
$item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); |
| 191 |
my $member = GetMember( borrowernumber => $authorisedby ); |
147 |
} |
| 192 |
|
148 |
if(my $code = GetAuthValCode("items.ccode", $fw)) { |
| 193 |
my $budget = GetBudget( $order->{budget_id} ); |
149 |
$item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); |
| 194 |
|
150 |
} |
| 195 |
$template->param( |
151 |
if(my $code = GetAuthValCode("items.materials", $fw)) { |
| 196 |
AcqCreateItem => $AcqCreateItem, |
152 |
$item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials}); |
| 197 |
count => 1, |
153 |
} |
| 198 |
biblionumber => $order->{'biblionumber'}, |
154 |
my $itemtype = getitemtypeinfo($item->{itype}); |
| 199 |
ordernumber => $order->{'ordernumber'}, |
155 |
$item->{itemtype} = $itemtype->{description}; |
| 200 |
biblioitemnumber => $order->{'biblioitemnumber'}, |
156 |
push @items, $item; |
| 201 |
booksellerid => $order->{'booksellerid'}, |
157 |
} |
| 202 |
freight => $freight, |
158 |
$template->param(items => \@items); |
| 203 |
gstrate => $order->{gstrate} || $bookseller->{gstrate} || C4::Context->preference("gist") || 0, |
|
|
| 204 |
name => $bookseller->{'name'}, |
| 205 |
date => format_date($order->{entrydate}), |
| 206 |
title => $order->{'title'}, |
| 207 |
author => $order->{'author'}, |
| 208 |
copyrightdate => $order->{'copyrightdate'}, |
| 209 |
isbn => $order->{'isbn'}, |
| 210 |
seriestitle => $order->{'seriestitle'}, |
| 211 |
bookfund => $budget->{budget_name}, |
| 212 |
quantity => $order->{'quantity'}, |
| 213 |
quantityreceivedplus1 => $order->{'quantityreceived'} + 1, |
| 214 |
quantityreceived => $order->{'quantityreceived'}, |
| 215 |
rrp => sprintf( "%.2f", $rrp ), |
| 216 |
ecost => sprintf( "%.2f", $ecost ), |
| 217 |
unitprice => sprintf( "%.2f", $unitprice), |
| 218 |
memberfirstname => $member->{firstname} || "", |
| 219 |
membersurname => $member->{surname} || "", |
| 220 |
invoiceid => $invoice->{invoiceid}, |
| 221 |
invoice => $invoice->{invoicenumber}, |
| 222 |
datereceived => $datereceived->output(), |
| 223 |
datereceived_iso => $datereceived->output('iso'), |
| 224 |
notes => $order->{notes}, |
| 225 |
suggestionid => $suggestion->{suggestionid}, |
| 226 |
surnamesuggestedby => $suggestion->{surnamesuggestedby}, |
| 227 |
firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, |
| 228 |
); |
| 229 |
} |
159 |
} |
| 230 |
else { |
160 |
|
| 231 |
my @loop; |
161 |
$order->{quantityreceived} = '' if $order->{quantityreceived} == 0; |
| 232 |
for ( my $i = 0 ; $i < $count ; $i++ ) { |
162 |
$order->{unitprice} = '' if $order->{unitprice} == 0; |
| 233 |
my %line = %{ @$results[$i] }; |
163 |
|
| 234 |
|
164 |
my $rrp; |
| 235 |
$line{invoice} = $invoice->{invoicenumber}; |
165 |
my $ecost; |
| 236 |
$line{datereceived} = $datereceived->output(); |
166 |
my $unitprice; |
| 237 |
$line{freight} = $freight; |
167 |
if ( $bookseller->{listincgst} ) { |
| 238 |
$line{gstrate} = @$results[$i]->{'gstrate'} || $bookseller->{gstrate} || C4::Context->preference("gist") || 0; |
168 |
if ( $bookseller->{invoiceincgst} ) { |
| 239 |
$line{title} = @$results[$i]->{'title'}; |
169 |
$rrp = $order->{rrp}; |
| 240 |
$line{author} = @$results[$i]->{'author'}; |
170 |
$ecost = $order->{ecost}; |
| 241 |
$line{booksellerid} = $booksellerid; |
171 |
$unitprice = $order->{unitprice}; |
| 242 |
push @loop, \%line; |
172 |
} else { |
|
|
173 |
$rrp = $order->{rrp} / ( 1 + $order->{gstrate} ); |
| 174 |
$ecost = $order->{ecost} / ( 1 + $order->{gstrate} ); |
| 175 |
$unitprice = $order->{unitprice} / ( 1 + $order->{gstrate} ); |
| 176 |
} |
| 177 |
} else { |
| 178 |
if ( $bookseller->{invoiceincgst} ) { |
| 179 |
$rrp = $order->{rrp} * ( 1 + $order->{gstrate} ); |
| 180 |
$ecost = $order->{ecost} * ( 1 + $order->{gstrate} ); |
| 181 |
$unitprice = $order->{unitprice} * ( 1 + $order->{gstrate} ); |
| 182 |
} else { |
| 183 |
$rrp = $order->{rrp}; |
| 184 |
$ecost = $order->{ecost}; |
| 185 |
$unitprice = $order->{unitprice}; |
| 243 |
} |
186 |
} |
|
|
187 |
} |
| 188 |
|
| 189 |
my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber}); |
| 190 |
|
| 191 |
my $authorisedby = $order->{authorisedby}; |
| 192 |
my $member = GetMember( borrowernumber => $authorisedby ); |
| 193 |
|
| 194 |
my $budget = GetBudget( $order->{budget_id} ); |
| 195 |
|
| 196 |
$template->param( |
| 197 |
AcqCreateItem => $AcqCreateItem, |
| 198 |
count => 1, |
| 199 |
biblionumber => $order->{'biblionumber'}, |
| 200 |
ordernumber => $order->{'ordernumber'}, |
| 201 |
biblioitemnumber => $order->{'biblioitemnumber'}, |
| 202 |
booksellerid => $order->{'booksellerid'}, |
| 203 |
freight => $freight, |
| 204 |
name => $bookseller->{'name'}, |
| 205 |
date => format_date($order->{entrydate}), |
| 206 |
title => $order->{'title'}, |
| 207 |
author => $order->{'author'}, |
| 208 |
copyrightdate => $order->{'copyrightdate'}, |
| 209 |
isbn => $order->{'isbn'}, |
| 210 |
seriestitle => $order->{'seriestitle'}, |
| 211 |
bookfund => $budget->{budget_name}, |
| 212 |
quantity => $order->{'quantity'}, |
| 213 |
quantityreceivedplus1 => $order->{'quantityreceived'} + 1, |
| 214 |
quantityreceived => $order->{'quantityreceived'}, |
| 215 |
rrp => sprintf( "%.2f", $rrp ), |
| 216 |
ecost => sprintf( "%.2f", $ecost ), |
| 217 |
unitprice => sprintf( "%.2f", $unitprice), |
| 218 |
memberfirstname => $member->{firstname} || "", |
| 219 |
membersurname => $member->{surname} || "", |
| 220 |
invoiceid => $invoice->{invoiceid}, |
| 221 |
invoice => $invoice->{invoicenumber}, |
| 222 |
datereceived => $datereceived->output(), |
| 223 |
datereceived_iso => $datereceived->output('iso'), |
| 224 |
notes => $order->{notes}, |
| 225 |
suggestionid => $suggestion->{suggestionid}, |
| 226 |
surnamesuggestedby => $suggestion->{surnamesuggestedby}, |
| 227 |
firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, |
| 228 |
); |
| 244 |
|
229 |
|
| 245 |
$template->param( |
|
|
| 246 |
loop => \@loop, |
| 247 |
booksellerid => $booksellerid, |
| 248 |
invoiceid => $invoice->{invoiceid}, |
| 249 |
); |
| 250 |
} |
| 251 |
my $op = $input->param('op'); |
230 |
my $op = $input->param('op'); |
| 252 |
if ($op and $op eq 'edit'){ |
231 |
if ($op and $op eq 'edit'){ |
| 253 |
$template->param(edit => 1); |
232 |
$template->param(edit => 1); |