@@ -, +, @@ --- C4/Circulation.pm | 29 +++++++++---------- C4/SIP/ILS/Transaction/Checkout.pm | 4 ++- C4/SIP/ILS/Transaction/Renew.pm | 5 +++- circ/circulation.pl | 3 +- .../prog/en/modules/circ/circulation.tt | 4 +++ t/db_dependent/Circulation.t | 18 +++++++----- t/db_dependent/rollingloans.t | 5 ++- 7 files changed, 41 insertions(+), 27 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -1193,6 +1193,8 @@ sub AddIssue { my $dbh = C4::Context->dbh; my $barcodecheck=CheckValidBarcode($barcode); + my $issue; + if ($datedue && ref $datedue ne 'DateTime') { $datedue = dt_from_string($datedue); } @@ -1263,12 +1265,6 @@ sub AddIssue { } # Record in the database the fact that the book was issued. - my $sth = - $dbh->prepare( - "INSERT INTO issues - (borrowernumber, itemnumber,issuedate, date_due, branchcode, onsite_checkout, auto_renew) - VALUES (?,?,?,?,?,?,?)" - ); unless ($datedue) { my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; $datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); @@ -1276,15 +1272,18 @@ sub AddIssue { } $datedue->truncate( to => 'minute'); - $sth->execute( - $borrower->{'borrowernumber'}, # borrowernumber - $item->{'itemnumber'}, # itemnumber - $issuedate->strftime('%Y-%m-%d %H:%M:%S'), # issuedate - $datedue->strftime('%Y-%m-%d %H:%M:%S'), # date_due - C4::Context->userenv->{'branch'}, # branchcode - $onsite_checkout, - $auto_renew ? 1 : 0 # automatic renewal + $issue = Koha::Database->new()->schema()->resultset('Issue')->create( + { + borrowernumber => $borrower->{'borrowernumber'}, + itemnumber => $item->{'itemnumber'}, + issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), + date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), + branchcode => C4::Context->userenv->{'branch'}, + onsite_checkout => $onsite_checkout, + auto_renew => $auto_renew ? 1 : 0 + } ); + if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart. CartToShelf( $item->{'itemnumber'} ); } @@ -1354,7 +1353,7 @@ sub AddIssue { logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $biblio->{'itemnumber'}) if C4::Context->preference("IssueLog"); } - return ($datedue); # not necessarily the same as when it came in! + return $issue; } =head2 GetLoanLength --- a/C4/SIP/ILS/Transaction/Checkout.pm +++ a/C4/SIP/ILS/Transaction/Checkout.pm @@ -20,6 +20,7 @@ use C4::Circulation; use C4::Members; use C4::Reserves qw(ModReserveFill); use C4::Debug; +use Koha::DateUtils; use parent qw(ILS::Transaction); our $debug; @@ -125,7 +126,8 @@ sub do_checkout { $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n" # . "w/ \$borrower: " . Dumper($borrower) . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv); - my $due_dt = AddIssue($borrower, $barcode, $overridden_duedate, 0); + my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 ); + my $due_dt = dt_from_string( $issue->date_due() ); if ($due_dt) { $self->{due} = $due_dt->clone(); } else { --- a/C4/SIP/ILS/Transaction/Renew.pm +++ a/C4/SIP/ILS/Transaction/Renew.pm @@ -12,6 +12,8 @@ use ILS; use C4::Circulation; use C4::Members; +use Koha::DateUtils; + use parent qw(ILS::Transaction); my %fields = ( @@ -36,7 +38,8 @@ sub do_renew_for { my ($renewokay,$renewerror) = CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber}); if ($renewokay){ $self->{due} = undef; - my $due_date = AddIssue( $borrower, $self->{item}->id, undef, 0 ); + my $issue = AddIssue( $borrower, $self->{item}->id, undef, 0 ); + my $due_date = dt_from_string( $issue->date_due() ); if ($due_date) { $self->{due} = $due_date; } --- a/circ/circulation.pl +++ a/circ/circulation.pl @@ -372,7 +372,8 @@ if ($barcode) { } } unless($confirm_required) { - AddIssue( $borrower, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew') } ); + my $issue = AddIssue( $borrower, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew') } ); + $template->param( issue => $issue ); $session->clear('auto_renew'); $inprocess = 1; } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -752,6 +752,10 @@ No patron matched [% message %] +[% IF ( issue ) %] +
+[% END %] +