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