From 04129226ec3850eebb08214939ca17c2574e2eb7 Mon Sep 17 00:00:00 2001 From: "ns77@siliconpin.com" Date: Mon, 1 Sep 2025 09:57:29 +0000 Subject: [PATCH] add agent panel --- .htpasswd | 2 - CONTENT/ROOT_URI/Agent/Agent_Header.php | 26 ++++ CONTENT/ROOT_URI/Agent/Agent_Nav.php | 112 ++++++++++++++++++ CONTENT/ROOT_URI/Agent/Dashboard.php | 103 ++++++++++++++++ CONTENT/ROOT_URI/Agent/Receive.php | 109 +++++++++++++++++ CONTENT/ROOT_URI/Agent/agent-login.php | 84 +++++++++++++ CONTENT/ROOT_URI/Agent/index.php | 14 +++ CONTENT/ROOT_URI/Agent/login_debug_log.txt | 9 ++ CONTENT/ROOT_URI/Agent/logout.php | 22 ++++ CONTENT/ROOT_URI/Agent/report.php | 111 +++++++++++++++++ CONTENT/ROOT_URI/Agent/transaction.php | 42 +++++++ CONTENT/ROOT_URI/exe/receive_amount/index.php | 2 +- 12 files changed, 633 insertions(+), 3 deletions(-) delete mode 100644 .htpasswd create mode 100644 CONTENT/ROOT_URI/Agent/Agent_Header.php create mode 100644 CONTENT/ROOT_URI/Agent/Agent_Nav.php create mode 100644 CONTENT/ROOT_URI/Agent/Dashboard.php create mode 100644 CONTENT/ROOT_URI/Agent/Receive.php create mode 100644 CONTENT/ROOT_URI/Agent/agent-login.php create mode 100644 CONTENT/ROOT_URI/Agent/index.php create mode 100644 CONTENT/ROOT_URI/Agent/login_debug_log.txt create mode 100644 CONTENT/ROOT_URI/Agent/logout.php create mode 100644 CONTENT/ROOT_URI/Agent/report.php create mode 100644 CONTENT/ROOT_URI/Agent/transaction.php diff --git a/.htpasswd b/.htpasswd deleted file mode 100644 index 461dc85..0000000 --- a/.htpasswd +++ /dev/null @@ -1,2 +0,0 @@ -seo:$apr1$X1Xy39UL$mxr5A27s3iyymTIAaAgzP/ - diff --git a/CONTENT/ROOT_URI/Agent/Agent_Header.php b/CONTENT/ROOT_URI/Agent/Agent_Header.php new file mode 100644 index 0000000..0f1d47b --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/Agent_Header.php @@ -0,0 +1,26 @@ + + + + Gramin Venture POS Portal + + + + + + + + + + + + + + diff --git a/CONTENT/ROOT_URI/Agent/Agent_Nav.php b/CONTENT/ROOT_URI/Agent/Agent_Nav.php new file mode 100644 index 0000000..edce758 --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/Agent_Nav.php @@ -0,0 +1,112 @@ + + +
+ + +
+
Agent Panel
+ + + +
+ + +
+ +
+ + + + + + + +
\ No newline at end of file diff --git a/CONTENT/ROOT_URI/Agent/Dashboard.php b/CONTENT/ROOT_URI/Agent/Dashboard.php new file mode 100644 index 0000000..ea68ef6 --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/Dashboard.php @@ -0,0 +1,103 @@ +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); +?> + + +
+

+ Welcome, 👋 +

+ +
+ +
+

+

Total Collection

+
+ + +
+ +
+
+ + + Recive New Payment + +
+ + diff --git a/CONTENT/ROOT_URI/Agent/Receive.php b/CONTENT/ROOT_URI/Agent/Receive.php new file mode 100644 index 0000000..1bce834 --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/Receive.php @@ -0,0 +1,109 @@ +
+

New Payment

+
+ + +
+ + + + + +
+ + diff --git a/CONTENT/ROOT_URI/Agent/agent-login.php b/CONTENT/ROOT_URI/Agent/agent-login.php new file mode 100644 index 0000000..f7697ba --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/agent-login.php @@ -0,0 +1,84 @@ +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 ""; + } else { + $error = "Invalid password."; + } + } else { + $error = "No agent account found with this User ID."; + } + + $stmt->close(); + } + } +} +?> + +
+
+
+
+

Agent Login

+ + +
+ +
+ + +
+
+ +
+
+ +
+ + +
+ +
+ +
+
+
+
+
diff --git a/CONTENT/ROOT_URI/Agent/index.php b/CONTENT/ROOT_URI/Agent/index.php new file mode 100644 index 0000000..010ee67 --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/index.php @@ -0,0 +1,14 @@ +"; + 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"); +?> diff --git a/CONTENT/ROOT_URI/Agent/login_debug_log.txt b/CONTENT/ROOT_URI/Agent/login_debug_log.txt new file mode 100644 index 0000000..5411250 --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/login_debug_log.txt @@ -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'. diff --git a/CONTENT/ROOT_URI/Agent/logout.php b/CONTENT/ROOT_URI/Agent/logout.php new file mode 100644 index 0000000..6a8f69f --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/logout.php @@ -0,0 +1,22 @@ +window.location.href='/Agent/agent-login'"; +// header("Location: login.php"); +exit; diff --git a/CONTENT/ROOT_URI/Agent/report.php b/CONTENT/ROOT_URI/Agent/report.php new file mode 100644 index 0000000..f1213e6 --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/report.php @@ -0,0 +1,111 @@ +
+
+

Generate Report

+
+
+ + +
+
+ + +
+ +
+ +
+
+
+
+ + + +
+
Report Period: '.$dateFrom." → ".$dateTo." (Up to)
+
+ "; + + $conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']); + if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); + + $totalAmount = 0; + + echo ' +
+
+
+
Transaction Report
+
+ + + + + + + + + + + '; + + // ----- 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 " + + + + + + + "; + $totalAmount += $row["AT_AMOUNT"]; + } + } else { + echo ""; + } + $conn->close(); + + echo ' + +
Transaction IDTimeAC NoNameAmount
".$row["AT_ID"]."".$row["AT_TIMESTAMP"]."".$row["AT_ACID"]."".$row["AA_NAME"]."".$row["AT_AMOUNT"]."
No results found
+
+
+
Total Transaction Amount : '.$totalAmount.'
+
+
+
+ '; +} + +// ---- 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']); +?> diff --git a/CONTENT/ROOT_URI/Agent/transaction.php b/CONTENT/ROOT_URI/Agent/transaction.php new file mode 100644 index 0000000..55812ca --- /dev/null +++ b/CONTENT/ROOT_URI/Agent/transaction.php @@ -0,0 +1,42 @@ +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); +?> + +
+

Transaction Records

+ num_rows > 0): ?> + + + + + + + + + + fetch_assoc()): ?> + + + + + + + +
TimestampACIDAmount
+ +
No record found
+ + + +
+ +close(); +?> diff --git a/CONTENT/ROOT_URI/exe/receive_amount/index.php b/CONTENT/ROOT_URI/exe/receive_amount/index.php index 8fc590b..cb29819 100644 --- a/CONTENT/ROOT_URI/exe/receive_amount/index.php +++ b/CONTENT/ROOT_URI/exe/receive_amount/index.php @@ -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"] . "'")); //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"] . "')")){ $total['status'] = 'Success'; $total['statusmsg'] = 'Transaction Successful! Rs. '.$_POST["add_i"];