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 ModelePDFStockTransfer $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 ($myTmpObjectArray[
'includerefgeneration']) {
244 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
246 print
'<div class="div-table-responsive-no-min">';
247 print
'<table class="noborder centpercent">';
248 print
'<tr class="liste_titre">';
249 print
'<td>'.$langs->trans(
"Name").
'</td>';
250 print
'<td>'.$langs->trans(
"Description").
'</td>';
251 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
252 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
253 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
258 foreach ($dirmodels as $reldir) {
262 $handle = opendir($dir);
263 if (is_resource($handle)) {
264 while (($file = readdir($handle)) !==
false) {
265 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
266 $file = substr($file, 0,
dol_strlen($file) - 4);
268 require_once $dir.
'/'.$file.
'.php';
270 $module =
new $file($db);
272 '@phan-var-force ModeleNumRefStockTransfer $module';
275 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
278 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
282 if ($module->isEnabled()) {
283 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
285 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
286 print $module->info($langs);
290 print
'<td class="nowrap">';
291 $tmp = $module->getExample();
292 if (preg_match(
'/^Error/', $tmp)) {
293 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
294 } elseif ($tmp ==
'NotConfigured') {
295 print $langs->trans($tmp);
301 print
'<td class="center">';
302 $constforvar =
'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).
'_ADDON';
304 print
img_picto($langs->trans(
"Activated"),
'switch_on');
306 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.$file.
'">';
307 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
312 $nameofclass = $myTmpObjectArray[
'class'];
313 $mytmpinstance =
new $nameofclass($db);
314 $mytmpinstance->initAsSpecimen();
318 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
320 $nextval = $module->getNextValue($mytmpinstance);
321 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
322 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
324 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
325 $nextval = $langs->trans($nextval);
327 $htmltooltip .= $nextval.
'<br>';
329 $htmltooltip .= $langs->trans($module->error).
'<br>';
333 print
'<td class="center">';
334 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
345 print
"</table></div><br>\n";
348 if ($myTmpObjectArray[
'includedocgeneration']) {
351 $type = strtolower($myTmpObjectKey);
353 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
358 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
359 $sql .=
" WHERE type = '".$db->escape($type).
"'";
360 $sql .=
" AND entity = ".$conf->entity;
361 $resql = $db->query($sql);
364 $num_rows = $db->num_rows($resql);
365 while ($i < $num_rows) {
366 $array = $db->fetch_array($resql);
367 if (is_array($array)) {
368 array_push($def, $array[0]);
376 print
'<div class="div-table-responsive">';
377 print
'<table class="noborder centpercent">'.
"\n";
378 print
'<tr class="liste_titre">'.
"\n";
379 print
'<td>'.$langs->trans(
"Name").
'</td>';
380 print
'<td>'.$langs->trans(
"Description").
'</td>';
381 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
382 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
383 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
384 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
389 foreach ($dirmodels as $reldir) {
390 foreach (array(
'',
'/doc') as $valdir) {
391 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
395 $handle = opendir($dir);
396 if (is_resource($handle)) {
398 while (($file = readdir($handle)) !==
false) {
404 foreach ($filelist as $file) {
405 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
406 if (file_exists($dir.
'/'.$file)) {
407 $name = substr($file, 4,
dol_strlen($file) - 16);
408 $classname = substr($file, 0,
dol_strlen($file) - 12);
410 require_once $dir.
'/'.$file;
411 $module =
new $classname($db);
413 '@phan-var-force ModelePDFStockTransfer $module';
415 $modulequalified = 1;
416 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
417 $modulequalified = 0;
419 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
420 $modulequalified = 0;
423 if ($modulequalified) {
424 print
'<tr class="oddeven"><td>';
425 print(empty($module->name) ? $name : $module->
name);
427 if (method_exists($module,
'info')) {
428 print $module->info($langs);
430 print $module->description;
435 if (in_array($name, $def)) {
436 print
'<td class="center">'.
"\n";
437 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.urlencode($name).
'&token='.
newToken().
'">';
438 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
442 print
'<td class="center">'.
"\n";
443 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>';
448 print
'<td class="center">';
449 $constforvar = strtoupper($myTmpObjectKey).
'_ADDON_PDF';
451 print
img_picto($langs->trans(
"Default"),
'on');
453 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>';
458 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
459 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
460 if ($module->type ==
'pdf') {
461 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
463 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
465 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
466 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
467 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
469 print
'<td class="center">';
470 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
474 print
'<td class="center">';
475 if ($module->type ==
'pdf') {
476 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
478 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
492 print
'</table></div>';
496if (empty($setupnotempty)) {
497 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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)
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)
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)
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'.
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...
getDolGlobalString($key, $default='')
Return a 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.