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"));
43 $action =
GETPOST(
'action',
'aZ09');
44 $value =
GETPOST(
'value',
'alpha');
45 $label =
GETPOST(
'label',
'alpha');
46 $scandir =
GETPOST(
'scan_dir',
'alpha');
49 if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
51 $conf->global->EXPEDITION_ADDON_NUMBER =
'mod_expedition_safor';
59 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
61 if ($action ==
'updateMask')
63 $maskconst =
GETPOST(
'maskconstexpedition',
'alpha');
64 $maskvalue =
GETPOST(
'maskexpedition',
'alpha');
65 if (!empty($maskconst))
66 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
74 } elseif ($action ==
'set_param')
76 $freetext =
GETPOST(
'SHIPPING_FREE_TEXT',
'restricthtml');
77 $res =
dolibarr_set_const($db,
"SHIPPING_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
84 $draft =
GETPOST(
'SHIPPING_DRAFT_WATERMARK',
'alpha');
85 $res =
dolibarr_set_const($db,
"SHIPPING_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
96 } elseif ($action ==
'specimen')
98 $modele =
GETPOST(
'module',
'alpha');
101 $exp->initAsSpecimen();
104 $file =
''; $classname =
''; $filefound = 0;
105 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
106 foreach ($dirmodels as $reldir)
108 $file =
dol_buildpath($reldir.
"core/modules/expedition/doc/pdf_".$modele.
".modules.php", 0);
109 if (file_exists($file))
112 $classname =
"pdf_".$modele;
121 $module =
new $classname($db);
123 if ($module->write_file($exp, $langs) > 0)
125 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=expedition&file=SPECIMEN.pdf");
133 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
138 elseif ($action ==
'set')
141 } elseif ($action ==
'del')
146 if ($conf->global->EXPEDITION_ADDON_PDF ==
"$value")
dolibarr_del_const($db,
'EXPEDITION_ADDON_PDF', $conf->entity);
151 elseif ($action ==
'setdoc')
153 if (
dolibarr_set_const($db,
"EXPEDITION_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity))
157 $conf->global->EXPEDITION_ADDON_PDF = $value;
166 } elseif ($action ==
'setmodel')
168 dolibarr_set_const($db,
"EXPEDITION_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
176 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
178 $form =
new Form($db);
180 llxHeader(
"", $langs->trans(
"SendingsSetup"));
182 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
187 print
dol_get_fiche_head($head,
'shipment', $langs->trans(
"Sendings"), -1,
'shipment');
193 print
'<table class="noborder centpercent">';
194 print
'<tr class="liste_titre">';
195 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
196 print
'<td>'.$langs->trans(
"Description").
'</td>';
197 print
'<td>'.$langs->trans(
"Example").
'</td>';
198 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
199 print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
204 foreach ($dirmodels as $reldir)
210 $handle = opendir($dir);
211 if (is_resource($handle))
213 while (($file = readdir($handle)) !==
false)
215 if (preg_match(
'/^mod_expedition_([a-z0-9_]*)\.php$/', $file)) {
216 $file = substr($file, 0,
dol_strlen($file) - 4);
218 require_once $dir.$file.
'.php';
222 if ($module->isEnabled())
225 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
226 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
228 print
'<tr><td>'.$module->name.
"</td>\n";
230 print $module->info();
234 print
'<td class="nowrap">';
235 $tmp = $module->getExample();
236 if (preg_match(
'/^Error/', $tmp)) {
237 $langs->load(
"errors");
238 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
239 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
243 print '<td class="center">';
244 if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file")
246 print
img_picto($langs->trans(
"Activated"),
'switch_on');
248 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodel&token='.
newToken().
'&value='.$file.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">';
249 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
255 $expedition->initAsSpecimen();
259 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
260 $nextval = $module->getNextValue($mysoc, $expedition);
261 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
262 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
264 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
265 $nextval = $langs->trans($nextval);
266 $htmltooltip .= $nextval.
'<br>';
268 $htmltooltip .= $langs->trans($module->error).
'<br>';
272 print
'<td class="center">';
273 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
285 print
'</table><br>';
298 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
299 $sql .=
" WHERE type = '".$db->escape($type).
"'";
300 $sql .=
" AND entity = ".$conf->entity;
302 $resql = $db->query($sql);
306 $num_rows = $db->num_rows(
$resql);
307 while ($i < $num_rows)
309 $array = $db->fetch_array(
$resql);
310 array_push($def, $array[0]);
317 print
'<table class="noborder centpercent">';
318 print
'<tr class="liste_titre">';
319 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
320 print
'<td>'.$langs->trans(
"Description").
'</td>';
321 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
322 print
'<td class="center" width="60">'.$langs->trans(
"Default").
'</td>';
323 print
'<td class="nowrap center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
324 print
'<td class="nowrap center" width="80" >'.$langs->trans(
"Preview").
'</td>';
329 foreach ($dirmodels as $reldir)
331 foreach (array(
'',
'/doc') as $valdir)
333 $dir =
dol_buildpath($reldir.
"core/modules/expedition".$valdir);
337 $handle = opendir($dir);
338 if (is_resource($handle))
340 while (($file = readdir($handle)) !==
false)
347 foreach ($filelist as $file)
349 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
351 if (file_exists($dir.
'/'.$file))
353 $name = substr($file, 4,
dol_strlen($file) - 16);
354 $classname = substr($file, 0,
dol_strlen($file) - 12);
356 require_once $dir.
'/'.$file;
357 $module =
new $classname($db);
359 $modulequalified = 1;
360 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
361 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
363 if ($modulequalified)
365 print
'<tr><td width="100">';
366 print (empty($module->name) ? $name : $module->name);
368 if (method_exists($module,
'info')) print $module->info($langs);
369 else print $module->description;
373 if (in_array($name, $def))
375 print
'<td class="center">'.
"\n";
376 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'">';
377 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
381 print
'<td class="center">'.
"\n";
382 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
387 print
'<td class="center">';
388 if ($conf->global->EXPEDITION_ADDON_PDF == $name)
390 print
img_picto($langs->trans(
"Default"),
'on');
392 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
397 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
398 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
399 if ($module->type ==
'pdf')
401 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
403 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
404 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
405 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
406 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
407 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
408 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
410 print
'<td class="center">';
411 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
415 print
'<td class="center">';
416 if ($module->type ==
'pdf')
418 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>';
420 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
444 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
445 print
'<input type="hidden" name="token" value="'.newToken().
'">';
446 print
'<input type="hidden" name="action" value="set_param">';
448 print
"<table class=\"noborder\" width=\"100%\">";
449 print
"<tr class=\"liste_titre\">";
450 print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
454 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
455 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
456 foreach ($substitutionarray as $key => $val) $htmltext .= $key.
'<br>';
460 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnShippings"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
461 $variablename =
'SHIPPING_FREE_TEXT';
462 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
464 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.$conf->global->$variablename.
'</textarea>';
466 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
467 $doleditor =
new DolEditor($variablename, $conf->global->$variablename,
'', 80,
'dolibarr_notes');
468 print $doleditor->Create();
470 print
"</td></tr>\n";
473 print $form->textwithpicto($langs->trans(
"WatermarkOnDraftContractCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
474 print
'<input size="50" class="flat" type="text" name="SHIPPING_DRAFT_WATERMARK" value="'.$conf->global->SHIPPING_DRAFT_WATERMARK.
'">';
475 print
"</td></tr>\n";
479 print
'<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"Modify").
'"></div>';
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.
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.
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)
Effacement d'une constante dans la base de donnees.
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.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
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 ...
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.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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'.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage a WYSIWYG editor.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.