up
This commit is contained in:
+17
-12
@@ -24,18 +24,23 @@ header('Access-Control-Allow-Headers: Content-Type');
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
|
||||
$templates = $db->fetchAll(
|
||||
"SELECT
|
||||
id,
|
||||
name,
|
||||
template_name,
|
||||
language_code,
|
||||
category,
|
||||
status,
|
||||
created_at
|
||||
FROM message_templates
|
||||
ORDER BY name ASC"
|
||||
);
|
||||
$approvedOnly = isset($_GET['approved_only']) && $_GET['approved_only'] == '1';
|
||||
$limit = isset($_GET['limit']) ? intval($_GET['limit']) : null;
|
||||
|
||||
$sql = "SELECT id, name, template_name, language_code, category, status, body_text, created_at FROM message_templates";
|
||||
$params = [];
|
||||
|
||||
if ($approvedOnly) {
|
||||
$sql .= " WHERE status = 'approved'";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY name ASC";
|
||||
|
||||
if ($limit && $limit > 0) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
|
||||
$templates = $db->fetchAll($sql, $params);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
|
||||
Reference in New Issue
Block a user