Envio de PDF por Telegram
- Agregado comando /pdf y boton Mi PDF en el menu - Genera y envia automaticamente el PDF con todos los horarios y turnos - PDF incluye: Turnos de Ayudantes, Horarios por Semana, Horarios de Apertura
This commit is contained in:
@@ -50,9 +50,33 @@ class TurnoBot {
|
||||
} elseif ($textLower === '/ayudantes' || $textLower === 'ayudantes') {
|
||||
$ayudantes = $this->bot->getListaAyudantesParaBusqueda();
|
||||
$this->bot->sendMessage($chatId, "<b>AYUDANTES DISPONIBLES:</b>\n\n" . implode("\n", $ayudantes));
|
||||
} elseif ($textLower === '/pdf' || $textLower === 'pdf' || $textLower === 'mi pdf') {
|
||||
$this->bot->sendPDFGeneral($chatId);
|
||||
} else {
|
||||
// Buscar por nombre
|
||||
$this->bot->sendMessage($chatId, $this->bot->getTurnosAyudante($text));
|
||||
// Buscar por nombre - verificar si existe el usuario
|
||||
$config = require __DIR__ . '/../config/config.php';
|
||||
try {
|
||||
$pdo = new PDO(
|
||||
"mysql:host={$config['db']['host']};port={$config['db']['port']};dbname={$config['db']['database']};charset=utf8mb4",
|
||||
$config['db']['username'],
|
||||
$config['db']['password'],
|
||||
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->bot->sendMessage($chatId, "Error de conexion.");
|
||||
return;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE (nombre LIKE ? OR username LIKE ?) AND rol = 'ayudante' AND activo = 1 LIMIT 1");
|
||||
$stmt->execute(["%$text%", "%$text%"]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user) {
|
||||
$this->bot->sendMessage($chatId, "Generando PDF de turnos...");
|
||||
$this->bot->sendPDF($chatId, $user['id']);
|
||||
} else {
|
||||
$this->bot->sendMessage($chatId, $this->bot->getTurnosAyudante($text));
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
error_log("Error en handleUpdate: " . $e->getMessage());
|
||||
@@ -81,6 +105,11 @@ class TurnoBot {
|
||||
$this->bot->editMessage($chatId, $messageId, $this->bot->getSemanaActual());
|
||||
break;
|
||||
|
||||
case 'mi_pdf':
|
||||
$this->bot->answerCallback($callbackId, 'Generando PDF...');
|
||||
$this->bot->sendPDFGeneral($chatId);
|
||||
break;
|
||||
|
||||
case 'buscar_nombre':
|
||||
$this->bot->answerCallback($callbackId, '');
|
||||
$this->bot->deleteMessage($chatId, $messageId);
|
||||
@@ -105,6 +134,7 @@ class TurnoBot {
|
||||
$mensaje .= "Selecciona una opcion del menu:\n\n";
|
||||
$mensaje .= "Ver Turnos - Tabla completa de asignaciones\n";
|
||||
$mensaje .= "Semana Actual - Quien tiene turno esta semana\n";
|
||||
$mensaje .= "Mi PDF - Descargar horarios en PDF\n";
|
||||
$mensaje .= "Buscar por Nombre - Consultar un ayudante especifico\n";
|
||||
$mensaje .= "Mi Turno - Ver tu proximo turno";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user