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 920-929 sub CanBookBeIssued { Link Here
920
    } else {
957
    } else {
921
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
958
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
922
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
959
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
960
            if ($issueconfirmed) {
961
                if ($message) {
962
                    $message = "$message + borrower had amend";
963
                } else {
964
                    $message = "borrower had amend";
965
                }
966
                push( @message, "borrower had amend" );
967
            }
923
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
968
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
924
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
969
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
925
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
970
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
926
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
971
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
972
            if ($issueconfirmed) {
973
                if ($message) {
974
                    $message = "$message + borrower had amend";
975
                } else {
976
                    $message = "borrower had amend";
977
                }
978
                push( @message, "borrower had amend" );
979
            }
927
        }
980
        }
928
    }
981
    }
929
982
Lines 1001-1013 sub CanBookBeIssued { Link Here
1001
        } else {
1054
        } else {
1002
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1055
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1003
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1056
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1004
            }
1057
            } else {
1005
            else {
1006
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1058
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1007
                $needsconfirmation{issued_firstname} = $patron->firstname;
1059
                $needsconfirmation{issued_firstname} = $patron->firstname;
1008
                $needsconfirmation{issued_surname} = $patron->surname;
1060
                $needsconfirmation{issued_surname} = $patron->surname;
1009
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1061
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1010
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1062
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1063
                if ($issueconfirmed) {
1064
                    if ($message) {
1065
                        $message = "$message + item is checked out for someone else ";
1066
                    } else {
1067
                        $message = "item is checked out for someone else";
1068
                    }
1069
                    push( @message, "item is checked out for someone else" );
1070
                }
1011
            }
1071
            }
1012
        }
1072
        }
1013
    }
1073
    }
Lines 1031-1036 sub CanBookBeIssued { Link Here
1031
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1091
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1032
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1092
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1033
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1093
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1094
            if ($issueconfirmed) {
1095
                if ($message) {
1096
                    $message = "$message + too many checkout";
1097
                } else {
1098
                    $message = "too many checkout";
1099
                }
1100
                push( @message, "too many checkout" );
1101
            }
1034
        } else {
1102
        } else {
1035
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1103
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1036
            $issuingimpossible{current_loan_count}        = $toomany->{count};
1104
            $issuingimpossible{current_loan_count}        = $toomany->{count};
Lines 1058-1063 sub CanBookBeIssued { Link Here
1058
        }else{
1126
        }else{
1059
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1127
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1060
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1128
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1129
            if ($issueconfirmed) {
1130
                if ($message) {
1131
                    $message = "$message + item not for loan";
1132
                } else {
1133
                    $message = "item not for loan";
1134
                }
1135
                push( @message, "item not for loan" );
1136
            }
1061
        }
1137
        }
1062
    }
1138
    }
