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');
100 if ($maskconstdelivery && preg_match(
'/_MASK$/', $maskconstdelivery)) {
101 $res =
dolibarr_set_const($db, $maskconstdelivery, $maskdelivery,
'chaine', 0,
'', $conf->entity);
115if ($action ==
'set_DELIVERY_FREE_TEXT') {
116 $free =
GETPOST(
'DELIVERY_FREE_TEXT',
'restricthtml');
117 $res =
dolibarr_set_const($db,
"DELIVERY_FREE_TEXT", $free,
'chaine', 0,
'', $conf->entity);
130if ($action ==
'specimen') {
131 $modele =
GETPOST(
'module',
'alpha');
134 $sending->initAsSpecimen();
139 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
140 foreach ($dirmodels as $reldir) {
141 $file =
dol_buildpath($reldir.
"core/modules/delivery/doc/pdf_".$modele.
".modules.php", 0);
142 if (file_exists($file)) {
143 $classname =
"pdf_".$modele;
148 if ($classname !==
'') {
151 $module =
new $classname($db);
152 '@phan-var-force ModelePDFDeliveryOrder $module';
154 if ($module->write_file($sending, $langs) > 0) {
155 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=delivery&file=SPECIMEN.pdf");
163 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
167if ($action ==
'set') {
171if ($action ==
'del') {
180if ($action ==
'setdoc') {
181 if (
dolibarr_set_const($db,
"DELIVERY_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
184 $conf->global->DELIVERY_ADDON_PDF = $value;
194if ($action ==
'setmod') {
198 dolibarr_set_const($db,
"DELIVERY_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
207$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
209llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-delivery');
211$form =
new Form($db);
213$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
214print
load_fiche_titre($langs->trans(
"SendingsSetup"), $linkback,
'title_setup');
218print
dol_get_fiche_head($head,
'receivings', $langs->trans(
"Receivings"), -1,
'shipment');
222print
'<div class="inline-block valignmiddle">'.$langs->trans(
"DeliveriesOrderAbility").
'</div>';
224 print
' <a class="inline-block valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=activate_delivery&token='.
newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
226 print
' <a class="inline-block valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=disable_delivery&token='.
newToken().
'">'.
img_picto($langs->trans(
"Enabled"),
'switch_on').
'</a>';
229print
'<br><span class="opacitymedium">'.info_admin($langs->trans(
"NoNeedForDeliveryReceipts"), 0, 1).
'</span>';
238 print
load_fiche_titre($langs->trans(
"DeliveryOrderNumberingModules"),
'',
'');
240 print
'<table class="noborder centpercent">';
241 print
'<tr class="liste_titre">';
242 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
243 print
'<td>'.$langs->trans(
"Description").
'</td>';
244 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
245 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
246 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
251 foreach ($dirmodels as $reldir) {
255 $handle = opendir($dir);
256 if (is_resource($handle)) {
257 while (($file = readdir($handle)) !==
false) {
258 if (preg_match(
'/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
259 $file = substr($file, 0,
dol_strlen($file) - 4);
261 require_once $dir.$file.
'.php';
263 $module =
new $file();
265 '@phan-var-force ModeleNumRefDeliveryOrder $module';
267 if ($module->isEnabled()) {
269 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
272 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
276 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
277 print $module->info($langs);
281 print
'<td class="nowrap">';
282 $tmp = $module->getExample();
283 if (preg_match(
'/^Error/', $tmp)) {
284 $langs->load(
"errors");
285 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
286 } elseif ($tmp ==
'NotConfigured') {
287 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
293 print
'<td class="center">';
294 if ($conf->global->DELIVERY_ADDON_NUMBER ==
"$file") {
295 print
img_picto($langs->trans(
"Activated"),
'switch_on');
297 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>';
302 $delivery->initAsSpecimen();
306 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
307 $nextval = $module->getNextValue($mysoc, $delivery);
308 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
309 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
311 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
312 $nextval = $langs->trans($nextval);
314 $htmltooltip .= $nextval.
'<br>';
316 $htmltooltip .= $langs->trans($module->error).
'<br>';
320 print
'<td class="center">';
321 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
347 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
348 $sql .=
" WHERE type = '".$db->escape($type).
"'";
349 $sql .=
" AND entity = ".$conf->entity;
351 $resql = $db->query($sql);
354 $num_rows = $db->num_rows($resql);
355 while ($i < $num_rows) {
356 $array = $db->fetch_array($resql);
357 if (is_array($array)) {
358 array_push($def, $array[0]);
366 print
'<table class="noborder centpercent">';
367 print
'<tr class="liste_titre">';
368 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
369 print
'<td>'.$langs->trans(
"Description").
'</td>';
370 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
371 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>';
372 print
'<td align="center" width="32">'.$langs->trans(
"ShortInfo").
'</td>';
373 print
'<td align="center" width="32">'.$langs->trans(
"Preview").
'</td>';
378 foreach ($dirmodels as $reldir) {
382 $handle = opendir($dir);
383 if (is_resource($handle)) {
385 while (($file = readdir($handle)) !==
false) {
391 foreach ($filelist as $file) {
392 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
393 if (file_exists($dir.
'/'.$file)) {
394 $name = substr($file, 4,
dol_strlen($file) - 16);
395 $classname = substr($file, 0,
dol_strlen($file) - 12);
397 require_once $dir.
'/'.$file;
398 $module =
new $classname($db);
400 '@phan-var-force ModelePDFDeliveryOrder $module';
402 $modulequalified = 1;
403 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
404 $modulequalified = 0;
406 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
407 $modulequalified = 0;
410 if ($modulequalified) {
411 print
'<tr class="oddeven"><td width="100">';
412 print(empty($module->name) ? $name : $module->
name);
414 if (method_exists($module,
'info')) {
415 print $module->info($langs);
417 print $module->description;
422 if (in_array($name, $def)) {
423 print
"<td align=\"center\">\n";
424 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
425 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
429 print
"<td align=\"center\">\n";
430 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>';
435 print
"<td align=\"center\">";
437 print
img_picto($langs->trans(
"Default"),
'on');
439 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>';
444 $htmltooltip =
''.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
445 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
446 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
'</u>:';
447 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
448 print
'<td class="center">';
449 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
453 print
'<td class="center">';
454 if ($module->type ==
'pdf') {
455 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
457 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
476 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
477 print
'<input type="hidden" name="token" value="'.newToken().
'">';
478 print
'<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
480 print
'<table class="noborder centpercent">';
481 print
'<tr class="liste_titre">';
482 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
483 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
484 print
'<td width="80"> </td>';
488 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
489 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
490 foreach ($substitutionarray as $key => $val) {
491 $htmltext .= $key.
'<br>';
495 print
'<tr class="oddeven"><td colspan="2">';
496 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnDeliveryReceipts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
497 $variablename =
'DELIVERY_FREE_TEXT';
499 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
501 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
503 print $doleditor->Create();
505 print
'</td><td class="right">';
506 print
"</td></tr>\n";
510 print
'<div class="center">';
511 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
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 a 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.