28 if (!$res && !empty(
$_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) $res = @include
$_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
30 $tmp = empty(
$_SERVER[
'SCRIPT_FILENAME']) ?
'' :
$_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
31 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
32 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
33 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
35 if (!$res && file_exists(
"../../main.inc.php")) $res = @include
"../../main.inc.php";
36 if (!$res && file_exists(
"../../../main.inc.php")) $res = @include
"../../../main.inc.php";
37 if (!$res) die(
"Include of main fails");
42 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
43 require_once
'../lib/mymodule.lib.php';
47 $langs->loadLangs(array(
"admin",
"mymodule@mymodule"));
53 $action =
GETPOST(
'action',
'aZ09');
54 $backtopage =
GETPOST(
'backtopage',
'alpha');
56 $value =
GETPOST(
'value',
'alpha');
57 $label =
GETPOST(
'label',
'alpha');
58 $scandir =
GETPOST(
'scan_dir',
'alpha');
61 $arrayofparameters = array(
62 'MYMODULE_MYPARAM1'=>array(
'css'=>
'minwidth200',
'enabled'=>1),
63 'MYMODULE_MYPARAM2'=>array(
'css'=>
'minwidth500',
'enabled'=>1)
74 if ((
float) DOL_VERSION >= 6)
76 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
79 if ($action ==
'updateMask') {
80 $maskconstorder =
GETPOST(
'maskconstorder',
'alpha');
81 $maskorder =
GETPOST(
'maskorder',
'alpha');
83 if ($maskconstorder) {
84 $res =
dolibarr_set_const($db, $maskconstorder, $maskorder,
'chaine', 0,
'', $conf->entity);
95 } elseif ($action ==
'specimen')
97 $modele =
GETPOST(
'module',
'alpha');
98 $tmpobjectkey =
GETPOST(
'object');
100 $tmpobject =
new $tmpobjectkey($db);
101 $tmpobject->initAsSpecimen();
104 $file =
''; $classname =
''; $filefound = 0;
105 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
106 foreach ($dirmodels as $reldir)
108 $file =
dol_buildpath($reldir.
"core/modules/mymodule/doc/pdf_".$modele.
"_".strtolower($tmpobjectkey).
".modules.php", 0);
109 if (file_exists($file))
112 $classname =
"pdf_".$modele;
121 $module =
new $classname($db);
123 if ($module->write_file($tmpobject, $langs) > 0)
125 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=".strtolower($tmpobjectkey).
"&file=SPECIMEN.pdf");
133 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
137 elseif ($action ==
'setmod') {
139 $tmpobjectkey =
GETPOST(
'object');
140 if (!empty($tmpobjectkey)) {
141 $constforval =
'MYMODULE_'.strtoupper($tmpobjectkey).
"_ADDON";
147 elseif ($action ==
'set') {
149 } elseif ($action ==
'del') {
152 $tmpobjectkey =
GETPOST(
'object');
153 if (!empty($tmpobjectkey)) {
154 $constforval =
'MYMODULE_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
155 if ($conf->global->$constforval ==
"$value")
dolibarr_del_const($db, $constforval, $conf->entity);
161 elseif ($action ==
'setdoc') {
162 $tmpobjectkey =
GETPOST(
'object');
163 if (!empty($tmpobjectkey)) {
164 $constforval =
'MYMODULE_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
168 $conf->global->$constforval = $value;
177 } elseif ($action ==
'unsetdoc') {
178 $tmpobjectkey =
GETPOST(
'object');
179 if (!empty($tmpobjectkey)) {
180 $constforval =
'MYMODULE_'.strtoupper($tmpobjectkey).
'_ADDON_PDF';
191 $form =
new Form($db);
193 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
195 $page_name =
"MyModuleSetup";
196 llxHeader(
'', $langs->trans($page_name));
199 $linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.$langs->trans(
"BackToModuleList").
'</a>';
208 echo
'<span class="opacitymedium">'.$langs->trans(
"MyModuleSetupPage").
'</span><br><br>';
211 if ($action ==
'edit')
213 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
214 print '<input type="hidden" name="token" value="'.newToken().
'">';
215 print '<input type="hidden" name="action" value="update">';
217 print '<table class="noborder centpercent">';
218 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
220 foreach ($arrayofparameters as $key => $val)
222 print '<tr class="oddeven"><td>';
223 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
224 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
225 print '</td><td><input name="'.$key.
'" class="flat '.(empty($val[
'css']) ?
'minwidth200' : $val[
'css']).
'" value="'.$conf->global->$key.
'"></td></tr>';
229 print '<br><div class="center">';
230 print '<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
236 if (!empty($arrayofparameters))
238 print '<table class="noborder centpercent">';
239 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
241 foreach ($arrayofparameters as $key => $val)
245 print '<tr class="oddeven"><td>';
246 $tooltiphelp = (($langs->trans($key.
'Tooltip') != $key.
'Tooltip') ? $langs->trans($key.
'Tooltip') :
'');
247 print $form->textwithpicto($langs->trans($key), $tooltiphelp);
248 print '</td><td>'.$conf->global->$key.
'</td></tr>';
253 print '<div class="tabsAction">';
254 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit">'.$langs->trans(
"Modify").
'</a>';
257 print '<br>'.$langs->trans(
"NothingToSetup");
262 $moduledir =
'mymodule';
263 $myTmpObjects = array();
264 $myTmpObjects[
'MyObject'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
267 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
268 if ($myTmpObjectKey ==
'MyObject')
continue;
269 if ($myTmpObjectArray[
'includerefgeneration']) {
277 print '<table class="noborder centpercent">';
278 print
'<tr class="liste_titre">';
279 print
'<td>'.$langs->trans(
"Name").
'</td>';
280 print
'<td>'.$langs->trans(
"Description").
'</td>';
281 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
282 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
283 print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
288 foreach ($dirmodels as $reldir)
294 $handle = opendir($dir);
295 if (is_resource($handle))
297 while (($file = readdir($handle)) !==
false)
299 if (strpos($file,
'mod_'.strtolower($myTmpObjectKey).
'_') === 0 && substr($file,
dol_strlen($file) - 3, 3) ==
'php')
301 $file = substr($file, 0,
dol_strlen($file) - 4);
303 require_once $dir.
'/'.$file.
'.php';
305 $module =
new $file($db);
308 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
309 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
311 if ($module->isEnabled())
313 dol_include_once(
'/'.$moduledir.
'/class/'.strtolower($myTmpObjectKey).
'.class.php');
315 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
316 print $module->info();
320 print
'<td class="nowrap">';
321 $tmp = $module->getExample();
322 if (preg_match(
'/^Error/', $tmp)) {
323 $langs->load(
"errors");
324 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
325 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
329 print '<td class="center">';
330 $constforvar = 'MYMODULE_'.strtoupper($myTmpObjectKey).'_ADDON';
331 if ($conf->global->$constforvar == $file)
333 print
img_picto($langs->trans(
"Activated"),
'switch_on');
335 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&object='.strtolower($myTmpObjectKey).
'&value='.urlencode($file).
'">';
336 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
341 $mytmpinstance =
new $myTmpObjectKey($db);
342 $mytmpinstance->initAsSpecimen();
346 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
348 $nextval = $module->getNextValue($mytmpinstance);
349 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
350 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
352 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
353 $nextval = $langs->trans($nextval);
354 $htmltooltip .= $nextval.
'<br>';
356 $htmltooltip .= $langs->trans($module->error).
'<br>';
360 print
'<td class="center">';
361 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
372 print
"</table><br>\n";
375 if ($myTmpObjectArray[
'includedocgeneration']) {
380 $type = strtolower($myTmpObjectKey);
382 print
load_fiche_titre($langs->trans(
"DocumentModules", $myTmpObjectKey),
'',
'');
387 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
388 $sql .=
" WHERE type = '".$db->escape($type).
"'";
389 $sql .=
" AND entity = ".$conf->entity;
390 $resql = $db->query($sql);
394 $num_rows = $db->num_rows(
$resql);
395 while ($i < $num_rows)
397 $array = $db->fetch_array(
$resql);
398 array_push($def, $array[0]);
405 print
"<table class=\"noborder\" width=\"100%\">\n";
406 print
"<tr class=\"liste_titre\">\n";
407 print
'<td>'.$langs->trans(
"Name").
'</td>';
408 print
'<td>'.$langs->trans(
"Description").
'</td>';
409 print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
410 print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
411 print
'<td class="center" width="38">'.$langs->trans(
"ShortInfo").
'</td>';
412 print
'<td class="center" width="38">'.$langs->trans(
"Preview").
'</td>';
417 foreach ($dirmodels as $reldir)
419 foreach (array(
'',
'/doc') as $valdir)
421 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
426 $handle = opendir($dir);
427 if (is_resource($handle))
429 while (($file = readdir($handle)) !==
false)
436 foreach ($filelist as $file)
438 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
440 if (file_exists($dir.
'/'.$file))
442 $name = substr($file, 4,
dol_strlen($file) - 16);
443 $classname = substr($file, 0,
dol_strlen($file) - 12);
445 require_once $dir.
'/'.$file;
446 $module =
new $classname($db);
448 $modulequalified = 1;
449 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
450 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
452 if ($modulequalified)
454 print
'<tr class="oddeven"><td width="100">';
455 print (empty($module->name) ? $name : $module->name);
457 if (method_exists($module,
'info')) print $module->info($langs);
458 else print $module->description;
462 if (in_array($name, $def))
464 print
'<td class="center">'.
"\n";
465 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.$name.
'">';
466 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
470 print
'<td class="center">'.
"\n";
471 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.$name.
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
476 print
'<td class="center">';
477 $constforvar =
'MYMODULE_'.strtoupper($myTmpObjectKey).
'_ADDON';
478 if ($conf->global->$constforvar == $name) {
481 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type='.urlencode($type).
'" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
483 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&object='.urlencode(strtolower($myTmpObjectKey)).
'&value='.$name.
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
488 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
489 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
490 if ($module->type ==
'pdf')
492 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
494 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
496 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
497 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
498 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
500 print
'<td class="center">';
501 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
505 print
'<td class="center">';
506 if ($module->type ==
'pdf')
508 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&object='.$myTmpObjectKey.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
510 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
528 if (empty($setupnotempty)) {
529 print
'<br>'.$langs->trans(
"NothingToSetup");
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.
delDocumentModel($name, $type)
Delete document model used by doc generator.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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).
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
mymoduleAdminPrepareHead()
Prepare admin pages header.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.