29 if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
31 $tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
32 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
33 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
34 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
36 if (!$res && file_exists(
"../main.inc.php")) $res = @include
"../main.inc.php";
37 if (!$res && file_exists(
"../../main.inc.php")) $res = @include
"../../main.inc.php";
38 if (!$res && file_exists(
"../../../main.inc.php")) $res = @include
"../../../main.inc.php";
39 if (!$res) die(
"Include of main fails");
44 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
45 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer.lib.php';
49 $langs->loadLangs(array(
"admin",
"stocks"));
55 $action =
GETPOST(
'action',
'alpha');
56 $backtopage =
GETPOST(
'backtopage',
'alpha');
58 $value =
GETPOST(
'value',
'alpha');
60 $arrayofparameters = array(
61 'STOCKTRANSFER_MYPARAM1'=>array(
'css'=>
'minwidth200',
'enabled'=>1),
62 'STOCKTRANSFER_MYPARAM2'=>array(
'css'=>
'minwidth500',
'enabled'=>1)
73 if ((
float) DOL_VERSION >= 6) {
74 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
77 if ($action ==
'updateMask') {
78 $maskconststocktransfer =
GETPOST(
'maskconststocktransfer',
'alpha');
79 $maskstocktransfer =
GETPOST(
'maskStockTransfer',
'alpha');
81 if ($maskconststocktransfer) {
82 $res =
dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer,
'chaine', 0,
'', $conf->entity);
83 if ($res <= 0) $error++;
91 } elseif ($action ==
'specimen') {
92 $modele =
GETPOST(
'module',
'alpha');
93 $tmpobjectkey =
'StockTransfer';
95 $tmpobject =
new $tmpobjectkey($db);
96 $tmpobject->initAsSpecimen();
99 $file =
''; $classname =
''; $filefound = 0;
100 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
101 foreach ($dirmodels as $reldir) {
102 $file =
dol_buildpath($reldir.
"core/modules/stocktransfer/doc/pdf_".$modele.
".modules.php", 0);
103 if (file_exists($file)) {
105 $classname =
"pdf_".$modele;
113 $module =
new $classname($db);
115 if ($module->write_file($tmpobject, $langs) > 0) {
116 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
124 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
126 } elseif ($action ==
'set') {
128 } elseif ($action ==
'del') {
129 $tmpobjectkey =
'StockTransfer';
133 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
134 if ($conf->global->$constforval ==
"$value")
dolibarr_del_const($db, $constforval, $conf->entity);
136 } elseif ($action ==
'setdoc') {
137 $tmpobjectkey =
'StockTransfer';
138 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
142 $conf->global->$constforval = $value;
150 } elseif ($action ==
'setmod') {
153 $tmpobjectkey =
'StockTransfer';
154 $constforval =
'STOCKTRANSFER_'.strtoupper($tmpobjectkey).
"_ADDON";
166 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
168 $page_name =
"StockTransferSetup";
169 llxHeader(
'', $langs->trans($page_name));
172 $linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
181 print
'<span class="opacitymedium">'.$langs->trans(
"StockTransferSetupPage").
'</span>';
237 $moduledir =
'stocktransfer';
238 $myTmpObjects = array();
239 $myTmpObjects[$moduledir]=array(
'includerefgeneration'=>1,
'includedocgeneration'=>1);
241 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
242 if ($myTmpObjectKey ==
'MyObject')
continue;
243 if ($myTmpObjectArray[
'includerefgeneration']) {
249 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
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' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
278 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
280 if ($module->isEnabled()) {
281 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
283 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
284 print $module->info();
288 print
'<td class="nowrap">';
289 $tmp = $module->getExample();
290 if (preg_match(
'/^Error/', $tmp)) print
'<div class="error">'.$langs->trans($tmp).
'</div>';
291 elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
295 print '<td class="center">';
296 $constforvar = 'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).'_ADDON';
297 if ($conf->global->$constforvar == $file) {
298 print
img_picto($langs->trans(
"Activated"),
'switch_on');
300 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&object='.strtolower($myTmpObjectKey).
'&value='.$file.
'">';
301 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
306 $mytmpinstance =
new $myTmpObjectKey($db);
307 $mytmpinstance->initAsSpecimen();
311 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
313 $nextval = $module->getNextValue($mytmpinstance);
314 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
315 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
317 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
318 $nextval = $langs->trans($nextval);
319 $htmltooltip .= $nextval.
'<br>';
321 $htmltooltip .= $langs->trans($module->error).
'<br>';
325 print
'<td class="center">';
326 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
337 print
"</table><br>\n";
340 if ($myTmpObjectArray[
'includedocgeneration']) {
345 $type = strtolower($myTmpObjectKey);
347 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
352 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
353 $sql .=
" WHERE type = '".$db->escape($type).
"'";
354 $sql .=
" AND entity = ".$conf->entity;
355 $resql = $db->query($sql);
358 $num_rows = $db->num_rows(
$resql);
359 while ($i < $num_rows) {
360 $array = $db->fetch_array(
$resql);
361 array_push($def, $array[0]);
368 print
"<table class=\"noborder\" width=\"100%\">\n";
369 print
"<tr class=\"liste_titre\">\n";
370 print
'<td>'.$langs->trans(
"Name").
'</td>';
371 print
'<td>'.$langs->trans(
"Description").
'</td>';
372 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
373 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
374 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
375 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
380 foreach ($dirmodels as $reldir) {
381 foreach (array(
'',
'/doc') as $valdir) {
382 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
386 $handle = opendir($dir);
387 if (is_resource($handle)) {
388 while (($file = readdir($handle)) !==
false) {
394 foreach ($filelist as $file) {
395 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
396 if (file_exists($dir.
'/'.$file)) {
397 $name = substr($file, 4,
dol_strlen($file) - 16);
398 $classname = substr($file, 0,
dol_strlen($file) - 12);
400 require_once $dir.
'/'.$file;
401 $module =
new $classname($db);
403 $modulequalified = 1;
404 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
405 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
407 if ($modulequalified) {
408 print
'<tr class="oddeven"><td width="100">';
409 print (empty($module->name) ? $name : $module->name);
411 if (method_exists($module,
'info')) print $module->info($langs);
412 else print $module->description;
416 if (in_array($name, $def)) {
417 print
'<td class="center">'.
"\n";
418 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'">';
419 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
423 print
'<td class="center">'.
"\n";
424 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
429 print
'<td class="center">';
430 $constforvar = strtoupper($myTmpObjectKey).
'_ADDON_PDF';
431 if ($conf->global->$constforvar == $name) {
432 print
img_picto($langs->trans(
"Default"),
'on');
434 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&object='.$myTmpObjectKey.
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
439 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
440 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
441 if ($module->type ==
'pdf') {
442 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
444 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
446 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
447 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
448 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
450 print
'<td class="center">';
451 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
455 print
'<td class="center">';
456 if ($module->type ==
'pdf') {
457 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
459 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
477 if (empty($setupnotempty)) {
478 print
'<br>'.$langs->trans(
"NothingToSetup");