PageRenderTime 52ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/facture/admin/facture.php

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