-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage_members.php
More file actions
178 lines (146 loc) · 5.11 KB
/
manage_members.php
File metadata and controls
178 lines (146 loc) · 5.11 KB
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
<?php
include('includes/config.php');
$selectQuery = "SELECT * FROM members ORDER BY created_at DESC";
$result = $conn->query($selectQuery);
if (!isset($_SESSION['user_id'])) {
header("Location: index.php");
exit();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$membershipType = $_POST['membershipType'];
$membershipAmount = $_POST['membershipAmount'];
$insertQuery = "INSERT INTO membership_types (type, amount) VALUES ('$membershipType', $membershipAmount)";
if ($conn->query($insertQuery) === TRUE) {
$successMessage = 'Membership type added successfully!';
// header("Location: dashboard.php");
// exit();
} else {
echo "Error: " . $insertQuery . "<br>" . $conn->error;
}
}
?>
<?php include('includes/header.php');?>
<body class="hold-transition sidebar-mini layout-fixed layout-navbar-fixed layout-footer-fixed">
<div class="wrapper">
<?php include('includes/nav.php');?>
<?php include('includes/sidebar.php');?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<?php include('includes/pagetitle.php');?>
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<!-- Info boxes -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Members DataTable</h3>
</div>
<!-- Visit codeastro.com for more projects -->
<!-- /.card-header -->
<div class="card-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>Fullname</th>
<th>Contact</th>
<th>Email</th>
<th>Address</th>
<th>Type</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$counter = 1;
while ($row = $result->fetch_assoc()) {
$expiryDate = strtotime($row['expiry_date']);
$currentDate = time();
$daysDifference = floor(($expiryDate - $currentDate) / (60 * 60 * 24));
$membershipStatus = ($daysDifference < 0) ? 'Expired' : 'Active';
$membershipTypeId = $row['membership_type'];
$membershipTypeQuery = "SELECT type FROM membership_types WHERE id = $membershipTypeId";
$membershipTypeResult = $conn->query($membershipTypeQuery);
$membershipTypeRow = $membershipTypeResult->fetch_assoc();
$membershipTypeName = ($membershipTypeRow) ? $membershipTypeRow['type'] : 'Unknown';
echo "<tr>";
echo "<td>{$row['membership_number']}</td>";
echo "<td>{$row['fullname']}</td>";
echo "<td>{$row['contact_number']}</td>";
echo "<td>{$row['email']}</td>";
echo "<td>{$row['address']}</td>";
echo "<td>{$membershipTypeName}</td>";
echo "<td>{$membershipStatus}</td>";
echo "<td>";
if (!empty($row['expiry_date'])) {
echo "<a href='memberProfile.php?id={$row['id']}' class='btn btn-info'><i class='fas fa-id-card'></i></a>";
}
echo "
<a href='edit_member.php?id={$row['id']}' class='btn btn-primary'><i class='fas fa-edit'></i></a>
<button class='btn btn-danger' onclick='deleteMember({$row['id']})'><i class='fas fa-trash'></i></button>
</td>";
echo "</tr>";
$counter++;
}
?>
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div><!--/. container-fluid -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<!-- Visit codeastro.com for more projects -->
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
<!-- Main Footer -->
<footer class="main-footer">
<strong> © <?php echo date('Y');?> codeastro.com</a> -</strong>
All rights reserved.
<div class="float-right d-none d-sm-inline-block">
<b>Developed By</b> <a href="https://codeastro.com/">CodeAstro</a>
</div>
</footer>
</div>
<!-- ./wrapper -->
<?php include('includes/footer.php');?>
<script>
$(function () {
$("#example1").DataTable({
"responsive": true,
"autoWidth": false,
});
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
});
});
</script>
<script>
function deleteMember(id) {
if (confirm("Are you sure you want to delete this member?")) {
window.location.href = 'delete_members.php?id=' + id;
}
}
</script>
</body>
</html>