add time zome
parent
eec8d5c5c4
commit
88e8efa31f
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
include(__DIR__ . '/auth.php');
|
||||
require_login();
|
||||
date_default_timezone_set('Asia/Kolkata');
|
||||
|
||||
// Don't send ANY HTML or echo above this line
|
||||
?>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<?php
|
||||
date_default_timezone_set('Asia/Kolkata');
|
||||
?>
|
||||
<style>
|
||||
.agent-body {
|
||||
margin: 0;
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
<?php
|
||||
session_start();
|
||||
date_default_timezone_set('Asia/Kolkata'); // Display timezone Kolkata
|
||||
|
||||
if (!isset($_SESSION['user_id']) || empty($_SESSION['user_id'])) {
|
||||
echo "<script>window.location.href = '/Agent/agent-login'</script>";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Generate Report Form -->
|
||||
<div class="container mt-4">
|
||||
<div class="card shadow-lg p-4 rounded-3">
|
||||
<h4 class="mb-3">Generate Report</h4>
|
||||
|
@ -24,34 +29,18 @@ if (!isset($_SESSION['user_id']) || empty($_SESSION['user_id'])) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
function report_view($type, $dt) {
|
||||
$dateFrom = $dt;
|
||||
|
||||
if($type!="month" && $type!="day") {
|
||||
$dateFrom = strtotime($dt);
|
||||
$dateFrom = date("Y-m-d", $dateFrom);
|
||||
$dateTo = strtotime('+1 day', strtotime($type));
|
||||
$dateTo = date("Y-m-d", $dateTo);
|
||||
} else {
|
||||
if($type=="month") {
|
||||
$dateFrom = strtotime('-1 day', strtotime($dt));
|
||||
$dateFrom = date("Y-m-d", $dateFrom);
|
||||
}
|
||||
$dateTo = strtotime('+1 '.$type, strtotime($dt));
|
||||
$dateTo = date("Y-m-d", $dateTo);
|
||||
}
|
||||
|
||||
echo '<div class="container mt-4">
|
||||
<div class="alert alert-primary shadow-sm">
|
||||
<h5 class="mb-0">Report Period: '.$dateFrom." → ".$dateTo." (Up to)</h5>
|
||||
</div>
|
||||
</div>";
|
||||
|
||||
function report_view($fromDate, $toDate) {
|
||||
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
|
||||
|
||||
// Display alert for report period
|
||||
echo '<div class="container mt-4">
|
||||
<div class="alert alert-primary shadow-sm">
|
||||
<h5 class="mb-0">Report Period: '.$fromDate.' → '.$toDate.' (Up to)</h5>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
$totalAmount = 0;
|
||||
|
||||
echo '
|
||||
|
@ -72,30 +61,31 @@ function report_view($type, $dt) {
|
|||
</thead>
|
||||
<tbody>';
|
||||
|
||||
// ----- base query -----
|
||||
$sql = "SELECT * FROM `".$GLOBALS['arif_tran']."`INNER JOIN `".$GLOBALS['arif_ac']."`ON `".$GLOBALS['arif_tran']."`.`AT_ACID`=`".$GLOBALS['arif_ac']."`.`AA_ACNO` WHERE `AT_TIMESTAMP` BETWEEN '".$dateFrom." 00:00:00' AND '".$dateTo." 00:00:00'";
|
||||
|
||||
// ----- always agent filter -----
|
||||
$sql .= " AND `AT_ADMIN`='".$_SESSION['user_id']."'";
|
||||
|
||||
$sql .= " ORDER BY `".$GLOBALS['arif_tran']."`.`AT_ID` DESC";
|
||||
// Query: UTC in DB, filter by date
|
||||
$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";
|
||||
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result && $result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
// Convert UTC timestamp to Kolkata time
|
||||
$kolkataTime = date("d M Y, h:i A", strtotime($row["AT_TIMESTAMP"] . " +5 hours 30 minutes"));
|
||||
|
||||
echo "
|
||||
<tr>
|
||||
<td>".$row["AT_ID"]."</td>
|
||||
<td>".$row["AT_TIMESTAMP"]."</td>
|
||||
<td>".$kolkataTime."</td>
|
||||
<td>".$row["AT_ACID"]."</td>
|
||||
<td>".$row["AA_NAME"]."</td>
|
||||
<td>".$row["AT_AMOUNT"]."</td>
|
||||
</tr>";
|
||||
|
||||
$totalAmount += $row["AT_AMOUNT"];
|
||||
}
|
||||
} else {
|
||||
echo "<tr><td colspan='5' class='text-center text-muted'>No results found</td></tr>";
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
|
||||
echo '
|
||||
|
@ -111,7 +101,7 @@ function report_view($type, $dt) {
|
|||
}
|
||||
|
||||
// ---- Call report function ----
|
||||
if(isset($_GET['tday']) && $_GET['tday']!="") report_view('day', $_GET['tday']);
|
||||
if(isset($_GET['tmonth']) && $_GET['tmonth']!="") report_view('month', $_GET['tmonth']);
|
||||
if(isset($_GET['dFrom']) && $_GET['dTo']!="") report_view($_GET['dTo'], $_GET['dFrom']);
|
||||
if(isset($_GET['dFrom'], $_GET['dTo']) && !empty($_GET['dFrom']) && !empty($_GET['dTo'])) {
|
||||
report_view($_GET['dFrom'], $_GET['dTo']);
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
date_default_timezone_set('Asia/Kolkata');
|
||||
|
||||
if (!isset($_SESSION['user_id']) || empty($_SESSION['user_id'])) {
|
||||
echo "<script>window.location.href = '/Agent/agent-login'</script>";
|
||||
exit;
|
||||
|
@ -15,7 +17,8 @@ $result = $conn->query($sql);
|
|||
|
||||
<div class="container" style="margin-top:80px;">
|
||||
<h3>Transaction Records</h3>
|
||||
<?php if ($result && $result->num_rows > 0): ?>
|
||||
<?php if ($result && $result->num_rows > 0): ?>
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -27,7 +30,7 @@ $result = $conn->query($sql);
|
|||
<tbody>
|
||||
<?php while ($row = $result->fetch_assoc()): ?>
|
||||
<tr>
|
||||
<td><?= date("d M Y, h:i A", strtotime($row['AT_TIMESTAMP'])) ?></td>
|
||||
<td><?= date("d M Y, h:i A", strtotime($row['AT_TIMESTAMP'] . ' +5 hours 30 minutes')) ?></td>
|
||||
<td><?= htmlspecialchars($row['AT_ACID']) ?></td>
|
||||
<td><?= htmlspecialchars($row['AT_AMOUNT']) ?></td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue