Autosave: 20260428-082031

This commit is contained in:
Flatlogic Bot 2026-04-28 08:20:31 +00:00
parent 388bd415b3
commit faa1a9f2b3
3 changed files with 75 additions and 1 deletions

View File

@ -54,7 +54,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['sync_shalom'])) {
$count = 0; $count = 0;
foreach ($sedes as $sede) { foreach ($sedes as $sede) {
$id = $sede['ter_id']; $id = $sede['ter_id'];
$nombre = $sede['lugar']; // Usamos el campo 'nombre' que es más completo (Departamento / Provincia / Distrito / Lugar)
$nombre = $sede['nombre'];
$stmt = $conn->prepare("INSERT INTO sedes_shalom (id_terminal, nombre_sede, activo, permite_origen, permite_destino) $stmt = $conn->prepare("INSERT INTO sedes_shalom (id_terminal, nombre_sede, activo, permite_origen, permite_destino)
VALUES (?, ?, 1, 1, 1) VALUES (?, ?, 1, 1, 1)
ON DUPLICATE KEY UPDATE nombre_sede = VALUES(nombre_sede)"); ON DUPLICATE KEY UPDATE nombre_sede = VALUES(nombre_sede)");

72
download_shalom.php Normal file
View File

@ -0,0 +1,72 @@
<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
require_once 'db/config.php';
try {
$pdo = db();
// Filtramos solo los pedidos que están en estado 'ROTULADO 📦'
$query = "
SELECT p.dni_cliente, p.nombre_completo, p.celular, p.sede_envio, p.agencia
FROM pedidos p
WHERE p.estado = 'ROTULADO 📦'
ORDER BY p.id DESC
";
$stmt = $pdo->prepare($query);
$stmt->execute();
$pedidos = $stmt->fetchAll(PDO::FETCH_ASSOC);
header('Content-Type: application/vnd.ms-excel; charset=utf-8');
header('Content-Disposition: attachment; filename="masivo_shalom.xls"');
header('Pragma: no-cache');
header('Expires: 0');
$output = '<html><head><meta charset="utf-8"></head><body>';
$output .= '<table border="1">';
$output .= '<thead>';
$output .= '<tr>';
$output .= '<th>DESTINATARIO (DOC)</th>';
$output .= '<th>TELF. DESTINATARIO</th>';
$output .= '<th>CONTACTO (DOC)</th>';
$output .= '<th>TELF. CONTACTO</th>';
$output .= '<th>NRO GRR</th>';
$output .= '<th>ORIGEN</th>';
$output .= '<th>DESTINO</th>';
$output .= '</tr>';
$output .= '</thead>';
$output .= '<tbody>';
foreach ($pedidos as $pedido) {
// Formato: Nombre (DNI)
$destinatario = htmlspecialchars($pedido['nombre_completo'] . ' (' . ($pedido['dni_cliente'] ?? '') . ')');
$celular = htmlspecialchars($pedido['celular'] ?? '');
$destino = htmlspecialchars($pedido['sede_envio'] ?? '');
$output .= '<tr>';
$output .= '<td>' . $destinatario . '</td>';
$output .= '<td>' . $celular . '</td>';
$output .= '<td>' . $destinatario . '</td>';
$output .= '<td>' . $celular . '</td>';
$output .= '<td></td>'; // NRO GRR
$output .= '<td></td>'; // ORIGEN
$output .= '<td>' . $destino . '</td>';
$output .= '</tr>';
}
$output .= '</tbody>';
$output .= '</table>';
$output .= '</body></html>';
echo $output;
} catch (Exception $e) {
header('HTTP/1.1 500 Internal Server Error');
echo '<script>alert("Ocurrió un error al generar el reporte para Shalom."); window.history.back();</script>';
}
?>

View File

@ -137,6 +137,7 @@ include 'layout_header.php';
<a href="pedidos.php" class="btn btn-secondary">Limpiar</a> <a href="pedidos.php" class="btn btn-secondary">Limpiar</a>
<?php if ($user_role === 'Administrador' || $user_role === 'Logistica'): ?> <?php if ($user_role === 'Administrador' || $user_role === 'Logistica'): ?>
<a href="download_report.php" class="btn btn-success">Descargar Todos los Rotulados</a> <a href="download_report.php" class="btn btn-success">Descargar Todos los Rotulados</a>
<a href="download_shalom.php" class="btn btn-primary">Descargar Shalom</a>
<?php endif; ?> <?php endif; ?>
</div> </div>
</form> </form>