-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch_temp.php
308 lines (258 loc) · 11.5 KB
/
search_temp.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
<?php
session_start();
require_once('connect.php');
?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>SB Admin 2 - Bootstrap Admin Theme</title>
<!-- Bootstrap Core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- MetisMenu CSS -->
<link href="vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
<!-- DataTables CSS -->
<link href="vendor/datatables-plugins/dataTables.bootstrap.css" rel="stylesheet">
<!-- DataTables Responsive CSS -->
<link href="vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="dist/css/sb-admin-2.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Bubbler+One|Tangerine" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
#res1{
width:80%;
background-color:#ffffff;
margin-left:30%;
}
#res{
padding:5px;
float:left;
width:15%;
height:35%;
list-style-type: none;
}
#navi{
background-color: #000000;
overflow:hidden;
list-style-type: none;
color:#ffffff;
margin:0;
padding: 0;
}
#navi1{
float:right;
padding: 15px;
}
#navi2{
color:#ffffff;
display:block;
text-decoration: none;
}
#navi1:hover{
background-color: #cc0000;
}
</style>
</head>
<body>
<?PHP // Search.php
$results = 0;
$results1=0;
$sql_query = 0;
$first_pos = 0;
?>
<div id="#res1">
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
<input name="search_term" list="search_term" style="margin-left:25%;width:30%;height:5%;margin-top:8%;padding:5px;" >
<datalist id="search_term">
<option value="Ministry">
<option value="Office Of Union Minister">
<option value="Office Of Minister Of State">
<option value="Office Of Secretary/CSI">
<option value="Additional Secretary">
<option value="Joint Secretary(Admin)">
<option value="Administration Wing">
<option value="Integrated Finance Division">
<option value="PI Wing">
<option value="Infrastructure and Project Monitoring Division">
<option value="MPLADS">
<option value="Twenty Point Programme">
</datalist>
<input name="search_button" type="submit" value="Search" style="height:5%;">
</form>
<!--<input name="search_term" type="text" style="margin-left:25%;width:30%;height:5%;margin-top:8%;padding:5px;" >
<input name="search_button" type="submit" value="Search" style="height:5%;"> -->
<?php
$sql1='SELECT `Name` , `office_name` , minister_info.Minister_ID , `designation_name` FROM `minister_info` INNER JOIN `designation` on minister_info.Minister_ID = designation.Minister_ID INNER JOIN `ministryoffice` on designation.Office_ID = ministryoffice.office_id AND minister_info.Minister_ID in ( SELECT `guest_id` from `guests` where guest_id=minister_info.Minister_id and event_id= 1001);';
$sql_query1 = $connect->query($sql1);
$results1 =$sql_query1->num_rows;
if($results1!=0)
{
echo '<center>';
echo '<div class="row">';
echo '<div class="col-lg-6" style="margin-left:25%;padding:5px;">';
echo '<div class="panel panel-default">';
echo '<div class="panel-heading">';
echo '<h4><b>List Of Invitees</b></h4>';
echo '</div>';
echo '<div class="panel-body">';
echo '<div class="table-responsive">';
echo '<table class="table table-striped table-bordered table-hover">';
echo '<tr>';
echo '<th>Sr_no</th>';
echo '<th>Minister_ID</th>';
echo '<th>Minister_Name</th>';
echo '<th>Designation</th>';
echo '<th>Office_Name</th>';
echo '<th>Send_Updates</th>';
echo '</tr>';
$i = 1;
echo '<form style="padding-left:20px;" method="post" action="">';
while($row1 = $sql_query1->fetch_assoc())
{
echo "<tr>";
echo "<td>",$i,"</td>";
echo "<td>",$row1["Minister_ID"],"</td>";
echo "<td>",$row1["Name"],"</td>";
echo "<td>",$row1["designation_name"],"</td>";
echo "<td>",$row1["office_name"],"</td>";
echo '<td><input type="checkbox" name="id1[]" value="'.$row1["Minister_ID"].'"/></td>';
echo "</tr>";
$i = $i + 1;
}
//<button type="button" class="btn btn-default">Default</button>
echo '</table>';
//echo '<br>';
echo ' <button type="button" class="btn btn-default">Send-Update</button>';
echo '</form>';
echo'</div>';
// <!-- /.table-responsive -->
echo '</div>';
//<!-- /.panel-body -->
echo '</div>';
//<!-- /.panel -->
echo '</div>';
echo '</center>';
}
if(isset($_POST['search_button']))
{
$search_term = $_POST['search_term'];
if(!isset($first_pos))
{
$first_pos = "0";
}
//initializing mysqli Quary
$select='SELECT `office_name` FROM `ministryoffice` WHERE MATCH(`office_name`) AGAINST(\''.$search_term.'\');';
//echo $select;
//echo "\n";
$sql_query = $connect->query($select);
//additional check. Insurance method to re-search the database again in case of too many matches (too many matches cause returning of 0 results)
if(!$sql_query)
{
// $results =$sql_query->num_rows;
$sql = 'SELECT `Name` , `office_name` , minister_info.Minister_ID , `designation_name` FROM `minister_info` INNER JOIN `designation` on minister_info.Minister_ID = designation.Minister_ID INNER JOIN `ministryoffice` on designation.Office_ID= ministryoffice.office_id WHERE MATCH(`office_name`) AGAINST(\''.$search_term.'\') AND minister_info.Minister_ID not in ( SELECT `guest_id` from `guests` where guest_id=minister_info.Minister_id and event_id= 1001) ;';
//echo $sql;
echo "\n";
$sql_result_query = $connect->query($sql);
}
else
{
try
{
$sql = 'SELECT `Name` , `office_name` , minister_info.Minister_ID , `designation_name` FROM `minister_info` INNER JOIN `designation` on minister_info.Minister_ID = designation.Minister_ID INNER JOIN `ministryoffice` on designation.Office_ID = ministryoffice.office_id WHERE `office_name` = \''.$search_term.'\' AND minister_info.Minister_ID not in ( SELECT `guest_id` from `guests` where guest_id=minister_info.Minister_id and event_id= 1001);';
//echo $sql;
$sql_query = $connect->query($sql);
$results =$sql_query->num_rows;
}
catch(Exception $e)
{
;
}
}
//calculating the search time
}
if($results != 0)
{
echo '<center>';
echo '<div class="row">';
echo '<div class="col-lg-6" style="margin-left:25%;padding:5px;">';
echo '<div class="panel panel-default">';
echo '<div class="panel-heading">';
?>
<h4><b>List Of Officers in <?PHP echo $search_term; ?></b></h4>
<?php
echo '</div>';
echo '<div class="panel-body">';
echo '<div class="table-responsive">';
echo '<table class="table table-striped table-bordered table-hover">';
echo '<tr>';
echo '<th>Sr_no</th>';
echo '<th>Minister_ID</th>';
echo '<th>Minister_Name</th>';
echo '<th>Designation</th>';
echo '<th>Office_Name</th>';
echo '<th>Invitee</th>';
echo '</tr>';
$i = 1;
//echo '<script>window.alert("'.$resultCheck.' row(s) fetched");</script>';
echo '<form style="padding-left:20px;" method="post" action="invitee.php">';
while($row = $sql_query->fetch_assoc())
{
echo "<tr>";
echo "<td>",$i,"</td>";
echo "<td>",$row["Minister_ID"],"</td>";
echo "<td>",$row["Name"],"</td>";
echo "<td>",$row["designation_name"],"</td>";
echo "<td>",$row["office_name"],"</td>";
echo '<td><input type="checkbox" name="id[]" value="'.$row["Minister_ID"].'"/></td>';
echo "</tr>";
$i = $i + 1;
}
echo '</table>';
echo '<button type="button" class="btn btn-default">Send Invitation</button>';
echo '</form>';
echo'</div>';
// <!-- /.table-responsive -->
echo '</div>';
//<!-- /.panel-body -->
echo '</div>';
//<!-- /.panel -->
echo '</div>';
echo '</center>';
}
//if nothing is found then displays a form and a message that there are nor results for the specified term
elseif($sql_query)
{
?>
<h1 style="text-align:center; font-family:'Tangerine', cursive;margin-top:4%;">Oops!!! There are no officers in <?PHP echo $search_term; ?><br>You might already sent the invitation!!</h1>
</div>
<?PHP
}
?>
<!-- jQuery -->
<script src="/vendor/jquery/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="/vendor/bootstrap/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="/vendor/metisMenu/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="/vendor/datatables/js/jquery.dataTables.min.js"></script>
<script src="/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
<script src="/vendor/datatables-responsive/dataTables.responsive.js"></script>
<!-- Custom Theme JavaScript -->
<script src="/dist/js/sb-admin-2.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->
<script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true
});
});
</script>
</body>
</html>