-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompleteReq.php
85 lines (63 loc) · 1.72 KB
/
completeReq.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
<?php
require_once("config/connection.php");
session_start();
if (!isset($_SESSION["login_user"])) {
echo "<b> Access Denied<b>";
print_r($_SESSION["login_user"] . "S");
die();
return;
}
$address=$_POST['address'];
$lat=$_POST['lat'];
$lon=$_POST['lon'];
$empId=$_SESSION['login_user']['id'];
$id=$_POST['id'];
$img= $_POST['img'];
$citizen= $_POST['citizen'];
$amount= $_POST['amount'];
$sql="SELECT balance from employee_info where id=$empId";
$res=mysqli_query($conn,$sql);
if(!$res){
echo mysqli_error($conn);
}else{
$row=mysqli_fetch_assoc($res);
$bal=$row['balance'];
if($amount>$bal){
echo -1;
echo $bal;
return;
}else{
$bal-=$amount;
$sql="UPDATE employee_info set balance=$bal where id=$empId";
$res=mysqli_query($conn,$sql);
if(!$res){
echo mysqli_error($conn);
}else{
$sql1="INSERT INTO complete_service (service_id,image,address,lat,lon) VALUES($id,'$img','$address',$lat,$lon)";
if(!mysqli_query($conn,$sql1)){
echo $mysqli_error($conn).$sql1;
}else{
$ro;
$sql2="UPDATE service set status=4,remark='Service Completed' where id=$id";
if(!mysqli_query($conn,$sql2)){
echo $mysqli_error($conn);
}else{
$sql="SELECT * FROM citizen where id=$citizen";
if(!$r=mysqli_query($conn,$sql)){
echo mysqli_error($conn).$sql;
}else{
$ro=mysqli_fetch_assoc($r);
// print_r($ro);
$account=$ro['account_no'];
$sql="INSERT into transection (amount,mode,narration,account_no) VALUES($amount,'CREDIT','For Service no $id',$account)";
if(!mysqli_query($conn,$sql)){
echo mysqli_error($conn).$sql;
}else
echo 1;
}
}
}
}
}
}
?>