dolibarr 21.0.0-beta
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 preg_match('/\-(.*)_(.*)$/', $classname, $reg);
336 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
337 continue;
338 }
339
340 $classname = preg_replace('/\-.*$/', '', $classname);
341 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
342 // Charging the numbering class
343 require_once $dir.$filebis;
344
345 $module = new $classname($db);
346
347 '@phan-var-force ModeleNumRefFactures $module';
348
349 // Show modules according to features level
350 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
351 continue;
352 }
353 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
354 continue;
355 }
356
357 if ($module->isEnabled()) {
358 print '<tr class="oddeven"><td width="100">';
359 echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
360 print "</td><td>\n";
361
362 print $module->info($langs);
363
364 print '</td>';
365
366 // Show example of numbering module
367 print '<td class="nowrap">';
368 $tmp = $module->getExample();
369 if (preg_match('/^Error/', $tmp)) {
370 $langs->load("errors");
371 print '<div class="error">'.$langs->trans($tmp).'</div>';
372 } elseif ($tmp == 'NotConfigured') {
373 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
374 } else {
375 print $tmp;
376 }
377 print '</td>'."\n";
378
379 print '<td class="center">';
380 //print "> ".$conf->global->FACTURE_ADDON." - ".$file;
381 if ($conf->global->FACTURE_ADDON == $file || getDolGlobalString('FACTURE_ADDON') . '.php' == $file) {
382 print img_picto($langs->trans("Activated"), 'switch_on');
383 } else {
384 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>';
385 }
386 print '</td>';
387
388 $facture = new Facture($db);
389 $facture->initAsSpecimen();
390
391 $htmltooltip = '';
392
393 // Example for standard invoice
394 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
395 $facture->type = 0;
396 $nextval = $module->getNextValue($mysoc, $facture);
397 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
398 $htmltooltip .= $langs->trans("NextValueForInvoices").': ';
399 if ($nextval) {
400 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
401 $nextval = $langs->trans($nextval);
402 }
403 $htmltooltip .= $nextval.'<br>';
404 } else {
405 $htmltooltip .= $langs->trans($module->error).'<br>';
406 }
407 }
408 // Example for replacement invoice
409 if (!getDolGlobalString('INVOICE_DISABLE_REPLACEMENT')) {
410 $facture->type = 1;
411 $nextval = $module->getNextValue($mysoc, $facture);
412 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
413 $htmltooltip .= $langs->trans("NextValueForReplacements").': ';
414 if ($nextval) {
415 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
416 $nextval = $langs->trans($nextval);
417 }
418 $htmltooltip .= $nextval.'<br>';
419 } else {
420 $htmltooltip .= $langs->trans($module->error).'<br>';
421 }
422 }
423 }
424 // Example for credit invoice
425 $facture->type = 2;
426 $nextval = $module->getNextValue($mysoc, $facture);
427 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
428 $htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
429 if ($nextval) {
430 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
431 $nextval = $langs->trans($nextval);
432 }
433 $htmltooltip .= $nextval.'<br>';
434 } else {
435 $htmltooltip .= $langs->trans($module->error).'<br>';
436 }
437 }
438 // Example for deposit invoice
439 $facture->type = 3;
440 $nextval = $module->getNextValue($mysoc, $facture);
441 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
442 $htmltooltip .= $langs->trans("NextValueForDeposit").': ';
443 if ($nextval) {
444 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
445 $nextval = $langs->trans($nextval);
446 }
447 $htmltooltip .= $nextval;
448 } else {
449 $htmltooltip .= $langs->trans($module->error);
450 }
451 }
452
453 print '<td class="center">';
454 print $form->textwithpicto('', $htmltooltip, 1, 0);
455
456 if (getDolGlobalString('FACTURE_ADDON') . '.php' == $file) { // If module is the one used, we show existing errors
457 if (!empty($module->error)) {
458 dol_htmloutput_mesg($module->error, array(), 'error', 1);
459 }
460 }
461
462 print '</td>';
463
464 print "</tr>\n";
465 }
466 }
467 }
468 }
469 closedir($handle);
470 }
471 }
472}
473
474print '</table>';
475print '</div>';
476
477
478/*
479 * Document templates generators
480 */
481
482print '<br>';
483print load_fiche_titre($langs->trans("BillsPDFModules"), '', '');
484
485// Load array def with activated templates
486$type = 'invoice';
487$def = array();
488$sql = "SELECT nom";
489$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
490$sql .= " WHERE type = '".$db->escape($type)."'";
491$sql .= " AND entity = ".$conf->entity;
492$resql = $db->query($sql);
493if ($resql) {
494 $i = 0;
495 $num_rows = $db->num_rows($resql);
496 while ($i < $num_rows) {
497 $array = $db->fetch_array($resql);
498 if (is_array($array)) {
499 array_push($def, $array[0]);
500 }
501 $i++;
502 }
503} else {
504 dol_print_error($db);
505}
506
507print '<div class="div-table-responsive-no-min">';
508print '<table class="noborder centpercent">';
509print '<tr class="liste_titre">';
510print '<td>'.$langs->trans("Name").'</td>';
511print '<td>'.$langs->trans("Description").'</td>';
512print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
513print '<td class="center" width="60">'.$langs->trans("Default").'</td>';
514print '<td class="center" width="32">'.$langs->trans("ShortInfo").'</td>';
515print '<td class="center" width="32">'.$langs->trans("Preview").'</td>';
516print "</tr>\n";
517
518clearstatcache();
519
520$activatedModels = array();
521
522foreach ($dirmodels as $reldir) {
523 foreach (array('', '/doc') as $valdir) {
524 $realpath = $reldir."core/modules/facture".$valdir;
525 $dir = dol_buildpath($realpath);
526
527 if (is_dir($dir)) {
528 $handle = opendir($dir);
529 if (is_resource($handle)) {
530 $filelist = array();
531 while (($file = readdir($handle)) !== false) {
532 $filelist[] = $file;
533 }
534 closedir($handle);
535 arsort($filelist);
536
537 foreach ($filelist as $file) {
538 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
539 if (file_exists($dir.'/'.$file)) {
540 $name = substr($file, 4, dol_strlen($file) - 16);
541 $classname = substr($file, 0, dol_strlen($file) - 12);
542
543 require_once $dir.'/'.$file;
544 $module = new $classname($db);
545
546 '@phan-var-force ModelePDFFactures $module';
547
548 $modulequalified = 1;
549 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
550 $modulequalified = 0;
551 }
552 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
553 $modulequalified = 0;
554 }
555 if ($module->version == 'disabled') {
556 $modulequalified = 0;
557 }
558
559 if ($modulequalified) {
560 print '<tr class="oddeven"><td width="100">';
561 print(empty($module->name) ? $name : $module->name);
562 print "</td><td>\n";
563 if (method_exists($module, 'info')) {
564 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
565 } else {
566 print $module->description;
567 }
568 print '</td>';
569
570 // Active
571 if (in_array($name, $def)) {
572 print '<td class="center">'."\n";
573 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
574 print img_picto($langs->trans("Enabled"), 'switch_on');
575 print '</a>';
576 print '</td>';
577 } else {
578 print '<td class="center">'."\n";
579 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>';
580 print "</td>";
581 }
582
583 // Default
584 print '<td class="center">';
585 if (getDolGlobalString('FACTURE_ADDON_PDF') == (string) $name) {
586 print img_picto($langs->trans("Default"), 'on');
587 } else {
588 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>';
589 }
590 print '</td>';
591
592 // Info
593 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
594 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
595 if ($module->type == 'pdf') {
596 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
597 }
598 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
599
600 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
601 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
602 $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
603 $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
604 $htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
605 $htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
606 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
607 $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
608
609
610 print '<td class="center">';
611 print $form->textwithpicto('', $htmltooltip, 1, 0);
612 print '</td>';
613
614 // Preview
615 print '<td class="center">';
616 if ($module->type == 'pdf') {
617 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
618 } else {
619 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
620 }
621 print '</td>';
622
623 print "</tr>\n";
624 }
625 }
626 }
627 }
628 }
629 }
630 }
631}
632print '</table>';
633print '</div>';
634
635if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) { // Hidden conf
636 /*
637 * Document templates generators
638 */
639 print '<br>';
640 print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
641
642 print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
643 print '<input type="hidden" name="token" value="'.newToken().'" />';
644 print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
645 print '<input type="hidden" name="page_y" value="" />';
646
647 print '<div class="div-table-responsive-no-min">';
648 print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
649 print '<tr class="liste_titre">';
650 print '<td>'.$langs->trans("Type").'</td>';
651 print '<td>'.$langs->trans("Name").'</td>';
652 print '<td class="right"><input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'"></td>';
653 print "</tr>\n";
654
655 $listtype = array(
656 Facture::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
657 Facture::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
658 Facture::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
659 Facture::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
660 );
661 if (getDolGlobalInt('INVOICE_USE_SITUATION')) {
662 $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
663 }
664
665 foreach ($listtype as $type => $trans) {
666 $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
667 $current = getDolGlobalString($thisTypeConfName, getDolGlobalString('FACTURE_ADDON_PDF'));
668 print '<tr >';
669 print '<td>'.$trans.'</td>';
670 print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
671 print "</tr>\n";
672 }
673
674 print '</table>';
675 print '</div>';
676
677 print "</form>";
678}
679
680/*
681 * Payment modes
682 */
683print '<br>';
684print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice"), '', '');
685
686print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
687print '<input type="hidden" name="token" value="'.newToken().'" />';
688print '<input type="hidden" name="page_y" value="" />';
689
690print '<div class="div-table-responsive-no-min">';
691print '<table class="noborder centpercent">';
692
693print '<tr class="liste_titre">';
694print '<td>';
695print '<input type="hidden" name="action" value="setribchq">';
696print $langs->trans("PaymentMode").'</td>';
697print '<td class="right"><input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'"></td>';
698print "</tr>\n";
699
700print '<tr class="oddeven">';
701print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
702print "<td>";
703if (isModEnabled('bank')) {
704 $sql = "SELECT rowid, label, clos";
705 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
706 $sql .= " WHERE courant = 1";
707 $sql .= " AND entity IN (".getEntity('bank_account').")";
708 $resql = $db->query($sql);
709 if ($resql) {
710 $num = $db->num_rows($resql);
711 $i = 0;
712 if ($num > 0) {
713 print '<select name="rib" class="flat" id="rib">';
714 print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
715 while ($i < $num) {
716 $obj = $db->fetch_object($resql);
717
718 print '<option value="'.$obj->rowid.'"';
719 print getDolGlobalString('FACTURE_RIB_NUMBER') == $obj->rowid ? ' selected' : '';
720 if (!empty($obj->clos)) {
721 print ' disabled';
722 }
723 print '>'.dol_escape_htmltag($obj->label).'</option>';
724
725 $i++;
726 }
727 print "</select>";
728 print ajax_combobox("rib");
729 } else {
730 print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
731 }
732 }
733} else {
734 print $langs->trans("BankModuleNotActive");
735}
736print "</td></tr>";
737
738$FACTURE_CHQ_NUMBER = getDolGlobalInt('FACTURE_CHQ_NUMBER');
739
740print '<tr class="oddeven">';
741print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
742print "<td>";
743print '<select class="flat" name="chq" id="chq">';
744print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
745print '<option value="-1"'.($FACTURE_CHQ_NUMBER == -1 ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
746
747$sql = "SELECT rowid, label";
748$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
749$sql .= " WHERE clos = 0";
750$sql .= " AND courant = 1";
751$sql .= " AND entity IN (".getEntity('bank_account').")";
752
753$resql = $db->query($sql);
754if ($resql) {
755 $num = $db->num_rows($resql);
756 $i = 0;
757 while ($i < $num) {
758 $row = $db->fetch_row($resql);
759
760 print '<option value="'.$row[0].'"';
761 print $FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
762 print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
763
764 $i++;
765 }
766}
767print "</select>";
768print ajax_combobox("chq", array(), 0, 0, 'resolve', '-2');
769
770print "</td></tr>";
771
772// Structured communication
773// Specific to Belgium - See core/lib/functions_be.lib.php
774if ($mysoc->country_code == 'BE') {
775 print '<tr class="oddeven"><td>' . $langs->trans("InvoicePaymentManageStructuredCommunication") . '&nbsp;';
776 print $form->textwithpicto('', $langs->trans("InvoicePaymentManageStructuredCommunicationHelp"), 1, 'help') . '</td>';
777 print '<td class="left" colspan="2">';
778 print ajax_constantonoff('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION');
779 print '</td></tr>';
780}
781
782print "</table>";
783print '</div>';
784
785print "</form>";
786
787
788print "<br>";
789print load_fiche_titre($langs->trans("OtherOptions"), '', '');
790
791print '<div class="div-table-responsive-no-min">';
792print '<table class="noborder centpercent">';
793print '<tr class="liste_titre">';
794print '<td>'.$langs->trans("Parameters").'</td>';
795print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
796print '<td width="80">&nbsp;</td>';
797print "</tr>\n";
798
799// Force date validation
800print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
801print '<input type="hidden" name="token" value="'.newToken().'" />';
802print '<input type="hidden" name="action" value="setforcedate" />';
803print '<input type="hidden" name="page_y" value="" />';
804print '<tr class="oddeven"><td>';
805print $langs->trans("ForceInvoiceDate");
806print '</td><td width="60" class="center">';
807print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1);
808print '</td><td class="right">';
809print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
810print "</td></tr>\n";
811print '</form>';
812
813$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
814$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
815$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
816foreach ($substitutionarray as $key => $val) {
817 $htmltext .= $key.'<br>';
818}
819$htmltext .= '</i>';
820
821print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
822print '<input type="hidden" name="token" value="'.newToken().'" />';
823print '<input type="hidden" name="action" value="set_INVOICE_FREE_TEXT" />';
824print '<input type="hidden" name="page_y" value="" />';
825print '<tr class="oddeven"><td colspan="2">';
826print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
827$variablename = 'INVOICE_FREE_TEXT';
828if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
829 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
830} else {
831 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
832 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
833 print $doleditor->Create();
834}
835print '</td><td class="right">';
836print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
837print "</td></tr>\n";
838print '</form>';
839
840
841print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
842print '<input type="hidden" name="token" value="'.newToken().'" />';
843print '<input type="hidden" name="action" value="set_FACTURE_DRAFT_WATERMARK" />';
844print '<input type="hidden" name="page_y" value="" />';
845print '<tr class="oddeven"><td>';
846print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
847print '</td>';
848print '<td><input class="flat minwidth200imp" type="text" name="FACTURE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('FACTURE_DRAFT_WATERMARK')).'">';
849print '</td><td class="right">';
850print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
851print "</td></tr>\n";
852print '</form>';
853
854
855print '<tr class="oddeven"><td>'.$langs->trans("InvoiceCheckPosteriorDate"). '&nbsp;' ;
856print $form->textwithpicto('', $langs->trans("InvoiceCheckPosteriorDateHelp"), 1, 'help') . '</td>';
857print '<td class="left" colspan="2">';
858print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE');
859print '</td></tr>';
860
861
862// Allow external download
863print '<tr class="oddeven">';
864print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
865print '<td class="left" colspan="2">';
866print ajax_constantonoff('INVOICE_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1);
867print '</td></tr>';
868
869print '</table>';
870print '</div>';
871
872/*
873 * Repertoire
874 */
875print '<br>';
876print load_fiche_titre($langs->trans("PathToDocuments"), '', '');
877
878print '<div class="div-table-responsive-no-min">';
879print '<table class="noborder centpercent">'."\n";
880print '<tr class="liste_titre">'."\n";
881print '<td>'.$langs->trans("Name").'</td>'."\n";
882print '<td>'.$langs->trans("Value").'</td>'."\n";
883print "</tr>\n";
884print '<tr class="oddeven">'."\n";
885print '<td width="140">'.$langs->trans("PathDirectory").'</td>'."\n";
886print '<td>'.$conf->facture->dir_output.'</td>'."\n";
887print '</tr>'."\n";
888print "</table>\n";
889print "</div>\n";
890
891/*
892 * Notifications
893 */
894print '<br>';
895print load_fiche_titre($langs->trans("Notifications"), '', '');
896
897print '<div class="div-table-responsive-no-min">';
898print '<table class="noborder centpercent">';
899print '<tr class="liste_titre">';
900print '<td>'.$langs->trans("Parameter").'</td>';
901print '<td class="center" width="60"></td>';
902print '<td width="80">&nbsp;</td>';
903print "</tr>\n";
904print '<tr class="oddeven"><td colspan="2">';
905print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
906print '</td><td class="right">';
907print "</td></tr>\n";
908print '</table>';
909print "</div>\n";
910
911
912print dol_get_fiche_end();
913
914// End of page
915llxFooter();
916$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
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.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
invoice_admin_prepare_head()
Return array head with list of tabs to view object information.
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:765
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:152
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.