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

(-)a/C4/Circulation.pm (-2 / +159 lines)
Lines 22-32 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 );
28
use C4::Reserves
29
use C4::Reserves
29
    qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsAvailableForItemLevelRequest );
30
    qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsItemOnHoldAndFound IsAvailableForItemLevelRequest );
30
use C4::Biblio qw( UpdateTotalIssues );
31
use C4::Biblio qw( UpdateTotalIssues );
31
use C4::Items  qw( ModItemTransfer ModDateLastSeen CartToShelf );
32
use C4::Items  qw( ModItemTransfer ModDateLastSeen CartToShelf );
32
use C4::Accounts;
33
use C4::Accounts;
Lines 319-324 A recall for this item was found, and the item needs to be transferred to the re Link Here
319
320
320
=cut
321
=cut
321
322
323
my $query = CGI->new;
324
325
my $stickyduedate      = $query->param('stickyduedate');
326
my $duedatespec        = $query->param('duedatespec');
327
my $restoreduedatespec = $query->param('restoreduedatespec') || $duedatespec;
328
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) {
329
    undef $restoreduedatespec;
330
}
331
my $issueconfirmed = $query->param('issueconfirmed');
332
my $cancelreserve  = $query->param('cancelreserve');
333
my $cancel_recall  = $query->param('cancel_recall');
334
my $recall_id      = $query->param('recall_id');
335
my $debt_confirmed = $query->param('debt_confirmed') || 0;     # Don't show the debt error dialog twice
336
my $charges        = $query->param('charges')        || q{};
337
322
sub transferbook {
338
sub transferbook {
323
    my $params   = shift;
339
    my $params   = shift;
324
    my $tbr      = $params->{to_branch};
340
    my $tbr      = $params->{to_branch};
Lines 816-824 sub CanBookBeIssued { Link Here
816
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) );
832
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) );
817
833
818
    my $now = dt_from_string();
834
    my $now = dt_from_string();
835
    my $message;
836
    my @message;
837
819
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
838
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
839
820
    if ( DateTime->compare( $duedate, $now ) == -1 ) {    # duedate cannot be before now
840
    if ( DateTime->compare( $duedate, $now ) == -1 ) {    # duedate cannot be before now
821
        $needsconfirmation{INVALID_DATE} = $duedate;
841
        $needsconfirmation{INVALID_DATE} = $duedate;
842
        if ($issueconfirmed) {
843
            if ($message) {
844
                $message = "$message + sticky due date is invalid or due date in the past";
845
            } else {
846
                $message = "sticky due date is invalid or due date in the past";
847
            }
848
            push( @message, "sticky due date is invalid or due date in the past" );
849
        }
850
822
    }
851
    }
823
852
824
    my $fees = Koha::Charges::Fees->new(
853
    my $fees = Koha::Charges::Fees->new(
Lines 864-869 sub CanBookBeIssued { Link Here
864
    }
893
    }
865
    if ( $patron->is_debarred ) {
894
    if ( $patron->is_debarred ) {
866
        $issuingimpossible{DEBARRED} = 1;
895
        $issuingimpossible{DEBARRED} = 1;
896
        if ($issueconfirmed) {
897
            if ($message) {
898
                $message = "$message + borrower is restricted";
899
            } else {
900
                $message = "borrower is restricted";
901
            }
902
            push( @message, "borrower is restricted" );
903
        }
867
    }
904
    }
868
905
869
    if ( $patron->is_expired ) {
906
    if ( $patron->is_expired ) {
Lines 936-945 sub CanBookBeIssued { Link Here
936
    } else {
973
    } else {
937
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
974
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
938
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
975
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
976
            if ($issueconfirmed) {
977
                if ($message) {
978
                    $message = "$message + borrower had amend";
979
                } else {
980
                    $message = "borrower had amend";
981
                }
982
                push( @message, "borrower had amend" );
983
            }
939
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
984
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
940
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
985
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
941
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
986
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
942
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
987
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
988
            if ($issueconfirmed) {
989
                if ($message) {
990
                    $message = "$message + borrower had amend";
991
                } else {
992
                    $message = "borrower had amend";
993
                }
994
                push( @message, "borrower had amend" );
995
            }
943
        }
996
        }
944
    }
997
    }
945
998
Lines 1020-1025 sub CanBookBeIssued { Link Here
1020
                $needsconfirmation{issued_surname}        = $patron->surname;
1073
                $needsconfirmation{issued_surname}        = $patron->surname;
1021
                $needsconfirmation{issued_cardnumber}     = $patron->cardnumber;
1074
                $needsconfirmation{issued_cardnumber}     = $patron->cardnumber;
1022
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1075
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1076
                if ($issueconfirmed) {
1077
                    if ($message) {
1078
                        $message = "$message + item is checked out for someone else ";
1079
                    } else {
1080
                        $message = "item is checked out for someone else";
1081
                    }
1082
                    push( @message, "item is checked out for someone else" );
1083
                }
1023
            }
1084
            }
1024
        }
1085
        }
1025
    }
1086
    }
