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

(-)a/C4/Circulation.pm (-73 / +59 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 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 815-823 sub CanBookBeIssued { Link Here
815
831
816
    my $now = dt_from_string();
832
    my $now = dt_from_string();
817
    my $message;
833
    my $message;
818
    my @message_log;
834
    my @message;
819
835
820
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
836
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
837
821
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
838
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
822
         $needsconfirmation{INVALID_DATE} = $duedate;
839
         $needsconfirmation{INVALID_DATE} = $duedate;
823
        if ($issueconfirmed) {
840
        if ($issueconfirmed) {
Lines 826-832 sub CanBookBeIssued { Link Here
826
            } else {
843
            } else {
827
                $message = "sticky due date is invalid or due date in the past";
844
                $message = "sticky due date is invalid or due date in the past";
828
            }
845
            }
829
            push( @message_log, "sticky due date is invalid or due date in the past" );
846
            push( @message, "sticky due date is invalid or due date in the past" );
830
        }
847
        }
831
848
832
    }
849
    }
Lines 880-886 sub CanBookBeIssued { Link Here
880
            } else {
897
            } else {
881
                $message = "borrower is restricted";
898
                $message = "borrower is restricted";
882
            }
899
            }
883
            push( @message_log, "borrower is restricted" );
900
            push( @message, "borrower is restricted" );
884
        }
901
        }
885
    }
902
    }
886
903
Lines 960-966 sub CanBookBeIssued { Link Here
960
                } else {
977
                } else {
961
                    $message = "borrower had amend";
978
                    $message = "borrower had amend";
962
                }
979
                }
963
                push( @message_log, "borrower had amend" );
980
                push( @message, "borrower had amend" );
964
            }
981
            }
965
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
982
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
966
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
983
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
Lines 972-978 sub CanBookBeIssued { Link Here
972
                } else {
989
                } else {
973
                    $message = "borrower had amend";
990
                    $message = "borrower had amend";
974
                }
991
                }
975
                push( @message_log, "borrower had amend" );
992
                push( @message, "borrower had amend" );
976
            }
993
            }
977
        }
994
        }
978
    }
995
    }
Lines 1049-1058 sub CanBookBeIssued { Link Here
1049
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1066
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1050
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1067
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1051
            } else {
1068
            } else {
1052
                $needsconfirmation{ISSUED_TO_ANOTHER}     = 1;
1069
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1053
                $needsconfirmation{issued_firstname}      = $patron->firstname;
1070
                $needsconfirmation{issued_firstname} = $patron->firstname;
1054
                $needsconfirmation{issued_surname}        = $patron->surname;
1071
                $needsconfirmation{issued_surname} = $patron->surname;
1055
                $needsconfirmation{issued_cardnumber}     = $patron->cardnumber;
1072
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1056
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1073
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1057
                if ($issueconfirmed) {
1074
                if ($issueconfirmed) {
1058
                    if ($message) {
1075
                    if ($message) {
Lines 1060-1066 sub CanBookBeIssued { Link Here
1060
                    } else {
1077
                    } else {
1061
                        $message = "item is checked out for someone else";
1078
                        $message = "item is checked out for someone else";
1062
                    }
1079
                    }
1063
                    push( @message_log, "item is checked out for someone else" );
1080
                    push( @message, "item is checked out for someone else" );
1064
                }
1081
                }
1065
            }
1082
            }
1066
        }
1083
        }
Lines 1095-1101 sub CanBookBeIssued { Link Here
1095
                } else {
1112
                } else {
1096
                    $message = "too many checkout";
1113
                    $message = "too many checkout";
1097
                }
1114
                }
1098
                push( @message_log, "too many checkout" );
1115
                push( @message, "too many checkout" );
1099
            }
1116
            }
1100
        } else {
1117
        } else {
1101
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1118
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
Lines 1130-1136 sub CanBookBeIssued { Link Here
1130
                } else {
1147
                } else {
1131
                    $message = "item not for loan";
1148
                    $message = "item not for loan";
1132
                }
1149
                }
1133
                push( @message_log, "item not for loan" );
