|
Lines 67-72
use Koha::Library::Hours;
Link Here
|
| 67 |
use Koha::Patron::Quotas; |
67 |
use Koha::Patron::Quotas; |
| 68 |
use Koha::Patron::Quota; |
68 |
use Koha::Patron::Quota; |
| 69 |
use Koha::Patron::Quota::Usage; |
69 |
use Koha::Patron::Quota::Usage; |
|
|
70 |
use Koha::Patron::Quota::Usages; |
| 70 |
|
71 |
|
| 71 |
use Carp qw( carp ); |
72 |
use Carp qw( carp ); |
| 72 |
use List::MoreUtils qw( any ); |
73 |
use List::MoreUtils qw( any ); |
|
Lines 1356-1366
sub CanBookBeIssued {
Link Here
|
| 1356 |
|
1357 |
|
| 1357 |
# CHECK FOR QUOTAS |
1358 |
# CHECK FOR QUOTAS |
| 1358 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1359 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
| 1359 |
unless ( $quota->has_available_quota ) { |
1360 |
if (ref($quota) eq 'ARRAY') { |
|
|
1361 |
# Multiple available quotas found - need confirmation from user |
| 1362 |
$needsconfirmation{QUOTA_SELECT} = $quota; |
| 1363 |
} |
| 1364 |
elsif (!$quota->has_available_quota) { |
| 1360 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1365 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
| 1361 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1366 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
| 1362 |
available => $quota->available_quota, |
1367 |
available => $quota->available_quota, |
| 1363 |
total => $quota->allocation, |
1368 |
total => $quota->allocation, |
| 1364 |
used => $quota->used, |
1369 |
used => $quota->used, |
| 1365 |
}; |
1370 |
}; |
| 1366 |
} |
1371 |
} |
|
Lines 1599-1604
sub AddIssue {
Link Here
|
| 1599 |
my $auto_renew = $params && $params->{auto_renew}; |
1604 |
my $auto_renew = $params && $params->{auto_renew}; |
| 1600 |
my $cancel_recall = $params && $params->{cancel_recall}; |
1605 |
my $cancel_recall = $params && $params->{cancel_recall}; |
| 1601 |
my $recall_id = $params && $params->{recall_id}; |
1606 |
my $recall_id = $params && $params->{recall_id}; |
|
|
1607 |
my $selected_quota_id = $params && $params->{selected_quota_id}; |
| 1602 |
my $dbh = C4::Context->dbh; |
1608 |
my $dbh = C4::Context->dbh; |
| 1603 |
my $barcodecheck = CheckValidBarcode($barcode); |
1609 |
my $barcodecheck = CheckValidBarcode($barcode); |
| 1604 |
|
1610 |
|
|
Lines 1925-1933
sub AddIssue {
Link Here
|
| 1925 |
if C4::Context->preference('RealTimeHoldsQueue'); |
1931 |
if C4::Context->preference('RealTimeHoldsQueue'); |
| 1926 |
|
1932 |
|
| 1927 |
# Check quotas and record usage if needed |
1933 |
# Check quotas and record usage if needed |
| 1928 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1934 |
my $quota; |
| 1929 |
# Update patron's used quota value |
1935 |
if ($selected_quota_id) { |
| 1930 |
$quota->add_usage({ |
1936 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
|
|
1937 |
} else { |
| 1938 |
$quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber); |
| 1939 |
} |
| 1940 |
|
| 1941 |
if ($quota) { |
| 1942 |
# Update patron's used quota value |
| 1943 |
$quota->add_usage({ |
| 1931 |
patron_id => $patron->patron_id, |
1944 |
patron_id => $patron->patron_id, |
| 1932 |
issue_id => $issue->issue_id, |
1945 |
issue_id => $issue->issue_id, |
| 1933 |
}); |
1946 |
}); |
|
Lines 3269-3278
sub CanBookBeRenewed {
Link Here
|
| 3269 |
} |
3282 |
} |
| 3270 |
} |
3283 |
} |
| 3271 |
|
3284 |
|
| 3272 |
# CHECK FOR QUOTAS |
3285 |
# # CHECK FOR QUOTAS |
| 3273 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
3286 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
| 3274 |
unless ( $quota->has_available_quota ) { |
3287 |
|
| 3275 |
return ( 0, "QUOTA_EXCEEDED" ); |
3288 |
# Get current active quota for the patron |
|
|
3289 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
| 3290 |
|
| 3291 |
if (!$active_quota->has_available_quota) { |
| 3292 |
return (0, "QUOTA_EXCEEDED"); |
| 3293 |
} |
| 3276 |
} |
3294 |
} |
| 3277 |
} |
3295 |
} |
| 3278 |
|
3296 |
|
|
Lines 3389-3400
sub AddRenewal {
Link Here
|
| 3389 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
3407 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
| 3390 |
|
3408 |
|
| 3391 |
# Check quotas and record usage if needed |
3409 |
# Check quotas and record usage if needed |
| 3392 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
3410 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
| 3393 |
# Update patron's used quota value |
3411 |
# Get current active quota for the patron |
| 3394 |
$quota->add_usage({ |
3412 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
| 3395 |
patron_id => $patron->patron_id, |
3413 |
# Update patron's used quota value |
| 3396 |
issue_id => $issue->issue_id, |
3414 |
$active_quota->add_usage({ |
| 3397 |
}); |
3415 |
patron_id => $patron->patron_id, |
|
|
3416 |
issue_id => $issue->issue_id, |
| 3417 |
}); |
| 3418 |
} |
| 3398 |
} |
3419 |
} |
| 3399 |
|
3420 |
|
| 3400 |
my $schema = Koha::Database->schema; |
3421 |
my $schema = Koha::Database->schema; |