29require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer.lib.php';
39$langs->loadLangs(array(
"admin",
"stocks"));
47$action =
GETPOST(
'action',
'alpha');
48$backtopage =
GETPOST(
'backtopage',
'alpha');
50$value =
GETPOST(
'value',
'alpha');
51$label =
GETPOST(
'label',
'alpha');
52$scandir =
GETPOST(
'scan_dir',
'alpha');
54$arrayofparameters = array(
55 'STOCKTRANSFER_MYPARAM1' => array(
'css' =>
'minwidth200',
'enabled' => 1),
56 'STOCKTRANSFER_MYPARAM2' => array(
'css' =>
'minwidth500',
'enabled' => 1)
67include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
70if ($action ==
'updateMask') {
71 $maskconststocktransfer =
GETPOST(
'maskconststocktransfer',
'aZ09');
72 $maskstocktransfer =
GETPOST(
'maskStockTransfer',
'alpha');
74 if ($maskconststocktransfer && preg_match(
'/_MASK$/', $maskconststocktransfer)) {
75 $res =
dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer,
'chaine', 0,
'', $conf->entity);
86} elseif ($action ==
'specimen') {
87 $modele =
GETPOST(
'module',
'alpha');
88 $tmpobjectkey =
'StockTransfer';
90 $tmpobject =
new $tmpobjectkey($db);
91 $tmpobject->initAsSpecimen();
96 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
97 foreach ($dirmodels as $reldir) {
98 $file =
dol_buildpath($reldir.
"core/modules/stocktransfer/doc/pdf_".$modele.
".modules.php", 0);
99 if (file_exists($file)) {
100 $classname =
"pdf_".$modele;
105 if ($classname !==
'') {
108 $module =
new $classname($db);
109 '@phan-var-force CommonDocGenerator $module';
111 if ($module->write_file($tmpobject, $langs) > 0) {
112 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
120 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
122} elseif ($action ==
'set') {
124} elseif ($action ==
'del') {
125 $tmpobjectkey =
'StockTransfer';
129 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
134} elseif ($action ==
'setdoc') {
135 $tmpobjectkey =
'StockTransfer';
136 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
140 $conf->global->$constforval = $value;
148} elseif ($action ==
'setmod') {
151 $tmpobjectkey =
'StockTransfer';
152 $constforval =
'STOCKTRANSFER_'.strtoupper($tmpobjectkey).
"_ADDON";
162$form =
new Form($db);
164$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
166$page_name =
"StockTransferSetup";
167llxHeader(
'', $langs->trans($page_name),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-stocktransfer');
170$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
179print
'<span class="opacitymedium">'.$langs->trans(
"StockTransferSetupPage").
'</span>';
235$moduledir =
'stocktransfer';
236$myTmpObjects = array();
237$myTmpObjects[$moduledir] = array(
'includerefgeneration' => 1,
'includedocgeneration' => 1,
'class' =>
'StockTransfer');
239foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
240 if ($myTmpObjectKey ==
'MyObject') {
243 if ($myTmpObjectArray[
'includerefgeneration']) {
249 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
251 print
'<div class="div-table-responsive-no-min">';
252 print
'<table class="noborder centpercent">';
253 print
'<tr class="liste_titre">';
254 print
'<td>'.$langs->trans(
"Name").
'</td>';
255 print
'<td>'.$langs->trans(
"Description").
'</td>';
256 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
257 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
258 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
263 foreach ($dirmodels as $reldir) {
267 $handle = opendir($dir);
268 if (is_resource($handle)) {
269 while (($file = readdir($handle)) !==
false) {
270 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
271 $file = substr($file, 0,
dol_strlen($file) - 4);
273 require_once $dir.
'/'.$file.
'.php';
275 $module =
new $file($db);
278 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
281 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
285 if ($module->isEnabled()) {
286 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
288 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
289 print $module->info($langs);
293 print
'<td class="nowrap">';
294 $tmp = $module->getExample();
295 if (preg_match(
'/^Error/', $tmp)) {
296 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
297 } elseif ($tmp ==
'NotConfigured') {
298 print $langs->trans($tmp);
304 print
'<td class="center">';
305 $constforvar =
'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).
'_ADDON';
307 print
img_picto($langs->trans(
"Activated"),
'switch_on');
309 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.$file.
'">';
310 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
315 $nameofclass = $myTmpObjectArray[
'class'];
316 $mytmpinstance =
new $nameofclass($db);
317 $mytmpinstance->initAsSpecimen();
321 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
323 $nextval = $module->getNextValue($mytmpinstance);
324 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
325 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
327 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
328 $nextval = $langs->trans($nextval);
330 $htmltooltip .= $nextval.
'<br>';
332 $htmltooltip .= $langs->trans($module->error).
'<br>';
336 print
'<td class="center">';
337 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
348 print
"</table></div><br>\n";
351 if ($myTmpObjectArray[
'includedocgeneration']) {
356 $type = strtolower($myTmpObjectKey);
358 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
363 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
364 $sql .=
" WHERE type = '".$db->escape($type).
"'";
365 $sql .=
" AND entity = ".$conf->entity;
366 $resql = $db->query($sql);
369 $num_rows = $db->num_rows($resql);
370 while ($i < $num_rows) {
371 $array = $db->fetch_array($resql);
372 if (is_array($array)) {
373 array_push($def, $array[0]);
381 print
'<div class="div-table-responsive">';
382 print
'<table class="noborder centpercent">'.
"\n";
383 print
'<tr class="liste_titre">'.
"\n";
384 print
'<td>'.$langs->trans(
"Name").
'</td>';
385 print
'<td>'.$langs->trans(
"Description").
'</td>';
386 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
387 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
388 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
389 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
394 foreach ($dirmodels as $reldir) {
395 foreach (array(
'',
'/doc') as $valdir) {
396 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
400 $handle = opendir($dir);
401 if (is_resource($handle)) {
403 while (($file = readdir($handle)) !==
false) {
409 foreach ($filelist as $file) {
410 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
411 if (file_exists($dir.
'/'.$file)) {
412 $name = substr($file, 4,
dol_strlen($file) - 16);
413 $classname = substr($file, 0,
dol_strlen($file) - 12);
415 require_once $dir.
'/'.$file;
416 $module =
new $classname($db);
418 $modulequalified = 1;
419 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
420 $modulequalified = 0;
422 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
423 $modulequalified = 0;
426 if ($modulequalified) {
427 print
'<tr class="oddeven"><td>';
428 print(empty($module->name) ? $name : $module->
name);
430 if (method_exists($module,
'info')) {
431 print $module->info($langs);
433 print $module->description;
438 if (in_array($name, $def)) {
439 print
'<td class="center">'.
"\n";
440 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.urlencode($name).
'&token='.
newToken().
'">';
441 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
445 print
'<td class="center">'.
"\n";
446 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>';
451 print
'<td class="center">';
452 $constforvar = strtoupper($myTmpObjectKey).
'_ADDON_PDF';
454 print
img_picto($langs->trans(
"Default"),
'on');
456 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&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>';
461 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
462 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
463 if ($module->type ==
'pdf') {
464 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
466 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
468 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
469 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
470 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
472 print
'<td class="center">';
473 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
477 print
'<td class="center">';
478 if ($module->type ==
'pdf') {
479 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
481 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
495 print
'</table></div>';
499if (empty($setupnotempty)) {
500 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($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.