Lines 1047-1052 sub CanBookBeIssued { Link Here
1047
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1108
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1048
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1109
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1049
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1110
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1111
            if ($issueconfirmed) {
1112
                if ($message) {
1113
                    $message = "$message + too many checkout";
1114
                } else {
1115
                    $message = "too many checkout";
1116
                }
1117
                push( @message, "too many checkout" );
1118
            }
1050
        } else {
1119
        } else {
1051
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1120
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1052
            $issuingimpossible{current_loan_count}        = $toomany->{count};
1121
            $issuingimpossible{current_loan_count}        = $toomany->{count};
Lines 1074-1079 sub CanBookBeIssued { Link Here
1074
        } else {
1143
        } else {
1075
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1144
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1076
            $needsconfirmation{item_notforloan}      = $item_object->notforloan;
1145
            $needsconfirmation{item_notforloan}      = $item_object->notforloan;
1146
            if ($issueconfirmed) {
1147
                if ($message) {
1148
                    $message = "$message + item not for loan";
1149
                } else {
1150
                    $message = "item not for loan";
1151
                }
1152
                push( @message, "item not for loan" );
1153
            }
1077
        }
1154
        }
1078
    } else {
1155
    } else {
1079
1156
Lines 1119-1124 sub CanBookBeIssued { Link Here
1119
        my $code = $av->count ? $av->next->lib : '';
1196
        my $code = $av->count ? $av->next->lib : '';
1120
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1197
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1121
        $alerts{ITEM_LOST}            = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1198
        $alerts{ITEM_LOST}            = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1199
        if ($issueconfirmed) {
1200
            if ($message) {
1201
                $message = "$message + item lost";
1202
            } else {
1203
                $message = "item lost";
1204
            }
1205
            push( @message, "item lost" );
1206
        }
1122
    }
1207
    }
1123
    if ( C4::Context->preference("IndependentBranches") ) {
1208
    if ( C4::Context->preference("IndependentBranches") ) {
1124
        my $userenv = C4::Context->userenv;
1209
        my $userenv = C4::Context->userenv;
Lines 1219-1224 sub CanBookBeIssued { Link Here
1219
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1304
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1220
                    $needsconfirmation{'reswaitingdate'}    = $res->{'waitingdate'};
1305
                    $needsconfirmation{'reswaitingdate'}    = $res->{'waitingdate'};
1221
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1306
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1307
1308
                    if ($issueconfirmed) {
1309
                        if ($message) {
1310
                            $message =
1311
                                "$message + item is on reserve and waiting, but has been reserved by some other patron.";
1312
                        } else {
1313
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1314
                        }
1315
                        push( @message, "item is on reserve and waiting, but has been reserved by some other patron" );
1316
                    }
1222
                } elsif ( $restype eq "Reserved" ) {
1317
                } elsif ( $restype eq "Reserved" ) {
1223
1318
1224
                    # The item is on reserve for someone else.
1319
                    # The item is on reserve for someone else.
Lines 1230-1235 sub CanBookBeIssued { Link Here
1230
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1325
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1231
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1326
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1232
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1327
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1328
1329
                    if ($issueconfirmed) {
1330
                        if ($message) {
1331
                            $message = "$message + item is on reserve for someone else";
1332
                        } else {
1333
                            $message = "item is on reserve for someone else";
1334
                        }
1335
                        push( @message, "item is on reserve for someone else" );
1336
                    }
1233
                } elsif ( $restype eq "Transferred" ) {
1337
                } elsif ( $restype eq "Transferred" ) {
1234
1338
1235
                    # The item is determined hold being transferred for someone else.
1339
                    # The item is determined hold being transferred for someone else.
Lines 1241-1246 sub CanBookBeIssued { Link Here
1241
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1345
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1242
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1346
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1243
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1347
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1348
1349
                    if ($issueconfirmed) {
1350
                        if ($message) {
1351
                            $message = "$message + item is determined hold being transferred for someone else";
1352
                        } else {
1353
                            $message = "item is determined hold being transferred for someone else";
1354
                        }
1355
                        push( @message, "item is determined hold being transferred for someone else" );
1356
                    }
1244
                } elsif ( $restype eq "Processing" ) {
1357
                } elsif ( $restype eq "Processing" ) {
1245
1358
1246
                    # The item is determined hold being processed for someone else.
1359
                    # The item is determined hold being processed for someone else.
Lines 1252-1257 sub CanBookBeIssued { Link Here
1252
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1365
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1253
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1366
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1254
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1367
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1368
1369
                    if ($issueconfirmed) {
1370
                        if ($message) {
1371
                            $message = "$message + item is determined hold being processed for someone else";
1372
                        } else {
1373
                            $message = "item is determined hold being processed for someone else";
1374
                        }
1375
                        push( @message, "item is determined hold being processed for someone else" );
1376
                    }
1255
                }
1377
                }
1256
            }
1378
            }
1257
        }
1379
        }
Lines 1295-1300 sub CanBookBeIssued { Link Here
1295
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1417
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1296
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1418
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1297
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1419
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1420
            if ($message) {
1421
                $message = "$message + age restriction";
1422
            } else {
1423
                $message = "age restriction";
1424
            }
1425
            push( @message, "age restriction" );
1298
        } else {
1426
        } else {
1299
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1427
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1300
        }
1428
        }
