- if ( $cgi->param('pending') eq 'true' ) { # if the 'pending' flag is true, we store the operation in the db instead of directly processing them
- $result = AddOfflineOperation(
- $cgi->param('userid') || '',
- $cgi->param('branchcode') || '',
- $cgi->param('timestamp') || '',
- $cgi->param('action') || '',
- $cgi->param('barcode') || '',
- $cgi->param('cardnumber') || '',
- );
- } else {
- $result = ProcessOfflineOperation(
+
+ my $userid = $cgi->param('userid') || '';
+ my $branchcode = $cgi->param('branchcode') || '';
+ my $timestamp = $cgi->param('timestamp') || '';
+ my $action = $cgi->param('action') || '';
+ my $barcode = $cgi->param('barcode') || '';
+ my $amount = $cgi->param('amount') || 0;
+ $barcode =~ s/^\s+//;
+ $barcode =~ s/\s+$//;
+ my $cardnumber = $cgi->param('cardnumber') || '';
+ $cardnumber =~ s/^\s+//;
+ $cardnumber =~ s/\s+$//;
+
+ if ( $cgi->param('pending') eq 'true' ) { # if the 'pending' flag is true, we store the operation in the db instead of directly processing them
+ $result = AddOfflineOperation(
+ $userid,
+ $branchcode,
+ $timestamp,
+ $action,
+ $barcode,
+ $cardnumber,
+ $amount
+ );
+ } else {
+ $result = ProcessOfflineOperation(