v2
This commit is contained in:
@@ -2,8 +2,6 @@
|
|||||||
include(__DIR__ . '/auth.php');
|
include(__DIR__ . '/auth.php');
|
||||||
require_login();
|
require_login();
|
||||||
date_default_timezone_set('Asia/Kolkata');
|
date_default_timezone_set('Asia/Kolkata');
|
||||||
|
|
||||||
// Don't send ANY HTML or echo above this line
|
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
.logo {
|
.logo {
|
||||||
@@ -20,66 +18,113 @@ date_default_timezone_set('Asia/Kolkata');
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mobile-specific styles */
|
/* Mobile-specific styles */
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
.mobile-welcome {
|
.mobile-welcome,
|
||||||
padding: 15px;
|
.mobile-profile {
|
||||||
color: #FFF;
|
display: inline-block;
|
||||||
line-height: 20px;
|
|
||||||
margin-left: 15px;
|
|
||||||
}
|
}
|
||||||
.desktop-welcome {
|
.desktop-welcome,
|
||||||
display: none;
|
.desktop-profile,
|
||||||
|
.navbar-right {
|
||||||
|
display: none !important; /* hide right side in mobile */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Desktop styles */
|
/* Desktop styles */
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.mobile-welcome {
|
.mobile-welcome,
|
||||||
display: none;
|
.mobile-profile {
|
||||||
|
display: none !important; /* hide mobile items in desktop */
|
||||||
}
|
}
|
||||||
.desktop-welcome {
|
.desktop-welcome {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- nav start -->
|
<!-- nav start -->
|
||||||
<nav class="navbar navbar-default">
|
<nav class="navbar navbar-default">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<a href="/Admin/"><img class="img-responsive logo" style="height:50px" src="/asset/images/new_logo2.jpg" alt=""></a>
|
|
||||||
|
|
||||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||||
<span class="sr-only">Toggle navigation</span>
|
<span class="sr-only">Toggle navigation</span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<!-- Mobile profile + welcome -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$imagePath = '';
|
||||||
|
if(isset($_SESSION['profile_pic']) && !empty($_SESSION['profile_pic'])){
|
||||||
|
$imagePath = "/CONTENT/ROOT_URI/Admin/".$_SESSION['profile_pic'];
|
||||||
|
}else{
|
||||||
|
$imagePath = "/CONTENT/ROOT_URI/Admin/default.svg";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<img class="mobile-profile"
|
||||||
|
src="<?php echo $imagePath; ?>"
|
||||||
|
width="40" height="40"
|
||||||
|
style="border-radius:50%; object-fit:cover;"
|
||||||
|
alt="Profile">
|
||||||
<span class="mobile-welcome">Welcome! <?php echo htmlspecialchars($_SESSION['name'] ?? ''); ?></span>
|
<span class="mobile-welcome">Welcome! <?php echo htmlspecialchars($_SESSION['name'] ?? ''); ?></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li><a href="/Admin/Create_AC_Recurring">New Recurring</a></li>
|
<?php
|
||||||
<li><a href="/Admin/Create_AC_FD">New FD</a></li>
|
$userType = $_SESSION['type'] ?? '';
|
||||||
<li><a href="/Admin/Create_AC_Loan">New Loan</a></li>
|
|
||||||
<li><a href="/Admin/Add_group">Add New Group</a></li>
|
if ($userType === 'admin') {
|
||||||
<li><a href="/Admin/View_AC?Type=Recurring">View A/C</a></li>
|
?>
|
||||||
<li><a href="/Admin/Trans_New">Transaction</a></li>
|
<li><a href="/Admin/Create_AC_Recurring">New Recurring</a></li>
|
||||||
<li><a href="/Admin/Due">Deemand Sheet</a></li>
|
<li><a href="/Admin/Create_AC_FD">New FD</a></li>
|
||||||
<li><a href="/Admin/Report">Report</a></li>
|
<li><a href="/Admin/Create_AC_Loan">New Loan</a></li>
|
||||||
<!-- <li><a href="/Admin/Revert">Revert</a></li> -->
|
<li><a href="/Admin/Add_group">Add New Group</a></li>
|
||||||
<?php
|
<li><a href="/Admin/Trans_New">Transaction</a></li>
|
||||||
if($_SESSION['type'] === 'admin'){ ?>
|
<li><a href="/Admin/agent-targets">Agent Targets</a></li>
|
||||||
<li><a href="/Admin/agent_View_report">Commission</a></li>
|
<!-- <li><a href="/Admin/agent_View_report">Commission</a></li> -->
|
||||||
<li><a href="/Admin/agent-targets">Agent Targets</a></li>
|
<li><a href="/Admin/View_AC?Type=Recurring">View A/C</a></li>
|
||||||
<li><a href="/Admin/Settings_Agent">Agent Settings</a></li>
|
<li><a href="/Admin/Report">Report</a></li>
|
||||||
<?php } ?>
|
<li><a href="/Admin/Due">Deemand Sheet</a></li>
|
||||||
|
<li><a href="/Admin/Settings_Agent">Agent Settings</a></li>
|
||||||
|
<?php
|
||||||
|
} elseif ($userType === 'bm') {
|
||||||
|
?>
|
||||||
|
<li><a href="/Admin/Create_AC_Recurring">New Recurring</a></li>
|
||||||
|
<li><a href="/Admin/Create_AC_FD">New FD</a></li>
|
||||||
|
<li><a href="/Admin/Create_AC_Loan">New Loan</a></li>
|
||||||
|
<li><a href="/Admin/Add_group">Add New Group</a></li>
|
||||||
|
<li><a href="/Admin/Trans_New">Transaction</a></li>
|
||||||
|
<li><a href="/Admin/agent-targets">Agent Targets</a></li>
|
||||||
|
<!-- <li><a href="/Admin/agent_View_report">Commission</a></li> -->
|
||||||
|
<?php
|
||||||
|
} elseif ($userType === 'agent') {
|
||||||
|
?>
|
||||||
|
<li><a href="/Admin/View_AC?Type=Recurring">View A/C</a></li>
|
||||||
|
<li><a href="/Admin/Due">Deemand Sheet</a></li>
|
||||||
|
<li><a href="/Admin/Report">Report</a></li>
|
||||||
|
<!-- <li><a href="/Admin/agent_View_report">Commission</a></li> -->
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<!-- Desktop right side -->
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li class="desktop-welcome"><span class="welcome-text">Welcome! <?php echo htmlspecialchars($_SESSION['name'] ?? ''); ?></span></li>
|
<li class="desktop-welcome">
|
||||||
|
<span class="welcome-text">Welcome! <?php echo htmlspecialchars($_SESSION['name'] ?? ''); ?></span>
|
||||||
|
</li>
|
||||||
|
<li class="desktop-profile">
|
||||||
|
<img src="<?php echo $imagePath; ?>" width="40" height="40" style="border-radius:50%; object-fit:cover;" alt="Profile">
|
||||||
|
</li>
|
||||||
<li><a href="/Admin/Signout">Signout</a></li>
|
<li><a href="/Admin/Signout">Signout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
113
CONTENT/ROOT_URI/Admin/next-matured.php
Normal file
113
CONTENT/ROOT_URI/Admin/next-matured.php
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
// ---- Default date range ----
|
||||||
|
$today = date("Y-m-d");
|
||||||
|
$monthStart = date("Y-m-01");
|
||||||
|
$dFrom = $_GET['dFrom'] ?? $monthStart;
|
||||||
|
$dTo = $_GET['dTo'] ?? $today;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<div class="card shadow-lg p-4 rounded-3">
|
||||||
|
<h4 class="mb-3">Maturity Report</h4>
|
||||||
|
<form method="get" class="row g-3">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label class="form-label">From</label>
|
||||||
|
<input value="<?= $dFrom ?>" type="date" name="dFrom" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label class="form-label">To</label>
|
||||||
|
<input value="<?= $dTo ?>" type="date" name="dTo" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 d-flex align-items-end" style="margin-top: 25px;">
|
||||||
|
<button type="submit" class="btn btn-info w-100">Generate Report</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
function maturity_report($dateFrom, $dateTo) {
|
||||||
|
echo '<div class="container mt-4">
|
||||||
|
<div class="alert alert-primary shadow-sm">
|
||||||
|
<h5 class="mb-0">Maturity Report: '.$dateFrom." → ".$dateTo.'</h5>
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||||
|
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
|
||||||
|
|
||||||
|
// ---- Next month maturity filter ----
|
||||||
|
$sql = "SELECT * FROM ".$GLOBALS['arif_ac']." WHERE DATE_FORMAT(AA_DATE_MATURE, '%Y-%m-%d') BETWEEN '".$dateFrom."' AND '".$dateTo."'ORDER BY AA_DATE_MATURE ASC";
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<div class="container mt-3">
|
||||||
|
<div class="card shadow-sm rounded-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered table-hover align-middle">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>AC No</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Total Installments</th>
|
||||||
|
<th>Paid</th>
|
||||||
|
<th>Pending</th>
|
||||||
|
<th>Mature Value</th>
|
||||||
|
<th>Maturity Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>';
|
||||||
|
|
||||||
|
$grandTotal = 0;
|
||||||
|
|
||||||
|
if ($result && $result->num_rows > 0) {
|
||||||
|
while($row = $result->fetch_assoc()) {
|
||||||
|
|
||||||
|
// Calculate installments
|
||||||
|
$paid_installments = floor($row['AA_BAL'] / $row['AA_INSTALLMENT']);
|
||||||
|
$pending_installments = $row['AA_NO_OF_PAYMENT'] - $paid_installments;
|
||||||
|
|
||||||
|
if ($pending_installments <= 0) {
|
||||||
|
// Fully matured
|
||||||
|
$payout = $row['AA_MATURE_VALUE'];
|
||||||
|
} else {
|
||||||
|
// Not fully paid, only balance is eligible
|
||||||
|
$payout = $row['AA_BAL'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$grandTotal += $row['AA_MATURE_VALUE'];
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<tr>
|
||||||
|
<td>".$row['AA_ACNO']."</td>
|
||||||
|
<td>".$row['AA_NAME']."</td>
|
||||||
|
<td>".$row['AA_ACTYPE']."</td>
|
||||||
|
<td>".$row['AA_NO_OF_PAYMENT']."</td>
|
||||||
|
<td>".$paid_installments."</td>
|
||||||
|
<td>".$pending_installments."</td>
|
||||||
|
<td>".number_format($payout,2)."</td>
|
||||||
|
<td>".$row['AA_DATE_MATURE']."</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "<tr><td colspan='8' class='text-center text-muted'>No matured accounts found</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h5 class="text-end">Grand Total Payout: <b>'.number_format($grandTotal,2).'</b></h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Call maturity function ----
|
||||||
|
maturity_report($dFrom, $dTo);
|
||||||
|
?>
|
||||||
@@ -110,26 +110,28 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Some content -->
|
<!-- Some content -->
|
||||||
<div style="margin-top:80px; padding:15px;">
|
<div style="margin-top:20px; padding:15px;"></div>
|
||||||
<!-- Dashboard Content -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Bottom Navigation -->
|
<!-- Bottom Navigation -->
|
||||||
<?php if(isset($_SESSION) && !empty($_SESSION['user_id'])){ ?>
|
<?php if(isset($_SESSION) && !empty($_SESSION['user_id'])){ ?>
|
||||||
<div class="agent-bottom-nav">
|
<div class="agent-bottom-nav">
|
||||||
<a href="/Agent/Dashboard" class="agent-bottom-link active">
|
<a href="/Agent/Dashboard" class="agent-bottom-link <?php echo ($current_page == 'Dashboard' || $current_page == 'Agent') ? 'active' : ''; ?>" data-page="Dashboard">
|
||||||
<i class="fa-solid fa-house"></i>
|
<i class="fa-solid fa-house"></i>
|
||||||
Home
|
Home
|
||||||
</a>
|
</a>
|
||||||
<a href="/Agent/report" class="agent-bottom-link">
|
<a href="/Agent/report" class="agent-bottom-link <?php echo ($current_page == 'report') ? 'active' : ''; ?>" data-page="report">
|
||||||
<i class="fa-solid fa-chart-line"></i>
|
<i class="fa-solid fa-chart-line"></i>
|
||||||
Reports
|
Reports
|
||||||
</a>
|
</a>
|
||||||
<a href="/Agent/Receive" class="agent-bottom-link">
|
<a href="/Agent/Receive" class="agent-bottom-link <?php echo ($current_page == 'Receive') ? 'active' : ''; ?>" data-page="Receive">
|
||||||
<i class="fa-solid fa-plus"></i>
|
<i class="fa-solid fa-plus"></i>
|
||||||
Payment
|
Payment
|
||||||
</a>
|
</a>
|
||||||
<a href="/Agent/transaction" class="agent-bottom-link">
|
<!-- <a href="/Agent/commission" class="agent-bottom-link">
|
||||||
|
<i class="fa-solid fa-plus"></i>
|
||||||
|
Commission
|
||||||
|
</a> -->
|
||||||
|
<a href="/Agent/transaction" class="agent-bottom-link <?php echo ($current_page == 'transaction') ? 'active' : ''; ?>" data-page="transaction">
|
||||||
<i class="fa-solid fa-money-check-dollar"></i>
|
<i class="fa-solid fa-money-check-dollar"></i>
|
||||||
Transaction
|
Transaction
|
||||||
</a>
|
</a>
|
||||||
@@ -137,3 +139,37 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
// Function to set active state based on current page
|
||||||
|
function setActiveNavLink() {
|
||||||
|
// Get all navigation links
|
||||||
|
const navLinks = document.querySelectorAll('.agent-bottom-link');
|
||||||
|
|
||||||
|
// Get current page from URL
|
||||||
|
const currentPage = window.location.pathname.split('/').pop() || 'Dashboard';
|
||||||
|
|
||||||
|
// Remove active class from all links
|
||||||
|
navLinks.forEach(link => {
|
||||||
|
link.classList.remove('active');
|
||||||
|
|
||||||
|
// Get the page identifier from data attribute or href
|
||||||
|
const linkPage = link.getAttribute('data-page') || link.getAttribute('href').split('/').pop();
|
||||||
|
|
||||||
|
// Add active class if matches current page
|
||||||
|
if (linkPage === currentPage) {
|
||||||
|
link.classList.add('active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set active nav link on page load
|
||||||
|
document.addEventListener('DOMContentLoaded', setActiveNavLink);
|
||||||
|
|
||||||
|
// Also set active state when navigating (optional)
|
||||||
|
document.querySelectorAll('.agent-bottom-link').forEach(link => {
|
||||||
|
link.addEventListener('click', function() {
|
||||||
|
document.querySelectorAll('.agent-bottom-link').forEach(l => l.classList.remove('active'));
|
||||||
|
this.classList.add('active');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
if (!isset($_SESSION['user_id']) || empty($_SESSION['user_id'])) {
|
if (!isset($_SESSION['user_id']) || empty($_SESSION['user_id'])) {
|
||||||
echo "<script>window.location.href = '/Agent/agent-login'</script>";
|
echo "<script>window.location.href = '/Agent/agent-login'</script>";
|
||||||
exit;
|
exit;
|
||||||
@@ -16,9 +17,8 @@ if ($conn->connect_error) {
|
|||||||
|
|
||||||
$today = date("Y-m-d");
|
$today = date("Y-m-d");
|
||||||
$userId = $_SESSION['user_id'];
|
$userId = $_SESSION['user_id'];
|
||||||
$message = ""; // success/error message holder
|
$message = "";
|
||||||
|
|
||||||
/* === Save button click handle === */
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['save_collection'])) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['save_collection'])) {
|
||||||
$rowId = intval($_POST['row_id']);
|
$rowId = intval($_POST['row_id']);
|
||||||
$collectedAmount = floatval($_POST['collected_amount']);
|
$collectedAmount = floatval($_POST['collected_amount']);
|
||||||
@@ -34,7 +34,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['save_collection'])) {
|
|||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* === Data fetch === */
|
|
||||||
$targetSql = "SELECT * FROM agent_collections WHERE agent = '$userId' AND date = '$today'";
|
$targetSql = "SELECT * FROM agent_collections WHERE agent = '$userId' AND date = '$today'";
|
||||||
$targetResult = $conn->query($targetSql);
|
$targetResult = $conn->query($targetSql);
|
||||||
$targetRows = $targetResult->fetch_all(MYSQLI_ASSOC);
|
$targetRows = $targetResult->fetch_all(MYSQLI_ASSOC);
|
||||||
@@ -50,26 +49,21 @@ $remaining = $remaining < 0 ? 0 : $remaining;
|
|||||||
|
|
||||||
$percent = $collectable > 0 ? ($totalAmount / $collectable) * 100 : 0;
|
$percent = $collectable > 0 ? ($totalAmount / $collectable) * 100 : 0;
|
||||||
|
|
||||||
// Fetch last 10 days report
|
|
||||||
$repStmt = "SELECT * FROM agent_collections WHERE agent = '$userId' ORDER BY date DESC LIMIT 10;";
|
$repStmt = "SELECT * FROM agent_collections WHERE agent = '$userId' ORDER BY date DESC LIMIT 10;";
|
||||||
$reportsStmt = $conn->query($repStmt);
|
$reportsStmt = $conn->query($repStmt);
|
||||||
$reportRows = $reportsStmt->fetch_all(MYSQLI_ASSOC);
|
$reportRows = $reportsStmt->fetch_all(MYSQLI_ASSOC);
|
||||||
|
|
||||||
// echo json_encode($reportRows);
|
|
||||||
$conn->close();
|
$conn->close();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<div class="container" style="margin-bottom: 105px;">
|
<div class="container" style="margin-bottom: 105px;">
|
||||||
<h3 class="welcome-text">
|
<h3 class="welcome-text">
|
||||||
Welcome, <?= htmlspecialchars($_SESSION['name']) ?> 👋
|
Welcome, <?= htmlspecialchars($_SESSION['name']) ?> 👋
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<!-- Show success/error message -->
|
|
||||||
<?= $message ?>
|
<?= $message ?>
|
||||||
|
|
||||||
<div class="dashboard-total-section">
|
<div class="dashboard-total-section">
|
||||||
<!-- Total Collection -->
|
|
||||||
<div class="card-box highlight">
|
<div class="card-box highlight">
|
||||||
<h3>₹ <?= number_format($totalAmount, 2) ?></h3>
|
<h3>₹ <?= number_format($totalAmount, 2) ?></h3>
|
||||||
<p>Total Collection</p>
|
<p>Total Collection</p>
|
||||||
@@ -79,7 +73,6 @@ $conn->close();
|
|||||||
<small><?= round($percent, 2) ?>% Completed</small>
|
<small><?= round($percent, 2) ?>% Completed</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Total Collectable (with Remaining) -->
|
|
||||||
<div class="card-box normal">
|
<div class="card-box normal">
|
||||||
<h3>₹ <?= number_format($collectable, 2) ?></h3>
|
<h3>₹ <?= number_format($collectable, 2) ?></h3>
|
||||||
<p>Total Collectable</p>
|
<p>Total Collectable</p>
|
||||||
@@ -88,13 +81,12 @@ $conn->close();
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display: flex; flex-direction: row; width: 100%; justify-content: space-between; margin-top: 20px;">
|
<div style="display: flex; flex-direction: row; width: 100%; justify-content: space-between; margin-top: 20px;">
|
||||||
<!-- Payment Receive Button -->
|
|
||||||
<a class="btn btn-primary w-100" href="/Agent/Receive">
|
<a class="btn btn-primary w-100" href="/Agent/Receive">
|
||||||
<i class="fa-solid fa-credit-card"></i>
|
<i class="fa-solid fa-credit-card"></i>
|
||||||
Receive New Payment
|
Receive New Payment
|
||||||
</a>
|
</a>
|
||||||
<!-- Save Collection Button -->
|
|
||||||
<?php if (!empty($targetRows)) : ?>
|
<?php if (!empty($targetRows)) : ?>
|
||||||
<form method="post" class="w-100">
|
<form method="post" class="w-100">
|
||||||
<input type="hidden" name="save_collection" value="1">
|
<input type="hidden" name="save_collection" value="1">
|
||||||
@@ -104,6 +96,7 @@ $conn->close();
|
|||||||
</form>
|
</form>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (!empty($reportRows)) : ?>
|
<?php if (!empty($reportRows)) : ?>
|
||||||
<div class="report-section">
|
<div class="report-section">
|
||||||
<h4 class="report-title">📊 Last 10 Days Report</h4>
|
<h4 class="report-title">📊 Last 10 Days Report</h4>
|
||||||
@@ -134,17 +127,19 @@ $conn->close();
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<div class="android-links">
|
||||||
|
<a href="/Agent/commission">Commission</a>
|
||||||
|
<!-- <a href="/Agent/Report">Report</a>
|
||||||
|
<a href="/Agent/Profile">Profile</a> -->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.welcome-text {
|
.welcome-text {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.success-msg {
|
.success-msg {
|
||||||
color: green;
|
color: green;
|
||||||
background: #e6ffe6;
|
background: #e6ffe6;
|
||||||
@@ -152,7 +147,6 @@ $conn->close();
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error-msg {
|
.error-msg {
|
||||||
color: red;
|
color: red;
|
||||||
background: #ffe6e6;
|
background: #ffe6e6;
|
||||||
@@ -160,58 +154,25 @@ $conn->close();
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard-total-section {
|
.dashboard-total-section {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-box {
|
.card-box {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
background: linear-gradient(135deg, #fdfdfd, #f6f6f6);
|
background: linear-gradient(135deg, #f0f0f0ff, #d3d3d3ff);
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
box-shadow: 0 6px 20px rgba(0,0,0,0.08);
|
box-shadow: 0 6px 20px rgba(0,0,0,0.08);
|
||||||
transition: transform 0.25s ease, box-shadow 0.25s ease;
|
|
||||||
position: relative;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-box:hover {
|
|
||||||
transform: translateY(-6px);
|
|
||||||
box-shadow: 0 10px 25px rgba(0,0,0,0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-box h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 28px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #222;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-box p {
|
|
||||||
margin: 6px 0 12px;
|
|
||||||
font-size: 14px;
|
|
||||||
color: #555;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-box.highlight {
|
.card-box.highlight {
|
||||||
background: linear-gradient(135deg, #e95420, #f37249);
|
background: linear-gradient(135deg, #e95420, #f37249);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
.card-box.normal{
|
|
||||||
background: linear-gradient(135deg, #ecececff, #ffffffff);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-box.highlight h3,
|
|
||||||
.card-box.highlight p,
|
|
||||||
.card-box.highlight small {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
.progress-bar {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 10px;
|
height: 10px;
|
||||||
@@ -220,14 +181,12 @@ $conn->close();
|
|||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-fill {
|
.progress-fill {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
transition: width 0.4s ease;
|
transition: width 0.4s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remaining-text {
|
.remaining-text {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@@ -237,76 +196,110 @@ $conn->close();
|
|||||||
padding: 4px 10px;
|
padding: 4px 10px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Report Section - Scroll Snap Slider */
|
||||||
.report-section {
|
.report-section {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
.report-title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.report-cards {
|
||||||
|
display: flex;
|
||||||
|
overflow-x: auto;
|
||||||
|
scroll-snap-type: x mandatory;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
.report-card {
|
||||||
|
flex: 0 0 85%;
|
||||||
|
scroll-snap-align: center;
|
||||||
|
background: linear-gradient(135deg, #ecececff, #ffffffff);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 16px;
|
||||||
|
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
|
||||||
|
}
|
||||||
|
.report-date {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.report-details p {
|
||||||
|
margin: 4px 0;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #444;
|
||||||
|
}
|
||||||
|
.report-progress {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
.report-card .progress-bar {
|
||||||
|
width: 100%;
|
||||||
|
height: 8px;
|
||||||
|
background: #eee;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin: 8px 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.report-card .progress-fill {
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(135deg, #e95420, #f37249);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
/* Report-cards horizontal scrollbar */
|
||||||
|
.report-cards {
|
||||||
|
scrollbar-width: thin; /* Firefox */
|
||||||
|
scrollbar-color: #f37249 rgba(0,0,0,0.04); /* Firefox */
|
||||||
|
}
|
||||||
|
|
||||||
.report-title {
|
/* --- WebKit browsers (Chrome, Edge, Safari) --- */
|
||||||
font-size: 18px;
|
.report-cards::-webkit-scrollbar {
|
||||||
font-weight: 600;
|
height: 8px; /* thin horizontal scrollbar */
|
||||||
margin-bottom: 15px;
|
}
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.report-cards {
|
.report-cards::-webkit-scrollbar-track {
|
||||||
display: grid;
|
background: rgba(0,0,0,0.08);
|
||||||
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
border-radius: 10px;
|
||||||
gap: 20px;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.report-card {
|
.report-cards::-webkit-scrollbar-thumb {
|
||||||
background: linear-gradient(135deg, #ecececff, #ffffffff);
|
background: linear-gradient(90deg, #e95420, #f37249);
|
||||||
border-radius: 16px;
|
border-radius: 999px; /* ✅ fully rounded pill shape */
|
||||||
padding: 16px;
|
min-width: 30px;
|
||||||
box-shadow: 0 4px 15px rgba(0,0,0,0.08);
|
}
|
||||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.report-card:hover {
|
/* Hover effect */
|
||||||
transform: translateY(-5px);
|
.report-cards::-webkit-scrollbar-thumb:hover {
|
||||||
box-shadow: 0 8px 20px rgba(0,0,0,0.12);
|
background: linear-gradient(90deg, #d7461c, #e65f3c);
|
||||||
}
|
}
|
||||||
|
|
||||||
.report-date {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: #666;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.report-details p {
|
.android-links {
|
||||||
margin: 4px 0;
|
display: flex;
|
||||||
font-size: 14px;
|
gap: 12px; /* বাটনের মাঝে ফাঁকা */
|
||||||
color: #444;
|
flex-wrap: wrap; /* ছোট স্ক্রিনে ভাঙবে */
|
||||||
}
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.report-details strong {
|
.android-links a {
|
||||||
color: #111;
|
background: #e95420; /* বাটনের ব্যাকগ্রাউন্ড */
|
||||||
}
|
color: #fff; /* টেক্সট কালার */
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 25px; /* গোলাকার প্রান্ত */
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
box-shadow: 0 3px 8px rgba(0,0,0,0.2);
|
||||||
|
transition: all 0.25s ease;
|
||||||
|
}
|
||||||
|
|
||||||
.report-progress {
|
.android-links a:hover {
|
||||||
margin-top: 12px;
|
background: #cf471c; /* hover হলে একটু গাঢ় */
|
||||||
}
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 6px 12px rgba(0,0,0,0.25);
|
||||||
.report-progress small {
|
}
|
||||||
font-size: 12px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.report-card .progress-bar {
|
|
||||||
width: 100%;
|
|
||||||
height: 8px;
|
|
||||||
background: #eee;
|
|
||||||
border-radius: 10px;
|
|
||||||
margin: 8px 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.report-card .progress-fill {
|
|
||||||
height: 100%;
|
|
||||||
background: linear-gradient(135deg, #e95420, #f37249);
|
|
||||||
border-radius: 10px;
|
|
||||||
transition: width 0.4s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
131
CONTENT/ROOT_URI/Agent/commission.php
Normal file
131
CONTENT/ROOT_URI/Agent/commission.php
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
// ---- Default date range ----
|
||||||
|
$today = date("Y-m-d"); // Today date
|
||||||
|
$monthStart = date("Y-m-01"); // first date of each month
|
||||||
|
$dFrom = $_GET['dFrom'] ?? $monthStart;
|
||||||
|
$dTo = $_GET['dTo'] ?? $today;
|
||||||
|
|
||||||
|
// Get login user type
|
||||||
|
$loginType = $_SESSION['type'] ?? '';
|
||||||
|
$isAgent = ($loginType === 'agent');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<div class="card shadow-lg p-4 rounded-3">
|
||||||
|
<h4 class="mb-3">Commission Report</h4>
|
||||||
|
<form method="get" class="row g-3">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label class="form-label">From</label>
|
||||||
|
<input value="<?= $dFrom ?>" type="date" name="dFrom" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label class="form-label">To</label>
|
||||||
|
<input value="<?= $dTo ?>" type="date" name="dTo" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 d-flex align-items-end" style="margin-top: 25px;">
|
||||||
|
<button type="submit" class="btn btn-info w-100">Generate Report</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
function commission_report($dateFrom, $dateTo, $isAgent) {
|
||||||
|
echo '<div class="container mt-4">
|
||||||
|
<div class="alert alert-primary shadow-sm">
|
||||||
|
<h5 class="mb-0">Commission Report: '.$dateFrom." → ".$dateTo.'</h5>
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||||
|
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
|
||||||
|
|
||||||
|
// ---- Login user type check ----
|
||||||
|
$loginType = $_SESSION['type'] ?? ''; // login session-এ type আছে
|
||||||
|
$loginId = $_SESSION['user_id']; // login user_id
|
||||||
|
|
||||||
|
// ---- Base Query ----
|
||||||
|
$sql = "SELECT u.user_id, u.user_name, u.comi_rate, COALESCE(SUM(t.AT_AMOUNT),0) as total_amount FROM `".$GLOBALS['arif_users']."` u LEFT JOIN `".$GLOBALS['arif_ac']."` a ON u.user_id = a.AA_AGENT LEFT JOIN `".$GLOBALS['arif_tran']."` t ON a.AA_ACNO = t.AT_ACID AND t.AT_TIMESTAMP BETWEEN '".$dateFrom." 00:00:00' AND '".$dateTo." 23:59:59' WHERE u.type = 'agent'";
|
||||||
|
|
||||||
|
// ---- if Agent self data filter ----
|
||||||
|
if ($isAgent) {
|
||||||
|
$sql .= " AND u.user_id = '".$loginId."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= " GROUP BY u.user_id, u.user_name, u.comi_rate ORDER BY u.user_name ASC";
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<div class="container mt-3">
|
||||||
|
<div class="card shadow-sm rounded-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered table-hover align-middle">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>';
|
||||||
|
|
||||||
|
// Only show Agent ID and Name columns if user is not an agent
|
||||||
|
if (!$isAgent) {
|
||||||
|
echo '<th>Agent ID</th>
|
||||||
|
<th>Agent Name</th>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<th>Total Collection</th>
|
||||||
|
<th>Total Commission</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>';
|
||||||
|
|
||||||
|
$grandTotalCommission = 0;
|
||||||
|
$grandTotalCollection = 0;
|
||||||
|
|
||||||
|
if ($result && $result->num_rows > 0) {
|
||||||
|
while($row = $result->fetch_assoc()) {
|
||||||
|
$collection = $row["total_amount"];
|
||||||
|
$commission = ($collection * $row["comi_rate"]) / 100;
|
||||||
|
|
||||||
|
$grandTotalCollection += $collection;
|
||||||
|
$grandTotalCommission += $commission;
|
||||||
|
|
||||||
|
echo "<tr>";
|
||||||
|
|
||||||
|
// Only show Agent ID and Name if user is not an agent
|
||||||
|
if (!$isAgent) {
|
||||||
|
echo "<td>".$row["user_id"]."</td>
|
||||||
|
<td>".$row["user_name"]."</td>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<td>".number_format($collection,2)."</td>
|
||||||
|
<td>".number_format($commission,2)."</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$colspan = $isAgent ? 2 : 4;
|
||||||
|
echo "<tr><td colspan='$colspan' class='text-center text-muted'>No agents found</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '
|
||||||
|
</tbody>
|
||||||
|
</table>';
|
||||||
|
|
||||||
|
// ---- if admin/bm then show grand total ----
|
||||||
|
if (!$isAgent) {
|
||||||
|
echo '<h5 class="text-end">
|
||||||
|
Grand Total Collection : <b>'.number_format($grandTotalCollection,2).'</b><br>
|
||||||
|
Grand Total Commission : <b>'.number_format($grandTotalCommission,2).'</b>
|
||||||
|
</h5>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Call commission function ----
|
||||||
|
commission_report($dFrom, $dTo, $isAgent);
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user