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 = $item->request_transfer(
3600
# second step create a new line of branchtransfer to the right location .
3601
        {
3601
	ModItemTransfer($itemNumber, $FromLibrary, $waitingAtLibrary);
3602
            to            => $transfer->to_library,
3602
3603
            reason        => $transfer->reason,
3603
#third step changing holdingbranch of item
3604
            comment       => $transfer->comments,
3604
    my $item = Koha::Items->find($itemNumber)->holdingbranch($FromLibrary)->store;
3605
            ignore_limits => 1,
3606
            enqueue       => 1
3607
        }
3608
    );
3609
3610
    return $new_transfer;
3605
}
3611
}
3606
3612
3607
=head2 CalcDateDue
3613
=head2 CalcDateDue
(-)a/Koha/Item/Transfer.pm (+14 lines)
Lines 66-71 sub from_library { Link Here
66
    return Koha::Library->_new_from_dbic($from_library_rs);
66
    return Koha::Library->_new_from_dbic($from_library_rs);
67
}
67
}
68
68
69
=head3 to_library
70
71
  my $to_library = $transfer->to_library;
72
73
Returns the associated to_library for this transfer.
74
75
=cut
76
77
sub to_library {
78
    my ($self) = @_;
79
    my $to_library_rs = $self->_result->tobranch;
80
    return Koha::Library->_new_from_dbic($to_library_rs);
81
}
82
69
=head3 transit
83
=head3 transit
70
84
71
Set the transfer as in transit by updating the datesent time.
85
Set the transfer as in transit by updating the datesent time.
(-)a/circ/returns.pl (-9 / +21 lines)
Lines 55-60 use Koha::Checkouts; Link Here
55
use Koha::DateUtils;
55
use Koha::DateUtils;
56
use Koha::Holds;
56
use Koha::Holds;
57
use Koha::Items;
57
use Koha::Items;
58
use Koha::Item::Transfers;
58
use Koha::Patrons;
59
use Koha::Patrons;
59
60
60
my $query = CGI->new;
61
my $query = CGI->new;
Lines 132-142 foreach ( $query->param ) { Link Here
132
133
133
############
134
############
134
# Deal with the requests....
135
# 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');
136
my $itemnumber = $query->param('itemnumber');
141
if ( $query->param('reserve_id') ) {
137
if ( $query->param('reserve_id') ) {
142
    my $borrowernumber = $query->param('borrowernumber');
138
    my $borrowernumber = $query->param('borrowernumber');
Lines 190-195 if ( Link Here
190
my $dropboxmode = $query->param('dropboxmode');
186
my $dropboxmode = $query->param('dropboxmode');
191
my $dotransfer  = $query->param('dotransfer');
187
my $dotransfer  = $query->param('dotransfer');
192
my $canceltransfer = $query->param('canceltransfer');
188
my $canceltransfer = $query->param('canceltransfer');
189
my $transit = $query->param('transit');
193
my $dest = $query->param('dest');
190
my $dest = $query->param('dest');
194
#dropbox: get last open day (today - 1)
191
#dropbox: get last open day (today - 1)
195
my $dropboxdate = Koha::Checkouts::calculate_dropbox_date();
192
my $dropboxdate = Koha::Checkouts::calculate_dropbox_date();
Lines 227-233 if ($dotransfer){ Link Here
227
    ModItemTransfer($transferitem, $userenv_branch, $tobranch, $trigger);
224
    ModItemTransfer($transferitem, $userenv_branch, $tobranch, $trigger);
228
}
225
}
229
226
230
if ($canceltransfer){
227
if ($transit) {
228
    my $transfer = Koha::Item::Transfers->find($transit);
229
    if ( $canceltransfer ) {
230
        $transfer->cancel({ reason => 'Manual', force => 1});
231
        $template->param( transfercancelled => 1);
232
    } else {
233
        $transfer->transit;
234
    }
235
} elsif ($canceltransfer){
231
    my $item = Koha::Items->find($itemnumber);
236
    my $item = Koha::Items->find($itemnumber);
232
    my $transfer = $item->get_transfer;
237
    my $transfer = $item->get_transfer;
233
    $transfer->cancel({ reason => 'Manual', force => 1});
238
    $transfer->cancel({ reason => 'Manual', force => 1});
Lines 239-244 if ($canceltransfer){ Link Here
239
    }
244
    }
240
}
245
}
241
246
247
242
# actually return book and prepare item table.....
248
# actually return book and prepare item table.....
243
my $returnbranch;
249
my $returnbranch;
244
if ($barcode) {
250
if ($barcode) {
Lines 389-398 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)
395
# case of wrong transfert, if the document wasn't transferred to the right library (according to branchtransfer (tobranch) BDD)
390
396
391
if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
397
if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
398
399
    # Trigger modal to prompt librarian
392
    $template->param(
400
    $template->param(
393
        WrongTransfer  => 1,
401
        WrongTransfer  => 1,
394
        TransferWaitingAt => $messages->{'WrongTransfer'},
402
        TransferWaitingAt => $messages->{'WrongTransfer'},
395
        WrongTransferItem => $messages->{'WrongTransferItem'},
403
        WrongTransferItem => $messages->{'WrongTransferItem'},
404
        trigger           => $messages->{'TransferTrigger'},
405
    );
406
407
    # Update the transfer to reflect the new item holdingbranch
408
	my $new_transfer = updateWrongTransfer($messages->{'WrongTransferItem'},$messages->{'WrongTransfer'}, $userenv_branch);
409
    $template->param(
410
        NewTransfer => $new_transfer->id
396
    );
411
    );
397
412
398
    my $reserve    = $messages->{'ResFound'};
413
    my $reserve    = $messages->{'ResFound'};
Lines 402-410 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { Link Here
402
            patron => $patron,
417
            patron => $patron,
403
        );
418
        );
404
    }
419
    }
