update agent dashboard, agent target assign,

This commit is contained in:
2025-09-26 14:19:31 +00:00
parent 32562554ad
commit ab034aeb72
5 changed files with 144 additions and 546 deletions

View File

@@ -17,12 +17,22 @@ if ($agentResult && $agentResult->num_rows > 0) {
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$collectableAmount = isset($_POST['COLLECTABLE_AMOUNT']) ? floatval($_POST['COLLECTABLE_AMOUNT']) : 0;
$collectableAgent = isset($_POST['COLLECTABLE_AGENT']) ? $_POST['COLLECTABLE_AGENT'] : null;
$collectableLoanAmount = isset($_POST['COLLECTABLE_LOAN_AMOUNT']) ? floatval($_POST['COLLECTABLE_LOAN_AMOUNT']) : 0;
$collectableRecurringAmount = isset($_POST['COLLECTABLE_RECURRING_AMOUNT']) ? floatval($_POST['COLLECTABLE_RECURRING_AMOUNT']) : 0;
$collectableAgent = isset($_POST['COLLECTABLE_AGENT']) ? $_POST['COLLECTABLE_AGENT'] : null;
if ($collectableAmount > 0 && $collectableAgent) {
$stmt = $conn->prepare("INSERT INTO agent_collections (agent, collectable_amount, collected_amount, date) VALUES (?, ?, 0, CURDATE())");
$stmt->bind_param("sd", $collectableAgent, $collectableAmount);
if (($collectableLoanAmount > 0 || $collectableRecurringAmount > 0) && $collectableAgent) {
$stmt = $conn->prepare("
INSERT INTO agent_collections (
agent,
collectable_loan_amount,
collected_loan_amount,
collectable_recurring_amount,
collected_recurring_amount,
date
) VALUES (?, ?, 0, ?, 0, CURDATE())
");
$stmt->bind_param("sdd", $collectableAgent, $collectableLoanAmount, $collectableRecurringAmount);
if ($stmt->execute()) {
echo "<div class='alert alert-success'>Target assigned successfully!</div>";
@@ -31,7 +41,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
$stmt->close();
} else {
echo "<div class='alert alert-warning'>Please enter a valid amount and select an agent.</div>";
echo "<div class='alert alert-warning'>Please enter a valid target amount and select an agent.</div>";
}
}
@@ -42,11 +52,15 @@ $conn->close();
<h2>Agent Collection Targets</h2>
<form method="post" style="display: flex; flex-direction: column; gap: 15px;">
<div>
<label for="COLLECTABLE_AMOUNT">Collectable Amount:</label>
<input id="COLLECTABLE_AMOUNT" class="form-control" name="COLLECTABLE_AMOUNT" type="text" placeholder="Enter Amount" />
<label for="COLLECTABLE_LOAN_AMOUNT">Loan Target Amount:</label>
<input id="COLLECTABLE_LOAN_AMOUNT" class="form-control" name="COLLECTABLE_LOAN_AMOUNT" type="text" placeholder="Enter Loan Amount" />
</div>
<div>
<label for="COLLECTABLE_AGENT">Collectable Agent:</label>
<label for="COLLECTABLE_RECURRING_AMOUNT">Recurring Target Amount:</label>
<input id="COLLECTABLE_RECURRING_AMOUNT" class="form-control" name="COLLECTABLE_RECURRING_AMOUNT" type="text" placeholder="Enter Recurring Amount" />
</div>
<div>
<label for="COLLECTABLE_AGENT">Assign To Agent:</label>
<select class="form-control" name="COLLECTABLE_AGENT" id="COLLECTABLE_AGENT">
<?php
foreach($agentList as $agent){