Lines 1353-1358 sub CanBookBeIssued { Link Here
1353
        }
1481
        }
1354
    }
1482
    }
1355
1483
1484
    my $borrower   = $patron;
1485
    my $user       = C4::Context->userenv->{number};
1486
    my $branchcode = C4::Context->userenv->{branch};
1487
    my $item       = Koha::Items->find( { barcode => $barcode } );
1488
    my $itemnumber = $item->itemnumber;
1489
1490
    # action, cardnumber, barcode, date, heure, user, branche
1491
    if ($issueconfirmed) {
1492
1493
        my $infos = (
1494
            {
1495
                message        => \@message,
1496
                borrowernumber => $borrower->borrowernumber,
1497
                barcode        => $barcode,
1498
                manager_id     => $user,
1499
                branchcode     => $branchcode,
1500
            }
1501
        );
1502
1503
        my $json_infos = JSON->new->utf8->pretty->encode($infos);
1504
        $json_infos =~ s/"/'/g;
1505
1506
        logaction(
1507
            "CIRCULATION", "ISSUE",
1508
            $borrower->{'borrowernumber'},
1509
            $json_infos,
1510
        ) if C4::Context->preference("IssueLog");
1511
    }
1512
1356
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1513
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1357
}
1514
}
1358
1515
Lines 3200-3206 sub CanBookBeRenewed { Link Here
3200
3357
3201
                foreach my $other_item (@other_items) {
3358
                foreach my $other_item (@other_items) {
3202
                    next if defined $matched_items{ $other_item->itemnumber };
3359
                    next if defined $matched_items{ $other_item->itemnumber };
3203
                    next if $other_item->holds->filter_by_found->count;
3360
                    next if IsItemOnHoldAndFound( $other_item->itemnumber );
3204
                    next unless IsAvailableForItemLevelRequest( $other_item, $patron_with_reserve, undef );
3361
                    next unless IsAvailableForItemLevelRequest( $other_item, $patron_with_reserve, undef );
3205
                    next
3362
                    next
3206
                        unless CanItemBeReserved(
3363
                        unless CanItemBeReserved(
(-)a/circ/circulation.pl (-41 / +56 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 52-58 use Koha::Plugins; Link Here
52
use Koha::Database;
53
use Koha::Database;
53
use Koha::BiblioFrameworks;
54
use Koha::BiblioFrameworks;
54
use Koha::Items;
55
use Koha::Items;
55
use Koha::CirculationRules;
56
use Koha::SearchEngine;
56
use Koha::SearchEngine;
57
use Koha::SearchEngine::Search;
57
use Koha::SearchEngine::Search;
58
use Koha::Patron::Modifications;
58
use Koha::Patron::Modifications;
Lines 112-118 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
112
    }
112
    }
113
);
113
);
114
114
115
my $op                      = $query->param('op') // '';
115
my $op                      = $query->param('op');
116
my $override_high_holds     = $query->param('override_high_holds');
116
my $override_high_holds     = $query->param('override_high_holds');
117
my $override_high_holds_tmp = $query->param('override_high_holds_tmp');
117
my $override_high_holds_tmp = $query->param('override_high_holds_tmp');
118
118
Lines 239-245 if ( @$barcodes == 0 && $charges eq 'yes' ) { Link Here
239
# STEP 2 : FIND BORROWER
239
# STEP 2 : FIND BORROWER
240
# if there is a list of find borrowers....
240
# if there is a list of find borrowers....
241
#
241
#
242
my $message;
242
243
if ($findborrower) {
243
if ($findborrower) {
244
    Koha::Plugins->call( 'patron_barcode_transform', \$findborrower );
244
    Koha::Plugins->call( 'patron_barcode_transform', \$findborrower );
245
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
245
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
Lines 325-330 if ($patron) { Link Here
325
# STEP 3 : ISSUING
325
# STEP 3 : ISSUING
326
#
326
#
327
#
327
#
328
my $message;
329
my @message;
330
328
if ( @$barcodes && $op eq 'cud-checkout' ) {
331
if ( @$barcodes && $op eq 'cud-checkout' ) {
329
    my $checkout_infos;
332
    my $checkout_infos;
330
    for my $barcode (@$barcodes) {
333
    for my $barcode (@$barcodes) {
Lines 370-385 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
370
        }
373
        }
371
374
372
        if ( $issuingimpossible->{'STATS'} ) {
375
        if ( $issuingimpossible->{'STATS'} ) {
373
            my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) =
376
            $template->param( STATS => 1 );
374
                AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 );
375
377
376
            $template->param(
378
            if ( $item->onloan ) {
377
                STATS     => 1,
379
                my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) =
378
                CHECKEDIN => $stats_return,
380
                    AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 );
379
                MESSAGES  => $stats_messages,
381
380
                ITEM      => $stats_iteminformation,
382
                $template->param(
381
                BORROWER  => $stats_borrower,
383
                    CHECKEDIN => $stats_return,
382
            );
384
                    MESSAGES  => $stats_messages,
385
                    ITEM      => $stats_iteminformation,
386
                    BORROWER  => $stats_borrower,
387
                );
388
            }
383
389
384
            #increment items.localuse
390
            #increment items.localuse
385
            my $localuse_count = $item->localuse;
391
            my $localuse_count = $item->localuse;
Lines 483-521 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
483
                $template_params->{ADDITIONAL_MATERIALS} = $materials;
489
                $template_params->{ADDITIONAL_MATERIALS} = $materials;
484
                $template_params->{itemhomebranch}       = $item->homebranch;
490
                $template_params->{itemhomebranch}       = $item->homebranch;
485
491
486
                my $patron_session_confirmation = $query->cookie('patronSessionConfirmation') || undef;
487
                my ( $patron_for_session, $session_confirmations ) = split( /:/, $patron_session_confirmation, 2 );
488
                my $patron_match = $borrowernumber == $patron_for_session;
489
                my @conf_keys    = split( /\|/, $session_confirmations );
490
                $template_params->{sessionConfirmationKeys} = ();
491
492
                # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
492
                # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
493
                foreach my $needsconfirmation_key ( keys %$needsconfirmation ) {
493
                foreach my $needsconfirmation_key ( keys %$needsconfirmation ) {
494
                    if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) {
495
                        my $rule = Koha::CirculationRules->get_effective_rule(
496
                            {
497
                                rule_name  => 'bookings_lead_period',
498
                                itemtype   => $item->effective_itemtype,
499
                                branchcode => "*"
500
                            }
501
                        );
502
                        my $preparation_period = $rule ? $rule->rule_value : 1;
503
                        my $reduceddue = dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )
504
505
                            ->subtract( days => $preparation_period );
506
                        $template_params->{reduceddue} = $reduceddue;
507
                    }
508
                    next
509
                        if $patron_match
510
                        && scalar(@conf_keys) > 0
511
                        && grep( { $needsconfirmation_key eq $_ } @conf_keys );
512
513
                    $template_params->{$needsconfirmation_key}    = $needsconfirmation->{$needsconfirmation_key};
494
                    $template_params->{$needsconfirmation_key}    = $needsconfirmation->{$needsconfirmation_key};
514
                    $template_params->{getTitleMessageIteminfo}   = $biblio->title;
495
                    $template_params->{getTitleMessageIteminfo}   = $biblio->title;
515
                    $template_params->{getBarcodeMessageIteminfo} = $item->barcode;
496
                    $template_params->{getBarcodeMessageIteminfo} = $item->barcode;
516
                    $template_params->{NEEDSCONFIRMATION}         = 1;
497
                    $template_params->{NEEDSCONFIRMATION}         = 1;
517
                    $confirm_required                             = 1;
498
                    $confirm_required                             = 1;
518
                    push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key );
499
                    if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) {
500
                        my $reduceddue =
501
                            dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date )
502
                            ->subtract( days => 1 );
503
                        $template_params->{reduceddue} = $reduceddue;
504
                    }
519
                }
505
                }
520
            }