405
    $template->param(
406
        wtransfertFrom  => $userenv_branch,
407
    );
408
}
420
}
409
421
410
#
422
#
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-33 / +40 lines)
Lines 430-467 Link Here
430
                                [% END %]
430
                                [% END %]
431
                                    <div class="modal-dialog">
431
                                    <div class="modal-dialog">
432
                                        <div class="modal-content">
432
                                        <div class="modal-content">
433
                                            <div class="modal-header">
433
                                            <form method="post" action="returns.pl" name="wrongtransferform" id="wrongtransferform">
434
                                                <h3>
434
                                                <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
435
                                                    Please return item to: [% Branches.GetName( TransferWaitingAt ) | html %]
435
                                                <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
436
                                                </h3>
436
                                                <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
437
                                            </div>
437
                                                <input type="hidden" name="transit" value="[% NewTransfer | html %]" />
438
                                            <div class="modal-body">
438
                                                [% FOREACH inputloo IN inputloop %]
439
                                                <p>
439
                                                    <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" />
440
                                                    <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber | uri %]">
440
                                                    <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" />
441
                                                        [% item.barcode | html %]: [% title | html %]
441
                                                    <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" />
442
                                                    </a>
442
                                                [% END %]
443
                                                </p>
443
444
                                                [% INCLUDE all_checkin_messages %]
444
                                                <div class="modal-header">
445
                                            </div>
445
                                                    <h3>
446
                                            <div class="modal-footer">
446
                                                        Wrong transfer detected, please return item to: [% Branches.GetName( TransferWaitingAt ) | html %]
447
                                                <!-- CONFIRM -->
447
                                                    </h3>
448
                                                <button type="button" data-dismiss="modal" class="btn btn-default approve"><i class="fa fa-check"></i> OK</button>
448
                                                </div>
449
                                                <!-- PRINT SLIP -->
449
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>
450
                                                <div class="modal-body">
451
                                                <!-- CANCEL TRANSFER -->
451
                                                    <p>
452
                                                <form method="post" action="returns.pl" name="mainform">
452
                                                        <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber | uri %]">[% item.barcode | html %]: [% title | html %]</a>
453
                                                    <button class="btn btn-default deny" type="submit"><i class="fa fa-times"></i> Cancel transfer</button>
453
                                                    </p>
454
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
454
455
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
455
                                                    [% INCLUDE all_checkin_messages %]
456
                                                    <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
456
                                                </div>
457
                                                    <input type="hidden" name="canceltransfer" value="1" />
457
458
                                                    [% FOREACH inputloo IN inputloop %]
458
                                                <div class="modal-footer">
459
                                                        <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" />
459
                                                    <!-- CONFIRM -->
460
                                                        <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" />
460
                                                    <button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> OK</button>
461
                                                        <input type="hidden" name="bn-[% inputloo.counter | html %]" value="[% inputloo.borrowernumber | html %]" />
461
                                                    <!-- PRINT SLIP -->
462
                                                    [% END %]
462
                                                    <button type="button" data-dismiss="modal" class="btn btn-default transit openWin" data-transfer="[% NewTransfer | html %]" 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>
463
                                                </form> <!-- /mainform -->
463
                                                    <!-- CANCEL TRANSFER -->
464
                                            </div> <!-- /.modal-footer -->
464
                                                    <button type="button" data-dismiss="modal" class="btn btn-default deny cancel"><i class="fa fa-times"></i> Cancel transfer</button>
465
                                                </div> <!-- /.modal-footer -->
466
                                            </form> <!-- /wrongtransferform -->
465
                                        </div> <!-- /.modal-content -->
467
                                        </div> <!-- /.modal-content -->
466
                                    </div> <!-- /.modal-dialog -->
468
                                    </div> <!-- /.modal-dialog -->
467
                                </div> <!-- /#wrong-transfer-modal -->
469
                                </div> <!-- /#wrong-transfer-modal -->
Lines 1126-1131 Link Here
1126
                Dopop( $(this).data("url") );
1128
                Dopop( $(this).data("url") );
1127
            });
1129
            });
1128
1130
1131
            $('.cancel').on("click",function(e){
1132
                var docancel = $("<input>").attr("type", "hidden").attr("name", "canceltransfer").val(1);
1133
                $('#wrongtransferform').append(docancel);
1134
                this.form.submit();
1135
            });
1136
1129
            $('.print').on("click",function(e){
1137
            $('.print').on("click",function(e){
1130
                this.form.print_slip.value = 1;
1138
                this.form.print_slip.value = 1;
1131
                let barcode = document.getElementById('confirm-hold-barcode');
1139
                let barcode = document.getElementById('confirm-hold-barcode');
1132
- 

Return to bug 24434