|
Lines 127-132
use Koha::Library::FloatLimits;
Link Here
|
| 127 |
use Koha::Patron::Quotas; |
127 |
use Koha::Patron::Quotas; |
| 128 |
use Koha::Patron::Quota; |
128 |
use Koha::Patron::Quota; |
| 129 |
use Koha::Patron::Quota::Usage; |
129 |
use Koha::Patron::Quota::Usage; |
|
|
130 |
use Koha::Patron::Quota::Usages; |
| 130 |
use Carp qw( carp ); |
131 |
use Carp qw( carp ); |
| 131 |
use List::MoreUtils qw( any ); |
132 |
use List::MoreUtils qw( any ); |
| 132 |
use Scalar::Util qw( looks_like_number blessed ); |
133 |
use Scalar::Util qw( looks_like_number blessed ); |
|
Lines 1376-1386
sub CanBookBeIssued {
Link Here
|
| 1376 |
|
1377 |
|
| 1377 |
# CHECK FOR QUOTAS |
1378 |
# CHECK FOR QUOTAS |
| 1378 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1379 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
| 1379 |
unless ( $quota->has_available_quota ) { |
1380 |
if (ref($quota) eq 'ARRAY') { |
|
|
1381 |
# Multiple available quotas found - need confirmation from user |
| 1382 |
$needsconfirmation{QUOTA_SELECT} = $quota; |
| 1383 |
} |
| 1384 |
elsif (!$quota->has_available_quota) { |
| 1380 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1385 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
| 1381 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1386 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
| 1382 |
available => $quota->available_quota, |
1387 |
available => $quota->available_quota, |
| 1383 |
total => $quota->allocation, |
1388 |
total => $quota->allocation, |
| 1384 |
used => $quota->used, |
1389 |
used => $quota->used, |
| 1385 |
}; |
1390 |
}; |
| 1386 |
} |
1391 |
} |
|
Lines 1638-1643
sub AddIssue {
Link Here
|
| 1638 |
my $recall_id = $params && $params->{recall_id}; |
1643 |
my $recall_id = $params && $params->{recall_id}; |
| 1639 |
my $confirmations = $params->{confirmations}; |
1644 |
my $confirmations = $params->{confirmations}; |
| 1640 |
my $forced = $params->{forced}; |
1645 |
my $forced = $params->{forced}; |
|
|
1646 |
my $selected_quota_id = $params && $params->{selected_quota_id}; |
| 1641 |
my $dbh = C4::Context->dbh; |
1647 |
my $dbh = C4::Context->dbh; |
| 1642 |
my $barcodecheck = CheckValidBarcode($barcode); |
1648 |
my $barcodecheck = CheckValidBarcode($barcode); |
| 1643 |
|
1649 |
|
|
Lines 2023-2031
sub AddIssue {
Link Here
|
| 2023 |
if C4::Context->preference('RealTimeHoldsQueue'); |
2029 |
if C4::Context->preference('RealTimeHoldsQueue'); |
| 2024 |
|
2030 |
|
| 2025 |
# Check quotas and record usage if needed |
2031 |
# Check quotas and record usage if needed |
| 2026 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
2032 |
my $quota; |
| 2027 |
# Update patron's used quota value |
2033 |
if ($selected_quota_id) { |
| 2028 |
$quota->add_usage({ |
2034 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
|
|
2035 |
} else { |
| 2036 |
$quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber); |
| 2037 |
} |
| 2038 |
|
| 2039 |
if ($quota) { |
| 2040 |
# Update patron's used quota value |
| 2041 |
$quota->add_usage({ |
| 2029 |
patron_id => $patron->patron_id, |
2042 |
patron_id => $patron->patron_id, |
| 2030 |
issue_id => $issue->issue_id, |
2043 |
issue_id => $issue->issue_id, |
| 2031 |
}); |
2044 |
}); |
|
Lines 3403-3412
sub CanBookBeRenewed {
Link Here
|
| 3403 |
} |
3416 |
} |
| 3404 |
} |
3417 |
} |
| 3405 |
|
3418 |
|
| 3406 |
# CHECK FOR QUOTAS |
3419 |
# # CHECK FOR QUOTAS |
| 3407 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
3420 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
| 3408 |
unless ( $quota->has_available_quota ) { |
3421 |
|
| 3409 |
return ( 0, "QUOTA_EXCEEDED" ); |
3422 |
# Get current active quota for the patron |
|
|
3423 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
| 3424 |
|
| 3425 |
if (!$active_quota->has_available_quota) { |
| 3426 |
return (0, "QUOTA_EXCEEDED"); |
| 3427 |
} |
| 3410 |
} |
3428 |
} |
| 3411 |
} |
3429 |
} |
| 3412 |
|
3430 |
|
|
Lines 3525-3536
sub AddRenewal {
Link Here
|
| 3525 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
3543 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
| 3526 |
|
3544 |
|
| 3527 |
# Check quotas and record usage if needed |
3545 |
# Check quotas and record usage if needed |
| 3528 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
3546 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
| 3529 |
# Update patron's used quota value |
3547 |
# Get current active quota for the patron |
| 3530 |
$quota->add_usage({ |
3548 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
| 3531 |
patron_id => $patron->patron_id, |
3549 |
# Update patron's used quota value |
| 3532 |
issue_id => $issue->issue_id, |
3550 |
$active_quota->add_usage({ |
| 3533 |
}); |
3551 |
patron_id => $patron->patron_id, |
|
|
3552 |
issue_id => $issue->issue_id, |
| 3553 |
}); |
| 3554 |
} |
| 3534 |
} |
3555 |
} |
| 3535 |
|
3556 |
|
| 3536 |
my $schema = Koha::Database->schema; |
3557 |
my $schema = Koha::Database->schema; |