-
Notifications
You must be signed in to change notification settings - Fork 1
/
scheduleHiring.php
59 lines (48 loc) · 2.11 KB
/
scheduleHiring.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
<?php
// include 'classes.php';
require_once 'classes.php';
require_once 'calendar.php';
// $conn = (new Connection())->createConnection();
$calendar_date = date("Y-m-d");
$calendar = new Calendar($calendar_date);
$notification = new Notification();
$sheduleID = $_GET['sheduleID'];
$sql = "SELECT * from notification where notification_id=$sheduleID;";
$result = QueryHandler::query($sql);
if (!$result) {
die('QUERY FAILLLL!');
}
$row = mysqli_fetch_assoc($result);
$date = $row['date'];
$time = $row['time'];
$tradesman_id = $row['receiver_id'];
$customer_id = $row['sender_id'];
// $service_id = $row[''];
$service_id = $row['service_id'];
$service = new Service();
$service->read($service_id);
$service_name = $service->getService_name();
// $notification->createHiring($sheduleID);
echo $date.' '.$time.' '.$tradesman_id.' '.$customer_id.' '.$service_id;
// $notification_id, $date, $time, $tradesman_id, $customer_id, $service_id)
$lng = $row['longitude'];
$lat = $row['latitude'];
$hiring_id = $notification->createHiring($date,$time, $tradesman_id,$customer_id,$service_id, "Scheduled" , $lng , $lat, "On the way");
// echo $sheduleID . ' ' . $date . ' ' . $time . '<br>';
$canSchedule = $calendar->checkShedule($tradesman_id, $time, $date );
// $tradesman_id = 1;
if ($canSchedule) {
echo "Hiring was successfully scheduled <br>This Hiring request is scheduled in your calendar<br>Check it!!! ";
echo $service_name;
$query = "INSERT INTO calendar(tradesman_id,date, time,customer_id,service_name)VALUES ('$tradesman_id','$date', '$time','$customer_id', '$service_name')";
$result = QueryHandler::query($query);
if (!$result) {
die('QUERY FAILLLL!');
}
} else {
echo "You have been scheduled for hiring at the same time already <br> The notification has been sent to the customer.";
// echo '<script> alert("You have another work at this time. You can not schedule this hiring request!!");<script>';
}
$notification->remove($sheduleID);
$data = $hiring_id;
echo json_encode($data);