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
+8 -4
View File
@@ -4,7 +4,7 @@
* Fecha: 3 de enero de 2026
*/
require_once '../config/config.php';
require_once __DIR__ . '/../config/config_enhanced.php';
// Suprimir errores para obtener JSON limpio
error_reporting(E_ERROR | E_PARSE);
@@ -67,22 +67,26 @@ try {
exit;
}
// Determinar estado según configuración
$initialStatus = defined('AUTO_APPROVE_TEMPLATES') && AUTO_APPROVE_TEMPLATES ? 'approved' : 'pending';
// Crear la plantilla
$templateId = $db->insert('message_templates', [
'name' => $name,
'template_name' => $templateName,
'language_code' => $languageCode,
'category' => $category,
'status' => 'pending', // Siempre inicia como pendiente
'status' => $initialStatus,
'created_at' => date('Y-m-d H:i:s')
]);
if ($templateId) {
echo json_encode([
'success' => true,
'message' => 'Plantilla creada correctamente. Estado: Pendiente de aprobación por WhatsApp.',
'message' => 'Plantilla creada correctamente.',
'id' => $templateId,
'note' => 'La plantilla debe ser aprobada en WhatsApp Business Manager antes de poder usarse.'
'status' => $initialStatus,
'note' => $initialStatus === 'approved' ? 'Plantilla marcada como aprobada localmente.' : 'La plantilla debe ser aprobada en WhatsApp Business Manager antes de poder usarse.'
]);
} else {
http_response_code(500);