s2
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// ---- শুধুমাত্র Admin হলে Agent dropdown দেখানো হবে ----
|
||||
// ---- if Admin then Agent dropdown and filter with agent----
|
||||
if($_SESSION['type'] === 'admin'){
|
||||
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
|
||||
@@ -84,11 +84,12 @@ function report_view($type, $dt) {
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Transaction ID</th>
|
||||
<th>Agent</th>
|
||||
'.($_SESSION['type'] === 'admin' ? "<th>Agent</th>" : "").'
|
||||
<th>Time</th>
|
||||
<th>AC No</th>
|
||||
<th>Name</th>
|
||||
<th>Amount</th>
|
||||
'.($_SESSION['type'] === 'admin' ? "<th>Remarks</th>" : "").'
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
@@ -96,12 +97,12 @@ function report_view($type, $dt) {
|
||||
// ----- 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'";
|
||||
|
||||
// ----- agent হলে নিজের report -----
|
||||
// ----- individual agent report -----
|
||||
if($_SESSION['type'] === 'agent') {
|
||||
$sql .= " AND `AA_AGENT`='".$_SESSION['user_id']."'";
|
||||
}
|
||||
|
||||
// ----- admin হলে filter option -----
|
||||
// ----- if admin filter option -----
|
||||
if($_SESSION['type'] === 'admin' && isset($_GET['agent']) && $_GET['agent']!="") {
|
||||
$agentId = $conn->real_escape_string($_GET['agent']);
|
||||
$sql .= " AND `AA_AGENT`='".$agentId."'";
|
||||
@@ -113,14 +114,15 @@ function report_view($type, $dt) {
|
||||
if ($result && $result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
echo "
|
||||
<tr>
|
||||
<td>".$row["AT_ID"]."</td>
|
||||
<td>".$row["AA_AGENT"]."</td>
|
||||
<td>".$row["AT_TIMESTAMP"]."</td>
|
||||
<td>".$row["AT_ACID"]."</td>
|
||||
<td>".$row["AA_NAME"]."</td>
|
||||
<td>".$row["AT_AMOUNT"]."</td>
|
||||
</tr>";
|
||||
<tr>
|
||||
<td>".$row["AT_ID"]."</td>
|
||||
".($_SESSION['type'] === 'admin' ? "<td>".$row["AA_AGENT"]."</td>" : "")."
|
||||
<td>".$row["AT_TIMESTAMP"]."</td>
|
||||
<td>".$row["AT_ACID"]."</td>
|
||||
<td>".$row["AA_NAME"]."</td>
|
||||
<td>".$row["AT_AMOUNT"]."</td>
|
||||
".($_SESSION['type'] === 'admin' ? "<td style='font-size: 12px;'>".($row["REMARKS"] ?? '')."</td>" : "")."
|
||||
</tr>";
|
||||
$totalAmount += $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';
|
||||
|
||||
// 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->bind_param("ssds", $userType, $accountId, $deductAmount, $remarksText1);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
// 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->bind_param("ssds", $userType, $paidToLoanAccountNumber, $loanEMIAmount, $remarksText2);
|
||||
$stmt->execute();
|
||||
@@ -285,9 +285,7 @@ if ($_SESSION['type'] === 'admin' && isset($_GET["no"]) && isset($_GET["type"])
|
||||
$stmt->close();
|
||||
|
||||
// Update Recurring Account
|
||||
$sql = "UPDATE `" . $GLOBALS['arif_ac'] . "`
|
||||
SET `AA_BAL` = `AA_BAL` - ?
|
||||
WHERE `AA_ACNO` = ?";
|
||||
$sql = "UPDATE `" . $GLOBALS['arif_ac'] . "` SET `AA_BAL` = `AA_BAL` - ? WHERE `AA_ACNO` = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ds", $loanEMIAmount, $accountId);
|
||||
$stmt->execute();
|
||||
|
||||
Reference in New Issue
Block a user