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