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

(-)a/C4/Circulation.pm (-8 / +177 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use DateTime;
22
use DateTime;
23
use POSIX qw( floor );
23
use POSIX qw( floor );
24
use Encode;
24
use Encode;
25
use JSON;
25
26
26
use C4::Context;
27
use C4::Context;
27
use C4::Stats qw( UpdateStats );
28
use C4::Stats qw( UpdateStats );
Lines 318-323 A recall for this item was found, and the item needs to be transferred to the re Link Here
318
319
319
=cut
320
=cut
320
321
322
my $query = CGI->new;
323
324
my $stickyduedate      = $query->param('stickyduedate');
325
my $duedatespec        = $query->param('duedatespec');
326
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec;
327
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) {
328
    undef $restoreduedatespec;
329
}
330
my $issueconfirmed = $query->param('issueconfirmed');
331
my $cancelreserve  = $query->param('cancelreserve');
332
my $cancel_recall  = $query->param('cancel_recall');
333
my $recall_id      = $query->param('recall_id');
334
my $debt_confirmed = $query->param('debt_confirmed') || 0;     # Don't show the debt error dialog twice
335
my $charges        = $query->param('charges')        || q{};
336
321
sub transferbook {
337
sub transferbook {
322
    my $params = shift;
338
    my $params = shift;
323
    my $tbr      = $params->{to_branch};
339
    my $tbr      = $params->{to_branch};
Lines 802-810 sub CanBookBeIssued { Link Here
802
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) );
818
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) );
803
819
804
    my $now = dt_from_string();
820
    my $now = dt_from_string();
821
    my $message;
822
    my @message;
823
805
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
824
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
825
806
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
826
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
807
         $needsconfirmation{INVALID_DATE} = $duedate;
827
         $needsconfirmation{INVALID_DATE} = $duedate;
828
        if ($issueconfirmed) {
829
            if ($message) {
830
                $message = "$message + sticky due date is invalid or due date in the past";
831
            } else {
832
                $message = "sticky due date is invalid or due date in the past";
833
            }
834
            push( @message, "sticky due date is invalid or due date in the past" );
835
        }
836
808
    }
837
    }
809
838
810
    my $fees = Koha::Charges::Fees->new(
839
    my $fees = Koha::Charges::Fees->new(
Lines 849-854 sub CanBookBeIssued { Link Here
849
    }
878
    }
850
    if ( $patron->is_debarred ) {
879
    if ( $patron->is_debarred ) {
851
        $issuingimpossible{DEBARRED} = 1;
880
        $issuingimpossible{DEBARRED} = 1;
881
        if ($issueconfirmed) {
882
            if ($message) {
883
                $message = "$message + borrower is restricted";
884
            } else {
885
                $message = "borrower is restricted";
886
            }
887
            push( @message, "borrower is restricted" );
888
        }
852
    }
889
    }
853
890
854
    if ( $patron->is_expired ) {
891
    if ( $patron->is_expired ) {
Lines 921-930 sub CanBookBeIssued { Link Here
921
    } else {
958
    } else {
922
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
959
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
923
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
960
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
961
            if ($issueconfirmed) {
962
                if ($message) {
963
                    $message = "$message + borrower had amend";
964
                } else {
965
                    $message = "borrower had amend";
966
                }
967
                push( @message, "borrower had amend" );
968
            }
924
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
969
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
925
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
970
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
926
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
971
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
927
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
972
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
973
            if ($issueconfirmed) {
974
                if ($message) {
975
                    $message = "$message + borrower had amend";
976
                } else {
977
                    $message = "borrower had amend";
978
                }
979
                push( @message, "borrower had amend" );
980
            }
928
        }
981
        }
929
    }
982
    }
930
983
Lines 1002-1014 sub CanBookBeIssued { Link Here
1002
        } else {
1055
        } else {
1003
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1056
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1004
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1057
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1005
            }
