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