Bug 14224: Remove SQL query in svc script
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 2 Feb 2017 10:10:28 +0000 (11:10 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 28 Apr 2017 13:03:22 +0000 (09:03 -0400)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
svc/checkin

index 4bc256f..78db9d9 100755 (executable)
@@ -27,6 +27,7 @@ use C4::Circulation;
 use C4::Items qw(GetBarcodeFromItemnumber GetItem ModItem);
 use C4::Context;
 use C4::Auth qw(check_cookie_auth);
+use Koha::Checkouts;
 
 my $input = new CGI;
 
@@ -73,13 +74,8 @@ if ( C4::Context->preference("ReturnToShelvingCart") ) {
     ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
 }
 
-my $dbh = C4::Context->dbh;
-my $query = "SELECT note FROM issues WHERE itemnumber = ?";
-my $sth = $dbh->prepare($query);
-$sth->execute($itemnumber);
-my $issue = $sth->fetchrow_hashref;
-my $patronnote = $issue->{note};
-$data->{patronnote} = $patronnote;
+my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber });
+$data->{patronnote} = $checkout ? $checkout->note : q||;
 
 ( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine );