Lines 387-393
sub transferbook {
Link Here
|
387 |
ModItemTransfer( $itemnumber, $fbr, $tbr, $trigger ); |
387 |
ModItemTransfer( $itemnumber, $fbr, $tbr, $trigger ); |
388 |
|
388 |
|
389 |
# don't need to update MARC anymore, we do it in batch now |
389 |
# don't need to update MARC anymore, we do it in batch now |
390 |
$messages->{'WasTransfered'} = 1; |
390 |
$messages->{'WasTransfered'} = $tbr; |
391 |
|
391 |
|
392 |
} |
392 |
} |
393 |
ModDateLastSeen( $itemnumber ); |
393 |
ModDateLastSeen( $itemnumber ); |
Lines 2136-2158
sub AddReturn {
Link Here
|
2136 |
} |
2136 |
} |
2137 |
|
2137 |
|
2138 |
# check if we have a transfer for this document |
2138 |
# check if we have a transfer for this document |
2139 |
my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->itemnumber ); |
2139 |
my $transfer = $item->get_transfer; |
2140 |
|
2140 |
|
2141 |
# if we have a transfer to complete, we update the line of transfers with the datearrived |
2141 |
# if we have a transfer to complete, we update the line of transfers with the datearrived |
2142 |
my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->itemnumber ); |
2142 |
my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->itemnumber ); |
2143 |
if ($datesent) { |
2143 |
if ($transfer) { |
2144 |
# At this point we will either fill the transfer or it is a wrong transfer |
|
|
2145 |
# either way we should not now generate a new transfer |
2146 |
$validTransfer = 0; |
2144 |
$validTransfer = 0; |
2147 |
if ( $tobranch eq $branch ) { |
2145 |
if ( $transfer->in_transit ) { |
2148 |
my $sth = C4::Context->dbh->prepare( |
2146 |
if ( $transfer->tobranch eq $branch ) { |
2149 |
"UPDATE branchtransfers SET datearrived = now() WHERE itemnumber= ? AND datearrived IS NULL" |
2147 |
$transfer->receive; |
2150 |
); |
2148 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2151 |
$sth->execute( $item->itemnumber ); |
2149 |
} |
2152 |
$messages->{'TransferArrived'} = $frombranch; |
2150 |
else { |
2153 |
} else { |
2151 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2154 |
$messages->{'WrongTransfer'} = $tobranch; |
2152 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
2155 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
2153 |
} |
|
|
2154 |
} |
2155 |
else { |
2156 |
if ( $transfer->tobranch eq $branch ) { |
2157 |
$transfer->receive; |
2158 |
$messages->{'TransferArrived'} = $transfer->frombranch; |
2159 |
} |
2160 |
else { |
2161 |
$messages->{'WasTransfered'} = $transfer->tobranch; |
2162 |
$messages->{'TransferTrigger'} = $transfer->reason; |
2163 |
} |
2156 |
} |
2164 |
} |
2157 |
} |
2165 |
} |
2158 |
|
2166 |
|
Lines 2243-2249
sub AddReturn {
Link Here
|
2243 |
} |
2251 |
} |
2244 |
|
2252 |
|
2245 |
# Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer |
2253 |
# Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer |
2246 |
if ($validTransfer && !$is_in_rotating_collection && ($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) ){ |
2254 |
if ( $validTransfer && !$is_in_rotating_collection |
|
|
2255 |
&& ( $doreturn or $messages->{'NotIssued'} ) |
2256 |
and !$resfound |
2257 |
and ( $branch ne $returnbranch ) |
2258 |
and not $messages->{'WrongTransfer'} |
2259 |
and not $messages->{'WasTransfered'} ) |
2260 |
{ |
2247 |
my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ? 'effective_itemtype' : 'ccode'; |
2261 |
my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ? 'effective_itemtype' : 'ccode'; |
2248 |
if (C4::Context->preference("AutomaticItemReturn" ) or |
2262 |
if (C4::Context->preference("AutomaticItemReturn" ) or |
2249 |
(C4::Context->preference("UseBranchTransferLimits") and |
2263 |
(C4::Context->preference("UseBranchTransferLimits") and |
Lines 2252-2258
sub AddReturn {
Link Here
|
2252 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
2266 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
2253 |
$debug and warn "item: " . Dumper($item->unblessed); |
2267 |
$debug and warn "item: " . Dumper($item->unblessed); |
2254 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger, { skip_record_index => 1 }); |
2268 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger, { skip_record_index => 1 }); |
2255 |
$messages->{'WasTransfered'} = 1; |
2269 |
$messages->{'WasTransfered'} = $returnbranch; |
|
|
2270 |
$messages->{'TransferTrigger'} = $transfer_trigger; |
2256 |
} else { |
2271 |
} else { |
2257 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2272 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2258 |
$messages->{'TransferTrigger'} = $transfer_trigger; |
2273 |
$messages->{'TransferTrigger'} = $transfer_trigger; |
Lines 3416-3422
sub GetTransfers {
Link Here
|
3416 |
SELECT datesent, |
3431 |
SELECT datesent, |
3417 |
frombranch, |
3432 |
frombranch, |
3418 |
tobranch, |
3433 |
tobranch, |
3419 |
branchtransfer_id |
3434 |
branchtransfer_id, |
|
|
3435 |
daterequested, |
3436 |
reason |
3420 |
FROM branchtransfers |
3437 |
FROM branchtransfers |
3421 |
WHERE itemnumber = ? |
3438 |
WHERE itemnumber = ? |
3422 |
AND datearrived IS NULL |
3439 |
AND datearrived IS NULL |