facture.php 28 KB

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