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 317-322 A recall for this item was found, and the item needs to be transferred to the re Link Here
317
318
318
=cut
319
=cut
319
320
321
my $query = CGI->new;
322
323
my $stickyduedate      = $query->param('stickyduedate');
324
my $duedatespec        = $query->param('duedatespec');
325
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec;
326
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) {
327
    undef $restoreduedatespec;
328
}
329
my $issueconfirmed = $query->param('issueconfirmed');
330
my $cancelreserve  = $query->param('cancelreserve');
331
my $cancel_recall  = $query->param('cancel_recall');
332
my $recall_id      = $query->param('recall_id');
333
my $debt_confirmed = $query->param('debt_confirmed') || 0;     # Don't show the debt error dialog twice
334
my $charges        = $query->param('charges')        || q{};
335
320
sub transferbook {
336
sub transferbook {
321
    my $params = shift;
337
    my $params = shift;
322
    my $tbr      = $params->{to_branch};
338
    my $tbr      = $params->{to_branch};
Lines 801-809 sub CanBookBeIssued { Link Here
801
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) );
817
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) );
802
818
803
    my $now = dt_from_string();
819
    my $now = dt_from_string();
820
    my $message;
821
    my @message;
822
804
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
823
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
824
805
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
825
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
806
         $needsconfirmation{INVALID_DATE} = $duedate;
826
         $needsconfirmation{INVALID_DATE} = $duedate;
827
        if ($issueconfirmed) {
828
            if ($message) {
829
                $message = "$message + sticky due date is invalid or due date in the past";
830
            } else {
831
                $message = "sticky due date is invalid or due date in the past";
832
            }
833
            push( @message, "sticky due date is invalid or due date in the past" );
834
        }
835
807
    }
836
    }
808
837
809
    my $fees = Koha::Charges::Fees->new(
838
    my $fees = Koha::Charges::Fees->new(
Lines 848-853 sub CanBookBeIssued { Link Here
848
    }
877
    }
849
    if ( $patron->is_debarred ) {
878
    if ( $patron->is_debarred ) {
850
        $issuingimpossible{DEBARRED} = 1;
879
        $issuingimpossible{DEBARRED} = 1;
880
        if ($issueconfirmed) {
881
            if ($message) {
882
                $message = "$message + borrower is restricted";
883
            } else {
884
                $message = "borrower is restricted";
885
            }
886
            push( @message, "borrower is restricted" );
887
        }
851
    }
888
    }
852
889
853
    if ( $patron->is_expired ) {
890
    if ( $patron->is_expired ) {
Lines 914-923 sub CanBookBeIssued { Link Here
914
    else {
951
    else {
915
        if ( $non_issues_charges > $amountlimit && $allowfineoverride ) {
952
        if ( $non_issues_charges > $amountlimit && $allowfineoverride ) {
916
            $needsconfirmation{DEBT} = $non_issues_charges;
953
            $needsconfirmation{DEBT} = $non_issues_charges;
954
            if ($issueconfirmed) {
955
                if ($message) {
956
                    $message = "$message + borrower had amend";
957
                } else {
958
                    $message = "borrower had amend";
959
                }
960
                push( @message, "borrower had amend" );
961
            }
917
        } elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) {
962
        } elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) {
918
            $issuingimpossible{DEBT} = $non_issues_charges;
963
            $issuingimpossible{DEBT} = $non_issues_charges;
919
        } elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) {
964
        } elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) {
920
            $needsconfirmation{DEBT} = $non_issues_charges;
965
            $needsconfirmation{DEBT} = $non_issues_charges;
966
            if ($issueconfirmed) {
967
                if ($message) {
968
                    $message = "$message + borrower had amend";
969
                } else {
970
                    $message = "borrower had amend";
971
                }
972
                push( @message, "borrower had amend" );
973
            }
921
        }
974
        }
922
    }
975
    }
923
976
Lines 994-1006 sub CanBookBeIssued { Link Here
994
        } else {
1047
        } else {
995
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1048
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
996
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1049
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
997
            }