1058
            } else {
1006
            else {
1007
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1059
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1008
                $needsconfirmation{issued_firstname} = $patron->firstname;
1060
                $needsconfirmation{issued_firstname} = $patron->firstname;
1009
                $needsconfirmation{issued_surname} = $patron->surname;
1061
                $needsconfirmation{issued_surname} = $patron->surname;
1010
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1062
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1011
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1063
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1064
                if ($issueconfirmed) {
1065
                    if ($message) {
1066
                        $message = "$message + item is checked out for someone else ";
1067
                    } else {
1068
                        $message = "item is checked out for someone else";
1069
                    }
1070
                    push( @message, "item is checked out for someone else" );
1071
                }
1012
            }
1072
            }
1013
        }
1073
        }
1014
    }
1074
    }
Lines 1032-1037 sub CanBookBeIssued { Link Here
1032
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1092
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1033
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1093
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1034
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1094
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1095
            if ($issueconfirmed) {
1096
                if ($message) {
1097
                    $message = "$message + too many checkout";
1098
                } else {
1099
                    $message = "too many checkout";
1100
                }
1101
                push( @message, "too many checkout" );
1102
            }
1035
        } else {
1103
        } else {
1036
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1104
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1037
            $issuingimpossible{current_loan_count}        = $toomany->{count};
1105
            $issuingimpossible{current_loan_count}        = $toomany->{count};
Lines 1059-1064 sub CanBookBeIssued { Link Here
1059
        }else{
1127
        }else{
1060
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1128
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1061
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1129
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1130
            if ($issueconfirmed) {
1131
                if ($message) {
1132
                    $message = "$message + item not for loan";
1133
                } else {
1134
                    $message = "item not for loan";
1135
                }
1136
                push( @message, "item not for loan" );
1137
            }
1062
        }
1138
        }
1063
    }
1139
    }
1064
    else {
1140
    else {
Lines 1105-1110 sub CanBookBeIssued { Link Here
1105
        my $code = $av->count ? $av->next->lib : '';
1181
        my $code = $av->count ? $av->next->lib : '';
1106
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1182
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1107
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1183
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1184
        if ($issueconfirmed) {
1185
            if ($message) {
1186
                $message = "$message + item lost";
1187
            } else {
1188
                $message = "item lost";
1189
            }
1190
            push( @message, "item lost" );
1191
        }
1108
    }
1192
    }
1109
    if ( C4::Context->preference("IndependentBranches") ) {
1193
    if ( C4::Context->preference("IndependentBranches") ) {
1110
        my $userenv = C4::Context->userenv;
1194
        my $userenv = C4::Context->userenv;
Lines 1201-1206 sub CanBookBeIssued { Link Here
1201
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1285
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1202
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1286
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1203
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1287
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1288
                    if ($issueconfirmed) {
1289
                        if ($message) {
1290
                            $message =
1291
                                "$message + item is on reserve and waiting, but has been reserved by some other patron.";
1292
                        } else {
1293
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1294
                        }
1295
                        push( @message, "item is on reserve and waiting, but has been reserved by some other patron" );
1296
                    }
1204
                }
1297
                }
1205
                elsif ( $restype eq "Reserved" ) {
1298
                elsif ( $restype eq "Reserved" ) {
1206
                    # The item is on reserve for someone else.
1299
                    # The item is on reserve for someone else.
Lines 1212-1217 sub CanBookBeIssued { Link Here
1212
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1305
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1213
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1306
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1214
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1307
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1308
                    if ($issueconfirmed) {
1309
                        if ($message) {
1310
                            $message = "$message + item is on reserve for someone else";
1311
                        } else {
1312
                            $message = "item is on reserve for someone else";
1313
                        }
1314
                        push( @message, "item is on reserve for someone else" );
1315
                    }
1215
                }
1316
                }
1216
                elsif ( $restype eq "Transferred" ) {
1317
                elsif ( $restype eq "Transferred" ) {
1217
                    # The item is determined hold being transferred for someone else.
1318
                    # The item is determined hold being transferred for someone else.
Lines 1223-1228 sub CanBookBeIssued { Link Here
1223
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1324
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1224
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1325
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1225
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1326
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1327
                    if ($issueconfirmed) {
1328
                        if ($message) {
1329
                            $message = "$message + item is determined hold being transferred for someone else";
1330
                        } else {
1331
                            $message = "item is determined hold being transferred for someone else";
1332
                        }
1333
                        push( @message, "item is determined hold being transferred for someone else" );
1334
                    }
1226
                }
1335
                }
1227
                elsif ( $restype eq "Processing" ) {
1336
                elsif ( $restype eq "Processing" ) {
1228
                    # The item is determined hold being processed for someone else.
1337
                    # The item is determined hold being processed for someone else.
Lines 1234-1239 sub CanBookBeIssued { Link Here
1234
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1343
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1235
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1344
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1236
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1345
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1346
                    if ($issueconfirmed) {
1347
                        if ($message) {
1348
                            $message = "$message + item is determined hold being processed for someone else";
1349
                        } else {
1350
                            $message = "item is determined hold being processed for someone else";
1351
                        }
1352
                        push( @message, "item is determined hold being processed for someone else" );
1353
                    }
1237
                }
1354
                }
1238
            }
1355
            }
1239
        }
1356
        }
Lines 1277-1282 sub CanBookBeIssued { Link Here
1277
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1394
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1278
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1395
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1279
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1396
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1397
            if ($message) {
1398
                $message = "$message + age restriction";
1399
            } else {
1400
                $message = "age restriction";
1401
            }
1402
            push( @message, "age restriction" );
1280
        }
1403
        }
