set_charset("utf8"); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Get agent list $getAgentListsQuery = "SELECT * FROM " . $GLOBALS['arif_users']; $agentResult = $conn->query($getAgentListsQuery); $agentList = []; if ($agentResult && $agentResult->num_rows > 0) { while ($row = $agentResult->fetch_assoc()) { $agentList[] = $row; } } // 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; 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 ($stmt->execute()) { echo "
Target assigned successfully!
"; } else { echo "
Error: " . $stmt->error . "
"; } $stmt->close(); } else { echo "
Please enter a valid amount and select an agent.
"; } } $conn->close(); ?>

Agent Collection Targets