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

(-)a/C4/Circulation.pm (-34 / +151 lines)
Lines 23-28 use DateTime; Link Here
23
use POSIX qw( floor );
23
use POSIX qw( floor );
24
use YAML::XS;
24
use YAML::XS;
25
use Encode;
25
use Encode;
26
use JSON;
26
27
27
use C4::Context;
28
use C4::Context;
28
use C4::Stats qw( UpdateStats );
29
use C4::Stats qw( UpdateStats );
Lines 318-323 A recall for this item was found, and the item needs to be transferred to the re Link Here
318
319
319
=cut
320
=cut
320
321
322
my $query = CGI->new;
323
324
my $stickyduedate  = $query->param('stickyduedate');
325
my $duedatespec    = $query->param('duedatespec');
326
my $restoreduedatespec  = $query->param('restoreduedatespec') || $duedatespec;
327
if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) {
328
    undef $restoreduedatespec;
329
}
330
my $issueconfirmed = $query->param('issueconfirmed');
331
my $cancelreserve  = $query->param('cancelreserve');
332
my $cancel_recall  = $query->param('cancel_recall');
333
my $recall_id      = $query->param('recall_id');
334
my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
335
my $charges        = $query->param('charges') || q{};
336
321
sub transferbook {
337
sub transferbook {
322
    my $params = shift;
338
    my $params = shift;
323
    my $tbr      = $params->{to_branch};
339
    my $tbr      = $params->{to_branch};
Lines 794-802 sub CanBookBeIssued { Link Here
794
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) );
810
    my $circ_library = Koha::Libraries->find( _GetCircControlBranch($item_object, $patron) );
795
811
796
    my $now = dt_from_string();
812
    my $now = dt_from_string();
813
    my $message;
814
    my @message;
815
797
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
816
    $duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
817
798
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
818
    if (DateTime->compare($duedate,$now) == -1 ) { # duedate cannot be before now
799
         $needsconfirmation{INVALID_DATE} = $duedate;
819
         $needsconfirmation{INVALID_DATE} = $duedate;
820
        if ($issueconfirmed) {
821
            if ($message ) {
822
                $message = "$message + sticky due date is invalid or due date in the past";
823
            } else {
824
                $message = "sticky due date is invalid or due date in the past";
825
            }
826
            push(@message, "sticky due date is invalid or due date in the past");
827
        }
828
800
    }
829
    }
801
830
802
    my $fees = Koha::Charges::Fees->new(
831
    my $fees = Koha::Charges::Fees->new(
Lines 905-914 sub CanBookBeIssued { Link Here
905
    else {
934
    else {
906
        if ( $non_issues_charges > $amountlimit && $allowfineoverride ) {
935
        if ( $non_issues_charges > $amountlimit && $allowfineoverride ) {
907
            $needsconfirmation{DEBT} = $non_issues_charges;
936
            $needsconfirmation{DEBT} = $non_issues_charges;
937
            if ($issueconfirmed) {
938
                if ($message) {
939
                    $message = "$message + borrower had amend";
940
                } else {
941
                    $message = "borrower had amend";
942
                }
943
                push(@message,  "borrower had amend");
944
            }
908
        } elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) {
945
        } elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) {
909
            $issuingimpossible{DEBT} = $non_issues_charges;
946
            $issuingimpossible{DEBT} = $non_issues_charges;
910
        } elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) {
947
        } elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) {
911
            $needsconfirmation{DEBT} = $non_issues_charges;
948
            $needsconfirmation{DEBT} = $non_issues_charges;
949
            if ($issueconfirmed) {
950
                if ($message) {
951
                    $message = "$message + borrower had amend";
952
                } else {
953
                    $message = "borrower had amend";
954
                }
955
                push(@message,  "borrower had amend");
956
            }
912
        }
957
        }
913
    }
958
    }
