Lines 383-389
sub transferbook {
Link Here
|
383 |
ModItemTransfer( $itemnumber, $fbr, $tbr, $trigger ); |
383 |
ModItemTransfer( $itemnumber, $fbr, $tbr, $trigger ); |
384 |
|
384 |
|
385 |
# don't need to update MARC anymore, we do it in batch now |
385 |
# don't need to update MARC anymore, we do it in batch now |
386 |
$messages->{'WasTransfered'} = 1; |
386 |
$messages->{'WasTransfered'} = $tbr; |
387 |
|
387 |
|
388 |
} |
388 |
} |
389 |
ModDateLastSeen( $itemnumber ); |
389 |
ModDateLastSeen( $itemnumber ); |
Lines 2025-2046
sub AddReturn {
Link Here
|
2025 |
} |
2025 |
} |
2026 |
|
2026 |
|
2027 |
# check if we have a transfer for this document |
2027 |
# check if we have a transfer for this document |
2028 |
my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->itemnumber ); |
2028 |
my $transfer = $item->get_transfer; |
2029 |
|
2029 |
|
2030 |
# if we have a transfer to do, we update the line of transfers with the datearrived |
2030 |
# if we have a transfer to do, we update the line of transfers with the datearrived |
2031 |
my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->itemnumber ); |
2031 |
my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->itemnumber ); |
2032 |
if ($datesent) { |
2032 |
if ($transfer) { |
2033 |
# At this point we will either fill the transfer or it is a wrong transfer |
|
|
2034 |
# either way we should not now generate a new transfer |
2035 |
$validTransfer = 0; |
2033 |
$validTransfer = 0; |
2036 |
if ( $tobranch eq $branch ) { |
2034 |
if ( $transfer->in_transit ) { |
2037 |
my $sth = C4::Context->dbh->prepare( |
2035 |
if ( $transfer->tobranch eq $branch ) { |
2038 |
"UPDATE branchtransfers SET datearrived = now() WHERE itemnumber= ? AND datearrived IS NULL" |
2036 |
$transfer->receive; |
2039 |
); |
2037 |
|
2040 |
$sth->execute( $item->itemnumber ); |
2038 |
# if we have a reservation with completed transfer, we can set it's status to 'W' |
2041 |
} else { |
2039 |
C4::Reserves::ModReserveStatus( $item->itemnumber, 'W' ); |
2042 |
$messages->{'WrongTransfer'} = $tobranch; |
2040 |
} |
2043 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
2041 |
else { |
|
|
2042 |
$messages->{'WrongTransfer'} = $transfer->tobranch; |
2043 |
$messages->{'WrongTransferItem'} = $item->itemnumber; |
2044 |
} |
2045 |
} |
2046 |
else { |
2047 |
if ( $transfer->tobranch eq $branch ) { |
2048 |
$transfer->receive; |
2049 |
} |
2050 |
else { |
2051 |
$messages->{'WasTransfered'} = $transfer->tobranch; |
2052 |
$messages->{'TransferTrigger'} = $transfer->reason; |
2053 |
} |
2044 |
} |
2054 |
} |
2045 |
} |
2055 |
} |
2046 |
|
2056 |
|
Lines 2131-2137
sub AddReturn {
Link Here
|
2131 |
} |
2141 |
} |
2132 |
|
2142 |
|
2133 |
# Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer |
2143 |
# Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer |
2134 |
if ($validTransfer && !$is_in_rotating_collection && ($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) ){ |
2144 |
if ( $validTransfer && !$is_in_rotating_collection |
|
|
2145 |
&& ( $doreturn or $messages->{'NotIssued'} ) |
2146 |
and !$resfound |
2147 |
and ( $branch ne $returnbranch ) |
2148 |
and not $messages->{'WrongTransfer'} |
2149 |
and not $messages->{'WasTransfered'} ) |
2150 |
{ |
2135 |
my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ? 'effective_itemtype' : 'ccode'; |
2151 |
my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ? 'effective_itemtype' : 'ccode'; |
2136 |
if (C4::Context->preference("AutomaticItemReturn" ) or |
2152 |
if (C4::Context->preference("AutomaticItemReturn" ) or |
2137 |
(C4::Context->preference("UseBranchTransferLimits") and |
2153 |
(C4::Context->preference("UseBranchTransferLimits") and |
Lines 2140-2146
sub AddReturn {
Link Here
|
2140 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
2156 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
2141 |
$debug and warn "item: " . Dumper($item->unblessed); |
2157 |
$debug and warn "item: " . Dumper($item->unblessed); |
2142 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger); |
2158 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger); |
2143 |
$messages->{'WasTransfered'} = 1; |
2159 |
$messages->{'WasTransfered'} = $returnbranch; |
|
|
2160 |
$messages->{'TransferTrigger'} = $transfer_trigger; |
2144 |
} else { |
2161 |
} else { |
2145 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2162 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2146 |
$messages->{'TransferTrigger'} = $transfer_trigger; |
2163 |
$messages->{'TransferTrigger'} = $transfer_trigger; |
Lines 3329-3335
sub GetTransfers {
Link Here
|
3329 |
SELECT datesent, |
3346 |
SELECT datesent, |
3330 |
frombranch, |
3347 |
frombranch, |
3331 |
tobranch, |
3348 |
tobranch, |
3332 |
branchtransfer_id |
3349 |
branchtransfer_id, |
|
|
3350 |
daterequested, |
3351 |
reason |
3333 |
FROM branchtransfers |
3352 |
FROM branchtransfers |
3334 |
WHERE itemnumber = ? |
3353 |
WHERE itemnumber = ? |
3335 |
AND datearrived IS NULL |
3354 |
AND datearrived IS NULL |