27require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer.lib.php';
37$langs->loadLangs(array(
"admin",
"stocks"));
45$action =
GETPOST(
'action',
'alpha');
46$backtopage =
GETPOST(
'backtopage',
'alpha');
48$value =
GETPOST(
'value',
'alpha');
49$label =
GETPOST(
'label',
'alpha');
50$scandir =
GETPOST(
'scan_dir',
'alpha');
52$arrayofparameters = array(
53 'STOCKTRANSFER_MYPARAM1'=>array(
'css'=>
'minwidth200',
'enabled'=>1),
54 'STOCKTRANSFER_MYPARAM2'=>array(
'css'=>
'minwidth500',
'enabled'=>1)
65include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
68if ($action ==
'updateMask') {
69 $maskconststocktransfer =
GETPOST(
'maskconststocktransfer',
'aZ09');
70 $maskstocktransfer =
GETPOST(
'maskStockTransfer',
'alpha');
72 if ($maskconststocktransfer && preg_match(
'/_MASK$/', $maskconststocktransfer)) {
73 $res =
dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer,
'chaine', 0,
'', $conf->entity);
84} elseif ($action ==
'specimen') {
85 $modele =
GETPOST(
'module',
'alpha');
86 $tmpobjectkey =
'StockTransfer';
88 $tmpobject =
new $tmpobjectkey($db);
89 $tmpobject->initAsSpecimen();
95 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
96 foreach ($dirmodels as $reldir) {
97 $file =
dol_buildpath($reldir.
"core/modules/stocktransfer/doc/pdf_".$modele.
".modules.php", 0);
98 if (file_exists($file)) {
100 $classname =
"pdf_".$modele;
108 $module =
new $classname($db);
110 if ($module->write_file($tmpobject, $langs) > 0) {
111 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
119 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
121} elseif ($action ==
'set') {
123} elseif ($action ==
'del') {
124 $tmpobjectkey =
'StockTransfer';
128 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
133} elseif ($action ==
'setdoc') {
134 $tmpobjectkey =
'StockTransfer';
135 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
139 $conf->global->$constforval = $value;
147} elseif ($action ==
'setmod') {
150 $tmpobjectkey =
'StockTransfer';
151 $constforval =
'STOCKTRANSFER_'.strtoupper($tmpobjectkey).
"_ADDON";
161$form =
new Form($db);
163$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
165$page_name =
"StockTransferSetup";
169$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
178print
'<span class="opacitymedium">'.$langs->trans(
"StockTransferSetupPage").
'</span>';
234$moduledir =
'stocktransfer';
235$myTmpObjects = array();
236$myTmpObjects[$moduledir]=array(
'includerefgeneration'=>1,
'includedocgeneration'=>1,
'class'=>
'StockTransfer');
238foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
239 if ($myTmpObjectKey ==
'MyObject') {
242 if ($myTmpObjectArray[
'includerefgeneration']) {
248 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
250 print
'<div class="div-table-responsive-no-min">';
251 print
'<table class="noborder centpercent">';
252 print
'<tr class="liste_titre">';
253 print
'<td>'.$langs->trans(
"Name").
'</td>';
254 print
'<td>'.$langs->trans(
"Description").
'</td>';
255 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
256 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
257 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
262 foreach ($dirmodels as $reldir) {
266 $handle = opendir($dir);
267 if (is_resource($handle)) {
268 while (($file = readdir($handle)) !==
false) {
269 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
270 $file = substr($file, 0,
dol_strlen($file) - 4);
272 require_once $dir.
'/'.$file.
'.php';
274 $module =
new $file($db);
277 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
280 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
284 if ($module->isEnabled()) {
285 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
287 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
288 print $module->info($langs);
292 print
'<td class="nowrap">';
293 $tmp = $module->getExample();
294 if (preg_match(
'/^Error/', $tmp)) {
295 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
296 } elseif ($tmp ==
'NotConfigured') {
297 print $langs->trans($tmp);
303 print
'<td class="center">';
304 $constforvar =
'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).
'_ADDON';
306 print
img_picto($langs->trans(
"Activated"),
'switch_on');
308 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&object='.strtolower($myTmpObjectKey).
'&value='.$file.
'">';
309 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
314 $nameofclass = $myTmpObjectArray[
'class'];
315 $mytmpinstance =
new $nameofclass($db);
316 $mytmpinstance->initAsSpecimen();
320 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
322 $nextval = $module->getNextValue($mytmpinstance);
323 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
324 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
326 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
327 $nextval = $langs->trans($nextval);
329 $htmltooltip .= $nextval.
'<br>';
331 $htmltooltip .= $langs->trans($module->error).
'<br>';
335 print
'<td class="center">';
336 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
347 print
"</table></div><br>\n";
350 if ($myTmpObjectArray[
'includedocgeneration']) {
355 $type = strtolower($myTmpObjectKey);
357 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
362 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
363 $sql .=
" WHERE type = '".$db->escape($type).
"'";
364 $sql .=
" AND entity = ".$conf->entity;
365 $resql = $db->query($sql);
368 $num_rows = $db->num_rows($resql);
369 while ($i < $num_rows) {
370 $array = $db->fetch_array($resql);
371 array_push($def, $array[0]);
378 print
'<div class="div-table-responsive">';
379 print
'<table class="noborder centpercent">'.
"\n";
380 print
'<tr class="liste_titre">'.
"\n";
381 print
'<td>'.$langs->trans(
"Name").
'</td>';
382 print
'<td>'.$langs->trans(
"Description").
'</td>';
383 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
384 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
385 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
386 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
391 foreach ($dirmodels as $reldir) {
392 foreach (array(
'',
'/doc') as $valdir) {
393 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
397 $handle = opendir($dir);
398 if (is_resource($handle)) {
399 while (($file = readdir($handle)) !==
false) {
405 foreach ($filelist as $file) {
406 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
407 if (file_exists($dir.
'/'.$file)) {
408 $name = substr($file, 4,
dol_strlen($file) - 16);
409 $classname = substr($file, 0,
dol_strlen($file) - 12);
411 require_once $dir.
'/'.$file;
412 $module =
new $classname($db);
414 $modulequalified = 1;
415 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
416 $modulequalified = 0;
418 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
419 $modulequalified = 0;
422 if ($modulequalified) {
423 print
'<tr class="oddeven"><td>';
424 print(empty($module->name) ? $name : $module->
name);
426 if (method_exists($module,
'info')) {
427 print $module->info($langs);
429 print $module->description;
434 if (in_array($name, $def)) {
435 print
'<td class="center">'.
"\n";
436 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.urlencode($name).
'&token='.newToken().
'">';
437 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
441 print
'<td class="center">'.
"\n";
442 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&token='.newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
447 print
'<td class="center">';
448 $constforvar = strtoupper($myTmpObjectKey).
'_ADDON_PDF';
450 print
img_picto($langs->trans(
"Default"),
'on');
452 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&object='.urlencode($myTmpObjectKey).
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
457 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
458 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
459 if ($module->type ==
'pdf') {
460 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
462 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
464 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
465 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
466 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
468 print
'<td class="center">';
469 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
473 print
'<td class="center">';
474 if ($module->type ==
'pdf') {
475 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
477 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
491 print
'</table></div>';
495if (empty($setupnotempty)) {
496 print
'<br>'.$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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$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.
stocktransferAdminPrepareHead()
Prepare admin pages header.