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/fourn.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
39 $langs->loadLangs(array(
"admin",
"other",
"orders"));
41 $action =
GETPOST(
'action',
'aZ09');
43 $type =
GETPOST(
'type',
'alpha');
44 $value =
GETPOST(
'value',
'alpha');
45 $modulepart =
GETPOST(
'modulepart',
'aZ09');
47 $label =
GETPOST(
'label',
'alpha');
48 $scandir =
GETPOST(
'scan_dir',
'alpha');
50 $specimenthirdparty =
new Societe($db);
51 $specimenthirdparty->initAsSpecimen();
64 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
66 if ($action ==
'updateMask') {
67 $maskconstinvoice =
GETPOST(
'maskconstinvoice',
'aZ09');
68 $maskconstcredit =
GETPOST(
'maskconstcredit',
'aZ09');
69 $maskconstdeposit =
GETPOST(
'maskconstdeposit',
'aZ09');
70 $maskinvoice =
GETPOST(
'maskinvoice',
'alpha');
71 $maskcredit =
GETPOST(
'maskcredit',
'alpha');
72 $maskdeposit =
GETPOST(
'maskdeposit',
'alpha');
74 if ($maskconstinvoice && preg_match(
'/_MASK$/', $maskconstinvoice)) {
75 $res =
dolibarr_set_const($db, $maskconstinvoice, $maskinvoice,
'chaine', 0,
'', $conf->entity);
77 if ($maskconstcredit && preg_match(
'/_MASK$/', $maskconstcredit)) {
78 $res =
dolibarr_set_const($db, $maskconstcredit, $maskcredit,
'chaine', 0,
'', $conf->entity);
80 if ($maskconstdeposit && preg_match(
'/_MASK$/', $maskconstdeposit)) {
81 $res =
dolibarr_set_const($db, $maskconstdeposit, $maskdeposit,
'chaine', 0,
'', $conf->entity);
95 if ($action ==
'specimen') {
96 $modele =
GETPOST(
'module',
'alpha');
99 $facture->initAsSpecimen();
100 $facture->thirdparty = $specimenthirdparty;
106 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
107 foreach ($dirmodels as $reldir) {
108 $file =
dol_buildpath($reldir.
"core/modules/supplier_invoice/doc/pdf_".$modele.
".modules.php", 0);
109 if (file_exists($file)) {
111 $classname =
"pdf_".$modele;
119 $module =
new $classname($db, $facture);
121 if ($module->write_file($facture, $langs) > 0) {
122 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
130 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
132 } elseif ($action ==
'set') {
135 } elseif ($action ==
'del') {
138 if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF ==
"$value") {
142 } elseif ($action ==
'setdoc') {
144 if (
dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
147 $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
155 } elseif ($action ==
'unsetdoc') {
159 if ($action ==
'setmod') {
163 dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
166 if ($action ==
'addcat') {
168 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
171 if ($action ==
'set_SUPPLIER_INVOICE_FREE_TEXT') {
172 $freetext =
GETPOST(
'SUPPLIER_INVOICE_FREE_TEXT',
'restricthtml');
174 $res =
dolibarr_set_const($db,
"SUPPLIER_INVOICE_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
194 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
198 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
199 print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
205 print
dol_get_fiche_head($head,
'invoice', $langs->trans(
"Suppliers"), -1,
'company');
210 print
load_fiche_titre($langs->trans(
"SuppliersInvoiceNumberingModel"),
'',
'');
212 print
'<div class="div-table-responsive-no-min">';
213 print
'<table class="noborder centpercent">';
214 print
'<tr class="liste_titre">';
215 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
216 print
'<td>'.$langs->trans(
"Description").
'</td>';
217 print
'<td>'.$langs->trans(
"Example").
'</td>';
218 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
219 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
224 foreach ($dirmodels as $reldir) {
225 $dir =
dol_buildpath($reldir.
"core/modules/supplier_invoice");
228 $handle = opendir($dir);
229 if (is_resource($handle)) {
230 while (($file = readdir($handle)) !==
false) {
231 if (substr($file, 0, 24) ==
'mod_facture_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
232 $file = substr($file, 0,
dol_strlen($file) - 4);
234 require_once $dir.
'/'.$file.
'.php';
238 if ($module->isEnabled()) {
240 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
243 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
248 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
249 print $module->info();
253 print
'<td class="nowrap">';
254 $tmp = $module->getExample();
255 if (preg_match(
'/^Error/', $tmp)) {
256 $langs->load(
"errors");
257 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
258 } elseif ($tmp ==
'NotConfigured') {
259 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
265 print
'<td class="center">';
266 if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER ==
"$file") {
267 print
img_picto($langs->trans(
"Activated"),
'switch_on');
269 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>';
274 $invoice->initAsSpecimen();
278 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
279 $nextval = $module->getNextValue($mysoc, $invoice);
280 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
281 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
283 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
284 $nextval = $langs->trans($nextval);
286 $htmltooltip .= $nextval.
'<br>';
288 $htmltooltip .= $langs->trans($module->error).
'<br>';
292 print
'<td class="center">';
293 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
305 print
'</table></div><br>';
320 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
321 $sql .=
" WHERE type = 'invoice_supplier'";
322 $sql .=
" AND entity = ".$conf->entity;
324 $resql = $db->query(
$sql);
327 $num_rows = $db->num_rows($resql);
328 while ($i < $num_rows) {
329 $array = $db->fetch_array($resql);
330 array_push($def, $array[0]);
337 print
'<div class="div-table-responsive-no-min">';
338 print
'<table class="noborder centpercent">'.
"\n";
339 print
'<tr class="liste_titre">'.
"\n";
340 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
341 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
342 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
343 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
344 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
345 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
350 foreach ($dirmodels as $reldir) {
351 $realpath = $reldir.
"core/modules/supplier_invoice/doc";
355 $handle = opendir($dir);
358 if (is_resource($handle)) {
359 while (($file = readdir($handle)) !==
false) {
360 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
361 $name = substr($file, 4,
dol_strlen($file) - 16);
362 $classname = substr($file, 0,
dol_strlen($file) - 12);
364 require_once $dir.
'/'.$file;
368 print
"<tr class=\"oddeven\">\n";
370 print (empty($module->name) ? $name : $module->name);
373 require_once $dir.
'/'.$file;
374 $module =
new $classname($db, $specimenthirdparty);
375 if (method_exists($module,
'info')) {
376 print $module->info($langs);
378 print $module->description;
384 if (in_array($name, $def)) {
385 print
'<td class="center">'.
"\n";
389 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=invoice_supplier">';
390 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
399 print
'<td class="center">'.
"\n";
400 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=invoice_supplier">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
405 print
'<td class="center">';
409 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=invoice_supplier"" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
411 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=invoice_supplier"" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
416 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
417 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
418 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
419 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
421 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
422 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
423 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
424 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
425 print
'<td class="center">';
426 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
428 print
'<td class="center">';
429 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
441 print
'</table></div><br>';
447 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
448 print
'<input type="hidden" name="token" value="'.newToken().
'">';
449 print
'<input type="hidden" name="action" value="set_SUPPLIER_INVOICE_FREE_TEXT">';
453 print
'<div class="div-table-responsive-no-min">';
454 print
'<table class="noborder centpercent">';
455 print
'<tr class="liste_titre">';
456 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
457 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
458 print
'<td width="80"> </td>';
462 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
463 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
464 foreach ($substitutionarray as $key => $val) {
465 $htmltext .= $key.
'<br>';
469 print
'<tr class="oddeven"><td colspan="2">';
470 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnInvoices"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
471 $variablename =
'SUPPLIER_INVOICE_FREE_TEXT';
472 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
473 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
475 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
477 print $doleditor->Create();
479 print
'</td><td class="right">';
480 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
481 print
"</td></tr>\n";
483 print
'</table></div><br>';
494 print
'<div class="div-table-responsive-no-min">';
495 print
'<table class="noborder centpercent">';
496 print
'<tr class="liste_titre">';
497 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
498 print
'<td align="center" width="60"></td>';
499 print
'<td width="80"> </td>';
502 print
'<tr class="oddeven"><td colspan="2">';
503 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
504 print
'</td><td class="right">';
505 print
"</td></tr>\n";