33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/expedition.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/delivery/class/delivery.class.php';
40$langs->loadLangs(array(
"admin",
"sendings",
"deliveries",
"other"));
46$action =
GETPOST(
'action',
'alpha');
47$value =
GETPOST(
'value',
'alpha');
48$modulepart =
GETPOST(
'modulepart',
'aZ09');
50$label =
GETPOST(
'label',
'alpha');
51$scandir =
GETPOST(
'scan_dir',
'alpha');
59include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
65 dolibarr_set_const($db,
"MAIN_SUBMODULE_EXPEDITION",
"1",
'chaine', 0,
'', $conf->entity);
83if ($action ==
'activate_delivery') {
84 dolibarr_set_const($db,
"MAIN_SUBMODULE_EXPEDITION",
"1",
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_SUBMODULE_DELIVERY",
"1",
'chaine', 0,
'', $conf->entity);
86 header(
"Location: delivery.php");
88} elseif ($action ==
'disable_delivery') {
90 header(
"Location: delivery.php");
94if ($action ==
'updateMask') {
95 $maskconstdelivery =
GETPOST(
'maskconstdelivery',
'aZ09');
96 $maskdelivery =
GETPOST(
'maskdelivery',
'alpha');
97 if ($maskconstdelivery && preg_match(
'/_MASK$/', $maskconstdelivery)) {
98 $res =
dolibarr_set_const($db, $maskconstdelivery, $maskdelivery,
'chaine', 0,
'', $conf->entity);
112if ($action ==
'set_DELIVERY_FREE_TEXT') {
113 $free =
GETPOST(
'DELIVERY_FREE_TEXT',
'restricthtml');
114 $res =
dolibarr_set_const($db,
"DELIVERY_FREE_TEXT", $free,
'chaine', 0,
'', $conf->entity);
127if ($action ==
'specimen') {
128 $modele =
GETPOST(
'module',
'alpha');
131 $sending->initAsSpecimen();
136 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
137 foreach ($dirmodels as $reldir) {
138 $file =
dol_buildpath($reldir.
"core/modules/delivery/doc/pdf_".$modele.
".modules.php", 0);
139 if (file_exists($file)) {
140 $classname =
"pdf_".$modele;
145 if ($classname !==
'') {
148 $module =
new $classname($db);
149 '@phan-var-force ModelePDFDeliveryOrder $module';
151 if ($module->write_file($sending, $langs) > 0) {
152 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=delivery&file=SPECIMEN.pdf");
160 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
164if ($action ==
'set') {
168if ($action ==
'del') {
177if ($action ==
'setdoc') {
178 if (
dolibarr_set_const($db,
"DELIVERY_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
181 $conf->global->DELIVERY_ADDON_PDF = $value;
191if ($action ==
'setmod') {
195 dolibarr_set_const($db,
"DELIVERY_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
204$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
206llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-delivery');
208$form =
new Form($db);
210$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
211print
load_fiche_titre($langs->trans(
"SendingsSetup"), $linkback,
'title_setup');
215print
dol_get_fiche_head($head,
'receivings', $langs->trans(
"Receivings"), -1,
'shipment');
219print
'<div class="inline-block valignmiddle">'.$langs->trans(
"DeliveriesOrderAbility").
'</div>';
221 print
' <a class="inline-block valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=activate_delivery&token='.
newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
223 print
' <a class="inline-block valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=disable_delivery&token='.
newToken().
'">'.
img_picto($langs->trans(
"Enabled"),
'switch_on').
'</a>';
226print
'<br><span class="opacitymedium">'.info_admin($langs->trans(
"NoNeedForDeliveryReceipts"), 0, 1).
'</span>';
235 print
load_fiche_titre($langs->trans(
"DeliveryOrderNumberingModules"),
'',
'');
237 print
'<table class="noborder centpercent">';
238 print
'<tr class="liste_titre">';
239 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
240 print
'<td>'.$langs->trans(
"Description").
'</td>';
241 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
242 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
243 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
248 foreach ($dirmodels as $reldir) {
252 $handle = opendir($dir);
253 if (is_resource($handle)) {
254 while (($file = readdir($handle)) !==
false) {
255 if (preg_match(
'/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
256 $file = substr($file, 0,
dol_strlen($file) - 4);
258 require_once $dir.$file.
'.php';
260 $module =
new $file();
262 if ($module->isEnabled()) {
264 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
267 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
271 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
272 print $module->info($langs);
276 print
'<td class="nowrap">';
277 $tmp = $module->getExample();
278 if (preg_match(
'/^Error/', $tmp)) {
279 $langs->load(
"errors");
280 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
281 } elseif ($tmp ==
'NotConfigured') {
282 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
288 print
'<td class="center">';
289 if ($conf->global->DELIVERY_ADDON_NUMBER ==
"$file") {
290 print
img_picto($langs->trans(
"Activated"),
'switch_on');
292 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>';
297 $delivery->initAsSpecimen();
301 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
302 $nextval = $module->getNextValue($mysoc, $delivery);
303 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
304 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
306 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
307 $nextval = $langs->trans($nextval);
309 $htmltooltip .= $nextval.
'<br>';
311 $htmltooltip .= $langs->trans($module->error).
'<br>';
315 print
'<td class="center">';
316 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
342 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
343 $sql .=
" WHERE type = '".$db->escape($type).
"'";
344 $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 if (is_array($array)) {
353 array_push($def, $array[0]);
361 print
'<table class="noborder centpercent">';
362 print
'<tr class="liste_titre">';
363 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
364 print
'<td>'.$langs->trans(
"Description").
'</td>';
365 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
366 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>';
367 print
'<td align="center" width="32">'.$langs->trans(
"ShortInfo").
'</td>';
368 print
'<td align="center" width="32">'.$langs->trans(
"Preview").
'</td>';
373 foreach ($dirmodels as $reldir) {
377 $handle = opendir($dir);
378 if (is_resource($handle)) {
380 while (($file = readdir($handle)) !==
false) {
386 foreach ($filelist as $file) {
387 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
388 if (file_exists($dir.
'/'.$file)) {
389 $name = substr($file, 4,
dol_strlen($file) - 16);
390 $classname = substr($file, 0,
dol_strlen($file) - 12);
392 require_once $dir.
'/'.$file;
393 $module =
new $classname($db);
395 $modulequalified = 1;
396 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
397 $modulequalified = 0;
399 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
400 $modulequalified = 0;
403 if ($modulequalified) {
404 print
'<tr class="oddeven"><td width="100">';
405 print(empty($module->name) ? $name : $module->
name);
407 if (method_exists($module,
'info')) {
408 print $module->info($langs);
410 print $module->description;
415 if (in_array($name, $def)) {
416 print
"<td align=\"center\">\n";
417 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
418 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
422 print
"<td align=\"center\">\n";
423 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>';
428 print
"<td align=\"center\">";
430 print
img_picto($langs->trans(
"Default"),
'on');
432 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>';
437 $htmltooltip =
''.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
438 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
439 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
'</u>:';
440 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 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.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
450 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
469 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
470 print
'<input type="hidden" name="token" value="'.newToken().
'">';
471 print
'<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
473 print
'<table class="noborder centpercent">';
474 print
'<tr class="liste_titre">';
475 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
476 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
477 print
'<td width="80"> </td>';
481 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
482 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
483 foreach ($substitutionarray as $key => $val) {
484 $htmltext .= $key.
'<br>';
488 print
'<tr class="oddeven"><td colspan="2">';
489 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnDeliveryReceipts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
490 $variablename =
'DELIVERY_FREE_TEXT';
492 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
494 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
496 print $doleditor->Create();
498 print
'</td><td class="right">';
499 print
"</td></tr>\n";
503 print
'<div class="center">';
504 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 information.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.