fix bottom nav

This commit is contained in:
ns77@siliconpin.com
2025-09-08 15:27:37 +00:00
parent a7141792f9
commit ed0741cbb2
3 changed files with 78 additions and 22 deletions

View File

@@ -1,9 +1,10 @@
<?php <?php
// ---- Default date range ---- // ---- Default date range ----
$today = date("Y-m-d"); $today = date("Y-m-d");
$monthStart = date("Y-m-01"); $monthStart = date("Y-m-01");
$dFrom = $_GET['dFrom'] ?? $monthStart; $monthEnd = date("Y-m-t"); // Gets last day of current month (e.g., 2023-10-31)
$dTo = $_GET['dTo'] ?? $today; $dFrom = $_GET['dFrom'] ?? $monthStart;
$dTo = $_GET['dTo'] ?? $monthEnd;
?> ?>
<div class="container mt-4"> <div class="container mt-4">
@@ -37,7 +38,7 @@ function maturity_report($dateFrom, $dateTo) {
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
// ---- Next month maturity filter ---- // ---- 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"; $sql = "SELECT * FROM ".$GLOBALS['arif_ac']." WHERE DATE_FORMAT(AA_DATE_MATURE, '%Y-%m-%d') BETWEEN '".$dateFrom."' AND '".$dateTo."' AND AA_TYPE = 'Recurring' ORDER BY AA_DATE_MATURE ASC";
$result = $conn->query($sql); $result = $conn->query($sql);

View File

@@ -57,7 +57,7 @@
left: 0; left: 0;
right: 0; right: 0;
height: 55px; height: 55px;
/* margin-bottom: 50px; important for bottom nav in mobile */ margin-bottom: 50px; /*important for bottom nav in mobile */
background: #e95420; background: #e95420;
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
@@ -67,7 +67,7 @@
} }
/* important for bottom nav in mobile */ /* important for bottom nav in mobile */
/* .agent-bottom-nav::after { .agent-bottom-nav::after {
content: ""; content: "";
position: fixed; position: fixed;
bottom: 0; bottom: 0;
@@ -76,7 +76,7 @@
height: 50px; height: 50px;
background: black; background: black;
z-index: -1; z-index: -1;
} */ }
.agent-bottom-link { .agent-bottom-link {
color: #fff; color: #fff;
text-align: center; text-align: center;
@@ -124,7 +124,7 @@
</div> </div>
<!-- Some content --> <!-- Some content -->
<div style="margin-top:40px; padding:15px;"></div> <div style="margin-top:80px; padding:15px;"></div>
<!-- Bottom Navigation --> <!-- Bottom Navigation -->
<?php if(isset($_SESSION) && !empty($_SESSION['user_id'])){ ?> <?php if(isset($_SESSION) && !empty($_SESSION['user_id'])){ ?>

View File

@@ -1,11 +1,21 @@
<?php <?php
session_start(); session_start();
date_default_timezone_set('Asia/Kolkata'); // Display timezone Kolkata date_default_timezone_set('Asia/Kolkata');
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;
} }
// Set default date range: 1st of current month to today
$firstDayOfMonth = date('Y-m-01');
$today = date('Y-m-d');
$defaultFrom = $firstDayOfMonth;
$defaultTo = $today;
// Use submitted dates or defaults
$dFrom = $_GET['dFrom'] ?? $defaultFrom;
$dTo = $_GET['dTo'] ?? $defaultTo;
?> ?>
<!-- Generate Report Form --> <!-- Generate Report Form -->
@@ -15,14 +25,38 @@ if (!isset($_SESSION['user_id']) || empty($_SESSION['user_id'])) {
<form method="get" class="row g-3"> <form method="get" class="row g-3">
<div class="col-md-3"> <div class="col-md-3">
<label class="form-label">From</label> <label class="form-label">From</label>
<input value="<?= $_GET['dFrom'] ?? '' ?>" type="date" name="dFrom" class="form-control" required> <input value="<?= $dFrom ?>" type="date" name="dFrom" class="form-control" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label class="form-label">To</label> <label class="form-label">To</label>
<input value="<?= $_GET['dTo'] ?? '' ?>" type="date" name="dTo" class="form-control" required> <input value="<?= $dTo ?>" type="date" name="dTo" class="form-control" required>
</div> </div>
<div class="col-md-3 d-flex align-items-end" style="margin-top: 25px;"> <?php
// Show agent dropdown for admin users
if($_SESSION['type'] === 'admin'){
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
$agents = $conn->query("SELECT * FROM `".$GLOBALS['arif_users']."` WHERE `type`='agent' ORDER BY user_name ASC");
?>
<div class="col-md-3">
<label class="form-label">Agent</label>
<select name="agent" id="agent" class="form-control">
<option value="">-- All Agents --</option>
<?php
if($agents && $agents->num_rows > 0){
while($a = $agents->fetch_assoc()){
$selected = (isset($_GET['agent']) && $_GET['agent']==$a['user_id']) ? "selected" : "";
echo "<option value='".$a['user_id']."' $selected>".$a['user_name']." (".$a['user_id'].")</option>";
}
}
?>
</select>
</div>
<?php } ?>
<div class="col-md-3 d-flex align-items-end" style="margin-top: 25px; z-index: -1;">
<button type="submit" class="btn btn-info w-100">Generate Report</button> <button type="submit" class="btn btn-info w-100">Generate Report</button>
</div> </div>
</form> </form>
@@ -53,6 +87,7 @@ function report_view($fromDate, $toDate) {
<thead class="table-light"> <thead class="table-light">
<tr> <tr>
<th>Transaction ID</th> <th>Transaction ID</th>
'.($_SESSION['type'] === 'admin' ? "<th>Agent</th>" : "").'
<th>Time</th> <th>Time</th>
<th>AC No</th> <th>AC No</th>
<th>Name</th> <th>Name</th>
@@ -61,8 +96,22 @@ function report_view($fromDate, $toDate) {
</thead> </thead>
<tbody>'; <tbody>';
// Query: UTC in DB, filter by date // Base query
$sql = "SELECT t.*, a.AA_NAME FROM `".$GLOBALS['arif_tran']."` t INNER JOIN `".$GLOBALS['arif_ac']."` a ON t.AT_ACID = a.AA_ACNO WHERE t.AT_ADMIN = '".$_SESSION['user_id']."' AND DATE(CONVERT_TZ(t.AT_TIMESTAMP,'+00:00','+05:30')) BETWEEN '$fromDate' AND '$toDate' ORDER BY t.AT_ID DESC"; $sql = "SELECT t.*, a.AA_NAME, a.AA_AGENT
FROM `".$GLOBALS['arif_tran']."` t
INNER JOIN `".$GLOBALS['arif_ac']."` a ON t.AT_ACID = a.AA_ACNO
WHERE DATE(CONVERT_TZ(t.AT_TIMESTAMP,'+00:00','+05:30')) BETWEEN '$fromDate' AND '$toDate'";
// Add agent filter if admin has selected a specific agent
if ($_SESSION['type'] === 'admin' && isset($_GET['agent']) && !empty($_GET['agent'])) {
$agentId = $conn->real_escape_string($_GET['agent']);
$sql .= " AND a.AA_AGENT = '$agentId'";
} else if ($_SESSION['type'] === 'agent') {
// For agents, only show their own transactions - FIXED
$sql .= " AND a.AA_AGENT = '".$_SESSION['user_id']."'";
}
$sql .= " ORDER BY t.AT_ID DESC";
$result = $conn->query($sql); $result = $conn->query($sql);
@@ -73,7 +122,14 @@ function report_view($fromDate, $toDate) {
echo " echo "
<tr> <tr>
<td>".$row["AT_ID"]."</td> <td>".$row["AT_ID"]."</td>";
// Show agent column for admin
if ($_SESSION['type'] === 'admin') {
echo "<td>".$row["AA_AGENT"]."</td>";
}
echo "
<td>".$kolkataTime."</td> <td>".$kolkataTime."</td>
<td>".$row["AT_ACID"]."</td> <td>".$row["AT_ACID"]."</td>
<td>".$row["AA_NAME"]."</td> <td>".$row["AA_NAME"]."</td>
@@ -83,7 +139,7 @@ function report_view($fromDate, $toDate) {
$totalAmount += $row["AT_AMOUNT"]; $totalAmount += $row["AT_AMOUNT"];
} }
} else { } else {
echo "<tr><td colspan='5' class='text-center text-muted'>No results found</td></tr>"; echo "<tr><td colspan='".($_SESSION['type'] === 'admin' ? 6 : 5)."' class='text-center text-muted'>No results found</td></tr>";
} }
$conn->close(); $conn->close();
@@ -101,7 +157,6 @@ function report_view($fromDate, $toDate) {
} }
// ---- Call report function ---- // ---- Call report function ----
if(isset($_GET['dFrom'], $_GET['dTo']) && !empty($_GET['dFrom']) && !empty($_GET['dTo'])) { // Always show report with default or selected dates
report_view($_GET['dFrom'], $_GET['dTo']); report_view($dFrom, $dTo);
} ?>
?>