914
959
Lines 985-997 sub CanBookBeIssued { Link Here
985
        } else {
1030
        } else {
986
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
1031
            if ( C4::Context->preference('AutoReturnCheckedOutItems') ) {
987
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
1032
                $alerts{RETURNED_FROM_ANOTHER} = { patron => $patron };
988
            }
1033
            } else {
989
            else {
990
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
1034
                $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
991
                $needsconfirmation{issued_firstname} = $patron->firstname;
1035
                $needsconfirmation{issued_firstname} = $patron->firstname;
992
                $needsconfirmation{issued_surname} = $patron->surname;
1036
                $needsconfirmation{issued_surname} = $patron->surname;
993
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
1037
                $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
994
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1038
                $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
1039
                if ($issueconfirmed) {
1040
                    if ($message) {
1041
                        $message = "$message + item is checked out for someone else ";
1042
                    } else {
1043
                        $message = "item is checked out for someone else";
1044
                    }
1045
                    push(@message,  "item is checked out for someone else");
1046
                }
995
            }
1047
            }
996
        }
1048
        }
997
    }
1049
    }
Lines 1013-1018 sub CanBookBeIssued { Link Here
1013
            $needsconfirmation{TOO_MANY} = $toomany->{reason};
1065
            $needsconfirmation{TOO_MANY} = $toomany->{reason};
1014
            $needsconfirmation{current_loan_count} = $toomany->{count};
1066
            $needsconfirmation{current_loan_count} = $toomany->{count};
1015
            $needsconfirmation{max_loans_allowed} = $toomany->{max_allowed};
1067
            $needsconfirmation{max_loans_allowed} = $toomany->{max_allowed};
1068
            if ($issueconfirmed) {
1069
                if ($message) {
1070
                    $message = "$message + too many checkout";
1071
                } else {
1072
                    $message = "too many checkout";
1073
                }
1074
                push(@message, "too many checkout");
1075
            }
1016
        } else {
1076
        } else {
1017
            $issuingimpossible{TOO_MANY} = $toomany->{reason};
1077
            $issuingimpossible{TOO_MANY} = $toomany->{reason};
1018
            $issuingimpossible{current_loan_count} = $toomany->{count};
1078
            $issuingimpossible{current_loan_count} = $toomany->{count};
Lines 1039-1044 sub CanBookBeIssued { Link Here
1039
        }else{
1099
        }else{
1040
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1100
            $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
1041
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1101
            $needsconfirmation{item_notforloan} = $item_object->notforloan;
1102
            if ($issueconfirmed) {
1103
                if ($message) {
1104
                    $message = "$message + item not for loan";
1105
                } else {
1106
                    $message = "item not for loan";
1107
                }
1108
                push(@message, "item not for loan");
1109
            }
1042
        }
1110
        }
1043
    }
1111
    }
