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

(-)a/C4/Circulation.pm (-2 / +119 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;
834
<<<<<<< HEAD
818
    my @message_log;
835
    my @message_log;
836
=======
837
    my @message;
838
>>>>>>> Bug 9762: Log circulation overrides
819
839
820
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
840
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
841
821
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
842
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
822
         $needsconfirmation{INVALID_DATE} = $duedate;
843
         $needsconfirmation{INVALID_DATE} = $duedate;
823
        if ($issueconfirmed) {
844
        if ($issueconfirmed) {
Lines 826-832 sub CanBookBeIssued { Link Here
826
            } else {
847
            } else {
827
                $message = "sticky due date is invalid or due date in the past";
848
                $message = "sticky due date is invalid or due date in the past";
828
            }
849
            }
850
<<<<<<< HEAD
829
            push( @message_log, "sticky due date is invalid or due date in the past" );
851
            push( @message_log, "sticky due date is invalid or due date in the past" );
852
=======
853
            push( @message, "sticky due date is invalid or due date in the past" );
854
>>>>>>> Bug 9762: Log circulation overrides
830
        }
855
        }
831
856
832
    }
857
    }
Lines 880-886 sub CanBookBeIssued { Link Here
880
            } else {
905
            } else {
881
                $message = "borrower is restricted";
906
                $message = "borrower is restricted";
882
            }
907
            }
908
<<<<<<< HEAD
883
            push( @message_log, "borrower is restricted" );
909
            push( @message_log, "borrower is restricted" );
910
=======
911
            push( @message, "borrower is restricted" );
912
>>>>>>> Bug 9762: Log circulation overrides
884
        }
913
        }
885
    }
914
    }
886
915
Lines 960-966 sub CanBookBeIssued { Link Here
960
                } else {
989
                } else {
961
                    $message = "borrower had amend";
990
                    $message = "borrower had amend";
962
                }
991
                }
992
<<<<<<< HEAD
963
                push( @message_log, "borrower had amend" );
993
                push( @message_log, "borrower had amend" );
994
=======
995
                push( @message, "borrower had amend" );
996
>>>>>>> Bug 9762: Log circulation overrides
964
            }
997
            }
965
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
998
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
966
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
999
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
Lines 972-978 sub CanBookBeIssued { Link Here
972
                } else {
1005
                } else {
973
                    $message = "borrower had amend";
1006
                    $message = "borrower had amend";
974
                }
1007
                }
1008
<<<<<<< HEAD
975
                push( @message_log, "borrower had amend" );
1009
                push( @message_log, "borrower had amend" );
1010
=======
1011
                push( @message, "borrower had amend" );
1012
>>>>>>> Bug 9762: Log circulation overrides
976
            }
1013
            }
977
        }
1014
        }
978
    }
1015
    }
Lines 1049-1058 sub CanBookBeIssued { Link Here
1049
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1086
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1050
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1087
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1051
            } else {
1088
            } else {
1089
<<<<<<< HEAD
1052
                $needsconfirmation{ISSUED_TO_ANOTHER}     = 1;
1090
                $needsconfirmation{ISSUED_TO_ANOTHER}     = 1;
1053
                $needsconfirmation{issued_firstname}      = $patron->firstname;
1091
                $needsconfirmation{issued_firstname}      = $patron->firstname;
1054
                $needsconfirmation{issued_surname}        = $patron->surname;
1092
                $needsconfirmation{issued_surname}        = $patron->surname;
1055
                $needsconfirmation{issued_cardnumber}     = $patron->cardnumber;
1093
                $needsconfirmation{issued_cardnumber}     = $patron->cardnumber;
1094
=======
1095
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1096
                $needsconfirmation{issued_firstname} = $patron->firstname;
1097
                $needsconfirmation{issued_surname} = $patron->surname;
1098
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1099
>>>>>>> Bug 9762: Log circulation overrides
1056
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1100
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1057
                if ($issueconfirmed) {
1101
                if ($issueconfirmed) {
1058
                    if ($message) {
1102
                    if ($message) {
Lines 1060-1066 sub CanBookBeIssued { Link Here
1060
                    } else {
1104
                    } else {
1061
                        $message = "item is checked out for someone else";
1105
                        $message = "item is checked out for someone else";
1062
                    }
1106
                    }
1107
<<<<<<< HEAD
1063
                    push( @message_log, "item is checked out for someone else" );
1108
                    push( @message_log, "item is checked out for someone else" );
1109
=======
1110
                    push( @message, "item is checked out for someone else" );
1111
>>>>>>> Bug 9762: Log circulation overrides
1064
                }
1112
                }
1065
            }
1113
            }
