add time zome
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
include(__DIR__ . '/auth.php');
|
include(__DIR__ . '/auth.php');
|
||||||
require_login();
|
require_login();
|
||||||
|
date_default_timezone_set('Asia/Kolkata');
|
||||||
|
|
||||||
// Don't send ANY HTML or echo above this line
|
// Don't send ANY HTML or echo above this line
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
date_default_timezone_set('Asia/Kolkata');
|
||||||
|
?>
|
||||||
<style>
|
<style>
|
||||||
.agent-body {
|
.agent-body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
date_default_timezone_set('Asia/Kolkata'); // Display timezone 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;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<!-- Generate Report Form -->
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<div class="card shadow-lg p-4 rounded-3">
|
<div class="card shadow-lg p-4 rounded-3">
|
||||||
<h4 class="mb-3">Generate Report</h4>
|
<h4 class="mb-3">Generate Report</h4>
|
||||||
@@ -24,34 +29,18 @@ if (!isset($_SESSION['user_id']) || empty($_SESSION['user_id'])) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
function report_view($type, $dt) {
|
function report_view($fromDate, $toDate) {
|
||||||
$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>";
|
|
||||||
|
|
||||||
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||||
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
|
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;
|
$totalAmount = 0;
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
@@ -72,30 +61,31 @@ function report_view($type, $dt) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>';
|
<tbody>';
|
||||||
|
|
||||||
// ----- base query -----
|
// Query: UTC in DB, filter by date
|
||||||
$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'";
|
$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";
|
||||||
|
|
||||||
// ----- always agent filter -----
|
|
||||||
$sql .= " AND `AT_ADMIN`='".$_SESSION['user_id']."'";
|
|
||||||
|
|
||||||
$sql .= " ORDER BY `".$GLOBALS['arif_tran']."`.`AT_ID` DESC";
|
|
||||||
|
|
||||||
$result = $conn->query($sql);
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
if ($result && $result->num_rows > 0) {
|
if ($result && $result->num_rows > 0) {
|
||||||
while($row = $result->fetch_assoc()) {
|
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 "
|
echo "
|
||||||
<tr>
|
<tr>
|
||||||
<td>".$row["AT_ID"]."</td>
|
<td>".$row["AT_ID"]."</td>
|
||||||
<td>".$row["AT_TIMESTAMP"]."</td>
|
<td>".$kolkataTime."</td>
|
||||||
<td>".$row["AT_ACID"]."</td>
|
<td>".$row["AT_ACID"]."</td>
|
||||||
<td>".$row["AA_NAME"]."</td>
|
<td>".$row["AA_NAME"]."</td>
|
||||||
<td>".$row["AT_AMOUNT"]."</td>
|
<td>".$row["AT_AMOUNT"]."</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
$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='5' class='text-center text-muted'>No results found</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn->close();
|
$conn->close();
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
@@ -111,7 +101,7 @@ function report_view($type, $dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---- Call report function ----
|
// ---- Call report function ----
|
||||||
if(isset($_GET['tday']) && $_GET['tday']!="") report_view('day', $_GET['tday']);
|
if(isset($_GET['dFrom'], $_GET['dTo']) && !empty($_GET['dFrom']) && !empty($_GET['dTo'])) {
|
||||||
if(isset($_GET['tmonth']) && $_GET['tmonth']!="") report_view('month', $_GET['tmonth']);
|
report_view($_GET['dFrom'], $_GET['dTo']);
|
||||||
if(isset($_GET['dFrom']) && $_GET['dTo']!="") report_view($_GET['dTo'], $_GET['dFrom']);
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
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;
|
||||||
@@ -15,7 +17,8 @@ $result = $conn->query($sql);
|
|||||||
|
|
||||||
<div class="container" style="margin-top:80px;">
|
<div class="container" style="margin-top:80px;">
|
||||||
<h3>Transaction Records</h3>
|
<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">
|
<table class="table table-bordered table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -27,7 +30,7 @@ $result = $conn->query($sql);
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php while ($row = $result->fetch_assoc()): ?>
|
<?php while ($row = $result->fetch_assoc()): ?>
|
||||||
<tr>
|
<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_ACID']) ?></td>
|
||||||
<td><?= htmlspecialchars($row['AT_AMOUNT']) ?></td>
|
<td><?= htmlspecialchars($row['AT_AMOUNT']) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user