1050
            } else {
998
            else {
999
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1051
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1000
                $needsconfirmation{issued_firstname} = $patron->firstname;
1052
                $needsconfirmation{issued_firstname} = $patron->firstname;
1001
                $needsconfirmation{issued_surname} = $patron->surname;
1053
                $needsconfirmation{issued_surname} = $patron->surname;
1002
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1054
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1003
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1055
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1056
                if ($issueconfirmed) {
1057
                    if ($message) {
1058
                        $message = "$message + item is checked out for someone else ";
1059
                    } else {
1060
                        $message = "item is checked out for someone else";
1061
                    }
1062
                    push( @message, "item is checked out for someone else" );
1063
                }
1004
            }
1064
            }
1005
        }
1065
        }
1006
    }
1066
    }
Lines 1024-1029 sub CanBookBeIssued { Link Here
1024
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1084
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1025
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1085
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1026
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1086
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1087
            if ($issueconfirmed) {
1088
                if ($message) {
1089
                    $message = "$message + too many checkout";
1090
                } else {
1091
                    $message = "too many checkout";
1092
                }
1093
                push( @message, "too many checkout" );
1094
            }
1027
        } else {
1095
        } else {
1028
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1096
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1029
            $issuingimpossible{current_loan_count}        = $toomany->{count};
1097
            $issuingimpossible{current_loan_count}        = $toomany->{count};
Lines 1051-1056 sub CanBookBeIssued { Link Here
1051
        }else{
1119
        }else{
1052
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1120
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1053
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1121
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1122
            if ($issueconfirmed) {
1123
                if ($message) {
1124
                    $message = "$message + item not for loan";
1125
                } else {
1126
                    $message = "item not for loan";
1127
                }
1128
                push( @message, "item not for loan" );
1129
            }
1054
        }
1130
        }
1055
    }
1131
    }
1056
    else {
1132
    else {
Lines 1097-1102 sub CanBookBeIssued { Link Here
1097
        my $code = $av->count ? $av->next->lib : '';
1173
        my $code = $av->count ? $av->next->lib : '';
1098
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1174
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1099
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1175
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1176
        if ($issueconfirmed) {
1177
            if ($message) {
1178
                $message = "$message + item lost";
1179
            } else {
1180
                $message = "item lost";
1181
            }
1182
            push( @message, "item lost" );
1183
        }
1100
    }
1184
    }
1101
    if ( C4::Context->preference("IndependentBranches") ) {
1185
    if ( C4::Context->preference("IndependentBranches") ) {
1102
        my $userenv = C4::Context->userenv;
1186
        my $userenv = C4::Context->userenv;
Lines 1193-1198 sub CanBookBeIssued { Link Here
1193
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1277
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1194
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1278
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1195
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1279
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1280
                    if ($issueconfirmed) {
1281
                        if ($message) {
1282
                            $message =
1283
                                "$message + item is on reserve and waiting, but has been reserved by some other patron.";
1284
                        } else {
1285
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1286
                        }
1287
                        push( @message, "item is on reserve and waiting, but has been reserved by some other patron" );
1288
                    }
1196
                }
1289
                }
1197
                elsif ( $restype eq "Reserved" ) {
1290
                elsif ( $restype eq "Reserved" ) {
1198
                    # The item is on reserve for someone else.
1291
                    # The item is on reserve for someone else.
Lines 1204-1209 sub CanBookBeIssued { Link Here
1204
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1297
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1205
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1298
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1206
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1299
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1300
                    if ($issueconfirmed) {
1301
                        if ($message) {
1302
                            $message = "$message + item is on reserve for someone else";
1303
                        } else {
1304
                            $message = "item is on reserve for someone else";
1305
                        }
1306
                        push( @message, "item is on reserve for someone else" );
1307
                    }
1207
                }
1308
                }
1208
                elsif ( $restype eq "Transferred" ) {
1309
                elsif ( $restype eq "Transferred" ) {
1209
                    # The item is determined hold being transferred for someone else.
1310
                    # The item is determined hold being transferred for someone else.
Lines 1215-1220 sub CanBookBeIssued { Link Here
1215
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1316
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1216
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1317
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1217
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1318
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1319
                    if ($issueconfirmed) {
1320
                        if ($message) {
1321
                            $message = "$message + item is determined hold being transferred for someone else";
1322
                        } else {
1323
                            $message = "item is determined hold being transferred for someone else";
1324
                        }
1325
                        push( @message, "item is determined hold being transferred for someone else" );
1326
                    }
1218
                }
1327
                }
1219
                elsif ( $restype eq "Processing" ) {
1328
                elsif ( $restype eq "Processing" ) {
1220
                    # The item is determined hold being processed for someone else.
1329
                    # The item is determined hold being processed for someone else.
Lines 1226-1231 sub CanBookBeIssued { Link Here
1226
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1335
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1227
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1336
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1228
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1337
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1338
                    if ($issueconfirmed) {
1339
                        if ($message) {
1340
                            $message = "$message + item is determined hold being processed for someone else";
1341
                        } else {
1342
                            $message = "item is determined hold being processed for someone else";
1343
                        }
1344
                        push( @message, "item is determined hold being processed for someone else" );
1345
                    }
1229
                }
1346
                }
1230
            }
1347
            }
1231
        }
1348
        }
Lines 1269-1274 sub CanBookBeIssued { Link Here
1269
    if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) {
1386
    if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) {
1270
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1387
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1271
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1388
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1389
            if ($message) {
1390
                $message = "$message + age restriction";
1391
            } else {
1392
                $message = "age restriction";
1393
            }
1394
            push( @message, "age restriction" );
1272
        }
1395
        }
