224 lines
8.4 KiB
PHP
224 lines
8.4 KiB
PHP
<?php
|
|
include(__DIR__ . '/auth.php');
|
|
require_login();
|
|
date_default_timezone_set('Asia/Kolkata');
|
|
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
|
|
$pendingCount = 0; // Default value
|
|
|
|
try {
|
|
$table = 'fund_trans';
|
|
|
|
// Check user type and prepare appropriate query
|
|
if ($_SESSION['type'] === 'admin') {
|
|
// Admin can only see BM requests
|
|
$countStmt = $conn->prepare("SELECT COUNT(*) AS pending_count FROM `$table` WHERE status = 0 AND request_usr_type = 'bm'");
|
|
} elseif ($_SESSION['type'] === 'bm') {
|
|
// BM can only see Admin requests
|
|
$countStmt = $conn->prepare("SELECT COUNT(*) AS pending_count FROM `$table` WHERE status = 0 AND request_usr_type = 'admin'");
|
|
} else {
|
|
// Other user types see nothing
|
|
$countStmt = false;
|
|
$pendingCount = 0;
|
|
}
|
|
|
|
if ($countStmt) {
|
|
$countStmt->execute();
|
|
$countResult = $countStmt->get_result();
|
|
|
|
if ($countResult) {
|
|
$row = $countResult->fetch_assoc();
|
|
$pendingCount = $row['pending_count'] ?? 0;
|
|
}
|
|
|
|
$countStmt->close();
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
// Log error instead of showing to user
|
|
error_log("Error getting pending count: " . $e->getMessage());
|
|
}
|
|
|
|
$conn->close();
|
|
?>
|
|
<style>
|
|
.logo {
|
|
display: inline-block;
|
|
margin: auto;
|
|
vertical-align: middle;
|
|
}
|
|
.welcome-text {
|
|
padding: 15px;
|
|
color: #FFF;
|
|
display: inline-block;
|
|
}
|
|
.navbar-right {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
/* Dropdown menu styling */
|
|
.dropdown-menu > li > a {
|
|
padding: 10px 20px;
|
|
}
|
|
.navbar-nav > li > .dropdown-menu {
|
|
border-top: 2px solid #337ab7;
|
|
}
|
|
|
|
/* Mobile-specific styles */
|
|
@media (max-width: 767px) {
|
|
.mobile-welcome,
|
|
.mobile-profile {
|
|
display: inline-block;
|
|
}
|
|
.desktop-welcome,
|
|
.desktop-profile,
|
|
.navbar-right {
|
|
display: none !important; /* hide right side in mobile */
|
|
}
|
|
|
|
/* Adjust dropdown for mobile */
|
|
.navbar-nav .open .dropdown-menu {
|
|
position: static;
|
|
float: none;
|
|
width: auto;
|
|
margin-top: 0;
|
|
background-color: transparent;
|
|
border: 0;
|
|
box-shadow: none;
|
|
}
|
|
.navbar-nav .open .dropdown-menu > li > a {
|
|
padding: 10px 15px 10px 35px;
|
|
color: #777;
|
|
}
|
|
}
|
|
|
|
/* Desktop styles */
|
|
@media (min-width: 768px) {
|
|
.mobile-welcome,
|
|
.mobile-profile {
|
|
display: none !important; /* hide mobile items in desktop */
|
|
}
|
|
.desktop-welcome {
|
|
display: inline-block;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<!-- nav start -->
|
|
<nav class="navbar navbar-default">
|
|
<div class="container-fluid">
|
|
<div class="navbar-header">
|
|
<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="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
|
|
<!-- Mobile profile + welcome -->
|
|
<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>
|
|
</div>
|
|
|
|
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
|
<ul class="nav navbar-nav">
|
|
<?php
|
|
$userType = $_SESSION['type'] ?? '';
|
|
|
|
if ($userType === 'admin' || $userType === 'bm') {
|
|
?>
|
|
<!-- Create New Dropdown Menu -->
|
|
<li class="dropdown">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
|
Create New <span class="caret"></span>
|
|
</a>
|
|
<ul class="dropdown-menu" role="menu">
|
|
<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 role="separator" class="divider"></li>
|
|
<li><a href="/Admin/Add_group">Add New Group</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="/Admin/View_AC?Type=Recurring">View A/C</a></li>
|
|
<!-- Other menu items -->
|
|
<li><a href="/Admin/Trans_New">Transaction</a></li>
|
|
<?php if ($userType === 'admin') { ?>
|
|
<li><a href="/Admin/agent-targets">Agent Targets</a></li>
|
|
<?php } ?>
|
|
<li><a href="/Admin/agent_View_report">Commission</a></li>
|
|
<?php if ($userType === 'admin') { ?>
|
|
<li><a href="/Admin/View_AC?Type=Recurring">View A/C</a></li>
|
|
<?php } ?>
|
|
<li><a href="/Admin/upcoming-maturity">Upcoming Maturity</a></li>
|
|
<?php if ($userType === 'admin') { ?>
|
|
<li><a href="/Admin/Report">Report</a></li>
|
|
<li><a href="/Admin/Due">Deemand Sheet</a></li>
|
|
<li><a href="/Admin/Settings_Agent">Agent Settings</a></li>
|
|
<?php } ?>
|
|
<?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>
|
|
|
|
<!-- Desktop right side -->
|
|
<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-profile">
|
|
<?php
|
|
if (!empty($_SESSION['profile_pic'])) {
|
|
$profilePicPath = '/CONTENT/ROOT_URI/Admin/' . $_SESSION['profile_pic'];
|
|
echo '<img src="' . htmlspecialchars($profilePicPath) . '" width="40" height="40" style="border-radius:50%; object-fit:cover;" alt="Profile" onerror="this.replaceWith(this.nextElementSibling.cloneNode(true))" />';
|
|
}
|
|
|
|
// Default SVG (always output but initially hidden)
|
|
echo '<svg style="border-radius:50%; object-fit:cover; border: 1px solid #ffffff; display: ' .
|
|
(empty($_SESSION['profile_pic']) ? 'block' : 'none') . ';"
|
|
class="img-responsive" version="1.1" width="38px" height="38px"
|
|
viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"
|
|
fill="#ffffff" stroke="#ffffff">
|
|
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
|
|
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
|
|
<g id="SVGRepo_iconCarrier">
|
|
<path fill="#ffffff" d="M628.736 528.896A416 416 0 0 1 928 928H96a415.872 415.872 0 0 1 299.264-399.104L512 704l116.736-175.104zM720 304a208 208 0 1 1-416 0 208 208 0 0 1 416 0z"></path>
|
|
</g>
|
|
</svg>';
|
|
?>
|
|
</li>
|
|
<li><a href="/Admin/Signout">Signout</a></li>
|
|
<li>
|
|
<a href="/Admin/notification" style="position: relative; display: inline-block; padding: 8px;">
|
|
<?php if($pendingCount > 0) { ?>
|
|
<div style="width: 18px; height: 18px; border-radius: 50%; background-color: #ff4444; position: absolute; top: 2px; right: 2px; z-index: 10; box-shadow: 0 0 0 2px rgba(255,255,255,0.8); font-size: 11px; font-weight: bold; color: white; text-align: center; line-height: 18px;">
|
|
<?= $pendingCount > 99 ? '99+' : $pendingCount ?>
|
|
</div>
|
|
<?php } ?>
|
|
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 64 64" fill="#4a5568" style="filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));">
|
|
<g>
|
|
<path fill="currentColor" d="M56,44c-1.832,0-4-2.168-4-4V20C52,8.973,43.027,0,32,0S12,8.973,12,20v20c0,1.793-2.207,4-4,4 c-2.211,0-4,1.789-4,4s1.789,4,4,4h48c2.211,0,4-1.789,4-4S58.211,44,56,44z"></path>
|
|
<path fill="currentColor" d="M32,64c4.418,0,8-3.582,8-8H24C24,60.418,27.582,64,32,64z"></path>
|
|
</g>
|
|
</svg>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|