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