commande.php 24 KB

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