1150
                push( @message, "item not for loan" );
1134
            }
1151
            }
1135
        }
1152
        }
1136
    } else {
1153
    } else {
Lines 1183-1189 sub CanBookBeIssued { Link Here
1183
            } else {
1200
            } else {
1184
                $message = "item lost";
1201
                $message = "item lost";
1185
            }
1202
            }
1186
            push( @message_log, "item lost" );
1203
            push( @message, "item lost" );
1187
        }
1204
        }
1188
    }
1205
    }
1189
    if ( C4::Context->preference("IndependentBranches") ) {
1206
    if ( C4::Context->preference("IndependentBranches") ) {
Lines 1292-1301 sub CanBookBeIssued { Link Here
1292
                        } else {
1309
                        } else {
1293
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1310
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1294
                        }
1311
                        }
1295
                        push(
1312
                        push( @message, "item is on reserve and waiting, but has been reserved by some other patron" );
1296
                            @message_log,
1297
                            "item is on reserve and waiting, but has been reserved by some other patron"
1298
                        );
1299
                    }
1313
                    }
1300
                }
1314
                }
1301
                elsif ( $restype eq "Reserved" ) {
1315
                elsif ( $restype eq "Reserved" ) {
Lines 1314-1320 sub CanBookBeIssued { Link Here
1314
                        } else {
1328
                        } else {
1315
                            $message = "item is on reserve for someone else";
1329
                            $message = "item is on reserve for someone else";
1316
                        }
1330
                        }
1317
                        push( @message_log, "item is on reserve for someone else" );
1331
                        push( @message, "item is on reserve for someone else" );
1318
                    }
1332
                    }
1319
                }
1333
                }
1320
                elsif ( $restype eq "Transferred" ) {
1334
                elsif ( $restype eq "Transferred" ) {
Lines 1333-1339 sub CanBookBeIssued { Link Here
1333
                        } else {
1347
                        } else {
1334
                            $message = "item is determined hold being transferred for someone else";
1348
                            $message = "item is determined hold being transferred for someone else";
1335
                        }
1349
                        }
1336
                        push( @message_log, "item is determined hold being transferred for someone else" );
1350
                        push( @message, "item is determined hold being transferred for someone else" );
1337
                    }
1351
                    }
1338
                }
1352
                }
1339
                elsif ( $restype eq "Processing" ) {
1353
                elsif ( $restype eq "Processing" ) {
Lines 1352-1358 sub CanBookBeIssued { Link Here
1352
                        } else {
1366
                        } else {
1353
                            $message = "item is determined hold being processed for someone else";
1367
                            $message = "item is determined hold being processed for someone else";
1354
                        }
1368
                        }
1355
                        push( @message_log, "item is determined hold being processed for someone else" );
1369
                        push( @message, "item is determined hold being processed for someone else" );
1356
                    }
1370
                    }
1357
                }
1371
                }
1358
            }
1372
            }
Lines 1402-1408 sub CanBookBeIssued { Link Here
1402
            } else {
1416
            } else {
1403
                $message = "age restriction";
1417
                $message = "age restriction";
1404
            }
1418
            }
1405
            push( @message_log, "age restriction" );
1419
            push( @message, "age restriction" );
1406
        }
1420
        }
