Bug 12905: funds with children could not be deleted
[koha.git] / offline_circ / service.pl
blobb56bb75482befa733f87575529cbca3ebfb93995
1 #!/usr/bin/perl
3 # 2009 BibLibre <jeanandre.santoni@biblibre.com>
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 use strict;
22 use warnings;
24 use CGI qw ( -utf8 );
25 use C4::Auth;
26 use C4::Circulation;
28 my $cgi = CGI->new;
30 # get the status of the user, this will check his credentials and rights
31 my ($status, $cookie, $sessionId) = C4::Auth::check_api_auth($cgi, undef);
32 ($status, $sessionId) = C4::Auth::check_cookie_auth($cgi, undef) if ($status ne 'ok');
34 my $result;
36 if ($status eq 'ok') { # if authentication is ok
38 my $userid = $cgi->param('userid') || '';
39 my $branchcode = $cgi->param('branchcode') || '';
40 my $timestamp = $cgi->param('timestamp') || '';
41 my $action = $cgi->param('action') || '';
42 my $barcode = $cgi->param('barcode') || '';
43 my $amount = $cgi->param('amount') || 0;
44 $barcode =~ s/^\s+//;
45 $barcode =~ s/\s+$//;
46 my $cardnumber = $cgi->param('cardnumber') || '';
47 $cardnumber =~ s/^\s+//;
48 $cardnumber =~ s/\s+$//;
50 if ( $cgi->param('pending') eq 'true' ) { # if the 'pending' flag is true, we store the operation in the db instead of directly processing them
51 $result = AddOfflineOperation(
52 $userid,
53 $branchcode,
54 $timestamp,
55 $action,
56 $barcode,
57 $cardnumber,
58 $amount
60 } else {
61 $result = ProcessOfflineOperation(
63 'userid' => $userid,
64 'branchcode' => $branchcode,
65 'timestamp' => $timestamp,
66 'action' => $action,
67 'barcode' => $barcode,
68 'cardnumber' => $cardnumber,
69 'amount' => $amount
73 } else {
74 $result = "Authentication failed."
77 print CGI::header('-type'=>'text/plain', '-charset'=>'utf-8');
78 print $result;