facture.php 30 KB

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