Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2020-01-09 23:02:05 +00:00
parent 0e58edd896
commit 52dbd95223
3 changed files with 58 additions and 58 deletions

View File

@ -48,7 +48,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
/** /**
* @var string name * @var string name
*/ */
public $name='advanced'; public $name = 'advanced';
/** /**
@ -65,28 +65,28 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
$form = new Form($db); $form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">'; $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="updateMask">'; $texte .= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstBom" value="MYMODULE_MYOBJECT_ADVANCED_MASK">'; $texte .= '<input type="hidden" name="maskconstBom" value="MYMODULE_MYOBJECT_ADVANCED_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">'; $texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject")); $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject"));
$tooltip.=$langs->trans("GenericMaskCodes2"); $tooltip .= $langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3"); $tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject")); $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject"));
$tooltip.=$langs->trans("GenericMaskCodes5"); $tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix // Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskMyObject" value="'.$conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK.'">', $tooltip, 1, 1).'</td>'; $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskMyObject" value="'.$conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>'; $texte .= '</tr>';
$texte.= '</table>'; $texte .= '</table>';
$texte.= '</form>'; $texte .= '</form>';
return $texte; return $texte;
} }
@ -98,17 +98,17 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
*/ */
public function getExample() public function getExample()
{ {
global $conf,$langs,$mysoc; global $conf, $langs, $mysoc;
$old_code_client=$mysoc->code_client; $old_code_client = $mysoc->code_client;
$old_code_type=$mysoc->typent_code; $old_code_type = $mysoc->typent_code;
$mysoc->code_client='CCCCCCCCCC'; $mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code='TTTTTTTTTT'; $mysoc->typent_code = 'TTTTTTTTTT';
$numExample = $this->getNextValue($mysoc, ''); $numExample = $this->getNextValue($mysoc, '');
$mysoc->code_client=$old_code_client; $mysoc->code_client = $old_code_client;
$mysoc->typent_code=$old_code_type; $mysoc->typent_code = $old_code_type;
if (! $numExample) if (!$numExample)
{ {
$numExample = $langs->trans('NotConfigured'); $numExample = $langs->trans('NotConfigured');
} }
@ -123,22 +123,22 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
*/ */
public function getNextValue($object) public function getNextValue($object)
{ {
global $db,$conf; global $db, $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// We get cursor rule // We get cursor rule
$mask=$conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK; $mask = $conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK;
if (! $mask) if (!$mask)
{ {
$this->error='NotConfigured'; $this->error = 'NotConfigured';
return 0; return 0;
} }
$date = $object->date; $date = $object->date;
$numFinal=get_next_value($db, $mask, 'mymodule_myobject', 'ref', '', null, $date); $numFinal = get_next_value($db, $mask, 'mymodule_myobject', 'ref', '', null, $date);
return $numFinal; return $numFinal;
} }

View File

@ -36,17 +36,17 @@ class mod_myobject_standard extends ModeleNumRefMyObject
*/ */
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='MYOBJECT'; public $prefix = 'MYOBJECT';
/** /**
* @var string Error code (or message) * @var string Error code (or message)
*/ */
public $error=''; public $error = '';
/** /**
* @var string name * @var string name
*/ */
public $name='standard'; public $name = 'standard';
/** /**
@ -80,26 +80,26 @@ class mod_myobject_standard extends ModeleNumRefMyObject
*/ */
public function canBeActivated() public function canBeActivated()
{ {
global $conf,$langs,$db; global $conf, $langs, $db;
$coyymm=''; $max=''; $coyymm = ''; $max = '';
$posindice=8; $posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; $sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql=$db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
} }
if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{ {
$langs->load("errors"); $langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max); $this->error = $langs->trans('ErrorNumRefModel', $max);
return false; return false;
} }
@ -114,21 +114,21 @@ class mod_myobject_standard extends ModeleNumRefMyObject
*/ */
public function getNextValue($object) public function getNextValue($object)
{ {
global $db,$conf; global $db, $conf;
// D'abord on recupere la valeur max // D'abord on recupere la valeur max
$posindice=9; $posindice = 9;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; $sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql=$db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max); if ($obj) $max = intval($obj->max);
else $max=0; else $max = 0;
} }
else else
{ {
@ -137,11 +137,11 @@ class mod_myobject_standard extends ModeleNumRefMyObject
} }
//$date=time(); //$date=time();
$date=$object->date_creation; $date = $object->date_creation;
$yymm = strftime("%y%m", $date); $yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1); else $num = sprintf("%04s", $max + 1);
dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num); dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num; return $this->prefix.$yymm."-".$num;

View File

@ -649,8 +649,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'.$tmpproduct->getNomUrl(1).'</td>'; print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td class="right">'; print '<td class="right">';
$help = ''; $help = '';
if ($line->qty_frozen) $help.=($help ? '<br>' : '').'<strong>'.$langs->trans("QuantityFrozen").'</strong>: '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; if ($line->qty_frozen) $help .= ($help ? '<br>' : '').'<strong>'.$langs->trans("QuantityFrozen").'</strong>: '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')';
if ($line->disable_stock_change) $help.=($help ? '<br>' : '').'<strong>'.$langs->trans("DisableStockChange").'</strong>: '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; if ($line->disable_stock_change) $help .= ($help ? '<br>' : '').'<strong>'.$langs->trans("DisableStockChange").'</strong>: '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')';
if ($help) { if ($help) {
print $form->textwithpicto($line->qty, $help, -1); print $form->textwithpicto($line->qty, $help, -1);
} else { } else {