This commit is contained in:
lizandrogd
2026-01-20 22:33:39 -05:00
parent 648a6c0291
commit f222df40cd
10 changed files with 86 additions and 5 deletions
+32
View File
@@ -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);
}
+11
View File
@@ -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;
}
+20
View File
@@ -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;
}
+1
View File
@@ -0,0 +1 @@
{"name":"auto_test_template","whatsapp_name":"auto_test_template_001","language":"es","category":"utility"}
+1
View File
@@ -0,0 +1 @@
{"name":"auto_test_template_2","whatsapp_name":"auto_test_template_002","language":"es","category":"utility"}