1281
        else {
1404
        else {
1282
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1405
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
Lines 1333-1338 sub CanBookBeIssued { Link Here
1333
        }
1456
        }
1334
    }
1457
    }
1335
1458
1459
    my $borrower = $patron;
1460
    my $user       = C4::Context->userenv->{number};
1461
    my $branchcode = C4::Context->userenv->{branch};
1462
    my $item       = Koha::Items->find( { barcode => $barcode } );
1463
    my $itemnumber = $item->itemnumber;
1464
1465
    # action, cardnumber, barcode, date, heure, user, branche
1466
    if ($issueconfirmed) {
1467
1468
        my $infos = (
1469
            {
1470
                message        => \@message,
1471
                borrowernumber => $borrower->borrowernumber,
1472
                barcode        => $barcode,
1473
                manager_id     => $user,
1474
                branchcode     => $branchcode,
1475
            }
1476
        );
1477
1478
        my $json_infos = JSON->new->utf8->pretty->encode($infos);
1479
        $json_infos =~ s/"/'/g;
1480
1481
        logaction(
1482
            "CIRCULATION", "ISSUE",
1483
            $borrower->{'borrowernumber'},
1484
            $json_infos,
1485
        ) if C4::Context->preference("IssueLog");
1486
    }
1487
1488
1336
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1489
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1337
}
1490
}
1338
1491
Lines 2354-2362 sub AddReturn { Link Here
2354
            if ( $transfer->tobranch eq $branch ) {
2507
            if ( $transfer->tobranch eq $branch ) {
2355
                $transfer->receive;
2508
                $transfer->receive;
2356
                $messages->{'TransferArrived'} = $transfer->frombranch;
2509
                $messages->{'TransferArrived'} = $transfer->frombranch;
2510
2357
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2511
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2358
                $validTransfer = 1
2512
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2359
                  if defined $transfer->reason && $transfer->reason eq 'Reserve';
2360
            }
2513
            }
2361
            else {
2514
            else {
2362
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2515
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
Lines 3079-3084 sub CanBookBeRenewed { Link Here
3079
    return ( 0, "on_reserve" )
3232
    return ( 0, "on_reserve" )
3080
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3233
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3081
3234
3235
    my $issuing_rule = Koha::CirculationRules->get_effective_rules(
3236
        {
3237
            categorycode => $patron->categorycode,
3238
            itemtype     => $item->effective_itemtype,
3239
            branchcode   => $branchcode,
3240
            rules        => [
3241
                'renewalsallowed',
3242
                'lengthunit',
3243
                'unseen_renewals_allowed'
3244
            ]
3245
        }
3246
    );
3247
3248
    return ( 0, "too_many" )
3249
        if not $issuing_rule->{renewalsallowed}
3250
        or $issuing_rule->{renewalsallowed} <= $issue->renewals_count;
3082
3251
3083
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3252
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3084
    my @fillable_holds = ();
3253
    my @fillable_holds = ();
Lines 3207-3214 fallback to a true value Link Here
3207
3376
3208
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3377
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3209
3378
3210
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing
3379
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing should be skipped for this renewal.
3211
should be skipped for this renewal.
3212
3380
3213
=cut
3381
=cut
3214
3382
Lines 3410-3418 sub AddRenewal { Link Here
3410
        });
3578
        });
3411
    });
