forked from KesaviAravinthan/QuickFix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsertHireAny.php
71 lines (57 loc) · 2.27 KB
/
insertHireAny.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
<?php
include 'classes.php';
$notification = new Notification();
if (isset($_POST['radioAddress'])) {
$address;
$lat;
$lng;
$customer_id = $_POST['customer_id'];
$service_id = $_POST['service_id'];
if ($_POST['radioAddress'] == "Use default Address") {
$result = QueryHandler::query("SELECT * from customer WHERE customer_id='$customer_id'");
$data = mysqli_fetch_assoc($result);
$address = $data['address'];
$lat = $data['latitude'];
$lng = $data['longitude'];
} else {
$address = $_POST['address'];
$lat = $_POST['lat'];
$lng = $_POST['lng'];
}
$customerObj = new Customer();
$customerObj->read($customer_id);
$_SESSION['lat_hire_any_now'] = $lat;
$_SESSION['lng_hire_any_now'] = $lng;
$_SESSION['address_hire_any_now'] = $address;
$distanceArrNow = $customerObj->findNearTradesmanHireNow($lat, $lng, $service_id);
$c = count($distanceArrNow);
if ($c > 0) {
$suggest_count = 0;
foreach ($distanceArrNow as $tradesman_id_hire_Now => $distanceNow) {
if ($suggest_count < 1) {
$suggest_count++;
$_SESSION['tradesman_id_for_hire_now'] = $tradesman_id_hire_Now;
}
}
}else{
echo "<script>alert('There are no tradesman online now try again later')</script>";
}
// echo "<script> count_check($c); </script>";
$latitude = $_SESSION['lat_hire_any_now'];
$longitude = $_SESSION['lng_hire_any_now'] ;
$address = $_SESSION['address_hire_any_now'] ;
$tradesman_id = $_SESSION['tradesman_id_for_hire_now'];
echo $longitude.$address.$latitude;
$receiver_id = $tradesman_id;
$sender_id = $customer_id;
$service = new Service();
$service->read($service_id);
$service_name = $service->getService_name();
$customer = new Customer();
$customer->read($customer_id);
$name_customer = $customer->getUsername();
$notificationString = "Hire Now request <br> Service - : <strong>".$service_name." </strong><br> Customer : <strong>".$name_customer."</strong><br> From: ".$address;
$notification->hireNow($notificationString, $receiver_id, $sender_id , "accept_decline" ,$service_id , $latitude, $longitude);
} else {
echo "aibswulefglwfe";
}