Autosave: 20260521-183802

This commit is contained in:
Flatlogic Bot 2026-05-21 18:38:03 +00:00
parent b4284d6ec3
commit 370e45f837
5 changed files with 288 additions and 65 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

View File

@ -193,15 +193,26 @@ if (!empty($generated_data)) {
<div class="card mt-4">
<div class="card-header d-flex justify-content-between align-items-center">
<h3 class="card-title mb-0">Códigos Generados</h3>
<form action="imprimir_etiquetas.php" method="POST" target="_blank" class="m-0">
<?php foreach ($generated_data as $data): ?>
<input type="hidden" name="codes[]" value="<?php echo htmlspecialchars($data['code']); ?>">
<input type="hidden" name="product_names[]" value="<?php echo htmlspecialchars($data['product_name']); ?>">
<?php endforeach; ?>
<button type="submit" class="btn btn-success">
<i class="fas fa-file-excel"></i> Exportar a Excel
</button>
</form>
<div class="d-flex gap-2">
<form action="imprimir_etiquetas_termica.php" method="POST" target="_blank" class="m-0">
<?php foreach ($generated_data as $data): ?>
<input type="hidden" name="codes[]" value="<?php echo htmlspecialchars($data['code']); ?>">
<input type="hidden" name="product_names[]" value="<?php echo htmlspecialchars($data['product_name']); ?>">
<?php endforeach; ?>
<button type="submit" class="btn btn-primary">
<i class="fas fa-print"></i> Imprimir Etiquetas (3x3)
</button>
</form>
<form action="imprimir_etiquetas.php" method="POST" target="_blank" class="m-0">
<?php foreach ($generated_data as $data): ?>
<input type="hidden" name="codes[]" value="<?php echo htmlspecialchars($data['code']); ?>">
<input type="hidden" name="product_names[]" value="<?php echo htmlspecialchars($data['product_name']); ?>">
<?php endforeach; ?>
<button type="submit" class="btn btn-success">
<i class="fas fa-file-excel"></i> Exportar a Excel
</button>
</form>
</div>
</div>
<div class="card-body">
<p>Estos son los códigos generados. Puedes escanearlos con una app en tu teléfono para probar que funcionan.</p>

View File

@ -0,0 +1,173 @@
<?php
require_once 'includes/barcode_generator.php';
$generator = new BarcodeGenerator();
$codes = $_POST['codes'] ?? [];
$product_names = $_POST['product_names'] ?? [];
if (empty($codes)) {
die("No se proporcionaron códigos para imprimir.");
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Imprimir Etiquetas Térmicas</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
background-color: #f0f2f5;
}
.no-print {
margin: 20px;
padding: 12px 25px;
background: #007bff;
color: white;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.no-print:hover {
background: #0056b3;
}
/* Hoja: 96mm x 75mm (Horizontal) */
.etiquetas-container {
width: 96mm;
height: 75mm;
display: grid;
grid-template-columns: repeat(3, 28mm);
grid-template-rows: repeat(3, 21mm);
gap: 2mm;
justify-content: center;
align-content: center;
background: white;
box-sizing: border-box;
page-break-after: always;
}
.etiqueta {
width: 28mm;
height: 21mm;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden;
text-align: center;
padding: 1mm;
border: 0.1mm solid #eee; /* Guía visual en pantalla */
}
.producto-nombre {
font-size: 6px;
font-weight: bold;
line-height: 1;
margin-bottom: 1mm;
text-transform: uppercase;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
}
.barcode-container {
height: 9.12mm; /* Altura exacta solicitada */
display: flex;
justify-content: center;
align-items: center;
margin: 1mm 0; /* Margen vertical */
padding: 0 2mm; /* Margen lateral de 2mm solicitado */
box-sizing: border-box;
width: 100%; /* Ocupa el ancho de la etiqueta para centrar */
}
.barcode-container svg {
height: 9.12mm;
width: auto; /* Que el ancho sea proporcional a la cantidad de caracteres */
shape-rendering: crispEdges;
}
.sku-text {
font-size: 7px;
font-weight: bold;
margin-top: 0.5mm;
letter-spacing: 0.5px;
}
@media print {
@page {
size: 96mm 75mm landscape;
margin: 0;
}
body {
background: none;
margin: 0;
padding: 0;
}
.no-print {
display: none;
}
.etiquetas-container {
border: none;
box-shadow: none;
margin: 0;
}
.etiqueta {
border: none;
}
}
</style>
</head>
<body>
<button class="no-print" onclick="window.print()">IMPRIMIR ETIQUETAS</button>
<?php
$total = count($codes);
$chunks = array_chunk($codes, 9); // Agrupar de a 9 para cada hoja 3x3
foreach ($chunks as $chunk_index => $chunk_codes):
?>
<div class="etiquetas-container">
<?php
foreach ($chunk_codes as $i => $code):
$index = ($chunk_index * 9) + $i;
$name = $product_names[$index] ?? '';
?>
<div class="etiqueta">
<div class="producto-nombre"><?php echo htmlspecialchars($name); ?></div>
<div class="barcode-container">
<?php
// widthFactor 1 + altura 70 en el SVG, escalado a 9.12mm en CSS
// resulta en una barra mínima de ~0.13mm (9.12 / 70 = 0.13)
echo $generator->getBarcode($code, 1, 70);
?>
</div>
<div class="sku-text"><?php echo htmlspecialchars($code); ?></div>
</div>
<?php endforeach; ?>
<?php
// Rellenar espacios vacíos si la última hoja no está completa
$empty_slots = 9 - count($chunk_codes);
for ($j = 0; $j < $empty_slots; $j++):
?>
<div class="etiqueta" style="visibility: hidden;"></div>
<?php endfor; ?>
</div>
<?php endforeach; ?>
</body>
</html>

View File

@ -1,123 +1,162 @@
<?php
// test_etiquetas.php - Página de prueba para impresión de etiquetas 3x3
// test_etiquetas.php - Prueba de etiquetas 3x3 con especificaciones exactas
require_once 'includes/barcode_generator.php';
$generator = new BarcodeGenerator();
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Prueba de Etiquetas 3x3</title>
<title>Prueba Etiquetas 3x3 - Especificaciones Exactas</title>
<style>
/* Estilos para pantalla */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 20px;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
}
.no-print {
margin-bottom: 20px;
padding: 15px 25px;
background: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
.no-print:hover {
background: #0056b3;
background-color: #f0f2f5;
}
/* Contenedor de etiquetas */
.no-print {
margin: 20px;
padding: 12px 25px;
background: #28a745;
color: white;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.no-print:hover {
background: #218838;
}
/* Hoja: 96mm x 75mm (Horizontal) */
.etiquetas-container {
width: 96mm;
height: 75mm;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(3, 1fr);
gap: 0; /* Sin espacio entre etiquetas */
width: 100mm; /* Ancho total del papel */
height: 75mm; /* Alto total del papel */
grid-template-columns: repeat(3, 28mm);
grid-template-rows: repeat(3, 21mm);
gap: 2mm;
justify-content: center;
align-content: center;
background: white;
padding: 0;
border: 1px solid #ccc;
box-sizing: border-box;
border: 1px dashed #ccc;
}
.etiqueta {
width: 28mm;
height: 21mm;
border: 0.1mm solid #eee;
padding: 1mm;
text-align: center;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 25mm; /* 75mm / 3 = 25mm */
width: 33.33mm; /* 100mm / 3 = 33.33mm */
box-sizing: border-box;
overflow: hidden;
text-align: center;
padding: 1mm;
}
.producto-nombre {
font-size: 8px;
font-size: 6px;
font-weight: bold;
line-height: 1;
margin-bottom: 1mm;
text-transform: uppercase;
line-height: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
}
.barcode-placeholder {
font-family: 'Courier New', Courier, monospace;
font-size: 12px;
letter-spacing: 1px;
border-top: 1px solid black;
padding-top: 1mm;
.barcode-container {
height: 9.12mm; /* Altura solicitada: 9.12mm */
display: flex;
justify-content: center;
align-items: center;
margin: 1mm 0;
padding: 0 2mm; /* Margen de 2mm solicitado */
box-sizing: border-box;
width: 100%;
}
.barcode-container svg {
height: 9.12mm;
width: auto;
shape-rendering: crispEdges;
}
.sku-text {
font-size: 7px;
font-weight: bold;
margin-top: 0.5mm;
letter-spacing: 0.5px;
}
/* Estilos específicos para IMPRESIÓN */
@media print {
@page {
size: 96mm 75mm landscape;
margin: 0;
}
body {
background: none;
padding: 0;
margin: 0;
padding: 0;
}
.no-print {
display: none;
}
.etiquetas-container {
border: none;
padding: 0;
box-shadow: none;
margin: 0;
width: 100mm;
height: 75mm;
}
.etiqueta {
border: none;
}
@page {
margin: 0;
size: 100mm 75mm;
}
}
</style>
</head>
<body>
<button class="no-print" onclick="window.print()">Imprimir Etiquetas de Prueba</button>
<button class="no-print" onclick="window.print()">IMPRIMIR PRUEBA (9.12mm alto)</button>
<div class="etiquetas-container">
<?php for ($i = 1; $i <= 9; $i++): ?>
<?php
$skus = ['AFS-0317', 'AFS-0318', 'AFS-0319', 'SKU-1001', 'SKU-1002', 'SKU-1003', 'TEST-001', 'TEST-002', 'TEST-003'];
for ($i = 0; $i < 9; $i++):
$sku = $skus[$i];
?>
<div class="etiqueta">
<div class="producto-nombre">Producto Ejemplo #<?php echo $i; ?></div>
<div class="barcode-placeholder">123456789</div>
<div style="font-size: 8px; margin-top: 1mm;">SKU-TEST-00<?php echo $i; ?></div>
<div class="producto-nombre">PRODUCTO <?php echo $sku; ?></div>
<div class="barcode-container">
<?php
// widthFactor 1 + altura 70 en el SVG, escalado a 9.12mm en CSS
// resulta en una barra mínima de ~0.13mm (9.12 / 70 = 0.13)
echo $generator->getBarcode($sku, 1, 70);
?>
</div>
<div class="sku-text"><?php echo $sku; ?></div>
</div>
<?php endfor; ?>
</div>
<div class="no-print" style="margin-top: 20px; color: #666; max-width: 400px; text-align: center;">
<p><strong>Nota:</strong> Al imprimir, asegúrate de seleccionar tu impresora <strong>REDPOS</strong> y en "Más ajustes" verifica que los márgenes estén en <strong>"Ninguno"</strong>.</p>
<div class="no-print" style="max-width: 500px; background: white; padding: 15px; border-radius: 8px; margin-top: 20px; font-size: 13px; line-height: 1.4; border: 1px solid #ddd;">
<p style="margin-top: 0;"><strong> Especificaciones Aplicadas:</strong></p>
<ul style="text-align: left; padding-left: 20px;">
<li><b>Tipo:</b> CODE 128</li>
<li><b>Altura:</b> 9.12 mm</li>
<li><b>Ancho:</b> ~24 mm</li>
<li><b>Margen lateral:</b> 2 mm</li>
<li><b>Ancho barra mínima:</b> 1 dot (~0.13mm)</li>
</ul>
</div>
</body>