up
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Approve all pending templates (script)
|
||||
* Usage: php approve_pending_templates.php
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../config/config_enhanced.php';
|
||||
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
echo "Connected DB\n";
|
||||
|
||||
$pending = $db->fetchAll("SELECT id, name, template_name, status, created_at FROM message_templates WHERE status = 'pending'");
|
||||
|
||||
if (empty($pending)) {
|
||||
echo "No pending templates found.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$ids = array_map(function($r){return $r['id'];}, $pending);
|
||||
|
||||
$in = implode(',', array_map('intval', $ids));
|
||||
|
||||
$updated = $db->query("UPDATE message_templates SET status = 'approved' WHERE id IN ($in)");
|
||||
|
||||
echo "Updated templates: " . count($ids) . "\n";
|
||||
echo json_encode($pending, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config/config_enhanced.php';
|
||||
require_once __DIR__ . '/../classes/Database.php';
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
echo "Connected DB\n";
|
||||
$rows = $db->fetchAll("SELECT id, name, template_name, status, created_at FROM message_templates ORDER BY created_at DESC LIMIT 10");
|
||||
echo json_encode($rows, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . PHP_EOL;
|
||||
} catch (Exception $e) {
|
||||
echo 'ERROR: ' . $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config/config_enhanced.php';
|
||||
require_once __DIR__ . '/../classes/Database.php';
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
echo "Connected DB\n";
|
||||
$t = $db->fetch('SELECT id, name, template_name, status, created_at FROM message_templates WHERE template_name = ? ORDER BY created_at DESC LIMIT 1', ['auto_test_template_001']);
|
||||
if ($t) {
|
||||
echo "Found template: " . json_encode($t) . PHP_EOL;
|
||||
} else {
|
||||
echo "Not found\n";
|
||||
$rows = $db->fetchAll('SELECT id, name, template_name, status, created_at FROM message_templates ORDER BY created_at DESC LIMIT 10');
|
||||
echo "Recent: " . json_encode($rows) . PHP_EOL;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo 'ERROR: ' . $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"auto_test_template","whatsapp_name":"auto_test_template_001","language":"es","category":"utility"}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"auto_test_template_2","whatsapp_name":"auto_test_template_002","language":"es","category":"utility"}
|
||||
Reference in New Issue
Block a user