Skip to content

Commit

Permalink
Fix payment and staff management UI, add amount field in add-member form
Browse files Browse the repository at this point in the history
  • Loading branch information
HashJProgramming committed Feb 9, 2024
1 parent 40edd0f commit 876d644
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 24 deletions.
17 changes: 4 additions & 13 deletions dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,13 @@
</div>
</div>
</div>
<div class="row row-cols-2 row-cols-sm-1 row-cols-md-1 row-cols-lg-2 row-cols-xl-2 row-cols-xxl-2">
<div class="row row-cols-1 row-cols-sm-1 row-cols-md-1 row-cols-lg-2 row-cols-xl-2 row-cols-xxl-2">
<div class="col">
<div class="card shadow mb-4">
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="text-primary fw-bold m-0">Monthly Earnings Overview</h6>
<div class="dropdown no-arrow"><button class="btn btn-link btn-sm dropdown-toggle" aria-expanded="false" data-bs-toggle="dropdown" type="button"><i class="fas fa-ellipsis-v text-gray-400"></i></button>
<div class="dropdown-menu shadow dropdown-menu-end animated--fade-in">
<p class="text-center dropdown-header">dropdown header:</p><a class="dropdown-item" href="#">&nbsp;Action</a><a class="dropdown-item" href="#">&nbsp;Another action</a>
<div class="dropdown-divider"></div><a class="dropdown-item" href="#">&nbsp;Something else here</a>
</div>

</div>
</div>
<div class="card-body">
Expand All @@ -122,10 +119,7 @@
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="text-primary fw-bold m-0">Annual Earnings Overview</h6>
<div class="dropdown no-arrow"><button class="btn btn-link btn-sm dropdown-toggle" aria-expanded="false" data-bs-toggle="dropdown" type="button"><i class="fas fa-ellipsis-v text-gray-400"></i></button>
<div class="dropdown-menu shadow dropdown-menu-end animated--fade-in">
<p class="text-center dropdown-header">dropdown header:</p><a class="dropdown-item" href="#">&nbsp;Action</a><a class="dropdown-item" href="#">&nbsp;Another action</a>
<div class="dropdown-divider"></div><a class="dropdown-item" href="#">&nbsp;Something else here</a>
</div>

</div>
</div>
<div class="card-body">
Expand All @@ -140,10 +134,7 @@
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="text-primary fw-bold m-0">Registered Gym by Gender</h6>
<div class="dropdown no-arrow"><button class="btn btn-link btn-sm dropdown-toggle" aria-expanded="false" data-bs-toggle="dropdown" type="button"><i class="fas fa-ellipsis-v text-gray-400"></i></button>
<div class="dropdown-menu shadow dropdown-menu-end animated--fade-in">
<p class="text-center dropdown-header">dropdown header:</p><a class="dropdown-item" href="#">&nbsp;Action</a><a class="dropdown-item" href="#">&nbsp;Another action</a>
<div class="dropdown-divider"></div><a class="dropdown-item" href="#">&nbsp;Something else here</a>
</div>

</div>
</div>
<div class="card-body">
Expand Down
38 changes: 36 additions & 2 deletions functions/add-member.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
include_once 'connection.php';
include_once 'connection.php';

$fullname = $_POST['fullname'];
$sex = $_POST['sex'];
Expand All @@ -8,6 +8,7 @@
$type = $_POST['type'];
$start_date = $_POST['start_date'];
$birthdate = $_POST['birthdate'];
$amount = $_POST['amount'];

$sql = "SELECT * FROM members WHERE fullname = :fullname OR phone = :phone";
$stmt = $db->prepare($sql);
Expand All @@ -21,6 +22,13 @@
exit;
}

$change = $amount - $total;

if ($change < 0) {
header('Location: ../rentals.php?type=error&message=Amount is not enough');
exit;
}

$sql = "INSERT INTO `members` (`fullname`, `sex`, `phone`, `address`, `type`, `start_date`, `birthdate`)
VALUES (:fullname, :sex, :phone, :address, :type, :start_date, :birthdate)";
$stmt = $db->prepare($sql);
Expand All @@ -33,4 +41,30 @@
$stmt->bindParam(':birthdate', $birthdate);
$stmt->execute();

header('Location: ../members.php?type=success&message=Member was added successfully');
$id = $db->lastInsertId();

if ($type == 'REGULAR'){
$total = 300;
} elseif ($type == 'PREMIUM'){
$total = 500;
} else {
$total = 800;
}

