-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfetchOK.php
110 lines (99 loc) · 4.93 KB
/
fetchOK.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
<?php
// include("connect.php");
include 'classes.php';
$output = '';
if (isset($_POST["view"])) {
$tradesman_id = $_POST["tradesman_id"];
// $tradesman_id =2;
if ($_POST["view"] != '') {
$update_query = "UPDATE notification SET seen_status=1 WHERE seen_status=0 AND receiver_id = '$tradesman_id'; ";
$result = QueryHandler::query($update_query);
if (!$result) {
die('QUERY FAIL!');
}
}
// $query = "SELECT * FROM notification WHERE receiver_id = '$tradesman_id'; ";
$query = "SELECT * FROM notification WHERE receiver_id = '$tradesman_id' Order by notification_id DESC; ";
$result = QueryHandler::query($query);
if (!$result) {
die('QUERY FAIL!');
}
if (mysqli_num_rows($result) > 0) {
// <a href="test_get.php?subject=PHP&web=W3schools.com">Test $GET</a>
//href = "chatTradesman.php?customer_id='.$commentID.'"
// href = "sample_myHiring.php?customer_id=3"
while ($row = mysqli_fetch_array($result)) {
$notificationID = '';
if ($row['notification_type'] == 'ok') {
$notificationID = $row['notification_id'];
$output .= '
<li>
<div class="bg-light p-1 row" >
<div class="col"><strong>' . $row["notification"] . '</strong> </div>
<div class="btn btn-success " id="ok" style="background-color:#142f61; color: white;" data-id="' . $notificationID . '" >OK</div>
</div>
</li>
<li class="divider"></li>
';
} elseif ($row['notification_type'] == 'accept_decline') {
$commentID = $row['notification_id'];
$output .= '
<li class="p-0">
<div class="" >
<div class=" p-1"> ' . $row["notification"] . '<br /> Date : <strong>' . $row["date"] . '</strong><br /> Time : <small><em>' . $row["time"] . '</em></small></div>
<div class="d-flex">
<a class="btn m-1" id="accept" style="background-color:#142f61; color: white;" data-id="' . $commentID . '" >Accept</a>
<a class="btn m-1" id="decline" style="background-color:#142f61; color: white;" data-id="' . $commentID . '">Decline</a>
</div>
</div>
</li>
<li class="divider"></li>
';
} elseif ($row['notification_type'] == 'common') {
$commentID = $row['notification_id'];
$output .= '
<li class="p-0">
<div class="" >
<div class=" p-1"> ' . $row["notification"] . '<br /> Date : <strong>' . $row["date"] . '</strong><br /> Time : <small><em>' . $row["time"] . '</em></small></div>
<div class="d-flex">
<a class="btn m-1" id="schedule" style="background-color:#142f61; color: white;" data-id="' . $commentID . '" >Schedule</a>
<a class="btn m-1" id="decline" style="background-color:#142f61; color: white;" data-id="' . $commentID . '">Decline</a>
</div>
</div>
</li>
<li class="divider"></li>
';
} elseif ($row['notification_type'] == 'addnewservice') {
$notificationID = $row['notification_id'];
$service_id = $row['service_id'];
$output .= '
<li>
<div class="bg-light p-1 row" >
<div class="col"><strong>' . $row["notification"] . '</strong> </div>
<a href="one_service_page.php?service_id='.$service_id.'"> <div class="btn btn-success " id="view" style="background-color:#142f61; color: white;" data-id=" ' . $notificationID . '" >view</div> </a>
</div>
</li>
<li class="divider"></li>
';
} else {
$notificationID = $row['notification_id'];
$output .= '
<li>
<div class="bg-light p-1 row" >
<div class="col"><strong>' . $row["notification"] . '</strong> </div>
<a class="btn btn-success " id="done" style="background-color:#142f61; color: white;" data-id="' . $notificationID . '" >done</a>
</div>
</li>
<li class="divider"></li>
';
}
}
} else {
$output .= '<li><div class="text-bold text-italic">No Notification Found</div></li>';
}
}
$data = array(
'notification' => $output
);
echo json_encode($data);
?>