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",
"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';
79if ($action ==
'activate_delivery') {
82 header(
"Location: delivery.php");
84} elseif ($action ==
'disable_delivery') {
86 header(
"Location: delivery.php");
90if ($action ==
'updateMask') {
91 $maskconstdelivery =
GETPOST(
'maskconstdelivery',
'aZ09');
92 $maskdelivery =
GETPOST(
'maskdelivery',
'alpha');
96 if ($maskconstdelivery && preg_match(
'/_MASK$/', $maskconstdelivery)) {
111if ($action ==
'set_DELIVERY_FREE_TEXT') {
112 $free =
GETPOST(
'DELIVERY_FREE_TEXT',
'restricthtml');
126if ($action ==
'specimen') {
127 $modele =
GETPOST(
'module',
'alpha');
130 $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)) {
139 $classname =
"pdf_".$modele;
144 if ($classname !==
'') {
147 $module =
new $classname(
$db);
148 '@phan-var-force ModelePDFDeliveryOrder $module';
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') {
180 $conf->global->DELIVERY_ADDON_PDF = $value;
190if ($action ==
'setmod') {
203$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
205llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-delivery');
209$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></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><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 '@phan-var-force ModeleNumRefDeliveryOrder $module';
264 if ($module->isEnabled()) {
266 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
269 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
273 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
274 print $module->info($langs);
278 print
'<td class="nowrap">';
279 $tmp = $module->getExample();
280 if (preg_match(
'/^Error/', $tmp)) {
281 $langs->load(
"errors");
282 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
283 } elseif ($tmp ==
'NotConfigured') {
284 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
290 print
'<td class="center">';
292 print
img_picto($langs->trans(
"Activated"),
'switch_on');
294 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>';
299 $delivery->initAsSpecimen();
303 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
304 $nextval = $module->getNextValue(
$mysoc, $delivery);
305 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
306 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
308 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
309 $nextval = $langs->trans($nextval);
311 $htmltooltip .= $nextval.
'<br>';
313 $htmltooltip .= $langs->trans($module->error).
'<br>';
317 print
'<td class="center">';
318 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
344 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
345 $sql .=
" WHERE type = '".$db->escape($type).
"'";
346 $sql .=
" AND entity = ".((int)
$conf->entity);
348 $resql =
$db->query($sql);
351 $num_rows =
$db->num_rows($resql);
352 while ($i < $num_rows) {
353 $array =
$db->fetch_array($resql);
354 if (is_array($array)) {
355 array_push($def, $array[0]);
363 print
'<table class="noborder centpercent">';
364 print
'<tr class="liste_titre">';
365 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
366 print
'<td>'.$langs->trans(
"Description").
'</td>';
367 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
368 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>';
369 print
'<td align="center" width="32">'.$langs->trans(
"ShortInfo").
'</td>';
370 print
'<td align="center" width="32">'.$langs->trans(
"Preview").
'</td>';
375 foreach ($dirmodels as $reldir) {
379 $handle = opendir($dir);
380 if (is_resource($handle)) {
382 while (($file = readdir($handle)) !==
false) {
388 foreach ($filelist as $file) {
389 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
390 if (file_exists($dir.
'/'.$file)) {
391 $name = substr($file, 4,
dol_strlen($file) - 16);
392 $classname = substr($file, 0,
dol_strlen($file) - 12);
394 require_once $dir.
'/'.$file;
395 $module =
new $classname(
$db);
397 '@phan-var-force ModelePDFDeliveryOrder $module';
399 $modulequalified = 1;
400 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
401 $modulequalified = 0;
403 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
404 $modulequalified = 0;
407 if ($modulequalified) {
408 print
'<tr class="oddeven"><td width="100">';
409 print(empty($module->name) ? $name : $module->
name);
411 if (method_exists($module,
'info')) {
412 print $module->info($langs);
414 print $module->description;
419 if (in_array($name, $def)) {
420 print
"<td align=\"center\">\n";
421 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
422 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
426 print
"<td align=\"center\">\n";
427 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>';
432 print
"<td align=\"center\">";
434 print
img_picto($langs->trans(
"Default"),
'on');
436 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>';
441 $htmltooltip =
''.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
442 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
443 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
'</u>:';
444 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
445 print
'<td class="center">';
446 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
450 print
'<td class="center">';
451 if ($module->type ==
'pdf') {
452 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
454 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
473 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
474 print
'<input type="hidden" name="token" value="'.newToken().
'">';
475 print
'<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
477 print
'<table class="noborder centpercent">';
478 print
'<tr class="liste_titre">';
479 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
480 print
'<td align="center" width="60"></td>';
481 print
'<td width="80"> </td>';
485 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
486 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
487 foreach ($substitutionarray as $key => $val) {
488 $htmltext .= $key.
'<br>';
492 print
'<tr class="oddeven"><td colspan="2">';
493 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnDeliveryReceipts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
494 $variablename =
'DELIVERY_FREE_TEXT';
496 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
498 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
500 print $doleditor->Create();
502 print
'</td><td class="right">';
503 print
"</td></tr>\n";
507 print
'<div class="center">';
508 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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
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.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.