1044
    else {
1112
    else {
Lines 1085-1090 sub CanBookBeIssued { Link Here
1085
        my $code = $av->count ? $av->next->lib : '';
1153
        my $code = $av->count ? $av->next->lib : '';
1086
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1154
        $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
1087
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1155
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
1156
        if ($issueconfirmed) {
1157
            if ($message) {
1158
                $message = "$message + item lost";
1159
            } else {
1160
                $message = "item lost";
1161
            }
1162
            push(@message, "item lost");
1163
        }
1088
    }
1164
    }
1089
    if ( C4::Context->preference("IndependentBranches") ) {
1165
    if ( C4::Context->preference("IndependentBranches") ) {
1090
        my $userenv = C4::Context->userenv;
1166
        my $userenv = C4::Context->userenv;
Lines 1181-1186 sub CanBookBeIssued { Link Here
1181
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1257
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1182
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1258
                    $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
1183
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1259
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1260
                    if ($issueconfirmed) {
1261
                        if($message) {
1262
                            $message = "$message + item is on reserve and waiting, but has been reserved by some other patron.";
1263
                        } else {
1264
                            $message = "item is on reserve and waiting, but has been reserved by some other patron.";
1265
                        }
1266
                        push(@message, "item is on reserve and waiting, but has been reserved by some other patron");
1267
                    }
1184
                }
1268
                }
1185
                elsif ( $restype eq "Reserved" ) {
1269
                elsif ( $restype eq "Reserved" ) {
1186
                    # The item is on reserve for someone else.
1270
                    # The item is on reserve for someone else.
Lines 1192-1197 sub CanBookBeIssued { Link Here
1192
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1276
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1193
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1277
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1194
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1278
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1279
                    if ($issueconfirmed) {
1280
                        if($message) {
1281
                            $message = "$message + item is on reserve for someone else";
1282
                        } else {
1283
                            $message = "item is on reserve for someone else";
1284
                        }
1285
                        push(@message, "item is on reserve for someone else");
1286
                    }
1195
                }
1287
                }
1196
                elsif ( $restype eq "Transferred" ) {
1288
                elsif ( $restype eq "Transferred" ) {
1197
                    # The item is determined hold being transferred for someone else.
1289
                    # The item is determined hold being transferred for someone else.
Lines 1203-1208 sub CanBookBeIssued { Link Here
1203
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1295
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1204
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1296
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1205
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1297
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1298
                    if ($issueconfirmed) {
1299
                        if($message) {
1300
                            $message = "$message + item is determined hold being transferred for someone else";
1301
                        } else {
1302
                            $message = "item is determined hold being transferred for someone else";
1303
                        }
1304
                        push(@message, "item is determined hold being transferred for someone else");
1305
                    }
1206
                }
1306
                }
1207
                elsif ( $restype eq "Processing" ) {
1307
                elsif ( $restype eq "Processing" ) {
1208
                    # The item is determined hold being processed for someone else.
1308
                    # The item is determined hold being processed for someone else.
Lines 1214-1219 sub CanBookBeIssued { Link Here
1214
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1314
                    $needsconfirmation{'resbranchcode'} = $res->{branchcode};
1215
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1315
                    $needsconfirmation{'resreservedate'} = $res->{reservedate};
1216
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1316
                    $needsconfirmation{'reserve_id'} = $res->{reserve_id};
1317
                    if ($issueconfirmed) {
1318
                        if($message) {
1319
                            $message = "$message + item is determined hold being processed for someone else";
1320
                        } else {
1321
                            $message = "item is determined hold being processed for someone else";
1322
                        }
1323
                        push(@message, "item is determined hold being processed for someone else");                        
1324
                    }
1217
                }
1325
                }
1218
            }
1326
            }
1219
        }
1327
        }
Lines 1225-1230 sub CanBookBeIssued { Link Here
1225
    if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) {
1333
    if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) {
1226
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1334
        if ( C4::Context->preference('AgeRestrictionOverride') ) {
1227
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1335
            $needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
1336
            if($message) {
1337
                $message = "$message + age restriction";
1338
            } else {
1339
                $message = "age restriction";
1340
            }
1341
            push(@message, "age restriction");
1228
        }
1342
        }
1229
        else {
1343
        else {
1230
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
1344
            $issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
Lines 1281-1290 sub CanBookBeIssued { Link Here
1281
        }
1395
        }
1282
    }
1396
    }
1283
1397
1398
    my $borrower = $patron;
1399
    #my $borrowernumber = $patron->cardnumber;
1400
    my $user = C4::Context->userenv->{number};
1401
    my $branchcode = C4::Context->userenv->{branch};
1402
    my $item = Koha::Items->find( { barcode => $barcode } );
1403
    my $itemnumber = $item->itemnumber;
1404
1405
    # action, cardnumber, barcode, date, heure, user, branche
1406
    if ($issueconfirmed) {
1407
1408
        my $infos = ({
1409
            message     => \@message,
1410
            borrowernumber => $borrower->borrowernumber,
1411
            barcode => $barcode,
1412
            manager_id => $user,
1413
            branchcode =>  $branchcode,
1414
        });
1415
1416
        my $json_infos = JSON->new->utf8->pretty->encode($infos);
1417
        $json_infos =~ s/"/'/g;
1418
1419
        logaction(
1420
            "CIRCULATION", "ISSUE",
1421
            $borrower->{'borrowernumber'},
1422
            $json_infos,
1423
        ) if C4::Context->preference("IssueLog");
1424
    } 
