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

(-)a/C4/Circulation.pm (-15 / +151 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 914-923 sub CanBookBeIssued { Link Here
914
    else {
943
    else {
915
        if ( $non_issues_charges > $amountlimit && $allowfineoverride ) {
944
        if ( $non_issues_charges > $amountlimit && $allowfineoverride ) {
916
            $needsconfirmation{DEBT} = $non_issues_charges;
945
            $needsconfirmation{DEBT} = $non_issues_charges;
946
            if ($issueconfirmed) {
947
                if ($message) {
948
                    $message = "$message + borrower had amend";
949
                } else {
950
                    $message = "borrower had amend";
951
                }
952
                push(@message,  "borrower had amend");
953
            }
917
        } elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) {
954
        } elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) {
918
            $issuingimpossible{DEBT} = $non_issues_charges;
955
            $issuingimpossible{DEBT} = $non_issues_charges;
919
        } elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) {
956
        } elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) {
920
            $needsconfirmation{DEBT} = $non_issues_charges;
957
            $needsconfirmation{DEBT} = $non_issues_charges;
958
            if ($issueconfirmed) {
959
                if ($message) {
960
                    $message = "$message + borrower had amend";
961
                } else {
962
                    $message = "borrower had amend";
963
                }
964
                push(@message,  "borrower had amend");
965
            }
921
        }
966
        }
922
    }
967
    }
923
968
Lines 994-1006 sub CanBookBeIssued { Link Here
994
        } else {
1039
        } else {
995
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1040
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
996
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1041
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
997
            }
1042
            } else {
998
            else {
999
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1043
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1000
                $needsconfirmation{issued_firstname} = $patron->firstname;
1044
                $needsconfirmation{issued_firstname} = $patron->firstname;
1001
                $needsconfirmation{issued_surname} = $patron->surname;
1045
                $needsconfirmation{issued_surname} = $patron->surname;
1002
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1046
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1003
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1047
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1048
                if ($issueconfirmed) {
1049
                    if ($message) {
1050
                        $message = "$message + item is checked out for someone else ";
1051
                    } else {
1052
                        $message = "item is checked out for someone else";
1053
                    }
1054
                    push(@message,  "item is checked out for someone else");
1055
                }
1004
            }
1056
            }
1005
        }
1057
        }
1006
    }
1058
    }
Lines 1024-1029 sub CanBookBeIssued { Link Here
1024
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1076
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1025
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1077
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1026
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1078
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1079
            if ($issueconfirmed) {
1080
                if ($message) {
1081
                    $message = "$message + too many checkout";
1082
                } else {
1083
                    $message = "too many checkout";
1084
                }
1085
                push(@message, "too many checkout");
1086
            }
1027
        } else {
1087
        } else {
1028
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1088
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1029
            $issuingimpossible{current_loan_count}        = $toomany->{count};
1089
            $issuingimpossible{current_loan_count}        = $toomany->{count};
Lines 1051-1056 sub CanBookBeIssued { Link Here
1051
        }else{
1111
        }else{
1052
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1112
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1053
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1113
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1114
            if ($issueconfirmed) {
1115
                if ($message) {
1116
                    $message = "$message + item not for loan";
1117
                } else {
1118
                    $message = "item not for loan";
1119
                }
1120
                push(@message, "item not for loan");
1121
            }
1054
        }
1122
        }
1055
    }
1123
    }
