dolibarr  20.0.0-alpha
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  * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
35 require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
36 
37 
41 class FormCompany extends Form
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 as label";
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->label;
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 as label";
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->label != '-' ? $objp->label : '';
129  $i++;
130  }
131  $this->db->free($resql);
132  }
133  //return natural sorted list
134  natsort($effs);
135  return $effs;
136  }
137 
138 
139  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
149  public function form_prospect_level($page, $selected = 0, $htmlname = 'prospect_level_id', $empty = 0)
150  {
151  // phpcs:enable
152  global $user, $langs;
153 
154  print '<form method="post" action="' . $page . '">';
155  print '<input type="hidden" name="action" value="setprospectlevel">';
156  print '<input type="hidden" name="token" value="' . newToken() . '">';
157 
158  dol_syslog(get_class($this) . '::form_prospect_level', LOG_DEBUG);
159  $sql = "SELECT code, label";
160  $sql .= " FROM " . $this->db->prefix() . "c_prospectlevel";
161  $sql .= " WHERE active > 0";
162  $sql .= " ORDER BY sortorder";
163  $resql = $this->db->query($sql);
164  if ($resql) {
165  $options = array();
166 
167  if ($empty) {
168  $options[''] = '';
169  }
170 
171  while ($obj = $this->db->fetch_object($resql)) {
172  $level = $langs->trans($obj->code);
173 
174  if ($level == $obj->code) {
175  $level = $langs->trans($obj->label);
176  }
177 
178  $options[$obj->code] = $level;
179  }
180 
181  print Form::selectarray($htmlname, $options, $selected);
182  } else {
183  dol_print_error($this->db);
184  }
185  if (!empty($htmlname) && $user->admin) {
186  print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
187  }
188  print '<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans("Modify") . '">';
189  print '</form>';
190  }
191 
201  public function formProspectContactLevel($page, $selected = 0, $htmlname = 'prospect_contact_level_id', $empty = 0)
202  {
203  global $user, $langs;
204 
205  print '<form method="post" action="' . $page . '">';
206  print '<input type="hidden" name="action" value="setprospectcontactlevel">';
207  print '<input type="hidden" name="token" value="' . newToken() . '">';
208 
209  dol_syslog(__METHOD__, LOG_DEBUG);
210  $sql = "SELECT code, label";
211  $sql .= " FROM " . $this->db->prefix() . "c_prospectcontactlevel";
212  $sql .= " WHERE active > 0";
213  $sql .= " ORDER BY sortorder";
214  $resql = $this->db->query($sql);
215  if ($resql) {
216  $options = array();
217 
218  if ($empty) {
219  $options[''] = '';
220  }
221 
222  while ($obj = $this->db->fetch_object($resql)) {
223  $level = $langs->trans($obj->code);
224 
225  if ($level == $obj->code) {
226  $level = $langs->trans($obj->label);
227  }
228 
229  $options[$obj->code] = $level;
230  }
231 
232  print Form::selectarray($htmlname, $options, $selected);
233  } else {
234  dol_print_error($this->db);
235  }
236  if (!empty($htmlname) && $user->admin) {
237  print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
238  }
239  print '<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans("Modify") . '">';
240  print '</form>';
241  }
242 
243  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
255  public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id')
256  {
257  // phpcs:enable
258  print $this->select_state($selected, $country_codeid, $htmlname);
259  }
260 
261  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
275  public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300')
276  {
277  // phpcs:enable
278  global $conf, $langs, $user;
279 
280  dol_syslog(get_class($this) . "::select_departement selected=" . $selected . ", country_codeid=" . $country_codeid, LOG_DEBUG);
281 
282  $langs->load("dict");
283 
284  $out = '';
285 
286  // Search departements/cantons/province active d'une region et pays actif
287  $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";
288  $sql .= " " . $this->db->prefix() . "c_departements as d, " . $this->db->prefix() . "c_regions as r," . $this->db->prefix() . "c_country as c";
289  $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
290  $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1";
291  if ($country_codeid && is_numeric($country_codeid)) {
292  $sql .= " AND c.rowid = '" . $this->db->escape($country_codeid) . "'";
293  }
294  if ($country_codeid && !is_numeric($country_codeid)) {
295  $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'";
296  }
297  $sql .= " ORDER BY c.code, d.code_departement";
298 
299  $result = $this->db->query($sql);
300  if ($result) {
301  if (!empty($htmlname)) {
302  $out .= '<select id="' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">';
303  }
304  if ($country_codeid) {
305  $out .= '<option value="0">&nbsp;</option>';
306  }
307  $num = $this->db->num_rows($result);
308  $i = 0;
309  dol_syslog(get_class($this) . "::select_departement num=" . $num, LOG_DEBUG);
310  if ($num) {
311  $country = '';
312  while ($i < $num) {
313  $obj = $this->db->fetch_object($result);
314  if ($obj->code == '0') { // Le code peut etre une chaine
315  $out .= '<option value="0">&nbsp;</option>';
316  } else {
317  if (!$country || $country != $obj->country) {
318  // Show break if we are in list with multiple countries
319  if (!$country_codeid && $obj->country_code) {
320  $out .= '<option value="-1" disabled data-html="----- ' . $obj->country . ' -----">----- ' . $obj->country . " -----</option>\n";
321  $country = $obj->country;
322  }
323  }
324 
325  if (!empty($selected) && $selected == $obj->rowid) {
326  $out .= '<option value="' . $obj->rowid . '" selected>';
327  } else {
328  $out .= '<option value="' . $obj->rowid . '">';
329  }
330 
331  // Si traduction existe, on l'utilise, sinon on prend le libelle par default
332  if (
333  getDolGlobalString('MAIN_SHOW_STATE_CODE') &&
334  (getDolGlobalInt('MAIN_SHOW_STATE_CODE') == 1 || getDolGlobalInt('MAIN_SHOW_STATE_CODE') == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')
335  ) {
336  if (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1) {
337  $out .= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
338  } else {
339  $out .= $obj->code . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
340  }
341  } else {
342  if (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1) {
343  $out .= $obj->region_name . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
344  } else {
345  $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
346  }
347  }
348 
349  $out .= '</option>';
350  }
351  $i++;
352  }
353  }
354  if (!empty($htmlname)) {
355  $out .= '</select>';
356  }
357  if (!empty($htmlname) && $user->admin) {
358  $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
359  }
360  } else {
361  dol_print_error($this->db);
362  }
363 
364  // Make select dynamic
365  if (!empty($htmlname)) {
366  include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
367  $out .= ajax_combobox($htmlname);
368  }
369 
370  return $out;
371  }
372 
373  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
388  public function select_state_ajax($parent_field_id = 'country_id', $selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300')
389  {
390  $html = '<script>';
391  $html.='$("select[name=\"'.$parent_field_id.'\"]").change(function(){
392  $.ajax( "'.dol_buildpath('/core/ajax/ziptown.php', 2).'", { data:{ selected: $("select[name=\"'.$htmlname.'\"]").val(), country_codeid: $(this).val(), htmlname:"'.$htmlname.'", morecss:"'.$morecss.'" } } )
393  .done(function(msg) {
394  $("span#target_'.$htmlname.'").html(msg);
395  })
396  });';
397  return $html.'</script><span id="target_'.$htmlname.'">'.$this->select_state($selected, $country_codeid, $htmlname, $morecss).'</span>';
398  }
399 
400  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
411  public function select_region($selected = '', $htmlname = 'region_id')
412  {
413  // phpcs:enable
414  global $conf, $langs;
415  $langs->load("dict");
416 
417  $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country";
418  $sql .= " FROM " . $this->db->prefix() . "c_regions as r, " . $this->db->prefix() . "c_country as c";
419  $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1";
420  $sql .= " ORDER BY c.code, c.label ASC";
421 
422  dol_syslog(get_class($this) . "::select_region", LOG_DEBUG);
423  $resql = $this->db->query($sql);
424  if ($resql) {
425  print '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">';
426  $num = $this->db->num_rows($resql);
427  $i = 0;
428  if ($num) {
429  $country = '';
430  while ($i < $num) {
431  $obj = $this->db->fetch_object($resql);
432  if ($obj->code == 0) {
433  print '<option value="0">&nbsp;</option>';
434  } else {
435  if ($country == '' || $country != $obj->country) {
436  // Show break
437  $key = $langs->trans("Country" . strtoupper($obj->country_code));
438  $valuetoshow = ($key != "Country" . strtoupper($obj->country_code)) ? $obj->country_code . " - " . $key : $obj->country;
439  print '<option value="-2" disabled>----- ' . $valuetoshow . " -----</option>\n";
440  $country = $obj->country;
441  }
442 
443  if ($selected > 0 && $selected == $obj->code) {
444  print '<option value="' . $obj->code . '" selected>' . $obj->label . '</option>';
445  } else {
446  print '<option value="' . $obj->code . '">' . $obj->label . '</option>';
447  }
448  }
449  $i++;
450  }
451  }
452  print '</select>';
453  print ajax_combobox($htmlname);
454  } else {
455  dol_print_error($this->db);
456  }
457  }
458 
459  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
469  public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 1)
470  {
471  // phpcs:enable
472  global $conf, $langs, $user;
473  $langs->load("dict");
474 
475  $out = '';
476 
477  $sql = "SELECT rowid, code, label, active FROM " . $this->db->prefix() . "c_civility";
478  $sql .= " WHERE active = 1";
479 
480  dol_syslog("Form::select_civility", LOG_DEBUG);
481  $resql = $this->db->query($sql);
482  if ($resql) {
483  $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
484  $out .= '<option value="">&nbsp;</option>';
485  $num = $this->db->num_rows($resql);
486  $i = 0;
487  if ($num) {
488  while ($i < $num) {
489  $obj = $this->db->fetch_object($resql);
490  if ($selected == $obj->code) {
491  $out .= '<option value="' . $obj->code . '" selected>';
492  } else {
493  $out .= '<option value="' . $obj->code . '">';
494  }
495  // If translation exists, we use it, otherwise, we use the hard coded label
496  $out .= ($langs->trans("Civility" . $obj->code) != "Civility" . $obj->code ? $langs->trans("Civility" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
497  $out .= '</option>';
498  $i++;
499  }
500  }
501  $out .= '</select>';
502  if ($user->admin) {
503  $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
504  }
505 
506  if ($addjscombo) {
507  // Enhance with select2
508  include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
509  $out .= ajax_combobox($htmlname);
510  }
511  } else {
512  dol_print_error($this->db);
513  }
514 
515  return $out;
516  }
517 
518  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
530  public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '')
531  {
532  // phpcs:enable
533  print $this->select_juridicalstatus($selected, $country_codeid, $filter);
534  }
535 
536  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
548  public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '')
549  {
550  // phpcs:enable
551  global $conf, $langs, $user;
552  $langs->load("dict");
553 
554  $out = '';
555 
556  // Lookup the active juridical types for the active countries
557  $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code";
558  $sql .= " FROM " . $this->db->prefix() . "c_forme_juridique as f, " . $this->db->prefix() . "c_country as c";
559  $sql .= " WHERE f.fk_pays=c.rowid";
560  $sql .= " AND f.active = 1 AND c.active = 1";
561  if ($country_codeid) {
562  $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'";
563  }
564  if ($filter) {
565  $sql .= " " . $filter;
566  }
567  $sql .= " ORDER BY c.code";
568 
569  dol_syslog(get_class($this) . "::select_juridicalstatus", LOG_DEBUG);
570  $resql = $this->db->query($sql);
571  if ($resql) {
572  $out .= '<div id="particulier2" class="visible">';
573  $out .= '<select class="flat minwidth200' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
574  if ($country_codeid) {
575  $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.
576  }
577 
578  $num = $this->db->num_rows($resql);
579  if ($num) {
580  $i = 0;
581  $country = '';
582  $arraydata = array();
583  while ($i < $num) {
584  $obj = $this->db->fetch_object($resql);
585 
586  if ($obj->code) { // We exclude empty line, we will add it later
587  $labelcountry = (($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) ? $langs->trans("Country" . $obj->country_code) : $obj->country);
588  $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)
589  $arraydata[$obj->code] = array('code' => $obj->code, 'label' => $labeljs, 'label_sort' => $labelcountry . '_' . $labeljs, 'country_code' => $obj->country_code, 'country' => $labelcountry);
590  }
591  $i++;
592  }
593 
594  $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC');
595  if (empty($country_codeid)) { // Introduce empty value (if $country_codeid not empty, empty value was already added)
596  $arraydata[0] = array('code' => 0, 'label' => '', 'label_sort' => '_', 'country_code' => '', 'country' => '');
597  }
598 
599  foreach ($arraydata as $key => $val) {
600  if (!$country || $country != $val['country']) {
601  // Show break when we are in multi country mode
602  if (empty($country_codeid) && $val['country_code']) {
603  $out .= '<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val['country'] . " -----</option>\n";
604  $country = $val['country'];
605  }
606  }
607 
608  if ($selected > 0 && $selected == $val['code']) {
609  $out .= '<option value="' . $val['code'] . '" selected>';
610  } else {
611  $out .= '<option value="' . $val['code'] . '">';
612  }
613  // If translation exists, we use it, otherwise we use default label in database
614  $out .= $val['label'];
615  $out .= '</option>';
616  }
617  }
618  $out .= '</select>';
619  if ($user->admin) {
620  $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
621  }
622 
623  // Make select dynamic
624  include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
625  $out .= ajax_combobox($htmlname);
626 
627  $out .= '</div>';
628  } else {
629  dol_print_error($this->db);
630  }
631 
632  return $out;
633  }
634 
635 
649  public function selectCompaniesForNewContact($object, $var_id, $selected = 0, $htmlname = 'newcompany', $limitto = [], $forceid = 0, $moreparam = '', $morecss = '')
650  {
651  global $conf, $hookmanager;
652 
653  if (!empty($conf->use_javascript_ajax) && getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) {
654  // Use Ajax search
655  $minLength = (is_numeric(getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
656 
657  $socid = 0;
658  $name = '';
659  if ($selected > 0) {
660  $tmpthirdparty = new Societe($this->db);
661  $result = $tmpthirdparty->fetch($selected);
662  if ($result > 0) {
663  $socid = $selected;
664  $name = $tmpthirdparty->name;
665  }
666  }
667 
668 
669  $events = array();
670  // Add an entry 'method' to say 'yes, we must execute url with param action = method';
671  // Add an entry 'url' to say which url to execute
672  // Add an entry htmlname to say which element we must change once url is called
673  // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
674  // To refresh contacts list on thirdparty list change
675  $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
676 
677  if (count($events)) { // If there is some ajax events to run once selection is done, we add code here to run events
678  print '<script nonce="' . getNonce() . '" type="text/javascript">
679  jQuery(document).ready(function() {
680  $("#search_' . $htmlname . '").change(function() {
681  var obj = ' . json_encode($events) . ';
682  $.each(obj, function(key,values) {
683  if (values.method.length) {
684  runJsCodeForEvent' . $htmlname . '(values);
685  }
686  });
687 
688  $(this).trigger("blur");
689  });
690 
691  // Function used to execute events when search_htmlname change
692  function runJsCodeForEvent' . $htmlname . '(obj) {
693  var id = $("#' . $htmlname . '").val();
694  var method = obj.method;
695  var url = obj.url;
696  var htmlname = obj.htmlname;
697  var showempty = obj.showempty;
698  console.log("Run runJsCodeForEvent-' . $htmlname . ' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
699  $.getJSON(url,
700  {
701  action: method,
702  id: id,
703  htmlname: htmlname
704  },
705  function(response) {
706  if (response != null)
707  {
708  console.log("Change select#"+htmlname+" with content "+response.value)
709  $.each(obj.params, function(key,action) {
710  if (key.length) {
711  var num = response.num;
712  if (num > 0) {
713  $("#" + key).removeAttr(action);
714  } else {
715  $("#" + key).attr(action, action);
716  }
717  }
718  });
719  $("select#" + htmlname).html(response.value);
720  }
721  }
722  );
723  }
724  });
725  </script>';
726  }
727 
728  print "\n" . '<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' . "\n";
729  print '<input type="text" size="30" id="search_' . $htmlname . '" name="search_' . $htmlname . '" value="' . $name . '" />';
730  print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT . '/societe/ajax/ajaxcompanies.php', '', $minLength, 0);
731  return $socid;
732  } else {
733  // Search to list thirdparties
734  $sql = "SELECT s.rowid, s.nom as name ";
735  if (getDolGlobalString('SOCIETE_ADD_REF_IN_LIST')) {
736  $sql .= ", s.code_client, s.code_fournisseur";
737  }
738  if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
739  $sql .= ", s.address, s.zip, s.town";
740  $sql .= ", dictp.code as country_code";
741  }
742  $sql .= " FROM " . $this->db->prefix() . "societe as s";
743  if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
744  $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays";
745  }
746  $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")";
747  // For ajax search we limit here. For combo list, we limit later
748  if (is_array($limitto) && count($limitto)) {
749  $sql .= " AND s.rowid IN (" . $this->db->sanitize(implode(',', $limitto)) . ")";
750  }
751  // Add where from hooks
752  $parameters = array();
753  $reshook = $hookmanager->executeHooks('selectCompaniesForNewContactListWhere', $parameters); // Note that $action and $object may have been modified by hook
754  $sql .= $hookmanager->resPrint;
755  $sql .= " ORDER BY s.nom ASC";
756 
757  $resql = $this->db->query($sql);
758  if ($resql) {
759  print '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '"';
760  if ($conf->use_javascript_ajax) {
761  $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;";
762  print ' onChange="' . $javaScript . '"';
763  }
764  print '>';
765  print '<option value="-1">&nbsp;</option>';
766 
767  $num = $this->db->num_rows($resql);
768  $i = 0;
769  if ($num) {
770  while ($i < $num) {
771  $obj = $this->db->fetch_object($resql);
772  if ($i == 0) {
773  $firstCompany = $obj->rowid;
774  }
775  $disabled = 0;
776  if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
777  $disabled = 1;
778  }
779  if ($selected > 0 && $selected == $obj->rowid) {
780  print '<option value="' . $obj->rowid . '"';
781  if ($disabled) {
782  print ' disabled';
783  }
784  print ' selected>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . '</option>';
785  $firstCompany = $obj->rowid;
786  } else {
787  print '<option value="' . $obj->rowid . '"';
788  if ($disabled) {
789  print ' disabled';
790  }
791  print '>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . '</option>';
792  }
793  $i++;
794  }
795  }
796  print "</select>\n";
797  print ajax_combobox($htmlname);
798  return $firstCompany;
799  } else {
800  dol_print_error($this->db);
801  return 0;
802  }
803  }
804  }
805 
820  public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '', $output = 1, $forcehidetooltip = 0)
821  {
822  global $user, $langs;
823 
824  $out = '';
825  if (is_object($object) && method_exists($object, 'liste_type_contact')) {
826  $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); // List of types into c_type_contact for element=$object->element
827 
828  $out .= '<select class="flat valignmiddle' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
829  if ($showempty) {
830  $out .= '<option value="0">&nbsp;</option>';
831  }
832  foreach ($lesTypes as $key => $value) {
833  $out .= '<option value="' . $key . '"';
834  if ($key == $selected) {
835  $out .= ' selected';
836  }
837  $out .= '>' . $value . '</option>';
838  }
839  $out .= "</select>";
840  if ($user->admin && empty($forcehidetooltip)) {
841  $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
842  }
843 
844  $out .= ajax_combobox($htmlname);
845 
846  $out .= "\n";
847  }
848  if (empty($output)) {
849  return $out;
850  } else {
851  print $out;
852  }
853  }
854 
865  public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array(), $morecss = 'minwidth500')
866  {
867  if ($rendermode === 'view') {
868  $toprint = array();
869  foreach ($contact->roles as $key => $val) {
870  $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val['label'] . '</li>';
871  }
872  return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname . '"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
873  }
874 
875  if ($rendermode === 'edit') {
876  $contactType = $contact->listeTypeContacts('external', '', 1, '', '', 'agenda'); // We exclude agenda as there is no contact on such element
877  if (count($selected) > 0) {
878  $newselected = array();
879  foreach ($selected as $key => $val) {
880  if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) {
881  $newselected[] = $val['id'];
882  } else {
883  break;
884  }
885  }
886  if (count($newselected) > 0) {
887  $selected = $newselected;
888  }
889  }
890  return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss);
891  }
892 
893  return 'ErrorBadValueForParameterRenderMode'; // Should not happened
894  }
895 
896  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
909  public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
910  {
911  // phpcs:enable
912  global $conf;
913 
914  $out = '';
915 
916  $size = '';
917  if (!empty($fieldsize)) {
918  $size = 'size="' . $fieldsize . '"';
919  }
920 
921  if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
922  $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT . '/core/ajax/ziptown.php') . "\n";
923  $moreattrib .= ' autocomplete="off"';
924  }
925  $out .= '<input id="' . $htmlname . '" class="maxwidthonsmartphone' . ($morecss ? ' ' . $morecss : '') . '" type="text"' . ($moreattrib ? ' ' . $moreattrib : '') . ' name="' . $htmlname . '" ' . $size . ' value="' . $selected . '">' . "\n";
926 
927  return $out;
928  }
929 
930  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
941  public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth200')
942  {
943  // phpcs:enable
944  global $conf, $langs, $hookmanager;
945 
946  $formlength = 0;
947  if (!getDolGlobalString('MAIN_DISABLEPROFIDRULES')) {
948  if ($country_code == 'FR') {
949  if (isset($idprof)) {
950  if ($idprof == 1) {
951  $formlength = 9;
952  } elseif ($idprof == 2) {
953  $formlength = 14;
954  } elseif ($idprof == 3) {
955  $formlength = 5; // 4 chiffres et 1 lettre depuis janvier
956  } elseif ($idprof == 4) {
957  $formlength = 32; // No maximum as we need to include a town name in this id
958  }
959  }
960  } elseif ($country_code == 'ES') {
961  if ($idprof == 1) {
962  $formlength = 9; //CIF/NIF/NIE 9 digits
963  }
964  if ($idprof == 2) {
965  $formlength = 12; //NASS 12 digits without /
966  }
967  if ($idprof == 3) {
968  $formlength = 5; //CNAE 5 digits
969  }
970  if ($idprof == 4) {
971  $formlength = 32; //depend of college
972  }
973  }
974  }
975 
976  $selected = $preselected;
977  if (!$selected && isset($idprof)) {
978  if ($idprof == 1 && !empty($this->idprof1)) {
979  $selected = $this->idprof1;
980  } elseif ($idprof == 2 && !empty($this->idprof2)) {
981  $selected = $this->idprof2;
982  } elseif ($idprof == 3 && !empty($this->idprof3)) {
983  $selected = $this->idprof3;
984  } elseif ($idprof == 4 && !empty($this->idprof4)) {
985  $selected = $this->idprof4;
986  }
987  }
988 
989  $maxlength = $formlength;
990  if (empty($formlength)) {
991  $formlength = 24;
992  $maxlength = 128;
993  }
994 
995  $out = '';
996 
997  // Execute hook getInputIdProf to complete or replace $out
998  $parameters = array('formlength' => $formlength, 'selected' => $preselected, 'idprof' => $idprof, 'htmlname' => $htmlname, 'country_code' => $country_code);
999  $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
1000  if (empty($reshook)) {
1001  $out .= '<input type="text" ' . ($morecss ? 'class="' . $morecss . '" ' : '') . 'name="' . $htmlname . '" id="' . $htmlname . '" maxlength="' . $maxlength . '" value="' . $selected . '">';
1002  }
1003  $out .= $hookmanager->resPrint;
1004 
1005  return $out;
1006  }
1007 
1008  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1017  public function select_localtax($local, $selected, $htmlname)
1018  {
1019  // phpcs:enable
1020  $tax = get_localtax_by_third($local);
1021 
1022  if ($tax) {
1023  $valors = explode(":", $tax);
1024  $nbvalues = count($valors);
1025 
1026  if ($nbvalues > 1) {
1027  //montar select
1028  print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
1029  $i = 0;
1030  while ($i < $nbvalues) {
1031  if ($selected == $valors[$i]) {
1032  print '<option value="' . $valors[$i] . '" selected>';
1033  } else {
1034  print '<option value="' . $valors[$i] . '">';
1035  }
1036  print $valors[$i];
1037  print '</option>';
1038  $i++;
1039  }
1040  print '</select>';
1041  }
1042  }
1043  }
1044 
1056  public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '', $allowempty = '')
1057  {
1058  global $conf, $langs;
1059  if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !isModEnabled('fournisseur')) {
1060  return '';
1061  }
1062 
1063  $out = '<select class="flat ' . $morecss . '" name="' . $htmlname . '" id="' . $htmlidname . '">';
1064  if ($typeinput == 'form') {
1065  if ($allowempty || ($selected == '' || $selected == '-1')) {
1066  $out .= '<option value="-1">';
1067  if (is_numeric($allowempty)) {
1068  $out .= '&nbsp;';
1069  } else {
1070  $out .= $langs->trans($allowempty);
1071  }
1072  $out .= '</option>';
1073  }
1074  if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1075  $out .= '<option value="2"' . ($selected == 2 ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1076  }
1077  if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
1078  $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1079  }
1080  if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1081  $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1082  }
1083  $out .= '<option value="0"' . ((string) $selected == '0' ? ' selected' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
1084  } elseif ($typeinput == 'list') {
1085  $out .= '<option value="-1"' . (($selected == '' || $selected == '-1') ? ' selected' : '') . '>&nbsp;</option>';
1086  if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1087  $out .= '<option value="2,3"' . ($selected == '2,3' ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1088  }
1089  if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1090  $out .= '<option value="1,3"' . ($selected == '1,3' ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1091  }
1092  if (isModEnabled("fournisseur")) {
1093  $out .= '<option value="4"' . ($selected == '4' ? ' selected' : '') . '>' . $langs->trans('Supplier') . '</option>';
1094  }
1095  $out .= '<option value="0"' . ($selected == '0' ? ' selected' : '') . '>' . $langs->trans('Other') . '</option>';
1096  } elseif ($typeinput == 'admin') {
1097  if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
1098  $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1099  }
1100  if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1101  $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1102  }
1103  }
1104  $out .= '</select>';
1105  $out .= ajax_combobox($htmlidname);
1106 
1107  return $out;
1108  }
1109 
1120  public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0)
1121  {
1122  // phpcs:enable
1123  global $conf, $langs;
1124 
1125  $out = '';
1126  if ($htmlname != "none") {
1127  $out .= '<form method="post" action="' . $page . '">';
1128  $out .= '<input type="hidden" name="action" value="set_thirdpartytype">';
1129  $out .= '<input type="hidden" name="token" value="' . newToken() . '">';
1130  $sortparam = (!getDolGlobalString('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.
1131  $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
1132  $out .= '<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans("Modify") . '">';
1133  $out .= '</form>';
1134  } else {
1135  if ($selected > 0) {
1136  $arr = $this->typent_array(0);
1137  $typent = $arr[$selected];
1138  $out .= $typent;
1139  } else {
1140  $out .= "&nbsp;";
1141  }
1142  }
1143 
1144  if ($nooutput) {
1145  return $out;
1146  } else {
1147  print $out;
1148  }
1149  }
1150 
1161  public function selectProspectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode = "html")
1162  {
1163  global $user, $langs;
1164 
1165  if ($mode === "html") {
1166  $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['code'];
1167  $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect]['picto']) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['picto'];
1168 
1169  //print $prospectstatic->LibProspCommStatut($statusprospect, 2, $prospectstatic->cacheprospectstatus[$statusprospect]['label'], $prospectstatic->cacheprospectstatus[$statusprospect]['picto']);
1170  print img_action('', $actioncode, $actionpicto, 'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1171  print '<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .'" data-socid="'.$idprospect.'" name="' . $htmlname .'"';
1172  if (!$user->hasRight('societe', 'creer')) {
1173  print ' disabled';
1174  }
1175  print '>';
1176  foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1177  //$titlealt = (empty($val['label']) ? 'default' : $val['label']);
1178  $label = $val['label'];
1179  if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1180  //$titlealt = $val['label'];
1181  $label = (($langs->trans("StatusProspect".$val['code']) != "StatusProspect".$val['code']) ? $langs->trans("StatusProspect".$val['code']) : $label);
1182  } else {
1183  $label = (($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id']) ? $langs->trans("StatusProspect".$val['id']) : $label);
1184  }
1185  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' : '').'>';
1186  print dol_escape_htmltag($label);
1187  print '</option>';
1188  }
1189  print '</select>';
1190  print ajax_combobox($htmlname.$idprospect);
1191  } elseif ($mode === "js") {
1192  print '<script>
1193  jQuery(document).ready(function() {
1194  $(".selectprospectstatus").on("change", function() {
1195  console.log("We change a value into a field selectprospectstatus");
1196  var statusid = $(this).val();
1197  var prospectid = $(this).attr("data-socid");
1198  var image = $(this).prev(".pictoprospectstatus");
1199  $.ajax({
1200  type: "POST",
1201  url: \'' . DOL_URL_ROOT . '/core/ajax/ajaxstatusprospect.php\',
1202  data: { id: statusid, prospectid: prospectid, token: \''. newToken() .'\', action: \'updatestatusprospect\' },
1203  success: function(response) {
1204  console.log(response.img);
1205  image.replaceWith(response.img);
1206  },
1207  error: function() {
1208  console.error("Error on status prospect");
1209  },
1210  });
1211  });
1212  });
1213  </script>';
1214  }
1215  }
1216 }
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
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:48
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:463
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:311
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 don't le pays est actif La cle de la liste est le co...
select_state_ajax($parent_field_id='country_id', $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.
form_prospect_level($page, $selected=0, $htmlname='prospect_level_id', $empty=0)
Affiche formulaire de selection des modes de reglement.
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.
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.
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.
select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code', $morecss='')
Return the list of all juridical entity types for all countries or a specific country.
formProspectContactLevel($page, $selected=0, $htmlname='prospect_contact_level_id', $empty=0)
Affiche formulaire de selection des niveau de prospection pour les contacts.
select_forme_juridique($selected='', $country_codeid=0, $filter='')
Return the list of all juridical entity types for all countries or a specific country.
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.
selectProspectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode="html")
Output html select to select prospect status.
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,...
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.
selectCompaniesForNewContact($object, $var_id, $selected=0, $htmlname='newcompany', $limitto=[], $forceid=0, $moreparam='', $morecss='')
Output list of third parties.
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('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
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int 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 the value of a given key, which produces ascending (default) or descending out...
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 in HTML for admin users or standard users.
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...
getNonce()
Return a random string to be used as a nonce value for js.
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.
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...