implemented admin or bm approval functionality

This commit is contained in:
ns77@siliconpin.com
2025-09-10 13:57:41 +00:00
parent 4a1128066d
commit 5a12de1c64
8 changed files with 2293 additions and 65 deletions

View File

@@ -215,14 +215,10 @@ function calculateAmount() {
}
?>
<?php
if ($_SESSION['type'] === 'admin' && isset($_GET["no"]) && isset($_GET["type"]) && $_GET["type"] == "Recurring") {
if (
$_SERVER['REQUEST_METHOD'] === 'POST'
&& isset($_POST['PAY_LOAN_EMI_FROM_RECURRING'], $_POST['PAY_LOAN_EMI_FROM_RECURRING_ID'], $_POST['DEDUCT_LOAN_AMOUNT'])
&& $_POST['PAY_LOAN_EMI_FROM_RECURRING_ID'] === 'axakassaoxnnxsaoij34866'
) {
if ($_SESSION['type'] === 'admin' || $_SESSION['type'] === 'bm' && isset($_GET["no"]) && isset($_GET["type"]) && $_GET["type"] == "Recurring") {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['PAY_LOAN_EMI_FROM_RECURRING'], $_POST['PAY_LOAN_EMI_FROM_RECURRING_ID'], $_POST['DEDUCT_LOAN_AMOUNT']) && $_POST['PAY_LOAN_EMI_FROM_RECURRING_ID'] === 'axakassaoxnnxsaoij34866') {
$loanEMIAmount = floatval($_POST['DEDUCT_LOAN_AMOUNT']);
$deductAmount = -$loanEMIAmount; // negative for recurring deduction
$deductAmount = $loanEMIAmount; // negative for recurring deduction
$paidToLoanAccountNumber = $_POST['LOAN_AC_NUMBER'];
$accountId = $_GET['no'];
@@ -259,35 +255,20 @@ if ($_SESSION['type'] === 'admin' && isset($_GET["no"]) && isset($_GET["type"])
$conn->begin_transaction();
try {
$table = $GLOBALS['arif_tran'] ?? 'arif_tran';
$userType = 'admin';
// $table = $GLOBALS['arif_tran'] ?? 'arif_tran';
$table = 'fund_trans';
$requestBy = $_SESSION['user_id'];
$requestUSRType = $_SESSION['type'];
$recACNumber = $accountId;
$loanACNumber = $paidToLoanAccountNumber;
$transferAmount = $deductAmount;
// Entry 1: Deduction from recurring
$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 = "₹$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();
$stmt->close();
// Update Loan Account
$ins_no = 1;
$sql = "UPDATE `" . $GLOBALS['arif_ac'] . "` SET `AA_BAL` = `AA_BAL` + ?, `AA_NO_OF_PAYPAID` = `AA_NO_OF_PAYPAID` + ? WHERE `AA_ACNO` = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("dis", $loanEMIAmount, $ins_no, $paidToLoanAccountNumber);
$stmt->execute();
$stmt->close();
// Update Recurring Account
$sql = "UPDATE `" . $GLOBALS['arif_ac'] . "` SET `AA_BAL` = `AA_BAL` - ? WHERE `AA_ACNO` = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ds", $loanEMIAmount, $accountId);
// $remarksText1 = "₹$loanEMIAmount deducted from Recurring for Loan A/c $paidToLoanAccountNumber EMI";
$stmt = $conn->prepare("INSERT INTO `$table` (request_by, request_usr_type, rec_ac_number, loan_ac_number, transfer_amount) VALUES (?, ?, ?, ?, ?)");
$stmt->bind_param("sssss", $requestBy, $requestUSRType, $recACNumber, $loanACNumber, $transferAmount);
$stmt->execute();
$stmt->close();
@@ -310,7 +291,7 @@ if ($_SESSION['type'] === 'admin' && isset($_GET["no"]) && isset($_GET["type"])
}
?>
<?php if ($_SESSION['type'] === 'admin' && isset($_GET["no"]) && isset($_GET["type"]) && $_GET["type"] == "Recurring") { ?>
<?php if ($_SESSION['type'] === 'admin' || $_SESSION['type'] === 'bm' && isset($_GET["no"]) && isset($_GET["type"]) && $_GET["type"] == "Recurring") { ?>
<div class="container">
<h4>Pay Loan EMI from Recurring balance</h4>
<div style="display: flex; gap: 20px; flex-direction: row; max-width: 60%;">