1063
    else {
1139
    else {
Lines 1104-1109 sub CanBookBeIssued { Link Here
1104
        my $code = $av->count ? $av->next->lib : '';
1180
        my $code = $av->count ? $av->next->lib : '';
1105
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1181
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1106
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1182
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1183
        if ($issueconfirmed) {
1184
            if ($message) {
1185
                $message = "$message + item lost";
1186
            } else {
1187
                $message = "item lost";
1188
            }
1189
            push( @message, "item lost" );
1190
        }
1107
    }
1191
    }
1108
    if ( C4::Context->preference("IndependentBranches") ) {
1192
    if ( C4::Context->preference("IndependentBranches") ) {
1109
        my $userenv = C4::Context->userenv;
1193
        my $userenv = C4::Context->userenv;
Lines 1200-1205 sub CanBookBeIssued { Link Here
1200
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1284
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1201
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1285
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1202
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1286
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1287
                    if ($issueconfirmed) {
1288
                        if ($message) {
1289
                            $message =
1290
                                "$message + item is on reserve and waiting, but has been reserved by some other patron.";
1291
                        } else {
1292
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1293
                        }
1294
                        push( @message, "item is on reserve and waiting, but has been reserved by some other patron" );
1295
                    }
1203
                }
1296
                }
1204
                elsif ( $restype eq "Reserved" ) {
1297
                elsif ( $restype eq "Reserved" ) {
1205
                    # The item is on reserve for someone else.
1298
                    # The item is on reserve for someone else.
Lines 1211-1216 sub CanBookBeIssued { Link Here
1211
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1304
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1212
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1305
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1213
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1306
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1307
                    if ($issueconfirmed) {
1308
                        if ($message) {
1309
                            $message = "$message + item is on reserve for someone else";
1310
                        } else {
1311
                            $message = "item is on reserve for someone else";
1312
                        }
1313
                        push( @message, "item is on reserve for someone else" );
1314
                    }
1214
                }
1315
                }
1215
                elsif ( $restype eq "Transferred" ) {
1316
                elsif ( $restype eq "Transferred" ) {
1216
                    # The item is determined hold being transferred for someone else.
1317
                    # The item is determined hold being transferred for someone else.
Lines 1222-1227 sub CanBookBeIssued { Link Here
1222
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1323
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1223
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1324
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1224
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1325
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1326
                    if ($issueconfirmed) {
1327
                        if ($message) {
1328
                            $message = "$message + item is determined hold being transferred for someone else";
1329
                        } else {
1330
                            $message = "item is determined hold being transferred for someone else";
1331
                        }
1332
                        push( @message, "item is determined hold being transferred for someone else" );
1333
                    }
1225
                }
1334
                }
1226
                elsif ( $restype eq "Processing" ) {
1335
                elsif ( $restype eq "Processing" ) {
1227
                    # The item is determined hold being processed for someone else.
1336
                    # The item is determined hold being processed for someone else.
Lines 1233-1238 sub CanBookBeIssued { Link Here
1233
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1342
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1234
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1343
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1235
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1344
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1345
                    if ($issueconfirmed) {
1346
                        if ($message) {
1347
                            $message = "$message + item is determined hold being processed for someone else";
1348
                        } else {
1349
                            $message = "item is determined hold being processed for someone else";
1350
                        }
1351
                        push( @message, "item is determined hold being processed for someone else" );
1352
                    }
1236
                }
1353
                }
1237
            }
1354
            }
1238
        }
1355
        }
Lines 1276-1281 sub CanBookBeIssued { Link Here
1276
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1393
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1277
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1394
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1278
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1395
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1396
            if ($message) {
1397
                $message = "$message + age restriction";
1398
            } else {
1399
                $message = "age restriction";
1400
            }
1401
            push( @message, "age restriction" );
1279
        }
1402
        }
1280
        else {
1403
        else {
1281
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1404
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
Lines 1332-1337 sub CanBookBeIssued { Link Here
1332
        }
1455
        }
1333
    }
1456
    }
1334
1457
1458
    my $borrower = $patron;
1459
    my $user       = C4::Context->userenv->{number};
1460
    my $branchcode = C4::Context->userenv->{branch};
1461
    my $item       = Koha::Items->find( { barcode => $barcode } );
1462
    my $itemnumber = $item->itemnumber;
1463
1464
    # action, cardnumber, barcode, date, heure, user, branche
1465
    if ($issueconfirmed) {
1466
1467
        my $infos = (
1468
            {
1469
                message        => \@message,
1470
                borrowernumber => $borrower->borrowernumber,
1471
                barcode        => $barcode,
1472
                manager_id     => $user,
1473
                branchcode     => $branchcode,
1474
            }
1475
        );
1476
1477
        my $json_infos = JSON->new->utf8->pretty->encode($infos);
1478
        $json_infos =~ s/"/'/g;
1479
1480
        logaction(
1481
            "CIRCULATION", "ISSUE",
1482
            $borrower->{'borrowernumber'},
1483
            $json_infos,
1484
        ) if C4::Context->preference("IssueLog");
1485
    }
