Skip to content

Commit

Permalink
Delete avatar images and update member avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
HashJProgramming committed Feb 9, 2024
1 parent e0c7cd9 commit fd97fa5
Show file tree
Hide file tree
Showing 21 changed files with 205 additions and 108 deletions.
Binary file removed assets/img/avatars/avatar2.jpeg
Binary file not shown.
Binary file removed assets/img/avatars/avatar3.jpeg
Binary file not shown.
Binary file removed assets/img/avatars/avatar4.jpeg
Binary file not shown.
Binary file removed assets/img/avatars/avatar5.jpeg
Binary file not shown.
42 changes: 31 additions & 11 deletions dashboard.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
include_once 'functions/authentication.php';
include_once 'functions/views/dashboard-chart.php';
include_once 'functions/views/dashboard-count.php';
?>
<!DOCTYPE html>
<html data-bs-theme="light" lang="en">
Expand Down Expand Up @@ -30,9 +32,9 @@
<li class="nav-item"><a class="nav-link active" href="dashboard.php"><i class="fas fa-tachometer-alt"></i><span>Dashboard</span></a></li>
<li class="nav-item"><a class="nav-link" href="members.php"><i class="far fa-folder-open"></i><span>Manage Members</span></a></li>
<li class="nav-item"><a class="nav-link" href="status.php"><i class="far fa-calendar-alt"></i><span>Member Status</span></a></li>
<li class="nav-item"><a class="nav-link" href="staff.php"><i class="far fa-user"></i><span>Manage Staff</span></a></li>
<li class="nav-item"><a class="nav-link" href="reports.php"><i class="fas fa-table"></i><span>Reports</span></a></li>
<li class="nav-item"><a class="nav-link" href="logs.php"><i class="far fa-address-card"></i><span>Users Activity Logs</span></a></li>
<li class="nav-item <?php echo ($_SESSION['level'] == 1) ? 'd-none' : ''; ?>"><a class="nav-link" href="staff.php"><i class="far fa-user"></i><span>Manage Staff</span></a></li>
<li class="nav-item <?php echo ($_SESSION['level'] == 1) ? 'd-none' : ''; ?>"><a class="nav-link" href="reports.php"><i class="fas fa-table"></i><span>Reports</span></a></li>
<li class="nav-item <?php echo ($_SESSION['level'] == 1) ? 'd-none' : ''; ?>"><a class="nav-link" href="logs.php"><i class="far fa-address-card"></i><span>Users Activity Logs</span></a></li>
<li class="nav-item"><a class="nav-link" href="functions/logout.php"><i class="far fa-clock"></i><span>Logout</span></a></li>
</ul>
<div class="text-center d-none d-md-inline"><button class="btn rounded-circle border-0" id="sidebarToggle" type="button"></button></div>
Expand All @@ -51,7 +53,7 @@
<div class="row align-items-center no-gutters">
<div class="col me-2">
<div class="text-uppercase text-primary fw-bold text-xs mb-1"><span>Earnings (monthly)</span></div>
<div class="text-dark fw-bold h5 mb-0"><span>₱0.00</span></div>
<div class="text-dark fw-bold h5 mb-0"><span>₱<?=number_format(calculateMonthlyEarnings())?></span></div>
</div>
<div class="col-auto"><i class="fas fa-calendar fa-2x text-gray-300"></i></div>
</div>
Expand All @@ -64,7 +66,7 @@
<div class="row align-items-center no-gutters">
<div class="col me-2">
<div class="text-uppercase text-success fw-bold text-xs mb-1"><span>Earnings (annual)</span></div>
<div class="text-dark fw-bold h5 mb-0"><span>₱0.00</span></div>
<div class="text-dark fw-bold h5 mb-0"><span>₱<?=number_format(calculateYearlyEarnings())?></span></div>
</div>
<div class="col-auto"><i class="fas fa-dollar-sign fa-2x text-gray-300"></i></div>
</div>
Expand All @@ -77,7 +79,7 @@
<div class="row align-items-center no-gutters">
<div class="col me-2">
<div class="text-uppercase text-warning fw-bold text-xs mb-1"><span>Active Member</span></div>
<div class="text-dark fw-bold h5 mb-0"><span>0</span></div>
<div class="text-dark fw-bold h5 mb-0"><span><?=countTotalActiveMembers()?></span></div>
</div>
<div class="col-auto"><i class="fas fa-comments fa-2x text-gray-300"></i></div>
</div>
Expand All @@ -90,19 +92,19 @@
<div class="row align-items-center no-gutters">
<div class="col me-2">
<div class="text-uppercase text-warning fw-bold text-xs mb-1"><span>Members</span></div>
<div class="text-dark fw-bold h5 mb-0"><span>0</span></div>
<div class="text-dark fw-bold h5 mb-0"><span><?=countTotalMembers()?></span></div>
</div>
<div class="col-auto"><i class="fas fa-comments fa-2x text-gray-300"></i></div>
</div>
</div>
</div>
</div>
</div>
<div class="row row-cols-lg-2 row-cols-xl-2 row-cols-xxl-2">
<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="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">Earnings Overview</h6>
<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>
Expand All @@ -111,10 +113,28 @@
</div>
</div>
<div class="card-body">
<div class="chart-area"><canvas data-bss-chart="{&quot;type&quot;:&quot;line&quot;,&quot;data&quot;:{&quot;labels&quot;:[&quot;Jan&quot;,&quot;Feb&quot;,&quot;Mar&quot;,&quot;Apr&quot;,&quot;May&quot;,&quot;Jun&quot;,&quot;Jul&quot;,&quot;Aug&quot;],&quot;datasets&quot;:[{&quot;label&quot;:&quot;Earnings&quot;,&quot;fill&quot;:true,&quot;data&quot;:[&quot;0&quot;,&quot;10000&quot;,&quot;5000&quot;,&quot;15000&quot;,&quot;10000&quot;,&quot;20000&quot;,&quot;15000&quot;,&quot;25000&quot;],&quot;backgroundColor&quot;:&quot;rgba(78, 115, 223, 0.05)&quot;,&quot;borderColor&quot;:&quot;rgb(223,87,78)&quot;}]},&quot;options&quot;:{&quot;maintainAspectRatio&quot;:false,&quot;legend&quot;:{&quot;display&quot;:false,&quot;labels&quot;:{&quot;fontStyle&quot;:&quot;normal&quot;}},&quot;title&quot;:{&quot;fontStyle&quot;:&quot;normal&quot;},&quot;scales&quot;:{&quot;xAxes&quot;:[{&quot;gridLines&quot;:{&quot;color&quot;:&quot;rgb(234, 236, 244)&quot;,&quot;zeroLineColor&quot;:&quot;rgb(234, 236, 244)&quot;,&quot;drawBorder&quot;:false,&quot;drawTicks&quot;:false,&quot;borderDash&quot;:[&quot;2&quot;],&quot;zeroLineBorderDash&quot;:[&quot;2&quot;],&quot;drawOnChartArea&quot;:false},&quot;ticks&quot;:{&quot;fontColor&quot;:&quot;#858796&quot;,&quot;fontStyle&quot;:&quot;normal&quot;,&quot;padding&quot;:20}}],&quot;yAxes&quot;:[{&quot;gridLines&quot;:{&quot;color&quot;:&quot;rgb(234, 236, 244)&quot;,&quot;zeroLineColor&quot;:&quot;rgb(234, 236, 244)&quot;,&quot;drawBorder&quot;:false,&quot;drawTicks&quot;:false,&quot;borderDash&quot;:[&quot;2&quot;],&quot;zeroLineBorderDash&quot;:[&quot;2&quot;]},&quot;ticks&quot;:{&quot;fontColor&quot;:&quot;#858796&quot;,&quot;fontStyle&quot;:&quot;normal&quot;,&quot;padding&quot;:20}}]}}}"></canvas></div>
<div class="chart-area"><?=month_chart()?></div>
</div>
</div>
</div>
<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">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">
<div class="chart-area"><?=yearly_chart()?></div>
</div>
</div>
</div>
</div>
<div class="row 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">
Expand All @@ -127,7 +147,7 @@
</div>
</div>
<div class="card-body">
<div class="chart-area"><canvas data-bss-chart="{&quot;type&quot;:&quot;doughnut&quot;,&quot;data&quot;:{&quot;labels&quot;:[&quot;Male&quot;,&quot;Female&quot;,&quot;Referral&quot;],&quot;datasets&quot;:[{&quot;label&quot;:&quot;&quot;,&quot;backgroundColor&quot;:[&quot;#4e73df&quot;,&quot;#1cc88a&quot;],&quot;borderColor&quot;:[&quot;#ffffff&quot;,&quot;#ffffff&quot;],&quot;data&quot;:[&quot;50&quot;,&quot;30&quot;]}]},&quot;options&quot;:{&quot;maintainAspectRatio&quot;:false,&quot;legend&quot;:{&quot;display&quot;:false,&quot;labels&quot;:{&quot;fontStyle&quot;:&quot;normal&quot;}},&quot;title&quot;:{&quot;fontStyle&quot;:&quot;normal&quot;}}}"></canvas></div>
<div class="chart-area"><?=get_gender_piechart()?></div>
<div class="text-center small mt-4"><span class="me-2"><i class="fas fa-circle text-primary"></i>&nbsp;Male</span><span class="me-2"><i class="fas fa-circle text-success"></i>&nbsp;Female</span></div>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion functions/authentication.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
session_start();
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
if (!isset($_SESSION['username'])) {
header('Location: ./index.php');
}
Expand Down
19 changes: 13 additions & 6 deletions functions/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
include_once 'connection.php';

