Lines 765-770
sub CanBookBeIssued {
Link Here
|
765 |
my %needsconfirmation; # filled with problems that needs confirmations |
765 |
my %needsconfirmation; # filled with problems that needs confirmations |
766 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
766 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
767 |
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. |
767 |
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. |
|
|
768 |
my %messages; # filled with information messages that should be displayed. |
768 |
|
769 |
|
769 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
770 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
770 |
my $override_high_holds = $params->{override_high_holds} || 0; |
771 |
my $override_high_holds = $params->{override_high_holds} || 0; |
Lines 1033-1055
sub CanBookBeIssued {
Link Here
|
1033 |
# |
1034 |
# |
1034 |
if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){ |
1035 |
if ( $issue->{borrowernumber} && $issue->{borrowernumber} eq $borrower->{'borrowernumber'} ){ |
1035 |
|
1036 |
|
1036 |
# Already issued to current borrower. Ask whether the loan should |
1037 |
# Already issued to current borrower. |
1037 |
# be renewed. |
1038 |
# If it is an on-site checkout if it can be switched to a normal checkout |
1038 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
1039 |
# or ask whether the loan should be renewed |
1039 |
$borrower->{'borrowernumber'}, |
1040 |
|
1040 |
$item->{'itemnumber'} |
1041 |
if ( $issue->{onsite_checkout} |
1041 |
); |
1042 |
and C4::Context->preference('SwitchOnSiteCheckouts') ) { |
1042 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
1043 |
$messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1; |
1043 |
if ( $renewerror eq 'onsite_checkout' ) { |
1044 |
} else { |
1044 |
$issuingimpossible{NO_RENEWAL_FOR_ONSITE_CHECKOUTS} = 1; |
1045 |
my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( |
|
|
1046 |
$borrower->{'borrowernumber'}, |
1047 |
$item->{'itemnumber'}, |
1048 |
); |
1049 |
if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed |
1050 |
if ( $renewerror eq 'onsite_checkout' ) { |
1051 |
$issuingimpossible{NO_RENEWAL_FOR_ONSITE_CHECKOUTS} = 1; |
1052 |
} |
1053 |
else { |
1054 |
$issuingimpossible{NO_MORE_RENEWALS} = 1; |
1055 |
} |
1045 |
} |
1056 |
} |
1046 |
else { |
1057 |
else { |
1047 |
$issuingimpossible{NO_MORE_RENEWALS} = 1; |
1058 |
$needsconfirmation{RENEW_ISSUE} = 1; |
1048 |
} |
1059 |
} |
1049 |
} |
1060 |
} |
1050 |
else { |
|
|
1051 |
$needsconfirmation{RENEW_ISSUE} = 1; |
1052 |
} |
1053 |
} |
1061 |
} |
1054 |
elsif ($issue->{borrowernumber}) { |
1062 |
elsif ($issue->{borrowernumber}) { |
1055 |
|
1063 |
|
Lines 1165-1171
sub CanBookBeIssued {
Link Here
|
1165 |
} |
1173 |
} |
1166 |
} |
1174 |
} |
1167 |
|
1175 |
|
1168 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts ); |
1176 |
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, ); |
1169 |
} |
1177 |
} |
1170 |
|
1178 |
|
1171 |
=head2 CanBookBeReturned |
1179 |
=head2 CanBookBeReturned |
Lines 1350-1355
sub AddIssue {
Link Here
|
1350 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $params ) = @_; |
1358 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode, $params ) = @_; |
1351 |
|
1359 |
|
1352 |
my $onsite_checkout = $params && $params->{onsite_checkout} ? 1 : 0; |
1360 |
my $onsite_checkout = $params && $params->{onsite_checkout} ? 1 : 0; |
|
|
1361 |
my $switch_onsite_checkout = $params && $params->{switch_onsite_checkout}; |
1353 |
my $auto_renew = $params && $params->{auto_renew}; |
1362 |
my $auto_renew = $params && $params->{auto_renew}; |
1354 |
my $dbh = C4::Context->dbh; |
1363 |
my $dbh = C4::Context->dbh; |
1355 |
my $barcodecheck = CheckValidBarcode($barcode); |
1364 |
my $barcodecheck = CheckValidBarcode($barcode); |
Lines 1386-1392
sub AddIssue {
Link Here
|
1386 |
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); |
1395 |
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); |
1387 |
|
1396 |
|
1388 |
# check if we just renew the issue. |
1397 |
# check if we just renew the issue. |
1389 |
if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} ) { |
1398 |
if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} |
|
|
1399 |
and not $switch_onsite_checkout ) { |
1390 |
$datedue = AddRenewal( |
1400 |
$datedue = AddRenewal( |
1391 |
$borrower->{'borrowernumber'}, |
1401 |
$borrower->{'borrowernumber'}, |
1392 |
$item->{'itemnumber'}, |
1402 |
$item->{'itemnumber'}, |
Lines 1397-1403
sub AddIssue {
Link Here
|
1397 |
} |
1407 |
} |
1398 |
else { |
1408 |
else { |
1399 |
# it's NOT a renewal |
1409 |
# it's NOT a renewal |
1400 |
if ( $actualissue->{borrowernumber} ) { |
1410 |
if ( $actualissue->{borrowernumber} |
|
|
1411 |
and not $switch_onsite_checkout ) { |
1401 |
# This book is currently on loan, but not to the person |
1412 |
# This book is currently on loan, but not to the person |
1402 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1413 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1403 |
my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
1414 |
my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); |
Lines 1439-1445
sub AddIssue {
Link Here
|
1439 |
} |
1450 |
} |
1440 |
$datedue->truncate( to => 'minute' ); |
1451 |
$datedue->truncate( to => 'minute' ); |
1441 |
|
1452 |
|
1442 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->create( |
1453 |
$issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( |
1443 |
{ |
1454 |
{ |
1444 |
borrowernumber => $borrower->{'borrowernumber'}, |
1455 |
borrowernumber => $borrower->{'borrowernumber'}, |
1445 |
itemnumber => $item->{'itemnumber'}, |
1456 |
itemnumber => $item->{'itemnumber'}, |