dolibarr 22.0.5
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';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
40
50// Load translation files required by the page
51$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
52
53if (!$user->admin) {
55}
56
57$action = GETPOST('action', 'aZ09');
58$value = GETPOST('value', 'alpha');
59$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
60
61$label = GETPOST('label', 'alpha');
62$scandir = GETPOST('scan_dir', 'alpha');
63$type = 'invoice';
64
65$error = 0;
66$reg = array();
67
68
69/*
70 * Actions
71 */
72
73include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
74
75if ($action == 'updateMask') {
76 $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09');
77 $maskconstreplacement = GETPOST('maskconstreplacement', 'aZ09');
78 $maskconstcredit = GETPOST('maskconstcredit', 'aZ09');
79 $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09');
80 $maskinvoice = GETPOST('maskinvoice', 'alpha');
81 $maskreplacement = GETPOST('maskreplacement', 'alpha');
82 $maskcredit = GETPOST('maskcredit', 'alpha');
83 $maskdeposit = GETPOST('maskdeposit', 'alpha');
84 $res = 0;
85 if ($maskconstinvoice && preg_match('/_MASK_/', $maskconstinvoice)) {
86 $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
87 }
88 if ($maskconstreplacement && preg_match('/_MASK_/', $maskconstreplacement)) {
89 $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
90 }
91 if ($maskconstcredit && preg_match('/_MASK_/', $maskconstcredit)) {
92 $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
93 }
94 if ($maskconstdeposit && preg_match('/_MASK_/', $maskconstdeposit)) {
95 $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
96 }
97
98 if (!($res > 0)) {
99 $error++;
100 }
101
102 if (!$error) {
103 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
104 } else {
105 setEventMessages($langs->trans("Error"), null, 'errors');
106 }
107} elseif ($action == 'specimen') {
108 $modele = GETPOST('module', 'alpha');
109
110 $facture = new Facture($db);
111 $facture->initAsSpecimen();
112
113 // Search template files
114 $file = '';
115 $classname = '';
116 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
117 foreach ($dirmodels as $reldir) {
118 $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
119 if (file_exists($file)) {
120 $classname = "pdf_".$modele;
121 break;
122 }
123 }
124
125 if ($classname !== '') {
126 require_once $file;
127
128 $module = new $classname($db);
130 '@phan-var-force ModelePDFFactures $module';
131
132 if ($module->write_file($facture, $langs) > 0) {
133 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
134 return;
135 } else {
136 setEventMessages($module->error, $module->errors, 'errors');
137 dol_syslog($module->error, LOG_ERR);
138 }
139 } else {
140 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
141 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
142 }
143} elseif ($action == 'set') {
144 // Activate a model
145 $ret = addDocumentModel($value, $type, $label, $scandir);
146} elseif ($action == 'del') {
147 $ret = delDocumentModel($value, $type);
148 if ($ret > 0) {
149 if (getDolGlobalString('FACTURE_ADDON_PDF') == (string) $value) {
150 dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
151 }
152 }
153} elseif ($action == 'setdoc') {
154 // Set default model
155 if (dolibarr_set_const($db, "FACTURE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
156 // La constante qui a ete lue en avant du nouveau set
157 // on passe donc par une variable pour avoir un affichage coherent
158 $conf->global->FACTURE_ADDON_PDF = $value;
159 }
160
161 // On active le modele
162 $ret = delDocumentModel($value, $type);
163 if ($ret > 0) {
164 $ret = addDocumentModel($value, $type, $label, $scandir);
165 }
166} elseif ($action == 'setmod') {
167 // TODO Check if numbering module chosen can ba activated by calling method canBeActivated()
168
169 dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity);
170} elseif ($action == 'setribchq') {
171 $rib = GETPOST('rib', 'alpha');
172 $chq = GETPOST('chq', 'alpha');
173
174 $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
175 $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
176
177 if (!($res > 0)) {
178 $error++;
179 }
180
181 if (!$error) {
182 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
183 } else {
184 setEventMessages($langs->trans("Error"), null, 'errors');
185 }
186} elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') {
187 $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha');
188
189 $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
190
191 if (!($res > 0)) {
192 $error++;
193 }
194
195 if (!$error) {
196 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
197 } else {
198 setEventMessages($langs->trans("Error"), null, 'errors');
199 }
200} elseif ($action == 'set_INVOICE_FREE_TEXT') {
201 $freetext = GETPOST('INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
202
203 $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
204
205 if (!($res > 0)) {
206 $error++;
207 }
208
209 if (!$error) {
210 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
211 } else {
212 setEventMessages($langs->trans("Error"), null, 'errors');
213 }
214} elseif ($action == 'setforcedate') {
215 $forcedate = GETPOST('forcedate', 'alpha');
216
217 $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
218
219 if (!($res > 0)) {
220 $error++;
221 }
222
223 if (!$error) {
224 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
225 } else {
226 setEventMessages($langs->trans("Error"), null, 'errors');
227 }
228} elseif ($action == 'setDefaultPDFModulesByType') {
229 $invoicetypemodels = GETPOST('invoicetypemodels');
230
231 if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) {
232 $error = 0;
233
234 foreach ($invoicetypemodels as $type => $value) {
235 $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
236 if (!($res > 0)) {
237 $error++;
238 }
239 }
240
241 if (!$error) {
242 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
243 } else {
244 setEventMessages($langs->trans("Error"), null, 'errors');
245 }
246 }
247} elseif ($action == 'set_INVOICE_CHECK_POSTERIOR_DATE') {
248 $check_posterior_date = GETPOSTINT('INVOICE_CHECK_POSTERIOR_DATE');
249 $res = dolibarr_set_const($db, 'INVOICE_CHECK_POSTERIOR_DATE', $check_posterior_date, 'chaine', 0, '', $conf->entity);
250 if (!($res > 0)) {
251 $error++;
252 }
253} elseif (preg_match('/set_(.*)/', $action, $reg)) {
254 $code = $reg[1];
255 $value = (GETPOST($code) ? GETPOST($code) : 1);
256
257 $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
258 if (!($res > 0)) {
259 $error++;
260 }
261
262 if ($error) {
263 setEventMessages($langs->trans('Error'), null, 'errors');
264 } else {
265 setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
266 header("Location: " . $_SERVER["PHP_SELF"]);
267 exit();
268 }
269} elseif (preg_match('/del_(.*)/', $action, $reg)) {
270 $code = $reg[1];
271 $res = dolibarr_del_const($db, $code, $conf->entity);
272
273 if (!($res > 0)) {
274 $error++;
275 }
276
277 if ($error) {
278 setEventMessages($langs->trans('Error'), null, 'errors');
279 } else {
280 setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
281 header("Location: " . $_SERVER["PHP_SELF"]);
282 exit();
283 }
284}
285
286
287/*
288 * View
289 */
290
291$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
292
293llxHeader("", $langs->trans("BillsSetup"), 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura', '', 0, 0, '', '', '', 'mod-admin page-invoice');
294
295$form = new Form($db);
296
297
298$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
299print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
300
302print dol_get_fiche_head($head, 'general', $langs->trans("Invoices"), -1, 'bill');
303
304// Numbering module
305
306print load_fiche_titre($langs->trans("BillsNumberingModule"), '', '');
307
308print '<div class="div-table-responsive-no-min">';
309print '<table class="noborder centpercent">';
310print '<tr class="liste_titre">';
311print '<td>'.$langs->trans("Name").'</td>';
312print '<td>'.$langs->trans("Description").'</td>';
313print '<td class="nowrap">'.$langs->trans("Example").'</td>';
314print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
315print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
316print '</tr>'."\n";
317
318clearstatcache();
319
320$arrayofmodules = array();
321
322foreach ($dirmodels as $reldir) {
323 $dir = dol_buildpath($reldir."core/modules/facture/");
324 if (is_dir($dir)) {
325 $handle = opendir($dir);
326 if (is_resource($handle)) {
327 while (($file = readdir($handle)) !== false) {
328 if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) {
329 $filebis = $file;
330 $classname = preg_replace('/\.php$/', '', $file);
331 // For compatibility
332 if (!is_file($dir.$filebis)) {
333 $filebis = $file."/".$file.".modules.php";
334 $classname = "mod_facture_".$file;
335 }
336 // Check if there is a filter on country
337 $reg = array();
338 preg_match('/\-(.*)_(.*)$/', $classname, $reg);
339 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
340 continue;
341 }
342
343 $classname = preg_replace('/\-.*$/', '', $classname);
344 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
345 // Charging the numbering class
346 require_once $dir.$filebis;
347
348 $module = new $classname($db);
350 '@phan-var-force ModeleNumRefFactures $module';
351
352 $arrayofmodules[] = $module;
353 }
354 }
355 }
356 closedir($handle);
357 }
358 }
359}
360
361$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
362
363foreach ($arrayofmodules as $module) {
364 $file = strtolower($module->getName($langs));
365 if (!preg_match('/^mod_facture_/', $file)) {
366 $file = 'mod_facture_'.$file;
367 }
368
369 // Show modules according to features level
370 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
371 continue;
372 }
373 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
374 continue;
375 }
376 if ($module->version == 'dolibarr_deprecated' && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 0 && getDolGlobalString('FACTURE_ADDON') != $file) {
377 continue;
378 }
379
380 if ($module->isEnabled()) {
381 print '<tr class="oddeven"><td width="100">';
382 print preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', $module->getName($langs)));
383 print "</td><td>\n";
384 print $module->info($langs);
385 print '</td>';
386
387 // Show example of numbering module
388 print '<td class="nowrap">';
389 $tmp = $module->getExample();
390 if (preg_match('/^Error/', $tmp)) {
391 $langs->load("errors");
392 print '<div class="error">'.$langs->trans($tmp).'</div>';
393 } elseif ($tmp == 'NotConfigured') {
394 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
395 } else {
396 print $tmp;
397 }
398 print '</td>'."\n";
399
400 print '<td class="center">';
401 if (getDolGlobalString('FACTURE_ADDON') == $file || getDolGlobalString('FACTURE_ADDON').'.php' == $file) {
402 print img_picto($langs->trans("Activated"), 'switch_on');
403 } else {
404 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>';
405 }
406 print '</td>';
407
408 $facture = new Facture($db);
409 $facture->initAsSpecimen();
410
411 $htmltooltip = '';
412
413 // Example for standard invoice
414 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
415 $facture->type = 0;
416 $nextval = $module->getNextValue($mysoc, $facture);
417 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
418 $htmltooltip .= $langs->trans("NextValueForInvoices").': ';
419 if ($nextval) {
420 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
421 $nextval = $langs->trans($nextval);
422 }
423 $htmltooltip .= $nextval.'<br>';
424 } else {
425 $htmltooltip .= $langs->trans($module->error).'<br>';
426 }
427 }
428 // Example for replacement invoice
429 if (!getDolGlobalString('INVOICE_DISABLE_REPLACEMENT')) {
430 $facture->type = 1;
431 $nextval = $module->getNextValue($mysoc, $facture);
432 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
433 $htmltooltip .= $langs->trans("NextValueForReplacements").': ';
434 if ($nextval) {
435 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
436 $nextval = $langs->trans($nextval);
437 }
438 $htmltooltip .= $nextval.'<br>';
439 } else {
440 $htmltooltip .= $langs->trans($module->error).'<br>';
441 }
442 }
443 }
444 // Example for credit invoice
445 $facture->type = 2;
446 $nextval = $module->getNextValue($mysoc, $facture);
447 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
448 $htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
449 if ($nextval) {
450 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
451 $nextval = $langs->trans($nextval);
452 }
453 $htmltooltip .= $nextval.'<br>';
454 } else {
455 $htmltooltip .= $langs->trans($module->error).'<br>';
456 }
457 }
458 // Example for deposit invoice
459 $facture->type = 3;
460 $nextval = $module->getNextValue($mysoc, $facture);
461 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
462 $htmltooltip .= $langs->trans("NextValueForDeposit").': ';
463 if ($nextval) {
464 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
465 $nextval = $langs->trans($nextval);
466 }
467 $htmltooltip .= $nextval;
468 } else {
469 $htmltooltip .= $langs->trans($module->error);
470 }
471 }
472
473 print '<td class="center">';
474 print $form->textwithpicto('', $htmltooltip, 1, 'info');
475
476 if (getDolGlobalString('FACTURE_ADDON').'.php' == $file) { // If module is the one used, we show existing errors
477 if (!empty($module->error)) {
478 dol_htmloutput_mesg($module->error, array(), 'error', 1);
479 }
480 }
481
482 print '</td>';
483
484 print "</tr>\n";
485 }
486}
487
488print '</table>';
489print '</div>';
490
491
492/*
493 * Document templates generators
494 */
495
496print '<br>';
497print load_fiche_titre($langs->trans("BillsPDFModules"), '', '');
498
499// Load array def with activated templates
500$type = 'invoice';
501$def = array();
502$sql = "SELECT nom";
503$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
504$sql .= " WHERE type = '".$db->escape($type)."'";
505$sql .= " AND entity = ".$conf->entity;
506$resql = $db->query($sql);
507if ($resql) {
508 $i = 0;
509 $num_rows = $db->num_rows($resql);
510 while ($i < $num_rows) {
511 $array = $db->fetch_array($resql);
512 if (is_array($array)) {
513 array_push($def, $array[0]);
514 }
515 $i++;
516 }
517} else {
518 dol_print_error($db);
519}
520
521print '<div class="div-table-responsive-no-min">';
522print '<table class="noborder centpercent">';
523print '<tr class="liste_titre">';
524print '<td>'.$langs->trans("Name").'</td>';
525print '<td>'.$langs->trans("Description").'</td>';
526print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
527print '<td class="center" width="60">'.$langs->trans("Default").'</td>';
528print '<td class="center" width="32">'.$langs->trans("ShortInfo").'</td>';
529print '<td class="center" width="32">'.$langs->trans("Preview").'</td>';
530print "</tr>\n";
531
532clearstatcache();
533
534$activatedModels = array();
535
536foreach ($dirmodels as $reldir) {
537 foreach (array('', '/doc') as $valdir) {
538 $realpath = $reldir."core/modules/facture".$valdir;
539 $dir = dol_buildpath($realpath);
540
541 if (is_dir($dir)) {
542 $handle = opendir($dir);
543 if (is_resource($handle)) {
544 $filelist = array();
545 while (($file = readdir($handle)) !== false) {
546 $filelist[] = $file;
547 }
548 closedir($handle);
549 arsort($filelist);
550
551 foreach ($filelist as $file) {
552 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
553 if (file_exists($dir.'/'.$file)) {
554 $name = substr($file, 4, dol_strlen($file) - 16);
555 $classname = substr($file, 0, dol_strlen($file) - 12);
556
557 require_once $dir.'/'.$file;
558 $module = new $classname($db);
559
560 '@phan-var-force ModelePDFFactures $module';
561
562 $modulequalified = 1;
563 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
564 $modulequalified = 0;
565 }
566 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
567 $modulequalified = 0;
568 }
569 if ($module->version == 'disabled') {
570 $modulequalified = 0;
571 }
572
573 if ($modulequalified) {
574 print '<tr class="oddeven"><td width="100">';
575 print(empty($module->name) ? $name : $module->name);
576 print "</td><td>\n";
577 if (method_exists($module, 'info')) {
578 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
579 } else {
580 print $module->description;
581 }
582 print '</td>';
583
584 // Active
585 if (in_array($name, $def)) {
586 print '<td class="center">'."\n";
587 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
588 print img_picto($langs->trans("Enabled"), 'switch_on');
589 print '</a>';
590 print '</td>';
591 } else {
592 print '<td class="center">'."\n";
593 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>';
594 print "</td>";
595 }
596
597 // Default
598 print '<td class="center">';
599 if (getDolGlobalString('FACTURE_ADDON_PDF') == (string) $name) {
600 print img_picto($langs->trans("Default"), 'on');
601 } else {
602 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>';
603 }
604 print '</td>';
605
606 // Info
607 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
608 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
609 if ($module->type == 'pdf') {
610 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
611 }
612 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
613
614 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
615 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
616 $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
617 $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
618 $htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
619 $htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
620 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
621 $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
622
623
624 print '<td class="center">';
625 print $form->textwithpicto('', $htmltooltip, 1, 'info');
626 print '</td>';
627
628 // Preview
629 print '<td class="center">';
630 if ($module->type == 'pdf') {
631 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
632 } else {
633 print img_object($langs->transnoentitiesnoconv("PreviewNotAvailable"), 'generic');
634 }
635 print '</td>';
636
637 print "</tr>\n";
638 }
639 }
640 }
641 }
642 }
643 }
644 }
645}
646print '</table>';
647print '</div>';
648
649if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) { // Hidden conf
650 /*
651 * Document templates generators
652 */
653 print '<br>';
654 print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
655
656 print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
657 print '<input type="hidden" name="token" value="'.newToken().'" />';
658 print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
659 print '<input type="hidden" name="page_y" value="" />';
660
661 print '<div class="div-table-responsive-no-min">';
662 print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
663 print '<tr class="liste_titre">';
664 print '<td>'.$langs->trans("Type").'</td>';
665 print '<td>'.$langs->trans("Name").'</td>';
666 print '<td class="right"><input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'"></td>';
667 print "</tr>\n";
668
669 $listtype = array(
670 Facture::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
671 Facture::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
672 Facture::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
673 Facture::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
674 );
675 if (getDolGlobalInt('INVOICE_USE_SITUATION')) {
676 $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
677 }
678
679 foreach ($listtype as $type => $trans) {
680 $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
681 $current = getDolGlobalString($thisTypeConfName, getDolGlobalString('FACTURE_ADDON_PDF'));
682 print '<tr >';
683 print '<td>'.$trans.'</td>';
684 print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
685 print "</tr>\n";
686 }
687
688 print '</table>';
689 print '</div>';
690
691 print "</form>";
692}
693
694/*
695 * Payment modes
696 */
697print '<br>';
698print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice"), '', '');
699
700print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
701print '<input type="hidden" name="token" value="'.newToken().'" />';
702print '<input type="hidden" name="page_y" value="" />';
703
704print '<div class="div-table-responsive-no-min">';
705print '<table class="noborder centpercent">';
706
707print '<tr class="liste_titre">';
708print '<td>';
709print '<input type="hidden" name="action" value="setribchq">';
710print $langs->trans("PaymentMode").'</td>';
711print '<td class="right"><input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'"></td>';
712print "</tr>\n";
713
714print '<tr class="oddeven">';
715print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
716print "<td>";
717if (isModEnabled('bank')) {
718 $sql = "SELECT rowid, label, clos";
719 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
720 $sql .= " WHERE courant = 1";
721 $sql .= " AND entity IN (".getEntity('bank_account').")";
722 $resql = $db->query($sql);
723 if ($resql) {
724 $num = $db->num_rows($resql);
725 $i = 0;
726 if ($num > 0) {
727 print '<select name="rib" class="flat" id="rib">';
728 print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
729 while ($i < $num) {
730 $obj = $db->fetch_object($resql);
731
732 print '<option value="'.$obj->rowid.'"';
733 print getDolGlobalString('FACTURE_RIB_NUMBER') == $obj->rowid ? ' selected' : '';
734 if (!empty($obj->clos)) {
735 print ' disabled';
736 }
737 print '>'.dol_escape_htmltag($obj->label).'</option>';
738
739 $i++;
740 }
741 print "</select>";
742 print ajax_combobox("rib");
743 } else {
744 print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
745 }
746 }
747} else {
748 print $langs->trans("BankModuleNotActive");
749}
750print "</td></tr>";
751
752$FACTURE_CHQ_NUMBER = getDolGlobalInt('FACTURE_CHQ_NUMBER');
753
754print '<tr class="oddeven">';
755print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
756print "<td>";
757print '<select class="flat" name="chq" id="chq">';
758print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
759print '<option value="-1"'.($FACTURE_CHQ_NUMBER == -1 ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
760
761$sql = "SELECT rowid, label";
762$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
763$sql .= " WHERE clos = 0";
764$sql .= " AND courant = 1";
765$sql .= " AND entity IN (".getEntity('bank_account').")";
766
767$resql = $db->query($sql);
768if ($resql) {
769 $num = $db->num_rows($resql);
770 $i = 0;
771 while ($i < $num) {
772 $row = $db->fetch_row($resql);
773
774 print '<option value="'.$row[0].'"';
775 print $FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
776 print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
777
778 $i++;
779 }
780}
781print "</select>";
782print ajax_combobox("chq", array(), 0, 0, 'resolve', '-2');
783
784print "</td></tr>";
785
786// Structured communication
787// Specific to Belgium - See core/lib/functions_be.lib.php
788if ($mysoc->country_code == 'BE') {
789 print '<tr class="oddeven"><td>' . $langs->trans("InvoicePaymentManageStructuredCommunication") . '&nbsp;';
790 print $form->textwithpicto('', $langs->trans("InvoicePaymentManageStructuredCommunicationHelp"), 1, 'help') . '</td>';
791 print '<td class="left" colspan="2">';
792 print ajax_constantonoff('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION');
793 print '</td></tr>';
794}
795
796print "</table>";
797print '</div>';
798
799print "</form>";
800
801
802print "<br>";
803print load_fiche_titre($langs->trans("OtherOptions"), '', '');
804
805print '<div class="div-table-responsive-no-min">';
806print '<table class="noborder centpercent">';
807print '<tr class="liste_titre">';
808print '<td>'.$langs->trans("Parameters").'</td>';
809print '<td class="center" width="60"></td>';
810print '<td width="80">&nbsp;</td>';
811print "</tr>\n";
812
813// Force date validation
814print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
815print '<input type="hidden" name="token" value="'.newToken().'" />';
816print '<input type="hidden" name="action" value="setforcedate" />';
817print '<input type="hidden" name="page_y" value="" />';
818print '<tr class="oddeven"><td>';
819print $langs->trans("ForceInvoiceDate");
820print '</td><td width="60" class="center">';
821print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1);
822print '</td><td class="right">';
823print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
824print "</td></tr>\n";
825print '</form>';
826
827$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
828$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
829$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
830foreach ($substitutionarray as $key => $val) {
831 $htmltext .= $key.'<br>';
832}
833$htmltext .= '</i>';
834
835print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
836print '<input type="hidden" name="token" value="'.newToken().'" />';
837print '<input type="hidden" name="action" value="set_INVOICE_FREE_TEXT" />';
838print '<input type="hidden" name="page_y" value="" />';
839print '<tr class="oddeven"><td colspan="2">';
840print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
841$variablename = 'INVOICE_FREE_TEXT';
842if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
843 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
844} else {
845 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
846 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
847 print $doleditor->Create();
848}
849print '</td><td class="right">';
850print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
851print "</td></tr>\n";
852print '</form>';
853
854
855print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
856print '<input type="hidden" name="token" value="'.newToken().'" />';
857print '<input type="hidden" name="action" value="set_FACTURE_DRAFT_WATERMARK" />';
858print '<input type="hidden" name="page_y" value="" />';
859print '<tr class="oddeven"><td>';
860print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
861print '</td>';
862print '<td><input class="flat minwidth200imp" type="text" name="FACTURE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('FACTURE_DRAFT_WATERMARK')).'">';
863print '</td><td class="right">';
864print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
865print "</td></tr>\n";
866print '</form>';
867
868
869print '<tr class="oddeven"><td>'.$langs->trans("InvoiceCheckPosteriorDate"). '&nbsp;' ;
870print $form->textwithpicto('', $langs->trans("InvoiceCheckPosteriorDateHelp"), 1, 'help') . '</td>';
871print '<td class="left" colspan="2">';
872print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE');
873print '</td></tr>';
874
875
876// Allow external download
877print '<tr class="oddeven">';
878print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
879print '<td class="left" colspan="2">';
880print ajax_constantonoff('INVOICE_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1);
881print '</td></tr>';
882
883// Consistency of Deposit Invoice
884/* Try to avoid optionflation by not showing options to remove features default features.
885print '<tr class="oddeven">';
886print '<td>'.$langs->trans("LimitDepositInvoicePossibilityForConsistency").'</td>';
887print '<td class="left" colspan="2">';
888print ajax_constantonoff('INVOICE_DEPOSIT_INVOICE_ONLY_SAME_LINES', array(), null, 0, 0, 0, 2, 0, 1);
889print '</td></tr>';
890*/
891
892print '</table>';
893print '</div>';
894
895/*
896 * Repertoire
897 */
898print '<br>';
899print load_fiche_titre($langs->trans("PathToDocuments"), '', '');
900
901print '<div class="div-table-responsive-no-min">';
902print '<table class="noborder centpercent">'."\n";
903print '<tr class="liste_titre">'."\n";
904print '<td>'.$langs->trans("Name").'</td>'."\n";
905print '<td></td>'."\n";
906print "</tr>\n";
907print '<tr class="oddeven">'."\n";
908print '<td width="140">'.$langs->trans("PathDirectory").'</td>'."\n";
909print '<td>'.$conf->facture->dir_output.'</td>'."\n";
910print '</tr>'."\n";
911print "</table>\n";
912print "</div>\n";
913
914/*
915 * Notifications
916 */
917print '<br>';
918print load_fiche_titre($langs->trans("Notifications"), '', '');
919
920print '<div class="div-table-responsive-no-min">';
921print '<table class="noborder centpercent">';
922print '<tr class="liste_titre">';
923print '<td>'.$langs->trans("Parameter").'</td>';
924print '<td class="center" width="60"></td>';
925print '<td width="80">&nbsp;</td>';
926print "</tr>\n";
927print '<tr class="oddeven"><td colspan="2">';
928print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
929print '</td><td class="right">';
930print "</td></tr>\n";
931print '</table>';
932print "</div>\n";
933
934
935print dol_get_fiche_end();
936
937// End of page
938llxFooter();
939$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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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:778
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:161
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.