facture.php 26 KB

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