1425
1426
1284
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1427
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, );
1285
}
1428
}
1286
1429
1287
=head2 CanBookBeReturned
1430
=head2 CanBookBeReturnedcd 
1288
1431
1289
  ($returnallowed, $message) = CanBookBeReturned($item, $branch)
1432
  ($returnallowed, $message) = CanBookBeReturned($item, $branch)
1290
1433
Lines 1741-1765 sub AddIssue { Link Here
1741
                }
1884
                }
1742
            }
1885
            }
1743
1886
1744
            my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckout');
1745
            if ($yaml) {
1746
                $yaml = "$yaml\n\n";
1747
1748
                my $rules;
1749
                eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); };
1750
                if ($@) {
1751
                    warn "Unable to parse UpdateNotForLoanStatusOnCheckout syspref : $@";
1752
                }
1753
                else {
1754
                    foreach my $key ( keys %$rules ) {
1755
                        if ( $item_object->notforloan eq $key ) {
1756
                            $item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 });
1757
                            last;
1758
                        }
1759
                    }
1760
                }
1761
            }
1762
1763
            # Record the fact that this book was issued.
1887
            # Record the fact that this book was issued.
1764
            C4::Stats::UpdateStats(
1888
            C4::Stats::UpdateStats(
1765
                {
1889
                {
Lines 2333-2340 sub AddReturn { Link Here
2333
                $transfer->receive;
2457
                $transfer->receive;
2334
                $messages->{'TransferArrived'} = $transfer->frombranch;
2458
                $messages->{'TransferArrived'} = $transfer->frombranch;
2335
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2459
                # validTransfer=1 allows us returning the item back if the reserve is cancelled
2336
                $validTransfer = 1
2460
                $validTransfer = 1 if $transfer->reason eq 'Reserve';
2337
                  if defined $transfer->reason && $transfer->reason eq 'Reserve';
2338
            }
2461
            }
2339
            else {
2462
            else {
2340
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
2463
                $messages->{'WrongTransfer'}     = $transfer->tobranch;
Lines 3125-3133 fallback to a true value Link Here
3125
3248
3126
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3249
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
3127
3250
3128
C<$skip_record_index> is an optional boolean flag to indicate whether queuing the search indexing
3129
should be skipped for this renewal.
3130
3131
=cut
3251
=cut
3132
3252
3133
sub AddRenewal {
3253
sub AddRenewal {
Lines 3238-3244 sub AddRenewal { Link Here
3238
        $renews = ( $item_object->renewals || 0 ) + 1;
3358
        $renews = ( $item_object->renewals || 0 ) + 1;
3239
        $item_object->renewals($renews);
3359
        $item_object->renewals($renews);
3240
        $item_object->onloan($datedue);
3360
        $item_object->onloan($datedue);
3241
        # Don't index as we are in a transaction, skip hardcoded here
3361
        # Don't index as we are in a transaction
3242
        $item_object->store({ log_action => 0, skip_record_index => 1 });
3362
        $item_object->store({ log_action => 0, skip_record_index => 1 });
3243
3363
3244
        # Charge a new rental fee, if applicable
3364
        # Charge a new rental fee, if applicable
Lines 3325-3336 sub AddRenewal { Link Here
3325
            }
3445
            }
3326
        });
3446
        });
3327
    });
3447
    });
3328
3448
    # We index now, after the transaction is committed
3329
    unless( $skip_record_index ){
3449
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
3330
        # We index now, after the transaction is committed
3450
    $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3331
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
3332
        $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" );
3333
    }
3334
3451
3335
    return $datedue;
3452
    return $datedue;
