add recurring reopen function

This commit is contained in:
ns77@siliconpin.com
2025-08-26 07:48:01 +00:00
parent f12458b0d2
commit d13cbafa88

View File

@@ -54,8 +54,10 @@
// Handle maturity for recurring accounts
if (isset($_POST['recurring_maturity_submit']) && !empty($_POST['maturity_acno'])) {
$maturityAcno = $_POST['maturity_acno'];
$maturityDate = date('Y-m-d');
$maturityAction = $_POST['maturity_action'];
if ($maturityAction === 'mature') {
$maturityDate = date('Y-m-d');
$maturitySql = "UPDATE `{$GLOBALS['arif_ac']}` SET STATUS = 'matured', CLOSING_DATE = ? WHERE AA_ACNO = ?";
$maturityStmt = $conn->prepare($maturitySql);
@@ -64,9 +66,22 @@
} else {
echo "<div class='alert alert-danger'>Failed to mark Recurring A/C <strong>{$maturityAcno}</strong> as matured.</div>";
}
} elseif ($maturityAction === 'unmature') {
$unmaturitySql = "UPDATE `{$GLOBALS['arif_ac']}` SET STATUS = NULL, CLOSING_DATE = NULL WHERE AA_ACNO = ?";
$unmaturityStmt = $conn->prepare($unmaturitySql);
if ($unmaturityStmt->bind_param("s", $maturityAcno) && $unmaturityStmt->execute()) {
echo "<div class='alert alert-success'>Recurring A/C <strong>{$maturityAcno}</strong> marked as active again.</div>";
} else {
echo "<div class='alert alert-danger'>Failed to mark Recurring A/C <strong>{$maturityAcno}</strong> as active.</div>";
}
$unmaturityStmt->close();
}
if (isset($maturityStmt)) {
$maturityStmt->close();
}
}
// Get agent list for dropdown
$getAgentListsQuery = "SELECT * FROM " . $GLOBALS['arif_users'] . "";
@@ -173,14 +188,17 @@
</tr>";
} elseif ($row["AA_TYPE"]== "Recurring") {
$isMatured = $row["STATUS"] === 'matured';
echo "
<tr>
<th style='vertical-align: middle;'>Recurring A/C of ".$row["AA_NAME"]. "</th>
<td style='vertical-align: middle; text-align: right;'>
<form method='post' style='display: inline;'>
<input type='hidden' name='maturity_acno' value='".$row["AA_ACNO"]."'>
<button type='submit' name='recurring_maturity_submit' class='btn " . ($row["STATUS"] === 'matured' ? 'btn-success' : 'btn-info') . "'>" . ($row['STATUS'] === 'matured' ? 'Matured' : 'Mark as Matured') . "</button>
" . ($row["STATUS"] === 'matured' ? "<br/><span>" . date('d-m-Y', strtotime($row["CLOSING_DATE"])) . "</span>" : "") . "
<input type='hidden' name='maturity_action' value='".($isMatured ? 'unmature' : 'mature')."'>
<button type='submit' name='recurring_maturity_submit' class='btn " . ($isMatured ? 'btn-warning' : 'btn-info') . "'>" . ($isMatured ? 'Mark as Active' : 'Mark as Matured') . "</button>
" . ($isMatured ? "<br/><span>Matured on: " . date('d-m-Y', strtotime($row["CLOSING_DATE"])) . "</span>" : "") . "
</form>
</td>
</tr>