Lines 1371-1395
sub CanBookBeIssued {
Link Here
|
1371 |
} |
1371 |
} |
1372 |
|
1372 |
|
1373 |
# CHECK FOR QUOTAS |
1373 |
# CHECK FOR QUOTAS |
1374 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1374 |
if ( my $quotas = $patron->all_quotas->filter_by_active ) { |
1375 |
if (ref($quota) eq 'ARRAY') { |
1375 |
if ( $quotas->count > 1 ) { |
|
|
1376 |
|
1376 |
# Multiple available quotas found - need confirmation from user |
1377 |
# Multiple available quotas found - need confirmation from user |
1377 |
$needsconfirmation{QUOTA_SELECT} = $quota; |
1378 |
$needsconfirmation{QUOTA_SELECT} = $quotas; |
1378 |
} |
1379 |
} elsif ( $quotas->count == 1 ) { |
1379 |
elsif (!$quota->has_available_quota) { |
1380 |
my $quota = $quotas->next; |
1380 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1381 |
if ( !$quota->has_available_quota ) { |
1381 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1382 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1382 |
available => $quota->available_quota, |
1383 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1383 |
total => $quota->allocation, |
1384 |
available => $quota->available_quota, |
1384 |
used => $quota->used, |
1385 |
total => $quota->allocation, |
1385 |
}; |
1386 |
used => $quota->used, |
1386 |
} |
1387 |
}; |
1387 |
else { |
1388 |
} else { |
1388 |
$issuingimpossible{QUOTA_EXCEEDED} = { |
1389 |
$issuingimpossible{QUOTA_EXCEEDED} = { |
1389 |
available => $quota->available_quota, |
1390 |
available => $quota->available_quota, |
1390 |
total => $quota->allocation, |
1391 |
total => $quota->allocation, |
1391 |
used => $quota->used, |
1392 |
used => $quota->used, |
1392 |
}; |
1393 |
}; |
|
|
1394 |
} |
1393 |
} |
1395 |
} |
1394 |
} |
1396 |
} |
1395 |
} |
1397 |
} |
Lines 1989-1995
sub AddIssue {
Link Here
|
1989 |
if ($selected_quota_id) { |
1991 |
if ($selected_quota_id) { |
1990 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
1992 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
1991 |
} else { |
1993 |
} else { |
1992 |
$quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber); |
1994 |
$quota = $patron->all_quotas->filter_by_active->single; |
1993 |
} |
1995 |
} |
1994 |
|
1996 |
|
1995 |
if ($quota) { |
1997 |
if ($quota) { |
Lines 3351-3364
sub CanBookBeRenewed {
Link Here
|
3351 |
} |
3353 |
} |
3352 |
|
3354 |
|
3353 |
# # CHECK FOR QUOTAS |
3355 |
# # CHECK FOR QUOTAS |
3354 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3356 |
if ( my $quota_usage = Koha::Patron::Quota::Usages->find( { issue_id => $issue->issue_id } ) ) { |
3355 |
|
3357 |
|
3356 |
# Get current active quota for the patron |
3358 |
# Get current actives quota for the patron |
3357 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
3359 |
if ( my $active_quotas = $patron->all_quotas->filter_by_active ) { |
3358 |
|
3360 |
my $all_exceeded = 1; |
3359 |
if (!$active_quota->has_available_quota) { |
3361 |
while ( my $active_quota = $active_quotas->next ) { |
3360 |
return (0, "QUOTA_EXCEEDED"); |
3362 |
if ( $active_quota->has_available_quota ) { |
|
|
3363 |
$all_exceeded = 0; |
3364 |
} |
3361 |
} |
3365 |
} |
|
|
3366 |
return ( 0, "QUOTA_EXCEEDED" ) if $all_exceeded; |
3362 |
} |
3367 |
} |
3363 |
} |
3368 |
} |
3364 |
|
3369 |
|
Lines 3477-3488
sub AddRenewal {
Link Here
|
3477 |
# Check quotas and record usage if needed |
3482 |
# Check quotas and record usage if needed |
3478 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3483 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3479 |
# Get current active quota for the patron |
3484 |
# Get current active quota for the patron |
3480 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
3485 |
if (my $active_quota = Koha::Patron::Quotas->find($quota_usage->patron_quota_id)) { |
3481 |
# Update patron's used quota value |
3486 |
# Update patron's used quota value |
3482 |
$active_quota->add_usage({ |
3487 |
$active_quota->add_usage({ |
3483 |
patron_id => $patron->patron_id, |
3488 |
patron_id => $patron->borrowernumber, |
3484 |
issue_id => $issue->issue_id, |
3489 |
issue_id => $issue->issue_id, |
3485 |
}); |
3490 |
}); |
3486 |
} |
3491 |
} |
3487 |
} |
3492 |
} |
3488 |
|
3493 |
|