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