$id = $_POST['id'];
$room = $_POST['room'];
$total = $_POST['total'];
$type = $_POST['type'];
if ($type == 'REGULAR'){
$total = 300;
} elseif ($type == 'PREMIUM'){
$total = 500;
} else {
$total = 800;
}

$amount = $_POST['amount'];
$change = $amount - $total;

Expand All @@ -12,17 +19,17 @@
exit;
}

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

$paymentId = $db->lastInsertId();

$sql = "UPDATE boarders SET start_date = CURDATE() WHERE id = :id";
$sql = "UPDATE members SET start_date = CURDATE() WHERE id = :id";
$stmt = $db->prepare($sql);
$stmt->bindParam(':id', $id);
$stmt->execute();
Expand Down
2 changes: 1 addition & 1 deletion functions/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
CREATE TABLE IF NOT EXISTS payments (
id INT PRIMARY KEY AUTO_INCREMENT,
member INT,
room INT,
type VARCHAR(255),
amount DECIMAL(10,2),
total DECIMAL(10,2),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
Expand Down
51 changes: 51 additions & 0 deletions functions/views/dashboard-chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,54 @@ function month_chart()
<canvas data-bss-chart='{"type":"line","data":<?php echo $chartDataJson; ?>,"options":{"maintainAspectRatio":false,"legend":{"display":false,"labels":{"fontStyle":"normal"}},"title":{"fontStyle":"normal"},"scales":{"xAxes":[{"gridLines":{"color":"rgb(234, 236, 244)","zeroLineColor":"rgb(234, 236, 244)","drawBorder":false,"drawTicks":false,"borderDash":["2"],"zeroLineBorderDash":["2"],"drawOnChartArea":false},"ticks":{"fontColor":"#858796","fontStyle":"normal","padding":20}}],"yAxes":[{"gridLines":{"color":"rgb(234, 236, 244)","zeroLineColor":"rgb(234, 236, 244)","drawBorder":false,"drawTicks":false,"borderDash":["2"],"zeroLineBorderDash":["2"]},"ticks":{"fontColor":"#858796","fontStyle":"normal","padding":20}}]}}}'></canvas>
<?php
}