1056
    else {
1124
    else {
Lines 1097-1102 sub CanBookBeIssued { Link Here
1097
        my $code = $av->count ? $av->next->lib : '';
1165
        my $code = $av->count ? $av->next->lib : '';
1098
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1166
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1099
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1167
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1168
        if ($issueconfirmed) {
1169
            if ($message) {
1170
                $message = "$message + item lost";
1171
            } else {
1172
                $message = "item lost";
1173
            }
1174
            push(@message, "item lost");
1175
        }
1100
    }
1176
    }
1101
    if ( C4::Context->preference("IndependentBranches") ) {
1177
    if ( C4::Context->preference("IndependentBranches") ) {
1102
        my $userenv = C4::Context->userenv;
1178
        my $userenv = C4::Context->userenv;
Lines 1193-1198 sub CanBookBeIssued { Link Here
1193
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1269
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1194
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1270
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1195
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1271
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1272
                    if ($issueconfirmed) {
1273
                        if($message) {
1274
                            $message = "$message + item is on reserve and waiting, but has been reserved by some other patron.";
1275
                        } else {
1276
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1277
                        }
1278
                        push(@message, "item is on reserve and waiting, but has been reserved by some other patron");
1279
                    }
1196
                }
1280
                }
1197
                elsif ( $restype eq "Reserved" ) {
1281
                elsif ( $restype eq "Reserved" ) {
1198
                    # The item is on reserve for someone else.
1282
                    # The item is on reserve for someone else.
Lines 1204-1209 sub CanBookBeIssued { Link Here
1204
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1288
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1205
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1289
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1206
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1290
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1291
                    if ($issueconfirmed) {
1292
                        if($message) {
1293
                            $message = "$message + item is on reserve for someone else";
1294
                        } else {
1295
                            $message = "item is on reserve for someone else";
1296
                        }
1297
                        push(@message, "item is on reserve for someone else");
1298
                    }
1207
                }
1299
                }
1208
                elsif ( $restype eq "Transferred" ) {
1300
                elsif ( $restype eq "Transferred" ) {
1209
                    # The item is determined hold being transferred for someone else.
1301
                    # The item is determined hold being transferred for someone else.
Lines 1215-1220 sub CanBookBeIssued { Link Here
1215
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1307
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1216
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1308
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1217
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1309
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1310
                    if ($issueconfirmed) {
1311
                        if($message) {
1312
                            $message = "$message + item is determined hold being transferred for someone else";
1313
                        } else {
1314
                            $message = "item is determined hold being transferred for someone else";
1315
                        }
1316
                        push(@message, "item is determined hold being transferred for someone else");
1317
                    }
1218
                }
1318
                }
1219
                elsif ( $restype eq "Processing" ) {
1319
                elsif ( $restype eq "Processing" ) {
1220
                    # The item is determined hold being processed for someone else.
1320
                    # The item is determined hold being processed for someone else.
Lines 1226-1231 sub CanBookBeIssued { Link Here
1226
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1326
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1227
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1327
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1228
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1328
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1329
                    if ($issueconfirmed) {
1330
                        if($message) {
1331
                            $message = "$message + item is determined hold being processed for someone else";
1332
                        } else {
1333
                            $message = "item is determined hold being processed for someone else";
1334
                        }
1335
                        push(@message, "item is determined hold being processed for someone else");
1336
                    }
1229
                }
1337
                }
1230
            }
1338
            }
1231
        }
1339
        }
Lines 1269-1274 sub CanBookBeIssued { Link Here
1269
    if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) {
1377
    if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) {
1270
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1378
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1271
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1379
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1380
            if($message) {
1381
                $message = "$message + age restriction";
1382
            } else {
1383
                $message = "age restriction";
1384
            }
1385
            push(@message, "age restriction");
1272
        }
1386
        }
1273
        else {
1387
        else {
1274
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1388
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
Lines 1325-1334 sub CanBookBeIssued { Link Here
1325
        }
1439
        }
1326
    }
1440
    }
1327
1441
1442
    my $borrower = $patron;
1443
    #my $borrowernumber = $patron->cardnumber;
1444
    my $user = C4::Context->userenv->{number};
1445
    my $branchcode = C4::Context->userenv->{branch};
1446
    my $item = Koha::Items->find( { barcode => $barcode } );
1447
    my $itemnumber = $item->itemnumber;
1448
1449
    # action, cardnumber, barcode, date, heure, user, branche
1450
    if ($issueconfirmed) {
1451
1452
        my $infos = ({
1453
            message     => \@message,
1454
            borrowernumber => $borrower->borrowernumber,
1455
            barcode => $barcode,
1456
            manager_id => $user,
1457
            branchcode =>  $branchcode,
1458
        });
1459
1460
        my $json_infos = JSON->new->utf8->pretty->encode($infos);
1461
        $json_infos =~ s/"/'/g;
1462
1463
        logaction(
1464
            "CIRCULATION", "ISSUE",
1465
            $borrower->{'borrowernumber'},
1466
            $json_infos,
1467
        ) if C4::Context->preference("IssueLog");
1468
    }
