-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtradesmanHome.php
596 lines (501 loc) · 21 KB
/
tradesmanHome.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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
<?php
include 'header.php';
include 'calendar.php';
// $tradesman_id = 17;
$tradesman_id = $_SESSION['customer_id'];
// $tradesman_id = $_GET['tradesman_id'];
$tradesmanObj = new Tradesman();
$tradesmanObj->read($tradesman_id);
?>
<html>
<style>
#top1 {
background-color: rgb(223, 223, 223);
font-weight: bold;
}
#earnsHeading {
border-bottom: 0.2rem solid #142f61;
}
#workerPhoto {
border-radius: 35%;
height: 7rem;
width: 7rem;
}
#reviewtext {
color: #818589;
;
}
@media (max-width: 992px) {
#details {
text-align: center;
}
#number {
text-align: center;
}
}
@media (min-width: 768px) {
#profile {
border-right: 0.3rem solid #142f61;
}
}
/*------------------------------------------------------------------------*/
.calendar {
display: flex;
flex-flow: column;
}
.calendar .days {
display: flex;
flex-flow: wrap;
}
.calendar .days .day_name {
width: calc(100% / 7);
border-right: 1px solid #ffffff;
padding: 0.25rem;
text-transform: none;
font-size: 0.75rem;
font-weight: bold;
color: #818589;
color: #fff;
background-color: #142f61;
}
.calendar .days .day_name:nth-child(7) {
border: none;
}
.calendar .days .day_num {
display: flex;
flex-flow: column;
width: calc(100% / 7);
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
padding: 2px;
font-weight: bold;
color: #000000;
cursor: pointer;
min-height: 50px !important;
max-height: 50px !important;
}
.calendar .days .day_num span {
display: inline-flex;
width: 30px;
font-size: 14px;
}
.calendar .days .day_num .scheduled_event {
margin-top: -13px;
font-weight: 500;
font-size: 14px;
padding-left: 10px;
color: rgb(0, 0, 0);
max-height: 50px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.calendar .days .day_num:nth-child(7n + 1) {
border-left: 1px solid #000000;
}
.calendar .days .day_num:hover {
background-color: #fdfdfde8;
}
.calendar .days .day_num.ignore_dates {
background-color: #fdfdfd;
color: #ced2d4;
cursor: inherit;
}
.calendar .days .day_num.selected {
background-color: #f1f2f3;
cursor: inherit;
}
.horizontal_line_customer {
border-top: 6px solid #142f61;
/* height: 25rem; */
width: 22rem;
position: relative;
/* right: 60%; */
top: -1rem;
}
.new1 {
border: 6px solid #142f61;
width: 6rem;
}
#schedule_list {
margin: auto;
}
#calendar_box {
border: 6px solid #142f61;
border-width: 0 0 0 0.4rem;
padding-left: 2rem;
}
@media (max-width: 992px) {
#calendar_box {
border: 6px hidden #142f61;
}
.horizontal_line_customer {
border-top: 6px solid #142f61;
position: relative;
top: -1rem;
padding-top: 2rem;
width: 18rem;
}
}
/* --------------------------------------------------------------- */
.horizontal_line_customer {
border-top: 6px solid #142f61;
width: 22rem;
position: relative;
top: -1rem;
}
#job_images {
width: 15rem;
height: 10rem;
border-radius: 2rem;
padding: 1rem;
}
/* #job{
border-bottom: 0.18rem solid #0d56dd;
padding-bottom: 0.5rem;
} */
#star {
color: #df8918;
position: relative;
top: 0.4rem;
}
#box {
border-bottom: 0.2rem solid #142f61;
}
#topServices,
#lastHiringUnderline,
#yourScheduleUnderline {
border-bottom: 0.4rem solid #142f61;
}
@media (max-width: 768px) {
#service_detail {
align-items: center;
}
}
/* ---------------------------------------------------------------------------------- */
#photoWorker {
width: 8rem;
height: 8rem;
border-radius: 50%;
padding: 1rem;
}
#hireBox {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2),
0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 2%;
}
</style>
<body>
<?php
$month = date("Y-m-d");
$calendar = new Calendar($month);
$current_month = $calendar->getActive_month();
$current_year = $calendar->getActive_year();
?>
<div class="container">
<!-- --------------------Top box 1 ------------------------------------------- -->
<div id="top1" class="row py-5">
<div class="col-md-5 com-sm-12 ms-lg-5 pe-0" id="profile">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-3" id="photo">
<div class="text-center">
<img src=<?php $tradesmanObj->getImg() ?> id="workerPhoto" class="" />
</div>
<div class="text-center pt-3">@<?= $tradesmanObj->getUsername() ?></div>
</div>
<div class="col-sm-12 col-md-12 col-lg-8 ms-lg-4 ms-md-4 ms-lg-0" id="details">
<div class="row" id="name">
<div class="text-uppercase"><?= $tradesmanObj->getFirstname(); ?> <?= $tradesmanObj->getLastname() ?></div>
</div>
<div class="row pt-3" id="number">
<div><?= $tradesmanObj->getPhone_no() ?></div>
<div><?= $tradesmanObj->getEmail() ?></div>
<div><?= $tradesmanObj->getAddress() ?></div>
</div>
</div>
</div>
</div>
<div class="col-md-5 com-sm-12 ms-4 row mt-sm-3" id="earnings">
<div id="counts" class="col-md-12 col-sm-6">
<div>Total Hirings - <?= $tradesmanObj->getNum_of_hirings() ?></div>
<div>Total Ratings - <?= $tradesmanObj->getNum_of_ratings() ?></div>
<div>Total Reviews - <?= $tradesmanObj->getNum_of_review() ?></div>
<div>Average Rating - <?= $tradesmanObj->getAverage_rating() ?></div>
<div>Total Earnings - <?= $tradesmanObj->getTotal_earnings() ?></div>
</div>
<div id="eanrs" class="mt-3 col-md-12 col-sm-6">
<span id="earnsHeading" class="text-uppercase pb-1 pe-5">earnings
</span>
<div class="mt-2">Plumbing - 10 - Hirings - Rs 3600/=</div>
<div>Electrical work - 13 - Hirings - Rs 4600/=</div>
</div>
</div>
</div>
<!-- ------------------------------------------------------------------------- -->
<!-- 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>
<!-- --------------------Third box - LAST HIRINGS ------------------------------------------- -->
<div class="h1 text-uppercase mt-2 ms-5">
<span id="lastHiringUnderline">last hirings</span>
</div>
<div class="row fw-bold ms-3" id="hiringRow">
<?php
require_once('classes.php');
$sql = "SELECT * FROM hiring WHERE current_status = 'completed' AND tradesman_id='$tradesman_id' limit 4;";
$result = QueryHandler::query($sql);
while ($row = mysqli_fetch_array($result)) {
$customerObject = new Customer();
$customerObject->read($row['customer_id']);
$hiringObject = new Hiring();
$hiringObject->read($row['hiring_id']);
?>
<div class="d-flex justify-content-center row col-sm-12 col-md-12 col-lg-6">
<div id="hireBox" class="p-2 m-3 col-sm-12 col-lg-11">
<div class="row">
<div class="col-4 d-flex justify-content-center">
<img src="images/mathi.JPG" id="photoWorker" />
</div>
<div class="col-8" id="statics">
<div>ID No :<span> <?= $customerObject->getCustomer_id() ?></span></div>
<div>Name :<span> <?= $customerObject->getFirstname() ?></span></div>
<div>Address :<span> <?= $customerObject->getAddress() ?></span></div>
<div><?= $hiringObject->getRegistered_dateTime(); ?></div>
<?php
$serviceID = $hiringObject->getService_id();
$serviceObj = new Service();
$serviceObj->read($serviceID);
?>
<div><?= $serviceObj->getService_name(); ?></div>
</div>
</div>
<div class="row">
<div>
Hiring amount :<span> Rs <?= $hiringObject->getHiring_amount() ?>/=</span>
</div>
<div>Payment method :<span> <?= $hiringObject->getPayment_method() ?></span></div>
</div>
<div class="row">
<div class="row">
<div class="col-3 col-sm-3 col-md-2 col-lg-3 ">Rating :</div>
<div class="col-9 col-sm-9 col-md-10 col-lg-9 p-0 m-0" id="ratingStar">
<span id="star" class="material-icons"> grade</span>
<span id="star" class="material-icons"> grade</span>
<span id="star" class="material-icons"> grade</span>
<span id="star" class="material-icons"> grade</span>
<span id="star" class="material-icons"> grade</span>
</div>
</div>
<div class="row">
<div class="col-3 col-sm-3 col-md-2 col-lg-3 ">Review :</div>
<?php
if ($row['review'] == NULL) {
$review = "Not Given";
} elseif ($row['review'] != NULL) {
$review = $row['review'];
}
?>
<div class="col-9 col-sm-9 col-md-10 col-lg-9 p-0 m-0" id="reviewtext"><?= $review ?></div>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
<!-- ---------------------------------TOP SERVIES------------------------------------------- -->
<p id="top-services " class="h1 fw-bold p-3">
<span id="topServices" class="pe-5">TOP SERVICES</span>
</p>
<!-- ---------------------------------PLUMBER BOX------------------------------------------- -->
<div class="row d-flex justify-content-evenly">
<?php
require_once('classes.php');
$sql = "SELECT * FROM service Order by average_rating DESC limit 4;";
$result = QueryHandler::query($sql);
while ($row = mysqli_fetch_array($result)) {
$serviceObject = new Service();
$serviceObject->read($row['service_id']);
?>
<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="<?= $serviceObject->getCover_photo() ?>" 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"><?= $serviceObject->getProvider_name() ?></div>
</div>
<div class="fw-bolder"><?= $serviceObject->getTotal_hirings() ?> Total Order</div>
<div class="fw-bolder">
<p class="">
Avg Rating <?= $serviceObject->getAverage_rating() ?>
<span id="star" class="material-icons"> grade</span>
</p>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function() {
// console.log('documemt ready');
let tradesman_id = <?php echo $tradesman_id ?>;
// 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);
// }
// });
// }
// $(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....");
// }
// });
// });
$(document).on("click", ".del", function() {
console.log("previous button cicked.");
let del = $(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: "previous.php",
success: function(data) {
console.log(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) {
console.log(data);
$("#CalendarContent").html(data);
}
});
});
<?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>