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"));
43$action =
GETPOST(
'action',
'alpha');
44$backtopage =
GETPOST(
'backtopage',
'alpha');
46$value =
GETPOST(
'value',
'alpha');
47$label =
GETPOST(
'label',
'alpha');
48$scandir =
GETPOST(
'scan_dir',
'alpha');
50$arrayofparameters = array(
51 'STOCKTRANSFER_MYPARAM1'=>array(
'css'=>
'minwidth200',
'enabled'=>1),
52 'STOCKTRANSFER_MYPARAM2'=>array(
'css'=>
'minwidth500',
'enabled'=>1)
63include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
66if ($action ==
'updateMask') {
67 $maskconststocktransfer =
GETPOST(
'maskconststocktransfer',
'aZ09');
68 $maskstocktransfer =
GETPOST(
'maskStockTransfer',
'alpha');
70 if ($maskconststocktransfer && preg_match(
'/_MASK$/', $maskconststocktransfer)) {
71 $res =
dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer,
'chaine', 0,
'', $conf->entity);
72 if ($res <= 0) $error++;
80} elseif ($action ==
'specimen') {
81 $modele =
GETPOST(
'module',
'alpha');
82 $tmpobjectkey =
'StockTransfer';
84 $tmpobject =
new $tmpobjectkey($db);
85 $tmpobject->initAsSpecimen();
88 $file =
''; $classname =
''; $filefound = 0;
89 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
90 foreach ($dirmodels as $reldir) {
91 $file =
dol_buildpath($reldir.
"core/modules/stocktransfer/doc/pdf_".$modele.
".modules.php", 0);
92 if (file_exists($file)) {
94 $classname =
"pdf_".$modele;
102 $module =
new $classname($db);
104 if ($module->write_file($tmpobject, $langs) > 0) {
105 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
113 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
115} elseif ($action ==
'set') {
117} elseif ($action ==
'del') {
118 $tmpobjectkey =
'StockTransfer';
122 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
127} elseif ($action ==
'setdoc') {
128 $tmpobjectkey =
'StockTransfer';
129 $constforval = strtoupper($tmpobjectkey).
'_ADDON_PDF';
133 $conf->global->$constforval = $value;
141} elseif ($action ==
'setmod') {
144 $tmpobjectkey =
'StockTransfer';
145 $constforval =
'STOCKTRANSFER_'.strtoupper($tmpobjectkey).
"_ADDON";
155$form =
new Form($db);
157$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
159$page_name =
"StockTransferSetup";
163$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
172print
'<span class="opacitymedium">'.$langs->trans(
"StockTransferSetupPage").
'</span>';
228$moduledir =
'stocktransfer';
229$myTmpObjects = array();
230$myTmpObjects[$moduledir]=array(
'includerefgeneration'=>1,
'includedocgeneration'=>1,
'class'=>
'StockTransfer');
232foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
233 if ($myTmpObjectKey ==
'MyObject')
continue;
234 if ($myTmpObjectArray[
'includerefgeneration']) {
240 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectKey),
'',
'');
242 print
'<table class="noborder centpercent">';
243 print
'<tr class="liste_titre">';
244 print
'<td>'.$langs->trans(
"Name").
'</td>';
245 print
'<td>'.$langs->trans(
"Description").
'</td>';
246 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
247 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
248 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
253 foreach ($dirmodels as $reldir) {
257 $handle = opendir($dir);
258 if (is_resource($handle)) {
259 while (($file = readdir($handle)) !==
false) {
260 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
261 $file = substr($file, 0,
dol_strlen($file) - 4);
263 require_once $dir.
'/'.$file.
'.php';
265 $module =
new $file($db);
268 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
269 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
271 if ($module->isEnabled()) {
272 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
274 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
275 print $module->info();
279 print
'<td class="nowrap">';
280 $tmp = $module->getExample();
281 if (preg_match(
'/^Error/', $tmp)) print
'<div class="error">'.$langs->trans($tmp).
'</div>';
282 elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
286 print '<td class="center">';
287 $constforvar = 'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).'_ADDON';
289 print
img_picto($langs->trans(
"Activated"),
'switch_on');
291 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&object='.strtolower($myTmpObjectKey).
'&value='.$file.
'">';
292 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
297 $nameofclass = $myTmpObjectArray[
'class'];
298 $mytmpinstance =
new $nameofclass($db);
299 $mytmpinstance->initAsSpecimen();
303 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
305 $nextval = $module->getNextValue($mytmpinstance);
306 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
307 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
309 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
310 $nextval = $langs->trans($nextval);
311 $htmltooltip .= $nextval.
'<br>';
313 $htmltooltip .= $langs->trans($module->error).
'<br>';
317 print
'<td class="center">';
318 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
329 print
"</table><br>\n";
332 if ($myTmpObjectArray[
'includedocgeneration']) {
337 $type = strtolower($myTmpObjectKey);
339 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
344 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
345 $sql .=
" WHERE type = '".$db->escape($type).
"'";
346 $sql .=
" AND entity = ".$conf->entity;
347 $resql = $db->query($sql);
350 $num_rows = $db->num_rows($resql);
351 while ($i < $num_rows) {
352 $array = $db->fetch_array($resql);
353 array_push($def, $array[0]);
360 print
'<table class="noborder centpercent">'.
"\n";
361 print
'<tr class="liste_titre">'.
"\n";
362 print
'<td>'.$langs->trans(
"Name").
'</td>';
363 print
'<td>'.$langs->trans(
"Description").
'</td>';
364 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
365 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
366 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
367 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
372 foreach ($dirmodels as $reldir) {
373 foreach (array(
'',
'/doc') as $valdir) {
374 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
378 $handle = opendir($dir);
379 if (is_resource($handle)) {
380 while (($file = readdir($handle)) !==
false) {
386 foreach ($filelist as $file) {
387 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
388 if (file_exists($dir.
'/'.$file)) {
389 $name = substr($file, 4,
dol_strlen($file) - 16);
390 $classname = substr($file, 0,
dol_strlen($file) - 12);
392 require_once $dir.
'/'.$file;
393 $module =
new $classname($db);
395 $modulequalified = 1;
396 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
397 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
399 if ($modulequalified) {
400 print
'<tr class="oddeven"><td>';
401 print (empty($module->name) ? $name : $module->
name);
403 if (method_exists($module,
'info')) print $module->info($langs);
404 else print $module->description;
408 if (in_array($name, $def)) {
409 print
'<td class="center">'.
"\n";
410 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'">';
411 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
415 print
'<td class="center">'.
"\n";
416 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>';
421 print
'<td class="center">';
422 $constforvar = strtoupper($myTmpObjectKey).
'_ADDON_PDF';
424 print
img_picto($langs->trans(
"Default"),
'on');
426 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>';
431 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
432 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
433 if ($module->type ==
'pdf') {
434 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
436 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
438 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
439 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
440 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
442 print
'<td class="center">';
443 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
447 print
'<td class="center">';
448 if ($module->type ==
'pdf') {
449 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
451 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
469if (empty($setupnotempty)) {
470 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.
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.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
$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.