function get_gender_piechart()
{
global $db;
$sql = "SELECT COUNT(CASE WHEN sex = 'Male' THEN 1 END) AS male_count,
COUNT(CASE WHEN sex = 'Female' THEN 1 END) AS female_count,
COUNT(CASE WHEN sex = 'Referral' THEN 1 END) AS referral_count
FROM members";

$stmt = $db->prepare($sql);
$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_ASSOC);
$maleCount = $row['male_count'];
$femaleCount = $row['female_count'];
$referralCount = $row['referral_count'];

$chartData = [
'type' => 'doughnut',
'data' => [
'labels' => ['Male', 'Female', 'Referral'],
'datasets' => [
[
'label' => '',
'backgroundColor' => ['#4e73df', '#1cc88a'],
'borderColor' => ['#ffffff', '#ffffff'],
'data' => [$maleCount, $femaleCount, $referralCount]
]
]
],
'options' => [
'maintainAspectRatio' => false,
'legend' => [
'display' => false,
'labels' => [
'fontStyle' => 'normal'
]
],
'title' => [
'fontStyle' => 'normal'
]
]
];

$chartDataJson = json_encode($chartData);
?>
<canvas data-bss-chart='<?php echo htmlspecialchars($chartDataJson); ?>'></canvas>
<?php
}
19 changes: 10 additions & 9 deletions functions/views/dashboard-count.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@ function calculateYearlyEarnings() {
return $yearlyEarnings;
}

