try to fix sticker

This commit is contained in:
Christophe Battarel 2021-03-11 11:30:12 +01:00
parent e8aacc7acf
commit 229c581a25
8 changed files with 80 additions and 122 deletions

View File

@ -109,12 +109,11 @@ class mod_lot_advanced extends ModeleNumRefBatch
$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');
} }
return $numExample; return $numExample;
} }
/** /**
* Return next free value * Return next free value
@ -123,8 +122,8 @@ class mod_lot_advanced extends ModeleNumRefBatch
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO * @return string Value if KO, <0 if KO
*/ */
public function getNextValue($objprod, $object) public function getNextValue($objprod, $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';
@ -132,8 +131,7 @@ class mod_lot_advanced extends ModeleNumRefBatch
// We get cursor rule // We get cursor rule
$mask = $conf->global->BATCH_ADVANCED_MASK; $mask = $conf->global->BATCH_ADVANCED_MASK;
if (!$mask) if (!$mask) {
{
$this->error = 'NotConfigured'; $this->error = 'NotConfigured';
return 0; return 0;
} }

View File

@ -53,9 +53,9 @@ class mod_lot_free extends ModeleNumRefBatch
public $code_null; // Code facultatif public $code_null; // Code facultatif
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/** /**
@ -78,9 +78,8 @@ class mod_lot_free extends ModeleNumRefBatch
/** /**
* Return description of module * Return description of module
* *
* @param Translate $langs Object langs
* @return string Description of module * @return string Description of module
*/ */
public function info() public function info()
@ -103,5 +102,4 @@ class mod_lot_free extends ModeleNumRefBatch
global $langs; global $langs;
return ''; return '';
} }
} }

View File

@ -57,7 +57,7 @@ class mod_lot_standard extends ModeleNumRefBatch
public function info() public function info()
{ {
global $langs; global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix); return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
} }
@ -91,13 +91,11 @@ class mod_lot_standard extends ModeleNumRefBatch
$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;
@ -125,14 +123,11 @@ class mod_lot_standard extends ModeleNumRefBatch
$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
{
dol_syslog("mod_lot_standard::getNextValue", LOG_DEBUG); dol_syslog("mod_lot_standard::getNextValue", LOG_DEBUG);
return -1; return -1;
} }

View File

@ -36,9 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batc
class mod_sn_advanced extends ModeleNumRefBatch class mod_sn_advanced extends ModeleNumRefBatch
{ {
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/** /**
@ -52,14 +52,14 @@ class mod_sn_advanced extends ModeleNumRefBatch
public $name = 'sn_advanced'; public $name = 'sn_advanced';
/** /**
* Returns the description of the numbering model * Returns the description of the numbering model
* *
* @return string Texte descripif * @return string Texte descripif
*/ */
public function info() public function info()
{ {
global $conf, $langs, $db; global $conf, $langs, $db;
$langs->load("bills"); $langs->load("bills");
@ -90,31 +90,30 @@ class mod_sn_advanced extends ModeleNumRefBatch
$texte .= '</form>'; $texte .= '</form>';
return $texte; return $texte;
} }
/** /**
* Return an example of numbering * Return an example of numbering
* *
* @return string Example * @return string Example
*/ */
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');
} }
return $numExample; return $numExample;
} }
/** /**
* Return next free value * Return next free value
@ -123,8 +122,8 @@ class mod_sn_advanced extends ModeleNumRefBatch
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO * @return string Value if KO, <0 if KO
*/ */
public function getNextValue($objprod, $object) public function getNextValue($objprod, $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';
@ -132,8 +131,7 @@ class mod_sn_advanced extends ModeleNumRefBatch
// We get cursor rule // We get cursor rule
$mask = $conf->global->BATCH_ADVANCED_MASK; $mask = $conf->global->BATCH_ADVANCED_MASK;
if (!$mask) if (!$mask) {
{
$this->error = 'NotConfigured'; $this->error = 'NotConfigured';
return 0; return 0;
} }

View File

@ -52,9 +52,9 @@ class mod_sn_free extends ModeleNumRefBatch
public $code_null; // Code facultatif public $code_null; // Code facultatif
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/** /**
@ -77,9 +77,8 @@ class mod_sn_free extends ModeleNumRefBatch
/** /**
* Return description of module * Return description of module
* *
* @param Translate $langs Object langs
* @return string Description of module * @return string Description of module
*/ */
public function info() public function info()
@ -102,5 +101,4 @@ class mod_sn_free extends ModeleNumRefBatch
global $langs; global $langs;
return ''; return '';
} }
} }