3336
}
3453
}
(-)a/circ/circulation.pl (-1 / +32 lines)
Lines 38-43 use C4::Members; Link Here
38
use C4::Biblio qw( TransformMarcToKoha );
38
use C4::Biblio qw( TransformMarcToKoha );
39
use C4::Search qw( new_record_from_zebra );
39
use C4::Search qw( new_record_from_zebra );
40
use C4::Reserves;
40
use C4::Reserves;
41
use C4::Log qw( logaction );
41
use Koha::Holds;
42
use Koha::Holds;
42
use C4::Context;
43
use C4::Context;
43
use CGI::Session;
44
use CGI::Session;
Lines 214-220 if ( @$barcodes == 0 && $charges eq 'yes' ) { Link Here
214
# STEP 2 : FIND BORROWER
215
# STEP 2 : FIND BORROWER
215
# if there is a list of find borrowers....
216
# if there is a list of find borrowers....
216
#
217
#
217
my $message;
218
218
if ($findborrower) {
219
if ($findborrower) {
219
    Koha::Plugins->call( 'patron_barcode_transform', \$findborrower );
220
    Koha::Plugins->call( 'patron_barcode_transform', \$findborrower );
220
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
221
    my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
Lines 288-293 if ($patron) { Link Here
288
# STEP 3 : ISSUING
289
# STEP 3 : ISSUING
289
#
290
#
290
#
291
#
292
my $message;
293
my @message;
294
291
if (@$barcodes) {
295
if (@$barcodes) {
292
  my $checkout_infos;
296
  my $checkout_infos;
293
  for my $barcode ( @$barcodes ) {
297
  for my $barcode ( @$barcodes ) {
Lines 398-406 if (@$barcodes) { Link Here
398
                    }
402
                    }
399
                );
403
                );
400
                $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
404
                $recall_id = ( $recall and $recall->id ) ? $recall->id : undef;
405
401
            }
406
            }
402
            my $issue = AddIssue( $patron, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, recall_id => $recall_id, } );
407
            my $issue = AddIssue( $patron, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, recall_id => $recall_id, } );
403
            $template_params->{issue} = $issue;
408
            $template_params->{issue} = $issue;
409
410
            my $borrower = $patron;
411
            my $borrowernumber = $patron->borrowernumber;
412
            my $user = C4::Context->userenv->{number};
413
            my $branchcode = C4::Context->userenv->{branch};
414
            $message = "Restriction overridden temporarily";
415
            @message = ("Restriction overridden temporarily");
416
417
            if ($issueconfirmed) {
418
                my $infos = ({
419
                    message    => \@message,
420
                    borrowernumber => $borrowernumber,
421
                    barcode => $barcode,
422
                    manager_id => $user,
423
                    branchcode =>  $branchcode,
424
                });
425
426
                my $json_infos = JSON->new->utf8->pretty->encode($infos);
427
                $json_infos =~ s/"/'/g;
428
                
429
                logaction(
430
                    "CIRCULATION", "ISSUE",
431
                    $borrower->{'borrowernumber'},
432
                    $json_infos,
433
                ) if C4::Context->preference("IssueLog");
434
            }
404
            $session->clear('auto_renew');
435
            $session->clear('auto_renew');
405
            $inprocess = 1;
436
            $inprocess = 1;
406
        }
437
        }
