-
Notifications
You must be signed in to change notification settings - Fork 1
/
tradesman_home11.php
436 lines (371 loc) · 15.6 KB
/
tradesman_home11.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<?php
// TRADESMAN PAGE
// $trademsna id = 1; // tradesman ID JB
// $customer_id = 2; // customer ID mathi
include 'header.php';
include 'calendar.php';
$tradesman_id = 1;
//echo "loop start<br>";
$tradesmanObj = new Tradesman();
$tradesmanObj->read($tradesman_id);
//echo $tradesmanObj->checkHiringTimeCome($tradesman_id);
?>
<html>
<style>
<?php include 'Tradesman/Assets/Css/tradesman_home.css'?>
<?php include 'Assets/Css/header.css'?>
<?php include './Tradesman/Assets/Css/workerSignup.css'?>
</style>
<body>
<?php
$month = date("Y-m-d");
$calendar = new Calendar($month);
$current_month = $calendar->getActive_month();
$current_year = $calendar->getActive_year();
?>
<!-- ---------------------------------COVER PHOTO ON TOP WITH GRADIENT------------------------------------------- -->
<div class="cover">
<div class="coverimg">
<div class="coveroverlay">
<div class="container">
<div class="covertxt">
<span class="weAreHere">
WE ARE HERE
</span><br>
<span class="toHelp">
TO HELP
</span><br>
<span class="you">
YOU
</span>
</div>
</div>
</div>
</div>
</div>
<div id="scheduledMessage" class="bg-warning"></div>
<!-- ---------------------------------TOP SERVIES------------------------------------------- -->
<div id="exceptCoverPhoto">
<p id="top-services " class="h1 fw-bold p-3"><span id="topServices" class="pe-5">TOP SERVICES</span> </p>
<div class="row d-flex justify-content-evenly">
<!-- ---------------------------------PLUMBER BOX------------------------------------------- -->
<?php
require_once('classes.php');
$sql = "SELECT * FROM service Order by average_rating limit 4;";
$result = QueryHandler::query($sql);
while ($row = mysqli_fetch_array($result)) {
?>
<div id="box_service" class="col-md-5 mb-5">
<div id="box" class="row ">
<div class="col text-center">
<img id="job_images" class="" src="Assets/Images/plumber.jpg" alt="" />
</div>
<div id="service_detail " class=" col pt-3 d-flex flex-column align-items-xs-center align-items-md-center align-items-lg-start">
<div id="job" class=" d-flex text-center fw-bold h5 mt-1">
<div id="box" class=" pb-2"><?php echo $row['service_name']; ?></div>
</div>
<div class="fw-bolder"><?php echo $row['total_hirings']; ?> Total Order</div>
<div class="fw-bolder">
<p class="">
Avg Review <?php echo $row['average_rating']; ?>
<span id="star" class="material-icons"> grade</span>
</p>
</div>
</div>
</div>
</div>
<?php } ?>
<!-- CUSTOMER scheduleS -> show scheduled details in 2 way. CALENDAR & LIST -->
<div class="h1 text-uppercase mt-2">
<p>your schedules</p>
</div>
<div class="horizontal_line_customer"></div>
<!-- LIST VIEW OF scheduleS :: example :: "Sep 1, 02.10 p.m - Jeyabawan" -->
<div class="row m-3" id="CalendarContent">
<div class="col-md-12 col-lg-6 mb-5" id="schedule_list">
<div class="fw-bold me-5" id="schedule_list_box">
<p id="scheuledList" class="h3 fw-bold">
Your scheduled hirings for this month
</p>
<div id="alertBox" class="alert alert-dark" role="alert">
You Have No Schedule For This Month!!!!
</div>
<ul>
<?php
$sql = "SELECT * from calendar where tradesman_id='$tradesman_id' ORDER BY date;";
$result = QueryHandler::query($sql);
if (!$result) {
die('QUERY FAIL!');
}
$count = 0;
while ($row = mysqli_fetch_assoc($result)) {
$customerObject = new Customer();
$customerObject->read($row['customer_id']);
// echo $row['customer_id'];
if (date('m', strtotime($row['date'])) == $current_month && date('Y', strtotime($row['date'])) == $current_year) {
$count = $count + 1;
$calendar->add_event($customerObject->getUsername(), $row['date'], 1, 'green', $row['time']);
echo '<li class="fw bold h5">' . date('M j ,', strtotime($row['date'])) . ' ' . date('g:i a', strtotime($row['time'])) . ' - ' . $customerObject->getUsername() . ' - ' . $row['service_name'] . '</li>';
$events = $calendar->getEvents();
// echo '<script> console.log('.$events[0].'); </script>';
// echo $events[0];
for ($i = 1; $i <= 31; $i++) {
?><div class="modal fade" id="modal_schedule_date_<?php echo $i; ?>" role="dialog">
<div class="modal-dialog modal-dialog-centered">
<!-- Modal content-->
<div class="modal-content p-3 text-center">
<div><?php echo $customerObject->getUsername() . "<br>Date:" . $row['date'] . " Time:" . $row['time']; ?></div>
<div class="row">
<div class="col">
<button class="btn text-white fw-bold" style="background-color: #142f61">
CHANGE
</button>
</div>
<div class="col">
<button type="close" data-dismiss="modal" class="close btn text-white fw-bold" style="background-color: #142f61">
CLOSE
</button>
</div>
</div>
</div>
</div>
</div><?php
}
}
}
if ($count == 0) {
echo '<script>document.getElementById("scheuledList").style.display="none"; </script>';
echo '<script>document.getElementById("alertBox").style.display="block"; </script>';
} else {
echo '<script>document.getElementById("scheuledList").style.display="block";</script>';
echo '<script>document.getElementById("alertBox").style.display="none";</script>';
}
?>
<!-- <li class="fw bold h5">Sep 1, 02.10 p.m - Jeyabawan</li> -->
</ul>
</div>
</div>
<div class="col-md-12 col-lg-6" id="calendar_box">
<?php echo $calendar ?>
</div>
</div>
</div>
<div id="getCount" class="bg-warning">
</div>
</body>
</html>
<script>
$(document).ready(function() {
// console.log('documemt ready');
let tradesman_id = <?php echo $tradesman_id ?>;
function getCount(view = '') {
$.ajax({
url: "countSchedule.php",
method: "POST",
data: {
view: tradesman_id
},
dataType: "json",
success: function(data) {
console.log('success');
if (data.unseen_notification > 0) {
$('.count').html(data.unseen_notification);
}
}
});
}
function interval(tradesman_id = '') {
console.log("interval start");
$.ajax({
url: "interval.php",
method: "POST",
data: {
tradesman_id: tradesman_id
},
dataType: "json",
success: function(data) {
console.log('success interval');
console.log(data);
}
});
}
getCount();
function insertNotification(type, sheduleID, view = '') {
$.ajax({
url: "insertC.php",
method: "POST",
data: {
view: view,
type: type,
sheduleID: sheduleID
},
dataType: "json",
success: function(data) {
load_unseen_notification('yes');
console.log("insert notification success");
}
});
}
setInterval(function() {
getCount();
}, 5000);
function load_unseen_notification(view = '') {
let tradesman_id = <?php echo $tradesman_id ?>;
$.ajax({
url: "fetchOK.php",
method: "POST",
data: {
tradesman_id: tradesman_id,
view: view
},
dataType: "json",
success: function(data) {
$('.dropdown-menu').html(data.notification);
getCount();
// console.log("load_unseen_notification success");
}
});
}
load_unseen_notification();
$(document).on('click', '#drop-down', function() {
console.log("drop down clicked....");
$('.count').html('');
load_unseen_notification('yes');
console.log("dropdown success");
});
$(document).on("click", "#accept", function() {
$("#hirehim_modalFinal").modal({
show: true
});
let del = $(this);
let sheduleID = $(this).attr("data-id");
insertNotification("accept", sheduleID);
let hiring_id;
$.ajax({
type: "get",
data: {
sheduleID: sheduleID
},
url: "schedule.php",
success: function(data) {
hiring_id = data;
location.href = "http://localhost/quickfix/avines/ongoing/chatTradesman.php?hiring_id=" + hiring_id;
}
});
});
$(document).on("click", "#schedule", function() {
$("#hirehim_modalFinal").modal({
show: true
});
let del = $(this);
let sheduleID = $(this).attr("data-id");
insertNotification("accept", sheduleID);
console.log("schedule clicked");
let hiring_id;
$.ajax({
type: "get",
data: {
sheduleID: sheduleID
},
url: "scheduleHiring.php",
success: function(data) {
console.log(data);
// location.href = "http://localhost/quickfix/avines/ongoing/chatTradesman.php?hiring_id="+hiring_id;
}
});
});
$(document).on("click", "#decline", function() {
$("#hirehim_modalFinal").modal({
show: true
});
let del = $(this);
let sheduleID = $(this).attr("data-id");
insertNotification("decline", sheduleID);
$.ajax({
type: "post",
data: {
sheduleID: sheduleID
},
url: "decline.php",
success: function(data) {
console.log("schedule ID is : ");
console.log(sheduleID);
console.log("decline clicked....");
}
});
});
$(document).on("click", ".del", function() {
let del = $(this);
let current_month = $(this).attr("data-id");
console.log("preious clic");
var name = <?php echo $tradesman_id ?>;
$.ajax({
type: "get",
data: {
name: name,
current_month: current_month
},
url: "previous.php",
success: function(data) {
$("#CalendarContent").html(data);
}
});
});
$(document).on("click", ".del1", function() {
let del1 = $(this);
let current_month = $(this).attr("data-id");
var name = <?php echo $tradesman_id ?>;
$.ajax({
type: "get",
data: {
name: name,
current_month: current_month
},
url: "next.php",
success: function(data) {
$("#CalendarContent").html(data);
}
});
});
$(document).on("click", "#ok", function() {
let del = $(this);
let sheduleID = $(this).attr("data-id");
$.ajax({
type: "get",
data: {
sheduleID: sheduleID
},
url: "done_ok.php",
success: function(data) {
load_unseen_notification();
console.log("done clicked....");
}
});
});
$(document).on("click", "#done", function() {
let del = $(this);
let sheduleID = $(this).attr("data-id");
// location.href = "http://localhost/quickfix/avines/chatTradesman.php?hiring_id=" + sheduleID;
$.ajax({
type: "get",
data: {
sheduleID: sheduleID
},
url: "done_ok.php",
success: function(data) {
load_unseen_notification();
console.log("done clicked....");
}
});
});
<?php
for ($x = 0; $x <= 31; $x++) {
?>
$("#month_date<?php echo $x; ?>").click(function() {
$("#modal_schedule_date_<?php echo $x; ?>").modal({
show: true
});
});
<?php } ?>
});
</script>