25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
31 $langs->loadLangs(array(
"admin",
"products",
"productbatch"));
34 if (!$user->admin || (empty($conf->productbatch->enabled)))
37 $action =
GETPOST(
'action',
'alpha');
38 $value =
GETPOST(
'value',
'alpha');
47 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
49 if ($action ==
'updateMaskLot') {
50 $maskconstbatch =
GETPOST(
'maskconstLot',
'aZ09');
51 $maskbatch =
GETPOST(
'maskLot',
'alpha');
53 if ($maskconstbatch && preg_match(
'/_MASK$/', $maskconstbatch)) {
54 $res =
dolibarr_set_const($db, $maskconstbatch, $maskbatch,
'chaine', 0,
'', $conf->entity);
55 if ($res <= 0) $error++;
63 } elseif ($action ==
'updateMaskSN') {
64 $maskconstbatch =
GETPOST(
'maskconstSN',
'aZ09');
65 $maskbatch =
GETPOST(
'maskSN',
'alpha');
67 if ($maskconstbatch && preg_match(
'/_MASK$/', $maskconstbatch)) {
68 $res =
dolibarr_set_const($db, $maskconstbatch, $maskbatch,
'chaine', 0,
'', $conf->entity);
69 if ($res <= 0) $error++;
77 } elseif ($action ==
'setmodlot') {
78 dolibarr_set_const($db,
"PRODUCTBATCH_LOT_ADDON", $value,
'chaine', 0,
'', $conf->entity);
79 } elseif ($action ==
'setmodsn') {
80 dolibarr_set_const($db,
"PRODUCTBATCH_SN_ADDON", $value,
'chaine', 0,
'', $conf->entity);
81 } elseif ($action ==
'setmaskslot') {
82 dolibarr_set_const($db,
"PRODUCTBATCH_LOT_USE_PRODUCT_MASKS", $value,
'bool', 0,
'', $conf->entity);
83 if ($value ==
'1' && $conf->global->PRODUCTBATCH_LOT_ADDONS !==
'mod_lot_advanced') {
84 dolibarr_set_const($db,
"PRODUCTBATCH_LOT_ADDON",
'mod_lot_advanced',
'chaine', 0,
'', $conf->entity);
86 } elseif ($action ==
'setmaskssn') {
87 dolibarr_set_const($db,
"PRODUCTBATCH_SN_USE_PRODUCT_MASKS", $value,
'bool', 0,
'', $conf->entity);
88 if ($value ==
'1' && $conf->global->PRODUCTBATCH_SN_ADDONS !==
'mod_sn_advanced') {
89 dolibarr_set_const($db,
"PRODUCTBATCH_SN_ADDON",
'mod_sn_advanced',
'chaine', 0,
'', $conf->entity);
99 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
101 llxHeader(
"", $langs->trans(
"ProductLotSetup"));
103 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
104 print
load_fiche_titre($langs->trans(
"ProductLotSetup"), $linkback,
'title_setup');
111 if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
116 print $langs->trans(
"NothingToSetup");
124 print
'<table class="noborder centpercent">';
125 print
'<tr class="liste_titre">';
126 print
'<td>'.$langs->trans(
"Name").
'</td>';
127 print
'<td>'.$langs->trans(
"Description").
'</td>';
128 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
129 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
130 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
135 foreach ($dirmodels as $reldir) {
139 $handle = opendir($dir);
140 if (is_resource($handle)) {
141 while (($file = readdir($handle)) !==
false) {
142 if (substr($file, 0, 8) ==
'mod_lot_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
143 $file = substr($file, 0,
dol_strlen($file) - 4);
145 require_once $dir.$file.
'.php';
147 $module =
new $file($db);
150 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
151 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
153 if ($module->isEnabled()) {
154 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
155 print $module->info();
159 print
'<td class="nowrap">';
160 $tmp = $module->getExample();
161 if (preg_match(
'/^Error/', $tmp)) print
'<div class="error">'.$langs->trans($tmp).
'</div>';
162 elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
166 print '<td class="center">';
167 if ($conf->global->PRODUCTBATCH_LOT_ADDON == $file) {
168 print
img_picto($langs->trans(
"Activated"),
'switch_on');
170 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodlot&token='.
newToken().
'&value='.urlencode($file).
'">';
171 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
177 $batch->initAsSpecimen();
181 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
182 $nextval = $module->getNextValue($mysoc, $batch);
183 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
184 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
186 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
187 $nextval = $langs->trans($nextval);
188 $htmltooltip .= $nextval.
'<br>';
190 $htmltooltip .= $langs->trans($module->error).
'<br>';
194 print
'<td class="center">';
195 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
207 print
"</table><br>\n";
214 print
load_fiche_titre($langs->trans(
"BatchSerialNumberingModules"),
'',
'');
216 print
'<table class="noborder centpercent">';
217 print
'<tr class="liste_titre">';
218 print
'<td>'.$langs->trans(
"Name").
'</td>';
219 print
'<td>'.$langs->trans(
"Description").
'</td>';
220 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
221 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
222 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
227 foreach ($dirmodels as $reldir) {
231 $handle = opendir($dir);
232 if (is_resource($handle)) {
233 while (($file = readdir($handle)) !==
false) {
234 if (substr($file, 0, 7) ==
'mod_sn_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
235 $file = substr($file, 0,
dol_strlen($file) - 4);
237 require_once $dir.$file.
'.php';
239 $module =
new $file($db);
242 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
243 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
245 if ($module->isEnabled()) {
246 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
247 print $module->info();
251 print
'<td class="nowrap">';
252 $tmp = $module->getExample();
253 if (preg_match(
'/^Error/', $tmp)) print
'<div class="error">'.$langs->trans($tmp).
'</div>';
254 elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
258 print '<td class="center">';
259 if ($conf->global->PRODUCTBATCH_SN_ADDON == $file) {
260 print
img_picto($langs->trans(
"Activated"),
'switch_on');
262 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodsn&token='.
newToken().
'&value='.urlencode($file).
'">';
263 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
269 $batch->initAsSpecimen();
273 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
274 $nextval = $module->getNextValue($mysoc, $batch);
275 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
276 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
278 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
279 $nextval = $langs->trans($nextval);
280 $htmltooltip .= $nextval.
'<br>';
282 $htmltooltip .= $langs->trans($module->error).
'<br>';
286 print
'<td class="center">';
287 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
299 print
"</table><br>\n";
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('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class with list of lots and properties.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
if(!GETPOST('transkey', 'alphanohtml') &&!GETPOST('transphrase', 'alphanohtml')) else
View.
product_lot_admin_prepare_head()
Return array head with list of tabs to view object informations.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.