dolibarr  19.0.0-dev
html.formcompany.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2008-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
6  * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
34 require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
35 
36 
40 class FormCompany extends Form
41 {
42 
43  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
51  public function typent_array($mode = 0, $filter = '')
52  {
53  // phpcs:enable
54  global $langs, $mysoc;
55 
56  $effs = array();
57 
58  $sql = "SELECT id, code, libelle";
59  $sql .= " FROM " . $this->db->prefix() . "c_typent";
60  $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = " . (empty($mysoc->country_id) ? '0' : $mysoc->country_id) . ")";
61  if ($filter) {
62  $sql .= " " . $filter;
63  }
64  $sql .= " ORDER by position, id";
65  dol_syslog(get_class($this) . '::typent_array', LOG_DEBUG);
66  $resql = $this->db->query($sql);
67  if ($resql) {
68  $num = $this->db->num_rows($resql);
69  $i = 0;
70 
71  while ($i < $num) {
72  $objp = $this->db->fetch_object($resql);
73  if (!$mode) {
74  $key = $objp->id;
75  } else {
76  $key = $objp->code;
77  }
78  if ($langs->trans($objp->code) != $objp->code) {
79  $effs[$key] = $langs->trans($objp->code);
80  } else {
81  $effs[$key] = $objp->libelle;
82  }
83  if ($effs[$key] == '-') {
84  $effs[$key] = '';
85  }
86  $i++;
87  }
88  $this->db->free($resql);
89  }
90 
91  return $effs;
92  }
93 
94  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
102  public function effectif_array($mode = 0, $filter = '')
103  {
104  // phpcs:enable
105  $effs = array();
106 
107  $sql = "SELECT id, code, libelle";
108  $sql .= " FROM " . $this->db->prefix() . "c_effectif";
109  $sql .= " WHERE active = 1";
110  if ($filter) {
111  $sql .= " " . $filter;
112  }
113  $sql .= " ORDER BY id ASC";
114  dol_syslog(get_class($this) . '::effectif_array', LOG_DEBUG);
115  $resql = $this->db->query($sql);
116  if ($resql) {
117  $num = $this->db->num_rows($resql);
118  $i = 0;
119 
120  while ($i < $num) {
121  $objp = $this->db->fetch_object($resql);
122  if (!$mode) {
123  $key = $objp->id;
124  } else {
125  $key = $objp->code;
126  }
127 
128  $effs[$key] = $objp->libelle != '-' ? $objp->libelle : '';
129  $i++;
130  }
131  $this->db->free($resql);
132  }
133  return $effs;
134  }
135 
136 
137  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
147  public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0)
148  {
149  // phpcs:enable
150  global $user, $langs;
151 
152  print '<form method="post" action="' . $page . '">';
153  print '<input type="hidden" name="action" value="setprospectlevel">';
154  print '<input type="hidden" name="token" value="' . newToken() . '">';
155 
156  dol_syslog(get_class($this) . '::form_prospect_level', LOG_DEBUG);
157  $sql = "SELECT code, label";
158  $sql .= " FROM " . $this->db->prefix() . "c_prospectlevel";
159  $sql .= " WHERE active > 0";
160  $sql .= " ORDER BY sortorder";
161  $resql = $this->db->query($sql);
162  if ($resql) {
163  $options = array();
164 
165  if ($empty) {
166  $options[''] = '';
167  }
168 
169  while ($obj = $this->db->fetch_object($resql)) {
170  $level = $langs->trans($obj->code);
171 
172  if ($level == $obj->code) {
173  $level = $langs->trans($obj->label);
174  }
175 
176  $options[$obj->code] = $level;
177  }
178 
179  print Form::selectarray($htmlname, $options, $selected);
180  } else {
181  dol_print_error($this->db);
182  }
183  if (!empty($htmlname) && $user->admin) {
184  print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
185  }
186  print '<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans("Modify") . '">';
187  print '</form>';
188  }
189 
199  public function formProspectContactLevel($page, $selected = '', $htmlname = 'prospect_contact_level_id', $empty = 0)
200  {
201  global $user, $langs;
202 
203  print '<form method="post" action="' . $page . '">';
204  print '<input type="hidden" name="action" value="setprospectcontactlevel">';
205  print '<input type="hidden" name="token" value="' . newToken() . '">';
206 
207  dol_syslog(__METHOD__, LOG_DEBUG);
208  $sql = "SELECT code, label";
209  $sql .= " FROM " . $this->db->prefix() . "c_prospectcontactlevel";
210  $sql .= " WHERE active > 0";
211  $sql .= " ORDER BY sortorder";
212  $resql = $this->db->query($sql);
213  if ($resql) {
214  $options = array();
215 
216  if ($empty) {
217  $options[''] = '';
218  }
219 
220  while ($obj = $this->db->fetch_object($resql)) {
221  $level = $langs->trans($obj->code);
222 
223  if ($level == $obj->code) {
224  $level = $langs->trans($obj->label);
225  }
226 
227  $options[$obj->code] = $level;
228  }
229 
230  print Form::selectarray($htmlname, $options, $selected);
231  } else {
232  dol_print_error($this->db);
233  }
234  if (!empty($htmlname) && $user->admin) {
235  print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
236  }
237  print '<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans("Modify") . '">';
238  print '</form>';
239  }
240 
241  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
253  public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id')
254  {
255  // phpcs:enable
256  print $this->select_state($selected, $country_codeid, $htmlname);
257  }
258 
259  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
273  public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300')
274  {
275  // phpcs:enable
276  global $conf, $langs, $user;
277 
278  dol_syslog(get_class($this) . "::select_departement selected=" . $selected . ", country_codeid=" . $country_codeid, LOG_DEBUG);
279 
280  $langs->load("dict");
281 
282  $out = '';
283 
284  // Serch departements/cantons/province active d'une region et pays actif
285  $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM";
286  $sql .= " " . $this->db->prefix() . "c_departements as d, " . $this->db->prefix() . "c_regions as r," . $this->db->prefix() . "c_country as c";
287  $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
288  $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1";
289  if ($country_codeid && is_numeric($country_codeid)) {
290  $sql .= " AND c.rowid = '" . $this->db->escape($country_codeid) . "'";
291  }
292  if ($country_codeid && !is_numeric($country_codeid)) {
293  $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'";
294  }
295  $sql .= " ORDER BY c.code, d.code_departement";
296 
297  $result = $this->db->query($sql);
298  if ($result) {
299  if (!empty($htmlname)) {
300  $out .= '<select id="' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">';
301  }
302  if ($country_codeid) {
303  $out .= '<option value="0">&nbsp;</option>';
304  }
305  $num = $this->db->num_rows($result);
306  $i = 0;
307  dol_syslog(get_class($this) . "::select_departement num=" . $num, LOG_DEBUG);
308  if ($num) {
309  $country = '';
310  while ($i < $num) {
311  $obj = $this->db->fetch_object($result);
312  if ($obj->code == '0') { // Le code peut etre une chaine
313  $out .= '<option value="0">&nbsp;</option>';
314  } else {
315  if (!$country || $country != $obj->country) {
316  // Show break if we are in list with multiple countries
317  if (!$country_codeid && $obj->country_code) {
318  $out .= '<option value="-1" disabled data-html="----- ' . $obj->country . ' -----">----- ' . $obj->country . " -----</option>\n";
319  $country = $obj->country;
320  }
321  }
322 
323  if (!empty($selected) && $selected == $obj->rowid) {
324  $out .= '<option value="' . $obj->rowid . '" selected>';
325  } else {
326  $out .= '<option value="' . $obj->rowid . '">';
327  }
328 
329  // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
330  if (
331  !empty($conf->global->MAIN_SHOW_STATE_CODE) &&
332  ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')
333  ) {
334  if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) {
335  $out .= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
336  } else {
337  $out .= $obj->code . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
338  }
339  } else {
340  if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) {
341  $out .= $obj->region_name . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
342  } else {
343  $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
344  }
345  }
346 
347  $out .= '</option>';
348  }
349  $i++;
350  }
351  }
352  if (!empty($htmlname)) {
353  $out .= '</select>';
354  }
355  if (!empty($htmlname) && $user->admin) {
356  $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
357  }
358  } else {
359  dol_print_error($this->db);
360  }
361 
362  // Make select dynamic
363  if (!empty($htmlname)) {
364  include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
365  $out .= ajax_combobox($htmlname);
366  }
367 
368  return $out;
369  }
370 
371 
372  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
383  public function select_region($selected = '', $htmlname = 'region_id')
384  {
385  // phpcs:enable
386  global $conf, $langs;
387  $langs->load("dict");
388 
389  $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country";
390  $sql .= " FROM " . $this->db->prefix() . "c_regions as r, " . $this->db->prefix() . "c_country as c";
391  $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1";
392  $sql .= " ORDER BY c.code, c.label ASC";
393 
394  dol_syslog(get_class($this) . "::select_region", LOG_DEBUG);
395  $resql = $this->db->query($sql);
396  if ($resql) {
397  print '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">';
398  $num = $this->db->num_rows($resql);
399  $i = 0;
400  if ($num) {
401  $country = '';
402  while ($i < $num) {
403  $obj = $this->db->fetch_object($resql);
404  if ($obj->code == 0) {
405  print '<option value="0">&nbsp;</option>';
406  } else {
407  if ($country == '' || $country != $obj->country) {
408  // Show break
409  $key = $langs->trans("Country" . strtoupper($obj->country_code));
410  $valuetoshow = ($key != "Country" . strtoupper($obj->country_code)) ? $obj->country_code . " - " . $key : $obj->country;
411  print '<option value="-2" disabled>----- ' . $valuetoshow . " -----</option>\n";
412  $country = $obj->country;
413  }
414 
415  if ($selected > 0 && $selected == $obj->code) {
416  print '<option value="' . $obj->code . '" selected>' . $obj->label . '</option>';
417  } else {
418  print '<option value="' . $obj->code . '">' . $obj->label . '</option>';
419  }
420  }
421  $i++;
422  }
423  }
424  print '</select>';
425  print ajax_combobox($htmlname);
426  } else {
427  dol_print_error($this->db);
428  }
429  }
430 
431  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
441  public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 1)
442  {
443  // phpcs:enable
444  global $conf, $langs, $user;
445  $langs->load("dict");
446 
447  $out = '';
448 
449  $sql = "SELECT rowid, code, label, active FROM " . $this->db->prefix() . "c_civility";
450  $sql .= " WHERE active = 1";
451 
452  dol_syslog("Form::select_civility", LOG_DEBUG);
453  $resql = $this->db->query($sql);
454  if ($resql) {
455  $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
456  $out .= '<option value="">&nbsp;</option>';
457  $num = $this->db->num_rows($resql);
458  $i = 0;
459  if ($num) {
460  while ($i < $num) {
461  $obj = $this->db->fetch_object($resql);
462  if ($selected == $obj->code) {
463  $out .= '<option value="' . $obj->code . '" selected>';
464  } else {
465  $out .= '<option value="' . $obj->code . '">';
466  }
467  // If translation exists, we use it, otherwise, we use tha had coded label
468  $out .= ($langs->trans("Civility" . $obj->code) != "Civility" . $obj->code ? $langs->trans("Civility" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
469  $out .= '</option>';
470  $i++;
471  }
472  }
473  $out .= '</select>';
474  if ($user->admin) {
475  $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
476  }
477 
478  if ($addjscombo) {
479  // Enhance with select2
480  include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
481  $out .= ajax_combobox($htmlname);
482  }
483  } else {
484  dol_print_error($this->db);
485  }
486 
487  return $out;
488  }
489 
490  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
502  public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '')
503  {
504  // phpcs:enable
505  print $this->select_juridicalstatus($selected, $country_codeid, $filter);
506  }
507 
508  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
520  public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '')
521  {
522  // phpcs:enable
523  global $conf, $langs, $user;
524  $langs->load("dict");
525 
526  $out = '';
527 
528  // On recherche les formes juridiques actives des pays actifs
529  $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code";
530  $sql .= " FROM " . $this->db->prefix() . "c_forme_juridique as f, " . $this->db->prefix() . "c_country as c";
531  $sql .= " WHERE f.fk_pays=c.rowid";
532  $sql .= " AND f.active = 1 AND c.active = 1";
533  if ($country_codeid) {
534  $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'";
535  }
536  if ($filter) {
537  $sql .= " " . $filter;
538  }
539  $sql .= " ORDER BY c.code";
540 
541  dol_syslog(get_class($this) . "::select_juridicalstatus", LOG_DEBUG);
542  $resql = $this->db->query($sql);
543  if ($resql) {
544  $out .= '<div id="particulier2" class="visible">';
545  $out .= '<select class="flat minwidth200' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
546  if ($country_codeid) {
547  $out .= '<option value="0">&nbsp;</option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select.
548  }
549 
550  $num = $this->db->num_rows($resql);
551  if ($num) {
552  $i = 0;
553  $country = '';
554  $arraydata = array();
555  while ($i < $num) {
556  $obj = $this->db->fetch_object($resql);
557 
558  if ($obj->code) { // We exclude empty line, we will add it later
559  $labelcountry = (($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) ? $langs->trans("Country" . $obj->country_code) : $obj->country);
560  $labeljs = (($langs->trans("JuridicalStatus" . $obj->code) != "JuridicalStatus" . $obj->code) ? $langs->trans("JuridicalStatus" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver)
561  $arraydata[$obj->code] = array('code' => $obj->code, 'label' => $labeljs, 'label_sort' => $labelcountry . '_' . $labeljs, 'country_code' => $obj->country_code, 'country' => $labelcountry);
562  }
563  $i++;
564  }
565 
566  $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC');
567  if (empty($country_codeid)) { // Introduce empty value (if $country_codeid not empty, empty value was already added)
568  $arraydata[0] = array('code' => 0, 'label' => '', 'label_sort' => '_', 'country_code' => '', 'country' => '');
569  }
570 
571  foreach ($arraydata as $key => $val) {
572  if (!$country || $country != $val['country']) {
573  // Show break when we are in multi country mode
574  if (empty($country_codeid) && $val['country_code']) {
575  $out .= '<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val['country'] . " -----</option>\n";
576  $country = $val['country'];
577  }
578  }
579 
580  if ($selected > 0 && $selected == $val['code']) {
581  $out .= '<option value="' . $val['code'] . '" selected>';
582  } else {
583  $out .= '<option value="' . $val['code'] . '">';
584  }
585  // If translation exists, we use it, otherwise we use default label in database
586  $out .= $val['label'];
587  $out .= '</option>';
588  }
589  }
590  $out .= '</select>';
591  if ($user->admin) {
592  $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
593  }
594 
595  // Make select dynamic
596  include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
597  $out .= ajax_combobox($htmlname);
598 
599  $out .= '</div>';
600  } else {
601  dol_print_error($this->db);
602  }
603 
604  return $out;
605  }
606 
607 
621  public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '')
622  {
623  global $conf, $hookmanager;
624 
625  if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
626  // Use Ajax search
627  $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
628 
629  $socid = 0;
630  $name = '';
631  if ($selected > 0) {
632  $tmpthirdparty = new Societe($this->db);
633  $result = $tmpthirdparty->fetch($selected);
634  if ($result > 0) {
635  $socid = $selected;
636  $name = $tmpthirdparty->name;
637  }
638  }
639 
640 
641  $events = array();
642  // Add an entry 'method' to say 'yes, we must execute url with param action = method';
643  // Add an entry 'url' to say which url to execute
644  // Add an entry htmlname to say which element we must change once url is called
645  // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
646  // To refresh contacts list on thirdparty list change
647  $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
648 
649  if (count($events)) { // If there is some ajax events to run once selection is done, we add code here to run events
650  print '<script nonce="' . getNonce() . '" type="text/javascript">
651  jQuery(document).ready(function() {
652  $("#search_' . $htmlname . '").change(function() {
653  var obj = ' . json_encode($events) . ';
654  $.each(obj, function(key,values) {
655  if (values.method.length) {
656  runJsCodeForEvent' . $htmlname . '(values);
657  }
658  });
659 
660  $(this).trigger("blur");
661  });
662 
663  // Function used to execute events when search_htmlname change
664  function runJsCodeForEvent' . $htmlname . '(obj) {
665  var id = $("#' . $htmlname . '").val();
666  var method = obj.method;
667  var url = obj.url;
668  var htmlname = obj.htmlname;
669  var showempty = obj.showempty;
670  console.log("Run runJsCodeForEvent-' . $htmlname . ' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
671  $.getJSON(url,
672  {
673  action: method,
674  id: id,
675  htmlname: htmlname
676  },
677  function(response) {
678  if (response != null)
679  {
680  console.log("Change select#"+htmlname+" with content "+response.value)
681  $.each(obj.params, function(key,action) {
682  if (key.length) {
683  var num = response.num;
684  if (num > 0) {
685  $("#" + key).removeAttr(action);
686  } else {
687  $("#" + key).attr(action, action);
688  }
689  }
690  });
691  $("select#" + htmlname).html(response.value);
692  }
693  }
694  );
695  }
696  });
697  </script>';
698  }
699 
700  print "\n" . '<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' . "\n";
701  print '<input type="text" size="30" id="search_' . $htmlname . '" name="search_' . $htmlname . '" value="' . $name . '" />';
702  print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT . '/societe/ajax/ajaxcompanies.php', '', $minLength, 0);
703  return $socid;
704  } else {
705  // Search to list thirdparties
706  $sql = "SELECT s.rowid, s.nom as name ";
707  if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
708  $sql .= ", s.code_client, s.code_fournisseur";
709  }
710  if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
711  $sql .= ", s.address, s.zip, s.town";
712  $sql .= ", dictp.code as country_code";
713  }
714  $sql .= " FROM " . $this->db->prefix() . "societe as s";
715  if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
716  $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays";
717  }
718  $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")";
719  // For ajax search we limit here. For combo list, we limit later
720  if (is_array($limitto) && count($limitto)) {
721  $sql .= " AND s.rowid IN (" . $this->db->sanitize(join(',', $limitto)) . ")";
722  }
723  // Add where from hooks
724  $parameters = array();
725  $reshook = $hookmanager->executeHooks('selectCompaniesForNewContactListWhere', $parameters); // Note that $action and $object may have been modified by hook
726  $sql .= $hookmanager->resPrint;
727  $sql .= " ORDER BY s.nom ASC";
728 
729  $resql = $this->db->query($sql);
730  if ($resql) {
731  print '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '"';
732  if ($conf->use_javascript_ajax) {
733  $javaScript = "window.location='" . dol_escape_js($_SERVER['PHP_SELF']) . "?" . $var_id . "=" . ($forceid > 0 ? $forceid : $object->id) . $moreparam . "&" . $htmlname . "=' + form." . $htmlname . ".options[form." . $htmlname . ".selectedIndex].value;";
734  print ' onChange="' . $javaScript . '"';
735  }
736  print '>';
737  print '<option value="-1">&nbsp;</option>';
738 
739  $num = $this->db->num_rows($resql);
740  $i = 0;
741  if ($num) {
742  while ($i < $num) {
743  $obj = $this->db->fetch_object($resql);
744  if ($i == 0) {
745  $firstCompany = $obj->rowid;
746  }
747  $disabled = 0;
748  if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
749  $disabled = 1;
750  }
751  if ($selected > 0 && $selected == $obj->rowid) {
752  print '<option value="' . $obj->rowid . '"';
753  if ($disabled) {
754  print ' disabled';
755  }
756  print ' selected>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . '</option>';
757  $firstCompany = $obj->rowid;
758  } else {
759  print '<option value="' . $obj->rowid . '"';
760  if ($disabled) {
761  print ' disabled';
762  }
763  print '>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . '</option>';
764  }
765  $i++;
766  }
767  }
768  print "</select>\n";
769  print ajax_combobox($htmlname);
770  return $firstCompany;
771  } else {
772  dol_print_error($this->db);
773  return 0;
774  }
775  }
776  }
777 
792  public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '', $output = 1, $forcehidetooltip = 0)
793  {
794  global $user, $langs;
795 
796  $out = '';
797  if (is_object($object) && method_exists($object, 'liste_type_contact')) {
798  $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1);
799 
800  $out .= '<select class="flat valignmiddle' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
801  if ($showempty) {
802  $out .= '<option value="0">&nbsp;</option>';
803  }
804  foreach ($lesTypes as $key => $value) {
805  $out .= '<option value="' . $key . '"';
806  if ($key == $selected) {
807  $out .= ' selected';
808  }
809  $out .= '>' . $value . '</option>';
810  }
811  $out .= "</select>";
812  if ($user->admin && empty($forcehidetooltip)) {
813  $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
814  }
815 
816  $out .= ajax_combobox($htmlname);
817 
818  $out .= "\n";
819  }
820  if (empty($output)) {
821  return $out;
822  } else {
823  print $out;
824  }
825  }
826 
837  public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array(), $morecss = 'minwidth500')
838  {
839  if ($rendermode === 'view') {
840  $toprint = array();
841  foreach ($contact->roles as $key => $val) {
842  $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val['label'] . '</li>';
843  }
844  return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname . '"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
845  }
846 
847  if ($rendermode === 'edit') {
848  $contactType = $contact->listeTypeContacts('external', '', 1, '', '', 'agenda'); // We exclude agenda as there is no contact on such element
849  if (count($selected) > 0) {
850  $newselected = array();
851  foreach ($selected as $key => $val) {
852  if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) {
853  $newselected[] = $val['id'];
854  } else {
855  break;
856  }
857  }
858  if (count($newselected) > 0) {
859  $selected = $newselected;
860  }
861  }
862  return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss);
863  }
864 
865  return 'ErrorBadValueForParameterRenderMode'; // Should not happened
866  }
867 
868  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
881  public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
882  {
883  // phpcs:enable
884  global $conf;
885 
886  $out = '';
887 
888  $size = '';
889  if (!empty($fieldsize)) {
890  $size = 'size="' . $fieldsize . '"';
891  }
892 
893  if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
894  $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT . '/core/ajax/ziptown.php') . "\n";
895  $moreattrib .= ' autocomplete="off"';
896  }
897  $out .= '<input id="' . $htmlname . '" class="maxwidthonsmartphone' . ($morecss ? ' ' . $morecss : '') . '" type="text"' . ($moreattrib ? ' ' . $moreattrib : '') . ' name="' . $htmlname . '" ' . $size . ' value="' . $selected . '">' . "\n";
898 
899  return $out;
900  }
901 
902  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
913  public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth200')
914  {
915  // phpcs:enable
916  global $conf, $langs, $hookmanager;
917 
918  $formlength = 0;
919  if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
920  if ($country_code == 'FR') {
921  if (isset($idprof)) {
922  if ($idprof == 1) {
923  $formlength = 9;
924  } elseif ($idprof == 2) {
925  $formlength = 14;
926  } elseif ($idprof == 3) {
927  $formlength = 5; // 4 chiffres et 1 lettre depuis janvier
928  } elseif ($idprof == 4) {
929  $formlength = 32; // No maximum as we need to include a town name in this id
930  }
931  }
932  } elseif ($country_code == 'ES') {
933  if ($idprof == 1) {
934  $formlength = 9; //CIF/NIF/NIE 9 digits
935  }
936  if ($idprof == 2) {
937  $formlength = 12; //NASS 12 digits without /
938  }
939  if ($idprof == 3) {
940  $formlength = 5; //CNAE 5 digits
941  }
942  if ($idprof == 4) {
943  $formlength = 32; //depend of college
944  }
945  }
946  }
947 
948  $selected = $preselected;
949  if (!$selected && isset($idprof)) {
950  if ($idprof == 1 && !empty($this->idprof1)) {
951  $selected = $this->idprof1;
952  } elseif ($idprof == 2 && !empty($this->idprof2)) {
953  $selected = $this->idprof2;
954  } elseif ($idprof == 3 && !empty($this->idprof3)) {
955  $selected = $this->idprof3;
956  } elseif ($idprof == 4 && !empty($this->idprof4)) {
957  $selected = $this->idprof4;
958  }
959  }
960 
961  $maxlength = $formlength;
962  if (empty($formlength)) {
963  $formlength = 24;
964  $maxlength = 128;
965  }
966 
967  $out = '';
968 
969  // Execute hook getInputIdProf to complete or replace $out
970  $parameters = array('formlength' => $formlength, 'selected' => $preselected, 'idprof' => $idprof, 'htmlname' => $htmlname, 'country_code' => $country_code);
971  $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
972  if (empty($reshook)) {
973  $out .= '<input type="text" ' . ($morecss ? 'class="' . $morecss . '" ' : '') . 'name="' . $htmlname . '" id="' . $htmlname . '" maxlength="' . $maxlength . '" value="' . $selected . '">';
974  }
975  $out .= $hookmanager->resPrint;
976 
977  return $out;
978  }
979 
980  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
989  public function select_localtax($local, $selected, $htmlname)
990  {
991  // phpcs:enable
992  $tax = get_localtax_by_third($local);
993 
994  if ($tax) {
995  $valors = explode(":", $tax);
996  $nbvalues = count($valors);
997 
998  if ($nbvalues > 1) {
999  //montar select
1000  print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
1001  $i = 0;
1002  while ($i < $nbvalues) {
1003  if ($selected == $valors[$i]) {
1004  print '<option value="' . $valors[$i] . '" selected>';
1005  } else {
1006  print '<option value="' . $valors[$i] . '">';
1007  }
1008  print $valors[$i];
1009  print '</option>';
1010  $i++;
1011  }
1012  print '</select>';
1013  }
1014  }
1015  }
1016 
1028  public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '', $allowempty = '')
1029  {
1030  global $conf, $langs;
1031  if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && !isModEnabled('fournisseur')) {
1032  return '';
1033  }
1034 
1035  $out = '<select class="flat ' . $morecss . '" name="' . $htmlname . '" id="' . $htmlidname . '">';
1036  if ($typeinput == 'form') {
1037  if ($allowempty || ($selected == '' || $selected == '-1')) {
1038  $out .= '<option value="-1">';
1039  if (is_numeric($allowempty)) {
1040  $out .= '&nbsp;';
1041  } else {
1042  $out .= $langs->trans($allowempty);
1043  }
1044  $out .= '</option>';
1045  }
1046  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
1047  $out .= '<option value="2"' . ($selected == 2 ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1048  }
1049  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
1050  $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1051  }
1052  if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
1053  $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1054  }
1055  $out .= '<option value="0"' . ((string) $selected == '0' ? ' selected' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
1056  } elseif ($typeinput == 'list') {
1057  $out .= '<option value="-1"' . (($selected == '' || $selected == '-1') ? ' selected' : '') . '>&nbsp;</option>';
1058  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
1059  $out .= '<option value="2,3"' . ($selected == '2,3' ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1060  }
1061  if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
1062  $out .= '<option value="1,3"' . ($selected == '1,3' ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1063  }
1064  if (isModEnabled("fournisseur")) {
1065  $out .= '<option value="4"' . ($selected == '4' ? ' selected' : '') . '>' . $langs->trans('Supplier') . '</option>';
1066  }
1067  $out .= '<option value="0"' . ($selected == '0' ? ' selected' : '') . '>' . $langs->trans('Other') . '</option>';
1068  } elseif ($typeinput == 'admin') {
1069  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
1070  $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1071  }
1072  if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
1073  $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1074  }
1075  }
1076  $out .= '</select>';
1077  $out .= ajax_combobox($htmlidname);
1078 
1079  return $out;
1080  }
1081 
1092  public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0)
1093  {
1094  // phpcs:enable
1095  global $conf, $langs;
1096 
1097  $out = '';
1098  if ($htmlname != "none") {
1099  $out .= '<form method="post" action="' . $page . '">';
1100  $out .= '<input type="hidden" name="action" value="set_thirdpartytype">';
1101  $out .= '<input type="hidden" name="token" value="' . newToken() . '">';
1102  $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
1103  $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
1104  $out .= '<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans("Modify") . '">';
1105  $out .= '</form>';
1106  } else {
1107  if ($selected > 0) {
1108  $arr = $this->typent_array(0);
1109  $typent = $arr[$selected];
1110  $out .= $typent;
1111  } else {
1112  $out .= "&nbsp;";
1113  }
1114  }
1115 
1116  if ($nooutput) {
1117  return $out;
1118  } else {
1119  print $out;
1120  }
1121  }
1122 
1133  public function selectProspectStatus($htmlname, Societe $prospectstatic, $statusprospect, $idprospect, $mode = "html")
1134  {
1135  global $langs;
1136 
1137  if ($mode === "html") {
1138  $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['code'];
1139  $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect]['picto']) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['picto'];
1140 
1141  //print $prospectstatic->LibProspCommStatut($statusprospect, 2, $prospectstatic->cacheprospectstatus[$statusprospect]['label'], $prospectstatic->cacheprospectstatus[$statusprospect]['picto']);
1142  print img_action('', $actioncode, $actionpicto, 'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1143  print '<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .'" data-socid="'.$idprospect.'" name="' . $htmlname .'">';
1144  foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1145  $titlealt = (empty($val['label']) ? 'default' : $val['label']);
1146  $label = $val['label'];
1147  if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1148  $titlealt = $val['label'];
1149  $label = (($langs->trans("StatusProspect".$val['code']) != "StatusProspect".$val['code']) ? $langs->trans("StatusProspect".$val['code']) : $label);
1150  } else {
1151  $label = (($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id']) ? $langs->trans("StatusProspect".$val['id']) : $label);
1152  }
1153  print '<option value="'.$val['id'].'" data-html="'.dol_escape_htmltag(img_action('', $val['code'], $val['picto']).' '.$label).'" title="'.dol_escape_htmltag($label).'"'.($statusprospect == $val['id'] ? ' selected' : '').'>';
1154  print dol_escape_htmltag($label);
1155  print '</option>';
1156  }
1157  print '</select>';
1158  print ajax_combobox($htmlname.$idprospect);
1159  } elseif ($mode === "js") {
1160  print '<script>
1161  jQuery(document).ready(function() {
1162  $(".selectprospectstatus").on("change", function() {
1163  console.log("We change a value into a field selectprospectstatus");
1164  var statusid = $(this).val();
1165  var prospectid = $(this).attr("data-socid");
1166  var image = $(this).prev(".pictoprospectstatus");
1167  $.ajax({
1168  type: "POST",
1169  url: \'' . DOL_URL_ROOT . '/core/ajax/ajaxstatusprospect.php\',
1170  data: { id: statusid, prospectid: prospectid, token: \''. newToken() .'\', action: \'updatestatusprospect\' },
1171  success: function(response) {
1172  console.log(response.img);
1173  image.replaceWith(response.img);
1174  },
1175  error: function() {
1176  console.error("Error on status prospect");
1177  },
1178  });
1179  });
1180  });
1181  </script>';
1182  }
1183  }
1184 }
ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams='')
Generic function that return javascript to add to a page to transform a common input field into an au...
Definition: ajax.lib.php:47
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:449
ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLength=2, $autoselect=0)
Generic function that return javascript to add to a page to transform a common input field into an au...
Definition: ajax.lib.php:297
Class to manage contact/addresses.
Class to build HTML component for third parties management Only common components are here.
select_civility($selected='', $htmlname='civility_id', $morecss='maxwidth150', $addjscombo=1)
Return combo list with people title.
select_ziptown($selected='', $htmlname='zipcode', $fields=array(), $fieldsize=0, $disableautocomplete=0, $moreattrib='', $morecss='')
Return a select list with zip codes and their town.
select_region($selected='', $htmlname='region_id')
Retourne la liste deroulante des regions actives dont le pays est actif La cle de la liste est le cod...
select_departement($selected='', $country_codeid=0, $htmlname='state_id')
Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='', $morecss='')
Output list of third parties.
effectif_array($mode=0, $filter='')
Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
formThirdpartyType($page, $selected='', $htmlname='socid', $filter='', $nooutput=0)
Output html select to select third-party type.
form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0)
Affiche formulaire de selection des modes de reglement.
select_localtax($local, $selected, $htmlname)
Return a HTML select with localtax values for thirdparties.
selectProspectCustomerType($selected, $htmlname='client', $htmlidname='customerprospect', $typeinput='form', $morecss='', $allowempty='')
Return a HTML select for thirdparty type.
selectProspectStatus($htmlname, Societe $prospectstatic, $statusprospect, $idprospect, $mode="html")
Output html select to select prospect status.
select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code', $morecss='')
Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
select_forme_juridique($selected='', $country_codeid=0, $filter='')
Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
showRoles($htmlname, Contact $contact, $rendermode='view', $selected=array(), $morecss='minwidth500')
showContactRoles on view and edit mode
selectTypeContact($object, $selected, $htmlname='type', $source='internal', $sortorder='position', $showempty=0, $morecss='', $output=1, $forcehidetooltip=0)
Return a select list with types of contacts.
typent_array($mode=0, $filter='')
Return list of labels (translated) of third parties type.
get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss='maxwidth200')
Return HTML string to use as input of professional id into a HTML page (siren, siret,...
formProspectContactLevel($page, $selected='', $htmlname='prospect_contact_level_id', $empty=0)
Affiche formulaire de selection des niveau de prospection pour les contacts.
select_state($selected=0, $country_codeid=0, $htmlname='state_id', $morecss='maxwidth200onsmartphone minwidth300')
Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
Class to manage generation of HTML components Only common components must be here.
static selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='minwidth75', $addjscombo=1, $moreparamonempty='', $disablebademail=0, $nohtmlescape=0)
Return a HTML select string, built from an array of key+value.
static multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=-1)
Show a multiselect form from an array.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') && $user->hasRight('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') && $user->hasRight('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)) $sql
Social contributions to pay.
Definition: index.php:746
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
get_localtax_by_third($local)
Get values of localtaxes (1 or 2) for company country for the common vat with the highest value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getNonce()
Return a random string to be used as a nonce value for js.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...