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