(-)a/circ/renew.pl (-2 / +48 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 62-70 if ($barcode) { Link Here
62
63
63
        if ($checkout) {
64
        if ($checkout) {
64
65
65
            $patron = $checkout->patron;
66
            $borrower = $issue->patron();
67
            my $borrowernumber = $borrower->borrowernumber;
68
            my $user = C4::Context->userenv->{number};
69
            my $branchcode = C4::Context->userenv->{branch};
70
            my $message;
71
            my @message;
66
72
67
            if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) {
73
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
68
                my $can_renew;
74
                my $can_renew;
69
                my $info;
75
                my $info;
70
                ( $can_renew, $error, $info ) =
76
                ( $can_renew, $error, $info ) =
Lines 74-79 if ($barcode) { Link Here
74
                    if ($override_holds) {
80
                    if ($override_holds) {
75
                        $can_renew = 1;
81
                        $can_renew = 1;
76
                        $error     = undef;
82
                        $error     = undef;
83
84
                        $message = "Override Renew hold for another";
85
                        @message = ("Override Renew hold for another");
86
87
                        my $infos = ({
88
                            message     => \@message,
89
                            borrowernumber => $borrowernumber,
90
                            barcode => $barcode,
91
                            manager_id => $user,
92
                            branchcode =>  $branchcode,
93
                        });
94
95
                        my $json_infos = JSON->new->utf8->pretty->encode($infos);
96
                        $json_infos =~ s/"/'/g;
97
98
                        logaction(
99
                            "CIRCULATION", "RENEWAL",
100
                            $borrower->{'borrowernumber'},
101
                            $json_infos,
102
                        ) if C4::Context->preference("RenewalLog");
77
                    }
103
                    }
78
                    else {
104
                    else {
79
                        $can_renew = 0;
105
                        $can_renew = 0;
Lines 106-111 if ($barcode) { Link Here
106
                        }
132
                        }
107
                    );
133
                    );
108
                    $template->param( date_due => $date_due );
134
                    $template->param( date_due => $date_due );
135
136
                    $message = "Override limit Renew";
137
                    @message = ("Override limit Renew");
138
139
                    my $infos = ({
140
                        message    => \@message,
141
                        borrowernumber => $borrowernumber,
142
                        barcode => $barcode,
143
                        manager_id => $user,
144
                        branchcode =>  $branchcode,
145
                    });
146
147
                    my $json_infos = JSON->new->utf8->pretty->encode($infos);
148
                    $json_infos =~ s/"/'/g;
149
150
                    logaction(
151
                        "CIRCULATION", "RENEWAL",
152
                        $borrower->{'borrowernumber'},
153
                        $json_infos,
154
                    ) if C4::Context->preference("RenewalLog");
109
                }
155
                }
110
            }
156
            }
111
            else {
157
            else {
(-)a/circ/returns.pl (-1 / +25 lines)
Lines 43-48 use C4::Members; Link Here
43
use C4::Output qw( output_html_with_http_headers );
43
use C4::Output qw( output_html_with_http_headers );
44
use C4::Reserves qw( ModReserve ModReserveAffect GetOtherReserves );
44
use C4::Reserves qw( ModReserve ModReserveAffect GetOtherReserves );
45
use C4::RotatingCollections;
45
use C4::RotatingCollections;
46
use C4::Log qw( logaction );
46
use Koha::AuthorisedValues;
47
use Koha::AuthorisedValues;
47
use Koha::BiblioFrameworks;
48
use Koha::BiblioFrameworks;
48
use Koha::Calendar;
49
use Koha::Calendar;
Lines 175-180 if ( $query->param('reserve_id') ) { Link Here
175
            diffbranch     => 1,
176
            diffbranch     => 1,
176
        );
177
        );
177
    }
178
    }
179
} else {
180
    my $message = "return an element that is reserved";
181
    my @message = ("return an element that is reserved");
182
    my $user = C4::Context->userenv->{number};
183
    my $branchcode = C4::Context->userenv->{branch};
184
    my $barcode = $query->param('barcode');
185
186
    my $infos = ({
187
        message    => \@message,
188
        #'card number' => $cardnumber,
189
        barcode    => $barcode,
190
        manager_id => $user,
191
        branchcode => $branchcode,
192
    });
193
194
    my $json_infos = JSON->new->utf8->pretty->encode($infos);
195
    $json_infos =~ s/"/'/g;
196
197
    logaction(
198
        "CIRCULATION", "RETURN",
199
        $session,
200
        $json_infos,
201
    ) if C4::Context->preference("ReturnLog");
178
}
202
}
179
203
180
if ( $query->param('recall_id') ) {
204
if ( $query->param('recall_id') ) {
Lines 419-425 if ($barcode) { Link Here
419
    }
443
    }
420
444
421
    # Mark missing bundle items as lost and report unexpected items
445
    # Mark missing bundle items as lost and report unexpected items
422
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') && !$query->param('do_not_verify_items_bundle_contents') ) {
446
    if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') ) {
423
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
447
        my $BundleLostValue = C4::Context->preference('BundleLostValue');
424
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
448
        my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
425
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
449
        my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
(-)a/reserve/request.pl (-8 / +62 lines)
Lines 27-32 script to place reserves/requests Link Here
27
=cut
27
=cut
28
28
29
use Modern::Perl;
29
use Modern::Perl;
30
use Data::Dumper;
30
31
31
use CGI qw ( -utf8 );
32
use CGI qw ( -utf8 );
32
use List::MoreUtils qw( uniq );
33
use List::MoreUtils qw( uniq );
Lines 40-45 use C4::Serials qw( CountSubscriptionFromBiblionumber ); Link Here
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 509-515 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
509
                            && !$exceeded_maxreserves
511
                            && !$exceeded_maxreserves
510
                            && $can_item_be_reserved eq 'OK'
512
                            && $can_item_be_reserved eq 'OK'
511
                            && IsAvailableForItemLevelRequest($item_object, $patron, undef)
513
                            && IsAvailableForItemLevelRequest($item_object, $patron, undef)
512
                        ) || C4::Context->preference('AllowHoldPolicyOverride')
