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

(-)a/C4/Circulation.pm (-16 / +35 lines)
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->receipt();
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->receipt();
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
(-)a/circ/returns.pl (-1 / +2 lines)
Lines 357-363 my $reserved = 0; Link Here
357
if ( $messages->{'WasTransfered'} ) {
357
if ( $messages->{'WasTransfered'} ) {
358
    $template->param(
358
    $template->param(
359
        found          => 1,
359
        found          => 1,
360
        transfer       => 1,
360
        transfer       => $messages->{'WasTransfered'},
361
        trigger        => $messages->{'TransferTrigger'},
361
        itemnumber     => $itemnumber,
362
        itemnumber     => $itemnumber,
362
    );
363
    );
363
}
364
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-3 / +21 lines)
Lines 106-111 Link Here
106
                                </div> <!-- /.hold-auto-filled -->
106
                                </div> <!-- /.hold-auto-filled -->
107
                            [% END # /IF hold_auto_filled %]
107
                            [% END # /IF hold_auto_filled %]
108
108
109
                            [% IF ( trigger ) %]
110
                                 <div id="transfer-trigger" class="dialog message">
111
                                     <h3>Reason for transfer</h3>
112
                                     <p>
113
                                         [%- SWITCH trigger -%]
114
                                             [%- CASE 'Manual' -%]Manual
115
                                             [%- CASE 'StockrotationAdvance' -%]Stock rotation advance
116
                                             [%- CASE 'StockrotationRepatriation' -%]Stock rotation repatriation
117
                                             [%- CASE 'ReturnToHome' -%]Return to home library
118
                                             [%- CASE 'ReturnToHolding' -%]Return to holding library
119
                                             [%- CASE 'RotatingCollection' -%]Rotating collection
120
                                             [%- CASE 'Reserve' -%]Reserve
121
                                             [%- CASE 'LostReserve' -%]Lost reserve
122
                                             [%- CASE 'CancelReserve' -%]Cancelled reserve
123
                                         [%- END -%]
124
                                     </p>
125
                                 </div>
126
                            [% END %]
127
109
                            [% IF privacy == 2 AND NOT Koha.Preference('AnonymousPatron') %]
128
                            [% IF privacy == 2 AND NOT Koha.Preference('AnonymousPatron') %]
110
                                <div class="dialog alert">
129
                                <div class="dialog alert">
111
                                    <strong>Error:</strong>
130
                                    <strong>Error:</strong>
Lines 494-500 Link Here
494
513
495
                                                <div class="modal-header">
514
                                                <div class="modal-header">
496
                                                    <h3>
515
                                                    <h3>
497
                                                        Please return this item to [% Branches.GetName( returnbranch ) | html %]
516
                                                        Please return this item to [% IF transfer %][% Branches.GetName( transfer ) | html %][% ELSE %][% Branches.GetName( returnbranch ) | html %][% END %]
498
                                                    </h3>
517
                                                    </h3>
499
                                                </div>
518
                                                </div>
500
                                                <div class="modal-body">
519
                                                <div class="modal-body">
Lines 521-527 Link Here
521
                                                        <button type="button" data-dismiss="modal" class="btn btn-default deny" name="notransfer" value="No"><i class="fa fa-times"></i> No</button>
540
                                                        <button type="button" data-dismiss="modal" class="btn btn-default deny" name="notransfer" value="No"><i class="fa fa-times"></i> No</button>
522
                                                    [% ELSE %]
541
                                                    [% ELSE %]
523
                                                        <button type="button" data-dismiss="modal" class="btn btn-default approve"><i class="fa fa-check"></i> OK</button>
542
                                                        <button type="button" data-dismiss="modal" class="btn btn-default approve"><i class="fa fa-check"></i> OK</button>
524
                                                        <button type="button" data-dismiss="modal" name="dotransfer" class="btn btn-default print openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber | uri %]&amp;branchcode=[% returnbranch | uri %]&amp;op=slip"><i class="fa fa-print"></i> Print slip</button>
543
                                                        <button type="button" data-dismiss="modal" name="dotransfer" class="btn btn-default print openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber | uri %]&amp;branchcode=[% transfer | uri %]&amp;op=slip"><i class="fa fa-print"></i> Print slip</button>
525
                                                    [% END %]
544
                                                    [% END %]
526
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
545
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
527
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
546
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
528
- 

Return to bug 24446