dolibarr 25.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-2026 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2024-2026 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' : ((int) $mysoc->country_id)) . ")";
62
63 $errormsg = '';
64 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 0);
65 if ($filter) {
66 $sqlwhere = $filter; // @phan-suppress-current-line SqlInjection
67 $sql .= " " . $sqlwhere;
68 }
69
70 $sql .= " ORDER by position, id";
71
72 dol_syslog(get_class($this) . '::typent_array', LOG_DEBUG);
73
74 $resql = $this->db->query($sql);
75 if ($resql) {
76 $num = $this->db->num_rows($resql);
77 $i = 0;
78
79 while ($i < $num) {
80 $objp = $this->db->fetch_object($resql);
81 if (!$mode) {
82 $key = $objp->id;
83 } else {
84 $key = $objp->code;
85 }
86 if ($langs->trans($objp->code) != $objp->code) {
87 $effs[$key] = $langs->trans($objp->code);
88 } else {
89 $effs[$key] = $objp->label;
90 }
91 if ($effs[$key] == '-') {
92 $effs[$key] = '';
93 }
94 $i++;
95 }
96 $this->db->free($resql);
97 }
98
99 return $effs;
100 }
101
102 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
110 public function effectif_array($mode = 0, $filter = '')
111 {
112 // phpcs:enable
113 $effs = array();
114
115 $sql = "SELECT id, code, libelle as label";
116 $sql .= " FROM " . $this->db->prefix() . "c_effectif";
117 $sql .= " WHERE active = 1";
118
119 $errormsg = '';
120 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 0);
121 if ($filter) {
122 $sqlwhere = $filter; // @phan-suppress-current-line SqlInjection
123 $sql .= " " . $sqlwhere;
124 }
125
126 $sql .= " ORDER BY id ASC";
127
128 dol_syslog(get_class($this) . '::effectif_array', LOG_DEBUG);
129 $resql = $this->db->query($sql);
130 if ($resql) {
131 $num = $this->db->num_rows($resql);
132 $i = 0;
133
134 while ($i < $num) {
135 $objp = $this->db->fetch_object($resql);
136 if (!$mode) {
137 $key = $objp->id;
138 } else {
139 $key = $objp->code;
140 }
141
142 $effs[$key] = $objp->label != '-' ? (string) $objp->label : '';
143 $i++;
144 }
145 $this->db->free($resql);
146 }
147 //return natural sorted list
148 natsort($effs);
149 '@phan-var-force array<string,string> $effs';
150 return $effs;
151 }
152
153
154 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
164 public function form_prospect_level($page, $selected = 0, $htmlname = 'prospect_level_id', $empty = 0)
165 {
166 // phpcs:enable
167 global $user, $langs;
168
169 print '<form method="post" action="' . $page . '">';
170 print '<input type="hidden" name="action" value="setprospectlevel">';
171 print '<input type="hidden" name="token" value="' . newToken() . '">';
172
173 dol_syslog(get_class($this) . '::form_prospect_level', LOG_DEBUG);
174 $sql = "SELECT code, label";
175 $sql .= " FROM " . $this->db->prefix() . "c_prospectlevel";
176 $sql .= " WHERE active > 0";
177 $sql .= " ORDER BY sortorder";
178 $resql = $this->db->query($sql);
179 if ($resql) {
180 $options = array();
181
182 if ($empty) {
183 $options[''] = '';
184 }
185
186 while ($obj = $this->db->fetch_object($resql)) {
187 $level = $langs->trans($obj->code);
188
189 if ($level == $obj->code) {
190 $level = $langs->trans($obj->label);
191 }
192
193 $options[$obj->code] = $level;
194 }
195
196 print Form::selectarray($htmlname, $options, $selected);
197 } else {
198 dol_print_error($this->db);
199 }
200 if (!empty($htmlname) && $user->admin) {
201 print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
202 }
203 print '<input type="submit" class="button button-save valignmiddle smallpaddingimp" value="' . $langs->trans("Modify") . '">';
204 print '</form>';
205 }
206
216 public function formProspectContactLevel($page, $selected = 0, $htmlname = 'prospect_contact_level_id', $empty = 0)
217 {
218 global $user, $langs;
219
220 print '<form method="post" action="' . $page . '">';
221 print '<input type="hidden" name="action" value="setprospectcontactlevel">';
222 print '<input type="hidden" name="token" value="' . newToken() . '">';
223
224 dol_syslog(__METHOD__, LOG_DEBUG);
225 $sql = "SELECT code, label";
226 $sql .= " FROM " . $this->db->prefix() . "c_prospectcontactlevel";
227 $sql .= " WHERE active > 0";
228 $sql .= " ORDER BY sortorder";
229 $resql = $this->db->query($sql);
230 if ($resql) {
231 $options = array();
232
233 if ($empty) {
234 $options[''] = '';
235 }
236
237 while ($obj = $this->db->fetch_object($resql)) {
238 $level = $langs->trans($obj->code);
239
240 if ($level == $obj->code) {
241 $level = $langs->trans($obj->label);
242 }
243
244 $options[$obj->code] = $level;
245 }
246
247 print Form::selectarray($htmlname, $options, $selected);
248 } else {
249 dol_print_error($this->db);
250 }
251 if (!empty($htmlname) && $user->admin) {
252 print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
253 }
254 print '<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans("Modify") . '">';
255 print '</form>';
256 }
257
258 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
270 public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id')
271 {
272 // phpcs:enable
273 print $this->select_state((int) $selected, $country_codeid, $htmlname);
274 }
275
276 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
291 public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300', $showempty = 0)
292 {
293 // phpcs:enable
294 global $conf, $langs, $user;
295
296 dol_syslog(get_class($this) . "::select_departement selected=" . $selected . ", country_codeid=" . $country_codeid, LOG_DEBUG);
297
298 $langs->load("dict");
299
300 $out = '';
301
302 // Search active departments/cantons/provinces of a region and active country
303 $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";
304 $sql .= " " . $this->db->prefix() . "c_departements as d, " . $this->db->prefix() . "c_regions as r," . $this->db->prefix() . "c_country as c";
305 $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
306 $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1";
307 if ($country_codeid && is_numeric($country_codeid)) {
308 $sql .= " AND c.rowid = '" . $this->db->escape($country_codeid) . "'";
309 }
310 if ($country_codeid && !is_numeric($country_codeid)) {
311 $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'";
312 }
313 $sql .= " ORDER BY c.code, d.code_departement";
314
315 $result = $this->db->query($sql);
316 if ($result) {
317 if (!empty($htmlname)) {
318 $out .= '<select id="' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">';
319 }
320 if ($country_codeid || $showempty) {
321 $out .= '<option value="0">&nbsp;</option>';
322 }
323 $num = $this->db->num_rows($result);
324 $i = 0;
325 dol_syslog(get_class($this) . "::select_departement num=" . $num, LOG_DEBUG);
326 if ($num) {
327 $country = '';
328 while ($i < $num) {
329 $obj = $this->db->fetch_object($result);
330 if ($obj->code == '0') { // Code may be a string
331 $out .= '<option value="0">&nbsp;</option>';
332 } else {
333 if (!$country || $country != $obj->country) {
334 // Show break if we are in list with multiple countries
335 if (!$country_codeid && $obj->country_code) {
336 $out .= '<option value="-1" disabled data-html="----- ' . $obj->country . ' -----">----- ' . $obj->country . " -----</option>\n";
337 $country = $obj->country;
338 }
339 }
340
341 if (!empty($selected) && $selected == $obj->rowid) {
342 $out .= '<option value="' . $obj->rowid . '" selected>';
343 } else {
344 $out .= '<option value="' . $obj->rowid . '">';
345 }
346
347 // If a translation exists, we use it, else we take the default label
348 if (
349 getDolGlobalString('MAIN_SHOW_STATE_CODE') &&
350 (getDolGlobalInt('MAIN_SHOW_STATE_CODE') == 1 || getDolGlobalInt('MAIN_SHOW_STATE_CODE') == 2 || getDolGlobalString('MAIN_SHOW_STATE_CODE') === 'all')
351 ) {
352 if (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1) {
353 $out .= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
354 } else {
355 $out .= $obj->code . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
356 }
357 } else {
358 if (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1) {
359 $out .= $obj->region_name . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
360 } else {
361 $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
362 }
363 }
364
365 $out .= '</option>';
366 }
367 $i++;
368 }
369 }
370 if (!empty($htmlname)) {
371 $out .= '</select>';
372 }
373 if (!empty($htmlname) && $user->admin) {
374 $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
375 }
376 } else {
377 dol_print_error($this->db);
378 }
379
380 // Make select dynamic
381 if (!empty($htmlname)) {
382 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
383 $out .= ajax_combobox($htmlname);
384 }
385
386 return $out;
387 }
388
389 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
404 public function select_state_ajax($parent_field_id = 'country_id', $selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300')
405 {
406 $html = '<script>';
407 $html .= '$("select[name=\"'.$parent_field_id.'\"]").change(function(){
408 $.ajax( "'.dol_buildpath('/core/ajax/ziptown.php', 2).'", { data:{ selected: $("select[name=\"'.$htmlname.'\"]").val(), country_codeid: $(this).val(), htmlname:"'.$htmlname.'", morecss:"'.$morecss.'" } } )
409 .done(function(msg) {
410 $("span#target_'.$htmlname.'").html(msg);
411 })
412 });';
413 return $html.'</script><span id="target_'.$htmlname.'">'.$this->select_state($selected, $country_codeid, $htmlname, $morecss).'</span>';
414 }
415
416 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
428 public function select_region($selected = '', $htmlname = 'region_id')
429 {
430 // phpcs:enable
431 global $conf, $langs;
432 $langs->load("dict");
433
434 $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country";
435 $sql .= " FROM " . $this->db->prefix() . "c_regions as r, " . $this->db->prefix() . "c_country as c";
436 $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1";
437 $sql .= " ORDER BY c.code, c.label ASC";
438
439 dol_syslog(get_class($this) . "::select_region", LOG_DEBUG);
440 $resql = $this->db->query($sql);
441 if ($resql) {
442 print '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">';
443 $num = $this->db->num_rows($resql);
444 $i = 0;
445 if ($num) {
446 $country = '';
447 while ($i < $num) {
448 $obj = $this->db->fetch_object($resql);
449 if ($obj->code == 0) {
450 print '<option value="0">&nbsp;</option>';
451 } else {
452 if ($country == '' || $country != $obj->country) {
453 // Show break
454 $key = $langs->trans("Country" . strtoupper($obj->country_code));
455 $valuetoshow = ($key != "Country" . strtoupper($obj->country_code)) ? $obj->country_code . " - " . $key : $obj->country;
456 print '<option value="-2" disabled>----- ' . $valuetoshow . " -----</option>\n";
457 $country = $obj->country;
458 }
459
460 if ($selected > 0 && $selected == $obj->code) {
461 print '<option value="' . $obj->code . '" selected>' . $obj->label . '</option>';
462 } else {
463 print '<option value="' . $obj->code . '">' . $obj->label . '</option>';
464 }
465 }
466 $i++;
467 }
468 }
469 print '</select>';
470 print ajax_combobox($htmlname);
471 } else {
472 dol_print_error($this->db);
473 }
474 }
475
476 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
486 public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 1)
487 {
488 // phpcs:enable
489 global $langs, $user;
490 $langs->load("dict");
491
492 $out = '';
493
494 $sql = "SELECT rowid, code, label, active FROM " . $this->db->prefix() . "c_civility";
495 $sql .= " WHERE active = 1";
496
497 dol_syslog("Form::select_civility", LOG_DEBUG);
498 $resql = $this->db->query($sql);
499 if ($resql) {
500 $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
501 $out .= '<option value="">&nbsp;</option>';
502 $num = $this->db->num_rows($resql);
503 $i = 0;
504 if ($num) {
505 while ($i < $num) {
506 $obj = $this->db->fetch_object($resql);
507 if ($selected == $obj->code) {
508 $out .= '<option value="' . $obj->code . '" selected>';
509 } else {
510 $out .= '<option value="' . $obj->code . '">';
511 }
512 // If translation exists, we use it, otherwise, we use the hard coded label
513 $out .= ($langs->trans("Civility" . $obj->code) != "Civility" . $obj->code ? $langs->trans("Civility" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
514 $out .= '</option>';
515 $i++;
516 }
517 }
518 $out .= '</select>';
519 if ($user->admin) {
520 $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
521 }
522
523 if ($addjscombo) {
524 // Enhance with select2
525 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
526 $out .= ajax_combobox($htmlname);
527 }
528 } else {
529 dol_print_error($this->db);
530 }
531
532 return $out;
533 }
534
535 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
547 public function select_forme_juridique($selected = 0, $country_codeid = 0, $filter = '')
548 {
549 // phpcs:enable
550 print $this->select_juridicalstatus($selected, $country_codeid, $filter);
551 }
552
553 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
565 public function select_juridicalstatus($selected = 0, $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '')
566 {
567 // phpcs:enable
568 global $langs, $user;
569 $langs->load("dict");
570
571 $out = '';
572
573 // Lookup the active juridical types for the active countries
574 $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code";
575 $sql .= " FROM " . $this->db->prefix() . "c_forme_juridique as f, " . $this->db->prefix() . "c_country as c";
576 $sql .= " WHERE f.fk_pays = c.rowid";
577 $sql .= " AND f.active = 1 AND c.active = 1";
578 if ($country_codeid) {
579 $sql .= " AND c.code = '" . $this->db->escape((string) $country_codeid) . "'";
580 }
581
582 $errormsg = '';
583 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 0);
584 if ($filter) {
585 $sqlwhere = $filter; // @phan-suppress-current-line SqlInjection
586 $sql .= " " . $sqlwhere;
587 }
588
589 $sql .= " ORDER BY c.code";
590
591 dol_syslog(get_class($this) . "::select_juridicalstatus", LOG_DEBUG);
592 $resql = $this->db->query($sql);
593 if ($resql) {
594 $out .= '<div id="particulier2" class="visible">';
595 $out .= '<select class="flat minwidth200' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
596 if ($country_codeid) {
597 $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.
598 }
599
600 $num = $this->db->num_rows($resql);
601 if ($num) {
602 $i = 0;
603 $country = '';
605 $arraydata = array();
606 while ($i < $num) {
607 $obj = $this->db->fetch_object($resql);
608
609 if ($obj->code) { // We exclude empty line, we will add it later
610 $labelcountry = (($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) ? $langs->trans("Country" . $obj->country_code) : $obj->country);
611 $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)
612 $arraydata[(int) $obj->code] = array('code' => (int) $obj->code, 'label' => $labeljs, 'label_sort' => $labelcountry . '_' . $labeljs, 'country_code' => (string) $obj->country_code, 'country' => $labelcountry);
613 }
614 $i++;
615 }
616
617 $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC');
618 if (empty($country_codeid)) { // Introduce empty value (if $country_codeid not empty, empty value was already added)
619 $arraydata[0] = array('code' => 0, 'label' => '', 'label_sort' => '_', 'country_code' => '', 'country' => '');
620 }
621
622 foreach ($arraydata as $key => $val) {
623 if (!$country || $country != $val['country']) {
624 // Show break when we are in multi country mode
625 if (empty($country_codeid) && $val['country_code']) {
626 $out .= '<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val['country'] . " -----</option>\n";
627 $country = $val['country'];
628 }
629 }
630
631 if ($selected > 0 && $selected == $val['code']) {
632 $out .= '<option value="' . $val['code'] . '" selected>';
633 } else {
634 $out .= '<option value="' . $val['code'] . '">';
635 }
636 // If translation exists, we use it, otherwise we use default label in database
637 $out .= $val['label'];
638 $out .= '</option>';
639 }
640 }
641 $out .= '</select>';
642 if ($user->admin) {
643 $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
644 }
645
646 // Make select dynamic
647 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
648 $out .= ajax_combobox($htmlname);
649
650 $out .= '</div>';
651 } else {
652 dol_print_error($this->db);
653 }
654
655 return $out;
656 }
657
658
672 public function selectCompaniesForNewContact($object, $var_id, $selected = 0, $htmlname = 'newcompany', $limitto = [], $forceid = 0, $moreparam = '', $morecss = '')
673 {
674 global $conf, $user, $hookmanager;
675
676 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) {
677 // Use Ajax search
678 $minLength = (is_numeric(getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
679
680 $socid = 0;
681 $name = '';
682 if ($selected > 0) {
683 $tmpthirdparty = new Societe($this->db);
684 $result = $tmpthirdparty->fetch($selected);
685 if ($result > 0) {
686 $socid = $selected;
687 $name = $tmpthirdparty->name;
688 }
689 }
690
691
692 $events = array();
693 // Add an entry 'method' to say 'yes, we must execute url with param action = method';
694 // Add an entry 'url' to say which url to execute
695 // Add an entry htmlname to say which element we must change once url is called
696 // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
697 // To refresh contacts list on thirdparty list change
698 $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
699
700 if (count($events)) { // If there is some ajax events to run once selection is done, we add code here to run events
701 print '<script nonce="' . getNonce() . '" type="text/javascript">
702 jQuery(document).ready(function() {
703 $("#search_' . $htmlname . '").change(function() {
704 var obj = ' . json_encode($events) . ';
705 $.each(obj, function(key,values) {
706 if (values.method.length) {
707 runJsCodeForEvent' . $htmlname . '(values);
708 }
709 });
710
711 $(this).trigger("blur");
712 });
713
714 // Function used to execute events when search_htmlname change
715 function runJsCodeForEvent' . $htmlname . '(obj) {
716 var id = $("#' . $htmlname . '").val();
717 var method = obj.method;
718 var url = obj.url;
719 var htmlname = obj.htmlname;
720 var showempty = obj.showempty;
721 console.log("Run runJsCodeForEvent-' . $htmlname . ' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
722 $.getJSON(url,
723 {
724 action: method,
725 id: id,
726 htmlname: htmlname
727 },
728 function(response) {
729 if (response != null)
730 {
731 console.log("Change select#"+htmlname+" with content "+response.value)
732 $.each(obj.params, function(key,action) {
733 if (key.length) {
734 var num = response.num;
735 if (num > 0) {
736 $("#" + key).removeAttr(action);
737 } else {
738 $("#" + key).attr(action, action);
739 }
740 }
741 });
742 $("select#" + htmlname).html(response.value);
743 }
744 }
745 );
746 }
747 });
748 </script>';
749 }
750
751 print "\n" . '<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' . "\n";
752 print '<input type="text" size="30" id="search_' . $htmlname . '" name="search_' . $htmlname . '" value="' . $name . '" />';
753 print ajax_autocompleter((string) ($socid ? $socid : -1), $htmlname, DOL_URL_ROOT . '/societe/ajax/ajaxcompanies.php', '', $minLength, 0);
754 return $socid;
755 } else {
756 // Search to list thirdparties
757 $sql = "SELECT s.rowid, s.nom as name, s.name_alias";
758 if (getDolGlobalString('SOCIETE_ADD_REF_IN_LIST')) {
759 $sql .= ", s.code_client, s.code_fournisseur";
760 }
761 if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
762 $sql .= ", s.address, s.zip, s.town";
763 $sql .= ", dictp.code as country_code";
764 }
765 $sql .= " FROM " . $this->db->prefix() . "societe as s";
766 if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
767 $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays";
768 }
769 // Filter on active third parties only (status = 1) Closed third parties must not be selectable
770 $sql .= " WHERE s.entity IN (" . getEntity('societe') . ") AND s.status = 1";
771 // For ajax search we limit here. For combo list, we limit later
772 if (is_array($limitto) && count($limitto)) {
773 $sql .= " AND s.rowid IN (" . $this->db->sanitize(implode(',', $limitto)) . ")";
774 }
775 // filter user access
776 if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
777 $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 .")";
778 }
779 if ($user->socid > 0) {
780 $sql .= " AND s.rowid = ".((int) $user->socid);
781 }
782 // Add where from hooks
783 $parameters = array();
784 $reshook = $hookmanager->executeHooks('selectCompaniesForNewContactListWhere', $parameters); // Note that $action and $object may have been modified by hook
785 $sql .= $hookmanager->resPrint;
786 $sql .= " ORDER BY s.nom ASC";
787
788 $resql = $this->db->query($sql);
789 if ($resql) {
790 print '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '"';
791 if ($conf->use_javascript_ajax) {
792 $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;"; // Quoting for dol_escape_js is ok @phan-suppress-current-line FunctionMissingSingleQuoteWrapping
793 print ' onChange="' . $javaScript . '"';
794 }
795 print '>';
796 print '<option value="-1">&nbsp;</option>';
797
798 $num = $this->db->num_rows($resql);
799 $i = 0;
800 $firstCompany = 0; // For static analysis
801 if ($num) {
802 while ($i < $num) {
803 $obj = $this->db->fetch_object($resql);
804 if ($i == 0) {
805 $firstCompany = $obj->rowid;
806 }
807 $disabled = 0;
808 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
809 $disabled = 1;
810 }
811 $nameAlias = !empty($obj->name_alias) ? ' (' . $obj->name_alias . ')' : '';
812 if ($selected > 0 && $selected == $obj->rowid) {
813 print '<option value="' . $obj->rowid . '"';
814 if ($disabled) {
815 print ' disabled';
816 }
817 print ' selected>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . $nameAlias . '</option>';
818 $firstCompany = $obj->rowid;
819 } else {
820 print '<option value="' . $obj->rowid . '"';
821 if ($disabled) {
822 print ' disabled';
823 }
824 print '>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . $nameAlias . '</option>';
825 }
826 $i++;
827 }
828 }
829 print "</select>\n";
830 print ajax_combobox($htmlname);
831 return $firstCompany;
832 } else {
833 dol_print_error($this->db);
834 return 0;
835 }
836 }
837 }
838
853 public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '', $output = 1, $forcehidetooltip = 0)
854 {
855 global $user, $langs;
856
857 $out = '';
858 if (is_object($object) && method_exists($object, 'liste_type_contact')) {
859 '@phan-var-force CommonObject $object'; // CommonObject has the method.
860 $lesTypes = $object->liste_type_contact($source, $sortorder, 2, 1); // List of types into c_type_contact for element=$object->element
861
862 $out .= '<select class="flat valignmiddle' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
863 if ($showempty) {
864 $out .= '<option value="0">&nbsp;</option>';
865 }
866 foreach ($lesTypes as $key => $arrayvalue) {
867 $out .= '<option value="'.$key.'" data-code="'.$arrayvalue['code'].'"';
868 if ($key == $selected) {
869 $out .= ' selected';
870 }
871 $out .= '>'.$arrayvalue['label'].'</option>';
872 }
873 $out .= "</select>";
874 if ($user->admin && empty($forcehidetooltip)) {
875 $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
876 }
877
878 $out .= ajax_combobox($htmlname);
879
880 $out .= "\n";
881 }
882 if (empty($output)) {
883 return $out;
884 } else {
885 print $out;
886 }
887 }
888
900 public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array(), $morecss = 'minwidth500', $placeholder = '')
901 {
902 if ($rendermode === 'view') {
903 $toprint = array();
904 foreach ($contact->roles as $key => $val) {
905 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val['label'] . '</li>';
906 }
907 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname . '"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
908 }
909
910 if ($rendermode === 'edit') { // A multiselect combo list
911 $contactType = $contact->listeTypeContacts('external', 0, 1, '', '', 'agenda'); // We exclude agenda as there is no contact on such element
912 if (count($selected) > 0) {
913 $newselected = array();
914 foreach ($selected as $key => $val) {
915 if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) {
916 $newselected[] = $val['id'];
917 } else {
918 break;
919 }
920 }
921 if (count($newselected) > 0) {
922 $selected = $newselected;
923 } else {
924 $selected = array();
925 }
926 }
927 return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss, 0, '90%', '', '', $placeholder);
928 }
929
930 return 'ErrorBadValueForParameterRenderMode'; // Should not happened
931 }
932
933 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
946 public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
947 {
948 // phpcs:enable
949 global $conf;
950
951 $out = '';
952
953 $size = '';
954 if (!empty($fieldsize)) {
955 $size = 'size="' . $fieldsize . '"';
956 }
957
958 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
959 $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT . '/core/ajax/ziptown.php') . "\n";
960 $moreattrib .= ' autocomplete="off"';
961 }
962 $out .= '<input id="' . $htmlname . '" class="maxwidthonsmartphone' . ($morecss ? ' ' . $morecss : '') . '" type="text"' . ($moreattrib ? ' ' . $moreattrib : '') . ' name="' . $htmlname . '" ' . $size . ' value="' . $selected . '">' . "\n";
963
964 return $out;
965 }
966
967 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
978 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth200')
979 {
980 // phpcs:enable
981 global $hookmanager;
982
983 require_once DOL_DOCUMENT_ROOT.'/core/lib/profid.lib.php';
984
985 $formlength = 0;
986 if (!getDolGlobalString('MAIN_DISABLEPROFIDRULES')) {
987 if ($country_code == 'FR') {
988 if ($idprof == 1) {
989 $formlength = 9;
990 } elseif ($idprof == 2) {
991 $formlength = 14;
992 } elseif ($idprof == 3) {
993 $formlength = 5; // 4 digits and 1 letter since january
994 } elseif ($idprof == 4) {
995 $formlength = 32; // No maximum as we need to include a town name in this id
996 }
997 } elseif ($country_code == 'ES') {
998 if ($idprof == 1) {
999 $formlength = 9; //CIF/NIF/NIE 9 digits
1000 } elseif ($idprof == 2) {
1001 $formlength = 12; //NASS 12 digits without /
1002 } elseif ($idprof == 3) {
1003 $formlength = 5; //CNAE 5 digits
1004 } elseif ($idprof == 4) {
1005 $formlength = 32; //depend of college
1006 }
1007 }
1008 }
1009
1010 $selected = $preselected;
1011
1012 $maxlength = $formlength;
1013 $maxlength += getDolGlobalInt("MAIN_PROFID_MAXLENGTH_PLUS");
1014 if (empty($formlength)) {
1015 $formlength = 24;
1016 $maxlength = 128;
1017 }
1018
1019 // Such an id is most often copy/pasted from an official document, where it is presented with its
1020 // separator spaces (SIREN "849 943 618"). This attribute tells lib_head.js.php to remove them from
1021 // the pasted text before it is inserted, so that maxlength applies to the id itself and not to its
1022 // presentation: without it the browser silently truncates the paste.
1023 $dataprofid = isProfIdWithoutSpace($idprof, $country_code) ? ' data-profidnospace="1"' : '';
1024 $dataprofid .= isProfIdWithoutDot($idprof, $country_code) ? ' data-profidnodot="1"' : ''; // Same for dots (SIREN "849.943.618")
1025
1026 $out = '';
1027
1028 // Execute hook getInputIdProf to complete or replace $out
1029 $parameters = array('formlength' => $formlength, 'selected' => $preselected, 'idprof' => $idprof, 'htmlname' => $htmlname, 'country_code' => $country_code);
1030 $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
1031 if (empty($reshook)) {
1032 $out .= '<input type="text" ' . ($morecss ? 'class="' . $morecss . '" ' : '') . 'name="' . $htmlname . '" id="' . $htmlname . '" maxlength="' . $maxlength . '"' . $dataprofid . ' value="' . $selected . '">';
1033 }
1034 $out .= $hookmanager->resPrint;
1035
1036 return $out;
1037 }
1038
1039 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1048 public function select_localtax($local, $selected, $htmlname)
1049 {
1050 // phpcs:enable
1051 $tax = get_localtax_by_third($local);
1052
1053 if ($tax) {
1054 $valors = explode(":", $tax);
1055 $nbvalues = count($valors);
1056
1057 if ($nbvalues > 1) {
1058 //montar select
1059 print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
1060 $i = 0;
1061 while ($i < $nbvalues) {
1062 if ($selected == $valors[$i]) {
1063 print '<option value="' . $valors[$i] . '" selected>';
1064 } else {
1065 print '<option value="' . $valors[$i] . '">';
1066 }
1067 print $valors[$i];
1068 print '</option>';
1069 $i++;
1070 }
1071 print '</select>';
1072 }
1073 }
1074 }
1075
1087 public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '', $allowempty = '')
1088 {
1089 global $conf, $langs;
1090 if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !isModEnabled('fournisseur')) {
1091 return '';
1092 }
1093
1094 $out = '<select class="flat ' . $morecss . '" name="' . $htmlname . '" id="' . $htmlidname . '">';
1095 if ($typeinput == 'form') {
1096 if ($allowempty || ($selected == '' || $selected == '-1')) {
1097 $out .= '<option value="-1">';
1098 if (is_numeric($allowempty)) {
1099 $out .= '&nbsp;';
1100 } else {
1101 $out .= $langs->trans($allowempty);
1102 }
1103 $out .= '</option>';
1104 }
1105 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1106 $out .= '<option value="2"' . ($selected == 2 ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1107 }
1108 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
1109 $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1110 }
1111 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1112 $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1113 }
1114 $out .= '<option value="0"' . ((string) $selected == '0' ? ' selected' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
1115 } elseif ($typeinput == 'list') {
1116 $out .= '<option value="-1"' . (($selected == '' || $selected == '-1') ? ' selected' : '') . '>&nbsp;</option>';
1117 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1118 $out .= '<option value="2,3"' . ($selected == '2,3' ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1119 }
1120 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1121 $out .= '<option value="1,3"' . ($selected == '1,3' ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1122 }
1123 if (isModEnabled("fournisseur")) {
1124 $out .= '<option value="4"' . ($selected == '4' ? ' selected' : '') . '>' . $langs->trans('Supplier') . '</option>';
1125 }
1126 $out .= '<option value="0"' . ($selected == '0' ? ' selected' : '') . '>' . $langs->trans('Other') . '</option>';
1127 } elseif ($typeinput == 'admin') {
1128 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
1129 $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1130 }
1131 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1132 $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1133 }
1134 }
1135 $out .= '</select>';
1136 $out .= ajax_combobox($htmlidname);
1137
1138 return $out;
1139 }
1140
1152 public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0)
1153 {
1154 // phpcs:enable
1155 global $conf, $langs;
1156
1157 $out = '';
1158 if ($htmlname != "none") {
1159 $out .= '<form method="post" action="' . $page . '">';
1160 $out .= '<input type="hidden" name="action" value="set_thirdpartytype">';
1161 $out .= '<input type="hidden" name="token" value="' . newToken() . '">';
1162 $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.
1163 $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
1164 $out .= '<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans("Modify") . '">';
1165 $out .= '</form>';
1166 } else {
1167 if ($selected > 0) {
1168 $arr = $this->typent_array(0);
1169 $typent = empty($arr[$selected]) ? '' : $arr[$selected];
1170 $out .= $typent;
1171 } else {
1172 $out .= "&nbsp;";
1173 }
1174 }
1175
1176 if ($nooutput) {
1177 return $out;
1178 } else {
1179 print $out;
1180 }
1181 }
1182
1193 public function selectProspectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode = "html")
1194 {
1195 global $user, $langs;
1196
1197 if ($mode === "html") {
1198 $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['code'];
1199 $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect]['picto']) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['picto'];
1200
1201 //print $prospectstatic->LibProspCommStatut($statusprospect, 2, $prospectstatic->cacheprospectstatus[$statusprospect]['label'], $prospectstatic->cacheprospectstatus[$statusprospect]['picto']);
1202 print img_action('', $actioncode, $actionpicto, 'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1203 print '<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .'" data-socid="'.$idprospect.'" name="' . $htmlname .'"';
1204 if (!$user->hasRight('societe', 'creer')) {
1205 print ' disabled';
1206 }
1207 print '>';
1208 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1209 //$titlealt = (empty($val['label']) ? 'default' : $val['label']);
1210 $label = $val['label'];
1211 if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1212 //$titlealt = $val['label'];
1213 $label = (($langs->trans("StatusProspect".$val['code']) != "StatusProspect".$val['code']) ? $langs->trans("StatusProspect".$val['code']) : $label);
1214 } else {
1215 $label = (($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id']) ? $langs->trans("StatusProspect".$val['id']) : $label);
1216 }
1217 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' : '').'>';
1218 print dol_escape_htmltag($label);
1219 print '</option>';
1220 }
1221 print '</select>';
1222 print ajax_combobox($htmlname.$idprospect);
1223 } elseif ($mode === "js") {
1224 print '<script>
1225 jQuery(document).ready(function() {
1226 $(".selectprospectstatus").on("change", function() {
1227 console.log("We change a value into a field selectprospectstatus");
1228 var statusid = $(this).val();
1229 var prospectid = $(this).attr("data-socid");
1230 var image = $(this).prev(".pictoprospectstatus");
1231 $.ajax({
1232 type: "POST",
1233 url: \'' . DOL_URL_ROOT . '/core/ajax/ajaxstatusprospect.php\',
1234 data: { id: statusid, prospectid: prospectid, token: \''. currentToken() .'\', action: \'updatestatusprospect\' },
1235 success: function(response) {
1236 console.log(response.img);
1237 image.replaceWith(response.img);
1238 },
1239 error: function() {
1240 console.error("Error on status prospect");
1241 },
1242 });
1243 });
1244 });
1245 </script>';
1246 }
1247 }
1248}
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:51
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:488
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:336
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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_state($selected=0, $country_codeid=0, $htmlname='state_id', $morecss='maxwidth200onsmartphone minwidth300', $showempty=0)
Returns the drop-down list of departments/provinces/cantons for all countries or for a given 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 active 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)
Displays form for selecting settlement methods.
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)
Show form to select the level of prospection for 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,...
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
currentToken()
Return the value of token currently saved into session with name 'token'.
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'.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getNonce()
Return a random string to be used as a nonce value for js.
getDolGlobalString($key, $default='')
Return a 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.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:183
isProfIdWithoutDot($idprof, $country_code)
Return whether the recorded value of a professional id never holds a dot, in which case the dots of a...
isProfIdWithoutSpace($idprof, $country_code)
Return whether the recorded value of a professional id never holds a space, in which case the spaces ...