30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
38 $langs->loadLangs(array(
"admin",
"other",
"orders"));
44 $type =
GETPOST(
'type',
'alpha');
45 $value =
GETPOST(
'value',
'alpha');
46 $action =
GETPOST(
'action',
'aZ09');
48 $label =
GETPOST(
'label',
'alpha');
49 $scandir =
GETPOST(
'scan_dir',
'alpha');
51 $specimenthirdparty =
new Societe($db);
52 $specimenthirdparty->initAsSpecimen();
59 if ($action ==
'updateMask') {
60 $maskconstinvoice =
GETPOST(
'maskconstinvoice',
'alpha');
61 $maskconstcredit =
GETPOST(
'maskconstcredit',
'alpha');
62 $maskconstdeposit =
GETPOST(
'maskconstdeposit',
'alpha');
63 $maskinvoice =
GETPOST(
'maskinvoice',
'alpha');
64 $maskcredit =
GETPOST(
'maskcredit',
'alpha');
65 $maskdeposit =
GETPOST(
'maskdeposit',
'alpha');
67 if ($maskconstinvoice) {
68 $res =
dolibarr_set_const($db, $maskconstinvoice, $maskinvoice,
'chaine', 0,
'', $conf->entity);
70 if ($maskconstcredit) {
71 $res =
dolibarr_set_const($db, $maskconstcredit, $maskcredit,
'chaine', 0,
'', $conf->entity);
73 if ($maskconstdeposit) {
74 $res =
dolibarr_set_const($db, $maskconstdeposit, $maskdeposit,
'chaine', 0,
'', $conf->entity);
88 if ($action ==
'specimen') {
89 $modele =
GETPOST(
'module',
'alpha');
92 $facture->initAsSpecimen();
93 $facture->thirdparty = $specimenthirdparty;
96 $file =
''; $classname =
''; $filefound = 0;
97 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
98 foreach ($dirmodels as $reldir) {
99 $file =
dol_buildpath($reldir.
"core/modules/supplier_invoice/doc/pdf_".$modele.
".modules.php", 0);
100 if (file_exists($file)) {
102 $classname =
"pdf_".$modele;
110 $module =
new $classname($db, $facture);
112 if ($module->write_file($facture, $langs) > 0) {
113 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
121 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
123 } elseif ($action ==
'set') {
126 } elseif ($action ==
'del') {
129 if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF ==
"$value") {
133 } elseif ($action ==
'setdoc') {
135 if (
dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
138 $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
146 } elseif ($action ==
'unsetdoc') {
150 if ($action ==
'setmod') {
154 dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
157 if ($action ==
'addcat') {
159 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
162 if ($action ==
'set_SUPPLIER_INVOICE_FREE_TEXT') {
163 $freetext =
GETPOST(
'SUPPLIER_INVOICE_FREE_TEXT',
'restricthtml');
165 $res =
dolibarr_set_const($db,
"SUPPLIER_INVOICE_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
183 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
189 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
190 print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
196 print
dol_get_fiche_head($head,
'invoice', $langs->trans(
"Suppliers"), -1,
'company');
201 print
load_fiche_titre($langs->trans(
"SuppliersInvoiceNumberingModel"),
'',
'');
203 print
'<table class="noborder centpercent">';
204 print
'<tr class="liste_titre">';
205 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
206 print
'<td>'.$langs->trans(
"Description").
'</td>';
207 print
'<td>'.$langs->trans(
"Example").
'</td>';
208 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
209 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
214 foreach ($dirmodels as $reldir) {
215 $dir =
dol_buildpath($reldir.
"core/modules/supplier_invoice");
218 $handle = opendir($dir);
219 if (is_resource($handle)) {
220 while (($file = readdir($handle)) !==
false) {
221 if (substr($file, 0, 24) ==
'mod_facture_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
222 $file = substr($file, 0,
dol_strlen($file) - 4);
224 require_once $dir.
'/'.$file.
'.php';
228 if ($module->isEnabled()) {
230 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
233 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
238 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
239 print $module->info();
243 print
'<td class="nowrap">';
244 $tmp = $module->getExample();
245 if (preg_match(
'/^Error/', $tmp)) {
246 $langs->load(
"errors");
247 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
248 } elseif ($tmp ==
'NotConfigured') {
249 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
255 print
'<td class="center">';
256 if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER ==
"$file") {
257 print
img_picto($langs->trans(
"Activated"),
'switch_on');
259 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>';
264 $invoice->initAsSpecimen();
268 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
269 $nextval = $module->getNextValue($mysoc, $invoice);
270 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
271 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
273 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
274 $nextval = $langs->trans($nextval);
276 $htmltooltip .= $nextval.
'<br>';
278 $htmltooltip .= $langs->trans($module->error).
'<br>';
282 print
'<td class="center">';
283 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
295 print
'</table><br>';
310 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
311 $sql .=
" WHERE type = 'invoice_supplier'";
312 $sql .=
" AND entity = ".$conf->entity;
314 $resql = $db->query($sql);
317 $num_rows = $db->num_rows(
$resql);
318 while ($i < $num_rows) {
319 $array = $db->fetch_array(
$resql);
320 array_push($def, $array[0]);
327 print
'<table class="noborder centpercent">'.
"\n";
328 print
'<tr class="liste_titre">'.
"\n";
329 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
330 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
331 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
332 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
333 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
334 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
339 foreach ($dirmodels as $reldir) {
340 $realpath = $reldir.
"core/modules/supplier_invoice/doc";
344 $handle = opendir($dir);
347 if (is_resource($handle)) {
348 while (($file = readdir($handle)) !==
false) {
349 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
350 $name = substr($file, 4,
dol_strlen($file) - 16);
351 $classname = substr($file, 0,
dol_strlen($file) - 12);
353 require_once $dir.
'/'.$file;
357 print
"<tr class=\"oddeven\">\n";
359 print (empty($module->name) ? $name : $module->name);
362 require_once $dir.
'/'.$file;
363 $module =
new $classname($db, $specimenthirdparty);
364 if (method_exists($module,
'info')) {
365 print $module->info($langs);
367 print $module->description;
373 if (in_array($name, $def)) {
374 print
'<td class="center">'.
"\n";
378 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=invoice_supplier">';
379 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
388 print
'<td class="center">'.
"\n";
389 print
'<a 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>';
394 print
'<td class="center">';
395 if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF ==
"$name") {
398 print
'<a 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>';
400 print
'<a 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>';
405 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
406 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
407 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
408 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
410 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
411 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
412 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
413 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
414 print
'<td class="center">';
415 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
417 print
'<td class="center">';
418 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
430 print
'</table><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_SUPPLIER_INVOICE_FREE_TEXT">';
441 print
'<table class="noborder centpercent">';
442 print
'<tr class="liste_titre">';
443 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
444 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
445 print
'<td width="80"> </td>';
449 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
450 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
451 foreach ($substitutionarray as $key => $val) {
452 $htmltext .= $key.
'<br>';
456 print
'<tr class="oddeven"><td colspan="2">';
457 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnInvoices"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
458 $variablename =
'SUPPLIER_INVOICE_FREE_TEXT';
459 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
460 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
462 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
464 print $doleditor->Create();
466 print
'</td><td class="right">';
467 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
468 print
"</td></tr>\n";
470 print
'</table><br>';
480 print
'<table class="noborder centpercent">';
481 print
'<tr class="liste_titre">';
482 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
483 print
'<td align="center" width="60"></td>';
484 print
'<td width="80"> </td>';
487 print
'<tr class="oddeven"><td colspan="2">';
488 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
489 print
'</td><td class="right">';
490 print
"</td></tr>\n";