commande.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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 = ''; $classname = ''; $filefound = 0;
  73. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  74. foreach ($dirmodels as $reldir) {
  75. $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
  76. if (file_exists($file)) {
  77. $filefound = 1;
  78. $classname = "pdf_".$modele;
  79. break;
  80. }
  81. }
  82. if ($filefound) {
  83. require_once $file;
  84. $module = new $classname($db);
  85. if ($module->write_file($commande, $langs) > 0) {
  86. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
  87. return;
  88. } else {
  89. setEventMessages($module->error, null, 'errors');
  90. dol_syslog($module->error, LOG_ERR);
  91. }
  92. } else {
  93. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  94. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  95. }
  96. } elseif ($action == 'set') {
  97. // Activate a model
  98. $ret = addDocumentModel($value, $type, $label, $scandir);
  99. } elseif ($action == 'del') {
  100. $ret = delDocumentModel($value, $type);
  101. if ($ret > 0) {
  102. if (getDolGlobalString('COMMANDE_ADDON_PDF') == $value) {
  103. dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
  104. }
  105. }
  106. } elseif ($action == 'setdoc') {
  107. // Set default model
  108. if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
  109. // The constant that was read before the new set
  110. // We therefore requires a variable to have a coherent view
  111. $conf->global->COMMANDE_ADDON_PDF = $value;
  112. }
  113. // On active le modele
  114. $ret = delDocumentModel($value, $type);
  115. if ($ret > 0) {
  116. $ret = addDocumentModel($value, $type, $label, $scandir);
  117. }
  118. } elseif ($action == 'setmod') {
  119. // TODO Check if numbering module chosen can be activated
  120. // by calling method canBeActivated
  121. dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity);
  122. } elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') {
  123. $draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
  124. $res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
  125. if (!($res > 0)) {
  126. $error++;
  127. }
  128. if (!$error) {
  129. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  130. } else {
  131. setEventMessages($langs->trans("Error"), null, 'errors');
  132. }
  133. } elseif ($action == 'set_ORDER_FREE_TEXT') {
  134. $freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
  135. $res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, '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 == 'setribchq') {
  145. $rib = GETPOST('rib', 'alpha');
  146. $chq = GETPOST('chq', 'alpha');
  147. $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
  148. $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
  149. if (!($res > 0)) {
  150. $error++;
  151. }
  152. if (!$error) {
  153. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  154. } else {
  155. setEventMessages($langs->trans("Error"), null, 'errors');
  156. }
  157. } elseif (preg_match('/set_(.*)/', $action, $reg)) {
  158. $code = $reg[1];
  159. $value = (GETPOST($code) ? GETPOST($code) : 1);
  160. $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
  161. if (!($res > 0)) {
  162. $error++;
  163. }
  164. if ($error) {
  165. setEventMessages($langs->trans('Error'), null, 'errors');
  166. } else {
  167. setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
  168. header("Location: " . $_SERVER["PHP_SELF"]);
  169. exit();
  170. }
  171. } elseif (preg_match('/del_(.*)/', $action, $reg)) {
  172. $code = $reg[1];
  173. $res = dolibarr_del_const($db, $code, $conf->entity);
  174. if (!($res > 0)) {
  175. $error++;
  176. }
  177. if ($error) {
  178. setEventMessages($langs->trans('Error'), null, 'errors');
  179. } else {
  180. setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
  181. header("Location: " . $_SERVER["PHP_SELF"]);
  182. exit();
  183. }
  184. }
  185. /*elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') {
  186. // Activate ask for payment bank
  187. $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
  188. if (!($res > 0)) {
  189. $error++;
  190. }
  191. if (!$error) {
  192. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  193. } else {
  194. setEventMessages($langs->trans("Error"), null, 'errors');
  195. }
  196. } elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') {
  197. // Activate ask for warehouse
  198. $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
  199. if (!($res > 0)) {
  200. $error++;
  201. }
  202. if (!$error) {
  203. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  204. } else {
  205. setEventMessages($langs->trans("Error"), null, 'errors');
  206. }
  207. } */
  208. /*
  209. * View
  210. */
  211. $form = new Form($db);
  212. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  213. llxHeader("", $langs->trans("OrdersSetup"));
  214. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  215. print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
  216. $head = order_admin_prepare_head();
  217. print dol_get_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order');
  218. /*
  219. * Orders Numbering model
  220. */
  221. print load_fiche_titre($langs->trans("OrdersNumberingModules"), '', '');
  222. print '<div class="div-table-responsive-no-min">';
  223. print '<table class="noborder centpercent">';
  224. print '<tr class="liste_titre">';
  225. print '<td>'.$langs->trans("Name").'</td>';
  226. print '<td>'.$langs->trans("Description").'</td>';
  227. print '<td class="nowrap">'.$langs->trans("Example").'</td>';
  228. print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
  229. print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
  230. print '</tr>'."\n";
  231. clearstatcache();
  232. foreach ($dirmodels as $reldir) {
  233. $dir = dol_buildpath($reldir."core/modules/commande/");
  234. if (is_dir($dir)) {
  235. $handle = opendir($dir);
  236. if (is_resource($handle)) {
  237. while (($file = readdir($handle)) !== false) {
  238. if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
  239. $file = substr($file, 0, dol_strlen($file) - 4);
  240. require_once $dir.$file.'.php';
  241. $module = new $file($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>'.$module->name."</td><td>\n";
  251. print $module->info($langs);
  252. print '</td>';
  253. // Show example of numbering model
  254. print '<td class="nowrap">';
  255. $tmp = $module->getExample();
  256. if (preg_match('/^Error/', $tmp)) {
  257. $langs->load("errors");
  258. print '<div class="error">'.$langs->trans($tmp).'</div>';
  259. } elseif ($tmp == 'NotConfigured') {
  260. print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
  261. } else {
  262. print $tmp;
  263. }
  264. print '</td>'."\n";
  265. print '<td class="center">';
  266. if ($conf->global->COMMANDE_ADDON == $file) {
  267. print img_picto($langs->trans("Activated"), 'switch_on');
  268. } else {
  269. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
  270. print img_picto($langs->trans("Disabled"), 'switch_off');
  271. print '</a>';
  272. }
  273. print '</td>';
  274. $commande = new Commande($db);
  275. $commande->initAsSpecimen();
  276. // Info
  277. $htmltooltip = '';
  278. $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  279. $commande->type = 0;
  280. $nextval = $module->getNextValue($mysoc, $commande);
  281. if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
  282. $htmltooltip .= ''.$langs->trans("NextValue").': ';
  283. if ($nextval) {
  284. if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
  285. $nextval = $langs->trans($nextval);
  286. }
  287. $htmltooltip .= $nextval.'<br>';
  288. } else {
  289. $htmltooltip .= $langs->trans($module->error).'<br>';
  290. }
  291. }
  292. print '<td class="center">';
  293. print $form->textwithpicto('', $htmltooltip, 1, 0);
  294. print '</td>';
  295. print "</tr>\n";
  296. }
  297. }
  298. }
  299. closedir($handle);
  300. }
  301. }
  302. }
  303. print "</table></div><br>\n";
  304. /*
  305. * Document templates generators
  306. */
  307. print load_fiche_titre($langs->trans("OrdersModelModule"), '', '');
  308. // Load array def with activated templates
  309. $def = array();
  310. $sql = "SELECT nom";
  311. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  312. $sql .= " WHERE type = '".$db->escape($type)."'";
  313. $sql .= " AND entity = ".$conf->entity;
  314. $resql = $db->query($sql);
  315. if ($resql) {
  316. $i = 0;
  317. $num_rows = $db->num_rows($resql);
  318. while ($i < $num_rows) {
  319. $array = $db->fetch_array($resql);
  320. array_push($def, $array[0]);
  321. $i++;
  322. }
  323. } else {
  324. dol_print_error($db);
  325. }
  326. print '<div class="div-table-responsive-no-min">';
  327. print '<table class="noborder centpercent">'."\n";
  328. print '<tr class="liste_titre">'."\n";
  329. print '<td>'.$langs->trans("Name").'</td>';
  330. print '<td>'.$langs->trans("Description").'</td>';
  331. print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
  332. print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
  333. print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
  334. print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
  335. print "</tr>\n";
  336. clearstatcache();
  337. foreach ($dirmodels as $reldir) {
  338. foreach (array('', '/doc') as $valdir) {
  339. $realpath = $reldir."core/modules/commande".$valdir;
  340. $dir = dol_buildpath($realpath);
  341. if (is_dir($dir)) {
  342. $handle = opendir($dir);
  343. if (is_resource($handle)) {
  344. while (($file = readdir($handle)) !== false) {
  345. $filelist[] = $file;
  346. }
  347. closedir($handle);
  348. arsort($filelist);
  349. foreach ($filelist as $file) {
  350. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  351. if (file_exists($dir.'/'.$file)) {
  352. $name = substr($file, 4, dol_strlen($file) - 16);
  353. $classname = substr($file, 0, dol_strlen($file) - 12);
  354. require_once $dir.'/'.$file;
  355. $module = new $classname($db);
  356. $modulequalified = 1;
  357. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  358. $modulequalified = 0;
  359. }
  360. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  361. $modulequalified = 0;
  362. }
  363. if ($modulequalified) {
  364. print '<tr class="oddeven"><td width="100">';
  365. print (empty($module->name) ? $name : $module->name);
  366. print "</td><td>\n";
  367. if (method_exists($module, 'info')) {
  368. print $module->info($langs);
  369. } else {
  370. print $module->description;
  371. }
  372. print '</td>';
  373. // Active
  374. if (in_array($name, $def)) {
  375. print '<td class="center">'."\n";
  376. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
  377. print img_picto($langs->trans("Enabled"), 'switch_on');
  378. print '</a>';
  379. print '</td>';
  380. } else {
  381. print '<td class="center">'."\n";
  382. 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>';
  383. print "</td>";
  384. }
  385. // Default
  386. print '<td class="center">';
  387. if (getDolGlobalString('COMMANDE_ADDON_PDF') == $name) {
  388. print img_picto($langs->trans("Default"), 'on');
  389. } else {
  390. 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>';
  391. }
  392. print '</td>';
  393. // Info
  394. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  395. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  396. if ($module->type == 'pdf') {
  397. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  398. }
  399. $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
  400. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  401. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  402. $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
  403. $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
  404. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  405. //$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
  406. //$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
  407. $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
  408. print '<td class="center">';
  409. print $form->textwithpicto('', $htmltooltip, 1, 0);
  410. print '</td>';
  411. // Preview
  412. print '<td class="center">';
  413. if ($module->type == 'pdf') {
  414. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
  415. } else {
  416. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  417. }
  418. print '</td>';
  419. print "</tr>\n";
  420. }
  421. }
  422. }
  423. }
  424. }
  425. }
  426. }
  427. }
  428. print '</table>';
  429. print '</div>';
  430. /*
  431. * Payment mode
  432. */
  433. print '<br>';
  434. print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInOrder"), '', '');
  435. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  436. print '<input type="hidden" name="token" value="'.newToken().'" />';
  437. print '<div class="div-table-responsive-no-min">';
  438. print '<table class="noborder centpercent">';
  439. print '<tr class="liste_titre">';
  440. print '<td>';
  441. print '<input type="hidden" name="action" value="setribchq">';
  442. print $langs->trans("PaymentMode").'</td>';
  443. print '<td align="right">';
  444. if (!isModEnabled('facture')) {
  445. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  446. }
  447. print '</td>';
  448. print "</tr>\n";
  449. print '<tr class="oddeven">';
  450. print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
  451. print "<td>";
  452. if (!isModEnabled('facture')) {
  453. if (isModEnabled("banque")) {
  454. $sql = "SELECT rowid, label";
  455. $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
  456. $sql .= " WHERE clos = 0";
  457. $sql .= " AND courant = 1";
  458. $sql .= " AND entity IN (".getEntity('bank_account').")";
  459. $resql = $db->query($sql);
  460. if ($resql) {
  461. $num = $db->num_rows($resql);
  462. $i = 0;
  463. if ($num > 0) {
  464. print '<select name="rib" class="flat" id="rib">';
  465. print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
  466. while ($i < $num) {
  467. $row = $db->fetch_row($resql);
  468. print '<option value="'.$row[0].'"';
  469. print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
  470. print '>'.$row[1].'</option>';
  471. $i++;
  472. }
  473. print "</select>";
  474. } else {
  475. print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>";
  476. }
  477. }
  478. } else {
  479. print '<span class="opacitymedium">'.$langs->trans("BankModuleNotActive").'</span>';
  480. }
  481. } else {
  482. print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
  483. }
  484. print "</td></tr>";
  485. print '<tr class="oddeven">';
  486. print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
  487. print "<td>";
  488. if (!isModEnabled('facture')) {
  489. print '<select class="flat" name="chq" id="chq">';
  490. print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
  491. print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
  492. $sql = "SELECT rowid, label";
  493. $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
  494. $sql .= " WHERE clos = 0";
  495. $sql .= " AND courant = 1";
  496. $sql .= " AND entity IN (".getEntity('bank_account').")";
  497. $resql = $db->query($sql);
  498. if ($resql) {
  499. $num = $db->num_rows($resql);
  500. $i = 0;
  501. while ($i < $num) {
  502. $row = $db->fetch_row($resql);
  503. print '<option value="'.$row[0].'"';
  504. print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
  505. print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
  506. $i++;
  507. }
  508. }
  509. print "</select>";
  510. } else {
  511. print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
  512. }
  513. print "</td></tr>";
  514. print "</table>";
  515. print '</div>';
  516. print "</form>";
  517. print '<br>';
  518. /*
  519. * Other options
  520. */
  521. print load_fiche_titre($langs->trans("OtherOptions"), '', '');
  522. print '<div class="div-table-responsive-no-min">';
  523. print '<table class="noborder centpercent">';
  524. print '<tr class="liste_titre">';
  525. print '<td>'.$langs->trans("Parameter").'</td>';
  526. print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
  527. print "<td>&nbsp;</td>\n";
  528. print "</tr>\n";
  529. $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
  530. $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
  531. $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
  532. foreach ($substitutionarray as $key => $val) {
  533. $htmltext .= $key.'<br>';
  534. }
  535. $htmltext .= '</i>';
  536. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  537. print '<input type="hidden" name="token" value="'.newToken().'">';
  538. print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
  539. print '<tr class="oddeven"><td colspan="2">';
  540. print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
  541. $variablename = 'ORDER_FREE_TEXT';
  542. if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
  543. print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
  544. } else {
  545. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  546. $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
  547. print $doleditor->Create();
  548. }
  549. print '</td><td class="right">';
  550. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  551. print "</td></tr>\n";
  552. print '</form>';
  553. //Use draft Watermark
  554. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
  555. print '<input type="hidden" name="token" value="'.newToken().'">';
  556. print '<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
  557. print '<tr class="oddeven"><td>';
  558. print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
  559. print '</td><td>';
  560. print '<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('COMMANDE_DRAFT_WATERMARK')).'">';
  561. print '</td><td class="right">';
  562. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  563. print "</td></tr>\n";
  564. // Allow external download
  565. print '<tr class="oddeven">';
  566. print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
  567. print '<td class="center" colspan="2">';
  568. print ajax_constantonoff('ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1);
  569. print '</td></tr>';
  570. print '</form>';
  571. /*
  572. // Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
  573. // TODO Must be implemented by PDF templates
  574. // Ask for payment bank during order
  575. if (isModEnabled("banque")) {
  576. print '<tr class="oddeven"><td>';
  577. print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">';
  578. if (!empty($conf->use_javascript_ajax)) {
  579. print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ORDER');
  580. } else {
  581. if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER)) {
  582. 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>';
  583. } else {
  584. 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>';
  585. }
  586. }
  587. print '</td></tr>';
  588. } else {
  589. print '<tr class="oddeven"><td>';
  590. print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
  591. }
  592. // Ask for warehouse during order
  593. if (isModEnabled('stock')) {
  594. print '<tr class="oddeven"><td>';
  595. print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">';
  596. if (!empty($conf->use_javascript_ajax)) {
  597. print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
  598. } else {
  599. if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
  600. 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>';
  601. } else {
  602. 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>';
  603. }
  604. }
  605. print '</td></tr>';
  606. } else {
  607. print '<tr class="oddeven"><td>';
  608. print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
  609. }
  610. */
  611. print '</table>';
  612. print '</div>';
  613. print '<br>';
  614. /*
  615. * Notifications
  616. */
  617. print load_fiche_titre($langs->trans("Notifications"), '', '');
  618. print '<div class="div-table-responsive-no-min">';
  619. print '<table class="noborder centpercent">';
  620. print '<tr class="liste_titre">';
  621. print '<td>'.$langs->trans("Parameter").'</td>';
  622. print '<td class="center" width="60"></td>';
  623. print '<td width="80">&nbsp;</td>';
  624. print "</tr>\n";
  625. print '<tr class="oddeven"><td colspan="2">';
  626. print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
  627. print '</td><td class="right">';
  628. print "</td></tr>\n";
  629. print '</table>';
  630. print '</div>';
  631. // End of page
  632. llxFooter();
  633. $db->close();