diff --git a/CONTENT/ROOT_URI/Admin/Details.php b/CONTENT/ROOT_URI/Admin/Details.php
index b3cd1a1..107e57d 100644
--- a/CONTENT/ROOT_URI/Admin/Details.php
+++ b/CONTENT/ROOT_URI/Admin/Details.php
@@ -54,18 +54,33 @@
// 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'];
- $maturitySql = "UPDATE `{$GLOBALS['arif_ac']}` SET STATUS = 'matured', CLOSING_DATE = ? WHERE AA_ACNO = ?";
- $maturityStmt = $conn->prepare($maturitySql);
-
- if ($maturityStmt->bind_param("ss", $maturityDate, $maturityAcno) && $maturityStmt->execute()) {
- echo "
Recurring A/C {$maturityAcno} marked as matured.
";
- } else {
- echo "Failed to mark Recurring A/C {$maturityAcno} as matured.
";
+ 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);
+
+ if ($maturityStmt->bind_param("ss", $maturityDate, $maturityAcno) && $maturityStmt->execute()) {
+ echo "Recurring A/C {$maturityAcno} marked as matured.
";
+ } else {
+ echo "Failed to mark Recurring A/C {$maturityAcno} as matured.
";
+ }
+ } 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 "Recurring A/C {$maturityAcno} marked as active again.
";
+ } else {
+ echo "Failed to mark Recurring A/C {$maturityAcno} as active.
";
+ }
+ $unmaturityStmt->close();
}
- $maturityStmt->close();
+ if (isset($maturityStmt)) {
+ $maturityStmt->close();
+ }
}
// Get agent list for dropdown
@@ -173,14 +188,17 @@
";
} elseif ($row["AA_TYPE"]== "Recurring") {
+ $isMatured = $row["STATUS"] === 'matured';
+
echo "
| Recurring A/C of ".$row["AA_NAME"]. " |
|