-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobsearcU.php
237 lines (175 loc) · 9.02 KB
/
obsearcU.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
<?php include('partials/headerSection.php');
ob_start();
?>
<div class="main">
<?php include('partials/sideMenuU.php')?>
<div class="mainContent">
<div class="topSection flex">
<div class="dashboardTitle">
<h1>Search Page</h1>
</div>
<div class="userBox flex">
<a href="index.php">
<div class="adminImage">
<img src="./assets/images/pp.jpg" alt="Admin Image">
</div>
</a>
<div class="userName">
<span>Administrator</span>
<small><?php
if(isset($_SESSION['firstName'])){
echo $_SESSION['firstName'];
}
?></small>
</div>
<i class="uil uil-bell icon"></i>
</div>
</div>
<div class="body">
<div class="overViewDiv">
<div class="intro flex" >
<h3 class="title">Fill the form below!</h3>
<div class="buttons flex" style="gap: 10px;">
<div class="addBtn">
<a href="addCaseU.php">
<span>Add Case</span>
</a>
</div>
</div>
</div>
</div>
<div class="mainItems">
<div class="addCaseContainer flex">
<div class="rowsDiv">
<form action ="" method ="POST">
<div class="row">
<label for="icnType">Incident Type</label>
<input type="text" name="sType" id="icnType" >
</div>
<div class="row">
<label for="status">Incident Status</label>
<input type="text" name="sStatus" id="status" >
</div>
<div class="row">
<label for="id">Incident Date</label>
<input type="date" name="sDate" id="id" >
</div>
</div>
<div class="rowsDiv">
<div class="row">
<label for="id">From Date</label>
<input type="date" name="fDate" id="id" >
</div>
<div class="row">
<label for="id">To Date</label>
<input type="date" name="tDate" id="id" >
</div>
<div class="row">
<label for="location">Incident Location</label>
<input type="text" name="sLocation" id="location" >
</div>
<div class="row">
<input type="submit" name="submit" id="submitBtn" value="Search">
</div>
</div>
</div>
</form>
<table>
<tr class="tableHeader">
<th>OB No.</th>
<th>Incident Type</th>
<th>Time(Reported)</th>
<th>Status</th>
<th>Category</th>
<th>Image(s)</th>
<th>Edit</th>
<th>Details</th>
<th>Follow</th>
</tr>
<?php
if(isset($_POST['submit'])){
$sDate = $_POST['sDate'];
$sType = $_POST['sType'];
$sStatus = $_POST['sStatus'];
$sLocation = $_POST['sLocation'];
$fDate = $_POST['fDate'];
$frDate = strtotime($fDate);
$frDate = date('d/m/Y', $frDate);
$tDate = $_POST['tDate'];
$toDate = strtotime($tDate);
$toDate = date('d/m/Y', $toDate);
if($sType != "" || $sStatus != "" || $sDate != "" || $sLocation != ""
|| $fDate !="" || $tDate != ""){
$sql = "SELECT * FROM cases_table WHERE incident_type = '$sType' OR
case_status = '$sStatus' OR incident_date = '$sDate'
OR location = '$sLocation' OR incident_date between $frDate and $toDate";
$res = mysqli_query($conn, $sql);
if($res == TRUE){
$count = mysqli_num_rows($res);
if($count>0){
while($row = mysqli_fetch_assoc($res)){
$id = $row['id'];
$incidentType = $row['incident_type'];
$incidentDate = $row['incident_date'];
$incidentTime = $row['incident_time'];
$caseStatus = $row['case_status'];
$caseCategory = $row['case_category'];
if($caseStatus=='Open'){
?>
<tr class="tableData">
<td><?php echo $incidentDate;?>/<?php echo $id;?></td>
<td><?php echo $incidentType;?></td>
<td><?php echo $incidentTime;?></td>
<td><?php echo $caseStatus;?></td>
<td><?php echo $caseCategory?></td>
<td><i class="uil uil-paperclip icon" style="color: blue;"></i></td>
<td><a href="<?php echo SITEURL?>updateCaseU.php?id= <?php echo $id;?>"><i class="uil uil-edit icon editIcon"></i></a></td>
<td><a href="<?php echo SITEURL?>detailsU.php?id= <?php echo $id;?>"><i class="uil uil-file-info-alt icon detailsIcon"></i></a></td>
<td><a href="<?php echo SITEURL?>followingU.php?id= <?php echo $id;?>"><i class="uil uil-arrow-from-right icon followIcon"></i></a></td>
</tr>
<?php
$_SESSION['res'] = '<span class="success">Search Results</span>';
}
else{
?>
<tr class="tableData">
<td><?php echo $incidentDate;?>/<?php echo $id;?></td>
<td><?php echo $incidentType;?></td>
<td><?php echo $incidentTime;?></td>
<td><?php echo $caseStatus;?></td>
<td><?php echo $caseCategory?></td>
<td><i class="uil uil-paperclip icon" style="color: blue;"></i></td>
<td><a href="<?php echo SITEURL?>updateCaseU.php?id= <?php echo $id;?>"><i class="uil uil-edit icon editIcon"></i></a></td>
<td><a href="<?php echo SITEURL?>detailsU.php?id= <?php echo $id;?>"><i class="uil uil-file-info-alt icon detailsIcon"></i></a></td>
<td>
<i class="uil uil-check-circle icon tickIcon"></i>
</td>
<?php
}
}
}
else{
?>
<tr>
<td colspan="9"><span class="fail" style="textalign:center; color: red; font-size=25px; margin: 2rem 1rem;">No results in the database, change your search field!</span></td>
</tr>
<?php
}
}
else{
die("Failed to connect!");
}
}
else{
$_SESSION['Search'] = '<span class="fail"> Enter any valid search!</span>';
header('location:' .SITEURL. 'obsearcU.php');
exit();
}
}
?>
</table>
</div>
</div>
</div>
</div>
<?php include('partials/footer.php')?>