1486
1487
1335
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1488
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1336
}
1489
}
1337
1490
Lines 2355-2363 sub AddReturn { Link Here
2355
            if ( $transfer->tobranch eq $branch ) {
2508
            if ( $transfer->tobranch eq $branch ) {
2356
                $transfer->receive;
2509
                $transfer->receive;
2357
                $messages->{'TransferArrived'} = $transfer->frombranch;
2510
                $messages->{'TransferArrived'} = $transfer->frombranch;
2511
2358
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2512
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2359
                $validTransfer = 1
2513
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2360
                  if defined $transfer->reason && $transfer->reason eq 'Reserve';
2361
            }
2514
            }
2362
            else {
2515
            else {
2363
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2516
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
Lines 3085-3090 sub CanBookBeRenewed { Link Here
3085
    return ( 0, "on_reserve" )
3238
    return ( 0, "on_reserve" )
3086
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3239
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3087
3240
3241
    my $issuing_rule = Koha::CirculationRules->get_effective_rules(
3242
        {
3243
            categorycode => $patron->categorycode,
3244
            itemtype     => $item->effective_itemtype,
3245
            branchcode   => $branchcode,
3246
            rules        => [
3247
                'renewalsallowed',
3248
                'lengthunit',
3249
                'unseen_renewals_allowed'
3250
            ]
3251
        }
3252
    );
3253
3254
    return ( 0, "too_many" )
3255
        if not $issuing_rule->{renewalsallowed}
3256
        or $issuing_rule->{renewalsallowed} <= $issue->renewals_count;
3088
3257
3089
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3258
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3090
    my @fillable_holds = ();
3259
    my @fillable_holds = ();
Lines 3213-3220 fallback to a true value Link Here
3213
3382
3214
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3383
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3215
3384
3216
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing
3385
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing should be skipped for this renewal.
3217
should be skipped for this renewal.
3218
3386
3219
=cut
3387
=cut
3220
3388
Lines 3416-3424 sub AddRenewal { Link Here
3416
        });
3584
        });
3417
    });
3585
    });
3418
3586
3419
    unless( $skip_record_index ){
3587
    unless ($skip_record_index) {
3588
3420
        # We index now, after the transaction is committed
3589
        # We index now, after the transaction is committed
3421
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
3590
        my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
3422
        $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3591
        $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3423
    }
3592
    }
3424
3593
(-)a/circ/circulation.pl (-6 / +44 lines)
Lines 36-44 use C4::Auth qw( get_session get_template_and_user ); Link Here
36
use C4::Koha;
36
use C4::Koha;
37
use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue AddReturn );
37
use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue AddReturn );
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 325-331 if ($patron) { Link Here
325
# STEP 3 : ISSUING
326
# STEP 3 : ISSUING
326
#
327
#
327
#
328
#
328
if ( @$barcodes && $op eq 'cud-checkout' ) {
329
my $message;
330
my @message;
331
332
if (@$barcodes && $op eq 'cud-checkout') {
329
    my $checkout_infos;
333
    my $checkout_infos;
330
    for my $barcode (@$barcodes) {
334
    for my $barcode (@$barcodes) {
331
335
Lines 517-522 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
517
                    push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key );
521
                    push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key );
518
                }
522
                }
519
            }
523
            }
524
        
520
            unless ($confirm_required) {
525
            unless ($confirm_required) {
521
                my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
526
                my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
522
                if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
527
                if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
Lines 530-535 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
530
                        }
535
                        }
531
                    );
536
                    );
532
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
537
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
538
533
                }
539
                }
534
540
535
                # If booked (alerts or confirmation) update datedue to end of booking
541
                # If booked (alerts or confirmation) update datedue to end of booking
Lines 550-557 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
550
                $session->clear('auto_renew');
556
                $session->clear('auto_renew');
551
                $inprocess = 1;
557
                $inprocess = 1;
552
            }
558
            }
559
        
553
        }
560
        }
554
555
        if (   $needsconfirmation->{RESERVE_WAITING}
561
        if (   $needsconfirmation->{RESERVE_WAITING}
556
            or $needsconfirmation->{RESERVED}
562
            or $needsconfirmation->{RESERVED}
557
            or $needsconfirmation->{TRANSFERRED}
563
            or $needsconfirmation->{TRANSFERRED}
Lines 563-568 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
563
            );
569
            );
564
        }
570
        }
565
571
572
                my $borrower       = $patron;
573
                my $borrowernumber = $patron->borrowernumber;
574
                my $user           = C4::Context->userenv->{number};
575
                my $branchcode     = C4::Context->userenv->{branch};
576
                $message = "Restriction overridden temporarily";
577
                @message = ("Restriction overridden temporarily");
578
579
                if ($issueconfirmed) {
580
                    my $infos = (
581
                        {
582
                            message        => \@message,
583
                            borrowernumber => $borrowernumber,
584
                            barcode        => $barcode,
585
                            manager_id     => $user,
586
                            branchcode     => $branchcode,
587
                        }
588
                    );
589
590
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
591
                    $json_infos =~ s/"/'/g;
592
593
                    logaction(
594
                        "CIRCULATION", "ISSUE",
595
                        $borrower->{'borrowernumber'},
596
                        $json_infos,
597
                    ) if C4::Context->preference("IssueLog");
598
                }
