-
Notifications
You must be signed in to change notification settings - Fork 1
/
requests.php
595 lines (553 loc) · 38.2 KB
/
requests.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
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
include("includes/functions.php");
check_if_logged_in();
include_once("includes/db.php");
$aid = $_SESSION['user_id'];
$q = "SELECT * FROM accounts WHERE aid={$aid}";
$query = oci_parse($db, $q);
oci_execute($query);
$row = oci_fetch_assoc($query);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include('includes/head.php'); ?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/header.css">
<link rel="stylesheet" href="css/profile.css">
<link rel="stylesheet" href="css/footer.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!-- <script type="text/javascript">-->
<!-- -->
<!-- if (screen.width <= 800) {-->
<!-- document.location = "requests-m";-->
<!-- }-->
<!-- -->
<!-- </script>-->
<title>Requests | Pick & Fix</title>
<style>
h1 {
font-size: 2em;
font-family: Roboto, sans-serif;
margin-bottom: 0 !important;
font-weight: bold !important;
}
a:hover {
text-decoration: none;
color: black;
}
</style>
</head>
<body id="requests">
<div id="page-container">
<?php include('includes/header.php'); ?>
<main class="center">
<!-- NEW REQUESTS -->
<?php
$query2 = oci_parse($db, "SELECT H.STATUS, H.DATETIME, H.REQUEST
FROM REQUESTS R, REQUESTS_HISTORY H, WORK_OFFERS W
WHERE R.WORK_OFFER = W.WID
AND H.REQUEST = R.RID
AND STATUS = 0
AND W.PROFESSIONAL = {$aid}");
oci_execute($query2);
?>
<?php if ($row['ROLE'] == 1) {
$num_of_new = 1; ?>
<h2>New requests</h2>
<div class="shadow">
<?php if ($row2 = oci_fetch_assoc($query2)) {
$query3 = oci_parse($db, "SELECT user_id, R.*, H.REQUEST, H.DATETIME, H.STATUS, S.CATEGORY, C.CNAME, A.FNAME, A.LNAME, offer_amount
FROM REQUESTS R, REQUESTS_HISTORY H, WORK_OFFERS W, SERVICES S, ACCOUNTS A, CITIES C
WHERE R.WORK_OFFER = W.WID
AND W.CITY = C.CID
AND R.USER_ID = A.AID
AND H.REQUEST = R.RID
AND W.SERVICE = S.SID
AND H.STATUS = 0 and offer_amount = -1
AND W.PROFESSIONAL = {$aid}
ORDER BY H.DATETIME DESC");
oci_execute($query3);
?>
<table class="requests">
<tr>
<th>#</th>
<th>FROM</th>
<th>REQUESTED<br>SERVICE</th>
<th>IN</th>
<th>NUMBER OF<br>HOURS</th>
<th>ESTIMATED<br>PRICE</th>
<th>DATE<br>RECEIVED</th>
<th>STATUS</th>
</tr>
<?php while ($row3 = oci_fetch_assoc($query3)) {
$request_id = $row3['REQUEST'];
$query4 = oci_parse($db, "SELECT R.*, H.REQUEST, H.DATETIME, H.STATUS, S.CATEGORY, A.FNAME, A.LNAME
FROM REQUESTS R, REQUESTS_HISTORY H, WORK_OFFERS W, SERVICES S, ACCOUNTS A
WHERE R.WORK_OFFER = W.WID
AND R.USER_ID = A.AID
AND H.REQUEST = R.RID
AND W.SERVICE = S.SID
AND H.REQUEST = {$request_id}
AND H.STATUS IN (1, 2)
AND W.PROFESSIONAL = {$aid}");
oci_execute($query4);
if (!oci_fetch_assoc($query4)) { ?>
<tr>
<td style="border-right: 1px solid #7579e7;"><?php echo $num_of_new;
$num_of_new++; ?></td>
<td><a href="profile.php?id=<?=$row3['USER_ID']?>"><?= $row3['FNAME'] . ' ' . $row3['LNAME'] ?></a></td>
<td><?= $row3['CATEGORY'] ?></td>
<td><?= $row3['CNAME'] ?></td>
<td><?= $row3['NUM_OF_HRS'] ?></td>
<td><?= $row3['NUM_OF_HRS'] * $row3['CHARGE_PER_HOUR'] ?></td>
<td><?= $row3['DATETIME'] ?></td>
<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#new-requests<?=$num_of_new?>">Review</button></td>
<div class="modal fade" id="new-requests<?=$num_of_new?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Incoming request</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<h5>Problem description</h5>
<p><?= $row3['DESCRIPTION'] ?></p>
<hr>
<h5>Send an offer</h5>
<form action="send_offer.php?rid=<?= $row3['RID'] ?>" method="post">
<input type="number" id="offer_amount" name="offer_amount" placeholder="Your offer in BAM..." style="margin-bottom: 0 !important;">
<button type="submit" class="btn btn-success">Send offer</button>
</form>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="rejected_request.php?id=<?=$row3['RID']?>&amount=<?=$row3['NUM_OF_HRS'] * $row3['CHARGE_PER_HOUR']?>"><button type="button" class="btn btn-danger">Reject</button></a>
</div>
</div>
</div>
</div>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php }
if ($num_of_new == 1) { ?>
<p style="padding: 1rem; ">You have no new requests.</p>
<?php } ?>
</div>
<?php } ?>
<!-- OFFERS SENT -->
<?php
$query2 = oci_parse($db, "SELECT H.STATUS, H.DATETIME, H.REQUEST
FROM REQUESTS R, REQUESTS_HISTORY H, WORK_OFFERS W
WHERE R.WORK_OFFER = W.WID
AND H.REQUEST = R.RID
AND STATUS = 0
AND W.PROFESSIONAL = {$aid}");
oci_execute($query2);
?>
<?php if ($row['ROLE'] == 1) {
$num_of_sent = 1; ?>
<h2 class="pt-5">Sent offers</h2>
<div class="shadow">
<?php if ($row2 = oci_fetch_assoc($query2)) {
$query3 = oci_parse($db, "SELECT R.*, H.REQUEST, H.DATETIME, H.STATUS, S.CATEGORY, C.CNAME, A.FNAME, A.LNAME, offer_amount
FROM REQUESTS R, REQUESTS_HISTORY H, WORK_OFFERS W, SERVICES S, ACCOUNTS A, CITIES C
WHERE R.WORK_OFFER = W.WID
AND W.CITY = C.CID
AND R.USER_ID = A.AID
AND H.REQUEST = R.RID
AND W.SERVICE = S.SID
AND W.PROFESSIONAL = {$aid}
ORDER BY H.DATETIME DESC");
oci_execute($query3);
?>
<table class="requests">
<tr>
<th>#</th>
<th>FROM</th>
<th>REQUESTED<br>SERVICE</th>
<th>IN</th>
<th>NUMBER OF<br>HOURS</th>
<th>ESTIMATED<br>PRICE</th>
<th>DATE<br>RECEIVED</th>
<th>STATUS</th>
</tr>
<?php while ($row3 = oci_fetch_assoc($query3)) {
if($row3['STATUS'] == 0 && $row3['OFFER_AMOUNT'] != -1) {
$request_id = $row3['REQUEST'];
$query4 = oci_parse($db, "SELECT user_id, R.*, H.REQUEST, H.DATETIME, H.STATUS, S.CATEGORY, A.FNAME, A.LNAME, A.PHONE_NUMBER, offer_amount
FROM REQUESTS R, REQUESTS_HISTORY H, WORK_OFFERS W, SERVICES S, ACCOUNTS A
WHERE R.WORK_OFFER = W.WID
AND R.USER_ID = A.AID
AND H.REQUEST = R.RID
AND W.SERVICE = S.SID
AND H.REQUEST = {$request_id}
AND H.STATUS IN (1, 2)
AND W.PROFESSIONAL = {$aid}");
oci_execute($query4);
if (!oci_fetch_assoc($query4)) { ?>
<tr>
<td style="border-right: 1px solid #7579e7;"><?php echo $num_of_sent;
$num_of_sent++; ?></td>
<td><a href="profile.php?id=<?=$row3['USER_ID']?>"><?= $row3['FNAME'] . ' ' . $row3['LNAME'] ?></a></td>
<td><?= $row3['CATEGORY'] ?></td>
<td><?= $row3['CNAME'] ?></td>
<td><?= $row3['NUM_OF_HRS'] ?></td>
<td><?= $row3['NUM_OF_HRS'] * $row3['CHARGE_PER_HOUR'] ?></td>
<td><?= $row3['DATETIME'] ?></td>
<td><button type="button" class="btn btn-warning" data-toggle="modal" data-target="#sent-offers<?=$num_of_sent?>">Pending</button></td>
<div class="modal fade" id="sent-offers<?=$num_of_sent?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Offer Pending</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>Your offer of <b><?=$row3['OFFER_AMOUNT']?></b>BAM has been sent. </p>
<hr>
<h5>Problem description</h5>
<p><?= $row3['DESCRIPTION'] ?></p>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</tr>
<?php } ?>
<?php } else if($row3['STATUS'] == 1) {
$pro_phone_number = oci_parse($db, "select phone_number, area_code from accounts where aid = {$row3['USER_ID']}");
oci_execute($pro_phone_number);
$row4 = oci_fetch_assoc($pro_phone_number);
?>
<tr>
<td style="border-right: 1px solid #7579e7;"><?php echo $num_of_sent;
$num_of_sent++; ?></td>
<td><a href="profile.php?id=<?=$row3['USER_ID']?>"><?= $row3['FNAME'] . ' ' . $row3['LNAME'] ?></a></td>
<td><?= $row3['CATEGORY'] ?></td>
<td><?= $row3['CNAME'] ?></td>
<td><?= $row3['NUM_OF_HRS'] ?></td>
<td><?= $row3['NUM_OF_HRS'] * $row3['CHARGE_PER_HOUR'] ?></td>
<td><?= $row3['DATETIME'] ?></td>
<td><button type="button" class="btn btn-success" data-toggle="modal" data-target="#accepted-offer<?=$num_of_sent?>">Offer Accepted</button></td>
<div class="modal fade" id="accepted-offer<?=$num_of_sent?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Offer: Accepted</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>Your offer of <b><?=$row3['OFFER_AMOUNT']?></b>BAM to solve their problem has been <span class="text-success font-italic font-weight-bold">accepted</span>.</p>
<p>Contact the client on +<?=$row4['AREA_CODE']?> <?=$row4['PHONE_NUMBER']?></p>
<hr>
<h5>Problem description:</h5>
<p><?= $row3['DESCRIPTION'] ?></p>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</tr>
<?php } else if($row3['STATUS'] == 2) { ?>
<tr>
<td style="border-right: 1px solid #7579e7;"><?php echo $num_of_sent;
$num_of_sent++; ?></td>
<td><a href="profile.php?id=<?=$row3['USER_ID']?>"><?= $row3['FNAME'] . ' ' . $row3['LNAME'] ?></a></td>
<td><?= $row3['CATEGORY'] ?></td>
<td><?= $row3['CNAME'] ?></td>
<td><?= $row3['NUM_OF_HRS'] ?></td>
<td><?= $row3['NUM_OF_HRS'] * $row3['CHARGE_PER_HOUR'] ?></td>
<td><?= $row3['DATETIME'] ?></td>
<td><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#rejected-offer<?=$num_of_sent?>">Offer Rejected</button></td>
<div class="modal fade" id="rejected-offer<?=$num_of_sent?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Offer: rejected</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>Your offer of <b><?=$row3['OFFER_AMOUNT']?></b>BAM to solve their problem has been <span class="text-danger font-italic font-weight-bold">rejected</span>.</p>
<hr>
<h5>Problem description:</h5>
<p><?= $row3['DESCRIPTION'] ?></p>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php }
if ($num_of_sent == 1) { ?>
<p style="padding: 1rem; ">You haven't sent any offers yet.</p>
<?php } ?>
</div>
<?php } ?>
<h2 class="pt-5">Sent Requests</h2>
<div class="shadow">
<?php
$query = oci_parse($db, "SELECT * FROM REQUESTS
WHERE USER_ID = {$_SESSION['user_id']}");
oci_execute($query);
$num_of_sent = 1;
if (oci_fetch($query)):
?>
<table class="sent-requests">
<tr>
<th>#</th>
<th>SERVICE</th>
<th>CITY</th>
<th>PROFESSIONAL</th>
<th>ESTIMATED PRICE</th>
<th>DATE</th>
<th>STATUS</th>
<th>Feedback</th>
</tr>
<?php
$query = oci_parse($db, "SELECT professional, OFFER_AMOUNT, CATEGORY, STATUS, DATETIME, R.DESCRIPTION, SERVICE, FNAME, LNAME, AREA_CODE, PHONE_NUMBER, CNAME, R.NUM_OF_HRS, R.CHARGE_PER_HOUR, R.RID
FROM REQUESTS R
JOIN WORK_OFFERS ON WORK_OFFER = WID
JOIN SERVICES ON SERVICE = SID
JOIN CITIES ON CITY = CID
JOIN REQUESTS_HISTORY ON REQUEST = RID
JOIN ACCOUNTS ON PROFESSIONAL = AID
WHERE USER_ID={$_SESSION['user_id']}
ORDER BY STATUS");
oci_execute($query);
?>
<?php while ($row = oci_fetch_assoc($query)) {
if ($row['STATUS'] == 0 && $row['OFFER_AMOUNT'] == -1) {
$queryN = oci_parse($db, "SELECT CATEGORY, STATUS, DATETIME, DESCRIPTION FROM REQUESTS
JOIN WORK_OFFERS ON WORK_OFFER = WID
JOIN SERVICES ON SERVICE = SID
JOIN REQUESTS_HISTORY ON REQUEST = RID
WHERE REQUEST = {$row['RID']}
AND SERVICE = {$row['SERVICE']}
AND STATUS IN (1, 2)
ORDER BY STATUS");
oci_execute($queryN);
$checkStatus = oci_fetch_assoc($queryN);
if (!$checkStatus) { ?>
<tr>
<td style="border-right: 1px solid #7579e7;"><?php echo $num_of_sent;
$num_of_sent++; ?></td>
<td><?= $row['CATEGORY'] ?></td>
<td><?= $row['CNAME'] ?></td>
<td><a href="profile.php?id=<?=$row['PROFESSIONAL']?>"><?= $row['FNAME'] . ' ' . $row['LNAME'] ?></a></td>
<td> <?= $row['CHARGE_PER_HOUR'] * $row['NUM_OF_HRS'] . 'BAM' ?></td>
<td><?= $row['DATETIME'] ?></td>
<td><button type="button" class="btn btn-warning" data-toggle="modal" data-target="#sent-requests<?=$num_of_sent?>">Pending</button></td>
<div class="modal fade" id="sent-requests<?=$num_of_sent?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Request pending</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>Professional will review your request as soon as possible and send you an offer.</p>
<hr>
<h5>Your problem description:</h5>
<p><?= $row['DESCRIPTION'] ?></p>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<td></td>
<?php }
}
else if($row['STATUS'] == 0 && $row['OFFER_AMOUNT'] != -1) {
$queryN = oci_parse($db, "SELECT CATEGORY, STATUS, DATETIME, DESCRIPTION FROM REQUESTS
JOIN WORK_OFFERS ON WORK_OFFER = WID
JOIN SERVICES ON SERVICE = SID
JOIN REQUESTS_HISTORY ON REQUEST = RID
WHERE REQUEST = {$row['RID']}
AND SERVICE = {$row['SERVICE']}
AND STATUS IN (1, 2)
ORDER BY STATUS");
oci_execute($queryN);
$checkStatus = oci_fetch_assoc($queryN);
if (!$checkStatus) { ?>
<tr>
<td style="border-right: 1px solid #7579e7;"><?php echo $num_of_sent;
$num_of_sent++; ?></td>
<td><?= $row['CATEGORY'] ?></td>
<td><?= $row['CNAME'] ?></td>
<td><a href="profile.php?id=<?=$row['PROFESSIONAL']?>"><?= $row['FNAME'] . ' ' . $row['LNAME'] ?></a></td>
<td> <?= $row['CHARGE_PER_HOUR'] * $row['NUM_OF_HRS'] . 'BAM' ?></td>
<td><?= $row['DATETIME'] ?></td>
<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#sent-requests<?=$num_of_sent?>">New offer!</button></td>
<div class="modal fade" id="sent-requests<?=$num_of_sent?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">New offer!</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>The seller has offered <b><?= $row['OFFER_AMOUNT'] ?></b>BAM to solve your problem.</p>
<hr>
<h5>Your problem description:</h5>
<p><?= $row['DESCRIPTION'] ?></p>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="rejected_request.php?id=<?=$row['RID']?>&amount=<?=$row['OFFER_AMOUNT']?>" class="btn btn-danger">Reject</a>
<a href="accepted_request.php?id=<?=$row['RID']?>&amount=<?=$row['OFFER_AMOUNT']?>" class="btn btn-success">Accept</a>
</div>
</div>
</div>
</div>
<td></td>
<?php }
}
else if ($row['STATUS'] == 1):
$pro_phone_number = oci_parse($db, "select phone_number, area_code from accounts where aid = {$row['PROFESSIONAL']}");
oci_execute($pro_phone_number);
$row4 = oci_fetch_assoc($pro_phone_number);
?>
<tr>
<td style="border-right: 1px solid #7579e7;"><?php echo $num_of_sent;
$num_of_sent++; ?></td>
<td><?= $row['CATEGORY'] ?></td>
<td><?= $row['CNAME'] ?></td>
<td><a href="profile.php?id=<?=$row['PROFESSIONAL']?>"><?= $row['FNAME'] . ' ' . $row['LNAME'] ?></a></td>
<td> <?= $row['CHARGE_PER_HOUR'] * $row['NUM_OF_HRS'] . 'BAM' ?></td>
<td><?= $row['DATETIME'] ?></td>
<td><button type="button" class="btn btn-success" data-toggle="modal" data-target="#job-success<?=$num_of_sent?>">Accepted</button></td>
<div class="modal fade" id="job-success<?=$num_of_sent?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Deal completed</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<h5>Congratulations!</h5>
<p>You have accepted the seller's offer of <b><?=$row['OFFER_AMOUNT']?></b>BAM to complete the job.</p>
<p>Contact the professional on +<?=$row4['AREA_CODE']?> <?=$row4['PHONE_NUMBER']?></p>
<hr>
<h5>Problem description:</h5>
<p><?= $row['DESCRIPTION'] ?></p>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
$checkRated = oci_parse($db, "SELECT R.JOB_RATING
FROM REQUESTS R
WHERE R.RID = {$row['RID']}
AND JOB_RATING IS NOT NULL");
oci_execute($checkRated);
$rated = oci_fetch_assoc($checkRated);
if (!$rated): ?>
<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#professional-rating<?=$num_of_sent?>">Rate</button></td>
<div class="modal fade" id="professional-rating<?=$num_of_sent?>">
<div class="modal-dialog modal-md modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Feedback!</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form action="rate_professional.php?rid=<?=$row['RID']?>" method="post">
<div class="modal-body">
<div>
<label for="rating">Rate the professional</label>
<select name="rating" id="rating" class="ml-3" required>
<option disabled selected>1-5</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<textarea name="comment" placeholder="Leave a review (optional)" style="margin-bottom: 0"></textarea>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success">Rate</button>
</div>
</form>
</div>
</div>
</div>
<?php else: ?>
<td><i>Completed</i></td>
<?php endif; ?>
</tr>
<?php elseif ($row['STATUS'] == 2): ?>
<tr>
<td style="border-right: 1px solid #7579e7;"><?php echo $num_of_sent;
$num_of_sent++; ?></td>
<td><?= $row['CATEGORY'] ?></td>
<td><?= $row['CNAME'] ?></td>
<td><a href="profile.php?id=<?=$row['PROFESSIONAL']?>"><?= $row['FNAME'] . ' ' . $row['LNAME'] ?></a></td>
<td> <?= $row['CHARGE_PER_HOUR'] * $row['NUM_OF_HRS'] . 'BAM' ?></td>
<td><?= $row['DATETIME'] ?></td>
<td><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#job-fail<?=$num_of_sent?>">Rejected</button></td>
<div class="modal fade" id="job-fail<?=$num_of_sent?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Job canceled</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>The job has been canceled.</p>
<hr>
<h5>Your problem description:</h5>
<p><?= $row['DESCRIPTION'] ?></p>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<td></td>
</tr>
<?php endif; ?>
<?php } ?>
</table>
</div>
<?php else: ?>
<p style="padding: 1rem;">You haven't sent any requests.</p>
<?php endif; ?>
</main>
<?php include('includes/footer.php'); ?>
</div>
</body>
</html>