|
Lines 1376-1400
sub CanBookBeIssued {
Link Here
|
| 1376 |
} |
1376 |
} |
| 1377 |
|
1377 |
|
| 1378 |
# CHECK FOR QUOTAS |
1378 |
# CHECK FOR QUOTAS |
| 1379 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1379 |
if ( my $quotas = $patron->all_quotas->filter_by_active ) { |
| 1380 |
if (ref($quota) eq 'ARRAY') { |
1380 |
if ( $quotas->count > 1 ) { |
|
|
1381 |
|
| 1381 |
# Multiple available quotas found - need confirmation from user |
1382 |
# Multiple available quotas found - need confirmation from user |
| 1382 |
$needsconfirmation{QUOTA_SELECT} = $quota; |
1383 |
$needsconfirmation{QUOTA_SELECT} = $quotas; |
| 1383 |
} |
1384 |
} elsif ( $quotas->count == 1 ) { |
| 1384 |
elsif (!$quota->has_available_quota) { |
1385 |
my $quota = $quotas->next; |
| 1385 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1386 |
if ( !$quota->has_available_quota ) { |
| 1386 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1387 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
| 1387 |
available => $quota->available_quota, |
1388 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
| 1388 |
total => $quota->allocation, |
1389 |
available => $quota->available_quota, |
| 1389 |
used => $quota->used, |
1390 |
total => $quota->allocation, |
| 1390 |
}; |
1391 |
used => $quota->used, |
| 1391 |
} |
1392 |
}; |
| 1392 |
else { |
1393 |
} else { |
| 1393 |
$issuingimpossible{QUOTA_EXCEEDED} = { |
1394 |
$issuingimpossible{QUOTA_EXCEEDED} = { |
| 1394 |
available => $quota->available_quota, |
1395 |
available => $quota->available_quota, |
| 1395 |
total => $quota->allocation, |
1396 |
total => $quota->allocation, |
| 1396 |
used => $quota->used, |
1397 |
used => $quota->used, |
| 1397 |
}; |
1398 |
}; |
|
|
1399 |
} |
| 1398 |
} |
1400 |
} |
| 1399 |
} |
1401 |
} |
| 1400 |
} |
1402 |
} |
|
Lines 2033-2039
sub AddIssue {
Link Here
|
| 2033 |
if ($selected_quota_id) { |
2035 |
if ($selected_quota_id) { |
| 2034 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
2036 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
| 2035 |
} else { |
2037 |
} else { |
| 2036 |
$quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber); |
2038 |
$quota = $patron->all_quotas->filter_by_active->single; |
| 2037 |
} |
2039 |
} |
| 2038 |
|
2040 |
|
| 2039 |
if ($quota) { |
2041 |
if ($quota) { |
|
Lines 3417-3430
sub CanBookBeRenewed {
Link Here
|
| 3417 |
} |
3419 |
} |
| 3418 |
|
3420 |
|
| 3419 |
# # CHECK FOR QUOTAS |
3421 |
# # CHECK FOR QUOTAS |
| 3420 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3422 |
if ( my $quota_usage = Koha::Patron::Quota::Usages->find( { issue_id => $issue->issue_id } ) ) { |
| 3421 |
|
3423 |
|
| 3422 |
# Get current active quota for the patron |
3424 |
# Get current actives quota for the patron |
| 3423 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
3425 |
if ( my $active_quotas = $patron->all_quotas->filter_by_active ) { |
| 3424 |
|
3426 |
my $all_exceeded = 1; |
| 3425 |
if (!$active_quota->has_available_quota) { |
3427 |
while ( my $active_quota = $active_quotas->next ) { |
| 3426 |
return (0, "QUOTA_EXCEEDED"); |
3428 |
if ( $active_quota->has_available_quota ) { |
|
|
3429 |
$all_exceeded = 0; |
| 3430 |
} |
| 3427 |
} |
3431 |
} |
|
|
3432 |
return ( 0, "QUOTA_EXCEEDED" ) if $all_exceeded; |
| 3428 |
} |
3433 |
} |
| 3429 |
} |
3434 |
} |
| 3430 |
|
3435 |
|
|
Lines 3545-3556
sub AddRenewal {
Link Here
|
| 3545 |
# Check quotas and record usage if needed |
3550 |
# Check quotas and record usage if needed |
| 3546 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3551 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
| 3547 |
# Get current active quota for the patron |
3552 |
# Get current active quota for the patron |
| 3548 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
3553 |
if (my $active_quota = Koha::Patron::Quotas->find($quota_usage->patron_quota_id)) { |
| 3549 |
# Update patron's used quota value |
3554 |
# Update patron's used quota value |
| 3550 |
$active_quota->add_usage({ |
3555 |
$active_quota->add_usage({ |
| 3551 |
patron_id => $patron->patron_id, |
3556 |
patron_id => $patron->borrowernumber, |
| 3552 |
issue_id => $issue->issue_id, |
3557 |
issue_id => $issue->issue_id, |
| 3553 |
}); |
3558 |
}); |
| 3554 |
} |
3559 |
} |
| 3555 |
} |
3560 |
} |
| 3556 |
|
3561 |
|