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

(-)a/C4/Circulation.pm (-1 / +142 lines)
Lines 779-784 sub CanBookBeIssued { Link Here
779
779
780
    my $onsite_checkout     = $params->{onsite_checkout}     || 0;
780
    my $onsite_checkout     = $params->{onsite_checkout}     || 0;
781
    my $override_high_holds = $params->{override_high_holds} || 0;
781
    my $override_high_holds = $params->{override_high_holds} || 0;
782
    my $issueconfirmed      = $params->{issueconfirmed}      || 0;
782
783
783
    my $item_object = !$barcode ? undef : $params->{item}
784
    my $item_object = !$barcode ? undef : $params->{item}
784
      // Koha::Items->find( { barcode => $barcode } );
785
      // Koha::Items->find( { barcode => $barcode } );
Lines 801-809 sub CanBookBeIssued { Link Here
801
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) );
802
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) );
802
803
803
    my $now = dt_from_string();
804
    my $now = dt_from_string();
805
    my $message;
806
    my @message_log;
807
804
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
808
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
805
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
809
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
806
         $needsconfirmation{INVALID_DATE} = $duedate;
810
         $needsconfirmation{INVALID_DATE} = $duedate;
811
        if ($issueconfirmed) {
812
            if ($message) {
813
                $message = "$message + sticky due date is invalid or due date in the past";
814
            } else {
815
                $message = "sticky due date is invalid or due date in the past";
816
            }
817
            push( @message_log, "sticky due date is invalid or due date in the past" );
818
        }
819
807
    }
820
    }
808
821
809
    my $fees = Koha::Charges::Fees->new(
822
    my $fees = Koha::Charges::Fees->new(
Lines 848-853 sub CanBookBeIssued { Link Here
848
    }
861
    }
849
    if ( $patron->is_debarred ) {
862
    if ( $patron->is_debarred ) {
850
        $issuingimpossible{DEBARRED} = 1;
863
        $issuingimpossible{DEBARRED} = 1;
864
        if ($issueconfirmed) {
865
            if ($message) {
866
                $message = "$message + borrower is restricted";
867
            } else {
868
                $message = "borrower is restricted";
869
            }
870
            push( @message_log, "borrower is restricted" );
871
        }
851
    }
872
    }
852
873
853
    if ( $patron->is_expired ) {
874
    if ( $patron->is_expired ) {
Lines 920-929 sub CanBookBeIssued { Link Here
920
    } else {
941
    } else {
921
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
942
        if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
922
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
943
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
944
            if ($issueconfirmed) {
945
                if ($message) {
946
                    $message = "$message + borrower had amend";
947
                } else {
948
                    $message = "borrower had amend";
949
                }
950
                push( @message_log, "borrower had amend" );
951
            }
923
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
952
        } elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
924
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
953
            $issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
925
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
954
        } elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
926
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
955
            $needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
956
            if ($issueconfirmed) {
957
                if ($message) {
958
                    $message = "$message + borrower had amend";
959
                } else {
960
                    $message = "borrower had amend";
961
                }
962
                push( @message_log, "borrower had amend" );
963
            }
927
        }
964
        }
928
    }
965
    }
929
966
Lines 1008-1013 sub CanBookBeIssued { Link Here
1008
                $needsconfirmation{issued_surname} = $patron->surname;
1045
                $needsconfirmation{issued_surname} = $patron->surname;
1009
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1046
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1010
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1047
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1048
                if ($issueconfirmed) {
1049
                    if ($message) {
1050
                        $message = "$message + item is checked out for someone else ";
1051
                    } else {
1052
                        $message = "item is checked out for someone else";
1053
                    }
1054
                    push( @message_log, "item is checked out for someone else" );
1055
                }
1011
            }
1056
            }
1012
        }
1057
        }
1013
    }
1058
    }
Lines 1031-1036 sub CanBookBeIssued { Link Here
1031
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1076
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1032
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1077
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1033
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1078
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1079
            if ($issueconfirmed) {
1080
                if ($message) {
1081
                    $message = "$message + too many checkout";
1082
                } else {
1083
                    $message = "too many checkout";
1084
                }
1085
                push( @message_log, "too many checkout" );
1086
            }
1034
        } else {
1087
        } else {
1035
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1088
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1036
            $issuingimpossible{current_loan_count}        = $toomany->{count};
1089
            $issuingimpossible{current_loan_count}        = $toomany->{count};
Lines 1058-1063 sub CanBookBeIssued { Link Here
1058
        }else{
1111
        }else{
1059
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1112
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1060
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1113
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1114
            if ($issueconfirmed) {
1115
                if ($message) {
1116
                    $message = "$message + item not for loan";
1117
                } else {
1118
                    $message = "item not for loan";
1119
                }
1120
                push( @message_log, "item not for loan" );
1121
            }
1061
        }
1122
        }
1062
    }
1123
    }
