-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch-event.php
207 lines (195 loc) · 9.07 KB
/
search-event.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
<?php include 'inc/pre.php' ?>
<?php include 'inc/header.php' ?>
<?php $navTitle = "Search Events"; ?>
<?php include 'inc/nav.php' ?>
<?php
include 'inc/country.php';
if (!isset($_SESSION["SESSION_EMAIL"])) {
header("Location: index.php");
}
$msg = "";
$search_name = " ";
$search_zip = " ";
$sname = "";
$sorg = "";
$szip = "";
$scity = "";
$scountry = "";
$sstartDate = "";
$sendDate = "";
try {
$res_events = select_events($conn, $sname, $sorg, $szip, $scity, $scountry, $sstartDate, $sendDate);
} catch (\Throwable $th) {
$msg = "<div class='alert alert-danger'>" . $th->getMessage() . "</div>";
}
if (isset($_POST['submit'])) {
$sname = mysqli_real_escape_string($conn, $_POST['event']);
$sorg = mysqli_real_escape_string($conn, $_POST['organization']);
$szip = mysqli_real_escape_string($conn, $_POST['zip']);
$scity = mysqli_real_escape_string($conn, $_POST['city']);
$scountry = mysqli_real_escape_string($conn, $_POST['country']);
$sstartDate = mysqli_real_escape_string($conn, $_POST['startDate']);
$sendDate = mysqli_real_escape_string($conn, $_POST['endDate']);
try {
$res_events = select_events($conn, $sname, $sorg, $szip, $scity, $scountry, $sstartDate, $sendDate);
} catch (\Throwable $th) {
$msg = "<div class='alert alert-danger'>" . $th->getMessage() . "</div>";
}
}
?>
<section class="container h-100">
<?php include 'inc/top.php' ?>
<div class="main-container pt-5">
<?= $msg ?>
<div class="border border-1 border-solid pt-4 pb-4 position-relative">
<button class="btn btn-primary position-absolute" data-bs-toggle="modal" data-bs-target="#addFilterModal"
style="top: -20px; left: 10px">Filters</button>
<div class="mt-2 ms-5">
<?php if ($sname != '') { ?>Name of Event: <?= $sname ?> <?php } ?>
<?php if ($szip != '') { ?>Zip code: <?= $szip ?> <?php } ?>
<?php if ($sorg != '') { ?>Organization: <?= $sorg ?> <?php } ?>
<?php if ($scity != '') { ?>City: <?= $scity ?> <?php } ?>
<?php if ($scountry != '') { ?>Country: <?= $scountry ?> <?php } ?>
<?php if ($sstartDate != '') { ?>Start Date: <?= $sstartDate ?> <?php } ?>
<?php if ($sendDate != '') { ?>End Date: <?= $sendDate ?> <?php } ?>
</div>
<div class="mt-3">
<?php $lop = 0;
if ($res_events->num_rows > 0) {
while ($row = $res_events->fetch_assoc()) {
$lop = $lop + 1; ?>
<div class="member-container <?= $lop % 2 == 1 ? "bg-primary text-white" : ""; ?> ">
<div class="member-image cursor-pointer" onclick="gotoMemberDetail(<?= $row['eventnr'] ?>)"><img src="assets/images/events.png" alt=""></div>
<div class="member-info">
<div>
<?= $row["fullname"] ?>-
</div>
<div>
<?= $row["zip"] ?>,
</div>
<div>
<?= $row["city"] ?>,
</div>
<div>
<?= strtoupper($row["country"]) ?>,
</div>
<div>
<?= $row["cellphone"] ?>,
</div>
<div>
<?= $row["begindate"] ?>,
</div>
<div>
<?= $row["enddate"] ?>
</div>
</div>
</div>
<?php }
} else { ?>
<?php } ?>
</div>
</div>
<div class="modal fade" id="addFilterModal" tabindex="-1" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<form action="" method="post">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Filters</h5>
</div>
<div class="modal-body">
<div class="row px-3">
<div class="col-sm-4">
</div>
<div class="col-sm-8">
<input type="text" class="form-control mt-3" name="event" placeholder="Event Name">
</div>
</div>
<div class="row px-3">
<div class="col-sm-4"></div>
<div class="col-sm-8">
<input type="text" class="form-control mt-3" name="organization"
placeholder="Organization">
</div>
</div>
<div class="row px-3">
<div class="col-sm-4">
<input type="text" class="form-control mt-3" name="zip" placeholder="Zip">
</div>
<div class="col-sm-8">
<input type="text" class="form-control mt-3" name="city" placeholder="City">
</div>
</div>
<div class="row px-3">
<div class="col-sm-4"></div>
<div class="col-sm-8">
<select type="text" class="form-control mt-3" name="country"
onchange="handle_changeCountry(event)" style="padding: 12px;">
<option value="" disabled selected>Select Country</option>
<?php foreach ($countryNames as $countryName) { ?>
<option value="<?= $countryName ?>">
<?= strtoupper(str_replace("_", " ", $countryName)) ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div class="row px-3">
<div class="col-sm-4">
<input type="text" id="from" class="form-control mt-3" name="startDate"
placeholder="Start Date">
</div>
<div class="col-sm-4">
<input type="text" id="to" class="form-control mt-3" name="endDate"
placeholder="End Date">
</div>
</div>
</div>
<div class="modal-footer pt-5">
<button type="button" class="btn btn-default px-5" onclick="clearHandle()">Clear</button>
<button type="submit" name="submit" class="btn btn-default px-5">Search</button>
</div>
</div>
</form>
</div>
</div>
</div>
<script>
function gotoMemberDetail(eventnr) {
window.location.href = '<?= DOMAIN . "/event-detail.php?eventnr=" ?>' + eventnr;
}
</script>
</section>
<script>
$(function () {
var dateFormat = "mm/dd/yy",
from = $("#from")
.datepicker({
defaultDate: "+1w",
changeMonth: true,
})
.on("change", function () {
to.datepicker("option", "minDate", getDate(this));
}),
to = $("#to").datepicker({
defaultDate: "+1w",
changeMonth: true,
})
.on("change", function () {
from.datepicker("option", "maxDate", getDate(this));
});
function getDate(element) {
var date;
try {
date = $.datepicker.parseDate(dateFormat, element.value);
} catch (error) {
date = null;
}
return date;
}
});
function clearHandle() {
window.location.href = "<?= DOMAIN ?>/search-event.php"
}
</script>
<?php include 'inc/footer.php' ?>