s2
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// ---- শুধুমাত্র Admin হলে Agent dropdown দেখানো হবে ----
|
// ---- if Admin then Agent dropdown and filter with agent----
|
||||||
if($_SESSION['type'] === 'admin'){
|
if($_SESSION['type'] === 'admin'){
|
||||||
$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);
|
||||||
@@ -84,11 +84,12 @@ function report_view($type, $dt) {
|
|||||||
<thead class="table-light">
|
<thead class="table-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Transaction ID</th>
|
<th>Transaction ID</th>
|
||||||
<th>Agent</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>
|
||||||
<th>Amount</th>
|
<th>Amount</th>
|
||||||
|
'.($_SESSION['type'] === 'admin' ? "<th>Remarks</th>" : "").'
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>';
|
<tbody>';
|
||||||
@@ -96,12 +97,12 @@ function report_view($type, $dt) {
|
|||||||
// ----- base query -----
|
// ----- 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'";
|
$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'";
|
||||||
|
|
||||||
// ----- agent হলে নিজের report -----
|
// ----- individual agent report -----
|
||||||
if($_SESSION['type'] === 'agent') {
|
if($_SESSION['type'] === 'agent') {
|
||||||
$sql .= " AND `AA_AGENT`='".$_SESSION['user_id']."'";
|
$sql .= " AND `AA_AGENT`='".$_SESSION['user_id']."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- admin হলে filter option -----
|
// ----- if admin filter option -----
|
||||||
if($_SESSION['type'] === 'admin' && isset($_GET['agent']) && $_GET['agent']!="") {
|
if($_SESSION['type'] === 'admin' && isset($_GET['agent']) && $_GET['agent']!="") {
|
||||||
$agentId = $conn->real_escape_string($_GET['agent']);
|
$agentId = $conn->real_escape_string($_GET['agent']);
|
||||||
$sql .= " AND `AA_AGENT`='".$agentId."'";
|
$sql .= " AND `AA_AGENT`='".$agentId."'";
|
||||||
@@ -113,14 +114,15 @@ function report_view($type, $dt) {
|
|||||||
if ($result && $result->num_rows > 0) {
|
if ($result && $result->num_rows > 0) {
|
||||||
while($row = $result->fetch_assoc()) {
|
while($row = $result->fetch_assoc()) {
|
||||||
echo "
|
echo "
|
||||||
<tr>
|
<tr>
|
||||||
<td>".$row["AT_ID"]."</td>
|
<td>".$row["AT_ID"]."</td>
|
||||||
<td>".$row["AA_AGENT"]."</td>
|
".($_SESSION['type'] === 'admin' ? "<td>".$row["AA_AGENT"]."</td>" : "")."
|
||||||
<td>".$row["AT_TIMESTAMP"]."</td>
|
<td>".$row["AT_TIMESTAMP"]."</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>";
|
".($_SESSION['type'] === 'admin' ? "<td style='font-size: 12px;'>".($row["REMARKS"] ?? '')."</td>" : "")."
|
||||||
|
</tr>";
|
||||||
$totalAmount += $row["AT_AMOUNT"];
|
$totalAmount += $row["AT_AMOUNT"];
|
||||||
$rowsData[] = [$row["AT_ID"], $row["AT_TIMESTAMP"], $row["AT_ACID"], $row["AA_NAME"], $row["AT_AMOUNT"]];
|
$rowsData[] = [$row["AT_ID"], $row["AT_TIMESTAMP"], $row["AT_ACID"], $row["AA_NAME"], $row["AT_AMOUNT"]];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,14 +263,14 @@ if ($_SESSION['type'] === 'admin' && isset($_GET["no"]) && isset($_GET["type"])
|
|||||||
$userType = 'admin';
|
$userType = 'admin';
|
||||||
|
|
||||||
// Entry 1: Deduction from recurring
|
// Entry 1: Deduction from recurring
|
||||||
$remarksText1 = "Deducted ₹$loanEMIAmount from recurring balance to pay Loan Account No: $paidToLoanAccountNumber EMI";
|
$remarksText1 = "₹$loanEMIAmount deducted from Recurring for Loan A/c $paidToLoanAccountNumber EMI";
|
||||||
$stmt = $conn->prepare("INSERT INTO `$table` (AT_ADMIN, AT_ACID, AT_AMOUNT, REMARKS) VALUES (?, ?, ?, ?)");
|
$stmt = $conn->prepare("INSERT INTO `$table` (AT_ADMIN, AT_ACID, AT_AMOUNT, REMARKS) VALUES (?, ?, ?, ?)");
|
||||||
$stmt->bind_param("ssds", $userType, $accountId, $deductAmount, $remarksText1);
|
$stmt->bind_param("ssds", $userType, $accountId, $deductAmount, $remarksText1);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|
||||||
// Entry 2: Credit to loan account
|
// Entry 2: Credit to loan account
|
||||||
$remarksText2 = "Credited ₹$loanEMIAmount to Loan Account No: $paidToLoanAccountNumber EMI from recurring balance";
|
$remarksText2 = "₹$loanEMIAmount credited to Loan A/c $paidToLoanAccountNumber EMI (from Recurring $accountId)";
|
||||||
$stmt = $conn->prepare("INSERT INTO `$table` (AT_ADMIN, AT_ACID, AT_AMOUNT, REMARKS) VALUES (?, ?, ?, ?)");
|
$stmt = $conn->prepare("INSERT INTO `$table` (AT_ADMIN, AT_ACID, AT_AMOUNT, REMARKS) VALUES (?, ?, ?, ?)");
|
||||||
$stmt->bind_param("ssds", $userType, $paidToLoanAccountNumber, $loanEMIAmount, $remarksText2);
|
$stmt->bind_param("ssds", $userType, $paidToLoanAccountNumber, $loanEMIAmount, $remarksText2);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@@ -285,9 +285,7 @@ if ($_SESSION['type'] === 'admin' && isset($_GET["no"]) && isset($_GET["type"])
|
|||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|
||||||
// Update Recurring Account
|
// Update Recurring Account
|
||||||
$sql = "UPDATE `" . $GLOBALS['arif_ac'] . "`
|
$sql = "UPDATE `" . $GLOBALS['arif_ac'] . "` SET `AA_BAL` = `AA_BAL` - ? WHERE `AA_ACNO` = ?";
|
||||||
SET `AA_BAL` = `AA_BAL` - ?
|
|
||||||
WHERE `AA_ACNO` = ?";
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->bind_param("ds", $loanEMIAmount, $accountId);
|
$stmt->bind_param("ds", $loanEMIAmount, $accountId);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|||||||
Reference in New Issue
Block a user