Autosave: 20260521-213229

This commit is contained in:
Flatlogic Bot 2026-05-21 21:32:30 +00:00
parent cd09784a88
commit 621d2a48d9
5 changed files with 38 additions and 101 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

View File

@ -62,40 +62,27 @@ if (empty($codes)) {
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: flex-start; /* Cambiado de center a flex-start para controlar el inicio */
align-items: center; align-items: center;
overflow: hidden; overflow: hidden;
text-align: center; text-align: center;
padding: 2mm 1mm 1mm 1mm; /* Reducido para dar más espacio vertical */ padding: 6mm 1mm 1mm 1mm; /* Aumentado de 4mm a 6mm para bajar más el contenido */
border: 0.1mm solid #eee; /* Guía visual en pantalla */ border: 0.1mm solid #eee; /* Guía visual en pantalla */
} }
.producto-nombre {
font-size: 6px;
line-height: 1.1;
margin-bottom: 1.5mm; /* Aumentado para separar del código */
text-transform: uppercase;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
width: 100%;
word-break: break-all;
}
.barcode-container { .barcode-container {
height: 9mm; height: 11mm;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin: 0.8mm 0; /* Ajuste milimétrico vertical */ margin: 0; /* Eliminado margen para control total con el padding de la etiqueta */
padding: 0 1mm; padding: 0 1mm;
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
} }
.barcode-container svg { .barcode-container svg {
height: 9mm; height: 11mm; /* Aumentado de 9mm a 11mm */
width: auto; width: auto;
display: block; display: block;
margin: 0 auto; margin: 0 auto;
@ -103,7 +90,7 @@ if (empty($codes)) {
.sku-text { .sku-text {
font-size: 7px; font-size: 7px;
margin-top: 1.2mm; /* Aumentado para separar del código */ margin-top: 1mm; /* Reducido ligeramente */
letter-spacing: 0.5px; letter-spacing: 0.5px;
} }
@ -148,11 +135,10 @@ if (empty($codes)) {
$name = $product_names[$index] ?? ''; $name = $product_names[$index] ?? '';
?> ?>
<div class="etiqueta"> <div class="etiqueta">
<div class="producto-nombre"><?php echo htmlspecialchars($name); ?></div>
<div class="barcode-container"> <div class="barcode-container">
<?php <?php
// widthFactor 1.0 y barReduction 0.15 para separar un poco más las barras // Altura aumentada a 88 para mayor facilidad de escaneo
echo $generator->getBarcode($code, 1.0, 72, 'black', 0.15); echo $generator->getBarcode($code, 1.0, 88, 'black', 0.25);
?> ?>
</div> </div>
<div class="sku-text"><?php echo htmlspecialchars($code); ?></div> <div class="sku-text"><?php echo htmlspecialchars($code); ?></div>

View File

@ -27,14 +27,14 @@ class BarcodeGenerator
if ($i % 2 == 0) { // Even indices are bars, odd are spaces if ($i % 2 == 0) { // Even indices are bars, odd are spaces
// Apply bar reduction to increase white space between bars // Apply bar reduction to increase white space between bars
$drawWidth = max(0.4, $width - $barReduction); $drawWidth = max(0.4, $width - $barReduction);
$bars .= '<rect x="' . $x . '" y="0" width="' . $drawWidth . '" height="' . $height . '" style="fill:' . $foregroundColor . ';" />'; $bars .= '<rect x="' . $x . '" y="0" width="' . $drawWidth . '" height="' . $height . '" fill="' . $foregroundColor . '" />';
} }
$x += $width; $x += $width;
} }
$totalWidth = $x + $quietZone; $totalWidth = $x + $quietZone;
$svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="' . $totalWidth . '" height="' . $height . '" viewBox="0 0 ' . $totalWidth . ' ' . $height . '">'; $svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="' . $totalWidth . '" height="' . $height . '" viewBox="0 0 ' . $totalWidth . ' ' . $height . '" shape-rendering="crispEdges">';
$svg .= '<rect width="' . $totalWidth . '" height="' . $height . '" style="fill:white;" />'; $svg .= '<rect width="' . $totalWidth . '" height="' . $height . '" fill="white" />';
$svg .= $bars; $svg .= $bars;
$svg .= '</svg>'; $svg .= '</svg>';
@ -43,36 +43,23 @@ class BarcodeGenerator
private function getBarcodeData($code) private function getBarcodeData($code)
{ {
// Remove any accidental spaces and trim
$code = str_replace(' ', '', trim($code));
$len = strlen($code); $len = strlen($code);
$indices = []; $indices = [104]; // Start B (Standard Set B)
// Check if code is purely numeric and has even length for Code 128C
// Or just use Code 128B as fallback
if (ctype_digit($code) && $len >= 2) {
$indices[] = 105; // Start C
for ($i = 0; $i < $len; $i += 2) {
if ($i + 1 < $len) {
$indices[] = (int)substr($code, $i, 2);
} else {
// Odd number of digits, switch to B for the last one
$indices[] = 100; // Code B
$indices[] = $this->getCharValue('B', $code[$i]);
}
}
} else {
$indices[] = 104; // Start B
for ($i = 0; $i < $len; $i++) { for ($i = 0; $i < $len; $i++) {
$val = $this->getCharValue('B', $code[$i]); $char = $code[$i];
$val = $this->getCharValue('B', $char);
if ($val !== null) { if ($val !== null) {
$indices[] = $val; $indices[] = $val;
} }
} }
}
// Checksum calculation // Checksum calculation
$sum = $indices[0]; $sum = $indices[0];
for ($k = 1; $k < count($indices); $k++) { for ($i = 1; $i < count($indices); $i++) {
$sum += ($indices[$k] * $k); $sum += ($indices[$i] * $i);
} }
$checksum = $sum % 103; $checksum = $sum % 103;
$indices[] = $checksum; $indices[] = $checksum;

View File

@ -1,5 +1,5 @@
<?php <?php
// test_etiquetas.php - Prueba de etiquetas 3x3 con especificaciones exactas // test_etiquetas.php - Prueba de etiquetas con Opción 3 (Finas)
require_once 'includes/barcode_generator.php'; require_once 'includes/barcode_generator.php';
$generator = new BarcodeGenerator(); $generator = new BarcodeGenerator();
?> ?>
@ -7,7 +7,7 @@ $generator = new BarcodeGenerator();
<html lang="es"> <html lang="es">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Prueba Etiquetas 3x3 - Especificaciones Exactas</title> <title>Prueba Etiquetas - Opción 3 (Finas)</title>
<style> <style>
body { body {
font-family: Verdana, sans-serif; font-family: Verdana, sans-serif;
@ -57,39 +57,26 @@ $generator = new BarcodeGenerator();
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: flex-start;
align-items: center; align-items: center;
overflow: hidden; overflow: hidden;
text-align: center; text-align: center;
padding: 2mm 1mm 1mm 1mm; /* Reducido para dar más espacio vertical */ padding: 6mm 1mm 1mm 1mm; /* Aumentado de 4mm a 6mm para bajar más el contenido */
}
.producto-nombre {
font-size: 6px;
line-height: 1.1;
margin-bottom: 1.5mm; /* Aumentado para separar del código */
text-transform: uppercase;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
width: 100%;
word-break: break-all;
} }
.barcode-container { .barcode-container {
height: 9mm; height: 11mm;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin: 0.8mm 0; /* Ajuste milimétrico vertical */ margin: 0;
padding: 0 1mm; padding: 0 1mm;
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
} }
.barcode-container svg { .barcode-container svg {
height: 9mm; height: 11mm; /* Aumentado de 9mm a 11mm */
width: auto; width: auto;
display: block; display: block;
margin: 0 auto; margin: 0 auto;
@ -97,7 +84,7 @@ $generator = new BarcodeGenerator();
.sku-text { .sku-text {
font-size: 7px; font-size: 7px;
margin-top: 1.2mm; /* Aumentado para separar del código */ margin-top: 1mm;
letter-spacing: 0.5px; letter-spacing: 0.5px;
} }
@ -127,38 +114,15 @@ $generator = new BarcodeGenerator();
</head> </head>
<body> <body>
<button class="no-print" onclick="window.print()">IMPRIMIR PRUEBA (9mm alto)</button> <button class="no-print" onclick="window.print()">IMPRIMIR PRUEBA (Opción 3)</button>
<div class="etiquetas-container"> <div class="etiquetas-container">
<?php <?php
// Fila 1: Configuración Actual (Equilibrada) $skus = ['AFS-0317', 'AFS-0318', 'AFS-0319', 'AFS-0320', 'AFS-0321', 'AFS-0322', 'AFS-0323', 'AFS-0324', 'AFS-0325'];
// Fila 2: Líneas Reforzadas (Más gruesas para impresoras con poca fuerza)
// Fila 3: Contraste Alto (Líneas más finas, espacios blancos más grandes)
$skus = ['AFS-0317', 'AFS-0318', 'AFS-0319'];
// Fila 1: Actual
foreach ($skus as $sku) { foreach ($skus as $sku) {
echo '<div class="etiqueta"> echo '<div class="etiqueta">
<div class="producto-nombre">OPCIÓN 1: ACTUAL</div> <div class="barcode-container">' . $generator->getBarcode($sku, 1.0, 88, 'black', 0.25) . '</div>
<div class="barcode-container">' . $generator->getBarcode($sku, 1.0, 72, 'black', 0.15) . '</div>
<div class="sku-text">' . $sku . '</div>
</div>';
}
// Fila 2: Reforzada (Líneas más gruesas)
foreach ($skus as $sku) {
echo '<div class="etiqueta">
<div class="producto-nombre">OPCIÓN 2: REFORZADA</div>
<div class="barcode-container">' . $generator->getBarcode($sku, 1.1, 72, 'black', 0.05) . '</div>
<div class="sku-text">' . $sku . '</div>
</div>';
}
// Fila 3: Contraste Alto (Líneas más finas)
foreach ($skus as $sku) {
echo '<div class="etiqueta">
<div class="producto-nombre">OPCIÓN 3: FINAS</div>
<div class="barcode-container">' . $generator->getBarcode($sku, 1.0, 72, 'black', 0.25) . '</div>
<div class="sku-text">' . $sku . '</div> <div class="sku-text">' . $sku . '</div>
</div>'; </div>';
} }
@ -166,13 +130,13 @@ $generator = new BarcodeGenerator();
</div> </div>
<div class="no-print" style="max-width: 600px; background: white; padding: 15px; border-radius: 8px; margin-top: 20px; font-size: 13px; line-height: 1.4; border: 1px solid #ddd;"> <div class="no-print" style="max-width: 600px; 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>🔬 Prueba de Grosor de Líneas:</strong></p> <p style="margin-top: 0;"><strong>Revertido a la versión estable:</strong></p>
<ul style="text-align: left; padding-left: 20px;"> <ul style="text-align: left; padding-left: 20px;">
<li><b>Opción 1 (Actual):</b> El equilibrio que veníamos usando.</li> <li>Se ha eliminado la optimización "Auto" que causaba errores de escaneo.</li>
<li><b>Opción 2 (Reforzada):</b> Las líneas negras son más anchas. Útil si tu impresora imprime muy "pálido".</li> <li>Se ha aplicado la <b>Opción 3 (Finas)</b> que confirmaste que funcionaba.</li>
<li><b>Opción 3 (Finas):</b> Las líneas negras son más delgadas, dejando más espacio blanco. Útil si la tinta térmica se "chorrea" o expande mucho.</li> <li>Las líneas son más delgadas y los espacios blancos más grandes para evitar que se "peguen".</li>
</ul> </ul>
<p><b>¿Cuál de las 3 filas escanea más rápido con tu lector?</b></p> <p>Por favor, imprime esta prueba y confirma si vuelve a escanear correctamente.</p>
</div> </div>
</body> </body>