facture.php 32 KB

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