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

(-)a/C4/Circulation.pm (-13 / +19 lines)
Lines 2175-2180 sub AddReturn { Link Here
2175
            else {
2175
            else {
2176
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2176
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2177
                $messages->{'WrongTransferItem'} = $item->itemnumber;
2177
                $messages->{'WrongTransferItem'} = $item->itemnumber;
2178
                $messages->{'TransferTrigger'}   = $transfer->reason;
2178
            }
2179
            }
2179
        }
2180
        }
2180
        else {
2181
        else {
Lines 3589-3607 This function validate the line of brachtransfer but with the wrong destination Link Here
3589
3590
3590
sub updateWrongTransfer {
3591
sub updateWrongTransfer {
3591
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3592
	my ( $itemNumber,$waitingAtLibrary,$FromLibrary ) = @_;
3592
	my $dbh = C4::Context->dbh;	
3593
    
3593
# first step validate the actual line of transfert .
3594
    # first step: cancel the original transfer
3594
	my $sth =
3595
    my $item = Koha::Items->find($itemNumber);
3595
        	$dbh->prepare(
3596
    my $transfer = $item->get_transfer;
3596
			"update branchtransfers set datearrived = now(),tobranch=?,comments='wrongtransfer' where itemnumber= ? AND datearrived IS NULL"
3597
    $transfer->set({ datecancelled => dt_from_string, cancellation_reason => 'WrongTransfer' })->store();
3597
          	);
3598
3598
        	$sth->execute($FromLibrary,$itemNumber);
3599
    # second step: create a new transfer to the right location
3599
3600
    my $new_transfer = Koha::Item::Transfer->new(
3600
# second step create a new line of branchtransfer to the right location .
3601
        {
3601
	ModItemTransfer($itemNumber, $FromLibrary, $waitingAtLibrary);
3602
            itemnumber    => $itemNumber,
3602
3603
            daterequested => dt_from_string,
3603
#third step changing holdingbranch of item
3604
            datesent      => dt_from_string,
3604
    my $item = Koha::Items->find($itemNumber)->holdingbranch($FromLibrary)->store;
3605
            frombranch    => $FromLibrary,
3606
            tobranch      => $transfer->tobranch,
3607
            reason        => $transfer->reason,
3608
            comments      => $transfer->comments
3609
        }
3610
    )->store();
3605
}
3611
}
3606
3612
3607
=head2 CalcDateDue
3613
=head2 CalcDateDue
(-)a/circ/returns.pl (-8 / +6 lines)
Lines 132-142 foreach ( $query->param ) { Link Here
132
132
133
############
133
############
134
# Deal with the requests....
134
# Deal with the requests....
135
136
if ($query->param('WT-itemNumber')){
137
	updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From'));
138
}
139
140
my $itemnumber = $query->param('itemnumber');
135
my $itemnumber = $query->param('itemnumber');
141
if ( $query->param('reserve_id') ) {
136
if ( $query->param('reserve_id') ) {
142
    my $borrowernumber = $query->param('borrowernumber');
137
    my $borrowernumber = $query->param('borrowernumber');
Lines 389-400 if ( $messages->{'Wrongbranch'} ){ Link Here
389
# case of wrong transfert, if the document wasn't transferred to the right library (according to branchtransfer (tobranch) BDD)
384
# case of wrong transfert, if the document wasn't transferred to the right library (according to branchtransfer (tobranch) BDD)
390
385
391
if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
386
if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
387
388
    # Trigger modal to prompt librarian
392
    $template->param(
389
    $template->param(
393
        WrongTransfer  => 1,
390
        WrongTransfer  => 1,
394
        TransferWaitingAt => $messages->{'WrongTransfer'},
391
        TransferWaitingAt => $messages->{'WrongTransfer'},
395
        WrongTransferItem => $messages->{'WrongTransferItem'},
392
        WrongTransferItem => $messages->{'WrongTransferItem'},
393
        trigger           => $messages->{'TransferTrigger'},
396
    );
394
    );
397
395
396
    # Update the transfer to reflect the new item holdingbranch
397
	updateWrongTransfer($messages->{'WrongTransferItem'},$messages->{'WrongTransfer'}, $userenv_branch);
398
398
    my $reserve    = $messages->{'ResFound'};
399
    my $reserve    = $messages->{'ResFound'};
399
    if ( $reserve ) {
400
    if ( $reserve ) {
400
        my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
401
        my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
Lines 402-410 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { Link Here
402
            patron => $patron,
403
            patron => $patron,
403
        );
404
        );
404
    }
405
    }
405
    $template->param(
406
        wtransfertFrom  => $userenv_branch,
407
    );
408
}
406
}
409
407
410
#
408
#
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-2 / +2 lines)
Lines 432-438 Link Here
432
                                        <div class="modal-content">
432
                                        <div class="modal-content">
433
                                            <div class="modal-header">
433
                                            <div class="modal-header">
434
                                                <h3>
434
                                                <h3>
435
                                                    Please return item to: [% Branches.GetName( TransferWaitingAt ) | html %]
435
                                                    Wrong transfer detected, please return item to: [% Branches.GetName( TransferWaitingAt ) | html %]
436
                                                </h3>
436
                                                </h3>
437
                                            </div>
437
                                            </div>
438
                                            <div class="modal-body">
438
                                            <div class="modal-body">
Lines 446-451 Link Here
446
                                            <div class="modal-footer">
446
                                            <div class="modal-footer">
447
                                                <!-- CONFIRM -->
447
                                                <!-- CONFIRM -->
448
                                                <button type="button" data-dismiss="modal" class="btn btn-default approve"><i class="fa fa-check"></i> OK</button>
448
                                                <button type="button" data-dismiss="modal" class="btn btn-default approve"><i class="fa fa-check"></i> OK</button>
449
449
                                                <!-- PRINT SLIP -->
450
                                                <!-- PRINT SLIP -->
450
                                                <button type="button" data-dismiss="modal" class="btn btn-default openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber | uri %]&amp;&amp;branchcode=[% TransferWaitingAt | uri %]&amp;op=slip"><i class="fa fa-print"></i> Print transfer slip</button>
451
                                                <button type="button" data-dismiss="modal" class="btn btn-default openWin" data-url="transfer-slip.pl?transferitem=[% itemnumber | uri %]&amp;&amp;branchcode=[% TransferWaitingAt | uri %]&amp;op=slip"><i class="fa fa-print"></i> Print transfer slip</button>
451
                                                <!-- CANCEL TRANSFER -->
452
                                                <!-- CANCEL TRANSFER -->
452
- 

Return to bug 24434