dolibarr  20.0.0-alpha
commande.php
Go to the documentation of this file.
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-2024 Frédéric France <frederic.france@free.fr>
13  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program. If not, see <https://www.gnu.org/licenses/>.
27  */
28 
35 // Load Dolibarr environment
36 require '../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
41 
42 // Load translation files required by the page
43 $langs->loadLangs(array('admin', 'errors', 'orders', 'other'));
44 
45 if (!$user->admin) {
47 }
48 
49 $action = GETPOST('action', 'aZ09');
50 $value = GETPOST('value', 'alpha');
51 $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
52 
53 $label = GETPOST('label', 'alpha');
54 $scandir = GETPOST('scan_dir', 'alpha');
55 $type = 'order';
56 
57 
58 /*
59  * Actions
60  */
61 
62 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
63 
64 if ($action == 'updateMask') {
65  $maskconstorder = GETPOST('maskconstorder', 'aZ09');
66  $maskorder = GETPOST('maskorder', 'alpha');
67 
68  if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) {
69  $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
70  }
71 
72  if (!($res > 0)) {
73  $error++;
74  }
75 
76  if (!$error) {
77  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
78  } else {
79  setEventMessages($langs->trans("Error"), null, 'errors');
80  }
81 } elseif ($action == 'specimen') {
82  $modele = GETPOST('module', 'alpha');
83 
84  $commande = new Commande($db);
85  $commande->initAsSpecimen();
86 
87  // Search template files
88  $file = '';
89  $classname = '';
90  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
91  foreach ($dirmodels as $reldir) {
92  $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
93  if (file_exists($file)) {
94  $classname = "pdf_".$modele;
95  break;
96  }
97  }
98 
99  if ($classname !== '') {
100  require_once $file;
101 
102  $module = new $classname($db);
103  '@phan-var-force ModelePDFCommandes $module';
104 
105  if ($module->write_file($commande, $langs) > 0) {
106  header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
107  return;
108  } else {
109  setEventMessages($module->error, null, 'errors');
110  dol_syslog($module->error, LOG_ERR);
111  }
112  } else {
113  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
114  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
115  }
116 } elseif ($action == 'set') {
117  // Activate a model
118  $ret = addDocumentModel($value, $type, $label, $scandir);
119 } elseif ($action == 'del') {
120  $ret = delDocumentModel($value, $type);
121  if ($ret > 0) {
122  if (getDolGlobalString('COMMANDE_ADDON_PDF') == $value) {
123  dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
124  }
125  }
126 } elseif ($action == 'setdoc') {
127  // Set default model
128  if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
129  // The constant that was read before the new set
130  // We therefore requires a variable to have a coherent view
131  $conf->global->COMMANDE_ADDON_PDF = $value;
132  }
133 
134  // On active le modele
135  $ret = delDocumentModel($value, $type);
136  if ($ret > 0) {
137  $ret = addDocumentModel($value, $type, $label, $scandir);
138  }
139 } elseif ($action == 'setmod') {
140  // TODO Check if numbering module chosen can be activated
141  // by calling method canBeActivated
142 
143  dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity);
144 } elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') {
145  $draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
146  $res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
147 
148  if (!($res > 0)) {
149  $error++;
150  }
151 
152  if (!$error) {
153  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
154  } else {
155  setEventMessages($langs->trans("Error"), null, 'errors');
156  }
157 } elseif ($action == 'set_ORDER_FREE_TEXT') {
158  $freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
159 
160  $res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
161 
162  if (!($res > 0)) {
163  $error++;
164  }
165 
166  if (!$error) {
167  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
168  } else {
169  setEventMessages($langs->trans("Error"), null, 'errors');
170  }
171 } elseif ($action == 'setribchq') {
172  $rib = GETPOST('rib', 'alpha');
173  $chq = GETPOST('chq', 'alpha');
174 
175  $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
176  $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
177 
178  if (!($res > 0)) {
179  $error++;
180  }
181 
182  if (!$error) {
183  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
184  } else {
185  setEventMessages($langs->trans("Error"), null, 'errors');
186  }
187 } elseif (preg_match('/set_(.*)/', $action, $reg)) {
188  $code = $reg[1];
189  $value = (GETPOST($code) ? GETPOST($code) : 1);
190 
191  $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
192  if (!($res > 0)) {
193  $error++;
194  }
195 
196  if ($error) {
197  setEventMessages($langs->trans('Error'), null, 'errors');
198  } else {
199  setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
200  header("Location: " . $_SERVER["PHP_SELF"]);
201  exit();
202  }
203 } elseif (preg_match('/del_(.*)/', $action, $reg)) {
204  $code = $reg[1];
205  $res = dolibarr_del_const($db, $code, $conf->entity);
206 
207  if (!($res > 0)) {
208  $error++;
209  }
210 
211  if ($error) {
212  setEventMessages($langs->trans('Error'), null, 'errors');
213  } else {
214  setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
215  header("Location: " . $_SERVER["PHP_SELF"]);
216  exit();
217  }
218 }
219 /*elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') {
220  // Activate ask for payment bank
221  $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
222 
223  if (!($res > 0)) {
224  $error++;
225  }
226 
227  if (!$error) {
228  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
229  } else {
230  setEventMessages($langs->trans("Error"), null, 'errors');
231  }
232 } elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') {
233  // Activate ask for warehouse
234  $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
235 
236  if (!($res > 0)) {
237  $error++;
238  }
239 
240  if (!$error) {
241  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
242  } else {
243  setEventMessages($langs->trans("Error"), null, 'errors');
244  }
245 } */
246 
247 
248 
249 /*
250  * View
251  */
252 
253 $form = new Form($db);
254 
255 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
256 
257 llxHeader("", $langs->trans("OrdersSetup"));
258 
259 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
260 print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
261 
262 $head = order_admin_prepare_head();
263 
264 print dol_get_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order');
265 
266 /*
267  * Orders Numbering model
268  */
269 
270 print load_fiche_titre($langs->trans("OrdersNumberingModules"), '', '');
271 
272 print '<div class="div-table-responsive-no-min">';
273 print '<table class="noborder centpercent">';
274 print '<tr class="liste_titre">';
275 print '<td>'.$langs->trans("Name").'</td>';
276 print '<td>'.$langs->trans("Description").'</td>';
277 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
278 print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
279 print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
280 print '</tr>'."\n";
281 
282 clearstatcache();
283 
284 foreach ($dirmodels as $reldir) {
285  $dir = dol_buildpath($reldir."core/modules/commande/");
286 
287  if (is_dir($dir)) {
288  $handle = opendir($dir);
289  if (is_resource($handle)) {
290  while (($file = readdir($handle)) !== false) {
291  if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
292  $file = substr($file, 0, dol_strlen($file) - 4);
293 
294  require_once $dir.$file.'.php';
295 
296  $module = new $file($db);
297 
298  // Show modules according to features level
299  if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
300  continue;
301  }
302  if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
303  continue;
304  }
305 
306  if ($module->isEnabled()) {
307  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
308  print $module->info($langs);
309  print '</td>';
310 
311  // Show example of numbering model
312  print '<td class="nowrap">';
313  $tmp = $module->getExample();
314  if (preg_match('/^Error/', $tmp)) {
315  $langs->load("errors");
316  print '<div class="error">'.$langs->trans($tmp).'</div>';
317  } elseif ($tmp == 'NotConfigured') {
318  print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
319  } else {
320  print $tmp;
321  }
322  print '</td>'."\n";
323 
324  print '<td class="center">';
325  if ($conf->global->COMMANDE_ADDON == $file) {
326  print img_picto($langs->trans("Activated"), 'switch_on');
327  } else {
328  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
329  print img_picto($langs->trans("Disabled"), 'switch_off');
330  print '</a>';
331  }
332  print '</td>';
333 
334  $commande = new Commande($db);
335  $commande->initAsSpecimen();
336 
337  // Info
338  $htmltooltip = '';
339  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
340  $commande->type = 0;
341 
342  $nextval = $module->getNextValue($mysoc, $commande);
343  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
344  $htmltooltip .= ''.$langs->trans("NextValue").': ';
345  if ($nextval) {
346  if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
347  $nextval = $langs->trans($nextval);
348  }
349  $htmltooltip .= $nextval.'<br>';
350  } else {
351  $htmltooltip .= $langs->trans($module->error).'<br>';
352  }
353  }
354 
355  print '<td class="center">';
356  print $form->textwithpicto('', $htmltooltip, 1, 0);
357  print '</td>';
358 
359  print "</tr>\n";
360  }
361  }
362  }
363  closedir($handle);
364  }
365  }
366 }
367 print "</table></div><br>\n";
368 
369 
370 /*
371  * Document templates generators
372  */
373 
374 print load_fiche_titre($langs->trans("OrdersModelModule"), '', '');
375 
376 // Load array def with activated templates
377 $def = array();
378 $sql = "SELECT nom";
379 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
380 $sql .= " WHERE type = '".$db->escape($type)."'";
381 $sql .= " AND entity = ".$conf->entity;
382 $resql = $db->query($sql);
383 if ($resql) {
384  $i = 0;
385  $num_rows = $db->num_rows($resql);
386  while ($i < $num_rows) {
387  $array = $db->fetch_array($resql);
388  if (is_array($array)) {
389  array_push($def, $array[0]);
390  }
391  $i++;
392  }
393 } else {
394  dol_print_error($db);
395 }
396 
397 
398 print '<div class="div-table-responsive-no-min">';
399 print '<table class="noborder centpercent">'."\n";
400 print '<tr class="liste_titre">'."\n";
401 print '<td>'.$langs->trans("Name").'</td>';
402 print '<td>'.$langs->trans("Description").'</td>';
403 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
404 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
405 print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
406 print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
407 print "</tr>\n";
408 
409 clearstatcache();
410 
411 foreach ($dirmodels as $reldir) {
412  foreach (array('', '/doc') as $valdir) {
413  $realpath = $reldir."core/modules/commande".$valdir;
414  $dir = dol_buildpath($realpath);
415 
416  if (is_dir($dir)) {
417  $handle = opendir($dir);
418  if (is_resource($handle)) {
419  $filelist = array();
420  while (($file = readdir($handle)) !== false) {
421  $filelist[] = $file;
422  }
423  closedir($handle);
424  arsort($filelist);
425 
426  foreach ($filelist as $file) {
427  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
428  if (file_exists($dir.'/'.$file)) {
429  $name = substr($file, 4, dol_strlen($file) - 16);
430  $classname = substr($file, 0, dol_strlen($file) - 12);
431 
432  require_once $dir.'/'.$file;
433  $module = new $classname($db);
434 
435  $modulequalified = 1;
436  if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
437  $modulequalified = 0;
438  }
439  if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
440  $modulequalified = 0;
441  }
442 
443  if ($modulequalified) {
444  print '<tr class="oddeven"><td width="100">';
445  print(empty($module->name) ? $name : $module->name);
446  print "</td><td>\n";
447  if (method_exists($module, 'info')) {
448  print $module->info($langs);
449  } else {
450  print $module->description;
451  }
452  print '</td>';
453 
454  // Active
455  if (in_array($name, $def)) {
456  print '<td class="center">'."\n";
457  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
458  print img_picto($langs->trans("Enabled"), 'switch_on');
459  print '</a>';
460  print '</td>';
461  } else {
462  print '<td class="center">'."\n";
463  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>';
464  print "</td>";
465  }
466 
467  // Default
468  print '<td class="center">';
469  if (getDolGlobalString('COMMANDE_ADDON_PDF') == $name) {
470  print img_picto($langs->trans("Default"), 'on');
471  } else {
472  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>';
473  }
474  print '</td>';
475 
476  // Info
477  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
478  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
479  if ($module->type == 'pdf') {
480  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
481  }
482  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
483 
484  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
485  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
486  $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
487  $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
488  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
489  //$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
490  //$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
491  $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
492 
493 
494  print '<td class="center">';
495  print $form->textwithpicto('', $htmltooltip, 1, 0);
496  print '</td>';
497 
498  // Preview
499  print '<td class="center">';
500  if ($module->type == 'pdf') {
501  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
502  } else {
503  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
504  }
505  print '</td>';
506 
507  print "</tr>\n";
508  }
509  }
510  }
511  }
512  }
513  }
514  }
515 }
516 
517 print '</table>';
518 print '</div>';
519 
520 
521 /*
522  * Payment mode
523  */
524 
525 print '<br>';
526 print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInOrder"), '', '');
527 
528 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
529 print '<input type="hidden" name="token" value="'.newToken().'" />';
530 
531 print '<div class="div-table-responsive-no-min">';
532 print '<table class="noborder centpercent">';
533 
534 print '<tr class="liste_titre">';
535 print '<td>';
536 print '<input type="hidden" name="action" value="setribchq">';
537 print $langs->trans("PaymentMode").'</td>';
538 print '<td align="right">';
539 if (!isModEnabled('invoice')) {
540  print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
541 }
542 print '</td>';
543 print "</tr>\n";
544 
545 print '<tr class="oddeven">';
546 print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
547 print "<td>";
548 if (!isModEnabled('invoice')) {
549  if (isModEnabled("bank")) {
550  $sql = "SELECT rowid, label";
551  $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
552  $sql .= " WHERE clos = 0";
553  $sql .= " AND courant = 1";
554  $sql .= " AND entity IN (".getEntity('bank_account').")";
555  $resql = $db->query($sql);
556  if ($resql) {
557  $num = $db->num_rows($resql);
558  $i = 0;
559  if ($num > 0) {
560  print '<select name="rib" class="flat" id="rib">';
561  print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
562  while ($i < $num) {
563  $row = $db->fetch_row($resql);
564 
565  print '<option value="'.$row[0].'"';
566  print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
567  print '>'.$row[1].'</option>';
568 
569  $i++;
570  }
571  print "</select>";
572  } else {
573  print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>";
574  }
575  }
576  } else {
577  print '<span class="opacitymedium">'.$langs->trans("BankModuleNotActive").'</span>';
578  }
579 } else {
580  print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
581 }
582 print "</td></tr>";
583 
584 print '<tr class="oddeven">';
585 print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
586 print "<td>";
587 if (!isModEnabled('invoice')) {
588  print '<select class="flat" name="chq" id="chq">';
589  print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
590  print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
591 
592  $sql = "SELECT rowid, label";
593  $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
594  $sql .= " WHERE clos = 0";
595  $sql .= " AND courant = 1";
596  $sql .= " AND entity IN (".getEntity('bank_account').")";
597 
598  $resql = $db->query($sql);
599  if ($resql) {
600  $num = $db->num_rows($resql);
601  $i = 0;
602  while ($i < $num) {
603  $row = $db->fetch_row($resql);
604 
605  print '<option value="'.$row[0].'"';
606  print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
607  print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
608 
609  $i++;
610  }
611  }
612  print "</select>";
613 } else {
614  print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
615 }
616 print "</td></tr>";
617 print "</table>";
618 print '</div>';
619 
620 print "</form>";
621 
622 
623 print '<br>';
624 
625 /*
626  * Other options
627  */
628 
629 print load_fiche_titre($langs->trans("OtherOptions"), '', '');
630 
631 print '<div class="div-table-responsive-no-min">';
632 print '<table class="noborder centpercent">';
633 print '<tr class="liste_titre">';
634 print '<td>'.$langs->trans("Parameter").'</td>';
635 print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
636 print "<td>&nbsp;</td>\n";
637 print "</tr>\n";
638 
639 $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
640 $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
641 $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
642 foreach ($substitutionarray as $key => $val) {
643  $htmltext .= $key.'<br>';
644 }
645 $htmltext .= '</i>';
646 
647 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
648 print '<input type="hidden" name="token" value="'.newToken().'">';
649 print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
650 print '<tr class="oddeven"><td colspan="2">';
651 print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
652 $variablename = 'ORDER_FREE_TEXT';
653 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
654  print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
655 } else {
656  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
657  $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
658  print $doleditor->Create();
659 }
660 print '</td><td class="right">';
661 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
662 print "</td></tr>\n";
663 print '</form>';
664 
665 //Use draft Watermark
666 
667 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
668 print '<input type="hidden" name="token" value="'.newToken().'">';
669 print '<input type="hidden" name="action" value="set_COMMANDE_DRAFT_WATERMARK">';
670 print '<tr class="oddeven"><td>';
671 print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
672 print '</td><td>';
673 print '<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('COMMANDE_DRAFT_WATERMARK')).'">';
674 print '</td><td class="right">';
675 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
676 print "</td></tr>\n";
677 
678 // Allow external download
679 print '<tr class="oddeven">';
680 print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
681 print '<td class="center" colspan="2">';
682 print ajax_constantonoff('ORDER_ALLOW_EXTERNAL_DOWNLOAD', array(), null, 0, 0, 0, 2, 0, 1);
683 print '</td></tr>';
684 print '</form>';
685 
686 /*
687 // Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
688 // TODO Must be implemented by PDF templates
689 // Ask for payment bank during order
690 if (isModEnabled("banque")) {
691 
692  print '<tr class="oddeven"><td>';
693  print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">';
694  if (!empty($conf->use_javascript_ajax)) {
695  print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ORDER');
696  } else {
697  if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER)) {
698  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>';
699  } else {
700  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>';
701  }
702  }
703  print '</td></tr>';
704 } else {
705 
706  print '<tr class="oddeven"><td>';
707  print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
708 }
709 
710 // Ask for warehouse during order
711 if (isModEnabled('stock')) {
712  print '<tr class="oddeven"><td>';
713  print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">';
714  if (!empty($conf->use_javascript_ajax)) {
715  print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
716  } else {
717  if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
718  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>';
719  } else {
720  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>';
721  }
722  }
723  print '</td></tr>';
724 } else {
725  print '<tr class="oddeven"><td>';
726  print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
727 }
728 */
729 
730 print '</table>';
731 print '</div>';
732 
733 print '<br>';
734 
735 
736 /*
737  * Notifications
738  */
739 
740 print load_fiche_titre($langs->trans("Notifications"), '', '');
741 
742 print '<div class="div-table-responsive-no-min">';
743 print '<table class="noborder centpercent">';
744 print '<tr class="liste_titre">';
745 print '<td>'.$langs->trans("Parameter").'</td>';
746 print '<td class="center" width="60"></td>';
747 print '<td width="80">&nbsp;</td>';
748 print "</tr>\n";
749 
750 print '<tr class="oddeven"><td colspan="2">';
751 print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
752 print '</td><td class="right">';
753 print "</td></tr>\n";
754 
755 print '</table>';
756 print '</div>';
757 
758 // End of page
759 llxFooter();
760 $db->close();
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1939
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:655
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:579
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1970
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='inline-block')
On/off button for constant.
Definition: ajax.lib.php:646
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage customers orders.
Class to manage a WYSIWYG editor.
Class to manage generation of HTML components Only common components must be here.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:744
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
order_admin_prepare_head()
Return array head with list of tabs to view object information.
Definition: order.lib.php:178
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:763
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.