View | Details | Raw Unified | Return to bug 24446
Collapse All | Expand All

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

Return to bug 24446