599
                $session->clear('auto_renew');
600
                $inprocess = 1;
601
            
602
    
603
566
        # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue
604
        # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue
567
        $patron = Koha::Patrons->find($borrowernumber);
605
        $patron = Koha::Patrons->find($borrowernumber);
568
        $template_params->{issuecount} = $patron->checkouts->count;
606
        $template_params->{issuecount} = $patron->checkouts->count;
(-)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 42-47 use C4::Members; Link Here
42
use C4::Output qw( output_html_with_http_headers );
42
use C4::Output qw( output_html_with_http_headers );
43
use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves );
43
use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves );
44
use C4::RotatingCollections;
44
use C4::RotatingCollections;
45
use C4::Log qw( logaction );
45
use Koha::AuthorisedValues;
46
use Koha::AuthorisedValues;
46
use Koha::BiblioFrameworks;
47
use Koha::BiblioFrameworks;
47
use Koha::Calendar;
48
use Koha::Calendar;
Lines 193-198 if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve') { Link Here
193
            diffbranch     => 1,
194
            diffbranch     => 1,
194
        );
195
        );
195
    }
196
    }
197
} else {
198
    my $message    = "return an element that is reserved";
199
    my @message    = ("return an element that is reserved");
200
    my $user       = C4::Context->userenv->{number};
201
    my $branchcode = C4::Context->userenv->{branch};
202
    my $barcode    = $query->param('barcode');
203
204
    my $infos = (
205
        {
206
            message => \@message,
207
208
            #'card number' => $cardnumber,
209
            barcode    => $barcode,
210
            manager_id => $user,
211
            branchcode => $branchcode,
212
        }
213
    );
214
215
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
216
    $json_infos =~ s/"/'/g;
217
218
    logaction(
219
        "CIRCULATION", "RETURN",
220
        $session,
221
        $json_infos,
222
    ) if C4::Context->preference("ReturnLog");
196
}
223
}
197
224
198
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
225
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
Lines 459-465 if ($barcode && ( $op eq 'cud-checkin' || $op eq 'cud-affect_reserve' ) ) { Link Here
459
    }
486
    }
460
487
461
    # Mark missing bundle items as lost and report unexpected items
488
    # Mark missing bundle items as lost and report unexpected items
462
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') && !$query->param('do_not_verify_items_bundle_contents') ) {
489
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') ) {
463
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
490
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
464
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
491
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
465
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
492
        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 553-567 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
553
555
554
                                my $default_pickup_location;
556
                                my $default_pickup_location;
555
557
556
                                ($default_pickup_location) = grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
558
                                ($default_pickup_location) =
559
                                    grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
557
560
558
                                $item->{default_pickup_location} = $default_pickup_location;
561
                                $item->{default_pickup_location} = $default_pickup_location;
559
                            }
562
                            } else {
560
                            else {
563
                                $item->{available}    = 0;
561
                                $item->{available} = 0;
562
                                $item->{not_holdable} = "no_valid_pickup_location";
564
                                $item->{not_holdable} = "no_valid_pickup_location";
563
                            }
565
                            }
564
                        } else { $num_alreadyheld++ }
566
                        } else {
567
                            $num_alreadyheld++;
568
                        }
569
570
                        my $borrower       = $patron;
571
                        my $borrowernumber = $patron->borrowernumber;
572
                        my $user           = C4::Context->userenv->{number};
573
                        my $branchcode     = C4::Context->userenv->{branch};
574
                        my $message        = "Override limitation of hold";
575
                        my @message        = ("Override limitation of hold");
576
                        my $barcode        = $item->{barcode};
577
578
                        my $infos = (
579
                            {
580
                                message        => \@message,
581
                                borrowernumber => $borrowernumber,
582
                                barcode        => $barcode,
583
                                manager_id     => $user,
584
                                branchcode     => $branchcode,
585
                            }
586
                        );
587
588
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
589
                        $json_infos =~ s/"/'/g;
590
591
                        logaction(
592
                            "HOLD", "ISSUE",
593
                            $borrower->{'borrowernumber'},
594
                            $json_infos,
595
                        ) if C4::Context->preference("IssueLog");
565
596
566
                        push( @available_itemtypes, $item->{itype} );
597
                        push( @available_itemtypes, $item->{itype} );
567
                    } else {
598
                    } 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