1273
        else {
1396
        else {
1274
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1397
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
Lines 1325-1330 sub CanBookBeIssued { Link Here
1325
        }
1448
        }
1326
    }
1449
    }
1327
1450
1451
    my $borrower = $patron;
1452
    my $user       = C4::Context->userenv->{number};
1453
    my $branchcode = C4::Context->userenv->{branch};
1454
    my $item       = Koha::Items->find( { barcode => $barcode } );
1455
    my $itemnumber = $item->itemnumber;
1456
1457
    # action, cardnumber, barcode, date, heure, user, branche
1458
    if ($issueconfirmed) {
1459
1460
        my $infos = (
1461
            {
1462
                message        => \@message,
1463
                borrowernumber => $borrower->borrowernumber,
1464
                barcode        => $barcode,
1465
                manager_id     => $user,
1466
                branchcode     => $branchcode,
1467
            }
1468
        );
1469
1470
        my $json_infos = JSON->new->utf8->pretty->encode($infos);
1471
        $json_infos =~ s/"/'/g;
1472
1473
        logaction(
1474
            "CIRCULATION", "ISSUE",
1475
            $borrower->{'borrowernumber'},
1476
            $json_infos,
1477
        ) if C4::Context->preference("IssueLog");
1478
    }
1479
1480
1328
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1481
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1329
}
1482
}
1330
1483
Lines 2343-2351 sub AddReturn { Link Here
2343
            if ( $transfer->tobranch eq $branch ) {
2496
            if ( $transfer->tobranch eq $branch ) {
2344
                $transfer->receive;
2497
                $transfer->receive;
2345
                $messages->{'TransferArrived'} = $transfer->frombranch;
2498
                $messages->{'TransferArrived'} = $transfer->frombranch;
2499
2346
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2500
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2347
                $validTransfer = 1
2501
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2348
                  if defined $transfer->reason && $transfer->reason eq 'Reserve';
2349
            }
2502
            }
2350
            else {
2503
            else {
2351
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2504
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
Lines 3053-3058 sub CanBookBeRenewed { Link Here
3053
    return ( 0, "on_reserve" )
3206
    return ( 0, "on_reserve" )
3054
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3207
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3055
3208
3209
    my $issuing_rule = Koha::CirculationRules->get_effective_rules(
3210
        {
3211
            categorycode => $patron->categorycode,
3212
            itemtype     => $item->effective_itemtype,
3213
            branchcode   => $branchcode,
3214
            rules        => [
3215
                'renewalsallowed',
3216
                'lengthunit',
3217
                'unseen_renewals_allowed'
3218
            ]
3219
        }
3220
    );
3221
3222
    return ( 0, "too_many" )
3223
        if not $issuing_rule->{renewalsallowed}
3224
        or $issuing_rule->{renewalsallowed} <= $issue->renewals_count;
3056
3225
3057
    my ( $status, $matched_reserve, $possible_holds ) = CheckReserves($item);
3226
    my ( $status, $matched_reserve, $possible_holds ) = CheckReserves($item);
3058
    my @fillable_holds = ();
3227
    my @fillable_holds = ();
Lines 3181-3188 fallback to a true value Link Here
3181
3350
3182
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3351
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3183
3352
3184
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing
3353
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing should be skipped for this renewal.
3185
should be skipped for this renewal.
3186
3354
3187
=cut
3355
=cut
3188
3356
Lines 3384-3392 sub AddRenewal { Link Here
3384
        });
3552
        });
3385
    });
