28 if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
29 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
32 $tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
33 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
36 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
37 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
39 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
40 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
43 if (!$res && file_exists(
"../../main.inc.php")) {
44 $res = @include
"../../main.inc.php";
46 if (!$res && file_exists(
"../../../main.inc.php")) {
47 $res = @include
"../../../main.inc.php";
50 die(
"Include of main fails");
56 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
57 require_once
'../lib/mymodule.lib.php';
58 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
64 $langs->loadLangs(array(
"admin",
"mymodule@mymodule"));
67 $hookmanager->initHooks(array(
'mymodulesetup',
'globalsetup'));
75 $action =
GETPOST(
'action',
'aZ09');
76 $backtopage =
GETPOST(
'backtopage',
'alpha');
77 $modulepart =
GETPOST(
'modulepart',
'aZ09');
79 $value =
GETPOST(
'value',
'alpha');
80 $label =
GETPOST(
'label',
'alpha');
81 $scandir =
GETPOST(
'scan_dir',
'alpha');
91 if (!class_exists(
'FormSetup')) {
93 if (floatval(DOL_VERSION) < 16.0 && !class_exists(
'FormSetup')) {
94 require_once __DIR__.
'/../backport/v16/core/class/html.formsetup.class.php';
96 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
104 $item = $formSetup->newItem(
'NO_PARAM_JUST_TEXT');
105 $item->fieldOverride = (empty($_SERVER[
'HTTPS']) ?
'http://' :
'https://') . $_SERVER[
'HTTP_HOST'];
106 $item->cssClass =
'minwidth500';
109 $item = $formSetup->newItem(
'MYMODULE_MYPARAM1');
110 $item->defaultFieldValue =
'default value';
113 $item = $formSetup->newItem(
'MYMODULE_MYPARAM2');
114 $item->nameText = $item->getNameText().
' more html text ';
117 $item = $formSetup->newItem(
'MYMODULE_MYPARAM3');
118 $item->setAsThirdpartyType();
121 $formSetup->newItem(
'MYMODULE_MYPARAM4')->setAsYesNo();
124 $formSetup->newItem(
'MYMODULE_MYPARAM5')->setAsEmailTemplate(
'thirdparty');
127 $formSetup->newItem(
'MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0;
130 $formSetup->newItem(
'MYMODULE_MYPARAM7')->setAsProduct();
132 $formSetup->newItem(
'Title')->setAsTitle();
135 $item = $formSetup->newItem(
'MYMODULE_MYPARAM8');
137 'test01' => $langs->trans(
'test01'),
138 'test02' => $langs->trans(
'test02'),
139 'test03' => $langs->trans(
'test03'),
140 'test04' => $langs->trans(
'test04'),
141 'test05' => $langs->trans(
'test05'),
142 'test06' => $langs->trans(
'test06'),
144 $item->setAsMultiSelect($TField);
145 $item->helpText = $langs->transnoentities(
'MYMODULE_MYPARAM8');
149 $formSetup->newItem(
'MYMODULE_MYPARAM9')->setAsSelect($TField);
153 $item = $formSetup->newItem(
'MYMODULE_MYPARAM10');
155 $item->defaultFieldValue =
'#FF0000';
156 $item->nameText = $item->getNameText().
' more html text ';
157 $item->fieldInputOverride =
'';
158 $item->helpText = $langs->transnoentities(
'AnHelpMessage');
166 $setupnotempty =+ count($formSetup->items);
169 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
177 if (
versioncompare(explode(
'.', DOL_VERSION), array(15)) < 0 && $action ==
'update' && !empty($user->admin)) {
178 $formSetup->saveConfFromPost();
181 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
183 if ($action ==
'updateMask') {
184 $maskconst =
GETPOST(
'maskconst',
'aZ09');
185 $maskvalue =
GETPOST(
'maskvalue',
'alpha');
187 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
188 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
199 } elseif ($action ==
'specimen') {
200 $modele =
GETPOST(
'module',
'alpha');
201 $tmpobjectkey =
GETPOST(
'object');
203 $tmpobject =
new $tmpobjectkey($db);
204 $tmpobject->initAsSpecimen();
207 $file =
''; $classname =
''; $filefound = 0;
208 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
209 foreach ($dirmodels as $reldir) {
210 $file =
dol_buildpath($reldir.
"core/modules/mymodule/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
211 if (file_exists($file)) {
213 $classname =
"pdf_".$modele.
"_".strtolower($tmpobjectkey);
221 $module =
new $classname($db);
223 if ($module->write_file($tmpobject, $langs) > 0) {
224 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=mymodule-".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
232 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
234 } elseif ($action ==
'setmod') {
236 $tmpobjectkey =
GETPOST(
'object');
237 if (!empty($tmpobjectkey)) {
238 $constforval =
'MYMODULE_'.strtoupper($tmpobjectkey).
"_ADDON";
241 } elseif ($action ==
'set') {
244 } elseif ($action ==
'del') {
247 $tmpobjectkey =
GETPOST(
'object');
248 if (!empty($tmpobjectkey)) {
249 $constforval =
'MYMODULE_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
250 if ($conf->global->$constforval ==
"$value") {
255 } elseif ($action ==
'setdoc') {
257 $tmpobjectkey =
GETPOST(
'object');
258 if (!empty($tmpobjectkey)) {
259 $constforval =
'MYMODULE_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
263 $conf->global->$constforval = $value;
272 } elseif ($action ==
'unsetdoc') {
273 $tmpobjectkey =
GETPOST(
'object');
274 if (!empty($tmpobjectkey)) {
275 $constforval =
'MYMODULE_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
289 $page_name =
"MyModuleSetup";
294 $linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
296 print
load_fiche_titre($langs->trans($page_name), $linkback,
'title_setup');
300 print
dol_get_fiche_head($head,
'settings', $langs->trans($page_name), -1,
"mymodule@mymodule");
303 echo
'<span class="opacitymedium">'.$langs->trans(
"MyModuleSetupPage").
'</span><br><br>';
306 if ($action ==
'edit') {
307 print $formSetup->generateOutput(
true);
309 } elseif (!empty($formSetup->items)) {
310 print $formSetup->generateOutput();
311 print
'<div class="tabsAction">';
312 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
315 print
'<br>'.$langs->trans(
"NothingToSetup");
319 $moduledir =
'mymodule';
320 $myTmpObjects = array();
322 $myTmpObjects[
'myobject'] = array(
'label'=>
'MyObject',
'includerefgeneration'=>0,
'includedocgeneration'=>0);
325 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
326 if ($myTmpObjectKey != $type) {
329 if ($myTmpObjectArray[
'includerefgeneration']) {
335 print
load_fiche_titre($langs->trans(
"NumberingModules", $myTmpObjectArray[
'label']),
'',
'');
337 print
'<table class="noborder centpercent">';
338 print
'<tr class="liste_titre">';
339 print
'<td>'.$langs->trans(
"Name").
'</td>';
340 print
'<td>'.$langs->trans(
"Description").
'</td>';
341 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
342 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
343 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
348 foreach ($dirmodels as $reldir) {
352 $handle = opendir($dir);
353 if (is_resource($handle)) {
354 while (($file = readdir($handle)) !==
false) {
355 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
356 $file = substr($file, 0,
dol_strlen($file) - 4);
358 require_once $dir.
'/'.$file.
'.php';
360 $module =
new $file($db);
363 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
366 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
370 if ($module->isEnabled()) {
371 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
373 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
374 print $module->info();
378 print
'<td class="nowrap">';
379 $tmp = $module->getExample();
380 if (preg_match(
'/^Error/', $tmp)) {
381 $langs->load(
"errors");
382 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
383 } elseif ($tmp ==
'NotConfigured') {
384 print $langs->trans($tmp);
390 print
'<td class="center">';
391 $constforvar =
'MYMODULE_'.strtoupper($myTmpObjectKey).
'_ADDON';
393 print
img_picto($langs->trans(
"Activated"),
'switch_on');
395 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
396 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
401 $mytmpinstance =
new $myTmpObjectKey($db);
402 $mytmpinstance->initAsSpecimen();
406 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
408 $nextval = $module->getNextValue($mytmpinstance);
409 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
410 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
412 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
413 $nextval = $langs->trans($nextval);
415 $htmltooltip .= $nextval.
'<br>';
417 $htmltooltip .= $langs->trans($module->error).
'<br>';
421 print
'<td class="center">';
422 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
433 print
"</table><br>\n";
436 if ($myTmpObjectArray[
'includedocgeneration']) {
441 $type = strtolower($myTmpObjectKey);
443 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
448 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
449 $sql .=
" WHERE type = '".$db->escape($type).
"'";
450 $sql .=
" AND entity = ".$conf->entity;
451 $resql = $db->query($sql);
454 $num_rows = $db->num_rows(
$resql);
455 while ($i < $num_rows) {
456 $array = $db->fetch_array(
$resql);
457 array_push($def, $array[0]);
464 print
"<table class=\"noborder\" width=\"100%\">\n";
465 print
"<tr class=\"liste_titre\">\n";
466 print
'<td>'.$langs->trans(
"Name").
'</td>';
467 print
'<td>'.$langs->trans(
"Description").
'</td>';
468 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
469 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
470 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
471 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
476 foreach ($dirmodels as $reldir) {
477 foreach (array(
'',
'/doc') as $valdir) {
478 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
482 $handle = opendir($dir);
483 if (is_resource($handle)) {
484 while (($file = readdir($handle)) !==
false) {
490 foreach ($filelist as $file) {
491 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
492 if (file_exists($dir.
'/'.$file)) {
493 $name = substr($file, 4,
dol_strlen($file) - 16);
494 $classname = substr($file, 0,
dol_strlen($file) - 12);
496 require_once $dir.
'/'.$file;
497 $module =
new $classname($db);
499 $modulequalified = 1;
500 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
501 $modulequalified = 0;
503 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
504 $modulequalified = 0;
507 if ($modulequalified) {
508 print
'<tr class="oddeven"><td width="100">';
509 print (empty($module->name) ? $name : $module->name);
511 if (method_exists($module,
'info')) {
512 print $module->info($langs);
514 print $module->description;
519 if (in_array($name, $def)) {
520 print
'<td class="center">'.
"\n";
521 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
522 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
526 print
'<td class="center">'.
"\n";
527 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
532 print
'<td class="center">';
533 $constforvar =
'MYMODULE_'.strtoupper($myTmpObjectKey).
'_ADDON';
537 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type='.urlencode($type).
'" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
539 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
544 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
545 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
546 if ($module->type ==
'pdf') {
547 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
549 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
551 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
552 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
553 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
555 print
'<td class="center">';
556 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
560 print
'<td class="center">';
561 if ($module->type ==
'pdf') {
562 $newname = preg_replace(
'/_'.preg_quote(strtolower($myTmpObjectKey),
'/').
'/',
'', $name);
563 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($newname).
'&object='.urlencode($myTmpObjectKey).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
565 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
583 if (empty($setupnotempty)) {
584 print
'<br>'.$langs->trans(
"NothingToSetup");
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
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)
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.
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.
mymoduleAdminPrepareHead()
Prepare admin pages header.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.