commande.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. <?php
  2. /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  5. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  6. * Copyright (C) 2004 Andre Cianfarani <acianfa@free.fr>
  7. * Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
  8. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  9. * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
  10. * Copyright (C) 2011-2016 Philippe Grand <philippe.grand@atoo-net.com>
  11. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  12. * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  26. */
  27. /**
  28. * \file htdocs/admin/commande.php
  29. * \ingroup commande
  30. * \brief Setup page of module Order
  31. */
  32. // Load Dolibarr environment
  33. require '../main.inc.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  36. require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
  38. // Load translation files required by the page
  39. $langs->loadLangs(array('admin', 'errors', 'orders', 'other'));
  40. if (!$user->admin) {
  41. accessforbidden();
  42. }
  43. $action = GETPOST('action', 'aZ09');
  44. $value = GETPOST('value', 'alpha');
  45. $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
  46. $label = GETPOST('label', 'alpha');
  47. $scandir = GETPOST('scan_dir', 'alpha');
  48. $type = 'order';
  49. /*
  50. * Actions
  51. */
  52. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  53. if ($action == 'updateMask') {
  54. $maskconstorder = GETPOST('maskconstorder', 'aZ09');
  55. $maskorder = GETPOST('maskorder', 'alpha');
  56. if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) {
  57. $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
  58. }
  59. if (!($res > 0)) {
  60. $error++;
  61. }
  62. if (!$error) {
  63. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  64. } else {
  65. setEventMessages($langs->trans("Error"), null, 'errors');
  66. }
  67. } elseif ($action == 'specimen') {
  68. $modele = GETPOST('module', 'alpha');
  69. $commande = new Commande($db);
  70. $commande->initAsSpecimen();
  71. // Search template files
  72. $file = '';
  73. $classname = '';
  74. $filefound = 0;
  75. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  76. foreach ($dirmodels as $reldir) {
  77. $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
  78. if (file_exists($file)) {
  79. $filefound = 1;
  80. $classname = "pdf_".$modele;
  81. break;
  82. }
  83. }
  84. if ($filefound) {
  85. require_once $file;
  86. $module = new $classname($db);
  87. if ($module->write_file($commande, $langs) > 0) {
  88. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
  89. return;
  90. } else {
  91. setEventMessages($module->error, null, 'errors');
  92. dol_syslog($module->error, LOG_ERR);
  93. }
  94. } else {
  95. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  96. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  97. }
  98. } elseif ($action == 'set') {
  99. // Activate a model
  100. $ret = addDocumentModel($value, $type, $label, $scandir);
  101. } elseif ($action == 'del') {
  102. $ret = delDocumentModel($value, $type);
  103. if ($ret > 0) {
  104. if (getDolGlobalString('COMMANDE_ADDON_PDF') == $value) {
  105. dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
  106. }
  107. }
  108. } elseif ($action == 'setdoc') {
  109. // Set default model
  110. if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
  111. // The constant that was read before the new set
  112. // We therefore requires a variable to have a coherent view
  113. $conf->global->COMMANDE_ADDON_PDF = $value;
  114. }
  115. // On active le modele
  116. $ret = delDocumentModel($value, $type);
  117. if ($ret > 0) {
  118. $ret = addDocumentModel($value, $type, $label, $scandir);
  119. }
  120. } elseif ($action == 'setmod') {
  121. // TODO Check if numbering module chosen can be activated
  122. // by calling method canBeActivated
  123. dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity);
  124. } elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') {
  125. $draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
  126. $res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
  127. if (!($res > 0)) {
  128. $error++;
  129. }
  130. if (!$error) {
  131. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  132. } else {
  133. setEventMessages($langs->trans("Error"), null, 'errors');
  134. }
  135. } elseif ($action == 'set_ORDER_FREE_TEXT') {
  136. $freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
  137. $res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
  138. if (!($res > 0)) {
  139. $error++;
  140. }
  141. if (!$error) {
  142. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  143. } else {
  144. setEventMessages($langs->trans("Error"), null, 'errors');
  145. }
  146. } elseif ($action == 'setribchq') {
  147. $rib = GETPOST('rib', 'alpha');
  148. $chq = GETPOST('chq', 'alpha');
  149. $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
  150. $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
  151. if (!($res > 0)) {
  152. $error++;
  153. }
  154. if (!$error) {
  155. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  156. } else {
  157. setEventMessages($langs->trans("Error"), null, 'errors');
  158. }
  159. } elseif (preg_match('/set_(.*)/', $action, $reg)) {
  160. $code = $reg[1];
  161. $value = (GETPOST($code) ? GETPOST($code) : 1);
  162. $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
  163. if (!($res > 0)) {
  164. $error++;
  165. }
  166. if ($error) {
  167. setEventMessages($langs->trans('Error'), null, 'errors');
  168. } else {
  169. setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
  170. header("Location: " . $_SERVER["PHP_SELF"]);
  171. exit();
  172. }
  173. } elseif (preg_match('/del_(.*)/', $action, $reg)) {
  174. $code = $reg[1];
  175. $res = dolibarr_del_const($db, $code, $conf->entity);
  176. if (!($res > 0)) {
  177. $error++;
  178. }
  179. if ($error) {
  180. setEventMessages($langs->trans('Error'), null, 'errors');
  181. } else {
  182. setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
  183. header("Location: " . $_SERVER["PHP_SELF"]);
  184. exit();
  185. }
  186. }
  187. /*elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') {
  188. // Activate ask for payment bank
  189. $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
  190. if (!($res > 0)) {
  191. $error++;
  192. }
  193. if (!$error) {
  194. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  195. } else {
  196. setEventMessages($langs->trans("Error"), null, 'errors');
  197. }
  198. } elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') {
  199. // Activate ask for warehouse
  200. $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
  201. if (!($res > 0)) {
  202. $error++;
  203. }
  204. if (!$error) {
  205. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  206. } else {
  207. setEventMessages($langs->trans("Error"), null, 'errors');
  208. }
  209. } */
  210. /*
  211. * View
  212. */
  213. $form = new Form($db);
  214. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  215. llxHeader("", $langs->trans("OrdersSetup"));
  216. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  217. print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
  218. $head = order_admin_prepare_head();
  219. print dol_get_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order');
  220. /*
  221. * Orders Numbering model
  222. */
  223. print load_fiche_titre($langs->trans("OrdersNumberingModules"), '', '');
  224. print '<div class="div-table-responsive-no-min">';
  225. print '<table class="noborder centpercent">';
  226. print '<tr class="liste_titre">';
  227. print '<td>'.$langs->trans("Name").'</td>';
  228. print '<td>'.$langs->trans("Description").'</td>';
  229. print '<td class="nowrap">'.$langs->trans("Example").'</td>';
  230. print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
  231. print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
  232. print '</tr>'."\n";
  233. clearstatcache();
  234. foreach ($dirmodels as $reldir) {
  235. $dir = dol_buildpath($reldir."core/modules/commande/");
  236. if (is_dir($dir)) {
  237. $handle = opendir($dir);
  238. if (is_resource($handle)) {
  239. while (($file = readdir($handle)) !== false) {
  240. if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
  241. $file = substr($file, 0, dol_strlen($file) - 4);
  242. require_once $dir.$file.'.php';
  243. $module = new $file($db);
  244. // Show modules according to features level
  245. if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
  246. continue;
  247. }
  248. if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
  249. continue;
  250. }
  251. if ($module->isEnabled()) {
  252. print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
  253. print $module->info($langs);
  254. print '</td>';
  255. // Show example of numbering model
  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 '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
  263. } else {
  264. print $tmp;
  265. }
  266. print '</td>'."\n";
  267. print '<td class="center">';
  268. if ($conf->global->COMMANDE_ADDON == $file) {
  269. print img_picto($langs->trans("Activated"), 'switch_on');
  270. } else {
  271. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
  272. print img_picto($langs->trans("Disabled"), 'switch_off');
  273. print '</a>';
  274. }
  275. print '</td>';
  276. $commande = new Commande($db);
  277. $commande->initAsSpecimen();
  278. // Info
  279. $htmltooltip = '';
  280. $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  281. $commande->type = 0;
  282. $nextval = $module->getNextValue($mysoc, $commande);
  283. if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
  284. $htmltooltip .= ''.$langs->trans("NextValue").': ';
  285. if ($nextval) {
  286. if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
  287. $nextval = $langs->trans($nextval);
  288. }
  289. $htmltooltip .= $nextval.'<br>';
  290. } else {
  291. $htmltooltip .= $langs->trans($module->error).'<br>';
  292. }
  293. }
  294. print '<td class="center">';
  295. print $form->textwithpicto('', $htmltooltip, 1, 0);
  296. print '</td>';
  297. print "</tr>\n";
  298. }
  299. }
  300. }
  301. closedir($handle);
  302. }
  303. }
  304. }
  305. print "</table></div><br>\n";
  306. /*
  307. * Document templates generators
  308. */
  309. print load_fiche_titre($langs->trans("OrdersModelModule"), '', '');
  310. // Load array def with activated templates
  311. $def = array();
  312. $sql = "SELECT nom";
  313. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  314. $sql .= " WHERE type = '".$db->escape($type)."'";
  315. $sql .= " AND entity = ".$conf->entity;
  316. $resql = $db->query($sql);
  317. if ($resql) {
  318. $i = 0;
  319. $num_rows = $db->num_rows($resql);
  320. while ($i < $num_rows) {
  321. $array = $db->fetch_array($resql);
  322. array_push($def, $array[0]);
  323. $i++;
  324. }
  325. } else {
  326. dol_print_error($db);
  327. }
  328. print '<div class="div-table-responsive-no-min">';
  329. print '<table class="noborder centpercent">'."\n";
  330. print '<tr class="liste_titre">'."\n";
  331. print '<td>'.$langs->trans("Name").'</td>';
  332. print '<td>'.$langs->trans("Description").'</td>';
  333. print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
  334. print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
  335. print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
  336. print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
  337. print "</tr>\n";
  338. clearstatcache();
  339. foreach ($dirmodels as $reldir) {
  340. foreach (array('', '/doc') as $valdir) {
  341. $realpath = $reldir."core/modules/commande".$valdir;
  342. $dir = dol_buildpath($realpath);
  343. if (is_dir($dir)) {
  344. $handle = opendir($dir);
  345. if (is_resource($handle)) {
  346. while (($file = readdir($handle)) !== false) {
  347. $filelist[] = $file;
  348. }
  349. closedir($handle);
  350. arsort($filelist);
  351. foreach ($filelist as $file) {
  352. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  353. if (file_exists($dir.'/'.$file)) {
  354. $name = substr($file, 4, dol_strlen($file) - 16);
  355. $classname = substr($file, 0, dol_strlen($file) - 12);
  356. require_once $dir.'/'.$file;
  357. $module = new $classname($db);
  358. $modulequalified = 1;
  359. if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
  360. $modulequalified = 0;
  361. }
  362. if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
  363. $modulequalified = 0;
  364. }
  365. if ($modulequalified) {
  366. print '<tr class="oddeven"><td width="100">';
  367. print(empty($module->name) ? $name : $module->name);
  368. print "</td><td>\n";
  369. if (method_exists($module, 'info')) {
  370. print $module->info($langs);
  371. } else {
  372. print $module->description;
  373. }
  374. print '</td>';
  375. // Active
  376. if (in_array($name, $def)) {
  377. print '<td class="center">'."\n";
  378. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
  379. print img_picto($langs->trans("Enabled"), 'switch_on');
  380. print '</a>';
  381. print '</td>';
  382. } else {
  383. print '<td class="center">'."\n";
  384. 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("Disabled"), 'switch_off').'</a>';
  385. print "</td>";
  386. }
  387. // Default
  388. print '<td class="center">';
  389. if (getDolGlobalString('COMMANDE_ADDON_PDF') == $name) {
  390. print img_picto($langs->trans("Default"), 'on');
  391. } else {
  392. 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("Disabled"), 'off').'</a>';
  393. }
  394. print '</td>';
  395. // Info
  396. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  397. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  398. if ($module->type == 'pdf') {
  399. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  400. }
  401. $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
  402. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  403. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  404. $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
  405. $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
  406. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  407. //$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
  408. //$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
  409. $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
  410. print '<td class="center">';
  411. print $form->textwithpicto('', $htmltooltip, 1, 0);
  412. print '</td>';
  413. // Preview
  414. print '<td class="center">';
  415. if ($module->type == 'pdf') {
  416. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
  417. } else {
  418. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  419. }
  420. print '</td>';
  421. print "</tr>\n";
  422. }
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. }
  430. print '</table>';
  431. print '</div>';
  432. /*
  433. * Payment mode
  434. */
  435. print '<br>';
  436. print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInOrder"), '', '');
  437. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  438. print '<input type="hidden" name="token" value="'.newToken().'" />';
  439. print '<div class="div-table-responsive-no-min">';
  440. print '<table class="noborder centpercent">';
  441. print '<tr class="liste_titre">';
  442. print '<td>';
  443. print '<input type="hidden" name="action" value="setribchq">';
  444. print $langs->trans("PaymentMode").'</td>';
  445. print '<td align="right">';
  446. if (!isModEnabled('facture')) {
  447. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  448. }
  449. print '</td>';
  450. print "</tr>\n";
  451. print '<tr class="oddeven">';
  452. print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
  453. print "<td>";
  454. if (!isModEnabled('facture')) {
  455. if (isModEnabled("banque")) {
  456. $sql = "SELECT rowid, label";
  457. $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
  458. $sql .= " WHERE clos = 0";
  459. $sql .= " AND courant = 1";
  460. $sql .= " AND entity IN (".getEntity('bank_account').")";
  461. $resql = $db->query($sql);
  462. if ($resql) {
  463. $num = $db->num_rows($resql);
  464. $i = 0;
  465. if ($num > 0) {
  466. print '<select name="rib" class="flat" id="rib">';
  467. print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
  468. while ($i < $num) {
  469. $row = $db->fetch_row($resql);
  470. print '<option value="'.$row[0].'"';
  471. print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
  472. print '>'.$row[1].'</option>';
  473. $i++;
  474. }
  475. print "</select>";
  476. } else {
  477. print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>";
  478. }
  479. }
  480. } else {
  481. print '<span class="opacitymedium">'.$langs->trans("BankModuleNotActive").'</span>';
  482. }
  483. } else {
  484. print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
  485. }
  486. print "</td></tr>";
  487. print '<tr class="oddeven">';
  488. print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
  489. print "<td>";
  490. if (!isModEnabled('facture')) {
  491. print '<select class="flat" name="chq" id="chq">';
  492. print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
  493. print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
  494. $sql = "SELECT rowid, label";
  495. $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
  496. $sql .= " WHERE clos = 0";
  497. $sql .= " AND courant = 1";
  498. $sql .= " AND entity IN (".getEntity('bank_account').")";
  499. $resql = $db->query($sql);
  500. if ($resql) {
  501. $num = $db->num_rows($resql);
  502. $i = 0;
  503. while ($i < $num) {
  504. $row = $db->fetch_row($resql);
  505. print '<option value="'.$row[0].'"';
  506. print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
  507. print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
  508. $i++;
  509. }
  510. }
  511. print "</select>";
  512. } else {
  513. print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
  514. }
  515. print "</td></tr>";
  516. print "</table>";
  517. print '</div>';
  518. print "</form>";
  519. print '<br>';
  520. /*
  521. * Other options
  522. */
  523. print load_fiche_titre($langs->trans("OtherOptions"), '', '');
  524. print '<div class="div-table-responsive-no-min">';
  525. print '<table class="noborder centpercent">';
  526. print '<tr class="liste_titre">';
  527. print '<td>'.$langs->trans("Parameter").'</td>';
  528. print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
  529. print "<td>&nbsp;</td>\n";
  530. print "</tr>\n";
  531. $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
  532. $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
  533. $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
  534. foreach ($substitutionarray as $key => $val) {
  535. $htmltext .= $key.'<br>';
  536. }
  537. $htmltext .= '</i>';
  538. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  539. print '<input type="hidden" name="token" value="'.newToken().'">';
  540. print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
  541. print '<tr class="oddeven"><td colspan="2">';
  542. print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
  543. $variablename = 'ORDER_FREE_TEXT';
  544. if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
  545. print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
  546. } else {
  547. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  548. $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
  549. print $doleditor->Create();
  550. }
  551. print '</td><td class="right">';
  552. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  553. print "</td></tr>\n";
  554. print '</form>';
  555. //Use draft Watermark
  556. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
  557. print '<input type="hidden" name="token" value="'.newToken().'">';
  558. print '<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
  559. print '<tr class="oddeven"><td>';
  560. print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
  561. print '</td><td>';
  562. print '<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('COMMANDE_DRAFT_WATERMARK')).'">';
  563. print '</td><td class="right">';
  564. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  565. print "</td></tr>\n";
  566. // Allow external download
  567. print '<tr class="oddeven">';
  568. print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
  569. print '<td class="center" colspan="2">';
  570. print ajax_constantonoff('ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1);
  571. print '</td></tr>';
  572. print '</form>';
  573. /*
  574. // Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
  575. // TODO Must be implemented by PDF templates
  576. // Ask for payment bank during order
  577. if (isModEnabled("banque")) {
  578. print '<tr class="oddeven"><td>';
  579. print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">';
  580. if (!empty($conf->use_javascript_ajax)) {
  581. print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ORDER');
  582. } else {
  583. if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER)) {
  584. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&token='.newToken().'&value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
  585. } else {
  586. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&token='.newToken().'&value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
  587. }
  588. }
  589. print '</td></tr>';
  590. } else {
  591. print '<tr class="oddeven"><td>';
  592. print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
  593. }
  594. // Ask for warehouse during order
  595. if (isModEnabled('stock')) {
  596. print '<tr class="oddeven"><td>';
  597. print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">';
  598. if (!empty($conf->use_javascript_ajax)) {
  599. print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
  600. } else {
  601. if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
  602. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&token='.newToken().'&value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
  603. } else {
  604. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&token='.newToken().'&value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
  605. }
  606. }
  607. print '</td></tr>';
  608. } else {
  609. print '<tr class="oddeven"><td>';
  610. print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
  611. }
  612. */
  613. print '</table>';
  614. print '</div>';
  615. print '<br>';
  616. /*
  617. * Notifications
  618. */
  619. print load_fiche_titre($langs->trans("Notifications"), '', '');
  620. print '<div class="div-table-responsive-no-min">';
  621. print '<table class="noborder centpercent">';
  622. print '<tr class="liste_titre">';
  623. print '<td>'.$langs->trans("Parameter").'</td>';
  624. print '<td class="center" width="60"></td>';
  625. print '<td width="80">&nbsp;</td>';
  626. print "</tr>\n";
  627. print '<tr class="oddeven"><td colspan="2">';
  628. print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
  629. print '</td><td class="right">';
  630. print "</td></tr>\n";
  631. print '</table>';
  632. print '</div>';
  633. // End of page
  634. llxFooter();
  635. $db->close();