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

(-)a/C4/Circulation.pm (-75 / +1 lines)
Lines 827-841 sub CanBookBeIssued { Link Here
827
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) );
827
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) );
828
828
829
    my $now = dt_from_string();
829
    my $now = dt_from_string();
830
    my @message_log;
831
830
832
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
831
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
833
832
834
    if ( DateTime->compare( $duedate, $now ) == -1 ) {    # duedate cannot be before now
833
    if ( DateTime->compare( $duedate, $now ) == -1 ) {    # duedate cannot be before now
835
        $needsconfirmation{INVALID_DATE} = $duedate;
834
        $needsconfirmation{INVALID_DATE} = $duedate;
836
        if ($issueconfirmed) {
837
            push( @message_log, "sticky due date is invalid or due date in the past" );
838
        }
839
    }
835
    }
840
836
841
    my $fees = Koha::Charges::Fees->new(
837
    my $fees = Koha::Charges::Fees->new(
Lines 881-889 sub CanBookBeIssued { Link Here
881
    }
877
    }
882
    if ( $patron->is_debarred ) {
878
    if ( $patron->is_debarred ) {
883
        $issuingimpossible{DEBARRED} = 1;
879
        $issuingimpossible{DEBARRED} = 1;
884
        if ($issueconfirmed) {
885
            push( @message_log, "borrower is restricted" );
886
        }
887
    }
880
    }
888
881
889
    if ( $patron->is_expired ) {
882
    if ( $patron->is_expired ) {
Lines 956-971 sub CanBookBeIssued { Link Here
956
    } else {
949
    } else {
957
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
950
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
958
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
951
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
959
            if ($issueconfirmed) {
960
                push( @message_log, "borrower had amend" );
961
            }
962
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
952
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
963
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
953
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
964
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
954
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
965
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
955
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
966
            if ($issueconfirmed) {
967
                push( @message_log, "borrower had amend" );
968
            }
969
        }
956
        }
970
    }
957
    }
971
958
Lines 1046-1054 sub CanBookBeIssued { Link Here
1046
                $needsconfirmation{issued_surname}        = $patron->surname;
1033
                $needsconfirmation{issued_surname}        = $patron->surname;
1047
                $needsconfirmation{issued_cardnumber}     = $patron->cardnumber;
1034
                $needsconfirmation{issued_cardnumber}     = $patron->cardnumber;
1048
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1035
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1049
                if ($issueconfirmed) {
1050
                    push( @message_log, "item is checked out for someone else" );
1051
                }
1052
            }
1036
            }
1053
        }
1037
        }
1054
    }
1038
    }
Lines 1076-1084 sub CanBookBeIssued { Link Here
1076
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1060
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1077
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1061
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1078
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1062
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1079
            if ($issueconfirmed) {
1080
                push( @message_log, "too many checkout" );
1081
            }
1082
        } else {
1063
        } else {
1083
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1064
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1084
            $issuingimpossible{current_loan_count}        = $toomany->{count};
1065
            $issuingimpossible{current_loan_count}        = $toomany->{count};
Lines 1111-1119 sub CanBookBeIssued { Link Here
1111
        } else {
1092
        } else {
1112
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1093
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1113
            $needsconfirmation{item_notforloan}      = $item_object->notforloan;
1094
            $needsconfirmation{item_notforloan}      = $item_object->notforloan;
1114
            if ($issueconfirmed) {
1115
                push( @message_log, "item not for loan" );
1116
            }
1117
        }
1095
        }
1118
    } else {
1096
    } else {
1119
1097
Lines 1159-1167 sub CanBookBeIssued { Link Here
1159
        my $code = $av->count ? $av->next->lib : '';
1137
        my $code = $av->count ? $av->next->lib : '';
1160
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1138
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1161
        $alerts{ITEM_LOST}            = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1139
        $alerts{ITEM_LOST}            = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1162
        if ($issueconfirmed) {
1163
            push( @message_log, "item lost" );
1164
        }
1165
    }
1140
    }