1063
    else {
1124
    else {
Lines 1104-1109 sub CanBookBeIssued { Link Here
1104
        my $code = $av->count ? $av->next->lib : '';
1165
        my $code = $av->count ? $av->next->lib : '';
1105
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1166
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1106
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1167
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1168
        if ($issueconfirmed) {
1169
            if ($message) {
1170
                $message = "$message + item lost";
1171
            } else {
1172
                $message = "item lost";
1173
            }
1174
            push( @message_log, "item lost" );
1175
        }
1107
    }
1176
    }
1108
    if ( C4::Context->preference("IndependentBranches") ) {
1177
    if ( C4::Context->preference("IndependentBranches") ) {
1109
        my $userenv = C4::Context->userenv;
1178
        my $userenv = C4::Context->userenv;
Lines 1200-1205 sub CanBookBeIssued { Link Here
1200
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1269
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1201
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1270
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1202
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1271
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1272
                    if ($issueconfirmed) {
1273
                        if ($message) {
1274
                            $message =
1275
                                "$message + item is on reserve and waiting, but has been reserved by some other patron.";
1276
                        } else {
1277
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1278
                        }
1279
                        push(
1280
                            @message_log,
1281
                            "item is on reserve and waiting, but has been reserved by some other patron"
1282
                        );
1283
                    }
1203
                }
1284
                }
1204
                elsif ( $restype eq "Reserved" ) {
1285
                elsif ( $restype eq "Reserved" ) {
1205
                    # The item is on reserve for someone else.
1286
                    # The item is on reserve for someone else.
Lines 1211-1216 sub CanBookBeIssued { Link Here
1211
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1292
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1212
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1293
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1213
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1294
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1295
                    if ($issueconfirmed) {
1296
                        if ($message) {
1297
                            $message = "$message + item is on reserve for someone else";
1298
                        } else {
1299
                            $message = "item is on reserve for someone else";
1300
                        }
1301
                        push( @message_log, "item is on reserve for someone else" );
1302
                    }
1214
                }
1303
                }
1215
                elsif ( $restype eq "Transferred" ) {
1304
                elsif ( $restype eq "Transferred" ) {
1216
                    # The item is determined hold being transferred for someone else.
1305
                    # The item is determined hold being transferred for someone else.
Lines 1222-1227 sub CanBookBeIssued { Link Here
1222
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1311
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1223
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1312
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1224
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1313
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1314
                    if ($issueconfirmed) {
1315
                        if ($message) {
1316
                            $message = "$message + item is determined hold being transferred for someone else";
1317
                        } else {
1318
                            $message = "item is determined hold being transferred for someone else";
1319
                        }
1320
                        push( @message_log, "item is determined hold being transferred for someone else" );
1321
                    }
1225
                }
1322
                }
1226
                elsif ( $restype eq "Processing" ) {
1323
                elsif ( $restype eq "Processing" ) {
1227
                    # The item is determined hold being processed for someone else.
1324
                    # The item is determined hold being processed for someone else.
Lines 1233-1238 sub CanBookBeIssued { Link Here
1233
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1330
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1234
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1331
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1235
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1332
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1333
                    if ($issueconfirmed) {
1334
                        if ($message) {
1335
                            $message = "$message + item is determined hold being processed for someone else";
1336
                        } else {
1337
                            $message = "item is determined hold being processed for someone else";
1338
                        }
1339
                        push( @message_log, "item is determined hold being processed for someone else" );
1340
                    }
1236
                }
1341
                }
1237
            }
1342
            }
1238
        }
1343
        }
Lines 1276-1281 sub CanBookBeIssued { Link Here
1276
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1381
    if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
1277
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1382
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1278
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1383
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1384
            if ($message) {
1385
                $message = "$message + age restriction";
1386
            } else {
1387
                $message = "age restriction";
1388
            }
1389
            push( @message_log, "age restriction" );
1279
        }
1390
        }
1280
        else {
1391
        else {
1281
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1392
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
Lines 1332-1338 sub CanBookBeIssued { Link Here
1332
        }
1443
        }
1333
    }
1444
    }
1334
1445
1335
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1446
    my $borrower = $patron;
1447
    my $user       = C4::Context->userenv->{number};
1448
    my $branchcode = C4::Context->userenv->{branch};
1449
    my $item       = Koha::Items->find( { barcode => $barcode } );
1450
    my $itemnumber = $item->itemnumber;
1451
1452
    # action, cardnumber, barcode, date, heure, user, branche
1453
    if ($issueconfirmed) {
1454
1455
        my $infos = (
1456
            {
1457
                message        => \@message_log,
1458
                borrowernumber => $borrower->borrowernumber,
1459
                barcode        => $barcode,
1460
                manager_id     => $user,
1461
                branchcode     => $branchcode,
1462
            }
1463
        );
1464
1465
        my $json_infos = JSON->new->utf8->pretty->encode($infos);
1466
        $json_infos =~ s/"/'/g;
1467
1468
        logaction(
1469
            "CIRCULATION", "ISSUE",
1470
            $borrower->{'borrowernumber'},
1471
            $json_infos,
1472
        ) if C4::Context->preference("IssueLog");
1473
    }
1474
1475
1476
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log );
1336
}
1477
}
1337
1478
1338
=head2 CanBookBeReturned
1479
=head2 CanBookBeReturned
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 345-350 if ( @$barcodes && $op eq 'cud-checkout' ) { Link Here
345
                {
345
                {
346
                    onsite_checkout     => $onsite_checkout,
346
                    onsite_checkout     => $onsite_checkout,
347
                    override_high_holds => $override_high_holds || $override_high_holds_tmp || 0,
347
                    override_high_holds => $override_high_holds || $override_high_holds_tmp || 0,
348
                    issueconfirmed      => $issueconfirmed,
348
                }
349
                }
349
            );
350
            );
350
        } catch {
351
        } catch {
351
- 

Return to bug 9762