Autosave: 20260522-165916
This commit is contained in:
parent
8dc1fb0062
commit
5707981abe
BIN
assets/uploads/vouchers/6a10696995907-Screenshot_359.png
Normal file
BIN
assets/uploads/vouchers/6a10696995907-Screenshot_359.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 KiB |
BIN
assets/uploads/vouchers/6a1079bc75dc9-355.png
Normal file
BIN
assets/uploads/vouchers/6a1079bc75dc9-355.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 328 KiB |
BIN
assets/uploads/vouchers/6a108aa092494-250.png
Normal file
BIN
assets/uploads/vouchers/6a108aa092494-250.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 328 KiB |
272
imprimir_rotulos_grandes.php
Normal file
272
imprimir_rotulos_grandes.php
Normal file
@ -0,0 +1,272 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
$pdo = db();
|
||||
|
||||
// Fetch all products to have their prefixes ready
|
||||
$stmt_products = $pdo->query("SELECT nombre, codigo_base FROM products");
|
||||
$product_prefixes = [];
|
||||
while ($row = $stmt_products->fetch(PDO::FETCH_ASSOC)) {
|
||||
$product_prefixes[$row['nombre']] = $row['codigo_base'];
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$user_role = $_SESSION['user_role'] ?? 'Asesor';
|
||||
|
||||
$selected_month = $_GET['mes'] ?? '';
|
||||
$selected_year = $_GET['año'] ?? '';
|
||||
$search_query = $_GET['q'] ?? '';
|
||||
$is_today = isset($_GET['today']);
|
||||
|
||||
$sql = "SELECT p.*
|
||||
FROM pedidos p
|
||||
WHERE p.estado = 'ROTULADO 📦'";
|
||||
$params = [];
|
||||
|
||||
if ($user_role === 'Asesor') {
|
||||
$sql .= " AND p.asesor_id = ?";
|
||||
$params[] = $user_id;
|
||||
}
|
||||
|
||||
if (!empty($search_query)) {
|
||||
$sql .= " AND (p.nombre_completo LIKE ? OR p.dni_cliente LIKE ? OR p.celular LIKE ?)";
|
||||
$params[] = "%$search_query%";
|
||||
$params[] = "%$search_query%";
|
||||
$params[] = "%$search_query%";
|
||||
}
|
||||
|
||||
if (!empty($selected_month)) {
|
||||
$sql .= " AND MONTH(p.created_at) = ?";
|
||||
$params[] = $selected_month;
|
||||
}
|
||||
if (!empty($selected_year)) {
|
||||
$sql .= " AND YEAR(p.created_at) = ?";
|
||||
$params[] = $selected_year;
|
||||
}
|
||||
|
||||
if ($is_today) {
|
||||
$sql .= " AND DATE(p.created_at) = CURDATE()";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY p.created_at DESC";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$pedidos = $stmt->fetchAll();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Rótulos del Día</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Arial', sans-serif;
|
||||
background-color: #f0f2f5;
|
||||
}
|
||||
.no-print {
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
background: white;
|
||||
border-bottom: 1px solid #ddd;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
.btn-print {
|
||||
padding: 12px 24px;
|
||||
background: #198754;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
||||
}
|
||||
.btn-print:hover {
|
||||
background: #157347;
|
||||
}
|
||||
.label-page {
|
||||
width: 96mm;
|
||||
height: 75mm;
|
||||
background: white;
|
||||
margin: 10mm auto;
|
||||
padding: 4mm;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
page-break-after: always;
|
||||
color: black;
|
||||
overflow: hidden;
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
border-bottom: 3px solid black;
|
||||
padding-bottom: 2mm;
|
||||
}
|
||||
.client-name {
|
||||
font-size: 22pt;
|
||||
font-weight: 900;
|
||||
text-transform: uppercase;
|
||||
margin: 0;
|
||||
line-height: 1.1;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
.details {
|
||||
font-size: 16pt;
|
||||
line-height: 1.3;
|
||||
font-weight: bold;
|
||||
margin-top: 1mm;
|
||||
}
|
||||
.details-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1mm;
|
||||
gap: 2mm;
|
||||
}
|
||||
.footer-msg {
|
||||
text-align: center;
|
||||
font-size: 14pt;
|
||||
font-weight: 900;
|
||||
border-top: 2px solid black;
|
||||
padding-top: 2mm;
|
||||
margin-top: auto;
|
||||
}
|
||||
@media print {
|
||||
@page {
|
||||
size: 96mm 75mm;
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
background: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.no-print {
|
||||
display: none;
|
||||
}
|
||||
.label-page {
|
||||
margin: 0;
|
||||
border: none;
|
||||
width: 96mm;
|
||||
height: 75mm;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="no-print">
|
||||
<button class="btn-print" onclick="window.print()">IMPRIMIR RÓTULOS (<?php echo count($pedidos); ?>)</button>
|
||||
<a href="pedidos.php" style="margin-left: 15px; text-decoration: none; color: #666; font-weight: bold;">← VOLVER</a>
|
||||
</div>
|
||||
|
||||
<?php if (empty($pedidos)): ?>
|
||||
<div style="text-align: center; margin-top: 50px;">
|
||||
<h3>No hay pedidos rotulados para mostrar.</h3>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($pedidos as $pedido):
|
||||
$display_variants = [];
|
||||
$found_in_notes = false;
|
||||
|
||||
// Try to parse from notas first
|
||||
if (preg_match_all('/Detalle de productos: (.*)$/m', $pedido['notas'], $matches)) {
|
||||
$last_match = end($matches[1]);
|
||||
$details = explode(', ', $last_match);
|
||||
foreach ($details as $detail) {
|
||||
if (preg_match('/(.*) \(x(\d+)\)/', $detail, $d_matches)) {
|
||||
$p_name = trim($d_matches[1]);
|
||||
$p_qty = (int)$d_matches[2];
|
||||
$prefix = $product_prefixes[$p_name] ?? 'S/V';
|
||||
$display_variants[] = "($p_qty) $prefix";
|
||||
$found_in_notes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback if not found in notes
|
||||
if (!$found_in_notes && !empty($pedido['producto'])) {
|
||||
$names = explode(', ', $pedido['producto']);
|
||||
$total_qty = (int)($pedido['cantidad'] ?: 1);
|
||||
|
||||
if (count($names) === 1) {
|
||||
$prefix = $product_prefixes[trim($names[0])] ?? 'S/V';
|
||||
$display_variants[] = "($total_qty) $prefix";
|
||||
} else {
|
||||
foreach ($names as $name) {
|
||||
$prefix = $product_prefixes[trim($name)] ?? 'S/V';
|
||||
$display_variants[] = "(1) $prefix";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$variante_text = !empty($display_variants) ? implode(' + ', $display_variants) : 'S/V';
|
||||
?>
|
||||
<div class="label-page">
|
||||
<div class="header">
|
||||
<h1 class="client-name"><?php
|
||||
$full_name = trim($pedido['nombre_completo']);
|
||||
$name_parts = array_filter(explode(' ', $full_name));
|
||||
$display_name = implode(' ', array_slice($name_parts, 0, 2));
|
||||
echo htmlspecialchars($display_name);
|
||||
?></h1>
|
||||
</div>
|
||||
|
||||
<div class="details">
|
||||
<div class="details-row">
|
||||
<span>VARIANTE: <?php echo htmlspecialchars($variante_text); ?></span>
|
||||
</div>
|
||||
<div class="details-row">
|
||||
<span><?php
|
||||
$dni_val = trim($pedido['dni_cliente'] ?: ($pedido['dni'] ?: 'N/A'));
|
||||
// Remove existing DNI: prefix to standardize
|
||||
$dni_clean = preg_replace('/^DNI:\s*/i', '', $dni_val);
|
||||
echo 'DNI:' . htmlspecialchars($dni_clean);
|
||||
?></span>
|
||||
<span>CANT: <?php echo htmlspecialchars($pedido['cantidad'] ?: '1'); ?></span>
|
||||
</div>
|
||||
<div class="details-row">
|
||||
<span><?php
|
||||
$cel_val = trim($pedido['celular']);
|
||||
// Remove CEL: prefix if exists, then remove +51, then trim again
|
||||
$cel_clean = preg_replace('/^CEL:\s*/i', '', $cel_val);
|
||||
$cel_clean = str_replace('+51', '', $cel_clean);
|
||||
$cel_clean = trim($cel_clean);
|
||||
echo 'CEL:' . htmlspecialchars($cel_clean);
|
||||
?></span>
|
||||
<span>AG: <?php echo htmlspecialchars($pedido['agencia'] ?: 'N/A'); ?></span>
|
||||
</div>
|
||||
<div class="details-row">
|
||||
<span><?php
|
||||
$sede_val = trim($pedido['sede_envio'] ?: 'N/A');
|
||||
if ($sede_val !== 'N/A' && strpos($sede_val, ' / ') !== false) {
|
||||
$parts = explode(' / ', $sede_val);
|
||||
if (count($parts) > 1) {
|
||||
$sede_val = trim($parts[0]) . ' / ' . trim(end($parts));
|
||||
}
|
||||
}
|
||||
echo 'SEDE: ' . htmlspecialchars($sede_val);
|
||||
?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer-msg">
|
||||
MUCHAS GRACIAS POR SU COMPRA
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</body>
|
||||
</html>
|
||||
@ -136,6 +136,7 @@ include 'layout_header.php';
|
||||
<button type="submit" class="btn btn-info">Filtrar</button>
|
||||
<a href="pedidos.php" class="btn btn-secondary">Limpiar</a>
|
||||
<?php if ($user_role === 'Administrador' || $user_role === 'Logistica'): ?>
|
||||
<a href="imprimir_rotulos_grandes.php?<?php echo http_build_query(array_merge($_GET, ['today' => 1])); ?>" class="btn btn-dark" target="_blank">Generar Rótulos del Día</a>
|
||||
<a href="download_report.php" class="btn btn-success">Descargar Todos los Rotulados</a>
|
||||
<a href="download_shalom.php?type=terrestre" class="btn btn-primary">Descargar Shalom Terrestre</a>
|
||||
<a href="download_shalom.php?type=aereo" class="btn btn-warning" style="background-color: #fd7e14; border-color: #fd7e14; color: white;">Descargar Shalom Aéreo</a>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user