3553
    });
3386
3554
3387
    unless( $skip_record_index ){
3555
    unless ($skip_record_index) {
3556
3388
        # We index now, after the transaction is committed
3557
        # We index now, after the transaction is committed
3389
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
3558
        my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
3390
        $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3559
        $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3391
    }
3560
    }
3392
3561
(-)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 239-245 if ( @$barcodes == 0 && $charges eq 'yes' ) { Link Here
239
# STEP 2 : FIND BORROWER
240
# STEP 2 : FIND BORROWER
240
# if there is a list of find borrowers....
241
# if there is a list of find borrowers....
241
#
242
#
242
my $message;
243
243
if ($findborrower) {
244
if ($findborrower) {
244
    Koha::Plugins->call( 'patron_barcode_transform', \$findborrower );
245
    Koha::Plugins->call( 'patron_barcode_transform', \$findborrower );
245
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
246
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
Lines 318-323 if ($patron) { Link Here
318
# STEP 3 : ISSUING
319
# STEP 3 : ISSUING
319
#
320
#
320
#
321
#
322
my $message;
323
my @message;
324
321
if (@$barcodes && $op eq 'cud-checkout') {
325
if (@$barcodes && $op eq 'cud-checkout') {
322
    my $checkout_infos;
326
    my $checkout_infos;
323
    for my $barcode ( @$barcodes ) {
327
    for my $barcode ( @$barcodes ) {
Lines 455-493 if (@$barcodes && $op eq 'cud-checkout') { Link Here
455
                }
459
                }
456
            }
460
            }
457
        }
461
        }
458
        unless ($confirm_required) {
462
            unless ($confirm_required) {
459
            my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
463
                my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
460
            if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
464
                if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
461
                my $recall = Koha::Recalls->find(
465
                    my $recall = Koha::Recalls->find(
466
                        {
467
                            biblio_id => $item->biblionumber,
468
                            item_id   => [ undef,       $item->itemnumber ],
469
                            status    => [ 'requested', 'waiting' ],
470
                            completed => 0,
471
                            patron_id => $patron->borrowernumber,
472
                        }
473
                    );
474
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
475
476
                }
477
478
                # If booked (alerts or confirmation) update datedue to end of booking
479
                if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
480
                    $datedue = $booked->end_date;
481
                }
482
                my $issue = AddIssue(
483
                    $patron, $barcode, $datedue,
484
                    $cancelreserve,
485
                    undef, undef,
462
                    {
486
                    {
463
                        biblio_id => $item->biblionumber,
487
                        onsite_checkout        => $onsite_checkout,        auto_renew => $session->param('auto_renew'),
464
                        item_id   => [ undef,       $item->itemnumber ],
488
                        switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall,
465
                        status    => [ 'requested', 'waiting' ],
489
                        recall_id              => $recall_id,
466
                        completed => 0,
467
                        patron_id => $patron->borrowernumber,
468
                    }
490
                    }
469
                );
491
                );
470
                $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
492
                $template_params->{issue} = $issue;
471
            }
493
472
494
                my $borrower       = $patron;
473
            # If booked (alerts or confirmation) update datedue to end of booking
495
                my $borrowernumber = $patron->borrowernumber;
474
            if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
496
                my $user           = C4::Context->userenv->{number};
475
                $datedue = $booked->end_date;
497
                my $branchcode     = C4::Context->userenv->{branch};
476
            }
498
                $message = "Restriction overridden temporarily";
477
            my $issue = AddIssue(
499
                @message = ("Restriction overridden temporarily");
478
                $patron, $barcode, $datedue,
500
479
                $cancelreserve,
501
                if ($issueconfirmed) {
480
                undef, undef,
502
                    my $infos = (
481
                {
503
                        {
482
                    onsite_checkout        => $onsite_checkout,        auto_renew    => $session->param('auto_renew'),
504
                            message        => \@message,
483
                    switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall,
505
                            borrowernumber => $borrowernumber,
484
                    recall_id              => $recall_id,
506
                            barcode        => $barcode,
507
                            manager_id     => $user,
508
                            branchcode     => $branchcode,
509
                        }
510
                    );
511
512
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
513
                    $json_infos =~ s/"/'/g;
514
515
                    logaction(
516
                        "CIRCULATION", "ISSUE",
517
                        $borrower->{'borrowernumber'},
518
                        $json_infos,
519
                    ) if C4::Context->preference("IssueLog");
485
                }
520
                }
486
            );
521
                $session->clear('auto_renew');
487
            $template_params->{issue} = $issue;
522
                $inprocess = 1;
488
            $session->clear('auto_renew');
523
            }