3579
    });
3412
3580
3413
    unless( $skip_record_index ){
3581
    unless ($skip_record_index) {
3582
3414
        # We index now, after the transaction is committed
3583
        # We index now, after the transaction is committed
3415
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
3584
        my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
3416
        $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3585
        $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3417
    }
3586
    }
3418
3587
(-)a/circ/circulation.pl (-31 / +64 lines)
Lines 38-44 use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue AddReturn ); Link Here
38
use C4::Members;
38
use C4::Members;
39
use C4::Biblio qw( TransformMarcToKoha );
39
use C4::Biblio qw( TransformMarcToKoha );
40
use C4::Search qw( new_record_from_zebra );
40
use C4::Search qw( new_record_from_zebra );
41
use C4::Reserves qw( ModReserveAffect );
41
use C4::Reserves;
42
use C4::Log qw( logaction );
42
use Koha::Holds;
43
use Koha::Holds;
43
use C4::Context;
44
use C4::Context;
44
use CGI::Session;
45
use CGI::Session;
Lines 240-246 if ( @$barcodes == 0 && $charges eq 'yes' ) { Link Here
240
# STEP 2 : FIND BORROWER
241
# STEP 2 : FIND BORROWER
241
# if there is a list of find borrowers....
242
# if there is a list of find borrowers....
242
#
243
#
243
my $message;
244
244
if ($findborrower) {
245
if ($findborrower) {
245
    Koha::Plugins->call( 'patron_barcode_transform', \$findborrower );
246
    Koha::Plugins->call( 'patron_barcode_transform', \$findborrower );
246
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
247
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
Lines 319-324 if ($patron) { Link Here
319
# STEP 3 : ISSUING
320
# STEP 3 : ISSUING
320
#
321
#
321
#
322
#
323
my $message;
324
my @message;
325
322
if (@$barcodes && $op eq 'cud-checkout') {
326
if (@$barcodes && $op eq 'cud-checkout') {
323
    my $checkout_infos;
327
    my $checkout_infos;
324
    for my $barcode ( @$barcodes ) {
328
    for my $barcode ( @$barcodes ) {
Lines 488-526 if (@$barcodes && $op eq 'cud-checkout') { Link Here
488
                }
492
                }
489
            }
493
            }
490
        }
494
        }
491
        unless ($confirm_required) {
495
            unless ($confirm_required) {
492
            my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
496
                my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
493
            if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
497
                if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
494
                my $recall = Koha::Recalls->find(
498
                    my $recall = Koha::Recalls->find(
499
                        {
500
                            biblio_id => $item->biblionumber,
501
                            item_id   => [ undef,       $item->itemnumber ],
502
                            status    => [ 'requested', 'waiting' ],
503
                            completed => 0,
504
                            patron_id => $patron->borrowernumber,
505
                        }
506
                    );
507
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
508
509
                }
510
511
                # If booked (alerts or confirmation) update datedue to end of booking
512
                if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
513
                    $datedue = $booked->end_date;
514
                }
515
                my $issue = AddIssue(
516
                    $patron, $barcode, $datedue,
517
                    $cancelreserve,
518
                    undef, undef,
495
                    {
519
                    {
496
                        biblio_id => $item->biblionumber,
520
                        onsite_checkout        => $onsite_checkout,        auto_renew => $session->param('auto_renew'),
497
                        item_id   => [ undef,       $item->itemnumber ],
521
                        switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall,
498
                        status    => [ 'requested', 'waiting' ],
522
                        recall_id              => $recall_id,
499
                        completed => 0,
500
                        patron_id => $patron->borrowernumber,
501
                    }
523
                    }
502
                );
524
                );
503
                $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
525
                $template_params->{issue} = $issue;
504
            }
526
505
527
                my $borrower       = $patron;
506
            # If booked (alerts or confirmation) update datedue to end of booking
528
                my $borrowernumber = $patron->borrowernumber;
507
            if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
529
                my $user           = C4::Context->userenv->{number};
508
                $datedue = $booked->end_date;
530
                my $branchcode     = C4::Context->userenv->{branch};
509
            }
531
                $message = "Restriction overridden temporarily";
510
            my $issue = AddIssue(
532
                @message = ("Restriction overridden temporarily");
511
                $patron, $barcode, $datedue,
533
512
                $cancelreserve,
534
                if ($issueconfirmed) {
513
                undef, undef,
535
                    my $infos = (
514
                {
536
                        {
515
                    onsite_checkout        => $onsite_checkout,        auto_renew    => $session->param('auto_renew'),
537
                            message        => \@message,
516
                    switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall,
538
                            borrowernumber => $borrowernumber,
517
                    recall_id              => $recall_id,
539
                            barcode        => $barcode,
540
                            manager_id     => $user,
541
                            branchcode     => $branchcode,
542
                        }
543
                    );
544
545
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
546
                    $json_infos =~ s/"/'/g;
547
548
                    logaction(
549
                        "CIRCULATION", "ISSUE",
550
                        $borrower->{'borrowernumber'},
551
                        $json_infos,
552
                    ) if C4::Context->preference("IssueLog");
518
                }
553
                }
519
            );
554
                $session->clear('auto_renew');
520
            $template_params->{issue} = $issue;
555
                $inprocess = 1;
521
            $session->clear('auto_renew');
556
            }