514
                        ) #|| C4::Context->preference('AllowHoldPolicyOverride')
513
                             # If AllowHoldPolicyOverride is set, it overrides EVERY restriction
515
                             # If AllowHoldPolicyOverride is set, it overrides EVERY restriction
514
                             # not just branch item rules
516
                             # not just branch item rules
515
                      )
517
                      )
Lines 524-540 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
524
                            my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
526
                            my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
525
                            $item->{default_pickup_location} = $default_pickup_location;
527
                            $item->{default_pickup_location} = $default_pickup_location;
526
                        }
528
                        }
527
                        elsif ( C4::Context->preference('AllowHoldPolicyOverride') ){
529
                        # elsif ( C4::Context->preference('AllowHoldPolicyOverride') ){
528
                             $num_items_available++;
530
                        #      $num_items_available++;
529
                             $item->{override} = 1;
531
                        #      $item->{override} = 1;
530
                            my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
532
                        #     my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
531
                            $item->{default_pickup_location} = $default_pickup_location;
533
                        #     $item->{default_pickup_location} = $default_pickup_location;
532
                        }
534
                        #
535
                        # }
533
                        else {
536
                        else {
534
                            $item->{available} = 0;
537
                            $item->{available} = 0;
535
                            $item->{not_holdable} = "no_valid_pickup_location";
538
                            $item->{not_holdable} = "no_valid_pickup_location";
536
                        }
539
                        }
537
540
541
                        push( @available_itemtypes, $item->{itype} );
542
                    }
543
                    elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
544
                        # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
545
                        # with the exception of itemAlreadyOnHold because, you know, the item is already on hold
546
                        if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) {
547
                            # Send the pickup locations count to the UI, the pickup locations will be pulled using the API
548
                            my @pickup_locations = $item_object->pickup_locations({ patron => $patron })->as_list;
549
                            $item->{pickup_locations_count} = scalar @pickup_locations;
550
551
                            if ( @pickup_locations ) {
552
                                $num_items_available++;
553
                                $item->{override} = 1;
554
555
                                my $default_pickup_location;
556
557
                                ($default_pickup_location) = grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
558
559
                                $item->{default_pickup_location} = $default_pickup_location;
560
                            }
561
                            else {
562
                                $item->{available} = 0;
563
                                $item->{not_holdable} = "no_valid_pickup_location";
564
                            }
565
                        } else { $num_alreadyheld++ }
566
567
                        my $borrower = $patron;
568
                        my $borrowernumber = $patron->borrowernumber;
569
                        my $user = C4::Context->userenv->{number};
570
                        my $branchcode = C4::Context->userenv->{branch};
571
                        my $message = "Override limitation of hold";
572
                        my @message = ("Override limitation of hold");
573
                        my $barcode = $input->param('barcode');
574
575
576
                        my $infos = ({
577
                            message     => \@message,
578
                            borrowernumber => $borrowernumber,
579
                            barcode => $barcode,
580
                            manager_id => $user,
581
                            branchcode =>  $branchcode,
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
538
                        push( @available_itemtypes, $item->{itype} );
593
                        push( @available_itemtypes, $item->{itype} );
539
                    } else {
594
                    } else {
540
                        # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
595
                        # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
541
- 

Return to bug 9762