1066
        }
1114
        }
Lines 1095-1101 sub CanBookBeIssued { Link Here
1095
                } else {
1143
                } else {
1096
                    $message = "too many checkout";
1144
                    $message = "too many checkout";
1097
                }
1145
                }
1146
<<<<<<< HEAD
1098
                push( @message_log, "too many checkout" );
1147
                push( @message_log, "too many checkout" );
1148
=======
1149
                push( @message, "too many checkout" );
1150
>>>>>>> Bug 9762: Log circulation overrides
1099
            }
1151
            }
1100
        } else {
1152
        } else {
1101
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1153
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
Lines 1130-1136 sub CanBookBeIssued { Link Here
1130
                } else {
1182
                } else {
1131
                    $message = "item not for loan";
1183
                    $message = "item not for loan";
1132
                }
1184
                }
1185
<<<<<<< HEAD
1133
                push( @message_log, "item not for loan" );
1186
                push( @message_log, "item not for loan" );
1187
=======
1188
                push( @message, "item not for loan" );
1189
>>>>>>> Bug 9762: Log circulation overrides
1134
            }
1190
            }
1135
        }
1191
        }
1136
    } else {
1192
    } else {
Lines 1183-1189 sub CanBookBeIssued { Link Here
1183
            } else {
1239
            } else {
1184
                $message = "item lost";
1240
                $message = "item lost";
1185
            }
1241
            }
1242
<<<<<<< HEAD
1186
            push( @message_log, "item lost" );
1243
            push( @message_log, "item lost" );
1244
=======
1245
            push( @message, "item lost" );
1246
>>>>>>> Bug 9762: Log circulation overrides
1187
        }
1247
        }
1188
    }
1248
    }
1189
    if ( C4::Context->preference("IndependentBranches") ) {
1249
    if ( C4::Context->preference("IndependentBranches") ) {
Lines 1292-1301 sub CanBookBeIssued { Link Here
1292
                        } else {
1352
                        } else {
1293
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1353
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1294
                        }
1354
                        }
1355
<<<<<<< HEAD
1295
                        push(
1356
                        push(
1296
                            @message_log,
1357
                            @message_log,
1297
                            "item is on reserve and waiting, but has been reserved by some other patron"
1358
                            "item is on reserve and waiting, but has been reserved by some other patron"
1298
                        );
1359
                        );
1360
=======
1361
                        push( @message, "item is on reserve and waiting, but has been reserved by some other patron" );
1362
>>>>>>> Bug 9762: Log circulation overrides
1299
                    }
1363
                    }
1300
                }
1364
                }
1301
                elsif ( $restype eq "Reserved" ) {
1365
                elsif ( $restype eq "Reserved" ) {
Lines 1314-1320 sub CanBookBeIssued { Link Here
1314
                        } else {
1378
                        } else {
1315
                            $message = "item is on reserve for someone else";
1379
                            $message = "item is on reserve for someone else";
1316
                        }
1380
                        }
1381
<<<<<<< HEAD
1317
                        push( @message_log, "item is on reserve for someone else" );
1382
                        push( @message_log, "item is on reserve for someone else" );
1383
=======
1384
                        push( @message, "item is on reserve for someone else" );
1385
>>>>>>> Bug 9762: Log circulation overrides
1318
                    }
1386
                    }
1319
                }
1387
                }
