-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathcustomer_transfer_process.php
78 lines (67 loc) · 2.93 KB
/
customer_transfer_process.php
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
<?php
session_start();
if(!isset($_SESSION['customer_login']))
header('location:index.php');
?>
<?php
$t_amount=$_REQUEST['t_val'];
$sender_id=$_SESSION["login_id"];
$reciever_id=$_REQUEST['transfer'];
//select last transaction id in reciever's passbook.
include '_inc/dbconn.php';
$sql="SELECT MAX(transactionid) from passbook".$reciever_id;
$result=mysql_query($sql) or die(mysql_error());
$rws= mysql_fetch_array($result);
$r_last_tid=$rws[0];
//select the details in the last row of reciever's passbook.
$sql="SELECT * from passbook".$reciever_id." WHERE transactionid='$r_last_tid'";
$result=mysql_query($sql) or die(mysql_error());
while($rws= mysql_fetch_array($result)){
$r_amount=$rws[7];
$r_name=$rws[2];
$r_branch=$rws[3];
$r_ifsc=$rws[4];
}
//select the last transaction id in the sender's passbook
$sql="SELECT MAX(transactionid) from passbook".$sender_id;
$result=mysql_query($sql) or die(mysql_error());
$rws= mysql_fetch_array($result);
$s_last_tid=$rws[0];
//select the details in the last row of sender's passbook.
$sql="SELECT * from passbook".$sender_id." WHERE transactionid='$s_last_tid'";
$result=mysql_query($sql) or die(mysql_error());
while($rws= mysql_fetch_array($result)) {
$s_amount=$rws[7];
$s_name=$rws[2];
$s_branch=$rws[3];
$s_ifsc=$rws[4];
}
$date=date("Y-m-d");
$s_total=$s_amount-$t_amount; //sender's final balance.
if($s_amount<=500)
{
echo '<script>alert("Your account balance is less than Rs. 500.\n\nYou must maintain a minimum balance of Rs. 500 in order to proceed with the transfer.");';
echo 'window.location= "customer_transfer.php";</script>';
}
elseif($t_amount<100){
echo '<script>alert("You cannot transfer less than Rs. 100");';
echo 'window.location= "customer_transfer.php";</script>';
}
elseif($s_total<500)
{
echo '<script>alert("You do not have enough balance in your account to proceed this transfer.\n\nYou must maintain a minimum of Rs. 500 in your account.");';
echo 'window.location= "customer_transfer.php";</script>';
}
else{
//insert statement into reciever passbook.
$r_total=$r_amount+$t_amount;
$sql1="insert into passbook".$reciever_id." values('','$date','$r_name','$r_branch','$r_ifsc','$t_amount','0','$r_total','BY $s_name')";
mysql_query($sql1) or die(mysql_error());
//insert statement into sender passbook.
$s_total=$s_amount-$t_amount;
$sql2="insert into passbook".$sender_id." values('','$date','$s_name','$s_branch','$s_ifsc','0','$t_amount','$s_total','TO $r_name')";
mysql_query($sql2) or die(mysql_error());
echo '<script>alert("Transfer Successful.");';
echo 'window.location= "customer_transfer.php";</script>';
}
?>