31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/expedition.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
38 $langs->loadLangs(array(
"admin",
"sendings",
"deliveries",
"other"));
44 $action =
GETPOST(
'action',
'aZ09');
45 $value =
GETPOST(
'value',
'alpha');
46 $modulepart =
GETPOST(
'modulepart',
'aZ09');
48 $label =
GETPOST(
'label',
'alpha');
49 $scandir =
GETPOST(
'scan_dir',
'alpha');
52 if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) {
53 $conf->global->EXPEDITION_ADDON_NUMBER =
'mod_expedition_safor';
61 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
63 if ($action ==
'updateMask') {
64 $maskconst =
GETPOST(
'maskconstexpedition',
'alpha');
65 $maskvalue =
GETPOST(
'maskexpedition',
'alpha');
66 if (!empty($maskconst)) {
67 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
77 } elseif ($action ==
'set_param') {
78 $freetext =
GETPOST(
'SHIPPING_FREE_TEXT',
'restricthtml');
79 $res =
dolibarr_set_const($db,
"SHIPPING_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
85 $draft =
GETPOST(
'SHIPPING_DRAFT_WATERMARK',
'alpha');
86 $res =
dolibarr_set_const($db,
"SHIPPING_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
95 } elseif ($action ==
'specimen') {
96 $modele =
GETPOST(
'module',
'alpha');
99 $exp->initAsSpecimen();
102 $file =
''; $classname =
''; $filefound = 0;
103 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
104 foreach ($dirmodels as $reldir) {
105 $file =
dol_buildpath($reldir.
"core/modules/expedition/doc/pdf_".$modele.
".modules.php", 0);
106 if (file_exists($file)) {
108 $classname =
"pdf_".$modele;
116 $module =
new $classname($db);
118 if ($module->write_file($exp, $langs) > 0) {
119 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=expedition&file=SPECIMEN.pdf");
127 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
129 } elseif ($action ==
'set') {
132 } elseif ($action ==
'del') {
139 } elseif ($action ==
'setdoc') {
141 if (
dolibarr_set_const($db,
"EXPEDITION_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
144 $conf->global->EXPEDITION_ADDON_PDF = $value;
152 } elseif ($action ==
'setmodel') {
153 dolibarr_set_const($db,
"EXPEDITION_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
161 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
165 llxHeader(
"", $langs->trans(
"SendingsSetup"));
167 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
168 print
load_fiche_titre($langs->trans(
"SendingsSetup"), $linkback,
'title_setup');
172 print
dol_get_fiche_head($head,
'shipment', $langs->trans(
"Sendings"), -1,
'shipment');
178 print
'<table class="noborder centpercent">';
179 print
'<tr class="liste_titre">';
180 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
181 print
'<td>'.$langs->trans(
"Description").
'</td>';
182 print
'<td>'.$langs->trans(
"Example").
'</td>';
183 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
184 print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
189 foreach ($dirmodels as $reldir) {
193 $handle = opendir($dir);
194 if (is_resource($handle)) {
195 while (($file = readdir($handle)) !==
false) {
196 if (preg_match(
'/^mod_expedition_([a-z0-9_]*)\.php$/', $file)) {
197 $file = substr($file, 0,
dol_strlen($file) - 4);
199 require_once $dir.$file.
'.php';
203 if ($module->isEnabled()) {
205 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
208 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
212 print
'<tr><td>'.$module->name.
"</td>\n";
214 print $module->info();
218 print
'<td class="nowrap">';
219 $tmp = $module->getExample();
220 if (preg_match(
'/^Error/', $tmp)) {
221 $langs->load(
"errors");
222 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
223 } elseif ($tmp ==
'NotConfigured') {
224 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
230 print
'<td class="center">';
231 if ($conf->global->EXPEDITION_ADDON_NUMBER ==
"$file") {
232 print
img_picto($langs->trans(
"Activated"),
'switch_on');
234 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodel&token='.
newToken().
'&value='.urlencode($file).
'&label='.urlencode($module->name).
'">';
235 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
241 $expedition->initAsSpecimen();
245 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
246 $nextval = $module->getNextValue($mysoc, $expedition);
247 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
248 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
250 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
251 $nextval = $langs->trans($nextval);
253 $htmltooltip .= $nextval.
'<br>';
255 $htmltooltip .= $langs->trans($module->error).
'<br>';
259 print
'<td class="center">';
260 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
272 print
'</table><br>';
285 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
286 $sql .=
" WHERE type = '".$db->escape($type).
"'";
287 $sql .=
" AND entity = ".$conf->entity;
289 $resql = $db->query($sql);
292 $num_rows = $db->num_rows(
$resql);
293 while ($i < $num_rows) {
294 $array = $db->fetch_array(
$resql);
295 array_push($def, $array[0]);
302 print
'<table class="noborder centpercent">';
303 print
'<tr class="liste_titre">';
304 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
305 print
'<td>'.$langs->trans(
"Description").
'</td>';
306 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
307 print
'<td class="center" width="60">'.$langs->trans(
"Default").
'</td>';
308 print
'<td class="nowrap center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
309 print
'<td class="nowrap center" width="80" >'.$langs->trans(
"Preview").
'</td>';
314 foreach ($dirmodels as $reldir) {
315 foreach (array(
'',
'/doc') as $valdir) {
316 $dir =
dol_buildpath($reldir.
"core/modules/expedition".$valdir);
319 $handle = opendir($dir);
320 if (is_resource($handle)) {
321 while (($file = readdir($handle)) !==
false) {
327 foreach ($filelist as $file) {
328 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
329 if (file_exists($dir.
'/'.$file)) {
330 $name = substr($file, 4,
dol_strlen($file) - 16);
331 $classname = substr($file, 0,
dol_strlen($file) - 12);
333 require_once $dir.
'/'.$file;
334 $module =
new $classname($db);
336 $modulequalified = 1;
337 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
338 $modulequalified = 0;
340 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
341 $modulequalified = 0;
344 if ($modulequalified) {
345 print
'<tr><td width="100">';
346 print (empty($module->name) ? $name : $module->name);
348 if (method_exists($module,
'info')) {
349 print $module->info($langs);
351 print $module->description;
356 if (in_array($name, $def)) {
357 print
'<td class="center">'.
"\n";
358 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
359 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
363 print
'<td class="center">'.
"\n";
364 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>';
369 print
'<td class="center">';
371 print
img_picto($langs->trans(
"Default"),
'on');
373 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>';
378 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
379 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
380 if ($module->type ==
'pdf') {
381 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
383 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
384 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
385 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
386 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
387 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
388 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
390 print
'<td class="center">';
391 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
395 print
'<td class="center">';
396 if ($module->type ==
'pdf') {
397 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>';
399 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
423 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
424 print
'<input type="hidden" name="token" value="'.newToken().
'">';
425 print
'<input type="hidden" name="action" value="set_param">';
427 print
"<table class=\"noborder\" width=\"100%\">";
428 print
"<tr class=\"liste_titre\">";
429 print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
433 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
434 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
435 foreach ($substitutionarray as $key => $val) {
436 $htmltext .= $key.
'<br>';
441 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnShippings"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
442 $variablename =
'SHIPPING_FREE_TEXT';
443 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
444 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
446 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
448 print $doleditor->Create();
450 print
"</td></tr>\n";
453 print
$form->textwithpicto($langs->trans(
"WatermarkOnDraftContractCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
454 print
'<input class="flat minwidth200" type="text" name="SHIPPING_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'SHIPPING_DRAFT_WATERMARK')).
'">';
455 print
"</td></tr>\n";
459 print
$form->buttonsSaveCancel(
"Modify",
'');
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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).
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
expedition_admin_prepare_head()
Return array head with list of tabs to view object informations.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Class to manage shipments.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Class to manage a WYSIWYG editor.