Bug 17047: subscriptions management with Mana-KB
[koha.git] / svc / checkin
index c10a1b8..9b72aba 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 
 # Copyright 2014 ByWater Solutions
+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz>
 #
 # This file is part of Koha.
 #
@@ -23,9 +24,11 @@ use CGI;
 use JSON qw(to_json);
 
 use C4::Circulation;
-use C4::Items qw(GetBarcodeFromItemnumber GetItem ModItem);
+use C4::Items qw(GetItem ModItem);
 use C4::Context;
 use C4::Auth qw(check_cookie_auth);
+use Koha::Checkouts;
+use Koha::Items;
 
 my $input = new CGI;
 
@@ -51,7 +54,9 @@ my $branchcode     = $input->param('branchcode')
 $override_limit = $override_limit ? $override_limit eq 'true' : undef;
 $exempt_fine    = $exempt_fine    ? $exempt_fine eq 'true'    : undef;
 
-my $barcode = GetBarcodeFromItemnumber($itemnumber);
+my $item = Koha::Items->find($itemnumber);
+
+my $barcode = $item ? $item->barcode : undef; # We certainly will want to return an error code
 
 my $data;
 $data->{itemnumber}     = $itemnumber;
@@ -72,6 +77,9 @@ if ( C4::Context->preference("ReturnToShelvingCart") ) {
     ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
 }
 
+my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber });
+$data->{patronnote} = $checkout ? $checkout->note : q||;
+
 ( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine );
 
 print to_json($data);