31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/expedition.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/delivery/class/delivery.class.php';
38$langs->loadLangs(array(
"admin",
"sendings",
"deliveries",
"other"));
44$action =
GETPOST(
'action',
'alpha');
45$value =
GETPOST(
'value',
'alpha');
46$modulepart =
GETPOST(
'modulepart',
'aZ09');
48$label =
GETPOST(
'label',
'alpha');
49$scandir =
GETPOST(
'scan_dir',
'alpha');
57include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
63 dolibarr_set_const($db,
"MAIN_SUBMODULE_EXPEDITION",
"1",
'chaine', 0,
'', $conf->entity);
81if ($action ==
'activate_delivery') {
82 dolibarr_set_const($db,
"MAIN_SUBMODULE_EXPEDITION",
"1",
'chaine', 0,
'', $conf->entity);
83 dolibarr_set_const($db,
"MAIN_SUBMODULE_DELIVERY",
"1",
'chaine', 0,
'', $conf->entity);
84 header(
"Location: delivery.php");
86} elseif ($action ==
'disable_delivery') {
88 header(
"Location: delivery.php");
92if ($action ==
'updateMask') {
93 $maskconstdelivery =
GETPOST(
'maskconstdelivery',
'aZ09');
94 $maskdelivery =
GETPOST(
'maskdelivery',
'alpha');
95 if ($maskconstdelivery && preg_match(
'/_MASK$/', $maskconstdelivery)) {
96 $res =
dolibarr_set_const($db, $maskconstdelivery, $maskdelivery,
'chaine', 0,
'', $conf->entity);
110if ($action ==
'set_DELIVERY_FREE_TEXT') {
111 $free =
GETPOST(
'DELIVERY_FREE_TEXT',
'restricthtml');
112 $res =
dolibarr_set_const($db,
"DELIVERY_FREE_TEXT", $free,
'chaine', 0,
'', $conf->entity);
125if ($action ==
'specimen') {
126 $modele =
GETPOST(
'module',
'alpha');
129 $sending->initAsSpecimen();
135 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
136 foreach ($dirmodels as $reldir) {
137 $file =
dol_buildpath($reldir.
"core/modules/delivery/doc/pdf_".$modele.
".modules.php", 0);
138 if (file_exists($file)) {
140 $classname =
"pdf_".$modele;
148 $module =
new $classname($db);
150 if ($module->write_file($sending, $langs) > 0) {
151 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=delivery&file=SPECIMEN.pdf");
159 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
163if ($action ==
'set') {
167if ($action ==
'del') {
176if ($action ==
'setdoc') {
177 if (
dolibarr_set_const($db,
"DELIVERY_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
180 $conf->global->DELIVERY_ADDON_PDF = $value;
190if ($action ==
'setmod') {
194 dolibarr_set_const($db,
"DELIVERY_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
203$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
207$form =
new Form($db);
209$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
210print
load_fiche_titre($langs->trans(
"SendingsSetup"), $linkback,
'title_setup');
214print
dol_get_fiche_head($head,
'receivings', $langs->trans(
"Receivings"), -1,
'shipment');
218print
'<div class="inline-block valignmiddle">'.$langs->trans(
"DeliveriesOrderAbility").
'</div>';
220 print
' <a class="inline-block valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=activate_delivery&token='.newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
222 print
' <a class="inline-block valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=disable_delivery&token='.newToken().
'">'.
img_picto($langs->trans(
"Enabled"),
'switch_on').
'</a>';
225print
'<br><span class="opacitymedium">'.info_admin($langs->trans(
"NoNeedForDeliveryReceipts"), 0, 1).
'</span>';
234 print
load_fiche_titre($langs->trans(
"DeliveryOrderNumberingModules"),
'',
'');
236 print
'<table class="noborder centpercent">';
237 print
'<tr class="liste_titre">';
238 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
239 print
'<td>'.$langs->trans(
"Description").
'</td>';
240 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
241 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
242 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
247 foreach ($dirmodels as $reldir) {
251 $handle = opendir($dir);
252 if (is_resource($handle)) {
253 while (($file = readdir($handle)) !==
false) {
254 if (preg_match(
'/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
255 $file = substr($file, 0,
dol_strlen($file) - 4);
257 require_once $dir.$file.
'.php';
259 $module =
new $file();
261 if ($module->isEnabled()) {
263 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
266 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
270 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
271 print $module->info($langs);
275 print
'<td class="nowrap">';
276 $tmp = $module->getExample();
277 if (preg_match(
'/^Error/', $tmp)) {
278 $langs->load(
"errors");
279 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
280 } elseif ($tmp ==
'NotConfigured') {
281 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
287 print
'<td class="center">';
288 if ($conf->global->DELIVERY_ADDON_NUMBER ==
"$file") {
289 print
img_picto($langs->trans(
"Activated"),
'switch_on');
291 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
296 $delivery->initAsSpecimen();
300 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
301 $nextval = $module->getNextValue($mysoc, $delivery);
302 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
303 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
305 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
306 $nextval = $langs->trans($nextval);
308 $htmltooltip .= $nextval.
'<br>';
310 $htmltooltip .= $langs->trans($module->error).
'<br>';
314 print
'<td class="center">';
315 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
341 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
342 $sql .=
" WHERE type = '".$db->escape($type).
"'";
343 $sql .=
" AND entity = ".$conf->entity;
345 $resql = $db->query($sql);
348 $num_rows = $db->num_rows($resql);
349 while ($i < $num_rows) {
350 $array = $db->fetch_array($resql);
351 array_push($def, $array[0]);
358 print
'<table class="noborder centpercent">';
359 print
'<tr class="liste_titre">';
360 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
361 print
'<td>'.$langs->trans(
"Description").
'</td>';
362 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
363 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>';
364 print
'<td align="center" width="32">'.$langs->trans(
"ShortInfo").
'</td>';
365 print
'<td align="center" width="32">'.$langs->trans(
"Preview").
'</td>';
370 foreach ($dirmodels as $reldir) {
374 $handle = opendir($dir);
375 if (is_resource($handle)) {
376 while (($file = readdir($handle)) !==
false) {
382 foreach ($filelist as $file) {
383 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
384 if (file_exists($dir.
'/'.$file)) {
385 $name = substr($file, 4,
dol_strlen($file) - 16);
386 $classname = substr($file, 0,
dol_strlen($file) - 12);
388 require_once $dir.
'/'.$file;
389 $module =
new $classname($db);
391 $modulequalified = 1;
392 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
393 $modulequalified = 0;
395 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
396 $modulequalified = 0;
399 if ($modulequalified) {
400 print
'<tr class="oddeven"><td width="100">';
401 print(empty($module->name) ? $name : $module->
name);
403 if (method_exists($module,
'info')) {
404 print $module->info($langs);
406 print $module->description;
411 if (in_array($name, $def)) {
412 print
"<td align=\"center\">\n";
413 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
414 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
418 print
"<td align=\"center\">\n";
419 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>';
424 print
"<td align=\"center\">";
426 print
img_picto($langs->trans(
"Default"),
'on');
428 print
'<a 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>';
433 $htmltooltip =
''.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
434 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
435 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
'</u>:';
436 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
437 print
'<td class="center">';
438 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
442 print
'<td class="center">';
443 if ($module->type ==
'pdf') {
444 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
446 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
465 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
466 print
'<input type="hidden" name="token" value="'.newToken().
'">';
467 print
'<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
469 print
'<table class="noborder centpercent">';
470 print
'<tr class="liste_titre">';
471 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
472 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
473 print
'<td width="80"> </td>';
477 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
478 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
479 foreach ($substitutionarray as $key => $val) {
480 $htmltext .= $key.
'<br>';
484 print
'<tr class="oddeven"><td colspan="2">';
485 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnDeliveryReceipts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
486 $variablename =
'DELIVERY_FREE_TEXT';
488 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
490 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
492 print $doleditor->Create();
494 print
'</td><td class="right">';
495 print
"</td></tr>\n";
499 print
'<div class="center">';
500 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
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.
Class to manage receptions.
Class to manage a WYSIWYG editor.
expedition_admin_prepare_head()
Return array head with list of tabs to view object informations.
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_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
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.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
$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.