-
Notifications
You must be signed in to change notification settings - Fork 0
/
member-detail.php
430 lines (396 loc) · 18.6 KB
/
member-detail.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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<?php include 'inc/pre.php' ?>
<?php $navTitle = "Member Details"; ?>
<?php include 'inc/nav.php' ?>
<?php
if (!isset($_SESSION["SESSION_EMAIL"])) {
header("Location: index.php");
}
$msg = '';
if ($_GET["usernr"]) {
$m_usernr = $_GET['usernr'];
} else {
header("Location: search-members.php");
}
try {
$res = select_userById($conn, $m_usernr);
$e_user = mysqli_fetch_assoc($res);
$activeRes = mysqli_query($conn, "SELECT * FROM tb_users WHERE usernr = '{$m_usernr}'");
$m_active = mysqli_fetch_assoc($activeRes)['active'];
} catch (\Throwable $th) {
$msg = "<div class='alert alert-danger'>{$th->getMessage()}</div>";
}
try {
$res_connect = select_connectMembers($conn, $_SESSION['usernr'], $m_usernr);
$conn_stt = $res_connect->num_rows == 0 ? false : true;
if ($conn_stt) {
$sql_stt = mysqli_fetch_assoc($res_connect)['status'] == 1 ? true : false;
}
} catch (\Throwable $th) {
//throw $th;
}
if (isset($_POST["deactive"])) {
$res_updateActive = update_activeMember($conn, $m_usernr, 0);
try {
$res = select_userById($conn, $m_usernr);
$e_user = mysqli_fetch_assoc($res);
$activeRes = mysqli_query($conn, "SELECT * FROM tb_users WHERE usernr = '{$m_usernr}'");
$m_active = mysqli_fetch_assoc($activeRes)['active'];
} catch (\Throwable $th) {
$msg = "<div class='alert alert-danger'>{$th->getMessage()}</div>";
}
}
if (isset($_POST["active"])) {
$res_updateActive = update_activeMember($conn, $m_usernr, 1);
try {
$res = select_userById($conn, $m_usernr);
$e_user = mysqli_fetch_assoc($res);
$activeRes = mysqli_query($conn, "SELECT * FROM tb_users WHERE usernr = '{$m_usernr}'");
$m_active = mysqli_fetch_assoc($activeRes)['active'];
} catch (\Throwable $th) {
$msg = "<div class='alert alert-danger'>{$th->getMessage()}</div>";
}
}
if (isset($_POST["memberDisconnect"]) || isset($_POST['memberConnectRemove'])) {
delete_connectMembers($conn, $_SESSION['usernr'], $m_usernr);
$res_connect = select_connectMembers($conn, $_SESSION['usernr'], $m_usernr);
$conn_stt = $res_connect->num_rows == 0 ? false : true;
if ($conn_stt) {
$sql_stt = mysqli_fetch_assoc($res_connect)['status'] == 1 ? true : false;
}
}
if (isset($_POST["memberConnect"])) {
// add connect to the tb_connect
insert_connectMember($conn, $_SESSION['usernr'], $m_usernr, 10, 0);
// get connect status
$res_connect = select_connectMembers($conn, $_SESSION['usernr'], $m_usernr);
$conn_stt = $res_connect->num_rows == 0 ? false : true;
if ($conn_stt) {
$sql_stt = mysqli_fetch_assoc($res_connect)['status'] == 1 ? true : false;
}
send_email($conn, $e_user['email'], 0, 'connect', $_SESSION, '', $siteLanguage);
}
if (isset($_POST["member_send_email"])) {
$subject = isset($_POST['subject']) ? $_POST['subject'] : '';
$content = isset($_POST['content']) ? $_POST['content'] : '';
send_email($conn, $e_user['email'], $_SESSION['usernr'], 'member_send_email', $subject, $content, $siteLanguage);
}
if (isset($_POST["send_whatsapp"])) {
// $username ='491738195613'; //Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
// $password = 'enter here your encrypted password';
// $w = new WhatsProt($username, 0, '', true); //Name your application by replacing “WhatsApp Messaging”
// $w->connect();
// // $w->loginWithPassword($password);
// $receiver = '381612652757';
// $message = 'hi';
// $w->sendMessage($receiver,$message ); // Send Message
// $w->pollMessage();
// echo 'Message Sent Successfully';
// $apiUrl = 'https://api.gupshup.io/sm/api/v1/msg';
// $apiKey = 'LWspxFrVd5k3';
// $requestBody = [
// 'channel' => 'whatsapp',
// 'source' => '491738195613',
// 'destination' => '381612652757',
// 'src.name' => 'DemoApp',
// 'message' => [
// 'type' => 'text',
// 'text' => 'Hi John, how are you?',
// ],
// ];
// $headers = [
// 'Content-Type: application/x-www-form-urlencoded',
// 'apikey: ' . $apiKey,
// ];
// // Construct the request options
// $options = [
// 'http' => [
// 'method' => 'POST',
// 'header' => implode("\r\n", $headers),
// 'content' => http_build_query(['message' => $requestBody]),
// ],
// ];
// // Create a stream context
// $context = stream_context_create($options);
// // Make the POST request
// $response = file_get_contents($apiUrl, false, $context);
// // Check for errors
// if ($response === false) {
// die('Error making POST request');
// }
// // Process the response data
// $data = json_decode($response, true);
}
?>
<?php include 'inc/header.php' ?>
<section class="container h-100">
<?php include 'inc/top.php' ?>
<div class="main-container pt-5">
<?= $msg ?>
<div class="map-container">
<div class="border border-1 border-solid map-content" id="map"></div>
<div class="member-detail pt-0 pb-3 text-white text-center">
<div>
<h2 class="mb-0 pt-3">Church</h2>
<hr>
</div>
<div>
<h3>
<?= $e_user['fullname'] ?>
</h3>
<h3 class="fst-italic">Jesus Church</h3>
<h6>
<?= $e_user['street'] ?>
</h6>
<h6>
<?= $e_user['zip'] ?>,
<?= $e_user['city'] ?>
</h6>
<h6>
<?= strtoupper($e_user['country']) ?>
</h6>
<h6>
<?= $e_user['cellphone'] ?>
</h6>
<h6>
<?= $e_user['telephone'] ?>
</h6>
</div>
<hr>
<?php if ($e_user['usernr'] != $_SESSION['usernr']) { ?>
<button class="btn btn-default mx-auto w-75 mt-1 mb-1" data-bs-toggle="modal" data-bs-target="#emailModal">
<div class="d-flex justify-content-center">
<div>
<img src="<?= DOMAIN ?>/assets/images/email.png" alt="">
</div>
<div class="d-flex justify-content-center align-items-center">
Email
</div>
</div>
</button>
<?php } ?>
<?php if ($e_user['whatsappcode']) { ?>
<button class="btn btn-default mx-auto w-75 mt-1 mb-1" data-bs-toggle="modal" data-bs-target="#whatsappModal">
<div class="d-flex justify-content-center">
<div>
<img src="<?= DOMAIN ?>/assets/images/wapp.png" alt="">
</div>
<div class="d-flex justify-content-center align-items-center">
Whatsapp
</div>
</div>
</button>
<?php } ?>
<button class="btn btn-default mx-auto w-75 mt-1 mb-1" onclick="gotoEventPage()">
<div class="d-flex justify-content-center">
<div>
<img src="<?= DOMAIN ?>/assets/images/events.png" alt="">
</div>
<div class="d-flex justify-content-center align-items-center">
Events
</div>
</div>
</button>
<?php if ($e_user['usernr'] != $_SESSION['usernr']) { ?>
<button class="btn btn-default mx-auto w-75 mt-1 mb-1" data-bs-toggle="modal" data-bs-target="#allowModal">
<?php if ($conn_stt && $sql_stt) { ?>
<div class="d-flex justify-content-center">
<div>
<img src="<?= DOMAIN ?>/assets/images/connection.png" alt="">
</div>
<div class="d-flex justify-content-center align-items-center">
Remove
</div>
</div>
<?php } else if ($conn_stt && !$sql_stt) { ?>
<div class="d-flex justify-content-center">
<div>
<img src="<?= DOMAIN ?>/assets/images/connectionOne.png" alt="">
</div>
<div class="d-flex justify-content-center align-items-center">
Remove
</div>
</div>
<?php } else { ?>
<div class="d-flex justify-content-center">
<div>
<img src="<?= DOMAIN ?>/assets/images/connection.png" alt="">
</div>
<div class="d-flex justify-content-center align-items-center">
Connect
</div>
</div>
<?php } ?>
</button>
<?php } ?>
<?php if ($_SESSION["admin"]) { ?>
<button class="btn btn-default mx-auto w-75 mt-1 mb-1" data-bs-toggle="modal" data-bs-target="#activeModal">
<div class="d-flex justify-content-center">
<?php if ($m_active == 1) { ?>
<div>
<img src="<?= DOMAIN ?>/assets/images/deactive.png" alt="">
</div>
<div class="d-flex justify-content-center align-items-center">
Deactivate
</div>
<?php } else { ?>
<div>
<img src="<?= DOMAIN ?>/assets/images/active.png" alt="">
</div>
<div class="d-flex justify-content-center align-items-center">
Activate
</div>
<?php } ?>
</div>
</button>
<?php } ?>
<div class="d-flex justify-content-between w-75 mx-auto">
<?php if ($e_user['website']) { ?>
<a href="<?= $e_user['website'] ?>" target="_blank">
<button class="btn btn-default ps-3 pe-3 mt-1 mb-1" style="width: fit-content">
<img src="assets/images/world.png" alt="" style="width: 30px">
</button>
</a>
<?php } ?>
<?php if ($e_user['facebook']) { ?>
<a href="<?= $e_user['facebook'] ?>" target="_blank">
<button class="btn btn-default ps-3 pe-3 mt-1 mb-1" style="width: fit-content">
<img src="assets/images/facebook.png" alt="" style="width: 30px">
</button>
</a>
<?php } ?>
<?php if ($e_user['instagram']) { ?>
<a href="<?= $e_user['instagram'] ?>" target="_blank">
<button class="btn btn-default ps-3 pe-3 mt-1 mb-1" style="width: fit-content">
<img src="assets/images/instagram.png" alt="" style="width: 30px">
</button>
</a>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="modal fade" id="emailModal" 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">Send E-mail</h5>
</div>
<div class="modal-body">
<input type="text" class="form-control mt-3" name="subject" placeholder="subject">
<textarea class="form-control mt-3" rows="5" name="content" placeholder="message"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default px-5" data-bs-dismiss="modal">Cancel</button>
<button type="submit" name="member_send_email" class="btn btn-default px-5" data-bs-dismiss="modal">Send</button>
</div>
</div>
</form>
</div>
</div>
<div class="modal fade" id="whatsappModal" 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">Send Whatsapp</h5>
</div>
<div class="modal-body">
<textarea class="form-control mt-3" rows="5" placeholder="message"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default px-5" data-bs-dismiss="modal">Cancel</button>
<button type="submit" name="send_whatsapp" class="btn btn-default px-5" data-bs-dismiss="modal">Send</button>
</div>
</div>
</form>
</div>
</div>
<div class="modal fade" id="allowModal" 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">
<?php if ($conn_stt && $sql_stt) {
echo 'Request Disconnection';
} else if ($conn_stt && !$sql_stt) {
echo 'Request Remove Connection';
} else {
echo 'Request Connection';
} ?>
</h5>
</div>
<div class="modal-footer justify-content-center pt-5 pb-3">
<button type="button" class="btn btn-default px-5" data-bs-dismiss="modal">No</button>
<button type="submit" <?php if ($conn_stt && $sql_stt) {
echo 'name="memberDisconnect"';
} else if ($conn_stt && !$sql_stt) {
echo 'name="memberConnectRemove"';
} else {
echo 'name="memberConnect"';
} ?> class="btn btn-default px-5" data-bs-dismiss="modal">Yes</button>
</div>
</div>
</form>
</div>
</div>
<div class="modal fade" id="activeModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<form action="" method="post">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel">Activate Member</h4>
</div>
<div class="modal-footer justify-content-center pt-5 pb-3">
<button type="button" class="btn btn-default px-5" data-bs-dismiss="modal">No</button>
<button type="submit" <?php
if ($m_active == 1) {
echo 'name="deactive"';
} else {
echo 'name="active"';
} ?> class="btn btn-default px-5" data-bs-dismiss="modal">Yes</button>
</div>
</div>
</form>
</div>
</div>
</section>
<script>
function gotoEventPage() {
window.location.href = "<?= DOMAIN ?>/search-event.php?usernr=<?= $m_usernr ?>"
}
function initMap() {
var apiKey = 'AIzaSyBWJPDBXRHjvgNN8DFAOX1VWv63rPvnXD0';
var zipCode = <?= $e_user['zip'] ?>;
var country = 'Germany';
// Build the Google Maps Geocoding API request URL
var requestUrl = "https://maps.googleapis.com/maps/api/geocode/json?address=" + zipCode + "&components=country:" + country + "&key=" + apiKey;
//define lat, lng value
var lat = 20;
var lng = 8.37504;
// Perform the request using fetch
fetch(requestUrl)
.then(response => {
return response.json()
})
.then(data => {
console.log('1')
if (data && data.status === 'OK' && data.results.length > 0) {
var center = {
lat: data.results[0].geometry.location.lat,
lng: data.results[0].geometry.location.lng
};
var map = new google.maps.Map(document.getElementById('map'), {
center: center,
zoom: 12 // Adjust the zoom level as needed
});
} else {
// Handle errors
console.log("Error geocoding the zip code.");
}
})
}
initMap();
</script>
<?php include 'inc/footer.php' ?>