-
Notifications
You must be signed in to change notification settings - Fork 0
/
modules_memberships_member.php
404 lines (377 loc) · 23.2 KB
/
modules_memberships_member.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
<?php
session_start();
require_once('config/config.php');
require_once('config/checklogin.php');
require_once('config/codeGen.php');
checklogin();
/* Update Profile */
if (isset($_POST['Update_Account'])) {
$user_id = $_POST['user_id'];
$user_name = $_POST['user_name'];
$user_email = $_POST['user_email'];
$user_phone = $_POST['user_phone'];
$user_idno = $_POST['user_idno'];
$query = 'UPDATE users SET user_name =?, user_email =?, user_phone =?, user_idno =? WHERE user_id =?';
$stmt = $mysqli->prepare($query);
$rc = $stmt->bind_param(
'sssss',
$user_name,
$user_email,
$user_phone,
$user_idno,
$user_id
);
$stmt->execute();
if ($stmt) {
$success = $user_name . ' Account Updated';
} else {
$err = 'Please Try Again Or Try Later';
}
}
/* Change Password */
if (isset($_POST['Update_Password'])) {
$user_id = $_POST['user_id'];
$new_password = sha1(md5($_POST['new_password']));
$confirm_password = sha1(md5($_POST['confirm_password']));
/* Check if passwords match */
if ($new_password != $confirm_password) {
$err = "Passwords Does Not Match";
} else {
$query = 'UPDATE users SET user_password =? WHERE user_id =?';
$stmt = $mysqli->prepare($query);
$rc = $stmt->bind_param(
'ss',
$confirm_password,
$user_id
);
$stmt->execute();
if ($stmt) {
$success = 'Password Updated';
} else {
$err = 'Please Try Again Or Try Later';
}
}
}
/* Update Member Package ID */
if (isset($_POST['Update_Membership'])) {
$user_id = $_POST['user_id'];
$user_membership_package_package_id = $_POST['user_membership_package_package_id'];
$query = 'UPDATE user_membership_package SET user_membership_package_package_id =? WHERE user_membership_package_user_id =?';
$stmt = $mysqli->prepare($query);
$rc = $stmt->bind_param('ss', $user_membership_package_package_id, $user_id);
$stmt->execute();
if ($stmt) {
$success = 'Membership Package Updated';
} else {
$err = 'Please Try Again Or Try Later';
}
}
/*Pay Membeship Package */
if (isset($_POST['Pay_Membership_Package'])) {
$payment_id = $sys_gen_id;
$payment_user_id = $_POST['payment_user_id'];
$payment_amount = $_POST['payment_amount'];
$payment_confirmation_code = $_POST['payment_confirmation_code'];
$payment_service_paid_id = $_POST['payment_service_paid_id'];
/* Update Payment Status */
$user_membership_package_payment_status = 'Paid';
$query = "INSERT INTO payments(payment_id, payment_user_id, payment_amount, payment_confirmation_code, payment_service_paid_id) VALUES(?,?,?,?,?)";
$payment = "UPDATE user_membership_package SET user_membership_package_payment_status = ? WHERE user_membership_package_id = ?";
$stmt = $mysqli->prepare($query);
$paystmt = $mysqli->prepare($payment);
$rc = $stmt->bind_param('sssss', $payment_id, $payment_user_id, $payment_amount, $payment_confirmation_code, $payment_service_paid_id);
$rc = $paystmt->bind_param('ss', $user_membership_package_payment_status, $payment_service_paid_id);
$stmt->execute();
$paystmt->execute();
if ($stmt && $paystmt) {
$success = "Membership Payment Posted";
} else {
$info = "Please Try Again Or Try Later";
}
}
require_once('partials/head.php');
?>
<body class="theme-red">
<!-- Page Loader -->
<div class="page-loader-wrapper">
<?php require_once('partials/loader.php'); ?>
</div>
<!-- Overlay For Sidebars -->
<div class="overlay"></div>
<!-- Top Bar -->
<?php require_once('partials/navigation.php'); ?>
<!-- Left Sidebar -->
<?php
require_once('partials/sidebar.php');
$view = $_GET['view'];
$ret = "SELECT * FROM users s
INNER JOIN user_membership_package ump ON s.user_id = ump.user_membership_package_user_id
INNER JOIN membership_packages mp ON mp.package_id = ump.user_membership_package_package_id
WHERE s.user_id = '$view'";
$stmt = $mysqli->prepare($ret);
$stmt->execute(); //ok
$res = $stmt->get_result();
while ($hrm = $res->fetch_object()) {
if ($hrm->user_profile_pic == '') {
$url = "assets/images/no-profile.png";
} else {
$url = "assets/images/$hrm->user_profile_pic";
}
?>
<section class="content profile-page">
<div class="container-fluid">
<div class="block-header">
<div class="row">
<div class="col-lg-12 col-md-6 col-sm-7">
<h2><?php echo $hrm->user_name; ?> Profile</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="dashboard">Dashboard</a></li>
<li class="breadcrumb-item"><a href="modules_memberships_members">Memberships</a></li>
<li class="breadcrumb-item active">Profile</li>
</ul>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-md-12">
<div class="boxs-simple">
<div class="profile-header">
<div class="profile_info">
<div class="profile-image"> <img src="<?php echo $url; ?>" alt=""> </div>
<h4 class="mb-0"><strong><?php echo $hrm->user_name; ?></strong></h4>
<span class="">Email: <?php echo $hrm->user_email; ?></span><br>
<span class="">Contacts: <?php echo $hrm->user_phone; ?></span><br>
<span class="">ID No: <?php echo $hrm->user_idno; ?></span><br>
<span class="">Membership Package: <?php echo $hrm->package_name; ?></span><br>
<span class="">Package Rate: Ksh <?php echo $hrm->package_pricing; ?></span><br>
<span class="">Member Since : <?php echo $hrm->user_created_on; ?></span><br>
<span class="">Membership Package Payment Status : <?php echo $hrm->user_membership_package_payment_status; ?></span><br>
<hr>
<?php if ($hrm->user_membership_package_payment_status == 'Pending') { ?>
<!-- Pay Membership Fee -->
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#pay_membership_modal">Pay Membership Package</button>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-lg-12 col-md-1">
<div class="card">
<div class="body">
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#profile_settings">Profile Settings</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#change_password">Change Password</a></li>
<?php
$user_access_level = $_SESSION['user_access_level'];
/* Only Show This If Access Level Is Admin */
if ($user_access_level == 'Administrator') {
?>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#change_access_level">Update Membership Package</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#delete_account">Delete Account</a></li>
<?php } ?>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="profile_settings">
<div class="wrap-reset">
<form method="POST">
<div class="modal-body">
<div class="row clearfix">
<div class="col-sm-6">
<div class="form-group">
<label>Full Name</label>
<div class="form-line">
<input type="text" name="user_name" value="<?php echo $hrm->user_name; ?>" required class="form-control" />
<!-- Hide This -->
<input type="hidden" name="user_id" value="<?php echo $hrm->user_id; ?>" required class="form-control" />
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Phone Number</label>
<div class="form-line">
<input type="text" name="user_phone" value="<?php echo $hrm->user_phone; ?>" required class="form-control" />
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>National ID No</label>
<div class="form-line">
<input type="text" name="user_idno" value="<?php echo $hrm->user_idno; ?>" required class="form-control" />
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Email</label>
<div class="form-line">
<input type="text" name="user_email" value="<?php echo $hrm->user_email; ?>" required class="form-control" />
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="Update_Account" class="btn btn-link waves-effect">SAVE CHANGES</button>
</div>
</form>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="change_password">
<form method="POST">
<div class="modal-body">
<div class="row clearfix">
<div class="col-sm-12">
<div class="form-group">
<label>New Password</label>
<div class="form-line">
<input type="password" name="new_password" required class="form-control" />
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<label>Confirm New Password</label>
<div class="form-line">
<input type="password" name="confirm_password" required class="form-control" />
<!-- Hide This -->
<input type="hidden" name="user_id" value="<?php echo $hrm->user_id; ?>" required class="form-control" />
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="Update_Password" class="btn btn-link waves-effect">SAVE CHANGES</button>
</div>
</form>
</div>
<div role="tabpanel" class="tab-pane" id="change_access_level">
<br>
<h2 class="card-inside-title text-center">Update <?php echo $hrm->user_name; ?> Membership Package</h2>
<form method="POST">
<div class="modal-body">
<div class="row clearfix">
<div class="col-sm-12">
<div class="form-group">
<label>Select Membership Package Name</label>
<div class="form-line">
<select name="user_membership_package_package_id" class="form-control show-tick">
<?php
$ret = "SELECT * FROM membership_packages ";
$stmt = $mysqli->prepare($ret);
$stmt->execute(); //ok
$res = $stmt->get_result();
while ($package = $res->fetch_object()) {
?>
<option value="<?php echo $package->package_id; ?>"><?php echo $package->package_name; ?></option>
<?php } ?>
</select>
</div>
</div>
<!-- Hide This -->
<input type="hidden" name="user_id" value="<?php echo $hrm->user_id; ?>" required class="form-control" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="Update_Membership" class="btn btn-link waves-effect">SAVE CHANGES</button>
</div>
</form>
</div>
<div role="tabpanel" class="tab-pane" id="delete_account">
<div class="row clearfix">
<div class="modal-body">
<div class="row clearfix">
<br>
<h2 class="card-inside-title text-danger text-center">
Heads Up!, you are about to delete <?php echo $hrm->user_name; ?> Staff account.
This action is reversible, the system will permanently delete <?php echo $hrm->user_name; ?>
records and any other related records too.
</h2>
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#delete_modal">Delete Account</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Delete Account Modal -->
<div class="modal fade" id="delete_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">CONFIRM</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body text-center text-danger">
<h4>Delete <?php echo $hrm->user_name; ?> ?</h4>
<br>
<p>Heads Up, You are about to delete <?php echo $hrm->user_name; ?>. This action is irrevisble.</p>
<button type="button" class="text-center btn btn-success" data-dismiss="modal">No</button>
<a href="modules_memberships_members?delete=<?php echo $hrm->user_id; ?>" class="text-center btn btn-danger"> Delete </a>
</div>
</div>
</div>
</div>
<!-- Pay Membership Package Modal -->
<div class="modal fade" id="pay_membership_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Pay <?php echo $hrm->user_name . ' ' . $hrm->package_name; ?> Membership Package Subsription</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form method="POST">
<div class="row clearfix">
<div class="col-sm-12">
<div class="form-group">
<label>Membership Package Amount (Ksh)</label>
<div class="form-line">
<input type="text" name="payment_amount" value="<?php echo $hrm->package_pricing; ?>" readonly required class="form-control" />
<!-- Hide This -->
<input type="hidden" name="payment_user_id" value="<?php echo $hrm->user_id; ?>" required class="form-control" />
<input type="hidden" name="payment_service_paid_id" value="<?php echo $hrm->user_membership_package_id; ?>" required class="form-control" />
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<label>Payment Confirmation Code</label>
<div class="form-line">
<input type="text" name="payment_confirmation_code" value="<?php echo $sys_gen_paycode; ?>" required class="form-control" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="Pay_Membership_Package" class="btn btn-link waves-effect">SAVE</button>
</div>
</form>
</div>
</div>
</div>
</div>u
<?php } ?>
<?php require_once('partials/scripts.php'); ?>
</body>
</html>