27 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
33 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
34 require_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)
63 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
66 if ($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";
157 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
159 $page_name =
"StockTransferSetup";
160 llxHeader(
'', $langs->trans($page_name));
163 $linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
172 print
'<span class="opacitymedium">'.$langs->trans(
"StockTransferSetupPage").
'</span>';
228 $moduledir =
'stocktransfer';
229 $myTmpObjects = array();
230 $myTmpObjects[$moduledir]=array(
'includerefgeneration'=>1,
'includedocgeneration'=>1);
232 foreach ($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 $mytmpinstance =
new $myTmpObjectKey($db);
298 $mytmpinstance->initAsSpecimen();
302 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
304 $nextval = $module->getNextValue($mytmpinstance);
305 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
306 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
308 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
309 $nextval = $langs->trans($nextval);
310 $htmltooltip .= $nextval.
'<br>';
312 $htmltooltip .= $langs->trans($module->error).
'<br>';
316 print
'<td class="center">';
317 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
328 print
"</table><br>\n";
331 if ($myTmpObjectArray[
'includedocgeneration']) {
336 $type = strtolower($myTmpObjectKey);
338 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
343 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
344 $sql .=
" WHERE type = '".$db->escape($type).
"'";
345 $sql .=
" AND entity = ".$conf->entity;
346 $resql = $db->query($sql);
349 $num_rows = $db->num_rows(
$resql);
350 while ($i < $num_rows) {
351 $array = $db->fetch_array(
$resql);
352 array_push($def, $array[0]);
359 print
"<table class=\"noborder\" width=\"100%\">\n";
360 print
"<tr class=\"liste_titre\">\n";
361 print
'<td>'.$langs->trans(
"Name").
'</td>';
362 print
'<td>'.$langs->trans(
"Description").
'</td>';
363 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
364 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
365 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
366 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
371 foreach ($dirmodels as $reldir) {
372 foreach (array(
'',
'/doc') as $valdir) {
373 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
377 $handle = opendir($dir);
378 if (is_resource($handle)) {
379 while (($file = readdir($handle)) !==
false) {
385 foreach ($filelist as $file) {
386 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
387 if (file_exists($dir.
'/'.$file)) {
388 $name = substr($file, 4,
dol_strlen($file) - 16);
389 $classname = substr($file, 0,
dol_strlen($file) - 12);
391 require_once $dir.
'/'.$file;
392 $module =
new $classname($db);
394 $modulequalified = 1;
395 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
396 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
398 if ($modulequalified) {
399 print
'<tr class="oddeven"><td width="100">';
400 print (empty($module->name) ? $name : $module->name);
402 if (method_exists($module,
'info')) print $module->info($langs);
403 else print $module->description;
407 if (in_array($name, $def)) {
408 print
'<td class="center">'.
"\n";
409 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'">';
410 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
414 print
'<td class="center">'.
"\n";
415 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>';
420 print
'<td class="center">';
421 $constforvar = strtoupper($myTmpObjectKey).
'_ADDON_PDF';
423 print
img_picto($langs->trans(
"Default"),
'on');
425 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>';
430 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
431 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
432 if ($module->type ==
'pdf') {
433 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
435 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
437 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
438 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
439 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
441 print
'<td class="center">';
442 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
446 print
'<td class="center">';
447 if ($module->type ==
'pdf') {
448 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'generic').
'</a>';
450 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
468 if (empty($setupnotempty)) {
469 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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) 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'))
if(!GETPOST('transkey', 'alphanohtml') &&!GETPOST('transphrase', 'alphanohtml')) else
View.
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.