Commit e60aaa8d authored by Philippe Corbes's avatar Philippe Corbes
Browse files

Check and print ean8 or ean 13 or code128 barcode in print label page


Signed-off-by: Philippe Corbes's avatarPhilippe Corbes <philippe.corbes@gmail.com>
parent ce4e238c
......@@ -60,10 +60,20 @@ function pdf_barcode($pdf, $productId, $col, $row) {
$pdf->SetXY($x, $y);
$pdf->Cell(BARCODE_WIDTH, TEXT_HEIGHT, utf8_decode($product->reference), 0, 1, "C");
$pdf->SetXY($x, $y + TEXT_HEIGHT);
if ($product->barcode == \BarcodeEAN::compute($product->barcode, "ean8")) {
$format = "ean8";
$lwidth = BARCODE_WIDTH / (15 * 7);
} else if ($product->barcode == \BarcodeEAN::compute($product->barcode, "ean13")) {
$format = "ean13";
$lwidth = BARCODE_WIDTH / (15 * 7);
} else {
$format = "code128";
$lwidth = BARCODE_WIDTH / (15 * 9);
}
$data = \Barcode::fpdf($pdf, "000000",
$pdf->GetX() + BARCODE_WIDTH / 2, $pdf->GetY() + BARCODE_HEIGHT / 2,
0, "ean13", array('code' => $product->barcode),
BARCODE_WIDTH / (15 * 7), BARCODE_HEIGHT);
0, $format, array('code' => $product->barcode),
$lwidth, BARCODE_HEIGHT);
$pdf->SetXY($x, $y + BARCODE_HEIGHT + TEXT_HEIGHT);
$pdf->Cell(BARCODE_WIDTH, TEXT_HEIGHT, $product->barcode, 0, 1, "C");
}
......
......@@ -177,12 +177,15 @@ function pdf_label($pdf, $productId, $col, $row, $h_margin, $v_margin) {
// Barcode
if ( BARCODE_X >= 0) {
$pdf->SetXY($x + BARCODE_X, $y + BARCODE_Y);
if (strlen($product->barcode) == 8) {
if ($product->barcode == \BarcodeEAN::compute($product->barcode, "ean8")) {
$format = "ean8";
} else if (strlen($product->barcode) == 13) {
$lwidth = BARCODE_WIDTH / (15 * 7);
} else if ($product->barcode == \BarcodeEAN::compute($product->barcode, "ean13")) {
$format = "ean13";
$lwidth = BARCODE_WIDTH / (15 * 7);
} else {
$format = "code128";
$lwidth = BARCODE_WIDTH / (15 * 9);
}
$data = \Barcode::fpdf($pdf,
"000000",
......@@ -191,7 +194,7 @@ function pdf_label($pdf, $productId, $col, $row, $h_margin, $v_margin) {
BARCODE_ANGLE,
$format,
array('code' => $product->barcode),
BARCODE_WIDTH / (15 * 7),
$lwidth,
BARCODE_HEIGHT);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment