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