Dashboard
New Customer ApplicationYour dashboard is ready. From here you can manage customer applications.
Submitted Applications
' : ' ';
}
return '';
}
function getStatusBadgeClass($status) {
switch ($status) {
case 'pending_approval':
return 'bg-warning';
case 'approved':
return 'bg-success';
case 'rejected':
return 'bg-danger';
case 'reverted':
return 'bg-info';
case 'draft':
default:
return 'bg-secondary';
}
}
$sort_column = $_GET['sort'] ?? 'created_at';
$sort_order = $_GET['order'] ?? 'DESC';
$valid_columns = ['id', 'application_id', 'company_name', 'status', 'created_at'];
if (!in_array($sort_column, $valid_columns)) {
$sort_column = 'created_at';
}
$status_filter = $_GET['status'] ?? '';
$sql = "SELECT id, application_id, company_name, status, created_at FROM customer_applications";
$params = [];
if ($status_filter) {
$sql .= " WHERE status = ?";
$params[] = $status_filter;
}
$sql .= " ORDER BY $sort_column $sort_order";
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
$applications = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($applications) > 0) {
echo '';
echo '';
echo '
';
} else {
echo '
| Application ID' . getSortIcon('application_id', $sort_column, $sort_order) . ' | '; echo 'Company Name' . getSortIcon('company_name', $sort_column, $sort_order) . ' | '; echo 'Status' . getSortIcon('status', $sort_column, $sort_order) . ' | '; echo 'Date Submitted' . getSortIcon('created_at', $sort_column, $sort_order) . ' | '; echo '
|---|---|---|---|
| ' . htmlspecialchars($app['application_id']) . ' | '; echo '' . htmlspecialchars($app['company_name']) . ' | '; echo '' . htmlspecialchars(ucfirst(str_replace('_', ' ', $app['status']))) . ' | '; echo '' . htmlspecialchars(date("Y-m-d H:i", strtotime($app['created_at']))) . ' | '; echo '
No customer applications found.
'; } } catch (PDOException $e) { echo 'Error: Could not fetch applications.
';
// Optional: log error to a file
// error_log($e->getMessage());
}
?>