1320
                elsif ( $restype eq "Transferred" ) {
1388
                elsif ( $restype eq "Transferred" ) {
Lines 1333-1339 sub CanBookBeIssued { Link Here
1333
                        } else {
1401
                        } else {
1334
                            $message = "item is determined hold being transferred for someone else";
1402
                            $message = "item is determined hold being transferred for someone else";
1335
                        }
1403
                        }
1404
<<<<<<< HEAD
1336
                        push( @message_log, "item is determined hold being transferred for someone else" );
1405
                        push( @message_log, "item is determined hold being transferred for someone else" );
1406
=======
1407
                        push( @message, "item is determined hold being transferred for someone else" );
1408
>>>>>>> Bug 9762: Log circulation overrides
1337
                    }
1409
                    }
1338
                }
1410
                }
1339
                elsif ( $restype eq "Processing" ) {
1411
                elsif ( $restype eq "Processing" ) {
Lines 1352-1358 sub CanBookBeIssued { Link Here
1352
                        } else {
1424
                        } else {
1353
                            $message = "item is determined hold being processed for someone else";
1425
                            $message = "item is determined hold being processed for someone else";
1354
                        }
1426
                        }
1427
<<<<<<< HEAD
1355
                        push( @message_log, "item is determined hold being processed for someone else" );
1428
                        push( @message_log, "item is determined hold being processed for someone else" );
1429
=======
1430
                        push( @message, "item is determined hold being processed for someone else" );
1431
>>>>>>> Bug 9762: Log circulation overrides
1356
                    }
1432
                    }
1357
                }
1433
                }
1358
            }
1434
            }
Lines 1402-1408 sub CanBookBeIssued { Link Here
1402
            } else {
1478
            } else {
1403
                $message = "age restriction";
1479
                $message = "age restriction";
1404
            }
1480
            }
1481
<<<<<<< HEAD
1405
            push( @message_log, "age restriction" );
1482
            push( @message_log, "age restriction" );
1483
=======
1484
            push( @message, "age restriction" );
1485
>>>>>>> Bug 9762: Log circulation overrides
1406
        }
1486
        }
