forked from samuelgilbertuk/absencetrackingsystem
/
managerViewApprovedRequests.php
142 lines (124 loc) · 4.98 KB
/
managerViewApprovedRequests.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
<?php
include 'sessionmanagement.php';
if (!$isManager) {
header('Location: index.php');
exit();
}
if (isset($_POST["submit"]))
{
ClearStatus();
$statusMessage = "";
$inputIsValid = true;
$startDate = $_POST["startDate"];
$endDate = $_POST["endDate"];
if (!isValidDate($startDate)) {
$statusMessage.="Start Date is not a valid Date.</br>";
$inputIsValid = false;
}
if (!isValidDate($endDate)) {
$statusMessage.="Finish Date is not a valid Date.</br>";
$inputIsValid = false;
}
if (strtotime($endDate) < strtotime($startDate))
{
$statusMessage.="End Date is before Start Date.</br>";
$inputIsValid = false;
}
if ($inputIsValid == false)
{
GenerateStatus(false, $statusMessage);
}
}
function DisplaySearchTableBody($startDate,$endDate)
{
date_default_timezone_set('UTC');
$startDate = $_POST["startDate"];
$startDateTime = strtotime($startDate);
$endDate =
$endDateTime = strtotime($endDate);
$bookings = RetrieveApprovedAbsenceBookings();
if ($bookings <> NULL)
{
foreach ($bookings as $booking)
{
$bookingStartTime = strtotime($booking[APPR_ABS_START_DATE]);
$bookingEndTime = strtotime($booking[APPR_ABS_START_DATE]);
if ( ($bookingStartTime >= $startDateTime) AND
($bookingEndTime <= $endDateTime))
{
$employee = RetrieveEmployeeByID($booking[APPR_ABS_EMPLOYEE_ID]);
$absenceType = RetrieveAbsenceTypeByID($booking[APPR_ABS_ABS_TYPE_ID]);
echo '<tr>';
echo '<td>'.$employee[EMP_NAME].'</td>';
echo '<td>'.$booking[APPR_ABS_START_DATE].'</td>';
echo '<td>'.$booking[APPR_ABS_END_DATE].'</td>';
echo '<td>'.$absenceType[ABS_TYPE_NAME].'</td>';
echo '</tr>';
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>View Approved Absence Bookings</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
</head>
<body>
<?php include 'navbar.php'; ?>
<form method="post" class="signUp">
<div class="row">
<div class="col-md-4 col-md-offset-4 text-center">
<h1>View Approved Absence Bookings</h1>
<div class="input-group" for="startDate">
<span class="input-group-addon">Search Period Start Date
<span class="glyphicon glyphicon-calendar"></span>
</span>
<input type="date" class="form-control" name="startDate"
id="startDate" placeholder="Start Date">
</div>
<div class="input-group" for="endDate">
<span class="input-group-addon">Search Period Finish Date
<span class="glyphicon glyphicon-calendar"></span>
</span>
<input type="date" class="form-control" name="endDate"
id="endDate" placeholder="End Date">
</div>
<br/>
<input class="btn btn-success btn-block" type="submit"
name="submit" id="submit" value="Display Bookings"/>
</div>
</div>
</form>
<?php if (isset($_POST["submit"])){?>
<div id="table">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<br/><br/><br/>
<h1>Search Results</h1>
<form method="post">
<table class="table table-bordered table-hover ">
<thead>
<tr>
<th>Name</th>
<th>Start Date</th>
<th>End Date</th>
<th>Absence Type</th>
</tr>
</thead>
<tbody>
<?php DisplaySearchTableBody($_POST["startDate"],
$_POST["endDate"]); ?>
</tbody>
</table>
</form>
</div> <?php }?>
</body>
</html>