32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/expedition.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
39$langs->loadLangs(array(
"admin",
"sendings",
"deliveries",
"other"));
45$action =
GETPOST(
'action',
'aZ09');
46$value =
GETPOST(
'value',
'alpha');
47$modulepart =
GETPOST(
'modulepart',
'aZ09');
49$label =
GETPOST(
'label',
'alpha');
50$scandir =
GETPOST(
'scan_dir',
'alpha');
53if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) {
54 $conf->global->EXPEDITION_ADDON_NUMBER =
'mod_expedition_safor';
62include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
64if ($action ==
'updateMask') {
65 $maskconst =
GETPOST(
'maskconstexpedition',
'aZ09');
66 $maskvalue =
GETPOST(
'maskexpedition',
'alpha');
67 if (!empty($maskconst) && preg_match(
'/_MASK$/', $maskconst)) {
68 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
78} elseif ($action ==
'set_param') {
79 $freetext =
GETPOST(
'SHIPPING_FREE_TEXT',
'restricthtml');
80 $res =
dolibarr_set_const($db,
"SHIPPING_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
86 $draft =
GETPOST(
'SHIPPING_DRAFT_WATERMARK',
'alpha');
87 $res =
dolibarr_set_const($db,
"SHIPPING_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
96} elseif ($action ==
'specimen') {
97 $modele =
GETPOST(
'module',
'alpha');
100 $exp->initAsSpecimen();
103 $file =
''; $classname =
''; $filefound = 0;
104 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
105 foreach ($dirmodels as $reldir) {
106 $file =
dol_buildpath($reldir.
"core/modules/expedition/doc/pdf_".$modele.
".modules.php", 0);
107 if (file_exists($file)) {
109 $classname =
"pdf_".$modele;
117 $module =
new $classname($db);
119 if ($module->write_file($exp, $langs) > 0) {
120 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=expedition&file=SPECIMEN.pdf");
128 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
130} elseif ($action ==
'set') {
133} elseif ($action ==
'del') {
140} elseif ($action ==
'setdoc') {
142 if (
dolibarr_set_const($db,
"EXPEDITION_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
145 $conf->global->EXPEDITION_ADDON_PDF = $value;
153} elseif ($action ==
'setmodel') {
154 dolibarr_set_const($db,
"EXPEDITION_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
162$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
164$form =
new Form($db);
166llxHeader(
"", $langs->trans(
"SendingsSetup"));
168$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
169print
load_fiche_titre($langs->trans(
"SendingsSetup"), $linkback,
'title_setup');
173print
dol_get_fiche_head($head,
'shipment', $langs->trans(
"Sendings"), -1,
'shipment');
179print
'<table class="noborder centpercent">';
180print
'<tr class="liste_titre">';
181print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
182print
'<td>'.$langs->trans(
"Description").
'</td>';
183print
'<td>'.$langs->trans(
"Example").
'</td>';
184print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
185print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
190foreach ($dirmodels as $reldir) {
194 $handle = opendir($dir);
195 if (is_resource($handle)) {
196 while (($file = readdir($handle)) !==
false) {
197 if (preg_match(
'/^mod_expedition_([a-z0-9_]*)\.php$/', $file)) {
198 $file = substr($file, 0,
dol_strlen($file) - 4);
200 require_once $dir.$file.
'.php';
204 if ($module->isEnabled()) {
206 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
209 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
213 print
'<tr><td>'.$module->name.
"</td>\n";
215 print $module->info();
219 print
'<td class="nowrap">';
220 $tmp = $module->getExample();
221 if (preg_match(
'/^Error/', $tmp)) {
222 $langs->load(
"errors");
223 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
224 } elseif ($tmp ==
'NotConfigured') {
225 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
231 print
'<td class="center">';
232 if ($conf->global->EXPEDITION_ADDON_NUMBER ==
"$file") {
233 print
img_picto($langs->trans(
"Activated"),
'switch_on');
235 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodel&token='.newToken().
'&value='.urlencode($file).
'&label='.urlencode($module->name).
'">';
236 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
242 $expedition->initAsSpecimen();
246 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
247 $nextval = $module->getNextValue($mysoc, $expedition);
248 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
249 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
251 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
252 $nextval = $langs->trans($nextval);
254 $htmltooltip .= $nextval.
'<br>';
256 $htmltooltip .= $langs->trans($module->error).
'<br>';
260 print
'<td class="center">';
261 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
286$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
287$sql .=
" WHERE type = '".$db->escape($type).
"'";
288$sql .=
" AND entity = ".$conf->entity;
290$resql = $db->query($sql);
293 $num_rows = $db->num_rows($resql);
294 while ($i < $num_rows) {
295 $array = $db->fetch_array($resql);
296 array_push($def, $array[0]);
303print
'<table class="noborder centpercent">';
304print
'<tr class="liste_titre">';
305print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
306print
'<td>'.$langs->trans(
"Description").
'</td>';
307print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
308print
'<td class="center" width="60">'.$langs->trans(
"Default").
'</td>';
309print
'<td class="nowrap center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
310print
'<td class="nowrap center" width="80" >'.$langs->trans(
"Preview").
'</td>';
315foreach ($dirmodels as $reldir) {
316 foreach (array(
'',
'/doc') as $valdir) {
317 $dir =
dol_buildpath($reldir.
"core/modules/expedition".$valdir);
320 $handle = opendir($dir);
321 if (is_resource($handle)) {
322 while (($file = readdir($handle)) !==
false) {
328 foreach ($filelist as $file) {
329 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
330 if (file_exists($dir.
'/'.$file)) {
331 $name = substr($file, 4,
dol_strlen($file) - 16);
332 $classname = substr($file, 0,
dol_strlen($file) - 12);
334 require_once $dir.
'/'.$file;
335 $module =
new $classname($db);
337 $modulequalified = 1;
338 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
339 $modulequalified = 0;
341 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
342 $modulequalified = 0;
345 if ($modulequalified) {
346 print
'<tr><td width="100">';
347 print (empty($module->name) ? $name : $module->
name);
349 if (method_exists($module,
'info')) {
350 print $module->info($langs);
352 print $module->description;
357 if (in_array($name, $def)) {
358 print
'<td class="center">'.
"\n";
359 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
360 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
364 print
'<td class="center">'.
"\n";
365 print
'<a class="reposition" 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>';
370 print
'<td class="center">';
372 print
img_picto($langs->trans(
"Default"),
'on');
374 print
'<a class="reposition" 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>';
379 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
380 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
381 if ($module->type ==
'pdf') {
382 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
384 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
385 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
386 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
387 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
388 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
389 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
391 print
'<td class="center">';
392 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
396 print
'<td class="center">';
397 if ($module->type ==
'pdf') {
398 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
400 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
424print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
425print
'<input type="hidden" name="token" value="'.newToken().
'">';
426print
'<input type="hidden" name="action" value="set_param">';
428print
"<table class=\"noborder\" width=\"100%\">";
429print
"<tr class=\"liste_titre\">";
430print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
434$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
435$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
436foreach ($substitutionarray as $key => $val) {
437 $htmltext .= $key.
'<br>';
442print $form->textwithpicto($langs->trans(
"FreeLegalTextOnShippings"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
443$variablename =
'SHIPPING_FREE_TEXT';
444if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
445 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
447 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
449 print $doleditor->Create();
454print $form->textwithpicto($langs->trans(
"WatermarkOnDraftContractCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
455print
'<input class="flat minwidth200" type="text" name="SHIPPING_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'SHIPPING_DRAFT_WATERMARK')).
'">';
460print $form->buttonsSaveCancel(
"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 a WYSIWYG editor.
Class to manage shipments.
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.
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.