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