facture.php 29 KB

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