522
            $inprocess = 1;
523
        }
524
    }
557
    }
525
558
526
    if ($needsconfirmation->{RESERVE_WAITING} or $needsconfirmation->{RESERVED} or $needsconfirmation->{TRANSFERRED} or $needsconfirmation->{PROCESSING}){
559
    if ($needsconfirmation->{RESERVE_WAITING} or $needsconfirmation->{RESERVED} or $needsconfirmation->{TRANSFERRED} or $needsconfirmation->{PROCESSING}){
(-)a/circ/renew.pl (-2 / +53 lines)
Lines 24-29 use C4::Context; Link Here
24
use C4::Auth qw( get_template_and_user );
24
use C4::Auth qw( get_template_and_user );
25
use C4::Output qw( output_html_with_http_headers );
25
use C4::Output qw( output_html_with_http_headers );
26
use C4::Circulation qw( barcodedecode CanBookBeRenewed GetLatestAutoRenewDate AddRenewal );
26
use C4::Circulation qw( barcodedecode CanBookBeRenewed GetLatestAutoRenewDate AddRenewal );
27
use C4::Log qw( logaction );
27
use Koha::DateUtils qw( dt_from_string );
28
use Koha::DateUtils qw( dt_from_string );
28
use Koha::Database;
29
use Koha::Database;
29
use Koha::BiblioFrameworks;
30
use Koha::BiblioFrameworks;
Lines 64-71 if ($op eq 'cud-renew' && $barcode) { Link Here
64
        if ($checkout) {
65
        if ($checkout) {
65
66
66
            $patron = $checkout->patron;
67
            $patron = $checkout->patron;
67
68
            my $borrower       = $patron;
68
            if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) {
69
            my $borrowernumber = $borrower->borrowernumber;
70
            my $user           = C4::Context->userenv->{number};
71
            my $branchcode     = C4::Context->userenv->{branch};
72
            my $message;
73
            my @message;
74
75
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
69
                my $can_renew;
76
                my $can_renew;
70
                my $info;
77
                my $info;
71
                ( $can_renew, $error, $info ) =
78
                ( $can_renew, $error, $info ) =
Lines 75-80 if ($op eq 'cud-renew' && $barcode) { Link Here
75
                    if ($override_holds) {
82
                    if ($override_holds) {
76
                        $can_renew = 1;
83
                        $can_renew = 1;
77
                        $error     = undef;
84
                        $error     = undef;
85
86
                        $message = "Override Renew hold for another";
87
                        @message = ("Override Renew hold for another");
88
89
                        my $infos = (
90
                            {
91
                                message        => \@message,
92
                                borrowernumber => $borrowernumber,
93
                                barcode        => $barcode,
94
                                manager_id     => $user,
95
                                branchcode     => $branchcode,
96
                            }
97
                        );
98
99
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
100
                        $json_infos =~ s/"/'/g;
101
102
                        logaction(
103
                            "CIRCULATION", "RENEWAL",
104
                            $borrower->{'borrowernumber'},
105
                            $json_infos,
106
                        ) if C4::Context->preference("RenewalLog");
78
                    }
107
                    }
79
                    else {
108
                    else {
80
                        $can_renew = 0;
109
                        $can_renew = 0;
Lines 107-112 if ($op eq 'cud-renew' && $barcode) { Link Here
107
                        }
136
                        }
108
                    );
137
                    );
109
                    $template->param( date_due => $date_due );
138
                    $template->param( date_due => $date_due );
139
140
                    $message = "Override limit Renew";
141
                    @message = ("Override limit Renew");
142
143
                    my $infos = (
144
                        {
145
                            message        => \@message,
146
                            borrowernumber => $borrowernumber,
147
                            barcode        => $barcode,
148
                            manager_id     => $user,
149
                            branchcode     => $branchcode,
150
                        }
151
                    );
152
153
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
154
                    $json_infos =~ s/"/'/g;
155
156
                    logaction(
157
                        "CIRCULATION", "RENEWAL",
158
                        $borrower->{'borrowernumber'},
159
                        $json_infos,
160
                    ) if C4::Context->preference("RenewalLog");
110
                }
161
                }
111
            }
162
            }
112
            else {
163
            else {
(-)a/circ/returns.pl (-1 / +28 lines)
Lines 43-48 use C4::Members; Link Here
43
use C4::Output qw( output_html_with_http_headers );
43
use C4::Output qw( output_html_with_http_headers );
44
use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves );
44
use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves );
45
use C4::RotatingCollections;
45
use C4::RotatingCollections;
46
use C4::Log qw( logaction );
46
use Koha::AuthorisedValues;
47
use Koha::AuthorisedValues;
47
use Koha::BiblioFrameworks;
48
use Koha::BiblioFrameworks;
48
use Koha::Calendar;
49
use Koha::Calendar;
Lines 189-194 if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve') { Link Here
189
            diffbranch     => 1,
190
            diffbranch     => 1,
190
        );
