PageRenderTime 52ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/admin/facture.php

https://github.com/asterix14/dolibarr
PHP | 769 lines | 589 code | 118 blank | 62 comment | 116 complexity | d2366bc72d1bafcb46e3aa2693f9257a MD5 | raw file
Possible License(s): LGPL-2.0
  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-2011 Regis Houssin <regis@dolibarr.fr>
  6. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/admin/facture.php
  23. * \ingroup facture
  24. * \brief Page to setup invoice module
  25. */
  26. require("../main.inc.php");
  27. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  28. require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php');
  29. $langs->load("admin");
  30. $langs->load("errors");
  31. if (! $user->admin) accessforbidden();
  32. $action = GETPOST("action");
  33. $value = GETPOST("value");
  34. /*
  35. * Actions
  36. */
  37. if ($action == 'updateMask')
  38. {
  39. $maskconstinvoice=GETPOST("maskconstinvoice");
  40. $maskconstcredit=GETPOST("maskconstcredit");
  41. $maskinvoice=GETPOST("maskinvoice");
  42. $maskcredit=GETPOST("maskcredit");
  43. if ($maskconstinvoice) $res = dolibarr_set_const($db,$maskconstinvoice,$maskinvoice,'chaine',0,'',$conf->entity);
  44. if ($maskconstcredit) $res = dolibarr_set_const($db,$maskconstcredit,$maskcredit,'chaine',0,'',$conf->entity);
  45. if (! $res > 0) $error++;
  46. if (! $error)
  47. {
  48. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  49. }
  50. else
  51. {
  52. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  53. }
  54. }
  55. if ($action == 'specimen')
  56. {
  57. $modele=GETPOST("module");
  58. $facture = new Facture($db);
  59. $facture->initAsSpecimen();
  60. // Load template
  61. $dir = DOL_DOCUMENT_ROOT . "/core/modules/facture/doc/";
  62. $file = "pdf_".$modele.".modules.php";
  63. if (file_exists($dir.$file))
  64. {
  65. $classname = "pdf_".$modele;
  66. require_once($dir.$file);
  67. $obj = new $classname($db);
  68. if ($obj->write_file($facture,$langs) > 0)
  69. {
  70. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
  71. return;
  72. }
  73. else
  74. {
  75. $mesg='<font class="error">'.$obj->error.'</font>';
  76. dol_syslog($obj->error, LOG_ERR);
  77. }
  78. }
  79. else
  80. {
  81. $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
  82. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  83. }
  84. }
  85. // define constants for models generator that need parameters
  86. if ($action == 'setModuleOptions')
  87. {
  88. $post_size=count($_POST);
  89. for($i=0;$i < $post_size;$i++)
  90. {
  91. if (array_key_exists('param'.$i,$_POST))
  92. {
  93. $param=$_POST["param".$i];
  94. $value=$_POST["value".$i];
  95. if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
  96. }
  97. }
  98. if (! $res > 0) $error++;
  99. if (! $error)
  100. {
  101. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  102. }
  103. else
  104. {
  105. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  106. }
  107. }
  108. if ($action == 'set')
  109. {
  110. $label = GETPOST("label");
  111. $scandir = GETPOST("scandir");
  112. $type='invoice';
  113. $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
  114. $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
  115. $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
  116. $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
  117. $sql.= ")";
  118. if ($db->query($sql))
  119. {
  120. }
  121. }
  122. if ($action == 'del')
  123. {
  124. $type='invoice';
  125. $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
  126. $sql.= " WHERE nom = '".$db->escape($value)."'";
  127. $sql.= " AND type = '".$type."'";
  128. $sql.= " AND entity = ".$conf->entity;
  129. if ($db->query($sql))
  130. {
  131. if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF',$conf->entity);
  132. }
  133. }
  134. if ($action == 'setdoc')
  135. {
  136. $label = GETPOST("label");
  137. $scandir = GETPOST("scandir");
  138. $db->begin();
  139. if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
  140. {
  141. $conf->global->FACTURE_ADDON_PDF = $value;
  142. }
  143. // On active le modele
  144. $type='invoice';
  145. $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
  146. $sql_del.= " WHERE nom = '".$db->escape($value)."'";
  147. $sql_del.= " AND type = '".$type."'";
  148. $sql_del.= " AND entity = ".$conf->entity;
  149. dol_syslog("facture.php ".$sql_del);
  150. $result1=$db->query($sql_del);
  151. $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
  152. $sql.= " VALUES ('".$value."', '".$type."', ".$conf->entity.", ";
  153. $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
  154. $sql.= (! empty($scandir)?"'".$scandir."'":"null");
  155. $sql.= ")";
  156. dol_syslog("facture.php ".$sql);
  157. $result2=$db->query($sql);
  158. if ($result1 && $result2)
  159. {
  160. $db->commit();
  161. }
  162. else
  163. {
  164. dol_syslog("facture.php ".$db->lasterror(), LOG_ERR);
  165. $db->rollback();
  166. }
  167. }
  168. if ($action == 'setmod')
  169. {
  170. // TODO Verifier si module numerotation choisi peut etre active
  171. // par appel methode canBeActivated
  172. dolibarr_set_const($db, "FACTURE_ADDON",$value,'chaine',0,'',$conf->entity);
  173. }
  174. if ($action == 'setribchq')
  175. {
  176. $rib = GETPOST("rib");
  177. $chq = GETPOST("chq");
  178. $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$rib,'chaine',0,'',$conf->entity);
  179. $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$chq,'chaine',0,'',$conf->entity);
  180. if (! $res > 0) $error++;
  181. if (! $error)
  182. {
  183. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  184. }
  185. else
  186. {
  187. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  188. }
  189. }
  190. if ($action == 'set_FACTURE_DRAFT_WATERMARK')
  191. {
  192. $draft = GETPOST("FACTURE_DRAFT_WATERMARK");
  193. $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
  194. if (! $res > 0) $error++;
  195. if (! $error)
  196. {
  197. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  198. }
  199. else
  200. {
  201. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  202. }
  203. }
  204. if ($action == 'set_FACTURE_FREE_TEXT')
  205. {
  206. $free = GETPOST("FACTURE_FREE_TEXT");
  207. $res = dolibarr_set_const($db, "FACTURE_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
  208. if (! $res > 0) $error++;
  209. if (! $error)
  210. {
  211. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  212. }
  213. else
  214. {
  215. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  216. }
  217. }
  218. if ($action == 'setforcedate')
  219. {
  220. $forcedate = GETPOST("forcedate");
  221. $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION",$forcedate,'chaine',0,'',$conf->entity);
  222. if (! $res > 0) $error++;
  223. if (! $error)
  224. {
  225. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  226. }
  227. else
  228. {
  229. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  230. }
  231. }
  232. /*
  233. * View
  234. */
  235. llxHeader("",$langs->trans("BillsSetup"),'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura');
  236. $form=new Form($db);
  237. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  238. print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup');
  239. print '<br>';
  240. /*
  241. * Numbering module
  242. */
  243. print_titre($langs->trans("BillsNumberingModule"));
  244. print '<table class="noborder" width="100%">';
  245. print '<tr class="liste_titre">';
  246. print '<td>'.$langs->trans("Name").'</td>';
  247. print '<td>'.$langs->trans("Description").'</td>';
  248. print '<td nowrap>'.$langs->trans("Example").'</td>';
  249. print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
  250. print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
  251. print '</tr>'."\n";
  252. clearstatcache();
  253. $var=true;
  254. foreach ($conf->file->dol_document_root as $dirroot)
  255. {
  256. $dir = $dirroot . "/core/modules/facture/";
  257. if (is_dir($dir))
  258. {
  259. $handle = opendir($dir);
  260. if (is_resource($handle))
  261. {
  262. while (($file = readdir($handle))!==false)
  263. {
  264. if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
  265. {
  266. $filebis = $file;
  267. $classname = preg_replace('/\.php$/','',$file);
  268. // For compatibility
  269. if (! is_file($dir.$filebis))
  270. {
  271. $filebis = $file."/".$file.".modules.php";
  272. $classname = "mod_facture_".$file;
  273. }
  274. if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
  275. {
  276. // Chargement de la classe de numerotation
  277. require_once($dir.$filebis);
  278. $module = new $classname($db);
  279. // Show modules according to features level
  280. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
  281. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
  282. if ($module->isEnabled())
  283. {
  284. $var = !$var;
  285. print '<tr '.$bc[$var].'><td width="100">';
  286. echo preg_replace('/mod_facture_/','',preg_replace('/\.php$/','',$file));
  287. print "</td><td>\n";
  288. print $module->info();
  289. print '</td>';
  290. // Show example of numbering module
  291. print '<td nowrap="nowrap">';
  292. $tmp=$module->getExample();
  293. if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
  294. elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
  295. else print $tmp;
  296. print '</td>'."\n";
  297. print '<td align="center">';
  298. //print "> ".$conf->global->FACTURE_ADDON." - ".$file;
  299. if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file)
  300. {
  301. print img_picto($langs->trans("Activated"),'switch_on');
  302. }
  303. else
  304. {
  305. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.preg_replace('/\.php$/','',$file).'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
  306. }
  307. print '</td>';
  308. $facture=new Facture($db);
  309. $facture->initAsSpecimen();
  310. // Example for standard invoice
  311. $htmltooltip='';
  312. $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  313. $facture->type=0;
  314. $nextval=$module->getNextValue($mysoc,$facture);
  315. if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
  316. {
  317. $htmltooltip.=$langs->trans("NextValueForInvoices").': ';
  318. if ($nextval)
  319. {
  320. $htmltooltip.=$nextval.'<br>';
  321. }
  322. else
  323. {
  324. $htmltooltip.=$langs->trans($module->error).'<br>';
  325. }
  326. }
  327. // Example for credit invoice
  328. $facture->type=2;
  329. $nextval=$module->getNextValue($mysoc,$facture);
  330. if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
  331. {
  332. $htmltooltip.=$langs->trans("NextValueForCreditNotes").': ';
  333. if ($nextval)
  334. {
  335. $htmltooltip.=$nextval;
  336. }
  337. else
  338. {
  339. $htmltooltip.=$langs->trans($module->error);
  340. }
  341. }
  342. print '<td align="center">';
  343. print $form->textwithpicto('',$htmltooltip,1,0);
  344. if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors
  345. {
  346. if (! empty($module->error)) dol_htmloutput_mesg($module->error,'','error',1);
  347. }
  348. print '</td>';
  349. print "</tr>\n";
  350. }
  351. }
  352. }
  353. }
  354. closedir($handle);
  355. }
  356. }
  357. }
  358. print '</table>';
  359. /*
  360. * Document templates generators
  361. */
  362. print '<br>';
  363. print_titre($langs->trans("BillsPDFModules"));
  364. // Load array def with activated templates
  365. $def = array();
  366. $sql = "SELECT nom";
  367. $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
  368. $sql.= " WHERE type = 'invoice'";
  369. $sql.= " AND entity = ".$conf->entity;
  370. $resql=$db->query($sql);
  371. if ($resql)
  372. {
  373. $i = 0;
  374. $num_rows=$db->num_rows($resql);
  375. while ($i < $num_rows)
  376. {
  377. $array = $db->fetch_array($resql);
  378. array_push($def, $array[0]);
  379. $i++;
  380. }
  381. }
  382. else
  383. {
  384. dol_print_error($db);
  385. }
  386. print '<table class="noborder" width="100%">';
  387. print '<tr class="liste_titre">';
  388. print '<td>'.$langs->trans("Name").'</td>';
  389. print '<td>'.$langs->trans("Description").'</td>';
  390. print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
  391. print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
  392. print '<td align="center" width="32" colspan="2">'.$langs->trans("Infos").'</td>';
  393. print "</tr>\n";
  394. clearstatcache();
  395. $var=true;
  396. foreach ($conf->file->dol_document_root as $dirroot)
  397. {
  398. foreach (array('','/doc') as $valdir)
  399. {
  400. $dir = $dirroot . "/core/modules/facture".$valdir;
  401. if (is_dir($dir))
  402. {
  403. $handle=opendir($dir);
  404. if (is_resource($handle))
  405. {
  406. while (($file = readdir($handle))!==false)
  407. {
  408. $filelist[]=$file;
  409. }
  410. closedir($handle);
  411. foreach($filelist as $file)
  412. {
  413. if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
  414. {
  415. if (file_exists($dir.'/'.$file))
  416. {
  417. $name = substr($file, 4, dol_strlen($file) -16);
  418. $classname = substr($file, 0, dol_strlen($file) -12);
  419. require_once($dir.'/'.$file);
  420. $module = new $classname($db);
  421. $modulequalified=1;
  422. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
  423. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
  424. if ($modulequalified)
  425. {
  426. $var = !$var;
  427. print '<tr '.$bc[$var].'><td width="100">';
  428. print (empty($module->name)?$name:$module->name);
  429. print "</td><td>\n";
  430. if (method_exists($module,'info')) print $module->info($langs);
  431. else print $module->description;
  432. print '</td>';
  433. // Active
  434. if (in_array($name, $def))
  435. {
  436. print '<td align="center">'."\n";
  437. print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'">';
  438. print img_picto($langs->trans("Enabled"),'switch_on');
  439. print '</a>';
  440. print '</td>';
  441. }
  442. else
  443. {
  444. print "<td align=\"center\">\n";
  445. print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
  446. print "</td>";
  447. }
  448. // Defaut
  449. print "<td align=\"center\">";
  450. if ($conf->global->FACTURE_ADDON_PDF == "$name")
  451. {
  452. print img_picto($langs->trans("Default"),'on');
  453. }
  454. else
  455. {
  456. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
  457. }
  458. print '</td>';
  459. // Info
  460. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  461. $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
  462. if ($module->type == 'pdf')
  463. {
  464. $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  465. }
  466. $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  467. $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
  468. $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
  469. $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
  470. $htmltooltip.='<br>'.$langs->trans("Escompte").': '.yn($module->option_escompte,1,1);
  471. $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
  472. $htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
  473. $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark,1,1);
  474. print '<td align="center">';
  475. print $form->textwithpicto('',$htmltooltip,1,0);
  476. print '</td>';
  477. // Preview
  478. print '<td align="center">';
  479. if ($module->type == 'pdf')
  480. {
  481. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
  482. }
  483. else
  484. {
  485. print img_object($langs->trans("PreviewNotAvailable"),'generic');
  486. }
  487. print '</td>';
  488. print "</tr>\n";
  489. }
  490. }
  491. }
  492. }
  493. }
  494. }
  495. }
  496. }
  497. print '</table>';
  498. /*
  499. * Modes de reglement
  500. *
  501. */
  502. print '<br>';
  503. print_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice"));
  504. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  505. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
  506. print '<table class="noborder" width="100%">';
  507. $var=True;
  508. print '<tr class="liste_titre">';
  509. print '<td>';
  510. print '<input type="hidden" name="action" value="setribchq">';
  511. print $langs->trans("PaymentMode").'</td>';
  512. print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
  513. print "</tr>\n";
  514. $var=!$var;
  515. print '<tr '.$bc[$var].'>';
  516. print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
  517. print "<td>";
  518. if ($conf->banque->enabled)
  519. {
  520. $sql = "SELECT rowid, label";
  521. $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
  522. $sql.= " WHERE clos = 0";
  523. $sql.= " AND courant = 1";
  524. $sql.= " AND entity = ".$conf->entity;
  525. $resql=$db->query($sql);
  526. if ($resql)
  527. {
  528. $num = $db->num_rows($resql);
  529. $i = 0;
  530. if ($num > 0)
  531. {
  532. print '<select name="rib" class="flat" id="rib">';
  533. print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
  534. while ($i < $num)
  535. {
  536. $row = $db->fetch_row($resql);
  537. print '<option value="'.$row[0].'"';
  538. print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected="selected"':'';
  539. print '>'.$row[1].'</option>';
  540. $i++;
  541. }
  542. print "</select>";
  543. }
  544. else
  545. {
  546. print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>";
  547. }
  548. }
  549. }
  550. else
  551. {
  552. print $langs->trans("BankModuleNotActive");
  553. }
  554. print "</td></tr>";
  555. $var=!$var;
  556. print '<tr '.$bc[$var].'>';
  557. print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
  558. print "<td>";
  559. print '<select class="flat" name="chq" id="chq">';
  560. print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
  561. print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER?' selected="selected"':'').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name?$mysoc->name:$langs->trans("NotDefined")).')</option>';
  562. $sql = "SELECT rowid, label";
  563. $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
  564. $sql.= " WHERE clos = 0";
  565. $sql.= " AND courant = 1";
  566. $sql.= " AND entity = ".$conf->entity;
  567. $var=True;
  568. $resql=$db->query($sql);
  569. if ($resql)
  570. {
  571. $num = $db->num_rows($resql);
  572. $i = 0;
  573. while ($i < $num)
  574. {
  575. $var=!$var;
  576. $row = $db->fetch_row($resql);
  577. print '<option value="'.$row[0].'"';
  578. print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected="selected"':'';
  579. print '>'.$langs->trans("OwnerOfBankAccount",$row[1]).'</option>';
  580. $i++;
  581. }
  582. }
  583. print "</select>";
  584. print "</td></tr>";
  585. print "</table>";
  586. print "</form>";
  587. print "<br>";
  588. print_titre($langs->trans("OtherOptions"));
  589. print '<table class="noborder" width="100%">';
  590. print '<tr class="liste_titre">';
  591. print '<td>'.$langs->trans("Parameter").'</td>';
  592. print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
  593. print '<td width="80">&nbsp;</td>';
  594. print "</tr>\n";
  595. $var=true;
  596. // Force date validation
  597. $var=! $var;
  598. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  599. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
  600. print '<input type="hidden" name="action" value="setforcedate" />';
  601. print '<tr '.$bc[$var].'><td>';
  602. print $langs->trans("ForceInvoiceDate");
  603. print '</td><td width="60" align="center">';
  604. print $form->selectyesno("forcedate",$conf->global->FAC_FORCE_DATE_VALIDATION,1);
  605. print '</td><td align="right">';
  606. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
  607. print "</td></tr>\n";
  608. print '</form>';
  609. $var=! $var;
  610. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  611. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
  612. print '<input type="hidden" name="action" value="set_FACTURE_FREE_TEXT" />';
  613. print '<tr '.$bc[$var].'><td colspan="2">';
  614. print $langs->trans("FreeLegalTextOnInvoices").' ('.$langs->trans("AddCRIfTooLong").')<br>';
  615. print '<textarea name="FACTURE_FREE_TEXT" class="flat" cols="120">'.$conf->global->FACTURE_FREE_TEXT.'</textarea>';
  616. print '</td><td align="right">';
  617. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
  618. print "</td></tr>\n";
  619. print '</form>';
  620. $var=!$var;
  621. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  622. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
  623. print '<input type="hidden" name="action" value="set_FACTURE_DRAFT_WATERMARK" />';
  624. print '<tr '.$bc[$var].'><td colspan="2">';
  625. print $langs->trans("WatermarkOnDraftBill").'<br>';
  626. print '<input size="50" class="flat" type="text" name="FACTURE_DRAFT_WATERMARK" value="'.$conf->global->FACTURE_DRAFT_WATERMARK.'" />';
  627. print '</td><td align="right">';
  628. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
  629. print "</td></tr>\n";
  630. print '</form>';
  631. print '</table>';
  632. /*
  633. * Repertoire
  634. */
  635. print '<br>';
  636. print_titre($langs->trans("PathToDocuments"));
  637. print '<table class="noborder" width="100%">'."\n";
  638. print '<tr class="liste_titre">'."\n";
  639. print '<td>'.$langs->trans("Name").'</td>'."\n";
  640. print '<td>'.$langs->trans("Value").'</td>'."\n";
  641. print "</tr>\n";
  642. print '<tr '.$bc[false].'>'."\n";
  643. print '<td width="140">'.$langs->trans("PathDirectory").'</td>'."\n";
  644. print '<td>'.$conf->facture->dir_output.'</td>'."\n";
  645. print '</tr>'."\n";
  646. print "</table>\n";
  647. //dol_fiche_end();
  648. dol_htmloutput_mesg($mesg);
  649. $db->close();
  650. llxFooter();
  651. ?>