1407
        else {
1421
        else {
1408
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1422
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
Lines 1473-1479 sub CanBookBeIssued { Link Here
1473
1487
1474
        my $infos = (
1488
        my $infos = (
1475
            {
1489
            {
1476
                message        => \@message_log,
1490
                message        => \@message,
1477
                borrowernumber => $borrower->borrowernumber,
1491
                borrowernumber => $borrower->borrowernumber,
1478
                barcode        => $barcode,
1492
                barcode        => $barcode,
1479
                manager_id     => $user,
1493
                manager_id     => $user,
Lines 1492-1498 sub CanBookBeIssued { Link Here
1492
    }
1506
    }
1493
1507
1494
1508
1495
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log );
1509
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1496
}
1510
}
1497
1511
1498
=head2 CanBookBeReturned
1512
=head2 CanBookBeReturned
Lines 2552-2560 sub AddReturn { Link Here
2552
                $messages->{'TransferArrived'} = $transfer->frombranch;
2566
                $messages->{'TransferArrived'} = $transfer->frombranch;
2553
2567
2554
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2568
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2555
                $validTransfer = 1
2569
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2556
                    if defined $transfer->reason && $transfer->reason eq 'Reserve';
2570
            }
2557
            } else {
2571
            else {
2558
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2572
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2559
                $messages->{'WrongTransferItem'} = $item->itemnumber;
2573
                $messages->{'WrongTransferItem'} = $item->itemnumber;
2560
                $messages->{'TransferTrigger'}   = $transfer->reason;
2574
                $messages->{'TransferTrigger'}   = $transfer->reason;
Lines 3309-3315 sub CanBookBeRenewed { Link Here
3309
3323
3310
    # There is an item level hold on this item, no other item can fill the hold
3324
    # There is an item level hold on this item, no other item can fill the hold
3311
    return ( 0, "on_reserve" )
3325
    return ( 0, "on_reserve" )
3312
        if ( $item->current_holds->search( { non_priority => 0 } )->count );
3326
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3327
3328
    my $issuing_rule = Koha::CirculationRules->get_effective_rules(
3329
        {
3330
            categorycode => $patron->categorycode,
3331
            itemtype     => $item->effective_itemtype,
3332
            branchcode   => $branchcode,
3333
            rules        => [
3334
                'renewalsallowed',
3335
                'lengthunit',
3336
                'unseen_renewals_allowed'
3337
            ]
3338
        }
3339
    );
3340
3341
    return ( 0, "too_many" )
3342
        if not $issuing_rule->{renewalsallowed}
3343
        or $issuing_rule->{renewalsallowed} <= $issue->renewals_count;
3313
3344
3314
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3345
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3315
    my @fillable_holds = ();
3346
    my @fillable_holds = ();
Lines 3446-3453 fallback to a true value Link Here
3446
3477
3447
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3478
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3448
3479
3449
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing
3480
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing should be skipped for this renewal.
3450
should be skipped for this renewal.
3451
3481
3452
=cut
3482
=cut
3453
3483
Lines 3618-3667 sub AddRenewal { Link Here
3618
                DelUniqueDebarment( { borrowernumber => $borrowernumber, type => 'OVERDUES' } );
3648
                DelUniqueDebarment( { borrowernumber => $borrowernumber, type => 'OVERDUES' } );
3619
            }
3649
            }
3620
3650
3621
            # Add renewal record
3622
            my $renewal = Koha::Checkouts::Renewal->new(
3623
                {
3624
                    checkout_id  => $issue->issue_id,
3625
                    interface    => C4::Context->interface,
3626
                    renewal_type => $renewal_type,
3627
                    renewer_id   => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
3628
                    seen         => $seen,
3629
                }
3630
            )->store();
3631
3632
            # Add the renewal to stats
3633
            C4::Stats::UpdateStats(
3634
                {
3635
                    branch         => $item_object->renewal_branchcode( { branch => $branch } ),
3636
                    type           => 'renew',
3637
                    amount         => $charge,
3638
                    itemnumber     => $itemnumber,
3639
                    itemtype       => $itemtype,
3640
                    location       => $item_object->location,
3641
                    borrowernumber => $borrowernumber,
3642
                    ccode          => $item_object->ccode,
3643
                    categorycode   => $patron->categorycode,
3644
                    interface      => C4::Context->interface,
3645
                }
3646
            );
3647
3648
            #Update borrowers.lastseen
3649
            $patron->update_lastseen('renewal');
3650
3651
            #Log the renewal
3652
            logaction( "CIRCULATION", "RENEWAL", $borrowernumber, $itemnumber )
3653
                if C4::Context->preference("RenewalLog");
3654
3655
            Koha::Plugins->call(
3656
                'after_circ_action',
3657
                {
3658
                    action  => 'renewal',
3659
                    payload => { checkout => $issue->get_from_storage }
3660
                }
3661
            );
3662
        }
3663
    );
3664
3665
    unless ($skip_record_index) {
3651
    unless ($skip_record_index) {
3666
3652
3667
        # We index now, after the transaction is committed
3653
        # We index now, after the transaction is committed
(-)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 518-523 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
518
                    push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key );
522
                    push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key );
519
                }
523
                }
