File size: 1,056 Bytes
0dff816 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<?php
// get-agent.php
session_start();
if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
header('HTTP/1.1 401 Unauthorized');
echo json_encode(['error' => 'Unauthorized']);
exit;
}
// Include agent functions
require_once 'agent-functions.php';
if (isset($_GET['id'])) {
$agentId = intval($_GET['id']);
$agent = getAgentDetails($agentId);
if ($agent) {
header('Content-Type: application/json');
echo json_encode($agent);
} else {
// Return dummy data for testing
$dummyAgent = [
'id' => $agentId,
'full_name' => 'Test Agent ' . $agentId,
'phone' => '+254 7XX XXX XXX',
'location' => 'Nairobi',
'applied_at' => date('Y-m-d H:i:s'),
'id_front' => '#',
'id_back' => '#'
];
header('Content-Type: application/json');
echo json_encode($dummyAgent);
}
} else {
header('HTTP/1.1 400 Bad Request');
echo json_encode(['error' => 'Agent ID required']);
}
?> |