1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| <?php
if (isset($_POST['deposit'])) {
$tr_code = $_POST['tr_code'];
$account_id = $_GET['account_id'];
$acc_name = $_POST['acc_name'];
$account_number = $_GET['account_number'];
$acc_type = $_POST['acc_type'];
// $acc_amount = $_POST['acc_amount'];
$tr_type = $_POST['tr_type'];
$tr_status = $_POST['tr_status'];
$client_id = $_GET['client_id'];
$client_name = $_POST['client_name'];
$client_national_id = $_POST['client_national_id'];
$transaction_amt = $_POST['transaction_amt'];
$client_phone = $_POST['client_phone'];
//$acc_new_amt = $_POST['acc_new_amt'];
//Notication
$notification_details = "$client_name Has Deposited Ksh $transaction_amt To Bank Account $account_number";
$balQuery = "SELECT acc_amount FROM iB_bankAccounts WHERE client_id = ? AND account_number = ? AND acc_status = 'Active'";
$stmtBal = $mysqli->prepare($balQuery);
//bind paramaters
$balance = $stmtBal->bind_param('ii', $client_id, $account_number);
$stmtBal->execute();
// var_dump($balance);
echo $balance;
if ($stmtBal->execute()) {
if ($balance->num_rows == 1) {
/* if($type == "debit") {
//check if amt is more then $balance
if($balance < $amt) {
header('Location: index.php?msg=' . urlencode('Solde du compte est inferieur, ne parvient pas a transférer des fonds.'));
exit;
}
} */
$total = $balance + $transaction_amt;
if($total <= 0) {
//return here...
}
//Insert Captured information to a database table
$query="UPDATE iB_bankAccounts SET acc_amount = ? WHERE client_id = ?";
$stmt = $mysqli->prepare($query);
//bind paramaters
$rc=$stmt->bind_param('ii', $total, $client_id);
$stmt->execute();
//email details...
header('Location: pages_balance_enquiries.php');
exit;
//Insert Captured information to a database table
$query = "INSERT INTO iB_Transactions (tr_code, account_id, acc_name, account_number, acc_type, tr_type, tr_status, client_id, client_name, client_national_id, transaction_amt, client_phone) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
$notification = "INSERT INTO iB_notifications (notification_details) VALUES (?)";
$stmt = $mysqli->prepare($query);
$notification_stmt = $mysqli->prepare($notification);
//bind paramaters
$rc = $notification_stmt->bind_param('s', $notification_details);
$rc = $stmt->bind_param('ssssssssssss', $tr_code, $account_id, $acc_name, $account_number, $acc_type, $tr_type, $tr_status, $client_id, $client_name, $client_national_id, $transaction_amt, $client_phone);
$stmt->execute();
$notification_stmt->execute();
//declare a varible which will be passed to alert function
if ($stmt->execute()) {
if ($notification_stmt->execute()) {
$success = "Money Deposited";
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $notification_stmt->error);
}
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $stmt->error);
}
} else {
die($stmtBal->error);
// header('Location: pages_dashboard.php');
// exit;
$err = 'The account number is inactive. You cannot transfer funds with an inactive account.';
}
} else {
$err = "Unable to operate fund deposit on this account at this time. Please try again later.";
// die('Erreur SQL : ' . $stmt->error);
exit;
}
}
?> |
Partager