dolibarr 23.0.3
invoice.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
7 * Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
9 * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
10 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
11 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 */
27
34// Load Dolibarr environment
35require '../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
48
49// Load translation files required by the page
50$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
51
52if (!$user->admin) {
54}
55
56$action = GETPOST('action', 'aZ09');
57$value = GETPOST('value', 'alpha');
58$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
59
60$label = GETPOST('label', 'alpha');
61$scandir = GETPOST('scan_dir', 'alpha');
62$type = 'invoice';
63
64$error = 0;
65$reg = array();
66
67
68/*
69 * Actions
70 */
71
72include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
73
74if ($action == 'updateMask') {
75 $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09');
76 $maskconstreplacement = GETPOST('maskconstreplacement', 'aZ09');
77 $maskconstcredit = GETPOST('maskconstcredit', 'aZ09');
78 $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09');
79 $maskinvoice = GETPOST('maskinvoice', 'alpha');
80 $maskreplacement = GETPOST('maskreplacement', 'alpha');
81 $maskcredit = GETPOST('maskcredit', 'alpha');
82 $maskdeposit = GETPOST('maskdeposit', 'alpha');
83 $res = 0;
84 if ($maskconstinvoice && preg_match('/_MASK_/', $maskconstinvoice)) {
85 $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
86 }
87 if ($maskconstreplacement && preg_match('/_MASK_/', $maskconstreplacement)) {
88 $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
89 }
90 if ($maskconstcredit && preg_match('/_MASK_/', $maskconstcredit)) {
91 $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
92 }
93 if ($maskconstdeposit && preg_match('/_MASK_/', $maskconstdeposit)) {
94 $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
95 }
96
97 if (!($res > 0)) {
98 $error++;
99 }
100
101 if (!$error) {
102 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
103 } else {
104 setEventMessages($langs->trans("Error"), null, 'errors');
105 }
106} elseif ($action == 'specimen') {
107 $modele = GETPOST('module', 'alpha');
108
109 $facture = new Facture($db);
110 $facture->initAsSpecimen();
111
112 // Search template files
113 $file = '';
114 $classname = '';
115 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
116 foreach ($dirmodels as $reldir) {
117 $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
118 if (file_exists($file)) {
119 $classname = "pdf_".$modele;
120 break;
121 }
122 }
123
124 if ($classname !== '') {
125 require_once $file;
126
127 $module = new $classname($db);
129 '@phan-var-force ModelePDFFactures $module';
130
131 if ($module->write_file($facture, $langs) > 0) {
132 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
133 return;
134 } else {
135 setEventMessages($module->error, $module->errors, 'errors');
136 dol_syslog($module->error, LOG_ERR);
137 }
138 } else {
139 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
140 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
141 }
142} elseif ($action == 'set') {
143 // Activate a model
144 $ret = addDocumentModel($value, $type, $label, $scandir);
145} elseif ($action == 'del') {
146 $ret = delDocumentModel($value, $type);
147 if ($ret > 0) {
148 if (getDolGlobalString('FACTURE_ADDON_PDF') == (string) $value) {
149 dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
150 }
151 }
152} elseif ($action == 'setdoc') {
153 // Set default model
154 if (dolibarr_set_const($db, "FACTURE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
155 // La constante qui a ete lue en avant du nouveau set
156 // on passe donc par une variable pour avoir un affichage coherent
157 $conf->global->FACTURE_ADDON_PDF = $value;
158 }
159
160 // On active le modele
161 $ret = delDocumentModel($value, $type);
162 if ($ret > 0) {
163 $ret = addDocumentModel($value, $type, $label, $scandir);
164 }
165} elseif ($action == 'setmod') {
166 // TODO Check if numbering module chosen can ba activated by calling method canBeActivated()
167
168 dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity);
169} elseif ($action == 'setribchq') {
170 $rib = GETPOST('rib', 'alpha');
171 $chq = GETPOST('chq', 'alpha');
172
173 $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
174 $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
175
176 if (!($res > 0)) {
177 $error++;
178 }
179
180 if (!$error) {
181 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
182 } else {
183 setEventMessages($langs->trans("Error"), null, 'errors');
184 }
185} elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') {
186 $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha');
187
188 $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
189
190 if (!($res > 0)) {
191 $error++;
192 }
193
194 if (!$error) {
195 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
196 } else {
197 setEventMessages($langs->trans("Error"), null, 'errors');
198 }
199} elseif ($action == 'set_INVOICE_FREE_TEXT') {
200 $freetext = GETPOST('INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
201
202 $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
203
204 if (!($res > 0)) {
205 $error++;
206 }
207
208 if (!$error) {
209 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
210 } else {
211 setEventMessages($langs->trans("Error"), null, 'errors');
212 }
213} elseif ($action == 'setforcedate') {
214 $forcedate = GETPOST('forcedate', 'alpha');
215
216 $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
217
218 if (!($res > 0)) {
219 $error++;
220 }
221
222 if (!$error) {
223 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
224 } else {
225 setEventMessages($langs->trans("Error"), null, 'errors');
226 }
227} elseif ($action == 'setDefaultPDFModulesByType') {
228 $invoicetypemodels = GETPOST('invoicetypemodels');
229
230 if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) {
231 $error = 0;
232
233 foreach ($invoicetypemodels as $type => $value) {
234 $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
235 if (!($res > 0)) {
236 $error++;
237 }
238 }
239
240 if (!$error) {
241 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
242 } else {
243 setEventMessages($langs->trans("Error"), null, 'errors');
244 }
245 }
246} elseif ($action == 'set_INVOICE_CHECK_POSTERIOR_DATE') {
247 $check_posterior_date = GETPOSTINT('INVOICE_CHECK_POSTERIOR_DATE');
248 $res = dolibarr_set_const($db, 'INVOICE_CHECK_POSTERIOR_DATE', $check_posterior_date, 'chaine', 0, '', $conf->entity);
249 if (!($res > 0)) {
250 $error++;
251 }
252} elseif (preg_match('/set_(.*)/', $action, $reg)) {
253 $code = $reg[1];
254 $value = (GETPOST($code) ? GETPOST($code) : 1);
255
256 $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
257 if (!($res > 0)) {
258 $error++;
259 }
260
261 if ($error) {
262 setEventMessages($langs->trans('Error'), null, 'errors');
263 } else {
264 setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
265 header("Location: " . $_SERVER["PHP_SELF"]);
266 exit();
267 }
268} elseif (preg_match('/del_(.*)/', $action, $reg)) {
269 $code = $reg[1];
270 $res = dolibarr_del_const($db, $code, $conf->entity);
271
272 if (!($res > 0)) {
273 $error++;
274 }
275
276 if ($error) {
277 setEventMessages($langs->trans('Error'), null, 'errors');
278 } else {
279 setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
280 header("Location: " . $_SERVER["PHP_SELF"]);
281 exit();
282 }
283}
284
285
286/*
287 * View
288 */
289
290$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
291
292$title = $langs->trans("BillsSetup");
293
294llxHeader("", $title, 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura', '', 0, 0, '', '', '', 'mod-admin page-invoice');
295
296$form = new Form($db);
297
298
299$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
300
301print load_fiche_titre($title, $linkback, 'title_setup');
302
304print dol_get_fiche_head($head, 'general', $langs->trans("Invoices"), -1, 'bill');
305
306// Numbering module
307
308print load_fiche_titre($langs->trans("BillsNumberingModule"), '', '');
309
310print '<div class="div-table-responsive-no-min">';
311print '<table class="noborder centpercent">';
312print '<tr class="liste_titre">';
313print '<td>'.$langs->trans("Name").'</td>';
314print '<td>'.$langs->trans("Description").'</td>';
315print '<td class="nowrap">'.$langs->trans("Example").'</td>';
316print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
317print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
318print '</tr>'."\n";
319
320clearstatcache();
321
322$arrayofmodules = array();
323
324foreach ($dirmodels as $reldir) {
325 $dir = dol_buildpath($reldir."core/modules/facture/");
326 if (is_dir($dir)) {
327 $handle = opendir($dir);
328 if (is_resource($handle)) {
329 while (($file = readdir($handle)) !== false) {
330 if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) {
331 $filebis = $file;
332 $classname = preg_replace('/\.php$/', '', $file);
333 // For compatibility
334 if (!is_file($dir.$filebis)) {
335 $filebis = $file."/".$file.".modules.php";
336 $classname = "mod_facture_".$file;
337 }
338 // Check if there is a filter on country
339 $reg = array();
340 preg_match('/\-(.*)_(.*)$/', $classname, $reg);
341 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
342 continue;
343 }
344
345 $classname = preg_replace('/\-.*$/', '', $classname);
346 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
347 // Charging the numbering class
348 require_once $dir.$filebis;
349
350 $module = new $classname($db);
352 '@phan-var-force ModeleNumRefFactures $module';
353
354 $arrayofmodules[] = $module;
355 }
356 }
357 }
358 closedir($handle);
359 }
360 }
361}
362
363$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
365'@phan-var-force ModeleNumRefFactures[] $arrayofmodules';
366
367foreach ($arrayofmodules as $module) {
368 $file = strtolower($module->getName($langs));
369 if (!preg_match('/^mod_facture_/', $file)) {
370 $file = 'mod_facture_'.$file;
371 }
372
373 // Show modules according to features level
374 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
375 continue;
376 }
377 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
378 continue;
379 }
380 if ($module->version == 'dolibarr_deprecated' && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 0 && getDolGlobalString('FACTURE_ADDON') != $file) {
381 continue;
382 }
383
384 if ($module->isEnabled()) {
385 print '<tr class="oddeven"><td width="100">';
386 print preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', $module->getName($langs)));
387 print "</td><td>\n";
388 print $module->info($langs);
389 print '</td>';
390
391 // Show example of numbering module
392 print '<td class="nowrap">';
393 $tmp = $module->getExample();
394 if (preg_match('/^Error/', $tmp)) {
395 $langs->load("errors");
396 print '<div class="error">'.$langs->trans($tmp).'</div>';
397 } elseif ($tmp == 'NotConfigured') {
398 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
399 } else {
400 print $tmp;
401 }
402 print '</td>'."\n";
403
404 print '<td class="center">';
405 if (getDolGlobalString('FACTURE_ADDON') == $file || getDolGlobalString('FACTURE_ADDON').'.php' == $file) {
406 print img_picto($langs->trans("Activated"), 'switch_on');
407 } else {
408 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
409 }
410 print '</td>';
411
412 $facture = new Facture($db);
413 $facture->initAsSpecimen();
414
415 $htmltooltip = '';
416
417 // Example for standard invoice
418 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
419 $facture->type = 0;
420 $nextval = $module->getNextValue($mysoc, $facture);
421 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
422 $htmltooltip .= $langs->trans("NextValueForInvoices").': ';
423 if ($nextval) {
424 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
425 $nextval = $langs->trans($nextval);
426 }
427 $htmltooltip .= $nextval.'<br>';
428 } else {
429 $htmltooltip .= $langs->trans($module->error).'<br>';
430 }
431 }
432 // Example for replacement invoice
433 if (!getDolGlobalString('INVOICE_DISABLE_REPLACEMENT')) {
434 $facture->type = 1;
435 $nextval = $module->getNextValue($mysoc, $facture);
436 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
437 $htmltooltip .= $langs->trans("NextValueForReplacements").': ';
438 if ($nextval) {
439 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
440 $nextval = $langs->trans($nextval);
441 }
442 $htmltooltip .= $nextval.'<br>';
443 } else {
444 $htmltooltip .= $langs->trans($module->error).'<br>';
445 }
446 }
447 }
448 // Example for credit invoice
449 $facture->type = 2;
450 $nextval = $module->getNextValue($mysoc, $facture);
451 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
452 $htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
453 if ($nextval) {
454 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
455 $nextval = $langs->trans($nextval);
456 }
457 $htmltooltip .= $nextval.'<br>';
458 } else {
459 $htmltooltip .= $langs->trans($module->error).'<br>';
460 }
461 }
462 // Example for deposit invoice
463 $facture->type = 3;
464 $nextval = $module->getNextValue($mysoc, $facture);
465 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
466 $htmltooltip .= $langs->trans("NextValueForDeposit").': ';
467 if ($nextval) {
468 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
469 $nextval = $langs->trans($nextval);
470 }
471 $htmltooltip .= $nextval;
472 } else {
473 $htmltooltip .= $langs->trans($module->error);
474 }
475 }
476
477 print '<td class="center">';
478 print $form->textwithpicto('', $htmltooltip, 1, 'info');
479
480 if (getDolGlobalString('FACTURE_ADDON').'.php' == $file) { // If module is the one used, we show existing errors
481 if (!empty($module->error)) {
482 dol_htmloutput_mesg($module->error, array(), 'error', 1);
483 }
484 }
485
486 print '</td>';
487
488 print "</tr>\n";
489 }
490}
491
492print '</table>';
493print '</div>';
494
495
496/*
497 * Document templates generators
498 */
499
500print '<br>';
501print load_fiche_titre($langs->trans("BillsPDFModules"), '', '');
502
503// Load array def with activated templates
504$type = 'invoice';
505$def = array();
506$sql = "SELECT nom";
507$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
508$sql .= " WHERE type = '".$db->escape($type)."'";
509$sql .= " AND entity = ".((int) $conf->entity);
510$resql = $db->query($sql);
511if ($resql) {
512 $i = 0;
513 $num_rows = $db->num_rows($resql);
514 while ($i < $num_rows) {
515 $array = $db->fetch_array($resql);
516 if (is_array($array)) {
517 array_push($def, $array[0]);
518 }
519 $i++;
520 }
521} else {
522 dol_print_error($db);
523}
524
525print '<div class="div-table-responsive-no-min">';
526print '<table class="noborder centpercent">';
527print '<tr class="liste_titre">';
528print '<td>'.$langs->trans("Name").'</td>';
529print '<td>'.$langs->trans("Description").'</td>';
530print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
531print '<td class="center" width="60">'.$langs->trans("Default").'</td>';
532print '<td class="center" width="32">'.$langs->trans("ShortInfo").'</td>';
533print '<td class="center" width="32">'.$langs->trans("Preview").'</td>';
534print "</tr>\n";
535
536clearstatcache();
537
538$activatedModels = array();
539
540foreach ($dirmodels as $reldir) {
541 foreach (array('', '/doc') as $valdir) {
542 $realpath = $reldir."core/modules/facture".$valdir;
543 $dir = dol_buildpath($realpath);
544
545 if (is_dir($dir)) {
546 $handle = opendir($dir);
547 if (is_resource($handle)) {
548 $filelist = array();
549 while (($file = readdir($handle)) !== false) {
550 $filelist[] = $file;
551 }
552 closedir($handle);
553 arsort($filelist);
554
555 foreach ($filelist as $file) {
556 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
557 if (file_exists($dir.'/'.$file)) {
558 $name = substr($file, 4, dol_strlen($file) - 16);
559 $classname = substr($file, 0, dol_strlen($file) - 12);
560
561 require_once $dir.'/'.$file;
562 $module = new $classname($db);
563
564 '@phan-var-force ModelePDFFactures $module';
567 $modulequalified = 1;
568 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
569 $modulequalified = 0;
570 }
571 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
572 $modulequalified = 0;
573 }
574 if ($module->version == 'disabled') {
575 $modulequalified = 0;
576 }
577
578 if ($modulequalified) {
579 print '<tr class="oddeven"><td width="100">';
580 print(empty($module->name) ? $name : $module->name);
581 print "</td><td>\n";
582 if (method_exists($module, 'info')) {
583 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
584 } else {
585 print $module->description;
586 }
587 print '</td>';
588
589 // Active
590 if (in_array($name, $def)) {
591 print '<td class="center">'."\n";
592 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
593 print img_picto($langs->trans("Enabled"), 'switch_on');
594 print '</a>';
595 print '</td>';
596 } else {
597 print '<td class="center">'."\n";
598 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("SetAsDefault"), 'switch_off').'</a>';
599 print "</td>";
600 }
601
602 // Default
603 print '<td class="center">';
604 if (getDolGlobalString('FACTURE_ADDON_PDF') == (string) $name) {
605 print img_picto($langs->trans("Default"), 'on');
606 } else {
607 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("SetAsDefault"), 'off').'</a>';
608 }
609 print '</td>';
610
611 // Info
612 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
613 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
614 if ($module->type == 'pdf') {
615 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
616 }
617 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
618
619 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
620 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
621 $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
622 $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
623 $htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
624 $htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
625 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
626 $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
627
628
629 print '<td class="center">';
630 print $form->textwithpicto('', $htmltooltip, 1, 'info');
631 print '</td>';
632
633 // Preview
634 print '<td class="center">';
635 if ($module->type == 'pdf') {
636 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
637 } else {
638 print img_object($langs->transnoentitiesnoconv("PreviewNotAvailable"), 'generic');
639 }
640 print '</td>';
641
642 print "</tr>\n";
643 }
644 }
645 }
646 }
647 }
648 }
649 }
650}
651print '</table>';
652print '</div>';
653
654if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) { // Hidden conf
655 /*
656 * Document templates generators
657 */
658 print '<br>';
659 print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
660
661 print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
662 print '<input type="hidden" name="token" value="'.newToken().'" />';
663 print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
664 print '<input type="hidden" name="page_y" value="" />';
665
666 print '<div class="div-table-responsive-no-min">';
667 print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
668 print '<tr class="liste_titre">';
669 print '<td>'.$langs->trans("Type").'</td>';
670 print '<td>'.$langs->trans("Name").'</td>';
671 print '<td class="right"><input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'"></td>';
672 print "</tr>\n";
673
674 $listtype = array(
675 Facture::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
676 Facture::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
677 Facture::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
678 Facture::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
679 );
680 if (getDolGlobalInt('INVOICE_USE_SITUATION')) {
681 $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
682 }
683
684 foreach ($listtype as $type => $trans) {
685 $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
686 $current = getDolGlobalString($thisTypeConfName, getDolGlobalString('FACTURE_ADDON_PDF'));
687 print '<tr >';
688 print '<td>'.$trans.'</td>';
689 print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
690 print "</tr>\n";
691 }
692
693 print '</table>';
694 print '</div>';
695
696 print "</form>";
697}
698
699/*
700 * Payment modes
701 */
702print '<br>';
703print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice"), '', '');
704
705print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
706print '<input type="hidden" name="token" value="'.newToken().'" />';
707print '<input type="hidden" name="page_y" value="" />';
708
709print '<div class="div-table-responsive-no-min">';
710print '<table class="noborder centpercent">';
711
712print '<tr class="liste_titre">';
713print '<td>';
714print '<input type="hidden" name="action" value="setribchq">';
715print $langs->trans("PaymentMode").'</td>';
716print '<td class="right"></td>';
717print "</tr>\n";
718
719print '<tr class="oddeven">';
720print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
721print "<td>";
722if (isModEnabled('bank')) {
723 $sql = "SELECT rowid, label, clos";
724 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
725 $sql .= " WHERE courant = 1";
726 $sql .= " AND entity IN (".getEntity('bank_account').")";
727 $resql = $db->query($sql);
728 if ($resql) {
729 $num = $db->num_rows($resql);
730 $i = 0;
731 if ($num > 0) {
732 print '<select name="rib" class="flat" id="rib">';
733 print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
734 while ($i < $num) {
735 $obj = $db->fetch_object($resql);
736
737 print '<option value="'.$obj->rowid.'"';
738 print getDolGlobalString('FACTURE_RIB_NUMBER') == $obj->rowid ? ' selected' : '';
739 if (!empty($obj->clos)) {
740 print ' disabled';
741 }
742 print '>'.dol_escape_htmltag($obj->label).'</option>';
743
744 $i++;
745 }
746 print "</select>";
747 print ajax_combobox("rib");
748 } else {
749 print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
750 }
751 }
752} else {
753 print $langs->trans("BankModuleNotActive");
754}
755print "</td></tr>";
756
757$FACTURE_CHQ_NUMBER = getDolGlobalInt('FACTURE_CHQ_NUMBER');
758
759print '<tr class="oddeven">';
760print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
761print "<td>";
762print '<select class="flat" name="chq" id="chq">';
763print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
764print '<option value="-1"'.($FACTURE_CHQ_NUMBER == -1 ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
765
766$sql = "SELECT rowid, label";
767$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
768$sql .= " WHERE clos = 0";
769$sql .= " AND courant = 1";
770$sql .= " AND entity IN (".getEntity('bank_account').")";
771
772$resql = $db->query($sql);
773if ($resql) {
774 $num = $db->num_rows($resql);
775 $i = 0;
776 while ($i < $num) {
777 $row = $db->fetch_row($resql);
778
779 print '<option value="'.$row[0].'"';
780 print $FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
781 print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
782
783 $i++;
784 }
785}
786print "</select>";
787print ajax_combobox("chq", array(), 0, 0, 'resolve', '-2');
788
789print "</td></tr>";
790
791// Structured communication
792// Specific to Belgium - See core/lib/functions_be.lib.php
793if ($mysoc->country_code == 'BE') {
794 print '<tr class="oddeven"><td>' . $langs->trans("InvoicePaymentManageStructuredCommunication") . '&nbsp;';
795 print $form->textwithpicto('', $langs->trans("InvoicePaymentManageStructuredCommunicationHelp"), 1, 'help') . '</td>';
796 print '<td class="left" colspan="2">';
797 print ajax_constantonoff('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION');
798 print '</td></tr>';
799}
800
801print "</table>";
802print '</div>';
803
804print '<center>';
805print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'">';
806print '</center>';
807
808print "</form>";
809
810
811print "<br>";
812print load_fiche_titre($langs->trans("OtherOptions"), '', '');
813
814print '<div class="div-table-responsive-no-min">';
815print '<table class="noborder centpercent">';
816print '<tr class="liste_titre">';
817print '<td>'.$langs->trans("Parameters").'</td>';
818print '<td class="center"></td>';
819print '<td width="80">&nbsp;</td>';
820print "</tr>\n";
821
822$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
823$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
824$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
825foreach ($substitutionarray as $key => $val) {
826 $htmltext .= $key.'<br>';
827}
828$htmltext .= '</i>';
829
830print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
831print '<input type="hidden" name="token" value="'.newToken().'" />';
832print '<input type="hidden" name="action" value="set_INVOICE_FREE_TEXT" />';
833print '<input type="hidden" name="page_y" value="" />';
834print '<tr class="oddeven"><td colspan="2">';
835print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
836$variablename = 'INVOICE_FREE_TEXT';
837if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
838 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
839} else {
840 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
841 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
842 print $doleditor->Create();
843}
844print '</td><td class="right">';
845print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
846print "</td></tr>\n";
847print '</form>';
848
849
850print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
851print '<input type="hidden" name="token" value="'.newToken().'" />';
852print '<input type="hidden" name="action" value="set_FACTURE_DRAFT_WATERMARK" />';
853print '<input type="hidden" name="page_y" value="" />';
854print '<tr class="oddeven"><td>';
855print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
856print '</td>';
857print '<td><input class="flat minwidth200imp" type="text" name="FACTURE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('FACTURE_DRAFT_WATERMARK')).'">';
858print '</td><td class="right">';
859print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
860print "</td></tr>\n";
861print '</form>';
862
863
864// Force date validation
865print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
866print '<input type="hidden" name="token" value="'.newToken().'" />';
867print '<input type="hidden" name="action" value="setforcedate" />';
868print '<input type="hidden" name="page_y" value="" />';
869print '<tr class="oddeven"><td>';
870print $langs->trans("ForceInvoiceDate");
871print '</td><td>';
872print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1);
873print '</td><td class="right">';
874print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
875print "</td></tr>\n";
876print '</form>';
877
878
879print '<tr class="oddeven"><td>'.$langs->trans("InvoiceCheckPosteriorDate"). '&nbsp;' ;
880print $form->textwithpicto('', $langs->trans("InvoiceCheckPosteriorDateHelp"), 1, 'help') . '</td>';
881print '<td class="left" colspan="2">';
882print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE');
883print '</td></tr>';
884
885
886// Allow external download
887print '<tr class="oddeven">';
888print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
889print '<td class="left" colspan="2">';
890print ajax_constantonoff('INVOICE_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1);
891print '</td></tr>';
892
893
894// Notifications
895print '<tr class="oddeven">';
896print '<td>'.img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("Notifications").'</td>';
897print '<td colspan="2">';
898print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification");
899print '</td></tr>';
900
901// More PDF options
902print '<tr class="oddeven">';
903print '<td>'.img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("MoreOptionsRelatedToPDF").'</td>';
904print '<td colspan="2">';
905print img_picto('', 'url', 'class="pictofixedwidth"').'<a href="'.DOL_URL_ROOT.'/admin/pdf_other.php">'.$langs->trans("SeeInPDFSetupPage").'</a>';
906print '</td></tr>';
907
908print '</table>';
909print '</div>';
910
911
912print dol_get_fiche_end();
913
914// End of page
915llxFooter();
916$db->close();
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:475
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage a WYSIWYG editor.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage generation of HTML components Only common components must be here.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
global $mysoc
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
invoice_admin_prepare_head()
Return array head with list of tabs to view object information.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition pdf.lib.php:824
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:128
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.