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';
49$langs->loadLangs(array(
"admin",
"sendings",
"deliveries",
"other"));
55$action =
GETPOST(
'action',
'alpha');
56$value =
GETPOST(
'value',
'alpha');
57$modulepart =
GETPOST(
'modulepart',
'aZ09');
59$label =
GETPOST(
'label',
'alpha');
60$scandir =
GETPOST(
'scan_dir',
'alpha');
69include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
93if ($action ==
'activate_delivery') {
96 header(
"Location: delivery.php");
98} elseif ($action ==
'disable_delivery') {
100 header(
"Location: delivery.php");
104if ($action ==
'updateMask') {
105 $maskconstdelivery =
GETPOST(
'maskconstdelivery',
'aZ09');
106 $maskdelivery =
GETPOST(
'maskdelivery',
'alpha');
110 if ($maskconstdelivery && preg_match(
'/_MASK$/', $maskconstdelivery)) {
125if ($action ==
'set_DELIVERY_FREE_TEXT') {
126 $free =
GETPOST(
'DELIVERY_FREE_TEXT',
'restricthtml');
140if ($action ==
'specimen') {
141 $modele =
GETPOST(
'module',
'alpha');
144 $sending->initAsSpecimen();
149 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
150 foreach ($dirmodels as $reldir) {
151 $file =
dol_buildpath($reldir.
"core/modules/delivery/doc/pdf_".$modele.
".modules.php", 0);
152 if (file_exists($file)) {
153 $classname =
"pdf_".$modele;
158 if ($classname !==
'') {
161 $module =
new $classname($db);
162 '@phan-var-force ModelePDFDeliveryOrder $module';
164 if ($module->write_file($sending, $langs) > 0) {
165 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=delivery&file=SPECIMEN.pdf");
173 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
177if ($action ==
'set') {
181if ($action ==
'del') {
190if ($action ==
'setdoc') {
194 $conf->global->DELIVERY_ADDON_PDF = $value;
204if ($action ==
'setmod') {
217$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
219llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-delivery');
221$form =
new Form($db);
223$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
224print
load_fiche_titre($langs->trans(
"SendingsSetup"), $linkback,
'title_setup');
228print
dol_get_fiche_head($head,
'receivings', $langs->trans(
"Receivings"), -1,
'shipment');
232print
'<div class="inline-block valignmiddle">'.$langs->trans(
"DeliveriesOrderAbility").
'</div>';
234 print
' <a class="inline-block valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=activate_delivery&token='.
newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
236 print
' <a class="inline-block valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=disable_delivery&token='.
newToken().
'">'.
img_picto($langs->trans(
"Enabled"),
'switch_on').
'</a>';
239print
'<br><br><span class="opacitymedium">'.info_admin($langs->trans(
"NoNeedForDeliveryReceipts"), 0, 1).
'</span>';
248 print
load_fiche_titre($langs->trans(
"DeliveryOrderNumberingModules"),
'',
'');
250 print
'<table class="noborder centpercent">';
251 print
'<tr class="liste_titre">';
252 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
253 print
'<td>'.$langs->trans(
"Description").
'</td>';
254 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
255 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
256 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
261 foreach ($dirmodels as $reldir) {
265 $handle = opendir($dir);
266 if (is_resource($handle)) {
267 while (($file = readdir($handle)) !==
false) {
268 if (preg_match(
'/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
269 $file = substr($file, 0,
dol_strlen($file) - 4);
271 require_once $dir.$file.
'.php';
273 $module =
new $file();
275 '@phan-var-force ModeleNumRefDeliveryOrder $module';
277 if ($module->isEnabled()) {
279 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
282 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
286 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
287 print $module->info($langs);
291 print
'<td class="nowrap">';
292 $tmp = $module->getExample();
293 if (preg_match(
'/^Error/', $tmp)) {
294 $langs->load(
"errors");
295 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
296 } elseif ($tmp ==
'NotConfigured') {
297 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
303 print
'<td class="center">';
304 if (
$conf->global->DELIVERY_ADDON_NUMBER ==
"$file") {
305 print
img_picto($langs->trans(
"Activated"),
'switch_on');
307 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>';
312 $delivery->initAsSpecimen();
316 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
317 $nextval = $module->getNextValue($mysoc, $delivery);
318 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
319 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
321 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
322 $nextval = $langs->trans($nextval);
324 $htmltooltip .= $nextval.
'<br>';
326 $htmltooltip .= $langs->trans($module->error).
'<br>';
330 print
'<td class="center">';
331 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
357 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
358 $sql .=
" WHERE type = '".$db->escape($type).
"'";
359 $sql .=
" AND entity = ".$conf->entity;
361 $resql = $db->query($sql);
364 $num_rows = $db->num_rows($resql);
365 while ($i < $num_rows) {
366 $array = $db->fetch_array($resql);
367 if (is_array($array)) {
368 array_push($def, $array[0]);
376 print
'<table class="noborder centpercent">';
377 print
'<tr class="liste_titre">';
378 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
379 print
'<td>'.$langs->trans(
"Description").
'</td>';
380 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
381 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>';
382 print
'<td align="center" width="32">'.$langs->trans(
"ShortInfo").
'</td>';
383 print
'<td align="center" width="32">'.$langs->trans(
"Preview").
'</td>';
388 foreach ($dirmodels as $reldir) {
392 $handle = opendir($dir);
393 if (is_resource($handle)) {
395 while (($file = readdir($handle)) !==
false) {
401 foreach ($filelist as $file) {
402 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
403 if (file_exists($dir.
'/'.$file)) {
404 $name = substr($file, 4,
dol_strlen($file) - 16);
405 $classname = substr($file, 0,
dol_strlen($file) - 12);
407 require_once $dir.
'/'.$file;
408 $module =
new $classname($db);
410 '@phan-var-force ModelePDFDeliveryOrder $module';
412 $modulequalified = 1;
413 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
414 $modulequalified = 0;
416 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
417 $modulequalified = 0;
420 if ($modulequalified) {
421 print
'<tr class="oddeven"><td width="100">';
422 print(empty($module->name) ? $name : $module->
name);
424 if (method_exists($module,
'info')) {
425 print $module->info($langs);
427 print $module->description;
432 if (in_array($name, $def)) {
433 print
"<td align=\"center\">\n";
434 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
435 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
439 print
"<td align=\"center\">\n";
440 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>';
445 print
"<td align=\"center\">";
447 print
img_picto($langs->trans(
"Default"),
'on');
449 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>';
454 $htmltooltip =
''.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
455 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
456 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
'</u>:';
457 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
458 print
'<td class="center">';
459 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
463 print
'<td class="center">';
464 if ($module->type ==
'pdf') {
465 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
467 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
486 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
487 print
'<input type="hidden" name="token" value="'.newToken().
'">';
488 print
'<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
490 print
'<table class="noborder centpercent">';
491 print
'<tr class="liste_titre">';
492 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
493 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
494 print
'<td width="80"> </td>';
498 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
499 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
500 foreach ($substitutionarray as $key => $val) {
501 $htmltext .= $key.
'<br>';
505 print
'<tr class="oddeven"><td colspan="2">';
506 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnDeliveryReceipts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
507 $variablename =
'DELIVERY_FREE_TEXT';
509 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
511 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
513 print $doleditor->Create();
515 print
'</td><td class="right">';
516 print
"</td></tr>\n";
520 print
'<div class="center">';
521 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.