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