commande.php 25 KB

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