dolibarr 23.0.3
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-2025 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2024-2025 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((int) $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 $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((string) $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 = '';
586 $arraydata = array();
587 while ($i < $num) {
588 $obj = $this->db->fetch_object($resql);
589
590 if ($obj->code) { // We exclude empty line, we will add it later
591 $labelcountry = (($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) ? $langs->trans("Country" . $obj->country_code) : $obj->country);
592 $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)
593 $arraydata[(int) $obj->code] = array('code' => (int) $obj->code, 'label' => $labeljs, 'label_sort' => $labelcountry . '_' . $labeljs, 'country_code' => (string) $obj->country_code, 'country' => $labelcountry);
594 }
595 $i++;
596 }
597
598 $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC');
599 if (empty($country_codeid)) { // Introduce empty value (if $country_codeid not empty, empty value was already added)
600 $arraydata[0] = array('code' => 0, 'label' => '', 'label_sort' => '_', 'country_code' => '', 'country' => '');
601 }
602
603 foreach ($arraydata as $key => $val) {
604 if (!$country || $country != $val['country']) {
605 // Show break when we are in multi country mode
606 if (empty($country_codeid) && $val['country_code']) {
607 $out .= '<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val['country'] . " -----</option>\n";
608 $country = $val['country'];
609 }
610 }
611
612 if ($selected > 0 && $selected == $val['code']) {
613 $out .= '<option value="' . $val['code'] . '" selected>';
614 } else {
615 $out .= '<option value="' . $val['code'] . '">';
616 }
617 // If translation exists, we use it, otherwise we use default label in database
618 $out .= $val['label'];
619 $out .= '</option>';
620 }
621 }
622 $out .= '</select>';
623 if ($user->admin) {
624 $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
625 }
626
627 // Make select dynamic
628 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
629 $out .= ajax_combobox($htmlname);
630
631 $out .= '</div>';
632 } else {
633 dol_print_error($this->db);
634 }
635
636 return $out;
637 }
638
639
653 public function selectCompaniesForNewContact($object, $var_id, $selected = 0, $htmlname = 'newcompany', $limitto = [], $forceid = 0, $moreparam = '', $morecss = '')
654 {
655 global $conf, $user, $hookmanager;
656
657 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) {
658 // Use Ajax search
659 $minLength = (is_numeric(getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
660
661 $socid = 0;
662 $name = '';
663 if ($selected > 0) {
664 $tmpthirdparty = new Societe($this->db);
665 $result = $tmpthirdparty->fetch($selected);
666 if ($result > 0) {
667 $socid = $selected;
668 $name = $tmpthirdparty->name;
669 }
670 }
671
672
673 $events = array();
674 // Add an entry 'method' to say 'yes, we must execute url with param action = method';
675 // Add an entry 'url' to say which url to execute
676 // Add an entry htmlname to say which element we must change once url is called
677 // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
678 // To refresh contacts list on thirdparty list change
679 $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
680
681 if (count($events)) { // If there is some ajax events to run once selection is done, we add code here to run events
682 print '<script nonce="' . getNonce() . '" type="text/javascript">
683 jQuery(document).ready(function() {
684 $("#search_' . $htmlname . '").change(function() {
685 var obj = ' . json_encode($events) . ';
686 $.each(obj, function(key,values) {
687 if (values.method.length) {
688 runJsCodeForEvent' . $htmlname . '(values);
689 }
690 });
691
692 $(this).trigger("blur");
693 });
694
695 // Function used to execute events when search_htmlname change
696 function runJsCodeForEvent' . $htmlname . '(obj) {
697 var id = $("#' . $htmlname . '").val();
698 var method = obj.method;
699 var url = obj.url;
700 var htmlname = obj.htmlname;
701 var showempty = obj.showempty;
702 console.log("Run runJsCodeForEvent-' . $htmlname . ' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
703 $.getJSON(url,
704 {
705 action: method,
706 id: id,
707 htmlname: htmlname
708 },
709 function(response) {
710 if (response != null)
711 {
712 console.log("Change select#"+htmlname+" with content "+response.value)
713 $.each(obj.params, function(key,action) {
714 if (key.length) {
715 var num = response.num;
716 if (num > 0) {
717 $("#" + key).removeAttr(action);
718 } else {
719 $("#" + key).attr(action, action);
720 }
721 }
722 });
723 $("select#" + htmlname).html(response.value);
724 }
725 }
726 );
727 }
728 });
729 </script>';
730 }
731
732 print "\n" . '<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' . "\n";
733 print '<input type="text" size="30" id="search_' . $htmlname . '" name="search_' . $htmlname . '" value="' . $name . '" />';
734 print ajax_autocompleter((string) ($socid ? $socid : -1), $htmlname, DOL_URL_ROOT . '/societe/ajax/ajaxcompanies.php', '', $minLength, 0);
735 return $socid;
736 } else {
737 // Search to list thirdparties
738 $sql = "SELECT s.rowid, s.nom as name ";
739 if (getDolGlobalString('SOCIETE_ADD_REF_IN_LIST')) {
740 $sql .= ", s.code_client, s.code_fournisseur";
741 }
742 if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
743 $sql .= ", s.address, s.zip, s.town";
744 $sql .= ", dictp.code as country_code";
745 }
746 $sql .= " FROM " . $this->db->prefix() . "societe as s";
747 if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
748 $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays";
749 }
750 // Filter on active third parties only (status = 1) Closed third parties must not be selectable
751 $sql .= " WHERE s.entity IN (" . getEntity('societe') . ") AND s.status = 1";
752 // For ajax search we limit here. For combo list, we limit later
753 if (is_array($limitto) && count($limitto)) {
754 $sql .= " AND s.rowid IN (" . $this->db->sanitize(implode(',', $limitto)) . ")";
755 }
756 // filter user access
757 if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
758 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid AND sc.fk_user = ".(int) $user->id .")";
759 }
760 if ($user->socid > 0) {
761 $sql .= " AND s.rowid = ".((int) $user->socid);
762 }
763 // Add where from hooks
764 $parameters = array();
765 $reshook = $hookmanager->executeHooks('selectCompaniesForNewContactListWhere', $parameters); // Note that $action and $object may have been modified by hook
766 $sql .= $hookmanager->resPrint;
767 $sql .= " ORDER BY s.nom ASC";
768
769 $resql = $this->db->query($sql);
770 if ($resql) {
771 print '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '"';
772 if ($conf->use_javascript_ajax) {
773 $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;";
774 print ' onChange="' . $javaScript . '"';
775 }
776 print '>';
777 print '<option value="-1">&nbsp;</option>';
778
779 $num = $this->db->num_rows($resql);
780 $i = 0;
781 $firstCompany = 0; // For static analysis
782 if ($num) {
783 while ($i < $num) {
784 $obj = $this->db->fetch_object($resql);
785 if ($i == 0) {
786 $firstCompany = $obj->rowid;
787 }
788 $disabled = 0;
789 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
790 $disabled = 1;
791 }
792 if ($selected > 0 && $selected == $obj->rowid) {
793 print '<option value="' . $obj->rowid . '"';
794 if ($disabled) {
795 print ' disabled';
796 }
797 print ' selected>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . '</option>';
798 $firstCompany = $obj->rowid;
799 } else {
800 print '<option value="' . $obj->rowid . '"';
801 if ($disabled) {
802 print ' disabled';
803 }
804 print '>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . '</option>';
805 }
806 $i++;
807 }
808 }
809 print "</select>\n";
810 print ajax_combobox($htmlname);
811 return $firstCompany;
812 } else {
813 dol_print_error($this->db);
814 return 0;
815 }
816 }
817 }
818
833 public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '', $output = 1, $forcehidetooltip = 0)
834 {
835 global $user, $langs;
836
837 $out = '';
838 if (is_object($object) && method_exists($object, 'liste_type_contact')) {
839 '@phan-var-force CommonObject $object'; // CommonObject has the method.
840 $lesTypes = $object->liste_type_contact($source, $sortorder, 2, 1); // List of types into c_type_contact for element=$object->element
841
842 $out .= '<select class="flat valignmiddle' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
843 if ($showempty) {
844 $out .= '<option value="0">&nbsp;</option>';
845 }
846 foreach ($lesTypes as $key => $arrayvalue) {
847 $out .= '<option value="'.$key.'" data-code="'.$arrayvalue['code'].'"';
848 if ($key == $selected) {
849 $out .= ' selected';
850 }
851 $out .= '>'.$arrayvalue['label'].'</option>';
852 }
853 $out .= "</select>";
854 if ($user->admin && empty($forcehidetooltip)) {
855 $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
856 }
857
858 $out .= ajax_combobox($htmlname);
859
860 $out .= "\n";
861 }
862 if (empty($output)) {
863 return $out;
864 } else {
865 print $out;
866 }
867 }
868
880 public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array(), $morecss = 'minwidth500', $placeholder = '')
881 {
882 if ($rendermode === 'view') {
883 $toprint = array();
884 foreach ($contact->roles as $key => $val) {
885 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val['label'] . '</li>';
886 }
887 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname . '"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
888 }
889
890 if ($rendermode === 'edit') { // A multiselect combo list
891 $contactType = $contact->listeTypeContacts('external', 0, 1, '', '', 'agenda'); // We exclude agenda as there is no contact on such element
892 if (count($selected) > 0) {
893 $newselected = array();
894 foreach ($selected as $key => $val) {
895 if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) {
896 $newselected[] = $val['id'];
897 } else {
898 break;
899 }
900 }
901 if (count($newselected) > 0) {
902 $selected = $newselected;
903 }
904 }
905 return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss, 0, '90%', '', '', $placeholder);
906 }
907
908 return 'ErrorBadValueForParameterRenderMode'; // Should not happened
909 }
910
911 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
924 public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
925 {
926 // phpcs:enable
927 global $conf;
928
929 $out = '';
930
931 $size = '';
932 if (!empty($fieldsize)) {
933 $size = 'size="' . $fieldsize . '"';
934 }
935
936 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
937 $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT . '/core/ajax/ziptown.php') . "\n";
938 $moreattrib .= ' autocomplete="off"';
939 }
940 $out .= '<input id="' . $htmlname . '" class="maxwidthonsmartphone' . ($morecss ? ' ' . $morecss : '') . '" type="text"' . ($moreattrib ? ' ' . $moreattrib : '') . ' name="' . $htmlname . '" ' . $size . ' value="' . $selected . '">' . "\n";
941
942 return $out;
943 }
944
945 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
956 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth200')
957 {
958 // phpcs:enable
959 global $conf, $langs, $hookmanager;
960
961 $formlength = 0;
962 if (!getDolGlobalString('MAIN_DISABLEPROFIDRULES')) {
963 if ($country_code == 'FR') {
964 if (isset($idprof)) {
965 if ($idprof == 1) {
966 $formlength = 9;
967 } elseif ($idprof == 2) {
968 $formlength = 14;
969 } elseif ($idprof == 3) {
970 $formlength = 5; // 4 chiffres et 1 lettre depuis janvier
971 } elseif ($idprof == 4) {
972 $formlength = 32; // No maximum as we need to include a town name in this id
973 }
974 }
975 } elseif ($country_code == 'ES') {
976 if ($idprof == 1) {
977 $formlength = 9; //CIF/NIF/NIE 9 digits
978 }
979 if ($idprof == 2) {
980 $formlength = 12; //NASS 12 digits without /
981 }
982 if ($idprof == 3) {
983 $formlength = 5; //CNAE 5 digits
984 }
985 if ($idprof == 4) {
986 $formlength = 32; //depend of college
987 }
988 }
989 }
990
991 $selected = $preselected;
992 if (!$selected && isset($idprof)) {
993 if ($idprof == 1 && !empty($this->idprof1)) {
994 $selected = $this->idprof1;
995 } elseif ($idprof == 2 && !empty($this->idprof2)) {
996 $selected = $this->idprof2;
997 } elseif ($idprof == 3 && !empty($this->idprof3)) {
998 $selected = $this->idprof3;
999 } elseif ($idprof == 4 && !empty($this->idprof4)) {
1000 $selected = $this->idprof4;
1001 }
1002 }
1003
1004 $maxlength = $formlength;
1005 $maxlength += getDolGlobalInt("MAIN_PROFID_MAXLENGTH_PLUS");
1006 if (empty($formlength)) {
1007 $formlength = 24;
1008 $maxlength = 128;
1009 }
1010
1011 $out = '';
1012
1013 // Execute hook getInputIdProf to complete or replace $out
1014 $parameters = array('formlength' => $formlength, 'selected' => $preselected, 'idprof' => $idprof, 'htmlname' => $htmlname, 'country_code' => $country_code);
1015 $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
1016 if (empty($reshook)) {
1017 $out .= '<input type="text" ' . ($morecss ? 'class="' . $morecss . '" ' : '') . 'name="' . $htmlname . '" id="' . $htmlname . '" maxlength="' . $maxlength . '" value="' . $selected . '">';
1018 }
1019 $out .= $hookmanager->resPrint;
1020
1021 return $out;
1022 }
1023
1024 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1033 public function select_localtax($local, $selected, $htmlname)
1034 {
1035 // phpcs:enable
1036 $tax = get_localtax_by_third($local);
1037
1038 if ($tax) {
1039 $valors = explode(":", $tax);
1040 $nbvalues = count($valors);
1041
1042 if ($nbvalues > 1) {
1043 //montar select
1044 print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
1045 $i = 0;
1046 while ($i < $nbvalues) {
1047 if ($selected == $valors[$i]) {
1048 print '<option value="' . $valors[$i] . '" selected>';
1049 } else {
1050 print '<option value="' . $valors[$i] . '">';
1051 }
1052 print $valors[$i];
1053 print '</option>';
1054 $i++;
1055 }
1056 print '</select>';
1057 }
1058 }
1059 }
1060
1072 public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '', $allowempty = '')
1073 {
1074 global $conf, $langs;
1075 if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !isModEnabled('fournisseur')) {
1076 return '';
1077 }
1078
1079 $out = '<select class="flat ' . $morecss . '" name="' . $htmlname . '" id="' . $htmlidname . '">';
1080 if ($typeinput == 'form') {
1081 if ($allowempty || ($selected == '' || $selected == '-1')) {
1082 $out .= '<option value="-1">';
1083 if (is_numeric($allowempty)) {
1084 $out .= '&nbsp;';
1085 } else {
1086 $out .= $langs->trans($allowempty);
1087 }
1088 $out .= '</option>';
1089 }
1090 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1091 $out .= '<option value="2"' . ($selected == 2 ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1092 }
1093 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
1094 $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1095 }
1096 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1097 $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1098 }
1099 $out .= '<option value="0"' . ((string) $selected == '0' ? ' selected' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
1100 } elseif ($typeinput == 'list') {
1101 $out .= '<option value="-1"' . (($selected == '' || $selected == '-1') ? ' selected' : '') . '>&nbsp;</option>';
1102 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1103 $out .= '<option value="2,3"' . ($selected == '2,3' ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1104 }
1105 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1106 $out .= '<option value="1,3"' . ($selected == '1,3' ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1107 }
1108 if (isModEnabled("fournisseur")) {
1109 $out .= '<option value="4"' . ($selected == '4' ? ' selected' : '') . '>' . $langs->trans('Supplier') . '</option>';
1110 }
1111 $out .= '<option value="0"' . ($selected == '0' ? ' selected' : '') . '>' . $langs->trans('Other') . '</option>';
1112 } elseif ($typeinput == 'admin') {
1113 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
1114 $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1115 }
1116 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1117 $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1118 }
1119 }
1120 $out .= '</select>';
1121 $out .= ajax_combobox($htmlidname);
1122
1123 return $out;
1124 }
1125
1137 public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0)
1138 {
1139 // phpcs:enable
1140 global $conf, $langs;
1141
1142 $out = '';
1143 if ($htmlname != "none") {
1144 $out .= '<form method="post" action="' . $page . '">';
1145 $out .= '<input type="hidden" name="action" value="set_thirdpartytype">';
1146 $out .= '<input type="hidden" name="token" value="' . newToken() . '">';
1147 $sortparam = getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC'); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
1148 $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
1149 $out .= '<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans("Modify") . '">';
1150 $out .= '</form>';
1151 } else {
1152 if ($selected > 0) {
1153 $arr = $this->typent_array(0);
1154 $typent = empty($arr[$selected]) ? '' : $arr[$selected];
1155 $out .= $typent;
1156 } else {
1157 $out .= "&nbsp;";
1158 }
1159 }
1160
1161 if ($nooutput) {
1162 return $out;
1163 } else {
1164 print $out;
1165 }
1166 }
1167
1178 public function selectProspectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode = "html")
1179 {
1180 global $user, $langs;
1181
1182 if ($mode === "html") {
1183 $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['code'];
1184 $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect]['picto']) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['picto'];
1185
1186 //print $prospectstatic->LibProspCommStatut($statusprospect, 2, $prospectstatic->cacheprospectstatus[$statusprospect]['label'], $prospectstatic->cacheprospectstatus[$statusprospect]['picto']);
1187 print img_action('', $actioncode, $actionpicto, 'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1188 print '<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .'" data-socid="'.$idprospect.'" name="' . $htmlname .'"';
1189 if (!$user->hasRight('societe', 'creer')) {
1190 print ' disabled';
1191 }
1192 print '>';
1193 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1194 //$titlealt = (empty($val['label']) ? 'default' : $val['label']);
1195 $label = $val['label'];
1196 if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1197 //$titlealt = $val['label'];
1198 $label = (($langs->trans("StatusProspect".$val['code']) != "StatusProspect".$val['code']) ? $langs->trans("StatusProspect".$val['code']) : $label);
1199 } else {
1200 $label = (($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id']) ? $langs->trans("StatusProspect".$val['id']) : $label);
1201 }
1202 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' : '').'>';
1203 print dol_escape_htmltag($label);
1204 print '</option>';
1205 }
1206 print '</select>';
1207 print ajax_combobox($htmlname.$idprospect);
1208 } elseif ($mode === "js") {
1209 print '<script>
1210 jQuery(document).ready(function() {
1211 $(".selectprospectstatus").on("change", function() {
1212 console.log("We change a value into a field selectprospectstatus");
1213 var statusid = $(this).val();
1214 var prospectid = $(this).attr("data-socid");
1215 var image = $(this).prev(".pictoprospectstatus");
1216 $.ajax({
1217 type: "POST",
1218 url: \'' . DOL_URL_ROOT . '/core/ajax/ajaxstatusprospect.php\',
1219 data: { id: statusid, prospectid: prospectid, token: \''. newToken() .'\', action: \'updatestatusprospect\' },
1220 success: function(response) {
1221 console.log(response.img);
1222 image.replaceWith(response.img);
1223 },
1224 error: function() {
1225 console.error("Error on status prospect");
1226 },
1227 });
1228 });
1229 });
1230 </script>';
1231 }
1232 }
1233}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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:475
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:324
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_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 multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $nu='', $placeholder='', $addjscombo=-1)
Show a multiselect form from an array.
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.
Class to manage third parties objects (customers, suppliers, prospects...)
global $mysoc
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.
isModEnabled($module)
Is Dolibarr module enabled.
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...