Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
parent
0e58edd896
commit
52dbd95223
@ -38,7 +38,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
||||
* Dolibarr version of the loaded document
|
||||
* @var string
|
||||
*/
|
||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
/**
|
||||
* @var string Error message
|
||||
@ -48,7 +48,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
||||
/**
|
||||
* @var string name
|
||||
*/
|
||||
public $name='advanced';
|
||||
public $name = 'advanced';
|
||||
|
||||
|
||||
/**
|
||||
@ -65,28 +65,28 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
||||
$form = new Form($db);
|
||||
|
||||
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
|
||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$texte.= '<input type="hidden" name="action" value="updateMask">';
|
||||
$texte.= '<input type="hidden" name="maskconstBom" value="MYMODULE_MYOBJECT_ADVANCED_MASK">';
|
||||
$texte.= '<table class="nobordernopadding" width="100%">';
|
||||
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$texte .= '<input type="hidden" name="action" value="updateMask">';
|
||||
$texte .= '<input type="hidden" name="maskconstBom" value="MYMODULE_MYOBJECT_ADVANCED_MASK">';
|
||||
$texte .= '<table class="nobordernopadding" width="100%">';
|
||||
|
||||
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject"));
|
||||
$tooltip.=$langs->trans("GenericMaskCodes2");
|
||||
$tooltip.=$langs->trans("GenericMaskCodes3");
|
||||
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject"));
|
||||
$tooltip.=$langs->trans("GenericMaskCodes5");
|
||||
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes2");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes3");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes5");
|
||||
|
||||
// Parametrage du prefix
|
||||
$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 .= '<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="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
||||
$texte .= '<td class="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
||||
|
||||
$texte.= '</tr>';
|
||||
$texte .= '</tr>';
|
||||
|
||||
$texte.= '</table>';
|
||||
$texte.= '</form>';
|
||||
$texte .= '</table>';
|
||||
$texte .= '</form>';
|
||||
|
||||
return $texte;
|
||||
}
|
||||
@ -98,17 +98,17 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
global $conf,$langs,$mysoc;
|
||||
global $conf, $langs, $mysoc;
|
||||
|
||||
$old_code_client=$mysoc->code_client;
|
||||
$old_code_type=$mysoc->typent_code;
|
||||
$mysoc->code_client='CCCCCCCCCC';
|
||||
$mysoc->typent_code='TTTTTTTTTT';
|
||||
$old_code_client = $mysoc->code_client;
|
||||
$old_code_type = $mysoc->typent_code;
|
||||
$mysoc->code_client = 'CCCCCCCCCC';
|
||||
$mysoc->typent_code = 'TTTTTTTTTT';
|
||||
$numExample = $this->getNextValue($mysoc, '');
|
||||
$mysoc->code_client=$old_code_client;
|
||||
$mysoc->typent_code=$old_code_type;
|
||||
$mysoc->code_client = $old_code_client;
|
||||
$mysoc->typent_code = $old_code_type;
|
||||
|
||||
if (! $numExample)
|
||||
if (!$numExample)
|
||||
{
|
||||
$numExample = $langs->trans('NotConfigured');
|
||||
}
|
||||
@ -123,22 +123,22 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
||||
*/
|
||||
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
|
||||
$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;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -34,19 +34,19 @@ class mod_myobject_standard extends ModeleNumRefMyObject
|
||||
* Dolibarr version of the loaded document
|
||||
* @var string
|
||||
*/
|
||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
public $prefix='MYOBJECT';
|
||||
public $prefix = 'MYOBJECT';
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error='';
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string name
|
||||
*/
|
||||
public $name='standard';
|
||||
public $name = 'standard';
|
||||
|
||||
|
||||
/**
|
||||
@ -80,26 +80,26 @@ class mod_myobject_standard extends ModeleNumRefMyObject
|
||||
*/
|
||||
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.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject";
|
||||
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($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");
|
||||
$this->error=$langs->trans('ErrorNumRefModel', $max);
|
||||
$this->error = $langs->trans('ErrorNumRefModel', $max);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -114,21 +114,21 @@ class mod_myobject_standard extends ModeleNumRefMyObject
|
||||
*/
|
||||
public function getNextValue($object)
|
||||
{
|
||||
global $db,$conf;
|
||||
global $db, $conf;
|
||||
|
||||
// D'abord on recupere la valeur max
|
||||
$posindice=9;
|
||||
$posindice = 9;
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject";
|
||||
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) $max = intval($obj->max);
|
||||
else $max=0;
|
||||
else $max = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -137,11 +137,11 @@ class mod_myobject_standard extends ModeleNumRefMyObject
|
||||
}
|
||||
|
||||
//$date=time();
|
||||
$date=$object->date_creation;
|
||||
$date = $object->date_creation;
|
||||
$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
|
||||
else $num = sprintf("%04s", $max+1);
|
||||
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);
|
||||
|
||||
dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||
return $this->prefix.$yymm."-".$num;
|
||||
|
||||
@ -649,8 +649,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
|
||||
print '<td class="right">';
|
||||
$help = '';
|
||||
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->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 ($help) {
|
||||
print $form->textwithpicto($line->qty, $help, -1);
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user