commande.php 25 KB

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