191
        );
191
    }
192
    }
193
} else {
194
    my $message    = "return an element that is reserved";
195
    my @message    = ("return an element that is reserved");
196
    my $user       = C4::Context->userenv->{number};
197
    my $branchcode = C4::Context->userenv->{branch};
198
    my $barcode    = $query->param('barcode');
199
200
    my $infos = (
201
        {
202
            message => \@message,
203
204
            #'card number' => $cardnumber,
205
            barcode    => $barcode,
206
            manager_id => $user,
207
            branchcode => $branchcode,
208
        }
209
    );
210
211
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
212
    $json_infos =~ s/"/'/g;
213
214
    logaction(
215
        "CIRCULATION", "RETURN",
216
        $session,
217
        $json_infos,
218
    ) if C4::Context->preference("ReturnLog");
192
}
219
}
193
220
194
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
221
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
Lines 452-458 if ($barcode && ( $op eq 'cud-checkin' || $op eq 'cud-affect_reserve' ) ) { Link Here
452
    }
479
    }
453
480
454
    # Mark missing bundle items as lost and report unexpected items
481
    # Mark missing bundle items as lost and report unexpected items
455
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') && !$query->param('do_not_verify_items_bundle_contents') ) {
482
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') ) {
456
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
483
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
457
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
484
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
458
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
485
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
(-)a/reserve/request.pl (-5 / +36 lines)
Lines 27-32 script to place reserves/requests Link Here
27
=cut
27
=cut
28
28
29
use Modern::Perl;
29
use Modern::Perl;
30
use Data::Dumper;
30
31
31
use CGI qw ( -utf8 );
32
use CGI qw ( -utf8 );
32
use List::MoreUtils qw( uniq );
33
use List::MoreUtils qw( uniq );
Lines 40-45 use C4::Serials qw( CountSubscriptionFromBiblionumber ); Link Here
40
use C4::Circulation qw( _GetCircControlBranch GetBranchItemRule );
41
use C4::Circulation qw( _GetCircControlBranch GetBranchItemRule );
41
use Koha::DateUtils qw( dt_from_string );
42
use Koha::DateUtils qw( dt_from_string );
42
use C4::Search qw( enabled_staff_search_views );
43
use C4::Search qw( enabled_staff_search_views );
44
use C4::Log qw( logaction );
43
45
44
use Koha::Biblios;
46
use Koha::Biblios;
45
use Koha::Checkouts;
47
use Koha::Checkouts;
Lines 540-554 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
540
542
541
                                my $default_pickup_location;