506
            }
521
            unless ($confirm_required) {
507
            unless ($confirm_required) {
Lines 531-536 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
531
                        }
517
                        }
532
                    );
518
                    );
533
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
519
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
520
534
                }
521
                }
535
522
536
                # If booked (alerts or confirmation) update datedue to end of booking
523
                # If booked (alerts or confirmation) update datedue to end of booking
Lines 548-553 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
548
                    }
535
                    }
549
                );
536
                );
550
                $template_params->{issue} = $issue;
537
                $template_params->{issue} = $issue;
538
539
                my $borrower       = $patron;
540
                my $borrowernumber = $patron->borrowernumber;
541
                my $user           = C4::Context->userenv->{number};
542
                my $branchcode     = C4::Context->userenv->{branch};
543
                $message = "Restriction overridden temporarily";
544
                @message = ("Restriction overridden temporarily");
545
546
                if ($issueconfirmed) {
547
                    my $infos = (
548
                        {
549
                            message        => \@message,
550
                            borrowernumber => $borrowernumber,
551
                            barcode        => $barcode,
552
                            manager_id     => $user,
553
                            branchcode     => $branchcode,
554
                        }
555
                    );
556
557
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
558
                    $json_infos =~ s/"/'/g;
559
560
                    logaction(
561
                        "CIRCULATION", "ISSUE",
562
                        $borrower->{'borrowernumber'},
563
                        $json_infos,
564
                    ) if C4::Context->preference("IssueLog");
565
                }
551
                $session->clear('auto_renew');
566
                $session->clear('auto_renew');
552
                $inprocess = 1;
567
                $inprocess = 1;
553
            }
568
            }
(-)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 ) = CanBookBeRenewed( $patron, $checkout, $override_limit );
78
                ( $can_renew, $error, $info ) = CanBookBeRenewed( $patron, $checkout, $override_limit );
Lines 74-79 if ( $op eq 'cud-renew' && $barcode ) { Link Here
74
                    if ($override_holds) {
81
                    if ($override_holds) {
75
                        $can_renew = 1;
82
                        $can_renew = 1;
76
                        $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
                            {
90
                                message        => \@message,
91
                                borrowernumber => $borrowernumber,
92
                                barcode        => $barcode,
93
                                manager_id     => $user,
94
                                branchcode     => $branchcode,
95
                            }
96
                        );
97
98
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
99
                        $json_infos =~ s/"/'/g;
100
101
                        logaction(
102
                            "CIRCULATION", "RENEWAL",
103
                            $borrower->{'borrowernumber'},
104
                            $json_infos,
105
                        ) if C4::Context->preference("RenewalLog");
77
                    } else {
106
                    } else {
78
                        $can_renew = 0;
107
                        $can_renew = 0;
79
                    }
108
                    }