1469
1470
1328
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1471
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1329
}
1472
}
1330
1473
1331
=head2 CanBookBeReturned
1474
=head2 CanBookBeReturnedcd
1332
1475
1333
  ($returnallowed, $message) = CanBookBeReturned($item, $branch)
1476
  ($returnallowed, $message) = CanBookBeReturned($item, $branch)
1334
1477
Lines 2344-2351 sub AddReturn { Link Here
2344
                $transfer->receive;
2487
                $transfer->receive;
2345
                $messages->{'TransferArrived'} = $transfer->frombranch;
2488
                $messages->{'TransferArrived'} = $transfer->frombranch;
2346
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2489
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2347
                $validTransfer = 1
2490
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2348
                  if defined $transfer->reason && $transfer->reason eq 'Reserve';
2349
            }
2491
            }
2350
            else {
2492
            else {
2351
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2493
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
Lines 3181-3189 fallback to a true value Link Here
3181
3323
3182
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3324
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3183
3325
3184
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing
3185
should be skipped for this renewal.
3186
3187
=cut
3326
=cut
3188
3327
3189
sub AddRenewal {
3328
sub AddRenewal {
Lines 3294-3300 sub AddRenewal { Link Here
3294
        $renews = ( $item_object->renewals || 0 ) + 1;
3433
        $renews = ( $item_object->renewals || 0 ) + 1;
3295
        $item_object->renewals($renews);
3434
        $item_object->renewals($renews);
3296
        $item_object->onloan($datedue);
3435
        $item_object->onloan($datedue);
3297
        # Don't index as we are in a transaction, skip hardcoded here
3436
        # Don't index as we are in a transaction
3298
        $item_object->store({ log_action => 0, skip_record_index => 1 });
3437
        $item_object->store({ log_action => 0, skip_record_index => 1 });
3299
3438
3300
        # Charge a new rental fee, if applicable
3439
        # Charge a new rental fee, if applicable
Lines 3383-3394 sub AddRenewal { Link Here
3383
            }
3522
            }
3384
        });
3523
        });
3385
    });
3524
    });
3386
3525
    # We index now, after the transaction is committed
3387
    unless( $skip_record_index ){
3526
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
3388
        # We index now, after the transaction is committed
3527
    $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3389
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
3390
        $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3391
    }
3392
3528
3393
    return $datedue;
3529
    return $datedue;
3394
}
3530
}
(-)a/circ/circulation.pl (-2 / +33 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 313-318 if ($patron) { Link Here
313
# STEP 3 : ISSUING
314
# STEP 3 : ISSUING
314
#
315
#
315
#
316
#
317
my $message;
318
my @message;
319
316
if (@$barcodes && $op eq 'cud-checkout') {
320
if (@$barcodes && $op eq 'cud-checkout') {
317
    my $checkout_infos;
321
    my $checkout_infos;
318
    for my $barcode ( @$barcodes ) {
322
    for my $barcode ( @$barcodes ) {
Lines 463-468 if (@$barcodes && $op eq 'cud-checkout') { Link Here
463
                    }
467
                    }
464
                );
468
                );
465
                $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
469
                $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
470
466
            }
471
            }
467
472
468
            # If booked (alerts or confirmation) update datedue to end of booking
473
            # If booked (alerts or confirmation) update datedue to end of booking
Lines 480-485 if (@$barcodes && $op eq 'cud-checkout') { Link Here
480
                }
485
                }
481
            );
486
            );
482
            $template_params->{issue} = $issue;
487
            $template_params->{issue} = $issue;
488
489
            my $borrower = $patron;
490
            my $borrowernumber = $patron->borrowernumber;
491
            my $user = C4::Context->userenv->{number};
492
            my $branchcode = C4::Context->userenv->{branch};
493
            $message = "Restriction overridden temporarily";
494
            @message = ("Restriction overridden temporarily");
