Lines 763-768
sub CanBookBeIssued {
Link Here
|
763 |
my %needsconfirmation; # filled with problems that needs confirmations |
763 |
my %needsconfirmation; # filled with problems that needs confirmations |
764 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
764 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
765 |
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. |
765 |
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. |
|
|
766 |
my %messages; # filled with information messages that should be displayed. |
766 |
|
767 |
|
767 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
768 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
768 |
my $override_high_holds = $params->{override_high_holds} || 0; |
769 |
my $override_high_holds = $params->{override_high_holds} || 0; |
Lines 1023-1045
sub CanBookBeIssued {
Link Here
|
1023 |
# |
1024 |
# |
1024 |
if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){ |
1025 |
if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){ |
1025 |
|
1026 |
|
1026 |
# Already issued to current borrower. Ask whether the loan should |
1027 |
# Already issued to current borrower. |
1027 |
# be renewed. |
1028 |
# If it is an on-site checkout if it can be switched to a normal checkout |
1028 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
1029 |
# or ask whether the loan should be renewed |
1029 |
$borrower->{'borrowernumber'}, |
1030 |
|
1030 |
$item->{'itemnumber'} |
1031 |
if ( $issue->{onsite_checkout} |
1031 |
); |
1032 |
and C4::Context->preference('SwitchOnSiteCheckouts') ) { |
1032 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
1033 |
$messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1; |
1033 |
if ( $renewerror eq 'onsite_checkout' ) { |
1034 |
} else { |
1034 |
$issuingimpossible{NO_RENEWAL_FOR_ONSITE_CHECKOUTS} = 1; |
1035 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
|
|
1036 |
$borrower->{'borrowernumber'}, |
1037 |
$item->{'itemnumber'}, |
1038 |
); |
1039 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
1040 |
if ( $renewerror eq 'onsite_checkout' ) { |
1041 |
$issuingimpossible{NO_RENEWAL_FOR_ONSITE_CHECKOUTS} = 1; |
1042 |
} |
1043 |
else { |
1044 |
$issuingimpossible{NO_MORE_RENEWALS} = 1; |
1045 |
} |
1035 |
} |
1046 |
} |
1036 |
else { |
1047 |
else { |
1037 |
$issuingimpossible{NO_MORE_RENEWALS} = 1; |
1048 |
$needsconfirmation{RENEW_ISSUE} = 1; |
1038 |
} |
1049 |
} |
1039 |
} |
1050 |
} |
1040 |
else { |
|
|
1041 |
$needsconfirmation{RENEW_ISSUE} = 1; |
1042 |
} |
1043 |
} |
1051 |
} |
1044 |
elsif ($issue->{borrowernumber}) { |
1052 |
elsif ($issue->{borrowernumber}) { |
1045 |
|
1053 |
|
Lines 1148-1154
sub CanBookBeIssued {
Link Here
|
1148 |
} |
1156 |
} |
1149 |
} |
1157 |
} |
1150 |
|
1158 |
|
1151 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts ); |
1159 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1152 |
} |
1160 |
} |
1153 |
|
1161 |
|
1154 |
=head2 CanBookBeReturned |
1162 |
=head2 CanBookBeReturned |
Lines 1332-1337
AddIssue does the following things :
Link Here
|
1332 |
sub AddIssue { |
1340 |
sub AddIssue { |
1333 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $params ) = @_; |
1341 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $params ) = @_; |
1334 |
my $onsite_checkout = $params && $params->{onsite_checkout} ? 1 : 0; |
1342 |
my $onsite_checkout = $params && $params->{onsite_checkout} ? 1 : 0; |
|
|
1343 |
my $switch_onsite_checkout = $params && $params->{switch_onsite_checkout}; |
1335 |
my $auto_renew = $params && $params->{auto_renew}; |
1344 |
my $auto_renew = $params && $params->{auto_renew}; |
1336 |
my $dbh = C4::Context->dbh; |
1345 |
my $dbh = C4::Context->dbh; |
1337 |
my $barcodecheck=CheckValidBarcode($barcode); |
1346 |
my $barcodecheck=CheckValidBarcode($barcode); |
Lines 1365-1371
sub AddIssue {
Link Here
|
1365 |
# |
1374 |
# |
1366 |
# check if we just renew the issue. |
1375 |
# check if we just renew the issue. |
1367 |
# |
1376 |
# |
1368 |
if ($actualissue->{borrowernumber} eq $borrower->{'borrowernumber'}) { |
1377 |
if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} |
|
|
1378 |
and not $switch_onsite_checkout ) { |
1369 |
$datedue = AddRenewal( |
1379 |
$datedue = AddRenewal( |
1370 |
$borrower->{'borrowernumber'}, |
1380 |
$borrower->{'borrowernumber'}, |
1371 |
$item->{'itemnumber'}, |
1381 |
$item->{'itemnumber'}, |
Lines 1376-1382
sub AddIssue {
Link Here
|
1376 |
} |
1386 |
} |
1377 |
else { |
1387 |
else { |
1378 |
# it's NOT a renewal |
1388 |
# it's NOT a renewal |
1379 |
if ( $actualissue->{borrowernumber}) { |
1389 |
if ( $actualissue->{borrowernumber} |
|
|
1390 |
and not $switch_onsite_checkout ) { |
1380 |
# This book is currently on loan, but not to the person |
1391 |
# This book is currently on loan, but not to the person |
1381 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1392 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1382 |
AddReturn( |
1393 |
AddReturn( |
Lines 1415-1421
sub AddIssue {
Link Here
|
1415 |
} |
1426 |
} |
1416 |
$datedue->truncate( to => 'minute'); |
1427 |
$datedue->truncate( to => 'minute'); |
1417 |
|
1428 |
|
1418 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->create( |
1429 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( |
1419 |
{ |
1430 |
{ |
1420 |
borrowernumber => $borrower->{'borrowernumber'}, |
1431 |
borrowernumber => $borrower->{'borrowernumber'}, |
1421 |
itemnumber => $item->{'itemnumber'}, |
1432 |
itemnumber => $item->{'itemnumber'}, |