Lines 104-109 if ( $op eq 'cud-renew' && $barcode ) { Link Here
104
                        }
133
                        }
105
                    );
134
                    );
106
                    $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
                        {
142
                            message        => \@message,
143
                            borrowernumber => $borrowernumber,
144
                            barcode        => $barcode,
145
                            manager_id     => $user,
146
                            branchcode     => $branchcode,
147
                        }
148
                    );
149
150
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
151
                    $json_infos =~ s/"/'/g;
152
153
                    logaction(
154
                        "CIRCULATION", "RENEWAL",
155
                        $borrower->{'borrowernumber'},
156
                        $json_infos,
157
                    ) if C4::Context->preference("RenewalLog");
107
                }
158
                }
108
            } else {
159
            } else {
109
                $error = "patron_restricted";
160
                $error = "patron_restricted";
(-)a/circ/returns.pl (-32 / +54 lines)
Lines 35-47 use CGI qw ( -utf8 ); Link Here
35
use DateTime;
35
use DateTime;
36
36
37
use C4::Auth        qw( get_template_and_user get_session haspermission );
37
use C4::Auth        qw( get_template_and_user get_session haspermission );
38
use C4::Circulation qw( barcodedecode GetBranchItemRule AddReturn LostItem );
38
use C4::Circulation qw( barcodedecode GetBranchItemRule AddReturn updateWrongTransfer LostItem );
39
use C4::Context;
39
use C4::Context;
40
use C4::Items qw( ModItemTransfer );
40
use C4::Members::Messaging;
41
use C4::Members::Messaging;
41
use C4::Members;
42
use C4::Members;
42
use C4::Output   qw( output_html_with_http_headers );
43
use C4::Output   qw( output_html_with_http_headers );
43
use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves );
44
use C4::Reserves qw( ModReserve ModReserveAffect CheckReserves );
44
use C4::RotatingCollections;
45
use C4::RotatingCollections;
46
use C4::Log qw( logaction );
45
use Koha::AuthorisedValues;
47
use Koha::AuthorisedValues;
46
use Koha::BiblioFrameworks;
48
use Koha::BiblioFrameworks;
47
use Koha::Calendar;
49
use Koha::Calendar;
Lines 111-117 for my $counter ( $query->multi_param("checkin_counter") ) { Link Here
111
    last if ++$i >= $returned_counter;
113
    last if ++$i >= $returned_counter;
112
}
114
}
113
115
114
my $op = $query->param('op') // '';
116
my $op = $query->param('op');
115
117
116
############
118
############
117
# Deal with the requests....
119
# Deal with the requests....
Lines 151-163 if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve' ) { Link Here
151
        ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id, $desk_id );
153
        ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id, $desk_id );
152
154
153
        if ($diffBranchSend) {
155
        if ($diffBranchSend) {
154
            my $tobranch = $hold->pickup_library();
156
            ModItemTransfer( $itemnumber, $userenv_branch, $diffBranchSend, 'Reserve' );
155
156
            # Add transfer, enqueue if one is already in the queue, and immediately set to in transit
157
            my $transfer = $item->request_transfer( { to => $tobranch, reason => 'Reserve', enqueue => 1 } );
158
            $transfer->transit;
159
        }
157
        }
160
    }
158
    }
159
160
    # check if we have other reserves for this document, if we have a result send the message of transfer
161
    # FIXME do we need to do this if we didn't take the cancel_reserve branch above?
162
    my ( undef, $nextreservinfo, undef ) = CheckReserves($item);
163
164
    if ( $userenv_branch ne $nextreservinfo->{'branchcode'} ) {
165
        my $patron = Koha::Patrons->find( $nextreservinfo->{'borrowernumber'} );
166
        $template->param(
167
            itemtitle        => $biblio->title,
168
            itembiblionumber => $biblio->biblionumber,
169
            iteminfo         => $biblio->author,
170
            patron           => $patron,
171
            diffbranch       => 1,
172
        );
173
    }
174
} else {
175
    my $message    = "return an element that is reserved";
176
    my @message    = ("return an element that is reserved");
177
    my $user       = C4::Context->userenv->{number};
178
    my $branchcode = C4::Context->userenv->{branch};
179
    my $barcode    = $query->param('barcode');
180
181
    my $infos = (
182
        {
183
            message => \@message,
184
185
            #'card number' => $cardnumber,
186
            barcode    => $barcode,
187
            manager_id => $user,
188
            branchcode => $branchcode,
189
        }
190
    );
191
192
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
193
    $json_infos =~ s/"/'/g;
194
195
    logaction(
196
        "CIRCULATION", "RETURN",
197
        $session,
198
        $json_infos,
199
    ) if C4::Context->preference("ReturnLog");
161
}
200
}
162
201
163
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
202
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
Lines 218-232 if ($return_date_override) { Link Here
218
    }
