dolibarr 19.0.4
facture.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 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
37
38// Load translation files required by the page
39$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
40
41if (!$user->admin) {
43}
44
45$action = GETPOST('action', 'aZ09');
46$value = GETPOST('value', 'alpha');
47$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
48
49$label = GETPOST('label', 'alpha');
50$scandir = GETPOST('scan_dir', 'alpha');
51$type = 'invoice';
52
53$error = 0;
54
55
56/*
57 * Actions
58 */
59
60include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
61
62if ($action == 'updateMask') {
63 $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09');
64 $maskconstreplacement = GETPOST('maskconstreplacement', 'aZ09');
65 $maskconstcredit = GETPOST('maskconstcredit', 'aZ09');
66 $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09');
67 $maskinvoice = GETPOST('maskinvoice', 'alpha');
68 $maskreplacement = GETPOST('maskreplacement', 'alpha');
69 $maskcredit = GETPOST('maskcredit', 'alpha');
70 $maskdeposit = GETPOST('maskdeposit', 'alpha');
71 if ($maskconstinvoice && preg_match('/_MASK_/', $maskconstinvoice)) {
72 $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
73 }
74 if ($maskconstreplacement && preg_match('/_MASK_/', $maskconstreplacement)) {
75 $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
76 }
77 if ($maskconstcredit && preg_match('/_MASK_/', $maskconstcredit)) {
78 $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
79 }
80 if ($maskconstdeposit && preg_match('/_MASK_/', $maskconstdeposit)) {
81 $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
82 }
83
84 if (!($res > 0)) {
85 $error++;
86 }
87
88 if (!$error) {
89 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
90 } else {
91 setEventMessages($langs->trans("Error"), null, 'errors');
92 }
93} elseif ($action == 'specimen') {
94 $modele = GETPOST('module', 'alpha');
95
96 $facture = new Facture($db);
97 $facture->initAsSpecimen();
98
99 // Search template files
100 $file = '';
101 $classname = '';
102 $filefound = 0;
103 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
104 foreach ($dirmodels as $reldir) {
105 $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
106 if (file_exists($file)) {
107 $filefound = 1;
108 $classname = "pdf_".$modele;
109 break;
110 }
111 }
112
113 if ($filefound) {
114 require_once $file;
115
116 $module = new $classname($db);
117
118 if ($module->write_file($facture, $langs) > 0) {
119 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
120 return;
121 } else {
122 setEventMessages($module->error, $module->errors, 'errors');
123 dol_syslog($module->error, LOG_ERR);
124 }
125 } else {
126 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
127 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
128 }
129} elseif ($action == 'set') {
130 // Activate a model
131 $ret = addDocumentModel($value, $type, $label, $scandir);
132} elseif ($action == 'del') {
133 $ret = delDocumentModel($value, $type);
134 if ($ret > 0) {
135 if ($conf->global->FACTURE_ADDON_PDF == "$value") {
136 dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
137 }
138 }
139} elseif ($action == 'setdoc') {
140 // Set default model
141 if (dolibarr_set_const($db, "FACTURE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
142 // La constante qui a ete lue en avant du nouveau set
143 // on passe donc par une variable pour avoir un affichage coherent
144 $conf->global->FACTURE_ADDON_PDF = $value;
145 }
146
147 // On active le modele
148 $ret = delDocumentModel($value, $type);
149 if ($ret > 0) {
150 $ret = addDocumentModel($value, $type, $label, $scandir);
151 }
152} elseif ($action == 'setmod') {
153 // TODO Verifier si module numerotation choisi peut etre active
154 // par appel methode 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 = GETPOST('INVOICE_CHECK_POSTERIOR_DATE', 'int');
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');
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 // Show modules according to features level
337 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
338 continue;
339 }
340 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
341 continue;
342 }
343
344 if ($module->isEnabled()) {
345 print '<tr class="oddeven"><td width="100">';
346 echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
347 print "</td><td>\n";
348
349 print $module->info($langs);
350
351 print '</td>';
352
353 // Show example of numbering module
354 print '<td class="nowrap">';
355 $tmp = $module->getExample();
356 if (preg_match('/^Error/', $tmp)) {
357 $langs->load("errors");
358 print '<div class="error">'.$langs->trans($tmp).'</div>';
359 } elseif ($tmp == 'NotConfigured') {
360 print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
361 } else {
362 print $tmp;
363 }
364 print '</td>'."\n";
365
366 print '<td class="center">';
367 //print "> ".$conf->global->FACTURE_ADDON." - ".$file;
368 if ($conf->global->FACTURE_ADDON == $file || getDolGlobalString('FACTURE_ADDON') . '.php' == $file) {
369 print img_picto($langs->trans("Activated"), 'switch_on');
370 } else {
371 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>';
372 }
373 print '</td>';
374
375 $facture = new Facture($db);
376 $facture->initAsSpecimen();
377
378 // Example for standard invoice
379 $htmltooltip = '';
380 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
381 $facture->type = 0;
382 $nextval = $module->getNextValue($mysoc, $facture);
383 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
384 $htmltooltip .= $langs->trans("NextValueForInvoices").': ';
385 if ($nextval) {
386 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
387 $nextval = $langs->trans($nextval);
388 }
389 $htmltooltip .= $nextval.'<br>';
390 } else {
391 $htmltooltip .= $langs->trans($module->error).'<br>';
392 }
393 }
394 // Example for remplacement
395 $facture->type = 1;
396 $nextval = $module->getNextValue($mysoc, $facture);
397 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
398 $htmltooltip .= $langs->trans("NextValueForReplacements").': ';
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
409 // Example for credit invoice
410 $facture->type = 2;
411 $nextval = $module->getNextValue($mysoc, $facture);
412 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
413 $htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
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 // Example for deposit invoice
424 $facture->type = 3;
425 $nextval = $module->getNextValue($mysoc, $facture);
426 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
427 $htmltooltip .= $langs->trans("NextValueForDeposit").': ';
428 if ($nextval) {
429 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
430 $nextval = $langs->trans($nextval);
431 }
432 $htmltooltip .= $nextval;
433 } else {
434 $htmltooltip .= $langs->trans($module->error);
435 }
436 }
437
438 print '<td class="center">';
439 print $form->textwithpicto('', $htmltooltip, 1, 0);
440
441 if (getDolGlobalString('FACTURE_ADDON') . '.php' == $file) { // If module is the one used, we show existing errors
442 if (!empty($module->error)) {
443 dol_htmloutput_mesg($module->error, '', 'error', 1);
444 }
445 }
446
447 print '</td>';
448
449 print "</tr>\n";
450 }
451 }
452 }
453 }
454 closedir($handle);
455 }
456 }
457}
458
459print '</table>';
460print '</div>';
461
462
463/*
464 * Document templates generators
465 */
466print '<br>';
467print load_fiche_titre($langs->trans("BillsPDFModules"), '', '');
468
469// Load array def with activated templates
470$type = 'invoice';
471$def = array();
472$sql = "SELECT nom";
473$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
474$sql .= " WHERE type = '".$db->escape($type)."'";
475$sql .= " AND entity = ".$conf->entity;
476$resql = $db->query($sql);
477if ($resql) {
478 $i = 0;
479 $num_rows = $db->num_rows($resql);
480 while ($i < $num_rows) {
481 $array = $db->fetch_array($resql);
482 array_push($def, $array[0]);
483 $i++;
484 }
485} else {
486 dol_print_error($db);
487}
488
489print '<div class="div-table-responsive-no-min">';
490print '<table class="noborder centpercent">';
491print '<tr class="liste_titre">';
492print '<td>'.$langs->trans("Name").'</td>';
493print '<td>'.$langs->trans("Description").'</td>';
494print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
495print '<td class="center" width="60">'.$langs->trans("Default").'</td>';
496print '<td class="center" width="32">'.$langs->trans("ShortInfo").'</td>';
497print '<td class="center" width="32">'.$langs->trans("Preview").'</td>';
498print "</tr>\n";
499
500clearstatcache();
501
502$activatedModels = array();
503
504foreach ($dirmodels as $reldir) {
505 foreach (array('', '/doc') as $valdir) {
506 $realpath = $reldir."core/modules/facture".$valdir;
507 $dir = dol_buildpath($realpath);
508
509 if (is_dir($dir)) {
510 $handle = opendir($dir);
511 if (is_resource($handle)) {
512 while (($file = readdir($handle)) !== false) {
513 $filelist[] = $file;
514 }
515 closedir($handle);
516 arsort($filelist);
517
518 foreach ($filelist as $file) {
519 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
520 if (file_exists($dir.'/'.$file)) {
521 $name = substr($file, 4, dol_strlen($file) - 16);
522 $classname = substr($file, 0, dol_strlen($file) - 12);
523
524 require_once $dir.'/'.$file;
525 $module = new $classname($db);
526
527 $modulequalified = 1;
528 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
529 $modulequalified = 0;
530 }
531 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
532 $modulequalified = 0;
533 }
534
535 if ($modulequalified) {
536 print '<tr class="oddeven"><td width="100">';
537 print(empty($module->name) ? $name : $module->name);
538 print "</td><td>\n";
539 if (method_exists($module, 'info')) {
540 print $module->info($langs);
541 } else {
542 print $module->description;
543 }
544 print '</td>';
545
546 // Active
547 if (in_array($name, $def)) {
548 print '<td class="center">'."\n";
549 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
550 print img_picto($langs->trans("Enabled"), 'switch_on');
551 print '</a>';
552 print '</td>';
553 } else {
554 print '<td class="center">'."\n";
555 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>';
556 print "</td>";
557 }
558
559 // Defaut
560 print '<td class="center">';
561 if ($conf->global->FACTURE_ADDON_PDF == "$name") {
562 print img_picto($langs->trans("Default"), 'on');
563 } else {
564 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>';
565 }
566 print '</td>';
567
568 // Info
569 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
570 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
571 if ($module->type == 'pdf') {
572 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
573 }
574 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
575
576 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
577 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
578 $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
579 $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
580 $htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
581 $htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
582 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
583 $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
584
585
586 print '<td class="center">';
587 print $form->textwithpicto('', $htmltooltip, 1, 0);
588 print '</td>';
589
590 // Preview
591 print '<td class="center">';
592 if ($module->type == 'pdf') {
593 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
594 } else {
595 print img_object($langs->trans("PreviewNotAvailable"), 'generic');
596 }
597 print '</td>';
598
599 print "</tr>\n";
600 }
601 }
602 }
603 }
604 }
605 }
606 }
607}
608print '</table>';
609print '</div>';
610
611if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) { // Hidden conf
612 /*
613 * Document templates generators
614 */
615 print '<br>';
616 print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
617
618 print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
619 print '<input type="hidden" name="token" value="'.newToken().'" />';
620 print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
621 print '<input type="hidden" name="page_y" value="" />';
622
623 print '<div class="div-table-responsive-no-min">';
624 print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
625 print '<tr class="liste_titre">';
626 print '<td>'.$langs->trans("Type").'</td>';
627 print '<td>'.$langs->trans("Name").'</td>';
628 print '<td class="right"><input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'"></td>';
629 print "</tr>\n";
630
631 $listtype = array(
632 Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
633 Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
634 Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
635 Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
636 );
637 if (getDolGlobalInt('INVOICE_USE_SITUATION')) {
638 $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
639 }
640
641 foreach ($listtype as $type => $trans) {
642 $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
643 $current = getDolGlobalString($thisTypeConfName, getDolGlobalString('FACTURE_ADDON_PDF'));
644 print '<tr >';
645 print '<td>'.$trans.'</td>';
646 print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
647 print "</tr>\n";
648 }
649
650 print '</table>';
651 print '</div>';
652
653 print "</form>";
654}
655
656/*
657 * Payment modes
658 */
659print '<br>';
660print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice"), '', '');
661
662print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
663print '<input type="hidden" name="token" value="'.newToken().'" />';
664print '<input type="hidden" name="page_y" value="" />';
665
666print '<div class="div-table-responsive-no-min">';
667print '<table class="noborder centpercent">';
668
669print '<tr class="liste_titre">';
670print '<td>';
671print '<input type="hidden" name="action" value="setribchq">';
672print $langs->trans("PaymentMode").'</td>';
673print '<td class="right"><input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'"></td>';
674print "</tr>\n";
675
676print '<tr class="oddeven">';
677print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
678print "<td>";
679if (isModEnabled('banque')) {
680 $sql = "SELECT rowid, label, clos";
681 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
682 $sql .= " WHERE courant = 1";
683 $sql .= " AND entity IN (".getEntity('bank_account').")";
684 $resql = $db->query($sql);
685 if ($resql) {
686 $num = $db->num_rows($resql);
687 $i = 0;
688 if ($num > 0) {
689 print '<select name="rib" class="flat" id="rib">';
690 print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
691 while ($i < $num) {
692 $obj = $db->fetch_object($resql);
693
694 print '<option value="'.$obj->rowid.'"';
695 print getDolGlobalString('FACTURE_RIB_NUMBER') == $obj->rowid ? ' selected' : '';
696 if (!empty($obj->clos)) {
697 print ' disabled';
698 }
699 print '>'.dol_escape_htmltag($obj->label).'</option>';
700
701 $i++;
702 }
703 print "</select>";
704 print ajax_combobox("rib");
705 } else {
706 print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
707 }
708 }
709} else {
710 print $langs->trans("BankModuleNotActive");
711}
712print "</td></tr>";
713
714$FACTURE_CHQ_NUMBER = getDolGlobalInt('FACTURE_CHQ_NUMBER');
715
716print '<tr class="oddeven">';
717print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
718print "<td>";
719print '<select class="flat" name="chq" id="chq">';
720print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
721print '<option value="-1"'.($FACTURE_CHQ_NUMBER == -1 ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
722
723$sql = "SELECT rowid, label";
724$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
725$sql .= " WHERE clos = 0";
726$sql .= " AND courant = 1";
727$sql .= " AND entity IN (".getEntity('bank_account').")";
728
729$resql = $db->query($sql);
730if ($resql) {
731 $num = $db->num_rows($resql);
732 $i = 0;
733 while ($i < $num) {
734 $row = $db->fetch_row($resql);
735
736 print '<option value="'.$row[0].'"';
737 print $FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
738 print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
739
740 $i++;
741 }
742}
743print "</select>";
744print ajax_combobox("chq", array(), 0, 0, 'resolve', -2);
745
746print "</td></tr>";
747print "</table>";
748print '</div>';
749
750print "</form>";
751
752
753print "<br>";
754print load_fiche_titre($langs->trans("OtherOptions"), '', '');
755
756print '<div class="div-table-responsive-no-min">';
757print '<table class="noborder centpercent">';
758print '<tr class="liste_titre">';
759print '<td>'.$langs->trans("Parameters").'</td>';
760print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
761print '<td width="80">&nbsp;</td>';
762print "</tr>\n";
763
764// Force date validation
765print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
766print '<input type="hidden" name="token" value="'.newToken().'" />';
767print '<input type="hidden" name="action" value="setforcedate" />';
768print '<input type="hidden" name="page_y" value="" />';
769print '<tr class="oddeven"><td>';
770print $langs->trans("ForceInvoiceDate");
771print '</td><td width="60" class="center">';
772print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1);
773print '</td><td class="right">';
774print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
775print "</td></tr>\n";
776print '</form>';
777
778$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
779$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
780$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
781foreach ($substitutionarray as $key => $val) {
782 $htmltext .= $key.'<br>';
783}
784$htmltext .= '</i>';
785
786print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
787print '<input type="hidden" name="token" value="'.newToken().'" />';
788print '<input type="hidden" name="action" value="set_INVOICE_FREE_TEXT" />';
789print '<input type="hidden" name="page_y" value="" />';
790print '<tr class="oddeven"><td colspan="2">';
791print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
792$variablename = 'INVOICE_FREE_TEXT';
793if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
794 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
795} else {
796 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
797 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
798 print $doleditor->Create();
799}
800print '</td><td class="right">';
801print '<input type="submit" class="button button-edit reposition" value="'.$langs->trans("Modify").'" />';
802print "</td></tr>\n";
803print '</form>';
804
805
806print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
807print '<input type="hidden" name="token" value="'.newToken().'" />';
808print '<input type="hidden" name="action" value="set_FACTURE_DRAFT_WATERMARK" />';
809print '<input type="hidden" name="page_y" value="" />';
810print '<tr class="oddeven"><td>';
811print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
812print '</td>';
813print '<td><input class="flat minwidth200imp" type="text" name="FACTURE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('FACTURE_DRAFT_WATERMARK')).'">';
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 '<tr class="oddeven"><td>'.$langs->trans("InvoiceCheckPosteriorDate"). '&nbsp;' ;
821print $form->textwithpicto('', $langs->trans("InvoiceCheckPosteriorDateHelp"), 1, 'help') . '</td>';
822print '<td class="left" colspan="2">';
823print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE');
824print '</td></tr>';
825
826// Allow external download
827print '<tr class="oddeven">';
828print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
829print '<td class="left" colspan="2">';
830print ajax_constantonoff('INVOICE_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1);
831print '</td></tr>';
832
833print '</table>';
834print '</div>';
835
836/*
837 * Repertoire
838 */
839print '<br>';
840print load_fiche_titre($langs->trans("PathToDocuments"), '', '');
841
842print '<div class="div-table-responsive-no-min">';
843print '<table class="noborder centpercent">'."\n";
844print '<tr class="liste_titre">'."\n";
845print '<td>'.$langs->trans("Name").'</td>'."\n";
846print '<td>'.$langs->trans("Value").'</td>'."\n";
847print "</tr>\n";
848print '<tr class="oddeven">'."\n";
849print '<td width="140">'.$langs->trans("PathDirectory").'</td>'."\n";
850print '<td>'.$conf->facture->dir_output.'</td>'."\n";
851print '</tr>'."\n";
852print "</table>\n";
853print "</div>\n";
854
855/*
856 * Notifications
857 */
858print '<br>';
859print load_fiche_titre($langs->trans("Notifications"), '', '');
860
861print '<div class="div-table-responsive-no-min">';
862print '<table class="noborder centpercent">';
863print '<tr class="liste_titre">';
864print '<td>'.$langs->trans("Parameter").'</td>';
865print '<td class="center" width="60"></td>';
866print '<td width="80">&nbsp;</td>';
867print "</tr>\n";
868print '<tr class="oddeven"><td colspan="2">';
869print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
870print '</td><td class="right">';
871print "</td></tr>\n";
872print '</table>';
873print "</div>\n";
874
875
876print dol_get_fiche_end();
877
878// End of page
879llxFooter();
880$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:455
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage a WYSIWYG editor.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage generation of HTML components Only common components must be here.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 formated messages to output (Used to show messages on html output).
getDolGlobalString($key, $default='')
Return 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 informations.
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:762
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.