543
                                my $default_pickup_location;
542
544
543
                                ($default_pickup_location) = grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
545
                                ($default_pickup_location) =
546
                                    grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
544
547
545
                                $item->{default_pickup_location} = $default_pickup_location;
548
                                $item->{default_pickup_location} = $default_pickup_location;
546
                            }
549
                            } else {
547
                            else {
550
                                $item->{available}    = 0;
548
                                $item->{available} = 0;
549
                                $item->{not_holdable} = "no_valid_pickup_location";
551
                                $item->{not_holdable} = "no_valid_pickup_location";
550
                            }
552
                            }
551
                        } else { $num_alreadyheld++ }
553
                        } else {
554
                            $num_alreadyheld++;
555
                        }
556
557
                        my $borrower       = $patron;
558
                        my $borrowernumber = $patron->borrowernumber;
559
                        my $user           = C4::Context->userenv->{number};
560
                        my $branchcode     = C4::Context->userenv->{branch};
561
                        my $message        = "Override limitation of hold";
562
                        my @message        = ("Override limitation of hold");
563
                        my $barcode        = $item->{barcode};
564
565
                        my $infos = (
566
                            {
567
                                message        => \@message,
568
                                borrowernumber => $borrowernumber,
569
                                barcode        => $barcode,
570
                                manager_id     => $user,
571
                                branchcode     => $branchcode,
572
                            }
573
                        );
574
575
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
576
                        $json_infos =~ s/"/'/g;
577
578
                        logaction(
579
                            "HOLD", "ISSUE",
580
                            $borrower->{'borrowernumber'},
581
                            $json_infos,
582
                        ) if C4::Context->preference("IssueLog");