489
            $inprocess = 1;
490
        }
491
    }
524
    }
492
525
493
    if ($needsconfirmation->{RESERVE_WAITING} or $needsconfirmation->{RESERVED} or $needsconfirmation->{TRANSFERRED} or $needsconfirmation->{PROCESSING}){
526
    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 GetOtherReserves );
44
use C4::Reserves qw( ModReserve ModReserveAffect GetOtherReserves );
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 179-184 if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve') { Link Here
179
            diffbranch     => 1,
180
            diffbranch     => 1,
180
        );
181
        );
181
    }
182
    }
183
} else {
184
    my $message    = "return an element that is reserved";
185
    my @message    = ("return an element that is reserved");
186
    my $user       = C4::Context->userenv->{number};
187
    my $branchcode = C4::Context->userenv->{branch};
188
    my $barcode    = $query->param('barcode');
189
190
    my $infos = (
191
        {
192
            message => \@message,
193
194
            #'card number' => $cardnumber,
195
            barcode    => $barcode,
196
            manager_id => $user,
197
            branchcode => $branchcode,
198
        }
199
    );
200
201
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
202
    $json_infos =~ s/"/'/g;
203
204
    logaction(
205
        "CIRCULATION", "RETURN",
206
        $session,
207
        $json_infos,
208
    ) if C4::Context->preference("ReturnLog");
182
}
209
}
183
210
184
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
211
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
Lines 432-438 if ($barcode && $op eq 'cud-checkin') { Link Here
432
    }
459
    }
433
460
434
    # Mark missing bundle items as lost and report unexpected items
461
    # Mark missing bundle items as lost and report unexpected items
435
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') && !$query->param('do_not_verify_items_bundle_contents') ) {
462
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') ) {
436
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
463
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
437
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
464
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
438
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
465
        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 539-553 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
539
541
540
                                my $default_pickup_location;
542
                                my $default_pickup_location;
541
543
542
                                ($default_pickup_location) = grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
544
                                ($default_pickup_location) =
545
                                    grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
543
546
544
                                $item->{default_pickup_location} = $default_pickup_location;
547
                                $item->{default_pickup_location} = $default_pickup_location;
545
                            }
548
                            } else {
546
                            else {
549
                                $item->{available}    = 0;
547
                                $item->{available} = 0;
548
                                $item->{not_holdable} = "no_valid_pickup_location";
550
                                $item->{not_holdable} = "no_valid_pickup_location";
549
                            }
551
                            }
550
                        } else { $num_alreadyheld++ }
552
                        } else {
553
                            $num_alreadyheld++;
554
                        }
555
556
                        my $borrower       = $patron;
557
                        my $borrowernumber = $patron->borrowernumber;
558
                        my $user           = C4::Context->userenv->{number};
559
                        my $branchcode     = C4::Context->userenv->{branch};
560
                        my $message        = "Override limitation of hold";
561
                        my @message        = ("Override limitation of hold");
562
                        my $barcode        = $item->{barcode};
563
564
                        my $infos = (
565
                            {
566
                                message        => \@message,
567
                                borrowernumber => $borrowernumber,
568
                                barcode        => $barcode,
569
                                manager_id     => $user,
570
                                branchcode     => $branchcode,
571
                            }
572
                        );
573
574
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
575
                        $json_infos =~ s/"/'/g;
576
577
                        logaction(
578
                            "HOLD", "ISSUE",
579
                            $borrower->{'borrowernumber'},
580
                            $json_infos,
581
                        ) if C4::Context->preference("IssueLog");
551
582
552
                        push( @available_itemtypes, $item->{itype} );
583
                        push( @available_itemtypes, $item->{itype} );
553
                    } else {
584
                    } 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