Merge pull request 'add agent panel' (#2) from copy_main into main
Reviewed-on: #2
This commit is contained in:
26
CONTENT/ROOT_URI/Agent/Agent_Header.php
Normal file
26
CONTENT/ROOT_URI/Agent/Agent_Header.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Gramin Venture POS Portal</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="/asset/css/bootstrap.min.css">
|
||||||
|
<script src="/asset/js/jquery.min.js"></script>
|
||||||
|
<script src="/asset/js/bootstrap.min.js"></script>
|
||||||
|
<script src="/asset/js/angular.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
|
||||||
|
<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>-->
|
||||||
|
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
112
CONTENT/ROOT_URI/Agent/Agent_Nav.php
Normal file
112
CONTENT/ROOT_URI/Agent/Agent_Nav.php
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<style>
|
||||||
|
.agent-body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
overflow-y: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Header/Navbar ===== */
|
||||||
|
.agent-header {
|
||||||
|
background: #e95420;
|
||||||
|
color: #fff;
|
||||||
|
padding: 30px 15px 12px 15px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
.agent-header-title {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.agent-header-logout {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Bottom Navigation ===== */
|
||||||
|
.agent-bottom-nav {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 55px;
|
||||||
|
background: #e95420;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: center;
|
||||||
|
border-top: 1px solid rgba(255,255,255,0.2);
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
.agent-bottom-link {
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
text-decoration: none;
|
||||||
|
flex: 1;
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
.agent-bottom-link i {
|
||||||
|
display: block;
|
||||||
|
font-size: 15px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
.agent-bottom-link.active {
|
||||||
|
background: rgba(255,255,255,0.2);
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="agent-body">
|
||||||
|
|
||||||
|
<!-- Top Header -->
|
||||||
|
<div class="agent-header">
|
||||||
|
<div class="agent-header-title">Agent Panel</div>
|
||||||
|
<?php if(isset($_SESSION) && !empty($_SESSION['user_id'])){ ?>
|
||||||
|
<button onclick="window.location.href='/Agent/logout'" class="agent-header-logout">Logout</button>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Some content -->
|
||||||
|
<div style="margin-top:20px; padding:15px;">
|
||||||
|
<!-- Dashboard Content -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Bottom Navigation -->
|
||||||
|
<?php if(isset($_SESSION) && !empty($_SESSION['user_id'])){ ?>
|
||||||
|
<div class="agent-bottom-nav">
|
||||||
|
<a href="/Agent/Dashboard" class="agent-bottom-link active">
|
||||||
|
<i class="fa-solid fa-house"></i>
|
||||||
|
Home
|
||||||
|
</a>
|
||||||
|
<a href="/Agent/report" class="agent-bottom-link">
|
||||||
|
<i class="fa-solid fa-chart-line"></i>
|
||||||
|
Reports
|
||||||
|
</a>
|
||||||
|
<a href="/Agent/Receive" class="agent-bottom-link" style="">
|
||||||
|
<i class="fa-solid fa-plus"></i>
|
||||||
|
Payment
|
||||||
|
</a>
|
||||||
|
<a href="/Agent/transaction" class="agent-bottom-link">
|
||||||
|
<i class="fa-solid fa-money-check-dollar"></i>
|
||||||
|
Transaction
|
||||||
|
</a>
|
||||||
|
<!-- <a href="javascript:void(0)" onclick="window.location.reload();" class="agent-bottom-link">
|
||||||
|
<i class="fa-solid fa-rotate-right"></i>
|
||||||
|
Reload
|
||||||
|
</a> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
103
CONTENT/ROOT_URI/Agent/Dashboard.php
Normal file
103
CONTENT/ROOT_URI/Agent/Dashboard.php
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function getTotalAmount(array $rows): float {
|
||||||
|
// array_column diye sudhu AT_AMOUNT gulo niye ashbo
|
||||||
|
$amounts = array_column($rows, 'AT_AMOUNT');
|
||||||
|
|
||||||
|
// jodi kono data na thake tahole 0 return hobe
|
||||||
|
return array_sum($amounts);
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$today = date("Y-m-d");
|
||||||
|
|
||||||
|
// query
|
||||||
|
$sql = "SELECT * FROM {$GLOBALS['arif_tran']} WHERE AT_ADMIN = '{$_SESSION['user_id']}' AND DATE(AT_TIMESTAMP) = '$today'";
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
|
// direct fetch_all
|
||||||
|
$rows = $result ? $result->fetch_all(MYSQLI_ASSOC) : [];
|
||||||
|
$totalAmount = getTotalAmount($rows);
|
||||||
|
// var_dump($rows); // ekhane pura array peye jabe
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
// var_dump($_SESSION);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h3 style="font-size: 20px; font-weight: 600; margin-bottom: 15px;">
|
||||||
|
Welcome, <?= $_SESSION['name'] ?> 👋
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="dashboard-total-section">
|
||||||
|
<!-- Total Collection Card -->
|
||||||
|
<div class="card-box highlight">
|
||||||
|
<h3><?= $totalAmount ?></h3>
|
||||||
|
<p>Total Collection</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Loan & Recurring Card -->
|
||||||
|
<div class="card-box normal">
|
||||||
|
<!-- <p><strong>Loan:</strong> <?= $totalLoan ?? 0 ?></p>
|
||||||
|
<p><strong>Recurring:</strong> <?= $totalRecurring ?? 0 ?></p> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a class="btn btn-primary w-100" href="/Agent/Receive" style="width: 100%; margin-top: 20px;">
|
||||||
|
<i class="fa-solid fa-credit-card"></i>
|
||||||
|
Recive New Payment
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.dashboard-total-section {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-box {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 180px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0 4px 10px rgba(0,0,0,0.08);
|
||||||
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-box:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 6px 16px rgba(0,0,0,0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-box h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-box p {
|
||||||
|
margin: 5px 0 0;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-box.highlight {
|
||||||
|
background: #e95420;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-box.highlight h3,
|
||||||
|
.card-box.highlight p {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
109
CONTENT/ROOT_URI/Agent/Receive.php
Normal file
109
CONTENT/ROOT_URI/Agent/Receive.php
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<div class="container">
|
||||||
|
<h3 class="">New Payment</h3>
|
||||||
|
<div style="display: flex; gap: 20px; flex-direction: row;">
|
||||||
|
<input class="form-control" type="text" id="acno" placeholder="Enter Account No" />
|
||||||
|
<button class="btn btn-primary" onclick="getAccountDetails()">Next <i class="fa-solid fa-arrow-right"></i></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- User Friendly Message -->
|
||||||
|
<div id="userMessage" style="margin-top:10px; display:none; padding:10px; border-radius:5px;"></div>
|
||||||
|
|
||||||
|
<form id="PAYMENT_RECEIVE_FORM" action="" method="post" style="display: none;">
|
||||||
|
<input id="ACCOUNT_NUMBER" name="AA_ACNO" class="form-control" type="hidden" />
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="ACCOUNT_HOLDER_NAME">Account Holder Name: </label>
|
||||||
|
<input id="ACCOUNT_HOLDER_NAME" class="form-control" type="text" placeholder="" readonly />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="INSTALLMENT_AMOUNT">Amount: </label>
|
||||||
|
<input id="INSTALLMENT_AMOUNT" name="add_i" class="form-control" type="text" placeholder="" />
|
||||||
|
</div>
|
||||||
|
<input class="btn btn-primary" type="submit" value="Receive Now" style="margin-top: 20px;" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function showMessage(msg, type = "success") {
|
||||||
|
let box = document.getElementById("userMessage");
|
||||||
|
box.style.display = "block";
|
||||||
|
box.innerText = msg;
|
||||||
|
|
||||||
|
if (type === "success") {
|
||||||
|
box.style.background = "#d4edda";
|
||||||
|
box.style.color = "#155724";
|
||||||
|
box.style.border = "1px solid #c3e6cb";
|
||||||
|
} else {
|
||||||
|
box.style.background = "#f8d7da";
|
||||||
|
box.style.color = "#721c24";
|
||||||
|
box.style.border = "1px solid #f5c6cb";
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
box.style.display = "none";
|
||||||
|
}, 4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAccountDetails() {
|
||||||
|
let acno = document.getElementById("acno").value;
|
||||||
|
|
||||||
|
fetch("/exe/get-loan-details/", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||||
|
body: "AA_ACNO=" + encodeURIComponent(acno)
|
||||||
|
})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log("Response from get-loan-details:", data);
|
||||||
|
|
||||||
|
if (data.status === "Success") {
|
||||||
|
document.getElementById("PAYMENT_RECEIVE_FORM").style.display = "block";
|
||||||
|
document.getElementById("ACCOUNT_NUMBER").value = data.data[0].AA_ACNO;
|
||||||
|
document.getElementById("ACCOUNT_HOLDER_NAME").value = data.data[0].AA_NAME;
|
||||||
|
document.getElementById("INSTALLMENT_AMOUNT").value = data.data[0].AA_INSTALLMENT;
|
||||||
|
|
||||||
|
showMessage("Account found: " + data.data[0].AA_NAME, "success");
|
||||||
|
} else {
|
||||||
|
showMessage(data.statusmsg, "error");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error("Fetch error in getAccountDetails:", err);
|
||||||
|
showMessage("Something went wrong while fetching details.", "error");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach form submit properly
|
||||||
|
document.getElementById("PAYMENT_RECEIVE_FORM").addEventListener("submit", function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var XHR = new XMLHttpRequest();
|
||||||
|
var FD = new FormData(this);
|
||||||
|
|
||||||
|
console.log("Sending FormData to /exe/receive_amount/:", Object.fromEntries(FD.entries()));
|
||||||
|
|
||||||
|
XHR.addEventListener("load", function (event) {
|
||||||
|
try {
|
||||||
|
var obj = JSON.parse(event.target.responseText);
|
||||||
|
console.log("Response from receive_amount:", obj);
|
||||||
|
|
||||||
|
showMessage(obj.statusmsg, obj.status === "Success" ? "success" : "error");
|
||||||
|
|
||||||
|
if (obj.status === "Success") {
|
||||||
|
setTimeout(() => window.history.back(), 2000);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error parsing JSON response:", e, event.target.responseText);
|
||||||
|
showMessage("Invalid response from server.", "error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
XHR.addEventListener("error", function () {
|
||||||
|
console.error("XHR request failed");
|
||||||
|
showMessage("Ooops!! Something went wrong.", "error");
|
||||||
|
});
|
||||||
|
|
||||||
|
XHR.open("POST", "/exe/receive_amount/");
|
||||||
|
XHR.send(FD);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
84
CONTENT/ROOT_URI/Agent/agent-login.php
Normal file
84
CONTENT/ROOT_URI/Agent/agent-login.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$table_users = $GLOBALS['arif_users'];
|
||||||
|
|
||||||
|
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Handle form submission
|
||||||
|
$error = '';
|
||||||
|
$success = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
|
||||||
|
$userId = trim($_POST['user_id'] ?? '');
|
||||||
|
$password = $_POST['pwd'] ?? '';
|
||||||
|
|
||||||
|
if (empty($userId) || empty($password)) {
|
||||||
|
$error = "Please fill in all fields.";
|
||||||
|
} else {
|
||||||
|
$stmt = $conn->prepare("SELECT * FROM $table_users WHERE user_id = ? AND type = 'agent'");
|
||||||
|
if (!$stmt) {
|
||||||
|
$error = "Internal server error.";
|
||||||
|
} else {
|
||||||
|
$stmt->bind_param("s", $userId);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
if ($result->num_rows === 1) {
|
||||||
|
$user = $result->fetch_assoc();
|
||||||
|
|
||||||
|
if (password_verify($password, $user['password'])) {
|
||||||
|
$_SESSION['user_id'] = $user['user_id'];
|
||||||
|
$_SESSION['type'] = $user['type'];
|
||||||
|
$_SESSION['name'] = $user['user_name'];
|
||||||
|
|
||||||
|
$success = "Login successful. Redirecting...";
|
||||||
|
echo "<script>setTimeout(() => { window.location.href = '/Agent/Dashboard'; }, 1000);</script>";
|
||||||
|
} else {
|
||||||
|
$error = "Invalid password.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "No agent account found with this User ID.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="bg-gradient mx-auto" style="">
|
||||||
|
<div class="container py-5 mx-auto" style="max-width: 420px; margin-top: 200px;">
|
||||||
|
<div class="mx-auto" style="">
|
||||||
|
<div class="card shadow-lg border-0 rounded-4 p-4" style="background: linear-gradient(135deg, #f5f7fa, #d9dce0ff); padding: 20px; border-radius: 15px;">
|
||||||
|
<h4 class="text-center mb-4 fw-semibold text-primary">Agent Login</h4>
|
||||||
|
|
||||||
|
<?php if ($error): ?>
|
||||||
|
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
|
||||||
|
<?php elseif ($success): ?>
|
||||||
|
<div class="alert alert-success"><?= htmlspecialchars($success) ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form method="post" autocomplete="off" style="display: flex; flex-direction: column; gap: 20px;">
|
||||||
|
<div class="mb-3">
|
||||||
|
<input type="text" class="form-control rounded-3 shadow-sm" id="user_id" name="user_id" placeholder="Enter your Agent ID" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<input type="password" class="form-control rounded-3 shadow-sm" id="pwd" name="pwd" placeholder="Enter your password" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-md btn-primary w-100">Login</button>
|
||||||
|
<!-- <div class="w-100"></div> -->
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="text-center mt-3">
|
||||||
|
<!-- Optional: Forgot password link -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
14
CONTENT/ROOT_URI/Agent/index.php
Normal file
14
CONTENT/ROOT_URI/Agent/index.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
include("CONFIG/config-local.php");
|
||||||
|
$lnk2 = explode('?', $lnk);
|
||||||
|
include("Agent_Header.php");
|
||||||
|
include("Agent_Nav.php");
|
||||||
|
|
||||||
|
echo "<br>";
|
||||||
|
if($lnk=="") include("home.php");
|
||||||
|
elseif(file_exists(__DIR__."/".$lnk.".php")) include($lnk.".php");
|
||||||
|
elseif(isset($lnk2[1]) && file_exists(__DIR__."/".$lnk2[0].".php") ) include($lnk2[0].".php");
|
||||||
|
else include("404.php");
|
||||||
|
|
||||||
|
include("ADMIN_FOOTER.php");
|
||||||
|
?>
|
||||||
9
CONTENT/ROOT_URI/Agent/login_debug_log.txt
Normal file
9
CONTENT/ROOT_URI/Agent/login_debug_log.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[2025-09-01 09:42:38] Form submitted.
|
||||||
|
[2025-09-01 09:42:38] Received credentials - UserID: 'grafin007@email.com'
|
||||||
|
[2025-09-01 09:42:38] Login success for agent 'grafin007@email.com'.
|
||||||
|
[2025-09-01 09:43:04] Form submitted.
|
||||||
|
[2025-09-01 09:43:04] Received credentials - UserID: 'grafin007@email.com'
|
||||||
|
[2025-09-01 09:43:04] Login success for agent 'grafin007@email.com'.
|
||||||
|
[2025-09-01 09:44:03] Form submitted.
|
||||||
|
[2025-09-01 09:44:03] Received credentials - UserID: 'grafin007@email.com'
|
||||||
|
[2025-09-01 09:44:03] Login success for agent 'grafin007@email.com'.
|
||||||
22
CONTENT/ROOT_URI/Agent/logout.php
Normal file
22
CONTENT/ROOT_URI/Agent/logout.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$_SESSION = [];
|
||||||
|
|
||||||
|
if (ini_get("session.use_cookies")) {
|
||||||
|
$params = session_get_cookie_params();
|
||||||
|
setcookie(
|
||||||
|
session_name(),
|
||||||
|
'',
|
||||||
|
time() - 42000,
|
||||||
|
$params["path"],
|
||||||
|
$params["domain"],
|
||||||
|
$params["secure"],
|
||||||
|
$params["httponly"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
session_destroy();
|
||||||
|
echo "<script>window.location.href='/Agent/agent-login'</script>";
|
||||||
|
// header("Location: login.php");
|
||||||
|
exit;
|
||||||
111
CONTENT/ROOT_URI/Agent/report.php
Normal file
111
CONTENT/ROOT_URI/Agent/report.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<div class="container mt-4">
|
||||||
|
<div class="card shadow-lg p-4 rounded-3">
|
||||||
|
<h4 class="mb-3">Generate Report</h4>
|
||||||
|
<form method="get" class="row g-3">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label class="form-label">From</label>
|
||||||
|
<input value="<?= $_GET['dFrom'] ?? '' ?>" type="date" name="dFrom" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label class="form-label">To</label>
|
||||||
|
<input value="<?= $_GET['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 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>";
|
||||||
|
|
||||||
|
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||||
|
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
|
||||||
|
|
||||||
|
$totalAmount = 0;
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<div class="container mt-3">
|
||||||
|
<div class="card shadow-sm rounded-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="mb-3">Transaction Report</h5>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered table-hover align-middle" id="reportTable" style="font-size: 12px;">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Transaction ID</th>
|
||||||
|
<th>Time</th>
|
||||||
|
<th>AC No</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Amount</th>
|
||||||
|
</tr>
|
||||||
|
</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";
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
if ($result && $result->num_rows > 0) {
|
||||||
|
while($row = $result->fetch_assoc()) {
|
||||||
|
echo "
|
||||||
|
<tr>
|
||||||
|
<td>".$row["AT_ID"]."</td>
|
||||||
|
<td>".$row["AT_TIMESTAMP"]."</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 '
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<h5 class="text-end">Total Transaction Amount : <b>'.$totalAmount.'</b></h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- 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']);
|
||||||
|
?>
|
||||||
42
CONTENT/ROOT_URI/Agent/transaction.php
Normal file
42
CONTENT/ROOT_URI/Agent/transaction.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM `" . $GLOBALS['arif_tran'] . "`WHERE `AT_ADMIN` = '" . $conn->real_escape_string($_SESSION['user_id']) . "'AND DATE(`AT_TIMESTAMP`) = CURDATE()";
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container" style="margin-top:80px;">
|
||||||
|
<h3>Transaction Records</h3>
|
||||||
|
<?php if ($result && $result->num_rows > 0): ?>
|
||||||
|
<table class="table table-bordered table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Timestamp</th>
|
||||||
|
<th>ACID</th>
|
||||||
|
<th>Amount</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php while ($row = $result->fetch_assoc()): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= date("d M Y, h:i A", strtotime($row['AT_TIMESTAMP'])) ?></td>
|
||||||
|
<td><?= htmlspecialchars($row['AT_ACID']) ?></td>
|
||||||
|
<td><?= htmlspecialchars($row['AT_AMOUNT']) ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endwhile; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="alert alert-warning">No record found</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- <a class="btn btn-primary" href="/Agent/Receive">Receive Payment</a> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$conn->close();
|
||||||
|
?>
|
||||||
@@ -13,7 +13,7 @@ if (isset($_POST["add_i"]) && isset($_POST["AA_ACNO"]) && is_numeric($_POST["add
|
|||||||
if ($conn->query("UPDATE `" . $GLOBALS['arif_ac'] . "` SET `AA_FINE` = `AA_FINE` + 5, `AA_BAL` = `AA_BAL`+".$_POST["add_i"]." , `AA_NO_OF_PAYPAID` = `AA_NO_OF_PAYPAID`+".$ins_no." WHERE `AA_ACNO` = '" . $_POST["AA_ACNO"] . "'"));
|
if ($conn->query("UPDATE `" . $GLOBALS['arif_ac'] . "` SET `AA_FINE` = `AA_FINE` + 5, `AA_BAL` = `AA_BAL`+".$_POST["add_i"]." , `AA_NO_OF_PAYPAID` = `AA_NO_OF_PAYPAID`+".$ins_no." WHERE `AA_ACNO` = '" . $_POST["AA_ACNO"] . "'"));
|
||||||
//Add entry to Transaction
|
//Add entry to Transaction
|
||||||
{
|
{
|
||||||
$AT_USER = $_SESSION['EMAIL'];
|
$AT_USER = $_SESSION['user_id'];
|
||||||
if ($conn->query("INSERT INTO `" . $GLOBALS['arif_tran'] . "` (`AT_ID`, `AT_TIMESTAMP`, `AT_ADMIN`, `AT_ACID`, `AT_AMOUNT`) VALUES (NULL, CURRENT_TIMESTAMP, '" . $AT_USER . "', '" . $_POST["AA_ACNO"] . "', '" . $_POST["add_i"] . "')")){
|
if ($conn->query("INSERT INTO `" . $GLOBALS['arif_tran'] . "` (`AT_ID`, `AT_TIMESTAMP`, `AT_ADMIN`, `AT_ACID`, `AT_AMOUNT`) VALUES (NULL, CURRENT_TIMESTAMP, '" . $AT_USER . "', '" . $_POST["AA_ACNO"] . "', '" . $_POST["add_i"] . "')")){
|
||||||
$total['status'] = 'Success';
|
$total['status'] = 'Success';
|
||||||
$total['statusmsg'] = 'Transaction Successful! Rs. '.$_POST["add_i"];
|
$total['statusmsg'] = 'Transaction Successful! Rs. '.$_POST["add_i"];
|
||||||
|
|||||||
Reference in New Issue
Block a user