-
Notifications
You must be signed in to change notification settings - Fork 7
/
deposit.php
58 lines (52 loc) · 1.95 KB
/
deposit.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
<?php
include('conf/db_connect.php');
connect();
session_start();
if(isset($_POST['shares'])){
$shares = $_POST['shares'];
}
$priv = $_SESSION['priv'];
$teller_id = $_SESSION['id'];
$acct_no = $_POST['acct_no'];
acct_check($acct_no);
$amt = $_POST['amt'];
$bank_teller = "default";
if(isset($_POST['bank_teller'])){
$bank_teller = $_POST['bank_teller'];
}
$date = date('y-m-d');
$result = query("SELECT * FROM account WHERE acct_no='$acct_no'");
$row = mysql_fetch_array($result);
$balance = $row['balance'] + $amt;
//$share = $row['shares'];
$no = $row['number'];
$type = $row['acct_type'];
/*if($shares == "shares"){
$share += $share;
$no += 1;
query("UPDATE account SET shares='$share', number='$no' WHERE acct_no='$acct_no'");
}*/
query("INSERT INTO deposit (bank_teller, acct_type, teller_id, acct_no, amount, date, balance) VALUES('$bank_teller', '$type', '$teller_id', '$acct_no', '$amt', '$date', '$balance')");
/*$rs = query("SELECT * FROM transaction WHERE date='$date' AND acct_no='$acct_no'");
if(mysql_num_rows($result) > 0) {
query("UPDATE transaction SET credit='$amt', balance='$balance'");
}else{*/
query("INSERT INTO transaction (bank_teller, description, acct_no, credit, date, balance) VALUES('$bank_teller', 'deposit', '$acct_no', '$amt', '$date', '$balance')");
//}$t_id = mysql_insert_id();
$result = query("SELECT * FROM account WHERE acct_no='$acct_no'");
$row = mysql_fetch_array($result);
$balance = $row['balance'];
$amt_todate = $row['amt_todate'];
$amt_todate += $amt;
$amt += $balance;
query("UPDATE account SET balance='$amt', amt_todate='$amt_todate' WHERE acct_no='$acct_no'");
$rs = query("SELECT * FROM ad_income");
$row = mysql_fetch_array($rs);
$bal = $row['balance'];
$int1 = $bal + $amt;
query("INSERT INTO income(date, income_type, amount, balance) VALUES('$date', '3', '$amt', '$int1')");
query("UPDATE ad_income SET balance='$int1'");
$res = "<strong id=result><i></i>New Balance</strong>
<p class=text-muted>$amt</p>";
echo $res;
?>