View File

@ -57,7 +57,7 @@ class mod_sn_standard extends ModeleNumRefBatch
public function info() public function info()
{ {
global $langs; global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix); return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
} }
@ -91,13 +91,11 @@ class mod_sn_standard extends ModeleNumRefBatch
$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;
@ -125,14 +123,11 @@ class mod_sn_standard extends ModeleNumRefBatch
$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
{
dol_syslog("mod_sn_standard::getNextValue", LOG_DEBUG); dol_syslog("mod_sn_standard::getNextValue", LOG_DEBUG);
return -1; return -1;
} }

View File

@ -42,8 +42,7 @@ $value = GETPOST('value', 'alpha');
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMaskLot') if ($action == 'updateMaskLot') {
{
$maskconstbatch = GETPOST('maskconstLot', 'alpha'); $maskconstbatch = GETPOST('maskconstLot', 'alpha');
$maskbatch = GETPOST('maskLot', 'alpha'); $maskbatch = GETPOST('maskLot', 'alpha');
@ -51,17 +50,13 @@ if ($action == 'updateMaskLot')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error) {
{ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else {
} setEventMessages($langs->trans("Error"), null, 'errors');
else }
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'updateMaskSN') } elseif ($action == 'updateMaskSN') {
{
$maskconstbatch = GETPOST('maskconstSN', 'alpha'); $maskconstbatch = GETPOST('maskconstSN', 'alpha');
$maskbatch = GETPOST('maskSN', 'alpha'); $maskbatch = GETPOST('maskSN', 'alpha');
@ -69,21 +64,16 @@ if ($action == 'updateMaskLot')
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) if (!$error) {
{ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else {
} setEventMessages($langs->trans("Error"), null, 'errors');
else }
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'setmodlot') } elseif ($action == 'setmodlot') {
{
dolibarr_set_const($db, "LOT_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "LOT_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'setmodsn') } elseif ($action == 'setmodsn') {
{
dolibarr_set_const($db, "SN_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "SN_ADDON", $value, 'chaine', 0, '', $conf->entity);
} }
@ -125,15 +115,12 @@ foreach ($dirmodels as $reldir)
{ {
$dir = dol_buildpath($reldir."core/modules/product_batch/"); $dir = dol_buildpath($reldir."core/modules/product_batch/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (substr($file, 0, 8) == 'mod_lot_' && substr($file, dol_strlen($file) - 3, 3) == 'php') if (substr($file, 0, 8) == 'mod_lot_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -144,8 +131,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -159,12 +145,9 @@ foreach ($dirmodels as $reldir)
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->LOT_ADDON == $file) if ($conf->global->LOT_ADDON == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} } else {
else
{
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodlot&amp;value='.$file.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodlot&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>'; print '</a>';
@ -226,15 +209,12 @@ foreach ($dirmodels as $reldir)
{ {
$dir = dol_buildpath($reldir."core/modules/product_batch/"); $dir = dol_buildpath($reldir."core/modules/product_batch/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (substr($file, 0, 7) == 'mod_sn_' && substr($file, dol_strlen($file) - 3, 3) == 'php') if (substr($file, 0, 7) == 'mod_sn_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -245,8 +225,7 @@ foreach ($dirmodels as $reldir)
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -260,12 +239,9 @@ foreach ($dirmodels as $reldir)
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->SN_ADDON == $file) if ($conf->global->SN_ADDON == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} } else {
else
{
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodsn&amp;value='.$file.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodsn&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>'; print '</a>';