1407
        else {
1487
        else {
1408
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1488
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
Lines 1473-1479 sub CanBookBeIssued { Link Here
1473
1553
1474
        my $infos = (
1554
        my $infos = (
1475
            {
1555
            {
1556
<<<<<<< HEAD
1476
                message        => \@message_log,
1557
                message        => \@message_log,
1558
=======
1559
                message        => \@message,
1560
>>>>>>> Bug 9762: Log circulation overrides
1477
                borrowernumber => $borrower->borrowernumber,
1561
                borrowernumber => $borrower->borrowernumber,
1478
                barcode        => $barcode,
1562
                barcode        => $barcode,
1479
                manager_id     => $user,
1563
                manager_id     => $user,
Lines 1492-1498 sub CanBookBeIssued { Link Here
1492
    }
1576
    }
1493
1577
1494
1578
1579
<<<<<<< HEAD
1495
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log );
1580
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log );
1581
=======
1582
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1583
>>>>>>> Bug 9762: Log circulation overrides
1496
}
1584
}
1497
1585
1498
=head2 CanBookBeReturned
1586
=head2 CanBookBeReturned
Lines 2552-2560 sub AddReturn { Link Here
2552
                $messages->{'TransferArrived'} = $transfer->frombranch;
2640
                $messages->{'TransferArrived'} = $transfer->frombranch;
2553
2641
2554
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2642
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2643
<<<<<<< HEAD
2555
                $validTransfer = 1
2644
                $validTransfer = 1
2556
                    if defined $transfer->reason && $transfer->reason eq 'Reserve';
2645
                    if defined $transfer->reason && $transfer->reason eq 'Reserve';
2557
            } else {
2646
            } else {
2647
=======
2648
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2649
            }
2650
            else {
2651
>>>>>>> Bug 9762: Log circulation overrides
2558
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2652
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2559
                $messages->{'WrongTransferItem'} = $item->itemnumber;
2653
                $messages->{'WrongTransferItem'} = $item->itemnumber;
2560
                $messages->{'TransferTrigger'}   = $transfer->reason;
2654
                $messages->{'TransferTrigger'}   = $transfer->reason;
Lines 3309-3315 sub CanBookBeRenewed { Link Here
3309
3403
3310
    # There is an item level hold on this item, no other item can fill the hold
3404
    # There is an item level hold on this item, no other item can fill the hold
3311
    return ( 0, "on_reserve" )
3405
    return ( 0, "on_reserve" )
3406
<<<<<<< HEAD
3312
        if ( $item->current_holds->search( { non_priority => 0 } )->count );
3407
        if ( $item->current_holds->search( { non_priority => 0 } )->count );
3408
=======
3409
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3410
3411
    my $issuing_rule = Koha::CirculationRules->get_effective_rules(
3412
        {
3413
            categorycode => $patron->categorycode,
3414
            itemtype     => $item->effective_itemtype,
3415
            branchcode   => $branchcode,
3416
            rules        => [
3417
                'renewalsallowed',
3418
                'lengthunit',
3419
                'unseen_renewals_allowed'
3420
            ]
3421
        }
3422
    );
3423
3424
    return ( 0, "too_many" )
3425
        if not $issuing_rule->{renewalsallowed}
3426
        or $issuing_rule->{renewalsallowed} <= $issue->renewals_count;
3427
>>>>>>> Bug 9762: Log circulation overrides
3313
3428
3314
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3429
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3315
    my @fillable_holds = ();
3430
    my @fillable_holds = ();
Lines 3446-3453 fallback to a true value Link Here
3446
3561
3447
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3562
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3448
3563
3449
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing
3564
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
3565
3452
=cut
3566
=cut
3453
3567
Lines 3618-3623 sub AddRenewal { Link Here
3618
                DelUniqueDebarment( { borrowernumber => $borrowernumber, type => 'OVERDUES' } );
3732
                DelUniqueDebarment( { borrowernumber => $borrowernumber, type => 'OVERDUES' } );
3619
            }
3733
            }
3620
3734
3735
<<<<<<< HEAD
3621
            # Add renewal record
3736
            # Add renewal record
3622
            my $renewal = Koha::Checkouts::Renewal->new(
3737
            my $renewal = Koha::Checkouts::Renewal->new(
3623
                {
3738
                {
Lines 3662-3667 sub AddRenewal { Link Here
3662
        }
3777
        }
3663
    );
3778
    );
3664
3779
3780
=======
3781
>>>>>>> Bug 9762: Log circulation overrides
3665
    unless ($skip_record_index) {
3782
    unless ($skip_record_index) {
3666
3783
3667
        # We index now, after the transaction is committed
3784
        # 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 (+36 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 );
43
<<<<<<< HEAD
42
use C4::Search      qw( enabled_staff_search_views );
44
use C4::Search      qw( enabled_staff_search_views );
45
=======
46
use C4::Search qw( enabled_staff_search_views );
47
use C4::Log qw( logaction );
48
>>>>>>> Bug 9762: Log circulation overrides
43
49
44
use Koha::Biblios;
50
use Koha::Biblios;
45
use Koha::Checkouts;
51
use Koha::Checkouts;
Lines 560-565 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
560
                        } else {
566
                        } else {
561
                            $num_alreadyheld++;
567
                            $num_alreadyheld++;
562
                        }
568
                        }
569
<<<<<<< HEAD
570
=======
571
572
                        my $borrower       = $patron;
573
                        my $borrowernumber = $patron->borrowernumber;
574
                        my $user           = C4::Context->userenv->{number};
575
                        my $branchcode     = C4::Context->userenv->{branch};
576
                        my $message        = "Override limitation of hold";
577
                        my @message        = ("Override limitation of hold");
578
                        my $barcode        = $item->{barcode};
579
580
                        my $infos = (
581
                            {
582
                                message        => \@message,
583
                                borrowernumber => $borrowernumber,
584
                                barcode        => $barcode,
585
                                manager_id     => $user,
586
                                branchcode     => $branchcode,
587
                            }
588
                        );
589
590
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
591
                        $json_infos =~ s/"/'/g;
592
593
                        logaction(
594
                            "HOLD", "ISSUE",
595
                            $borrower->{'borrowernumber'},
596
                            $json_infos,
597
                        ) if C4::Context->preference("IssueLog");
598
>>>>>>> Bug 9762: Log circulation overrides
563
599
564
                        push( @available_itemtypes, $item->{itype} );
600
                        push( @available_itemtypes, $item->{itype} );
565
                    } else {
601
                    } else {
(-)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