257
    }
219
}
258
}
220
259
221
# If 'needstransfer' was set and the librarian has chosen to initiate the transfer
222
if ( $op eq 'cud-dotransfer' ) {
260
if ( $op eq 'cud-dotransfer' ) {
261
262
    # An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
223
    my $transferitem = $query->param('transferitem');
263
    my $transferitem = $query->param('transferitem');
224
    my $item         = Koha::Items->find($transferitem);
264
    my $tobranch     = $query->param('tobranch');
225
    my $tobranchcode = $query->param('tobranch');
226
    my $tobranch     = Koha::Libraries->find($tobranchcode);
227
    my $trigger      = $query->param('trigger');
265
    my $trigger      = $query->param('trigger');
228
    my $transfer     = $item->request_transfer( { to => $tobranch, reason => $trigger } );
266
    ModItemTransfer( $transferitem, $userenv_branch, $tobranch, $trigger );
229
    $transfer->transit;
230
}
267
}
231
268
232
if ( $transit && $op eq 'cud-transfer' ) {
269
if ( $transit && $op eq 'cud-transfer' ) {
Lines 414-424 if ( $barcode && ( $op eq 'cud-checkin' || $op eq 'cud-affect_reserve' ) ) { Link Here
414
    }
451
    }
415
452
416
    # Mark missing bundle items as lost and report unexpected items
453
    # Mark missing bundle items as lost and report unexpected items
417
    if (   $item
454
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') ) {
418
        && $item->is_bundle
419
        && $query->param('confirm_items_bundle_return')
420
        && !$query->param('do_not_verify_items_bundle_contents') )
421
    {
422
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
455
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
423
        my $barcodes        = $query->param('verify-items-bundle-contents-barcodes');
456
        my $barcodes        = $query->param('verify-items-bundle-contents-barcodes');
424
        my @barcodes        = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
457
        my @barcodes        = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
Lines 513-519 if ( $messages->{'WasTransfered'} ) { Link Here
513
    $template->param(
546
    $template->param(
514
        found      => 1,
547
        found      => 1,
515
        transfer   => $messages->{'WasTransfered'},
548
        transfer   => $messages->{'WasTransfered'},
516
        transferto => $messages->{'TransferTo'},
517
        trigger    => $messages->{'TransferTrigger'},
549
        trigger    => $messages->{'TransferTrigger'},
518
        itemnumber => $itemnumber,
550
        itemnumber => $itemnumber,
519
    );
551
    );
Lines 547-556 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'} ) { Link Here
547
    );
579
    );
548
580
549
    # Update the transfer to reflect the new item holdingbranch
581
    # Update the transfer to reflect the new item holdingbranch
550
    my $item         = Koha::Items->find( $messages->{'WrongTransferItem'} );
582
    my $new_transfer =
551
    my $old_transfer = $item->get_transfer;
583
        updateWrongTransfer( $messages->{'WrongTransferItem'}, $messages->{'WrongTransfer'}, $userenv_branch );
552
    my $new_transfer = $item->request_transfer(
553
        { to => $old_transfer->to_library, reason => $old_transfer->reason, replace => 'WrongTransfer' } );
554
    $template->param( NewTransfer => $new_transfer->id );
584
    $template->param( NewTransfer => $new_transfer->id );
555
585
556
    my $reserve = $messages->{'ResFound'};
586
    my $reserve = $messages->{'ResFound'};
Lines 583-593 if ( $messages->{'ResFound'} ) { Link Here
583
        ModReserveAffect( $itemnumber, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id}, $desk_id );
613
        ModReserveAffect( $itemnumber, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id}, $desk_id );
584
614
585
        if ($diffBranchSend) {
615
        if ($diffBranchSend) {
586
            my $tobranch = Koha::Libraries->find( $reserve->{branchcode} );
616
            ModItemTransfer( $itemnumber, $item->holdingbranch, $reserve->{branchcode}, 'Reserve' );
587
588
            # Add transfer, enqueue if one is already in the queue, and immediately set to in transit
589
            my $transfer = $item->request_transfer( { to => $tobranch, reason => 'Reserve', enqueue => 1 } );
590
            $transfer->transit;
591
        }
617
        }
