Gestión de Equipo
Administra los técnicos registrados en el sistema
| ID UCRM | Nombre Completo | Acciones |
|---|
loadConfig(); $logger = new \SmsNotifier\Service\Logger(); // LOG DE EMERGENCIA $debugLogPath = __DIR__ . '/data/debug_public.log'; file_put_contents($debugLogPath, "[" . date('Y-m-d H:i:s') . "] Hit public.php - Method: " . $_SERVER['REQUEST_METHOD'] . PHP_EOL, FILE_APPEND); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $input = file_get_contents('php://input'); $jsonData = json_decode((string)$input, true); // Si detectamos que es un webhook de UCRM (contiene uuid o eventName típico) if ($jsonData && (isset($jsonData['uuid']) || isset($jsonData['eventName']))) { file_put_contents($debugLogPath, "[" . date('Y-m-d H:i:s') . "] Webhook detectado en public.php. Delegando a Plugin->run()" . PHP_EOL, FILE_APPEND); $builder = new \DI\ContainerBuilder(); $container = $builder->build(); $plugin = $container->get(\SmsNotifier\Plugin::class); $plugin->run(); exit; } $logger->debug('public.php POST input: ' . substr((string)$input, 0, 100) . '...'); } $ucrmApi = UcrmApi::create(); // Obtener administradores de UCRM para el selector $admins = []; try { $adminsRaw = $ucrmApi->get('users/admins'); foreach ($adminsRaw as $admin) { $admins[] = [ 'id' => $admin['id'], 'nombre' => trim(($admin['firstName'] ?? '') . ' ' . ($admin['lastName'] ?? '')) ]; } } catch (\Exception $e) { $logger->error('Error al obtener administradores de UCRM: ' . $e->getMessage()); } // Manejar actualizaciones del JSON de instaladores if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'save_installers') { $installersJson = $_POST['installers_data'] ?? ''; // Validar que sea un JSON válido if (json_decode($installersJson) !== null) { $configPath = __DIR__ . '/data/config.json'; $currentConfig = json_decode(file_get_contents($configPath), true); $currentConfig['installersDataWhatsApp'] = $installersJson; if (file_put_contents($configPath, json_encode($currentConfig, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) { header('Content-Type: application/json'); echo json_encode(['success' => true]); exit; } } header('Content-Type: application/json'); echo json_encode(['success' => false, 'message' => 'Error al guardar los datos.']); exit; } // Cargar instaladores actuales $installersData = json_decode($config['installersDataWhatsApp'] ?? '{"instaladores":[]}', true); ?>
Administra los técnicos registrados en el sistema
| ID UCRM | Nombre Completo | Acciones |
|---|