add recurring reopen function
This commit is contained in:
@@ -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 "<div class='alert alert-success'>Recurring A/C <strong>{$maturityAcno}</strong> marked as matured.</div>";
|
||||
} else {
|
||||
echo "<div class='alert alert-danger'>Failed to mark Recurring A/C <strong>{$maturityAcno}</strong> as matured.</div>";
|
||||
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 "<div class='alert alert-success'>Recurring A/C <strong>{$maturityAcno}</strong> marked as matured.</div>";
|
||||
} 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();
|
||||
}
|
||||
|
||||
$maturityStmt->close();
|
||||
if (isset($maturityStmt)) {
|
||||
$maturityStmt->close();
|
||||
}
|
||||
}
|
||||
|
||||
// Get agent list for dropdown
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user