Lines 350-369
sub ModItemTransfer {
Link Here
|
350 |
my $dbh = C4::Context->dbh; |
350 |
my $dbh = C4::Context->dbh; |
351 |
my $item = Koha::Items->find( $itemnumber ); |
351 |
my $item = Koha::Items->find( $itemnumber ); |
352 |
|
352 |
|
353 |
# Remove the 'shelving cart' location status if it is being used. |
353 |
# NOTE: This retains the existing hard coded behaviour by ignoring transfer limits |
354 |
CartToShelf( $itemnumber ) if $item->location && $item->location eq 'CART' && ( !$item->permanent_location || $item->permanent_location ne 'CART' ); |
354 |
# and always replacing any existing transfers. (In theory, calls to ModItemTransfer |
355 |
|
355 |
# will have been preceded by a check of branch transfer limits) |
356 |
$dbh->do("UPDATE branchtransfers SET datearrived = NOW(), comments = ? WHERE itemnumber = ? AND datearrived IS NULL", undef, "Canceled, new transfer from $frombranch to $tobranch created", $itemnumber); |
356 |
my $to_library = Koha::Libraries->find($tobranch); |
|
|
357 |
my $transfer = $item->request_transfer( |
358 |
{ |
359 |
to => $to_library, |
360 |
reason => $trigger, |
361 |
ignore_limits => 1, |
362 |
replace => 1 |
363 |
} |
364 |
); |
357 |
|
365 |
|
358 |
#new entry in branchtransfers.... |
366 |
# Immediately set the item to in transit if it is checked in |
359 |
my $sth = $dbh->prepare( |
367 |
if ( !$item->checkout ) { |
360 |
"INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch, reason) |
368 |
$item->holdingbranch($frombranch)->store( |
361 |
VALUES (?, ?, NOW(), ?, ?)"); |
369 |
{ |
362 |
$sth->execute($itemnumber, $frombranch, $tobranch, $trigger); |
370 |
log_action => 0, |
|
|
371 |
skip_record_index => $params->{skip_record_index} |
372 |
} |
373 |
); |
374 |
$transfer->transit; |
375 |
} |
363 |
|
376 |
|
364 |
# FIXME we are fetching the item twice in the 2 next statements! |
|
|
365 |
Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store({ log_action => 0, skip_record_index => $params->{skip_record_index} }); |
366 |
ModDateLastSeen($itemnumber, undef, { skip_record_index => $params->{skip_record_index} }); |
367 |
return; |
377 |
return; |
368 |
} |
378 |
} |
369 |
|
379 |
|
370 |
- |
|
|