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

View File

@ -53,9 +53,9 @@ class mod_lot_free extends ModeleNumRefBatch
public $code_null; // Code facultatif
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
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
*/
public function info()
@ -103,5 +102,4 @@ class mod_lot_free extends ModeleNumRefBatch
global $langs;
return '';
}
}

View File

@ -57,7 +57,7 @@ class mod_lot_standard extends ModeleNumRefBatch
public function info()
{
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;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$row = $db->fetch_row($resql);
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);
return false;
@ -125,14 +123,11 @@ class mod_lot_standard extends ModeleNumRefBatch
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max = 0;
}
else
{
} else {
dol_syslog("mod_lot_standard::getNextValue", LOG_DEBUG);
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
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
@ -52,14 +52,14 @@ class mod_sn_advanced extends ModeleNumRefBatch
public $name = 'sn_advanced';
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
*/
public function info()
{
global $conf, $langs, $db;
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
*/
public function info()
{
global $conf, $langs, $db;
$langs->load("bills");
@ -90,31 +90,30 @@ class mod_sn_advanced extends ModeleNumRefBatch
$texte .= '</form>';
return $texte;
}
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $conf, $langs, $mysoc;
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $conf, $langs, $mysoc;
$old_code_client = $mysoc->code_client;
$old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';
$numExample = $this->getNextValue($mysoc, '');
$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;
if (!$numExample)
{
if (!$numExample) {
$numExample = $langs->trans('NotConfigured');
}
return $numExample;
}
}
/**
* Return next free value
@ -123,8 +122,8 @@ class mod_sn_advanced extends ModeleNumRefBatch
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objprod, $object)
{
public function getNextValue($objprod, $object)
{
global $db, $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@ -132,8 +131,7 @@ class mod_sn_advanced extends ModeleNumRefBatch
// We get cursor rule
$mask = $conf->global->BATCH_ADVANCED_MASK;
if (!$mask)
{
if (!$mask) {
$this->error = 'NotConfigured';
return 0;
}

View File

@ -52,9 +52,9 @@ class mod_sn_free extends ModeleNumRefBatch
public $code_null; // Code facultatif
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
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
*/
public function info()
@ -102,5 +101,4 @@ class mod_sn_free extends ModeleNumRefBatch
global $langs;
return '';
}
}

View File

@ -57,7 +57,7 @@ class mod_sn_standard extends ModeleNumRefBatch
public function info()
{
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;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$row = $db->fetch_row($resql);
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);
return false;
@ -125,14 +123,11 @@ class mod_sn_standard extends ModeleNumRefBatch
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max = 0;
}
else
{
} else {
dol_syslog("mod_sn_standard::getNextValue", LOG_DEBUG);
return -1;
}

View File

@ -150,4 +150,4 @@ abstract class ModeleNumRefBatch
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
}
}

View File

@ -42,8 +42,7 @@ $value = GETPOST('value', 'alpha');
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMaskLot')
{
if ($action == 'updateMaskLot') {
$maskconstbatch = GETPOST('maskconstLot', 'alpha');
$maskbatch = GETPOST('maskLot', 'alpha');
@ -51,17 +50,13 @@ if ($action == 'updateMaskLot')
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'updateMaskSN')
{
} elseif ($action == 'updateMaskSN') {
$maskconstbatch = GETPOST('maskconstSN', 'alpha');
$maskbatch = GETPOST('maskSN', 'alpha');
@ -69,21 +64,16 @@ if ($action == 'updateMaskLot')
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'setmodlot')
{
} elseif ($action == 'setmodlot') {
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);
}
@ -125,15 +115,12 @@ foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/product_batch/");
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
if (is_resource($handle)) {
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);
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 == '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 $module->info();
print '</td>';
@ -159,12 +145,9 @@ foreach ($dirmodels as $reldir)
print '</td>'."\n";
print '<td class="center">';
if ($conf->global->LOT_ADDON == $file)
{
if ($conf->global->LOT_ADDON == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
}
else
{
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodlot&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
@ -226,15 +209,12 @@ foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/product_batch/");
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
if (is_resource($handle)) {
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);
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 == '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 $module->info();
print '</td>';
@ -260,12 +239,9 @@ foreach ($dirmodels as $reldir)
print '</td>'."\n";
print '<td class="center">';
if ($conf->global->SN_ADDON == $file)
{
if ($conf->global->SN_ADDON == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
}
else
{
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmodsn&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';