520
            }
524
            }
525
521
            unless ($confirm_required) {
526
            unless ($confirm_required) {
522
                my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
527
                my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED};
523
                if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
528
                if ( C4::Context->preference('UseRecalls') && !$recall_id ) {
Lines 531-536 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
531
                        }
536
                        }
532
                    );
537
                    );
533
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
538
                    $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
539
534
                }
540
                }
535
541
536
                # If booked (alerts or confirmation) update datedue to end of booking
542
                # If booked (alerts or confirmation) update datedue to end of booking
Lines 551-558 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
551
                $session->clear('auto_renew');
557
                $session->clear('auto_renew');
552
                $inprocess = 1;
558
                $inprocess = 1;
553
            }
559
            }
554
        }
555
560
561
        }
556
        if (   $needsconfirmation->{RESERVE_WAITING}
562
        if (   $needsconfirmation->{RESERVE_WAITING}
557
            or $needsconfirmation->{RESERVED}
563
            or $needsconfirmation->{RESERVED}
558
            or $needsconfirmation->{TRANSFERRED}
564
            or $needsconfirmation->{TRANSFERRED}
Lines 564-569 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
564
            );
570
            );
565
        }
571
        }
566
572
573
                my $borrower       = $patron;
574
                my $borrowernumber = $patron->borrowernumber;
575
                my $user           = C4::Context->userenv->{number};
576
                my $branchcode     = C4::Context->userenv->{branch};
577
                $message = "Restriction overridden temporarily";
578
                @message = ("Restriction overridden temporarily");
579
580
                if ($issueconfirmed) {
581
                    my $infos = (
582
                        {
583
                            message        => \@message,
584
                            borrowernumber => $borrowernumber,
585
                            barcode        => $barcode,
586
                            manager_id     => $user,
587
                            branchcode     => $branchcode,
588
                        }
589
                    );
590
591
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
592
                    $json_infos =~ s/"/'/g;
593
594
                    logaction(
595
                        "CIRCULATION", "ISSUE",
596
                        $borrower->{'borrowernumber'},
597
                        $json_infos,
598
                    ) if C4::Context->preference("IssueLog");
599
                }
600
                $session->clear('auto_renew');
601
                $inprocess = 1;
602
603
604
567
        # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue
605
        # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue
568
        $patron = Koha::Patrons->find($borrowernumber);
606
        $patron = Koha::Patrons->find($borrowernumber);
569
        $template_params->{issuecount} = $patron->checkouts->count;
607
        $template_params->{issuecount} = $patron->checkouts->count;
(-)a/circ/renew.pl (-3 / +55 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-80 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;
77
                    } else {
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");
106
                    }
107
                    else {
78
                        $can_renew = 0;
108
                        $can_renew = 0;
79
                    }
109
                    }
80
                }
110
                }
Lines 104-109 if ( $op eq 'cud-renew' && $barcode ) { Link Here
104
                        }
134
                        }
105
                    );
135
                    );
106
                    $template->param( date_due => $date_due );
136
                    $template->param( date_due => $date_due );
137
138
                    $message = "Override limit Renew";
139
                    @message = ("Override limit Renew");
140
141
                    my $infos = (
142
                        {
143
                            message        => \@message,
144
                            borrowernumber => $borrowernumber,
145
                            barcode        => $barcode,
146
                            manager_id     => $user,
147
                            branchcode     => $branchcode,
148
                        }
149
                    );
150
151
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
152
                    $json_infos =~ s/"/'/g;
153
154
                    logaction(
155
                        "CIRCULATION", "RENEWAL",
156
                        $borrower->{'borrowernumber'},
157
                        $json_infos,
158
                    ) if C4::Context->preference("RenewalLog");
