-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontribution_check.php
116 lines (82 loc) · 2.96 KB
/
contribution_check.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
error_reporting();
session_start();
$entered_amount=$_SESSION['boxamount'];
date_default_timezone_set('Asia/Kolkata');
$today=date('d-M-y');
$updated_time= date('d-M-y h:i a', time());
$time=date('h:i a', time());
$month=date('M');
$year=date('Y');
$name=$_SESSION['name'];
$user=implode($name);
$reason=$_SESSION['reason'];
$optone='No Amount in Box';
include("./database/db_connection.php");
/*if(isset($_POST['submit']))
{*/
if($reason==$optone)
{
$query=mysqli_query($con, "SELECT Amount FROM `current_boxbalance`");
$row=mysqli_fetch_assoc($query);
$available_amount_in_box=$row['Amount'];
if(mysqli_num_rows($query)==0)
{
$sql="INSERT INTO `individual_contribute` (`Date`, `Time`, `Month`, `Year`, `Contribution Amount`, `Whose Amount`, `Reason`) VALUES ('$today', '$time', '$month', '$year', '$entered_amount', '$user', '$reason')";
if($con->Query($sql)===TRUE)
{
$insert="INSERT INTO `current_boxbalance` (`Amount`, `last_updated`, `Addedby`) VALUES ('$entered_amount', '$updated_time', '$user')";
if($con->Query($insert)===TRUE)
{
header("location:boxbalance_success.php");
}
}
}
else
if($available_amount_in_box==0)
{
$contribute="INSERT INTO `individual_contribute` (`Date`, `Time`, `Month`, `Year`, `Contribution Amount`, `Whose Amount`, `Reason`) VALUES ('$today', '$time', '$month', '$year', '$entered_amount', '$user', '$reason')";
if($con->Query($contribute)===TRUE)
{
$query2="UPDATE `current_boxbalance` SET `Amount`=Amount+$entered_amount, `last_updated`='$updated_time', `Addedby`='$user'";
if($con->Query($query2)===TRUE)
{
header("location:boxbalance_success.php");
}
}
}
else
{
header("location:recheck.php");
}
}
else
{
$que=mysqli_query($con, "SELECT Amount FROM `current_boxbalance`");
if(mysqli_num_rows($que)==0)
{
$sqli="INSERT INTO `individual_contribute` (`Date`, `Time`, `Month`, `Year`, `Contribution Amount`, `Whose Amount`, `Reason`) VALUES ('$today', '$time', '$month', '$year', '$entered_amount', '$user', '$reason')";
if($con->Query($sqli)===TRUE)
{
$ins="INSERT INTO `current_boxbalance` (`Amount`, `last_updated`, `Addedby`) VALUES ('$entered_amount', '$updated_time', '$user')";
if($con->Query($ins)===TRUE)
{
header("location:boxbalance_success.php");
}
}
}
else
{
$contri="INSERT INTO `individual_contribute` (`Date`, `Time`, `Month`, `Year`, `Contribution Amount`, `Whose Amount`, `Reason`) VALUES ('$today', '$time', '$month', '$year', '$entered_amount', '$user', '$reason')";
if($con->Query($contri)===TRUE)
{
$query3="UPDATE `current_boxbalance` SET `Amount`=Amount+$entered_amount, `last_updated`='$updated_time', `Addedby`='$user'";
if($con->Query($query3)===TRUE)
{
header("location:boxbalance_success.php");
}
}
}
}
//}
?>