Skip to content

Commit

Permalink
fixup! fix phpstan (Dolibarr#28727)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Mar 11, 2024
1 parent 77c10d6 commit eefe123
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions htdocs/core/modules/barcode/mod_barcode_product_standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2007-2012 Regis Houssin <[email protected]>
* Copyright (C) 2011 Juanjo Menent <[email protected]>
* Copyright (C) 2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -157,14 +158,19 @@ public function literalBarcodeType($db, $type = 0)
/**
* Return next value
*
* @param Product $objproduct Object product
* @param string $type Type of barcode (EAN, ISBN, ...)
* @param CommonObject $objproduct Object product
* @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value if OK, '' if module not configured, <0 if KO
*/
public function getNextValue($objproduct, $type = '')
{
global $db, $conf;

if (!$objproduct instanceof Product) {
dol_syslog(get_class($this)."::getNextValue used on incompatible".get_class($objproduct), LOG_ERR);
return -1;
}

require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // to be able to call function barcode_gen_ean_sum($ean)

Expand Down Expand Up @@ -192,19 +198,19 @@ public function getNextValue($objproduct, $type = '')

$numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now);
//Begin barcode with key: for barcode with key (EAN13...) calculate and substitute the last character (* or ?) used in the mask by the key
if ((substr($numFinal, -1)=='*') or (substr($numFinal, -1)=='?')) { // if last mask character is * or ? a joker, probably we have to calculate a key as last character (EAN13...)
if ((substr($numFinal, -1) == '*') or (substr($numFinal, -1) == '?')) { // if last mask character is * or ? a joker, probably we have to calculate a key as last character (EAN13...)
$literaltype = '';
$literaltype = $this->literalBarcodeType($db, $type);//get literal_Barcode_Type
switch ($literaltype) {
case 'EAN13': //EAN13 rowid = 2
if (strlen($numFinal)==13) {// be sure that the mask length is correct for EAN13
if (strlen($numFinal) == 13) {// be sure that the mask length is correct for EAN13
$ean = substr($numFinal, 0, 12); //take first 12 digits
$eansum = barcode_gen_ean_sum($ean);
$eansum = barcode_gen_ean_sum($ean);
$ean .= $eansum; //substitute the las character by the key
$numFinal = $ean;
}
break;
// Other barcode cases with key could be written here
// Other barcode cases with key could be written here
default:
break;
}
Expand Down

0 comments on commit eefe123

Please sign in to comment.