|
Lines 1377-1401
sub CanBookBeIssued {
Link Here
|
| 1377 |
} |
1377 |
} |
| 1378 |
|
1378 |
|
| 1379 |
# CHECK FOR QUOTAS |
1379 |
# CHECK FOR QUOTAS |
| 1380 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1380 |
if ( my $quotas = $patron->all_quotas->filter_by_active ) { |
| 1381 |
if (ref($quota) eq 'ARRAY') { |
1381 |
if ( $quotas->count > 1 ) { |
|
|
1382 |
|
| 1382 |
# Multiple available quotas found - need confirmation from user |
1383 |
# Multiple available quotas found - need confirmation from user |
| 1383 |
$needsconfirmation{QUOTA_SELECT} = $quota; |
1384 |
$needsconfirmation{QUOTA_SELECT} = $quotas; |
| 1384 |
} |
1385 |
} elsif ( $quotas->count == 1 ) { |
| 1385 |
elsif (!$quota->has_available_quota) { |
1386 |
my $quota = $quotas->next; |
| 1386 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1387 |
if ( !$quota->has_available_quota ) { |
| 1387 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1388 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
| 1388 |
available => $quota->available_quota, |
1389 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
| 1389 |
total => $quota->allocation, |
1390 |
available => $quota->available_quota, |
| 1390 |
used => $quota->used, |
1391 |
total => $quota->allocation, |
| 1391 |
}; |
1392 |
used => $quota->used, |
| 1392 |
} |
1393 |
}; |
| 1393 |
else { |
1394 |
} else { |
| 1394 |
$issuingimpossible{QUOTA_EXCEEDED} = { |
1395 |
$issuingimpossible{QUOTA_EXCEEDED} = { |
| 1395 |
available => $quota->available_quota, |
1396 |
available => $quota->available_quota, |
| 1396 |
total => $quota->allocation, |
1397 |
total => $quota->allocation, |
| 1397 |
used => $quota->used, |
1398 |
used => $quota->used, |
| 1398 |
}; |
1399 |
}; |
|
|
1400 |
} |
| 1399 |
} |
1401 |
} |
| 1400 |
} |
1402 |
} |
| 1401 |
} |
1403 |
} |
|
Lines 2023-2029
sub AddIssue {
Link Here
|
| 2023 |
if ($selected_quota_id) { |
2025 |
if ($selected_quota_id) { |
| 2024 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
2026 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
| 2025 |
} else { |
2027 |
} else { |
| 2026 |
$quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber); |
2028 |
$quota = $patron->all_quotas->filter_by_active->single; |
| 2027 |
} |
2029 |
} |
| 2028 |
|
2030 |
|
| 2029 |
if ($quota) { |
2031 |
if ($quota) { |
|
Lines 3388-3401
sub CanBookBeRenewed {
Link Here
|
| 3388 |
} |
3390 |
} |
| 3389 |
|
3391 |
|
| 3390 |
# # CHECK FOR QUOTAS |
3392 |
# # CHECK FOR QUOTAS |
| 3391 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3393 |
if ( my $quota_usage = Koha::Patron::Quota::Usages->find( { issue_id => $issue->issue_id } ) ) { |
| 3392 |
|
3394 |
|
| 3393 |
# Get current active quota for the patron |
3395 |
# Get current actives quota for the patron |
| 3394 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
3396 |
if ( my $active_quotas = $patron->all_quotas->filter_by_active ) { |
| 3395 |
|
3397 |
my $all_exceeded = 1; |
| 3396 |
if (!$active_quota->has_available_quota) { |
3398 |
while ( my $active_quota = $active_quotas->next ) { |
| 3397 |
return (0, "QUOTA_EXCEEDED"); |
3399 |
if ( $active_quota->has_available_quota ) { |
|
|
3400 |
$all_exceeded = 0; |
| 3401 |
} |
| 3398 |
} |
3402 |
} |
|
|
3403 |
return ( 0, "QUOTA_EXCEEDED" ) if $all_exceeded; |
| 3399 |
} |
3404 |
} |
| 3400 |
} |
3405 |
} |
| 3401 |
|
3406 |
|
|
Lines 3516-3527
sub AddRenewal {
Link Here
|
| 3516 |
# Check quotas and record usage if needed |
3521 |
# Check quotas and record usage if needed |
| 3517 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3522 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
| 3518 |
# Get current active quota for the patron |
3523 |
# Get current active quota for the patron |
| 3519 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
3524 |
if (my $active_quota = Koha::Patron::Quotas->find($quota_usage->patron_quota_id)) { |
| 3520 |
# Update patron's used quota value |
3525 |
# Update patron's used quota value |
| 3521 |
$active_quota->add_usage({ |
3526 |
$active_quota->add_usage({ |
| 3522 |
patron_id => $patron->patron_id, |
3527 |
patron_id => $patron->borrowernumber, |
| 3523 |
issue_id => $issue->issue_id, |
3528 |
issue_id => $issue->issue_id, |
| 3524 |
}); |
3529 |
}); |
| 3525 |
} |
3530 |
} |
| 3526 |
} |
3531 |
} |
| 3527 |
|
3532 |
|