Lines 68-73
use Koha::Library::Hours;
Link Here
|
68 |
use Koha::Patron::Quotas; |
68 |
use Koha::Patron::Quotas; |
69 |
use Koha::Patron::Quota; |
69 |
use Koha::Patron::Quota; |
70 |
use Koha::Patron::Quota::Usage; |
70 |
use Koha::Patron::Quota::Usage; |
|
|
71 |
use Koha::Patron::Quota::Usages; |
71 |
|
72 |
|
72 |
use Carp qw( carp ); |
73 |
use Carp qw( carp ); |
73 |
use List::MoreUtils qw( any ); |
74 |
use List::MoreUtils qw( any ); |
Lines 1371-1377
sub CanBookBeIssued {
Link Here
|
1371 |
|
1372 |
|
1372 |
# CHECK FOR QUOTAS |
1373 |
# CHECK FOR QUOTAS |
1373 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1374 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1374 |
unless ( $quota->has_available_quota ) { |
1375 |
if (ref($quota) eq 'ARRAY') { |
|
|
1376 |
# Multiple available quotas found - need confirmation from user |
1377 |
$needsconfirmation{QUOTA_SELECT} = $quota; |
1378 |
} |
1379 |
elsif (!$quota->has_available_quota) { |
1375 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1380 |
if ( C4::Context->preference("AllowQuotaOverride") ) { |
1376 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1381 |
$needsconfirmation{QUOTA_EXCEEDED} = { |
1377 |
available => $quota->available_quota, |
1382 |
available => $quota->available_quota, |
Lines 1620-1625
sub AddIssue {
Link Here
|
1620 |
my $auto_renew = $params && $params->{auto_renew}; |
1625 |
my $auto_renew = $params && $params->{auto_renew}; |
1621 |
my $cancel_recall = $params && $params->{cancel_recall}; |
1626 |
my $cancel_recall = $params && $params->{cancel_recall}; |
1622 |
my $recall_id = $params && $params->{recall_id}; |
1627 |
my $recall_id = $params && $params->{recall_id}; |
|
|
1628 |
my $selected_quota_id = $params && $params->{selected_quota_id}; |
1623 |
my $dbh = C4::Context->dbh; |
1629 |
my $dbh = C4::Context->dbh; |
1624 |
my $barcodecheck = CheckValidBarcode($barcode); |
1630 |
my $barcodecheck = CheckValidBarcode($barcode); |
1625 |
|
1631 |
|
Lines 1979-1987
sub AddIssue {
Link Here
|
1979 |
if C4::Context->preference('RealTimeHoldsQueue'); |
1985 |
if C4::Context->preference('RealTimeHoldsQueue'); |
1980 |
|
1986 |
|
1981 |
# Check quotas and record usage if needed |
1987 |
# Check quotas and record usage if needed |
1982 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
1988 |
my $quota; |
1983 |
# Update patron's used quota value |
1989 |
if ($selected_quota_id) { |
1984 |
$quota->add_usage({ |
1990 |
$quota = Koha::Patron::Quotas->find($selected_quota_id); |
|
|
1991 |
} else { |
1992 |
$quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber); |
1993 |
} |
1994 |
|
1995 |
if ($quota) { |
1996 |
# Update patron's used quota value |
1997 |
$quota->add_usage({ |
1985 |
patron_id => $patron->patron_id, |
1998 |
patron_id => $patron->patron_id, |
1986 |
issue_id => $issue->issue_id, |
1999 |
issue_id => $issue->issue_id, |
1987 |
}); |
2000 |
}); |
Lines 3337-3346
sub CanBookBeRenewed {
Link Here
|
3337 |
} |
3350 |
} |
3338 |
} |
3351 |
} |
3339 |
|
3352 |
|
3340 |
# CHECK FOR QUOTAS |
3353 |
# # CHECK FOR QUOTAS |
3341 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
3354 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3342 |
unless ( $quota->has_available_quota ) { |
3355 |
|
3343 |
return ( 0, "QUOTA_EXCEEDED" ); |
3356 |
# Get current active quota for the patron |
|
|
3357 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
3358 |
|
3359 |
if (!$active_quota->has_available_quota) { |
3360 |
return (0, "QUOTA_EXCEEDED"); |
3361 |
} |
3344 |
} |
3362 |
} |
3345 |
} |
3363 |
} |
3346 |
|
3364 |
|
Lines 3457-3468
sub AddRenewal {
Link Here
|
3457 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
3475 |
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) ); |
3458 |
|
3476 |
|
3459 |
# Check quotas and record usage if needed |
3477 |
# Check quotas and record usage if needed |
3460 |
if ( my $quota = Koha::Patron::Quotas->get_patron_quota($patron->borrowernumber) ) { |
3478 |
if (my $quota_usage = Koha::Patron::Quota::Usages->find({ issue_id => $issue->issue_id })) { |
3461 |
# Update patron's used quota value |
3479 |
# Get current active quota for the patron |
3462 |
$quota->add_usage({ |
3480 |
if (my $active_quota = Koha::Patron::Quotas->get_active_quota($quota_usage->patron_id)) { |
3463 |
patron_id => $patron->patron_id, |
3481 |
# Update patron's used quota value |
3464 |
issue_id => $issue->issue_id, |
3482 |
$active_quota->add_usage({ |
3465 |
}); |
3483 |
patron_id => $patron->patron_id, |
|
|
3484 |
issue_id => $issue->issue_id, |
3485 |
}); |
3486 |
} |
3466 |
} |
3487 |
} |
3467 |
|
3488 |
|
3468 |
my $schema = Koha::Database->schema; |
3489 |
my $schema = Koha::Database->schema; |