24 require
'../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/reception.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
30 $langs->loadLangs(array(
"admin",
"receptions",
'other'));
37 $action =
GETPOST(
'action',
'aZ09');
38 $value =
GETPOST(
'value',
'alpha');
39 $modulepart =
GETPOST(
'modulepart',
'aZ09');
41 $label =
GETPOST(
'label',
'alpha');
42 $scandir =
GETPOST(
'scan_dir',
'alpha');
50 if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) {
52 dolibarr_set_const($db,
"MAIN_SUBMODULE_RECEPTION",
"1",
'chaine', 0,
'', $conf->entity);
55 if (empty($conf->global->RECEPTION_ADDON_NUMBER)) {
56 $conf->global->RECEPTION_ADDON_NUMBER =
'mod_reception_beryl';
64 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
66 if ($action ==
'updateMask') {
67 $maskconst =
GETPOST(
'maskconstreception',
'alpha');
68 $maskvalue =
GETPOST(
'maskreception',
'alpha');
69 if (!empty($maskconst)) {
70 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
80 } elseif ($action ==
'set_param') {
81 $freetext =
GETPOST(
'RECEPTION_FREE_TEXT',
'restricthtml');
82 $res =
dolibarr_set_const($db,
"RECEPTION_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
88 $draft =
GETPOST(
'RECEPTION_DRAFT_WATERMARK',
'alpha');
89 $res =
dolibarr_set_const($db,
"RECEPTION_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
98 } elseif ($action ==
'specimen') {
99 $modele =
GETPOST(
'module',
'alpha');
102 $exp->initAsSpecimen();
105 $file =
''; $classname =
''; $filefound = 0;
106 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
107 foreach ($dirmodels as $reldir) {
108 $file =
dol_buildpath($reldir.
"core/modules/reception/doc/pdf_".$modele.
".modules.php", 0);
109 if (file_exists($file)) {
111 $classname =
"pdf_".$modele;
119 $module =
new $classname($db);
121 if ($module->write_file($exp, $langs) > 0) {
122 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=reception&file=SPECIMEN.pdf");
130 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
132 } elseif ($action ==
'set') {
135 } elseif ($action ==
'del') {
138 if ($conf->global->RECEPTION_ADDON_PDF ==
"$value") {
142 } elseif ($action ==
'setdoc') {
144 if (
dolibarr_set_const($db,
"RECEPTION_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
147 $conf->global->RECEPTION_ADDON_PDF = $value;
155 } elseif ($action ==
'setmodel') {
156 dolibarr_set_const($db,
"RECEPTION_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
166 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
170 llxHeader(
"", $langs->trans(
"ReceptionsSetup"));
172 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php">'.$langs->trans(
"BackToModuleList").
'</a>';
173 print
load_fiche_titre($langs->trans(
"ReceptionsSetup"), $linkback,
'title_setup');
177 print
dol_get_fiche_head($head,
'reception', $langs->trans(
"Receptions"), -1,
'reception');
183 print
'<div class="div-table-responsive-no-min">';
184 print
'<table class="noborder centpercent">';
185 print
'<tr class="liste_titre">';
186 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
187 print
'<td>'.$langs->trans(
"Description").
'</td>';
188 print
'<td>'.$langs->trans(
"Example").
'</td>';
189 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
190 print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
195 foreach ($dirmodels as $reldir) {
199 $handle = opendir($dir);
200 if (is_resource($handle)) {
201 while (($file = readdir($handle)) !==
false) {
202 if (substr($file, 0, 14) ==
'mod_reception_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
203 $file = substr($file, 0,
dol_strlen($file) - 4);
205 require_once $dir.
'/'.$file.
'.php';
209 if ($module->isEnabled()) {
211 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
214 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
218 print
'<tr><td>'.$module->nom.
"</td>\n";
220 print $module->info();
224 print
'<td class="nowrap">';
225 $tmp = $module->getExample();
226 if (preg_match(
'/^Error/', $tmp)) {
227 $langs->load(
"errors");
228 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
229 } elseif ($tmp ==
'NotConfigured') {
230 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
236 print
'<td class="center">';
237 if ($conf->global->RECEPTION_ADDON_NUMBER ==
"$file") {
238 print
img_picto($langs->trans(
"Activated"),
'switch_on');
240 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodel&token='.
newToken().
'&value='.urlencode($file).
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">';
241 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
247 $reception->initAsSpecimen();
251 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
252 $nextval = $module->getNextValue($mysoc, $reception);
253 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
254 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
256 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
257 $nextval = $langs->trans($nextval);
259 $htmltooltip .= $nextval.
'<br>';
261 $htmltooltip .= $langs->trans($module->error).
'<br>';
265 print
'<td class="center">';
266 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
293 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
294 $sql .=
" WHERE type = '".$db->escape($type).
"'";
295 $sql .=
" AND entity = ".$conf->entity;
297 $resql = $db->query($sql);
300 $num_rows = $db->num_rows(
$resql);
301 while ($i < $num_rows) {
302 $array = $db->fetch_array(
$resql);
303 array_push($def, $array[0]);
310 print
'<div class="div-table-responsive-no-min">';
311 print
'<table class="noborder centpercent">';
312 print
'<tr class="liste_titre">';
313 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
314 print
'<td>'.$langs->trans(
"Description").
'</td>';
315 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
316 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>';
317 print
'<td align="center" width="80" class="nowrap">'.$langs->trans(
"ShortInfo").
'</td>';
318 print
'<td align="center" width="80" class="nowrap">'.$langs->trans(
"Preview").
'</td>';
323 foreach ($dirmodels as $reldir) {
324 foreach (array(
'',
'/doc') as $valdir) {
325 $realpath = $reldir.
"core/modules/reception".$valdir;
329 $handle = opendir($dir);
330 if (is_resource($handle)) {
331 while (($file = readdir($handle)) !==
false) {
337 foreach ($filelist as $file) {
338 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
339 if (file_exists($dir.
'/'.$file)) {
340 $name = substr($file, 4,
dol_strlen($file) - 16);
341 $classname = substr($file, 0,
dol_strlen($file) - 12);
343 require_once $dir.
'/'.$file;
344 $module =
new $classname($db);
346 $modulequalified = 1;
347 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
348 $modulequalified = 0;
350 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
351 $modulequalified = 0;
354 if ($modulequalified) {
355 print
'<tr><td width="100">';
356 print (empty($module->name) ? $name : $module->name);
358 if (method_exists($module,
'info')) {
359 print $module->info($langs);
361 print $module->description;
366 if (in_array($name, $def)) {
367 print
'<td class="center">'.
"\n";
368 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
369 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
373 print
'<td class="center">'.
"\n";
374 print
'<a class="reposition" 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>';
379 print
'<td class="center">';
380 if ($conf->global->RECEPTION_ADDON_PDF == $name) {
381 print
img_picto($langs->trans(
"Default"),
'on');
383 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
388 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
389 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
390 if ($module->type ==
'pdf') {
391 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
393 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
395 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
396 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
397 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
398 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
399 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
400 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
402 print
'<td class="center">';
403 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
407 print
'<td class="center">';
408 if ($module->type ==
'pdf') {
409 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
411 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');