function countTotalBoarders() {
function countTotalActiveMembers() {
global $db;
$sql = 'SELECT COUNT(*) AS totalBoarders FROM boarders';
$sql = 'SELECT COUNT(*) AS totalActiveMembers FROM `members` WHERE DATE_ADD(start_date, INTERVAL 1 MONTH) > CURDATE()';
$stmt = $db->prepare($sql);
$stmt->execute();
$result = $stmt->fetch();
$totalBoarders = $result['totalBoarders'];
return $totalBoarders;
$totalActiveMembers = $result['totalActiveMembers'];
return $totalActiveMembers;
}
function countTotalRooms() {

function countTotalMembers() {
global $db;
$sql = 'SELECT COUNT(*) AS totalRooms FROM rooms';
$sql = 'SELECT COUNT(*) AS totalMembers FROM members';
$stmt = $db->prepare($sql);
$stmt->execute();
$result = $stmt->fetch();
$totalRooms = $result['totalRooms'];
return $totalRooms;
}
$totalMembers = $result['totalMembers'];
return $totalMembers;
}
6 changes: 3 additions & 3 deletions functions/views/members-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
?>
<tr>
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/avatars/avatar1.jpeg"><?=$row['fullname']?></td>
<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>
Expand All @@ -33,9 +33,9 @@
<td><?=$row['start_date']?></td>
<td><span class="<?= $class ?>"><?= $text ?></span></td>
<td class="text-center">
<a class="btn btn-primary mx-1" role="button" href="profile.php" data-bs-target="#pay" data-bs-toggle="modal" data-id="<?= $row['id'] ?>" data-type="<?= $row['type'] ?>">
<button class="btn btn-primary mx-1" role="button" href="profile.php" data-bs-target="#pay" data-bs-toggle="modal" data-id="<?= $row['id'] ?>" data-type="<?= $row['type'] ?>">
<i class="far fa-money-bill-alt"></i>&nbsp;Payment
</a>
</button>
</td>
</tr>
<?php
Expand Down
2 changes: 1 addition & 1 deletion functions/views/members.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
?>
<tr>
<td><?=$row['id']?></td>
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/avatars/avatar1.jpeg"><?=$row['fullname']?></td>
<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>
Expand Down
15 changes: 7 additions & 8 deletions functions/views/reports.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<?php
include_once 'functions/connection.php';

$sql = 'SELECT boarders.*, rooms.id as room, rooms.rent as rent, payments.total, payments.amount
FROM boarders
INNER JOIN rooms ON boarders.room = rooms.id
INNER JOIN payments ON boarders.id = payments.boarder';
$sql = 'SELECT members.*, payments.total, payments.amount
FROM members
INNER JOIN payments ON members.id = payments.member';
$stmt = $db->prepare($sql);
$stmt->execute();
$results = $stmt->fetchAll();

foreach ($results as $row) {
?>
<tr>
<td><img class="rounded-circle me-2" width="30" height="30" src="functions/<?=$row['profile_picture']?>"><?=$row['fullname']?></td>
<td>Room # <?=$row['room']?></td>
<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><?=$row['type']?></td>
<td>₱<?=number_format($row['rent'], 2)?></td>
<td>₱<?=number_format($row['total'], 2)?></td>
<td>₱<?=number_format($row['amount'], 2)?></td>
<td>₱<?=number_format($row['total'], 2)?></td>
<td><?=$row['start_date']?></td>
</tr>
<?php
Expand Down
2 changes: 1 addition & 1 deletion functions/views/staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tr>
<td><?=$row['id']?></td>
<td><?=$row['username'] ? : 'None';?></td>
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/avatars/avatar1.jpeg"><?=$row['fullname']? : 'None'?></td>
<td><img class="rounded-circle me-2" width="30" height="30" src="https://bootdey.com/img/Content/avatar/avatar7.png"><?=$row['fullname']? : 'None'?></td>
<td><?=$row['address']? : 'None'?></td>
<td><?=$row['phone']? : 'None'?></td>
<td><?=$row['created_at']?></td>
Expand Down
Loading

0 comments on commit fd97fa5

Please sign in to comment.