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