diff --git a/bot/TelegramBot.php b/bot/TelegramBot.php
index 1037b90..41cc910 100755
--- a/bot/TelegramBot.php
+++ b/bot/TelegramBot.php
@@ -20,14 +20,16 @@ class TelegramBot {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// --- MEJORAS ---
- // 1. Forzar el uso de IPv4. Un problema común en entornos Docker
- // es un timeout al intentar resolver AAAA (IPv6) antes de usar A (IPv4).
+ // 1. Forzar el uso de IPv4.
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
- // 2. Añadir timeouts para evitar que el script se cuelgue indefinidamente.
+ // 2. Añadir timeouts de seguridad.
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // 5 segundos para conectar
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // 10 segundos para la transferencia total
+ // 3. (ÚLTIMO INTENTO) Forzar versión de TLS.
+ curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
+
if ($httpMethod === 'POST') {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
@@ -269,7 +271,7 @@ class TelegramBot {
$db = \Database::getInstance()->getConnection();
$horarios = $horariosModel->getActivos();
- $ayudantes = $userModel->getAyudantesActivos();
+ $ayudantes = $asignacionModel->getAyudantesPorOrden();
$semanasFuturas = [];
$hoy = new DateTime();
@@ -398,7 +400,7 @@ class TelegramBot {
$db = \Database::getInstance()->getConnection();
$horarios = $horariosModel->getActivos();
- $ayudantes = $userModel->getAyudantesActivos();
+ $ayudantes = $asignacionModel->getAyudantesPorOrden();
$semanasFuturas = [];
$hoy = new DateTime();
diff --git a/public/admin/export-pdf.php b/public/admin/export-pdf.php
index d274b4a..3024251 100644
--- a/public/admin/export-pdf.php
+++ b/public/admin/export-pdf.php
@@ -22,7 +22,7 @@ $totalAyudantes = count($userModel->getAyudantesActivos());
$totalHorarios = count($horariosModel->getAll());
$asignacionActual = $asignacionModel->getAsignacionActual();
-$ayudantes = $userModel->getAyudantesActivos();
+$ayudantes = $asignacionModel->getAyudantesPorOrden();
$horarios = $horariosModel->getAll();
$asignaciones = $asignacionModel->getTodasAsignaciones();
@@ -89,6 +89,40 @@ foreach ($asignacionesLimit as $a) {
$html .= '';
+$html .= '
Turnos de Ayudantes
';
+$html .= '';
+$html .= '| Ayudante | Fecha 1 | Fecha 2 | Fecha 3 | Fecha 4 |
';
+$html .= '';
+
+foreach ($ayudantes as $ayudante) {
+ $stmt = $db->prepare("
+ SELECT semana_inicio, semana_fin
+ FROM asignaciones_turnos
+ WHERE user_id = ? AND semana_inicio >= CURDATE()
+ ORDER BY semana_inicio
+ LIMIT 4
+ ");
+ $stmt->execute([$ayudante['id']]);
+ $turnos = $stmt->fetchAll();
+
+ $html .= '';
+ $html .= '| ' . htmlspecialchars($ayudante['nombre']) . ' | ';
+
+ for ($i = 0; $i < 4; $i++) {
+ $html .= '';
+ if (isset($turnos[$i])) {
+ $html .= date('d/m/Y', strtotime($turnos[$i]['semana_inicio'])) . ' - ';
+ $html .= date('d/m/Y', strtotime($turnos[$i]['semana_fin']));
+ } else {
+ $html .= '-';
+ }
+ $html .= ' | ';
+ }
+ $html .= '
';
+}
+
+$html .= '
';
+
$html .= PDFGenerator::getFooter();
$pdf = new PDFGenerator();
diff --git a/public/export-pdf.php b/public/export-pdf.php
index 0190208..fd71f11 100644
--- a/public/export-pdf.php
+++ b/public/export-pdf.php
@@ -21,7 +21,7 @@ $db = Database::getInstance()->getConnection();
$horarios = $horariosModel->getActivos();
$userModel = new User();
-$ayudantes = $userModel->getAyudantesActivos();
+$ayudantes = $asignacionModel->getAyudantesPorOrden();
$semanasFuturas = [];
$hoy = new DateTime();
@@ -127,6 +127,44 @@ foreach ($semanasFuturas as $index => $semana) {
$html .= '';
}
+$html .= '';
+
+$html .= 'Turnos de Ayudantes
';
+$html .= '';
+$html .= '| Ayudante | Fecha 1 | Fecha 2 | Fecha 3 | Fecha 4 |
';
+$html .= '';
+
+foreach ($ayudantes as $ayudante) {
+ $stmt = $db->prepare("
+ SELECT semana_inicio, semana_fin
+ FROM asignaciones_turnos
+ WHERE user_id = ? AND semana_inicio >= CURDATE()
+ ORDER BY semana_inicio
+ LIMIT 4
+ ");
+ $stmt->execute([$ayudante['id']]);
+ $turnos = $stmt->fetchAll();
+
+ $html .= '';
+ $html .= '| ' . htmlspecialchars($ayudante['nombre']);
+ if ($ayudante['id'] == $user['id']) {
+ $html .= ' Tu';
+ }
+ $html .= ' | ';
+
+ for ($i = 0; $i < 4; $i++) {
+ $html .= '';
+ if (isset($turnos[$i])) {
+ $html .= date('d/m/Y', strtotime($turnos[$i]['semana_inicio'])) . ' - ';
+ $html .= date('d/m/Y', strtotime($turnos[$i]['semana_fin']));
+ } else {
+ $html .= '-';
+ }
+ $html .= ' | ';
+ }
+ $html .= '
';
+}
+
$html .= '
';
$html .= PDFGenerator::getFooter();