495
496
            if ($issueconfirmed) {
497
                my $infos = ({
498
                    message    => \@message,
499
                    borrowernumber => $borrowernumber,
500
                    barcode => $barcode,
501
                    manager_id => $user,
502
                    branchcode =>  $branchcode,
503
                });
504
505
                my $json_infos = JSON->new->utf8->pretty->encode($infos);
506
                $json_infos =~ s/"/'/g;
507
508
                logaction(
509
                    "CIRCULATION", "ISSUE",
510
                    $borrower->{'borrowernumber'},
511
                    $json_infos,
512
                ) if C4::Context->preference("IssueLog");
513
            }
483
            $session->clear('auto_renew');
514
            $session->clear('auto_renew');
484
            $inprocess = 1;
515
            $inprocess = 1;
485
        }
516
        }
(-)a/circ/renew.pl (-2 / +48 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 63-71 if ($op eq 'cud-renew' && $barcode) { Link Here
63
64
64
        if ($checkout) {
65
        if ($checkout) {
65
66
66
            $patron = $checkout->patron;
67
            $borrower = $issue->patron();
68
            my $borrowernumber = $borrower->borrowernumber;
69
            my $user = C4::Context->userenv->{number};
70
            my $branchcode = C4::Context->userenv->{branch};
71
            my $message;
72
            my @message;
67
73
68
            if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) {
74
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
69
                my $can_renew;
75
                my $can_renew;
70
                my $info;
76
                my $info;
71
                ( $can_renew, $error, $info ) =
77
                ( $can_renew, $error, $info ) =
Lines 75-80 if ($op eq 'cud-renew' && $barcode) { Link Here
75
                    if ($override_holds) {
81
                    if ($override_holds) {
76
                        $can_renew = 1;
82
                        $can_renew = 1;
77
                        $error     = undef;
83
                        $error     = undef;
84
85
                        $message = "Override Renew hold for another";
86
                        @message = ("Override Renew hold for another");
87
88
                        my $infos = ({
89
                            message     => \@message,
90
                            borrowernumber => $borrowernumber,
91
                            barcode => $barcode,
92
                            manager_id => $user,
93
                            branchcode =>  $branchcode,
94
                        });
95
96
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
97
                        $json_infos =~ s/"/'/g;
98
99
                        logaction(
100
                            "CIRCULATION", "RENEWAL",
101
                            $borrower->{'borrowernumber'},
102
                            $json_infos,
103
                        ) if C4::Context->preference("RenewalLog");
78
                    }
104
                    }
79
                    else {
105
                    else {
80
                        $can_renew = 0;
106
                        $can_renew = 0;
Lines 107-112 if ($op eq 'cud-renew' && $barcode) { Link Here
107
                        }
133
                        }
108
                    );
134
                    );
109
                    $template->param( date_due => $date_due );
135
                    $template->param( date_due => $date_due );
136
137
                    $message = "Override limit Renew";
138
                    @message = ("Override limit Renew");
139
140
                    my $infos = ({
141
                        message    => \@message,
142
                        borrowernumber => $borrowernumber,
143
                        barcode => $barcode,
144
                        manager_id => $user,
145
                        branchcode =>  $branchcode,
146
                    });
147
148
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
149
                    $json_infos =~ s/"/'/g;
150
151
                    logaction(
152
                        "CIRCULATION", "RENEWAL",
153
                        $borrower->{'borrowernumber'},
154
                        $json_infos,
155
                    ) if C4::Context->preference("RenewalLog");
110
                }
156
                }
111
            }
157
            }
112
            else {
158
            else {
(-)a/circ/returns.pl (-1 / +25 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
        message    => \@message,
192
        #'card number' => $cardnumber,
193
        barcode    => $barcode,
194
        manager_id => $user,
195
        branchcode => $branchcode,
196
    });
197
198
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
199
    $json_infos =~ s/"/'/g;
200
201
    logaction(
202
        "CIRCULATION", "RETURN",
203
        $session,
204
        $json_infos,
205
    ) if C4::Context->preference("ReturnLog");
182
}
206
}
183
207
184
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
208
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
Lines 432-438 if ($barcode && $op eq 'cud-checkin') { Link Here
432
    }
456
    }
433
457
434
    # Mark missing bundle items as lost and report unexpected items
458
    # 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') ) {
