facture.php 30 KB

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