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.
'/delivery/class/delivery.class.php';
38 $langs->loadLangs(array(
"admin",
"sendings",
"deliveries",
"other"));
42 $action =
GETPOST(
'action',
'alpha');
43 $value =
GETPOST(
'value',
'alpha');
44 $label =
GETPOST(
'label',
'alpha');
45 $scandir =
GETPOST(
'scan_dir',
'alpha');
53 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
55 if ($action ==
'updateMask')
57 $maskconstdelivery =
GETPOST(
'maskconstdelivery',
'alpha');
58 $maskdelivery =
GETPOST(
'maskdelivery',
'alpha');
59 if ($maskconstdelivery) $res =
dolibarr_set_const($db, $maskconstdelivery, $maskdelivery,
'chaine', 0,
'', $conf->entity);
61 if (!($res > 0)) $error++;
71 if ($action ==
'set_DELIVERY_FREE_TEXT')
73 $free =
GETPOST(
'DELIVERY_FREE_TEXT',
'restricthtml');
74 $res =
dolibarr_set_const($db,
"DELIVERY_FREE_TEXT", $free,
'chaine', 0,
'', $conf->entity);
76 if (!($res > 0)) $error++;
86 if ($action ==
'specimen')
88 $modele =
GETPOST(
'module',
'alpha');
91 $sending->initAsSpecimen();
94 $file =
''; $classname =
''; $filefound = 0;
95 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
96 foreach ($dirmodels as $reldir)
98 $file =
dol_buildpath($reldir.
"core/modules/delivery/doc/pdf_".$modele.
".modules.php", 0);
99 if (file_exists($file))
102 $classname =
"pdf_".$modele;
111 $module =
new $classname($db);
113 if ($module->write_file($sending, $langs) > 0)
115 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=delivery&file=SPECIMEN.pdf");
123 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
127 if ($action ==
'set')
132 if ($action ==
'del')
137 if ($conf->global->DELIVERY_ADDON_PDF ==
"$value")
dolibarr_del_const($db,
'DELIVERY_ADDON_PDF', $conf->entity);
141 if ($action ==
'setdoc')
143 if (
dolibarr_set_const($db,
"DELIVERY_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity))
147 $conf->global->DELIVERY_ADDON_PDF = $value;
158 if ($action ==
'setmod')
163 dolibarr_set_const($db,
"DELIVERY_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
171 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
175 $form =
new Form($db);
177 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
182 print
dol_get_fiche_head($head,
'receivings', $langs->trans(
"Receivings"), -1,
'shipment');
187 print
load_fiche_titre($langs->trans(
"DeliveryOrderNumberingModules"),
'',
'');
189 print
'<table class="noborder centpercent">';
190 print
'<tr class="liste_titre">';
191 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
192 print
'<td>'.$langs->trans(
"Description").
'</td>';
193 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
194 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
195 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
200 foreach ($dirmodels as $reldir)
206 $handle = opendir($dir);
207 if (is_resource($handle))
209 while (($file = readdir($handle)) !==
false)
211 if (preg_match(
'/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
212 $file = substr($file, 0,
dol_strlen($file) - 4);
214 require_once $dir.$file.
'.php';
218 if ($module->isEnabled())
221 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
222 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
224 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
225 print $module->info();
229 print
'<td class="nowrap">';
230 $tmp = $module->getExample();
231 if (preg_match(
'/^Error/', $tmp)) {
232 $langs->load(
"errors");
233 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
234 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
238 print '<td class="center">';
239 if ($conf->global->DELIVERY_ADDON_NUMBER == "$file")
241 print
img_picto($langs->trans(
"Activated"),
'switch_on');
243 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>';
248 $delivery->initAsSpecimen();
252 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
253 $nextval = $module->getNextValue($mysoc, $delivery);
254 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
255 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
257 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
258 $nextval = $langs->trans($nextval);
259 $htmltooltip .= $nextval.
'<br>';
261 $htmltooltip .= $langs->trans($module->error).
'<br>';
265 print
'<td class="center">';
266 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
292 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
293 $sql .=
" WHERE type = '".$db->escape($type).
"'";
294 $sql .=
" AND entity = ".$conf->entity;
296 $resql = $db->query($sql);
300 $num_rows = $db->num_rows(
$resql);
301 while ($i < $num_rows)
303 $array = $db->fetch_array(
$resql);
304 array_push($def, $array[0]);
311 print
'<table class="noborder centpercent">';
312 print
'<tr class="liste_titre">';
313 print
'<td width="140">'.$langs->trans(
"Name").
'</td>';
314 print
'<td>'.$langs->trans(
"Description").
'</td>';
315 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
316 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>';
317 print
'<td align="center" width="32">'.$langs->trans(
"ShortInfo").
'</td>';
318 print
'<td align="center" width="32">'.$langs->trans(
"Preview").
'</td>';
323 foreach ($dirmodels as $reldir)
329 $handle = opendir($dir);
330 if (is_resource($handle))
332 while (($file = readdir($handle)) !==
false)
339 foreach ($filelist as $file)
341 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
343 if (file_exists($dir.
'/'.$file))
345 $name = substr($file, 4,
dol_strlen($file) - 16);
346 $classname = substr($file, 0,
dol_strlen($file) - 12);
348 require_once $dir.
'/'.$file;
349 $module =
new $classname($db);
351 $modulequalified = 1;
352 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
353 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
355 if ($modulequalified)
357 print
'<tr class="oddeven"><td width="100">';
358 print (empty($module->name) ? $name : $module->name);
360 if (method_exists($module,
'info')) print $module->info($langs);
361 else print $module->description;
365 if (in_array($name, $def))
367 print
"<td align=\"center\">\n";
368 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">';
369 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
373 print
"<td align=\"center\">\n";
374 print
'<a 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>';
379 print
"<td align=\"center\">";
380 if ($conf->global->DELIVERY_ADDON_PDF ==
"$name")
382 print
img_picto($langs->trans(
"Default"),
'on');
384 print
'<a 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>';
389 $htmltooltip =
''.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
390 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
391 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
'</u>:';
392 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
393 print
'<td class="center">';
394 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
398 print
'<td class="center">';
399 if ($module->type ==
'pdf')
401 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
403 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
423 print
'<table class="noborder centpercent">';
424 print
'<tr class="liste_titre">';
425 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
426 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
427 print
'<td width="80"> </td>';
431 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
432 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
433 foreach ($substitutionarray as $key => $val) $htmltext .= $key.
'<br>';
436 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
437 print
'<input type="hidden" name="token" value="'.newToken().
'">';
438 print
'<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
439 print
'<tr class="oddeven"><td colspan="2">';
440 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnDeliveryReceipts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
441 $variablename =
'DELIVERY_FREE_TEXT';
442 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
444 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.$conf->global->$variablename.
'</textarea>';
446 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
447 $doleditor =
new DolEditor($variablename, $conf->global->$variablename,
'', 80,
'dolibarr_notes');
448 print $doleditor->Create();
450 print
'</td><td class="right">';
451 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
452 print
"</td></tr>\n";
Class to manage receptions.
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.
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.