3 # Copyright 2014 ByWater Solutions
4 # Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz>
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 3 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 use C4
::Items
qw(GetBarcodeFromItemnumber GetItem ModItem);
29 use C4
::Auth
qw(check_cookie_auth);
33 my ( $auth_status, $sessionID ) =
34 check_cookie_auth
( $input->cookie('CGISESSID'),
35 { circulate
=> 'circulate_remaining_permissions' } );
37 if ( $auth_status ne "ok" ) {
41 binmode STDOUT
, ":encoding(UTF-8)";
42 print $input->header( -type
=> 'text/plain', -charset
=> 'UTF-8' );
44 my $itemnumber = $input->param('itemnumber');
45 my $borrowernumber = $input->param('borrowernumber');
46 my $override_limit = $input->param('override_limit');
47 my $exempt_fine = $input->param('exempt_fine');
48 my $branchcode = $input->param('branchcode')
49 || C4
::Context
->userenv->{'branch'};
51 # Expect these inputs to come in as JSON boolean values
52 $override_limit = $override_limit ?
$override_limit eq 'true' : undef;
53 $exempt_fine = $exempt_fine ?
$exempt_fine eq 'true' : undef;
55 my $barcode = GetBarcodeFromItemnumber
($itemnumber);
58 $data->{itemnumber
} = $itemnumber;
59 $data->{borrowernumber
} = $borrowernumber;
60 $data->{branchcode
} = $branchcode;
62 if ( C4
::Context
->preference("InProcessingToShelvingCart") ) {
63 my $item = GetItem
($itemnumber);
64 if ( $item->{'location'} eq 'PROC' ) {
65 $item->{'location'} = 'CART';
66 ModItem
( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
70 if ( C4
::Context
->preference("ReturnToShelvingCart") ) {
71 my $item = GetItem
($itemnumber);
72 $item->{'location'} = 'CART';
73 ModItem
( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
76 my $dbh = C4
::Context
->dbh;
77 my $query = "SELECT note FROM issues WHERE itemnumber = ?";
78 my $sth = $dbh->prepare($query);
79 $sth->execute($itemnumber);
80 my $issue = $sth->fetchrow_hashref;
81 my $patronnote = $issue->{note
};
82 $data->{patronnote
} = $patronnote;
84 ( $data->{returned
} ) = AddReturn
( $barcode, $branchcode, $exempt_fine );