diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php
index d8629b92dd6..c49a2963e3c 100644
--- a/htdocs/core/modules/product_batch/mod_lot_advanced.php
+++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php
@@ -84,6 +84,16 @@ class mod_lot_advanced extends ModeleNumRefBatch
$texte .= '
| ';
+ // Option to enable custom masks per product
+ $texte .= '';
+ if ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS) {
+ $texte .= ''.img_picto($langs->trans("Enabled"), 'on').'';
+ } else {
+ $texte .= ''.img_picto($langs->trans("Disabled"), 'off').'';
+ }
+ $texte .= ' '.$langs->trans('CustomMasks')."\n";
+ $texte .= ' | ';
+
$texte .= '';
$texte .= '';
diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php
index 89d70a8239d..74f36a55fe6 100644
--- a/htdocs/core/modules/product_batch/mod_sn_advanced.php
+++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php
@@ -84,6 +84,16 @@ class mod_sn_advanced extends ModeleNumRefBatch
$texte .= ' | ';
+ // Option to enable custom masks per product
+ $texte .= '';
+ if ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS) {
+ $texte .= ''.img_picto($langs->trans("Enabled"), 'on').'';
+ } else {
+ $texte .= ''.img_picto($langs->trans("Disabled"), 'off').'';
+ }
+ $texte .= ' '.$langs->trans('CustomMasks')."\n";
+ $texte .= ' | ';
+
$texte .= '';
$texte .= '';
diff --git a/htdocs/product/admin/product_lot.php b/htdocs/product/admin/product_lot.php
index 874f4b9e8a9..8cafa97e077 100644
--- a/htdocs/product/admin/product_lot.php
+++ b/htdocs/product/admin/product_lot.php
@@ -72,12 +72,16 @@ if ($action == 'updateMaskLot') {
dolibarr_set_const($db, "PRODUCTBATCH_LOT_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'setmodsn') {
dolibarr_set_const($db, "PRODUCTBATCH_SN_ADDON", $value, 'chaine', 0, '', $conf->entity);
-}
-if ($action == 'setmaskslot') {
+} elseif ($action == 'setmaskslot') {
dolibarr_set_const($db, "PRODUCTBATCH_LOT_USE_PRODUCT_MASKS", $value, 'bool', 0, '', $conf->entity);
-}
-if ($action == 'setmaskssn') {
+ if ($value == '1' && $conf->global->PRODUCTBATCH_LOT_ADDONS !== 'mod_lot_advanced') {
+ dolibarr_set_const($db, "PRODUCTBATCH_LOT_ADDON", 'mod_lot_advanced', 'chaine', 0, '', $conf->entity);
+ }
+} elseif ($action == 'setmaskssn') {
dolibarr_set_const($db, "PRODUCTBATCH_SN_USE_PRODUCT_MASKS", $value, 'bool', 0, '', $conf->entity);
+ if ($value == '1' && $conf->global->PRODUCTBATCH_SN_ADDONS !== 'mod_sn_advanced') {
+ dolibarr_set_const($db, "PRODUCTBATCH_SN_ADDON", 'mod_sn_advanced', 'chaine', 0, '', $conf->entity);
+ }
}
/*
@@ -182,40 +186,6 @@ foreach ($dirmodels as $reldir) {
}
}
closedir($handle);
- if ($conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') {
- print '| Option | '."\n";
- print $langs->trans('CustomMasks');
- print ' | ';
-
- // Show example of numbering model
- print '';
- $tmp = 'NoExample';
- if (preg_match('/^Error/', $tmp)) print ' '.$langs->trans($tmp).' ';
- elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
- else print $langs->trans($tmp);
- print ' | '."\n";
-
- print '';
- if ($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) {
- print '';
- print img_picto($langs->trans("Activated"), 'switch_on');
- print '';
- } else {
- print '';
- print img_picto($langs->trans("Disabled"), 'switch_off');
- print '';
- }
- print ' | ';
-
- // Info
- $htmltooltip = $langs->trans("LotProductTooltip");
-
- print '';
- print $form->textwithpicto('', $htmltooltip, 1, 0);
- print ' | ';
-
- print "
\n";
- }
}
}
}
@@ -308,40 +278,6 @@ foreach ($dirmodels as $reldir) {
}
}
closedir($handle);
- if ($conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced') {
- print '| Option | '."\n";
- print $langs->trans('CustomMasks');
- print ' | ';
-
- // Show example of numbering model
- print '';
- $tmp = 'NoExample';
- if (preg_match('/^Error/', $tmp)) print ' '.$langs->trans($tmp).' ';
- elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
- else print $langs->trans($tmp);
- print ' | '."\n";
-
- print '';
- if ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS) {
- print '';
- print img_picto($langs->trans("Activated"), 'switch_on');
- print '';
- } else {
- print '';
- print img_picto($langs->trans("Disabled"), 'switch_off');
- print '';
- }
- print ' | ';
-
- // Info
- $htmltooltip = $langs->trans("SNProductTooltip");
-
- print '';
- print $form->textwithpicto('', $htmltooltip, 1, 0);
- print ' | ';
-
- print "
\n";
- }
}
}
}