552
583
553
                        push( @available_itemtypes, $item->{itype} );
584
                        push( @available_itemtypes, $item->{itype} );
554
                    } else {
585
                    } else {
(-)a/svc/renew (-3 / +56 lines)
Lines 26-31 use Try::Tiny; Link Here
26
use C4::Circulation qw( AddRenewal CanBookBeRenewed );
26
use C4::Circulation qw( AddRenewal CanBookBeRenewed );
27
use C4::Context;
27
use C4::Context;
28
use C4::Auth qw(check_cookie_auth);
28
use C4::Auth qw(check_cookie_auth);
29
use C4::Log qw( logaction );
29
30
30
use Koha::DateUtils qw(output_pref dt_from_string);
31
use Koha::DateUtils qw(output_pref dt_from_string);
31
32
Lines 52-57 my $date_due; Link Here
52
if ( $input->param('date_due') ) {
53
if ( $input->param('date_due') ) {
53
    $date_due = dt_from_string( scalar $input->param('date_due') );
54
    $date_due = dt_from_string( scalar $input->param('date_due') );
54
}
55
}
56
my $borrower = Koha::Patrons->find($borrowernumber);
57
my $user     = C4::Context->userenv->{'number'};
58
my $message;
59
my @message;
55
60
56
my $data;
61
my $data;
57
$data->{itemnumber} = $itemnumber;
62
$data->{itemnumber} = $itemnumber;
Lines 65-73 my $item = Koha::Items->find($itemnumber); Link Here
65
    CanBookBeRenewed( $patron, $item->checkout, $override_limit );
70
    CanBookBeRenewed( $patron, $item->checkout, $override_limit );
66
71
67
# If we're allowing reserved items to be renewed...
72
# If we're allowing reserved items to be renewed...
68
if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference('AllowRenewalOnHoldOverride')) {
73
if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference('AllowRenewalOnHoldOverride') ) {
69
    $data->{renew_okay} = 1;
74
    $data->{renew_okay} = 1;
70
    $data->{error} = undef;
75
    $data->{error}      = undef;
76
77
    $message = "Override Renew hold for another";
78
    @message = ("Override Renew hold for another");
79
80
    my $infos = (
81
        {
82
            message        => \@message,
83
            borrowernumber => $borrowernumber,
84
            barcode        => $item->barcode,
85
            manager_id     => $user,
86
            branchcode     => $branchcode,
87
        }
88
    );
89
90
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
91
    $json_infos =~ s/"/'/g;
92
93
    logaction(
94
        "CIRCULATION", "RENEWAL",
95
        $borrower->{'borrowernumber'},
96
        $json_infos,
97
    ) if C4::Context->preference("IssueLog");
98
}
99
100
if ( $data->{error} && $data->{error} eq 'too_many' && C4::Context->preference('AllowRenewalLimitOverride') ) {
101
    $data->{renew_okay} = 1;
102
    $data->{error}      = undef;
103
104
    $message = "Override limit Renew";
105
    @message = ("Override limit Renew");
106
107
    my $infos = (
108
        {
109
            message        => \@message,
110
            borrowernumber => $borrowernumber,
111
            barcode        => $item->barcode,
112
            manager_id     => $user,
113
            branchcode     => $branchcode,
114
        }
115
    );
116
117
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
118
    $json_infos =~ s/"/'/g;
119
120
    logaction(
121
        "CIRCULATION", "RENEWAL",
122
        $borrower->{'borrowernumber'},
123
        $json_infos,
124
    ) if C4::Context->preference("IssueLog");
71
}
125
}
72
126
73
if ( $data->{renew_okay} || ( $seen && $data->{error} eq 'too_unseen') ) {
127
if ( $data->{renew_okay} || ( $seen && $data->{error} eq 'too_unseen') ) {
74
- 

Return to bug 9762