-
Notifications
You must be signed in to change notification settings - Fork 1
/
previous.php
71 lines (63 loc) · 2.72 KB
/
previous.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
<?php
// $conn = mysqli_connect("localhost", "root", "", "quickfix_database", "3310");
// require_once('connect.php');
require_once('calendar.php');
require_once('classes.php');
$tradesman_id = $_GET['name'];
$concat = $_GET['current_month'];
$current_month = substr($concat, 4);
$current_month = intval($current_month);
$current_year = substr($concat, 0, 4);
$current_year = intval($current_year);
// echo "I try to print: ".$concat." month: ".$current_month." year: ".$current_year." **** ";
$month = date($current_year . "-" . $current_month . "-05");
$calendar = new Calendar($month);
if ($current_month == 01) {
$current_year = $current_year - 1;
$calendar->setActive_year($current_year);
}
if ($current_month == 01) {
$current_month = 13;
}
$current_month = $current_month - 1;
$calendar->setActive_month($current_month);
$htmlContent = "";
?>
<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">
You have scheduled these tradesman 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';";
$result = QueryHandler::query($sql);
if (!$result) {
die('QUERY FAIL!');
}
$count1 = 0;
while ($row = mysqli_fetch_assoc($result)) {
$customerObject = new Customer($row['customer_id']);
if (date('m', strtotime($row['date'])) == $current_month && date('Y', strtotime($row['date'])) == $current_year) {
$count1 = $count1 + 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>';
}
}
if ($count1 == 0) {
echo '<script>document.getElementById("alertBox").style.display="block"; </script>';
echo '<script>document.getElementById("scheuledList").style.display="none"; </script>';
} else {
echo '<script>document.getElementById("alertBox").style.display="none";</script>';
echo '<script>document.getElementById("scheuledList").style.display="block";</script>';
}
?>
</ul>
</div>
</div>
<div class="col-md-12 col-lg-6" id="calendar_box">
<?php echo $calendar ?>
</div>