29require
'../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';
45$langs->loadLangs(array(
"admin",
"stocks"));
53$action =
GETPOST(
'action',
'alpha');
54$backtopage =
GETPOST(
'backtopage',
'alpha');
56$value =
GETPOST(
'value',
'alpha');
57$label =
GETPOST(
'label',
'alpha');
58$scandir =
GETPOST(
'scan_dir',
'alpha');
60$arrayofparameters = array(
61 'STOCKTRANSFER_MYPARAM1' => array(
'css' =>
'minwidth200',
'enabled' => 1),
62 'STOCKTRANSFER_MYPARAM2' => array(
'css' =>
'minwidth500',
'enabled' => 1)
73include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
76if ($action ==
'updateMask') {
77 $maskconststocktransfer =
GETPOST(
'maskconststocktransfer',
'aZ09');
78 $maskstocktransfer =
GETPOST(
'maskStockTransfer',
'alpha');
80 if ($maskconststocktransfer && preg_match(
'/_MASK$/', $maskconststocktransfer)) {
92} elseif ($action ==
'specimen') {
93 $modele =
GETPOST(
'module',
'alpha');
94 $tmpobjectkey =
'StockTransfer';
96 $tmpobject =
new $tmpobjectkey($db);
97 $tmpobject->initAsSpecimen();
102 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
103 foreach ($dirmodels as $reldir) {
104 $file =
dol_buildpath($reldir.
"core/modules/stocktransfer/doc/pdf_".$modele.
".modules.php", 0);
105 if (file_exists($file)) {
106 $classname =
"pdf_".$modele;
111 if ($classname !==
'') {
114 $module =
new $classname($db);
115 '@phan-var-force ModelePDFStockTransfer $module';
117 if ($module->write_file($tmpobject, $langs) > 0) {
118 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
126 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
128} elseif ($action ==
'set') {
130} elseif ($action ==
'del') {
131 $tmpobjectkey =
'StockTransfer';
135 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
140} elseif ($action ==
'setdoc') {
141 $tmpobjectkey =
'StockTransfer';
142 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
146 $conf->global->$constforval = $value;
154} elseif ($action ==
'setmod') {
157 $tmpobjectkey =
'StockTransfer';
158 $constforval =
'STOCKTRANSFER_'.strtoupper($tmpobjectkey).
"_ADDON";
168$form =
new Form($db);
170$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
172$page_name =
"StockTransferSetup";
173llxHeader(
'', $langs->trans($page_name),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-stocktransfer');
176$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
185print
'<span class="opacitymedium">'.$langs->trans(
"StockTransferSetupPage").
'</span>';
241$moduledir =
'stocktransfer';
242$myTmpObjects = array();
243$myTmpObjects[$moduledir] = array(
'includerefgeneration' => 1,
'includedocgeneration' => 1,
'class' =>
'StockTransfer');
245foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
246 if ($myTmpObjectArray[
'includerefgeneration']) {
250 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
252 print
'<div class="div-table-responsive-no-min">';
253 print
'<table class="noborder centpercent">';
254 print
'<tr class="liste_titre">';
255 print
'<td>'.$langs->trans(
"Name").
'</td>';
256 print
'<td>'.$langs->trans(
"Description").
'</td>';
257 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
258 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
259 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
264 foreach ($dirmodels as $reldir) {
268 $handle = opendir($dir);
269 if (is_resource($handle)) {
270 while (($file = readdir($handle)) !==
false) {
271 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
272 $file = substr($file, 0,
dol_strlen($file) - 4);
274 require_once $dir.
'/'.$file.
'.php';
276 $module =
new $file($db);
278 '@phan-var-force ModeleNumRefStockTransfer $module';
281 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
284 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
288 if ($module->isEnabled()) {
289 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
291 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
292 print $module->info($langs);
296 print
'<td class="nowrap">';
297 $tmp = $module->getExample();
298 if (preg_match(
'/^Error/', $tmp)) {
299 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
300 } elseif ($tmp ==
'NotConfigured') {
301 print $langs->trans($tmp);
307 print
'<td class="center">';
308 $constforvar =
'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).
'_ADDON';
310 print
img_picto($langs->trans(
"Activated"),
'switch_on');
312 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.$file.
'">';
313 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
318 $nameofclass = $myTmpObjectArray[
'class'];
319 $mytmpinstance =
new $nameofclass($db);
320 $mytmpinstance->initAsSpecimen();
324 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
326 $nextval = $module->getNextValue($mytmpinstance);
327 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
328 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
330 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
331 $nextval = $langs->trans($nextval);
333 $htmltooltip .= $nextval.
'<br>';
335 $htmltooltip .= $langs->trans($module->error).
'<br>';
339 print
'<td class="center">';
340 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
351 print
"</table></div><br>\n";
354 if ($myTmpObjectArray[
'includedocgeneration']) {
357 $type = strtolower($myTmpObjectKey);
359 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
364 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
365 $sql .=
" WHERE type = '".$db->escape($type).
"'";
366 $sql .=
" AND entity = ".$conf->entity;
367 $resql = $db->query($sql);
370 $num_rows = $db->num_rows($resql);
371 while ($i < $num_rows) {
372 $array = $db->fetch_array($resql);
373 if (is_array($array)) {
374 array_push($def, $array[0]);
382 print
'<div class="div-table-responsive">';
383 print
'<table class="noborder centpercent">'.
"\n";
384 print
'<tr class="liste_titre">'.
"\n";
385 print
'<td>'.$langs->trans(
"Name").
'</td>';
386 print
'<td>'.$langs->trans(
"Description").
'</td>';
387 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
388 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
389 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
390 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
395 foreach ($dirmodels as $reldir) {
396 foreach (array(
'',
'/doc') as $valdir) {
397 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
401 $handle = opendir($dir);
402 if (is_resource($handle)) {
404 while (($file = readdir($handle)) !==
false) {
410 foreach ($filelist as $file) {
411 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
412 if (file_exists($dir.
'/'.$file)) {
413 $name = substr($file, 4,
dol_strlen($file) - 16);
414 $classname = substr($file, 0,
dol_strlen($file) - 12);
416 require_once $dir.
'/'.$file;
417 $module =
new $classname($db);
419 '@phan-var-force ModelePDFStockTransfer $module';
421 $modulequalified = 1;
422 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
423 $modulequalified = 0;
425 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
426 $modulequalified = 0;
429 if ($modulequalified) {
430 print
'<tr class="oddeven"><td>';
431 print(empty($module->name) ? $name : $module->
name);
433 if (method_exists($module,
'info')) {
434 print $module->info($langs);
436 print $module->description;
441 if (in_array($name, $def)) {
442 print
'<td class="center">'.
"\n";
443 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.urlencode($name).
'&token='.
newToken().
'">';
444 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
448 print
'<td class="center">'.
"\n";
449 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>';
454 print
'<td class="center">';
455 $constforvar = strtoupper($myTmpObjectKey).
'_ADDON_PDF';
457 print
img_picto($langs->trans(
"Default"),
'on');
459 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>';
464 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
465 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
466 if ($module->type ==
'pdf') {
467 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
469 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
471 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
472 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
473 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
475 print
'<td class="center">';
476 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
480 print
'<td class="center">';
481 if ($module->type ==
'pdf') {
482 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
484 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
498 print
'</table></div>';
502if (empty($setupnotempty)) {
503 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$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.