$sql = "INSERT INTO payments (member, type, amount, total) VALUES (:member, :type, :amount, :total)";
$stmt = $db->prepare($sql);
$stmt->bindParam(':member', $id);
$stmt->bindParam(':type', $type);
$stmt->bindParam(':amount', $amount);
$stmt->bindParam(':total', $total);
$stmt->execute();

$paymentId = $db->lastInsertId();

$sql = "UPDATE members SET start_date = CURDATE() WHERE id = :id";
$stmt = $db->prepare($sql);
$stmt->bindParam(':id', $id);
$stmt->execute();

generate_logs('Payment', $id . '| Payment was made');
header('Location: ../reciept.php?id=' . $paymentId);
2 changes: 1 addition & 1 deletion functions/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$change = $amount - $total;

if ($change < 0) {
header('Location: ../rentals.php?type=error&message=Amount is not enough');
header('Location: ../status.php?type=error&message=Amount is not enough');
exit;
}

Expand Down
10 changes: 9 additions & 1 deletion functions/views/members-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@
$class = 'badge bg-danger';
$text = 'Expired';
}

if ($row['type'] == 'Regular') {
$text_type =$row['type'].' - ₱300';
} elseif ($row['type'] == 'Premium') {
$text_type =$row['type'].' - ₱500';
} else {
$text_type =$row['type'].' - ₱800';
}
?>
<tr>
<td><img class="rounded-circle me-2" width="30" height="30" src="https://bootdey.com/img/Content/avatar/avatar7.png"><?=$row['fullname']?></td>
<td><?=$row['address']?></td>
<td><?=$row['phone']?></td>
<td><?=$age?></td>
<td><?=$row['sex']?></td>
<td><?=$row['type']?></td>
<td><?=$text_type?></td>
<td><?=$row['start_date']?></td>
<td><span class="<?= $class ?>"><?= $text ?></span></td>
<td class="text-center">
Expand Down
13 changes: 7 additions & 6 deletions members.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div id="content" class="mt-5">
<div class="container-fluid">
<div class="d-sm-flex justify-content-between align-items-center mb-4">
<h3 class="text-dark mb-0">Members Management</h3><button class="btn btn-primary btn-sm d-none d-sm-inline-block" type="button" data-bs-target="#add" data-bs-toggle="modal"><i class="fas fa-download fa-sm text-white-50"></i>&nbsp;Add Member</button>
<h3 class="text-dark mb-0">Members Management</h3><button class="btn btn-primary btn-sm mx-1 my-1" type="button" data-bs-target="#add" data-bs-toggle="modal"><i class="fas fa-download fa-sm text-white-50"></i>&nbsp;Add Member</button>
</div>
<div class="card shadow">
<div class="card-header py-3">
Expand Down Expand Up @@ -115,12 +115,13 @@
<div class="form-floating mb-3"><input class="form-control form-control" placeholder="" type="date" name="birthdate"><label class="form-label" for="floatingInput">Birthdate</label></div>
</div>
</div>
<div class="form-floating mb-3"><input class="form-control form-control" type="text" placeholder="Amount" name="amount"><label class="form-label" for="floatingInput">Amount</label></div>
<div class="form-floating"><select class="form-select form-select" aria-label="Floating label select example" id="floatingSelect-1" name="type">
<option value="Regular">₱300 Regular (Membership)</option>
<option value="Premium">₱500 Premium (Membership, Coach, Personal Locker)</option>
<option value="VIP">₱800 VIP (Membership, ID Card, Coach, Personal Locker)</option>
</select><label class="form-label" for="floatingSelect">Type</label></div>
</div>
<option value="Regular">₱300 Regular (Membership)</option>
<option value="Premium">₱500 Premium (Membership, Coach, Personal Locker)</option>
<option value="VIP">₱800 VIP (Membership, ID Card, Coach, Personal Locker)</option>
</select><label class="form-label" for="floatingSelect">Type</label></div>
</div>
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="submit">Save</button></div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div id="content" class="mt-5">
<div class="container-fluid">
<div class="d-sm-flex justify-content-between align-items-center mb-4">
<h3 class="text-dark mb-0">Staff Management</h3><button class="btn btn-primary btn-sm d-none d-sm-inline-block" type="button" data-bs-target="#add" data-bs-toggle="modal"><i class="fas fa-download fa-sm text-white-50"></i>&nbsp;Add Staff</button>
<h3 class="text-dark mb-0">Staff Management</h3><button class="btn btn-primary btn-sm mx-1 my-1" type="button" data-bs-target="#add" data-bs-toggle="modal"><i class="fas fa-download fa-sm text-white-50"></i>&nbsp;Add Staff</button>
</div>
<div class="card shadow">
<div class="card-header py-3">
Expand Down

0 comments on commit 876d644

Please sign in to comment.