459
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') ) {
436
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
460
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
437
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
461
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
438
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
462
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
(-)a/reserve/request.pl (-8 / +62 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 509-515 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
509
                            && !$exceeded_maxreserves
511
                            && !$exceeded_maxreserves
510
                            && $can_item_be_reserved eq 'OK'
512
                            && $can_item_be_reserved eq 'OK'
511
                            && IsAvailableForItemLevelRequest($item_object, $patron, undef)
513
                            && IsAvailableForItemLevelRequest($item_object, $patron, undef)
512
                        ) || C4::Context->preference('AllowHoldPolicyOverride')
514
                        ) #|| C4::Context->preference('AllowHoldPolicyOverride')
513
                             # If AllowHoldPolicyOverride is set, it overrides EVERY restriction
515
                             # If AllowHoldPolicyOverride is set, it overrides EVERY restriction
514
                             # not just branch item rules
516
                             # not just branch item rules
515
                      )
517
                      )
Lines 524-540 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
524
                            my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
526
                            my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
525
                            $item->{default_pickup_location} = $default_pickup_location;
527
                            $item->{default_pickup_location} = $default_pickup_location;
526
                        }
528
                        }
527
                        elsif ( C4::Context->preference('AllowHoldPolicyOverride') ){
529
                        # elsif ( C4::Context->preference('AllowHoldPolicyOverride') ){
528
                             $num_items_available++;
530
                        #      $num_items_available++;
529
                             $item->{override} = 1;
531
                        #      $item->{override} = 1;
530
                            my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
532
                        #     my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
531
                            $item->{default_pickup_location} = $default_pickup_location;
533
                        #     $item->{default_pickup_location} = $default_pickup_location;
532
                        }
534
                        #
535
                        # }
533
                        else {
536
                        else {
534
                            $item->{available} = 0;
537
                            $item->{available} = 0;
535
                            $item->{not_holdable} = "no_valid_pickup_location";
538
                            $item->{not_holdable} = "no_valid_pickup_location";
536
                        }
539
                        }
537
540
541
                        push( @available_itemtypes, $item->{itype} );
542
                    }
543
                    elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
544
                        # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
545
                        # with the exception of itemAlreadyOnHold because, you know, the item is already on hold
546
                        if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) {
547
                            # Send the pickup locations count to the UI, the pickup locations will be pulled using the API
548
                            my @pickup_locations = $item_object->pickup_locations({ patron => $patron })->as_list;
549
                            $item->{pickup_locations_count} = scalar @pickup_locations;
550
551
                            if ( @pickup_locations ) {
552
                                $num_items_available++;
553
                                $item->{override} = 1;
554
555
                                my $default_pickup_location;
556
557
                                ($default_pickup_location) = grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
558
559
                                $item->{default_pickup_location} = $default_pickup_location;
560
                            }
561
                            else {
562
                                $item->{available} = 0;
563
                                $item->{not_holdable} = "no_valid_pickup_location";
564
                            }
565
                        } else { $num_alreadyheld++ }
566
567
                        my $borrower = $patron;
568
                        my $borrowernumber = $patron->borrowernumber;
569
                        my $user = C4::Context->userenv->{number};
570
                        my $branchcode = C4::Context->userenv->{branch};
571
                        my $message = "Override limitation of hold";
572
                        my @message = ("Override limitation of hold");
573
                        my $barcode = $input->param('barcode');
574
575
576
                        my $infos = ({
577
                            message     => \@message,
578
                            borrowernumber => $borrowernumber,
579
                            barcode => $barcode,
580
                            manager_id => $user,
581
                            branchcode =>  $branchcode,
582
                        });
583
584
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
585
                        $json_infos =~ s/"/'/g;
586
587
                        logaction(
588
                            "HOLD", "ISSUE",
589
                            $borrower->{'borrowernumber'},
590
                            $json_infos,
591
                        ) if C4::Context->preference("IssueLog");
592
538
                        push( @available_itemtypes, $item->{itype} );
593
                        push( @available_itemtypes, $item->{itype} );
539
                    } else {
594
                    } else {
540
                        # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
595
                        # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
541
- 

Return to bug 9762