Bug 19484: Add test before using object itemtype
[koha.git] / svc / checkin
index d0fbd75..78db9d9 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,10 @@ use CGI;
 use JSON qw(to_json);
 
 use C4::Circulation;
-use C4::Items qw(GetBarcodeFromItemnumber GetItem);
+use C4::Items qw(GetBarcodeFromItemnumber GetItem ModItem);
 use C4::Context;
 use C4::Auth qw(check_cookie_auth);
+use Koha::Checkouts;
 
 my $input = new CGI;
 
@@ -47,6 +49,10 @@ my $exempt_fine    = $input->param('exempt_fine');
 my $branchcode     = $input->param('branchcode')
   || C4::Context->userenv->{'branch'};
 
+# Expect these inputs to come in as JSON boolean values
+$override_limit = $override_limit ? $override_limit eq 'true' : undef;
+$exempt_fine    = $exempt_fine    ? $exempt_fine eq 'true'    : undef;
+
 my $barcode = GetBarcodeFromItemnumber($itemnumber);
 
 my $data;
@@ -68,6 +74,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);