|
Lines 69-74
use Koha::Library::Hours;
Link Here
|
| 69 |
use Koha::Patron::Quotas; |
69 |
use Koha::Patron::Quotas; |
| 70 |
use Koha::Patron::Quota; |
70 |
use Koha::Patron::Quota; |
| 71 |
use Koha::Patron::Quota::Usage; |
71 |
use Koha::Patron::Quota::Usage; |
|
|
72 |
use Koha::Patron::Quota::Usages; |
| 72 |
|
73 |
|
| 73 |
use Carp qw( carp ); |
74 |
use Carp qw( carp ); |
| 74 |
use List::MoreUtils qw( any ); |
75 |
use List::MoreUtils qw( any ); |
|
Lines 1377-1387
sub CanBookBeIssued {
Link Here
|
| 1377 |
|
1378 |
|
| 1378 |
# CHECK FOR QUOTAS |
1379 |
# CHECK FOR QUOTAS |
| 1379 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1380 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
| 1380 |
unless ( $quota->has_available_quota ) { |
1381 |
if (ref($quota) eq 'ARRAY') { |
|
|
1382 |
# Multiple available quotas found - need confirmation from user |
| 1383 |
$needsconfirmation{QUOTA_SELECT} = $quota; |
| 1384 |
} |
| 1385 |
elsif (!$quota->has_available_quota) { |
| 1381 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1386 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
| 1382 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1387 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
| 1383 |
available => $quota->available_quota, |
1388 |
available => $quota->available_quota, |
| 1384 |
total => $quota->allocation, |
1389 |
total => $quota->allocation, |
| 1385 |
used => $quota->used, |
1390 |
used => $quota->used, |
| 1386 |
}; |
1391 |
}; |
| 1387 |
} |
1392 |
} |
|
Lines 1628-1633
sub AddIssue {
Link Here
|
| 1628 |
my $recall_id = $params && $params->{recall_id}; |
1633 |
my $recall_id = $params && $params->{recall_id}; |
| 1629 |
my $confirmations = $params->{confirmations}; |
1634 |
my $confirmations = $params->{confirmations}; |
| 1630 |
my $forced = $params->{forced}; |
1635 |
my $forced = $params->{forced}; |
|
|
1636 |
my $selected_quota_id = $params && $params->{selected_quota_id}; |
| 1631 |
my $dbh = C4::Context->dbh; |
1637 |
my $dbh = C4::Context->dbh; |
| 1632 |
my $barcodecheck = CheckValidBarcode($barcode); |
1638 |
my $barcodecheck = CheckValidBarcode($barcode); |
| 1633 |
|
1639 |
|
|
Lines 2013-2021
sub AddIssue {
Link Here
|
| 2013 |
if C4::Context->preference('RealTimeHoldsQueue'); |
2019 |
if C4::Context->preference('RealTimeHoldsQueue'); |
| 2014 |
|
2020 |
|
| 2015 |
# Check quotas and record usage if needed |
2021 |
# Check quotas and record usage if needed |
| 2016 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
2022 |
my $quota; |
| 2017 |
# Update patron's used quota value |
2023 |
if ($selected_quota_id) { |
| 2018 |
$quota->add_usage({ |
2024 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
|
|
2025 |
} else { |
| 2026 |
$quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber); |
| 2027 |
} |
| 2028 |
|
| 2029 |
if ($quota) { |
| 2030 |
# Update patron's used quota value |
| 2031 |
$quota->add_usage({ |
| 2019 |
patron_id => $patron->patron_id, |
2032 |
patron_id => $patron->patron_id, |
| 2020 |
issue_id => $issue->issue_id, |
2033 |
issue_id => $issue->issue_id, |
| 2021 |
}); |
2034 |
}); |
|
Lines 3374-3383
sub CanBookBeRenewed {
Link Here
|
| 3374 |
} |
3387 |
} |
| 3375 |
} |
3388 |
} |
| 3376 |
|
3389 |
|
| 3377 |
# CHECK FOR QUOTAS |
3390 |
# # CHECK FOR QUOTAS |
| 3378 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
3391 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
| 3379 |
unless ( $quota->has_available_quota ) { |
3392 |
|
| 3380 |
return ( 0, "QUOTA_EXCEEDED" ); |
3393 |
# Get current active quota for the patron |
|
|
3394 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
| 3395 |
|
| 3396 |
if (!$active_quota->has_available_quota) { |
| 3397 |
return (0, "QUOTA_EXCEEDED"); |
| 3398 |
} |
| 3381 |
} |
3399 |
} |
| 3382 |
} |
3400 |
} |
| 3383 |
|
3401 |
|
|
Lines 3496-3507
sub AddRenewal {
Link Here
|
| 3496 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
3514 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
| 3497 |
|
3515 |
|
| 3498 |
# Check quotas and record usage if needed |
3516 |
# Check quotas and record usage if needed |
| 3499 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
3517 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
| 3500 |
# Update patron's used quota value |
3518 |
# Get current active quota for the patron |
| 3501 |
$quota->add_usage({ |
3519 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
| 3502 |
patron_id => $patron->patron_id, |
3520 |
# Update patron's used quota value |
| 3503 |
issue_id => $issue->issue_id, |
3521 |
$active_quota->add_usage({ |
| 3504 |
}); |
3522 |
patron_id => $patron->patron_id, |
|
|
3523 |
issue_id => $issue->issue_id, |
| 3524 |
}); |
| 3525 |
} |
| 3505 |
} |
3526 |
} |
| 3506 |
|
3527 |
|
| 3507 |
my $schema = Koha::Database->schema; |
3528 |
my $schema = Koha::Database->schema; |