27require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
41$langs->loadLangs(array(
"admin",
"products",
"productbatch"));
48$action =
GETPOST(
'action',
'alpha');
49$value =
GETPOST(
'value',
'alpha');
50$label =
GETPOST(
'label',
'alpha');
51$scandir =
GETPOST(
'scan_dir',
'alpha');
52$type =
'product_batch';
61include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
63if ($action ==
'updateMaskLot') {
64 $maskconstbatch =
GETPOST(
'maskconstLot',
'aZ09');
65 $maskbatch =
GETPOST(
'maskLot',
'alpha');
67 if ($maskconstbatch && preg_match(
'/_MASK$/', $maskconstbatch)) {
79} elseif ($action ==
'updateMaskSN') {
80 $maskconstbatch =
GETPOST(
'maskconstSN',
'aZ09');
81 $maskbatch =
GETPOST(
'maskSN',
'alpha');
83 if ($maskconstbatch && preg_match(
'/_MASK$/', $maskconstbatch)) {
95} elseif ($action ==
'setmodlot') {
97} elseif ($action ==
'setmodsn') {
99} elseif ($action ==
'setmaskslot') {
101 if ($value ==
'1' &&
getDolGlobalString(
'PRODUCTBATCH_LOT_ADDONS') !==
'mod_lot_advanced') {
104} elseif ($action ==
'setmaskssn') {
106 if ($value ==
'1' &&
getDolGlobalString(
'PRODUCTBATCH_SN_ADDONS') !==
'mod_sn_advanced') {
109} elseif ($action ==
'set') {
112} elseif ($action ==
'del') {
119} elseif ($action ==
'specimen') {
120 $modele =
GETPOST(
'module',
'alpha');
123 $product_batch->initAsSpecimen();
128 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
129 foreach ($dirmodels as $reldir) {
130 $file =
dol_buildpath($reldir .
"core/modules/product_batch/doc/pdf_" . $modele .
".modules.php", 0);
131 if (file_exists($file)) {
132 $classname =
"pdf_" . $modele;
137 if ($classname !==
'') {
140 $module =
new $classname(
$db);
142 '@phan-var-force ModelePDFProductBatch $module';
144 if ($module->write_file($product_batch, $langs) > 0) {
145 header(
"Location: " . DOL_URL_ROOT .
"/document.php?modulepart=product_batch&file=SPECIMEN.pdf");
153 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
155} elseif ($action ==
'setdoc') {
160 $conf->global->PRODUCT_BATCH_ADDON_PDF = $value;
176$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
178llxHeader(
"", $langs->trans(
"ProductLotSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-product page-admin_product_lot');
180$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
181print
load_fiche_titre($langs->trans(
"ProductLotSetup"), $linkback,
'title_setup');
195 print
'<table class="noborder centpercent">';
196 print
'<tr class="liste_titre">';
197 print
'<td>'.$langs->trans(
"Name").
'</td>';
198 print
'<td>'.$langs->trans(
"Description").
'</td>';
199 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
200 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
201 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
206 foreach ($dirmodels as $reldir) {
210 $handle = opendir($dir);
211 if (is_resource($handle)) {
212 while (($file = readdir($handle)) !==
false) {
213 if (substr($file, 0, 8) ==
'mod_lot_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
214 $file = substr($file, 0,
dol_strlen($file) - 4);
216 require_once $dir.$file.
'.php';
218 $module =
new $file(
$db);
219 '@phan-var-force ModeleNumRefBatch $module';
222 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
225 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
229 if ($module->isEnabled()) {
230 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
231 print $module->info($langs);
235 print
'<td class="nowrap">';
236 $tmp = $module->getExample();
237 if (preg_match(
'/^Error/', $tmp)) {
238 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
239 } elseif ($tmp ==
'NotConfigured') {
240 print $langs->trans($tmp);
246 print
'<td class="center">';
248 print
img_picto($langs->trans(
"Activated"),
'switch_on');
250 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodlot&token='.newToken().
'&value='.urlencode($file).
'">';
251 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
257 $batch->initAsSpecimen();
261 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
262 $nextval = $module->getNextValue(
$mysoc, $batch);
263 if ((
string) $nextval != $langs->trans(
"NotAvailable")) {
264 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
266 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
267 $nextval = $langs->trans($nextval);
269 $htmltooltip .= $nextval.
'<br>';
271 $htmltooltip .= $langs->trans($module->error).
'<br>';
275 print
'<td class="center">';
276 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
288 print
"</table><br>\n";
295 print
load_fiche_titre($langs->trans(
"BatchSerialNumberingModules"),
'',
'');
297 print
'<table class="noborder centpercent">';
298 print
'<tr class="liste_titre">';
299 print
'<td>'.$langs->trans(
"Name").
'</td>';
300 print
'<td>'.$langs->trans(
"Description").
'</td>';
301 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
302 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
303 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
308 foreach ($dirmodels as $reldir) {
312 $handle = opendir($dir);
313 if (is_resource($handle)) {
314 while (($file = readdir($handle)) !==
false) {
315 if (substr($file, 0, 7) ==
'mod_sn_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
316 $file = substr($file, 0,
dol_strlen($file) - 4);
318 require_once $dir.$file.
'.php';
320 $module =
new $file(
$db);
321 '@phan-var-force ModeleNumRefBatch $module';
324 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
327 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
331 if ($module->isEnabled()) {
332 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
333 print $module->info($langs);
337 print
'<td class="nowrap">';
338 $tmp = $module->getExample();
339 if (preg_match(
'/^Error/', $tmp)) {
340 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
341 } elseif ($tmp ==
'NotConfigured') {
342 print $langs->trans($tmp);
348 print
'<td class="center">';
350 print
img_picto($langs->trans(
"Activated"),
'switch_on');
352 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodsn&token='.newToken().
'&value='.urlencode($file).
'">';
353 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
359 $batch->initAsSpecimen();
363 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
364 $nextval = $module->getNextValue(
$mysoc, $batch);
365 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
366 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
368 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
369 $nextval = $langs->trans($nextval);
371 $htmltooltip .= $nextval.
'<br>';
373 $htmltooltip .= $langs->trans($module->error).
'<br>';
377 print
'<td class="center">';
378 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
390 print
"</table><br>\n";
397$sql .=
" FROM " . MAIN_DB_PREFIX .
"document_model";
398$sql .=
" WHERE type = '" .
$db->escape($type) .
"'";
399$sql .=
" AND entity = " . ((int)
$conf->entity);
400$resql =
$db->query($sql);
403 $num_rows =
$db->num_rows($resql);
404 while ($i < $num_rows) {
405 $array =
$db->fetch_array($resql);
406 if (is_array($array)) {
407 array_push($def, $array[0]);
419 print
load_fiche_titre($langs->trans(
"ProductBatchDocumentTemplates"),
'',
'');
421 print
'<div class="div-table-responsive-no-min">';
422 print
'<table class="noborder centpercent">';
423 print
'<tr class="liste_titre">';
424 print
'<td>' . $langs->trans(
"Name") .
'</td>';
425 print
'<td>' . $langs->trans(
"Description") .
'</td>';
426 print
'<td class="center" width="60">' . $langs->trans(
"Status") .
"</td>\n";
427 print
'<td class="center" width="60">' . $langs->trans(
"Default") .
"</td>\n";
428 print
'<td class="center"></td>';
429 print
'<td class="center" width="80">' . $langs->trans(
"Preview") .
'</td>';
435 foreach ($dirmodels as $reldir) {
436 foreach (array(
'',
'/doc') as $valdir) {
437 $dir =
dol_buildpath($reldir .
"core/modules/product_batch" . $valdir);
439 $handle = opendir($dir);
440 if (is_resource($handle)) {
441 while (($file = readdir($handle)) !==
false) {
447 foreach ($filelist as $file) {
448 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
449 if (file_exists($dir .
'/' . $file)) {
450 $name = substr($file, 4,
dol_strlen($file) - 16);
451 $classname = substr($file, 0,
dol_strlen($file) - 12);
453 require_once $dir .
'/' . $file;
454 $module =
new $classname(
$db);
455 '@phan-var-force ModelePDFProductBatch $module';
457 $modulequalified = 1;
458 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
459 $modulequalified = 0;
461 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
462 $modulequalified = 0;
465 if ($modulequalified) {
466 print
'<tr class="oddeven"><td width="100">';
467 print(empty($module->name) ? $name : $module->
name);
469 if (method_exists($module,
'info')) {
470 print $module->info($langs);
472 print $module->description;
477 if (in_array($name, $def)) {
478 print
'<td class="center">' .
"\n";
479 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?action=del&token=' . newToken() .
'&value=' . urlencode($name) .
'">';
480 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
484 print
'<td class="center">' .
"\n";
485 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?action=set&token=' . newToken() .
'&value=' . urlencode($name) .
'&scan_dir=' . urlencode($module->scandir) .
'&label=' . urlencode($module->name) .
'">' .
img_picto($langs->trans(
"Disabled"),
'switch_off') .
'</a>';
490 print
'<td class="center">';
492 print
img_picto($langs->trans(
"Default"),
'on');
494 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?action=setdoc&token=' . newToken() .
'&value=' . urlencode($name) .
'&scan_dir=' . urlencode($module->scandir) .
'&label=' . urlencode($module->name) .
'" alt="' . $langs->trans(
"Default") .
'">' .
img_picto($langs->trans(
"Disabled"),
'off') .
'</a>';
499 $htmltooltip =
'' . $langs->trans(
"Name") .
': ' . $module->name;
500 $htmltooltip .=
'<br>' . $langs->trans(
"Type") .
': ' . ($module->type ? $module->type : $langs->trans(
"Unknown"));
501 if ($module->type ==
'pdf') {
502 $htmltooltip .=
'<br>' . $langs->trans(
"Width") .
'/' . $langs->trans(
"Height") .
': ' . $module->page_largeur .
'/' . $module->page_hauteur;
504 $htmltooltip .=
'<br><br><u>' . $langs->trans(
"FeaturesSupported") .
':</u>';
505 $htmltooltip .=
'<br>' . $langs->trans(
"Logo") .
': ' .
yn($module->option_logo, 1, 1);
506 $htmltooltip .=
'<br>' . $langs->trans(
"MultiLanguage") .
': ' .
yn($module->option_multilang, 1, 1);
509 print
'<td class="center">';
510 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
514 print
'<td class="center">';
515 if ($module->type ==
'pdf') {
516 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?action=specimen&module=' . $name .
'">' .
img_object($langs->trans(
"Preview"),
'contract') .
'</a>';
518 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
542 print $langs->trans(
"NothingToSetup");
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class with list of lots and properties.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
product_lot_admin_prepare_head()
Return array head with list of tabs to view object information.
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.