Lines 756-761
sub CanBookBeIssued {
Link Here
|
756 |
my %needsconfirmation; # filled with problems that needs confirmations |
756 |
my %needsconfirmation; # filled with problems that needs confirmations |
757 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
757 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
758 |
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. |
758 |
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. |
|
|
759 |
my %messages; # filled with information messages that should be displayed. |
759 |
|
760 |
|
760 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
761 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
761 |
|
762 |
|
Lines 991-1013
sub CanBookBeIssued {
Link Here
|
991 |
# |
992 |
# |
992 |
if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){ |
993 |
if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){ |
993 |
|
994 |
|
994 |
# Already issued to current borrower. Ask whether the loan should |
995 |
# Already issued to current borrower. |
995 |
# be renewed. |
996 |
# If it is an on-site checkout if it can be switched to a normal checkout |
996 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
997 |
# or ask whether the loan should be renewed |
997 |
$borrower->{'borrowernumber'}, |
998 |
|
998 |
$item->{'itemnumber'} |
999 |
if ( $issue->{onsite_checkout} |
999 |
); |
1000 |
and C4::Context->preference('SwitchOnSiteCheckouts') ) { |
1000 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
1001 |
$messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1; |
1001 |
if ( $renewerror eq 'onsite_checkout' ) { |
1002 |
} else { |
1002 |
$issuingimpossible{NO_RENEWAL_FOR_ONSITE_CHECKOUTS} = 1; |
1003 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
|
|
1004 |
$borrower->{'borrowernumber'}, |
1005 |
$item->{'itemnumber'}, |
1006 |
); |
1007 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
1008 |
if ( $renewerror eq 'onsite_checkout' ) { |
1009 |
$issuingimpossible{NO_RENEWAL_FOR_ONSITE_CHECKOUTS} = 1; |
1010 |
} |
1011 |
else { |
1012 |
$issuingimpossible{NO_MORE_RENEWALS} = 1; |
1013 |
} |
1003 |
} |
1014 |
} |
1004 |
else { |
1015 |
else { |
1005 |
$issuingimpossible{NO_MORE_RENEWALS} = 1; |
1016 |
$needsconfirmation{RENEW_ISSUE} = 1; |
1006 |
} |
1017 |
} |
1007 |
} |
1018 |
} |
1008 |
else { |
|
|
1009 |
$needsconfirmation{RENEW_ISSUE} = 1; |
1010 |
} |
1011 |
} |
1019 |
} |
1012 |
elsif ($issue->{borrowernumber}) { |
1020 |
elsif ($issue->{borrowernumber}) { |
1013 |
|
1021 |
|
Lines 1107-1113
sub CanBookBeIssued {
Link Here
|
1107 |
} |
1115 |
} |
1108 |
} |
1116 |
} |
1109 |
|
1117 |
|
1110 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts ); |
1118 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1111 |
} |
1119 |
} |
1112 |
|
1120 |
|
1113 |
=head2 CanBookBeReturned |
1121 |
=head2 CanBookBeReturned |
Lines 1291-1296
AddIssue does the following things :
Link Here
|
1291 |
sub AddIssue { |
1299 |
sub AddIssue { |
1292 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $params ) = @_; |
1300 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $params ) = @_; |
1293 |
my $onsite_checkout = $params && $params->{onsite_checkout} ? 1 : 0; |
1301 |
my $onsite_checkout = $params && $params->{onsite_checkout} ? 1 : 0; |
|
|
1302 |
my $switch_onsite_checkout = $params && $params->{switch_onsite_checkout}; |
1294 |
my $auto_renew = $params && $params->{auto_renew}; |
1303 |
my $auto_renew = $params && $params->{auto_renew}; |
1295 |
my $dbh = C4::Context->dbh; |
1304 |
my $dbh = C4::Context->dbh; |
1296 |
my $barcodecheck=CheckValidBarcode($barcode); |
1305 |
my $barcodecheck=CheckValidBarcode($barcode); |
Lines 1324-1330
sub AddIssue {
Link Here
|
1324 |
# |
1333 |
# |
1325 |
# check if we just renew the issue. |
1334 |
# check if we just renew the issue. |
1326 |
# |
1335 |
# |
1327 |
if ($actualissue->{borrowernumber} eq $borrower->{'borrowernumber'}) { |
1336 |
if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} |
|
|
1337 |
and not $switch_onsite_checkout ) { |
1328 |
$datedue = AddRenewal( |
1338 |
$datedue = AddRenewal( |
1329 |
$borrower->{'borrowernumber'}, |
1339 |
$borrower->{'borrowernumber'}, |
1330 |
$item->{'itemnumber'}, |
1340 |
$item->{'itemnumber'}, |
Lines 1335-1341
sub AddIssue {
Link Here
|
1335 |
} |
1345 |
} |
1336 |
else { |
1346 |
else { |
1337 |
# it's NOT a renewal |
1347 |
# it's NOT a renewal |
1338 |
if ( $actualissue->{borrowernumber}) { |
1348 |
if ( $actualissue->{borrowernumber} |
|
|
1349 |
and not $switch_onsite_checkout ) { |
1339 |
# This book is currently on loan, but not to the person |
1350 |
# This book is currently on loan, but not to the person |
1340 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1351 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1341 |
AddReturn( |
1352 |
AddReturn( |
Lines 1374-1380
sub AddIssue {
Link Here
|
1374 |
} |
1385 |
} |
1375 |
$datedue->truncate( to => 'minute'); |
1386 |
$datedue->truncate( to => 'minute'); |
1376 |
|
1387 |
|
1377 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->create( |
1388 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( |
1378 |
{ |
1389 |
{ |
1379 |
borrowernumber => $borrower->{'borrowernumber'}, |
1390 |
borrowernumber => $borrower->{'borrowernumber'}, |
1380 |
itemnumber => $item->{'itemnumber'}, |
1391 |
itemnumber => $item->{'itemnumber'}, |