107
                }
159
                }
108
            } else {
160
            } else {
109
                $error = "patron_restricted";
161
                $error = "patron_restricted";
(-)a/circ/returns.pl (-5 / +42 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 187-192 if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve' ) { Link Here
187
            $transfer->transit;
188
            $transfer->transit;
188
        }
189
        }
189
    }
190
    }
191
    # check if we have other reserves for this document, if we have a result send the message of transfer
192
    # FIXME do we need to do this if we didn't take the cancel_reserve branch above?
193
    my ( undef, $nextreservinfo, undef ) = CheckReserves($item);
194
195
    if ( $userenv_branch ne $nextreservinfo->{'branchcode'} ) {
196
        my $patron = Koha::Patrons->find( $nextreservinfo->{'borrowernumber'} );
197
        $template->param(
198
            itemtitle      => $biblio->title,
199
            itembiblionumber => $biblio->biblionumber,
200
            iteminfo       => $biblio->author,
201
            patron         => $patron,
202
            diffbranch     => 1,
203
        );
204
    }
205
} else {
206
    my $message    = "return an element that is reserved";
207
    my @message    = ("return an element that is reserved");
208
    my $user       = C4::Context->userenv->{number};
209
    my $branchcode = C4::Context->userenv->{branch};
210
    my $barcode    = $query->param('barcode');
211
212
    my $infos = (
213
        {
214
            message => \@message,
215
216
            #'card number' => $cardnumber,
217
            barcode    => $barcode,
218
            manager_id => $user,
219
            branchcode => $branchcode,
220
        }
221
    );
222
223
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
224
    $json_infos =~ s/"/'/g;
225
226
    logaction(
227
        "CIRCULATION", "RETURN",
228
        $session,
229
        $json_infos,
230
    ) if C4::Context->preference("ReturnLog");
190
}
231
}
191
232
192
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
233
if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {
Lines 458-468 if ( $barcode && ( $op eq 'cud-checkin' || $op eq 'cud-affect_reserve' ) ) { Link Here
458
    }
499
    }
459
500
460
    # Mark missing bundle items as lost and report unexpected items
501
    # Mark missing bundle items as lost and report unexpected items
461
    if (   $item
502
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') ) {
462
        && $item->is_bundle
463
        && $query->param('confirm_items_bundle_return')
464
        && !$query->param('do_not_verify_items_bundle_contents') )
465
    {
466
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
503
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
467
        my $barcodes        = $query->param('verify-items-bundle-contents-barcodes');
504
        my $barcodes        = $query->param('verify-items-bundle-contents-barcodes');
468
        my @barcodes        = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
505
        my @barcodes        = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
(-)a/reserve/request.pl (-1 / +30 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 39-45 use C4::Koha qw( getitemtypeimagelocation ); Link Here
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 561-566 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
561
                            $num_alreadyheld++;
563
                            $num_alreadyheld++;
562
                        }
564
                        }
563
565
566
                        my $borrower       = $patron;
567
                        my $borrowernumber = $patron->borrowernumber;
568
                        my $user           = C4::Context->userenv->{number};
569
                        my $branchcode     = C4::Context->userenv->{branch};
570
                        my $message        = "Override limitation of hold";
571
                        my @message        = ("Override limitation of hold");
572
                        my $barcode        = $item->{barcode};
573
574
                        my $infos = (
575
                            {
576
                                message        => \@message,
577
                                borrowernumber => $borrowernumber,
578
                                barcode        => $barcode,
579
                                manager_id     => $user,
580
                                branchcode     => $branchcode,
581
                            }
582
                        );
583
584
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
585
                        $json_infos =~ s/"/'/g;
586
587
                        logaction(
588
                            "HOLD", "ISSUE",
589
                            $borrower->{'borrowernumber'},
590
                            $json_infos,
591
                        ) if C4::Context->preference("IssueLog");
592
564
                        push( @available_itemtypes, $item->{itype} );
593
                        push( @available_itemtypes, $item->{itype} );
565
                    } else {
594
                    } else {
566
595
(-)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