1166
    if ( C4::Context->preference("IndependentBranches") ) {
1141
    if ( C4::Context->preference("IndependentBranches") ) {
1167
        my $userenv = C4::Context->userenv;
1142
        my $userenv = C4::Context->userenv;
Lines 1262-1274 sub CanBookBeIssued { Link Here
1262
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1237
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1263
                    $needsconfirmation{'reswaitingdate'}    = $res->{'waitingdate'};
1238
                    $needsconfirmation{'reswaitingdate'}    = $res->{'waitingdate'};
1264
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1239
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1265
1266
                    if ($issueconfirmed) {
1267
                        push(
1268
                            @message_log,
1269
                            "item is on reserve and waiting, but has been reserved by some other patron"
1270
                        );
1271
                    }
1272
                } elsif ( $restype eq "Reserved" ) {
1240
                } elsif ( $restype eq "Reserved" ) {
1273
1241
1274
                    # The item is on reserve for someone else.
1242
                    # The item is on reserve for someone else.
Lines 1280-1289 sub CanBookBeIssued { Link Here
1280
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1248
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1281
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1249
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1282
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1250
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1283
1284
                    if ($issueconfirmed) {
1285
                        push( @message_log, "item is on reserve for someone else" );
1286
                    }
1287
                } elsif ( $restype eq "Transferred" ) {
1251
                } elsif ( $restype eq "Transferred" ) {
1288
1252
1289
                    # The item is determined hold being transferred for someone else.
1253
                    # The item is determined hold being transferred for someone else.
Lines 1295-1304 sub CanBookBeIssued { Link Here
1295
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1259
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1296
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1260
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1297
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1261
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1298
1299
                    if ($issueconfirmed) {
1300
                        push( @message_log, "item is determined hold being transferred for someone else" );
1301
                    }
1302
                } elsif ( $restype eq "Processing" ) {
1262
                } elsif ( $restype eq "Processing" ) {
1303
1263
1304
                    # The item is determined hold being processed for someone else.
1264
                    # The item is determined hold being processed for someone else.
Lines 1310-1319 sub CanBookBeIssued { Link Here
1310
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1270
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1311
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1271
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1312
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1272
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1313
1314
                    if ($issueconfirmed) {
1315
                        push( @message_log, "item is determined hold being processed for someone else" );
1316
                    }
1317
                }
1273
                }
1318
            }
1274
            }
1319
        }
1275
        }
Lines 1357-1365 sub CanBookBeIssued { Link Here
1357
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1313
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1358
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1314
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1359
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1315
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1360
            if ($issueconfirmed) {
1361
                push( @message_log, "age restriction" );
1362
            }
1363
        } else {
1316
        } else {
1364
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1317
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1365
        }
1318
        }
Lines 1418-1451 sub CanBookBeIssued { Link Here
1418
        }
1371
        }
1419
    }
1372
    }
1420
1373
1421
    my $borrower   = $patron;
1374
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages );
1422
    my $user       = C4::Context->userenv->{number};
1423
    my $branchcode = C4::Context->userenv->{branch};
1424
1425
    # action, cardnumber, barcode, date, heure, user, branche
1426
    if ($issueconfirmed) {
1427
1428
        my $infos = (
1429
            {
1430
                message        => \@message_log,
1431
                borrowernumber => $borrower->borrowernumber,
1432
                barcode        => $barcode,
1433
                manager_id     => $user,
1434
                branchcode     => $branchcode,
1435
            }
1436
        );
1437
1438
        my $json_infos = JSON->new->utf8->pretty->encode($infos);
1439
        $json_infos =~ s/"/'/g;
1440
1441
        logaction(
1442
            "CIRCULATION", "ISSUE",
1443
            $borrower->{'borrowernumber'},
1444
            $json_infos,
1445
        ) if C4::Context->preference("IssueLog");
1446
    }
1447
1448
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log );
1449
}
1375
}
1450
1376
1451
=head2 CanBookBeReturned
1377
=head2 CanBookBeReturned
(-)a/circ/circulation.pl (-3 / +1 lines)
Lines 547-554 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
547
                if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
547
                if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
548
                    $datedue = $booked->end_date;
548
                    $datedue = $booked->end_date;
549
                }
549
                }
550
                $needsconfirmation->{'DEBT'}       = $needsconfirmationDEBT if ($debt_confirmed);
550
                $needsconfirmation->{'DEBT'} = $needsconfirmationDEBT if ($debt_confirmed);
551
                $needsconfirmation->{'OVERRIDDEN'} = $issueconfirmed        if ($issueconfirmed);
552
                my $issue = AddIssue(
551
                my $issue = AddIssue(
553
                    $patron, $barcode, $datedue,
552
                    $patron, $barcode, $datedue,
554
                    $cancelreserve,
553
                    $cancelreserve,
555
- 

Return to bug 40866