24 require
'../../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
30 $langs->loadLangs(array(
"admin",
"products",
"productbatch"));
33 if (!$user->admin || (empty($conf->productbatch->enabled)))
36 $action =
GETPOST(
'action',
'alpha');
37 $value =
GETPOST(
'value',
'alpha');
46 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
48 if ($action ==
'updateMaskLot') {
49 $maskconstbatch =
GETPOST(
'maskconstLot',
'alpha');
50 $maskbatch =
GETPOST(
'maskLot',
'alpha');
52 if ($maskconstbatch) {
53 $res =
dolibarr_set_const($db, $maskconstbatch, $maskbatch,
'chaine', 0,
'', $conf->entity);
54 if ($res <= 0) $error++;
62 } elseif ($action ==
'updateMaskSN') {
63 $maskconstbatch =
GETPOST(
'maskconstSN',
'alpha');
64 $maskbatch =
GETPOST(
'maskSN',
'alpha');
66 if ($maskconstbatch) {
67 $res =
dolibarr_set_const($db, $maskconstbatch, $maskbatch,
'chaine', 0,
'', $conf->entity);
68 if ($res <= 0) $error++;
76 } elseif ($action ==
'setmodlot') {
77 dolibarr_set_const($db,
"PRODUCTBATCH_LOT_ADDON", $value,
'chaine', 0,
'', $conf->entity);
78 } elseif ($action ==
'setmodsn') {
79 dolibarr_set_const($db,
"PRODUCTBATCH_SN_ADDON", $value,
'chaine', 0,
'', $conf->entity);
80 } elseif ($action ==
'setmaskslot') {
81 dolibarr_set_const($db,
"PRODUCTBATCH_LOT_USE_PRODUCT_MASKS", $value,
'bool', 0,
'', $conf->entity);
82 if ($value ==
'1' && $conf->global->PRODUCTBATCH_LOT_ADDONS !==
'mod_lot_advanced') {
83 dolibarr_set_const($db,
"PRODUCTBATCH_LOT_ADDON",
'mod_lot_advanced',
'chaine', 0,
'', $conf->entity);
85 } elseif ($action ==
'setmaskssn') {
86 dolibarr_set_const($db,
"PRODUCTBATCH_SN_USE_PRODUCT_MASKS", $value,
'bool', 0,
'', $conf->entity);
87 if ($value ==
'1' && $conf->global->PRODUCTBATCH_SN_ADDONS !==
'mod_sn_advanced') {
88 dolibarr_set_const($db,
"PRODUCTBATCH_SN_ADDON",
'mod_sn_advanced',
'chaine', 0,
'', $conf->entity);
98 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
100 llxHeader(
"", $langs->trans(
"ProductLotSetup"));
102 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
103 print
load_fiche_titre($langs->trans(
"ProductLotSetup"), $linkback,
'title_setup');
110 if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
115 print $langs->trans(
"NothingToSetup");
123 print
'<table class="noborder centpercent">';
124 print
'<tr class="liste_titre">';
125 print
'<td>'.$langs->trans(
"Name").
'</td>';
126 print
'<td>'.$langs->trans(
"Description").
'</td>';
127 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
128 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
129 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
134 foreach ($dirmodels as $reldir) {
138 $handle = opendir($dir);
139 if (is_resource($handle)) {
140 while (($file = readdir($handle)) !==
false) {
141 if (substr($file, 0, 8) ==
'mod_lot_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
142 $file = substr($file, 0,
dol_strlen($file) - 4);
144 require_once $dir.$file.
'.php';
146 $module =
new $file($db);
149 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
150 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
152 if ($module->isEnabled()) {
153 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
154 print $module->info();
158 print
'<td class="nowrap">';
159 $tmp = $module->getExample();
160 if (preg_match(
'/^Error/', $tmp)) print
'<div class="error">'.$langs->trans($tmp).
'</div>';
161 elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
165 print '<td class="center">';
166 if ($conf->global->PRODUCTBATCH_LOT_ADDON == $file) {
167 print
img_picto($langs->trans(
"Activated"),
'switch_on');
169 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodlot&token='.
newToken().
'&value='.urlencode($file).
'">';
170 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
176 $batch->initAsSpecimen();
180 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
181 $nextval = $module->getNextValue($mysoc, $batch);
182 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
183 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
185 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
186 $nextval = $langs->trans($nextval);
187 $htmltooltip .= $nextval.
'<br>';
189 $htmltooltip .= $langs->trans($module->error).
'<br>';
193 print
'<td class="center">';
194 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
206 print
"</table><br>\n";
213 print
load_fiche_titre($langs->trans(
"BatchSerialNumberingModules"),
'',
'');
215 print
'<table class="noborder centpercent">';
216 print
'<tr class="liste_titre">';
217 print
'<td>'.$langs->trans(
"Name").
'</td>';
218 print
'<td>'.$langs->trans(
"Description").
'</td>';
219 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
220 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
221 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
226 foreach ($dirmodels as $reldir) {
230 $handle = opendir($dir);
231 if (is_resource($handle)) {
232 while (($file = readdir($handle)) !==
false) {
233 if (substr($file, 0, 7) ==
'mod_sn_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
234 $file = substr($file, 0,
dol_strlen($file) - 4);
236 require_once $dir.$file.
'.php';
238 $module =
new $file($db);
241 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
242 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
244 if ($module->isEnabled()) {
245 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
246 print $module->info();
250 print
'<td class="nowrap">';
251 $tmp = $module->getExample();
252 if (preg_match(
'/^Error/', $tmp)) print
'<div class="error">'.$langs->trans($tmp).
'</div>';
253 elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
257 print '<td class="center">';
258 if ($conf->global->PRODUCTBATCH_SN_ADDON == $file) {
259 print
img_picto($langs->trans(
"Activated"),
'switch_on');
261 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodsn&token='.
newToken().
'&value='.urlencode($file).
'">';
262 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
268 $batch->initAsSpecimen();
272 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
273 $nextval = $module->getNextValue($mysoc, $batch);
274 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
275 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
277 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
278 $nextval = $langs->trans($nextval);
279 $htmltooltip .= $nextval.
'<br>';
281 $htmltooltip .= $langs->trans($module->error).
'<br>';
285 print
'<td class="center">';
286 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
298 print
"</table><br>\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class with list of lots and properties.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
product_lot_admin_prepare_head()
Return array head with list of tabs to view object informations.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
newToken()
Return the value of token currently saved into session with name 'newtoken'.