592
618
593
        $template->param(
619
        $template->param(
Lines 679-686 foreach my $code ( keys %$messages ) { Link Here
679
        $err{waslost} = 1;
705
        $err{waslost} = 1;
680
    } elsif ( $code eq 'LostItemFeeRefunded' ) {
706
    } elsif ( $code eq 'LostItemFeeRefunded' ) {
681
        $template->param( LostItemFeeRefunded => 1 );
707
        $template->param( LostItemFeeRefunded => 1 );
682
    } elsif ( $code eq 'LostItemPaymentNotRefunded' ) {
683
        $template->param( LostItemPaymentNotRefunded => 1 );
684
    } elsif ( $code eq 'LostItemFeeCharged' ) {
708
    } elsif ( $code eq 'LostItemFeeCharged' ) {
685
        $template->param( LostItemFeeCharged => 1 );
709
        $template->param( LostItemFeeCharged => 1 );
686
    } elsif ( $code eq 'LostItemFeeRestored' ) {
710
    } elsif ( $code eq 'LostItemFeeRestored' ) {
Lines 693-700 foreach my $code ( keys %$messages ) { Link Here
693
        ;    # FIXME... anything to do here?
717
        ;    # FIXME... anything to do here?
694
    } elsif ( $code eq 'WasTransfered' ) {
718
    } elsif ( $code eq 'WasTransfered' ) {
695
        ;    # FIXME... anything to do here?
719
        ;    # FIXME... anything to do here?
696
    } elsif ( $code eq 'TransferTo' ) {
697
        ;    # Handled above, along with WasTransfered
698
    } elsif ( $code eq 'withdrawn' ) {
720
    } elsif ( $code eq 'withdrawn' ) {
699
        $err{withdrawn} = 1;
721
        $err{withdrawn} = 1;
700
    } elsif ( $code eq 'WrongTransfer' ) {
722
    } elsif ( $code eq 'WrongTransfer' ) {
(-)a/reserve/request.pl (-31 / +49 lines)
Lines 26-31 script to place reserves/requests Link Here
26
=cut
26
=cut
27
27
28
use Modern::Perl;
28
use Modern::Perl;
29
use Data::Dumper;
29
30
30
use CGI             qw ( -utf8 );
31
use CGI             qw ( -utf8 );
31
use List::MoreUtils qw( uniq );
32
use List::MoreUtils qw( uniq );
Lines 33-45 use Date::Calc qw( Date_to_Days ); Link Here
33
use C4::Output      qw( output_html_with_http_headers );
34
use C4::Output      qw( output_html_with_http_headers );
34
use C4::Auth        qw( get_template_and_user );
35
use C4::Auth        qw( get_template_and_user );
35
use C4::Reserves
36
use C4::Reserves
36
    qw( RevertWaitingStatus AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest );
37
    qw( RevertWaitingStatus AlterPriority ToggleLowestPriority ToggleSuspend CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest );
37
use C4::Items       qw( get_hostitemnumbers_of );
38
use C4::Items       qw( get_hostitemnumbers_of );
38
use C4::Koha        qw( getitemtypeimagelocation );
39
use C4::Koha        qw( getitemtypeimagelocation );
39
use C4::Serials     qw( CountSubscriptionFromBiblionumber );
40
use C4::Serials     qw( CountSubscriptionFromBiblionumber );
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 88-95 my $warnings; Link Here
88
my $messages;
90
my $messages;
89
my $exceeded_maxreserves;
91
my $exceeded_maxreserves;
90
my $exceeded_holds_per_record;
92
my $exceeded_holds_per_record;
91
my @failed_holds   = $input->multi_param('failed_holds');
93
my @failed_holds = $input->multi_param('failed_holds');
92
my $form_submitted = $input->param('form_submitted');
93
94
94
my $op = $input->param('op') || q{};
95
my $op = $input->param('op') || q{};
95
96
Lines 117-131 if ( $op eq 'cud-move' ) { Link Here
117
} elsif ( $op eq 'cud-setLowestPriority' ) {
118
} elsif ( $op eq 'cud-setLowestPriority' ) {
118
    my $reserve_id = $input->param('reserve_id');
119
    my $reserve_id = $input->param('reserve_id');
119
    ToggleLowestPriority($reserve_id);
120
    ToggleLowestPriority($reserve_id);
120
} elsif ( $op eq 'cud-suspend' ) {
121
} elsif ( $op eq 'cud-toggleSuspend' ) {
121
    my $reserve_id    = $input->param('reserve_id');
122
    my $reserve_id    = $input->param('reserve_id');
122
    my $suspend_until = $input->param('suspend_until');
123
    my $suspend_until = $input->param('suspend_until');
123
    my $hold          = Koha::Holds->find($reserve_id);
124
    ToggleSuspend( $reserve_id, $suspend_until );
124
    $hold->suspend_hold($suspend_until) if $hold;
125
} elsif ( $op eq 'cud-unsuspend' ) {
126
    my $reserve_id = $input->param('reserve_id');
127
    my $hold       = Koha::Holds->find($reserve_id);
128
    $hold->resume() if $hold;
129
} elsif ( $op eq 'cud-cancel_bulk' ) {
125
} elsif ( $op eq 'cud-cancel_bulk' ) {
130
    my $cancellation_reason = $input->param("cancellation-reason");
126
    my $cancellation_reason = $input->param("cancellation-reason");
131
    my @hold_ids            = split( ',', scalar $input->param("ids") );
127
    my @hold_ids            = split( ',', scalar $input->param("ids") );
Lines 146-174 if ($findborrower) { Link Here
146
    $borrowernumber_hold = $patron->borrowernumber if $patron;
142
    $borrowernumber_hold = $patron->borrowernumber if $patron;
147
}
143
}
148
144
149
if ($form_submitted) {
145
if ($findclub) {
150
    if ($findclub) {
146
    my $club = Koha::Clubs->find( { name => $findclub } );
151
        my $club = Koha::Clubs->find( { name => $findclub } );
147
    if ($club) {
152
        if ($club) {
148
        $club_hold = $club->id;
153
            $club_hold = $club->id;
149
    } else {
150
        my @clubs = Koha::Clubs->search(
151
            [
152
                { name        => { like => '%' . $findclub . '%' } },
153
                { description => { like => '%' . $findclub . '%' } }
154
            ]
155
        )->as_list;
156
        if ( scalar @clubs == 1 ) {
157
            $club_hold = $clubs[0]->id;
158
        } elsif (@clubs) {
159
            $template->param( clubs => \@clubs );
154
        } else {
160
        } else {
155
            my @clubs = Koha::Clubs->search(
161
            $messageclub = "'$findclub'";
156
                [
157
                    { name        => { like => '%' . $findclub . '%' } },
158
                    { description => { like => '%' . $findclub . '%' } }
159
                ]
160
            )->as_list;
161
            if ( scalar @clubs == 1 ) {
162
                $club_hold = $clubs[0]->id;
163
            } elsif (@clubs) {
164
                $template->param( clubs => \@clubs );
165
            } else {
166
                $messageclub = "'$findclub'";
167
            }
168
        }
162
        }
169
    } else {
170
        my @clubs = Koha::Clubs->search()->as_list;
171
        $template->param( clubs => \@clubs );
172
    }
163
    }
173
}
164
}
174
165
Lines 561-566 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
561
                            $num_alreadyheld++;
552
                            $num_alreadyheld++;
562
                        }
553
                        }
563
554
555
                        my $borrower       = $patron;
556
                        my $borrowernumber = $patron->borrowernumber;
557
                        my $user           = C4::Context->userenv->{number};
558
                        my $branchcode     = C4::Context->userenv->{branch};
559
                        my $message        = "Override limitation of hold";
560
                        my @message        = ("Override limitation of hold");
561
                        my $barcode        = $item->{barcode};
562
563
                        my $infos = (
564
                            {
565
                                message        => \@message,
566
                                borrowernumber => $borrowernumber,
567
                                barcode        => $barcode,
568
                                manager_id     => $user,
569
                                branchcode     => $branchcode,
570
                            }
571
                        );
572
573
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
574
                        $json_infos =~ s/"/'/g;
575
576
                        logaction(
577
                            "HOLD", "ISSUE",
578
                            $borrower->{'borrowernumber'},
579
                            $json_infos,
580
                        ) if C4::Context->preference("IssueLog");
581
564
                        push( @available_itemtypes, $item->{itype} );
582
                        push( @available_itemtypes, $item->{itype} );
565
                    } else {
583
                    } else {
566
584
(-)a/svc/renew (-1 / +54 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 53-58 my $date_due; Link Here
53
if ( $input->param('date_due') ) {
54
if ( $input->param('date_due') ) {
54
    $date_due = dt_from_string( scalar $input->param('date_due') );
55
    $date_due = dt_from_string( scalar $input->param('date_due') );
55
}
56
}
57
my $borrower = Koha::Patrons->find($borrowernumber);
58
my $user     = C4::Context->userenv->{'number'};
59
my $message;
60
my @message;
56
61
57
my $data;
62
my $data;
58
$data->{itemnumber}     = $itemnumber;
63
$data->{itemnumber}     = $itemnumber;
Lines 69-74 my $item = Koha::Items->find($itemnumber); Link Here
69
if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference('AllowRenewalOnHoldOverride') ) {
74
if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference('AllowRenewalOnHoldOverride') ) {
70
    $data->{renew_okay} = 1;
75
    $data->{renew_okay} = 1;
71
    $data->{error}      = undef;
76
    $data->{error}      = undef;
77
78
    $message = "Override Renew hold for another";
79
    @message = ("Override Renew hold for another");
80
81
    my $infos = (
82
        {
83
            message        => \@message,
84
            borrowernumber => $borrowernumber,
85
            barcode        => $item->barcode,
86
            manager_id     => $user,
87
            branchcode     => $branchcode,
88
        }
89
    );
90
91
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
92
    $json_infos =~ s/"/'/g;
93
94
    logaction(
95
        "CIRCULATION", "RENEWAL",
96
        $borrower->{'borrowernumber'},
97
        $json_infos,
98
    ) if C4::Context->preference("IssueLog");
99
}
100
101
if ( $data->{error} && $data->{error} eq 'too_many' && C4::Context->preference('AllowRenewalLimitOverride') ) {
102
    $data->{renew_okay} = 1;
103
    $data->{error}      = undef;
104
105
    $message = "Override limit Renew";
106
    @message = ("Override limit Renew");
107
108
    my $infos = (
109
        {
110
            message        => \@message,
111
            borrowernumber => $borrowernumber,
112
            barcode        => $item->barcode,
113
            manager_id     => $user,
114
            branchcode     => $branchcode,
115
        }
116
    );
117
118
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
119
    $json_infos =~ s/"/'/g;
120
121
    logaction(
122
        "CIRCULATION", "RENEWAL",
123
        $borrower->{'borrowernumber'},
124
        $json_infos,
125
    ) if C4::Context->preference("IssueLog");
72
}
126
}
73
127
74
if ( $data->{renew_okay} || ( $seen && $data->{error} eq 'too_unseen' ) ) {
128
if ( $data->{renew_okay} || ( $seen && $data->{error} eq 'too_unseen' ) ) {
75
- 

Return to bug 9762