dolibarr 24.0.0-beta
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' : $mysoc->country_id) . ")";
62
63 $errormsg = '';
64 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 0);
65 if ($filter) {
66 $sqlwhere = $filter;
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;
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
290 public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300')
291 {
292 // phpcs:enable
293 global $conf, $langs, $user;
294
295 dol_syslog(get_class($this) . "::select_departement selected=" . $selected . ", country_codeid=" . $country_codeid, LOG_DEBUG);
296
297 $langs->load("dict");
298
299 $out = '';
300
301 // Search departements/cantons/province active d'une region et pays actif
302 $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";
303 $sql .= " " . $this->db->prefix() . "c_departements as d, " . $this->db->prefix() . "c_regions as r," . $this->db->prefix() . "c_country as c";
304 $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
305 $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1";
306 if ($country_codeid && is_numeric($country_codeid)) {
307 $sql .= " AND c.rowid = '" . $this->db->escape($country_codeid) . "'";
308 }
309 if ($country_codeid && !is_numeric($country_codeid)) {
310 $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'";
311 }
312 $sql .= " ORDER BY c.code, d.code_departement";
313
314 $result = $this->db->query($sql);
315 if ($result) {
316 if (!empty($htmlname)) {
317 $out .= '<select id="' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">';
318 }
319 if ($country_codeid) {
320 $out .= '<option value="0">&nbsp;</option>';
321 }
322 $num = $this->db->num_rows($result);
323 $i = 0;
324 dol_syslog(get_class($this) . "::select_departement num=" . $num, LOG_DEBUG);
325 if ($num) {
326 $country = '';
327 while ($i < $num) {
328 $obj = $this->db->fetch_object($result);
329 if ($obj->code == '0') { // Code may be a string
330 $out .= '<option value="0">&nbsp;</option>';
331 } else {
332 if (!$country || $country != $obj->country) {
333 // Show break if we are in list with multiple countries
334 if (!$country_codeid && $obj->country_code) {
335 $out .= '<option value="-1" disabled data-html="----- ' . $obj->country . ' -----">----- ' . $obj->country . " -----</option>\n";
336 $country = $obj->country;
337 }
338 }
339
340 if (!empty($selected) && $selected == $obj->rowid) {
341 $out .= '<option value="' . $obj->rowid . '" selected>';
342 } else {
343 $out .= '<option value="' . $obj->rowid . '">';
344 }
345
346 // If a translation exists, we use it, else we take the default label
347 if (
348 getDolGlobalString('MAIN_SHOW_STATE_CODE') &&
349 (getDolGlobalInt('MAIN_SHOW_STATE_CODE') == 1 || getDolGlobalInt('MAIN_SHOW_STATE_CODE') == 2 || getDolGlobalString('MAIN_SHOW_STATE_CODE') === 'all')
350 ) {
351 if (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1) {
352 $out .= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
353 } else {
354 $out .= $obj->code . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
355 }
356 } else {
357 if (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1) {
358 $out .= $obj->region_name . ' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
359 } else {
360 $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : ''));
361 }
362 }
363
364 $out .= '</option>';
365 }
366 $i++;
367 }
368 }
369 if (!empty($htmlname)) {
370 $out .= '</select>';
371 }
372 if (!empty($htmlname) && $user->admin) {
373 $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
374 }
375 } else {
376 dol_print_error($this->db);
377 }
378
379 // Make select dynamic
380 if (!empty($htmlname)) {
381 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
382 $out .= ajax_combobox($htmlname);
383 }
384
385 return $out;
386 }
387
388 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
403 public function select_state_ajax($parent_field_id = 'country_id', $selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300')
404 {
405 $html = '<script>';
406 $html .= '$("select[name=\"'.$parent_field_id.'\"]").change(function(){
407 $.ajax( "'.dol_buildpath('/core/ajax/ziptown.php', 2).'", { data:{ selected: $("select[name=\"'.$htmlname.'\"]").val(), country_codeid: $(this).val(), htmlname:"'.$htmlname.'", morecss:"'.$morecss.'" } } )
408 .done(function(msg) {
409 $("span#target_'.$htmlname.'").html(msg);
410 })
411 });';
412 return $html.'</script><span id="target_'.$htmlname.'">'.$this->select_state($selected, $country_codeid, $htmlname, $morecss).'</span>';
413 }
414
415 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
427 public function select_region($selected = '', $htmlname = 'region_id')
428 {
429 // phpcs:enable
430 global $conf, $langs;
431 $langs->load("dict");
432
433 $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country";
434 $sql .= " FROM " . $this->db->prefix() . "c_regions as r, " . $this->db->prefix() . "c_country as c";
435 $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1";
436 $sql .= " ORDER BY c.code, c.label ASC";
437
438 dol_syslog(get_class($this) . "::select_region", LOG_DEBUG);
439 $resql = $this->db->query($sql);
440 if ($resql) {
441 print '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">';
442 $num = $this->db->num_rows($resql);
443 $i = 0;
444 if ($num) {
445 $country = '';
446 while ($i < $num) {
447 $obj = $this->db->fetch_object($resql);
448 if ($obj->code == 0) {
449 print '<option value="0">&nbsp;</option>';
450 } else {
451 if ($country == '' || $country != $obj->country) {
452 // Show break
453 $key = $langs->trans("Country" . strtoupper($obj->country_code));
454 $valuetoshow = ($key != "Country" . strtoupper($obj->country_code)) ? $obj->country_code . " - " . $key : $obj->country;
455 print '<option value="-2" disabled>----- ' . $valuetoshow . " -----</option>\n";
456 $country = $obj->country;
457 }
458
459 if ($selected > 0 && $selected == $obj->code) {
460 print '<option value="' . $obj->code . '" selected>' . $obj->label . '</option>';
461 } else {
462 print '<option value="' . $obj->code . '">' . $obj->label . '</option>';
463 }
464 }
465 $i++;
466 }
467 }
468 print '</select>';
469 print ajax_combobox($htmlname);
470 } else {
471 dol_print_error($this->db);
472 }
473 }
474
475 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
485 public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 1)
486 {
487 // phpcs:enable
488 global $langs, $user;
489 $langs->load("dict");
490
491 $out = '';
492
493 $sql = "SELECT rowid, code, label, active FROM " . $this->db->prefix() . "c_civility";
494 $sql .= " WHERE active = 1";
495
496 dol_syslog("Form::select_civility", LOG_DEBUG);
497 $resql = $this->db->query($sql);
498 if ($resql) {
499 $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
500 $out .= '<option value="">&nbsp;</option>';
501 $num = $this->db->num_rows($resql);
502 $i = 0;
503 if ($num) {
504 while ($i < $num) {
505 $obj = $this->db->fetch_object($resql);
506 if ($selected == $obj->code) {
507 $out .= '<option value="' . $obj->code . '" selected>';
508 } else {
509 $out .= '<option value="' . $obj->code . '">';
510 }
511 // If translation exists, we use it, otherwise, we use the hard coded label
512 $out .= ($langs->trans("Civility" . $obj->code) != "Civility" . $obj->code ? $langs->trans("Civility" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
513 $out .= '</option>';
514 $i++;
515 }
516 }
517 $out .= '</select>';
518 if ($user->admin) {
519 $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
520 }
521
522 if ($addjscombo) {
523 // Enhance with select2
524 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
525 $out .= ajax_combobox($htmlname);
526 }
527 } else {
528 dol_print_error($this->db);
529 }
530
531 return $out;
532 }
533
534 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
546 public function select_forme_juridique($selected = 0, $country_codeid = 0, $filter = '')
547 {
548 // phpcs:enable
549 print $this->select_juridicalstatus($selected, $country_codeid, $filter);
550 }
551
552 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
564 public function select_juridicalstatus($selected = 0, $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '')
565 {
566 // phpcs:enable
567 global $langs, $user;
568 $langs->load("dict");
569
570 $out = '';
571
572 // Lookup the active juridical types for the active countries
573 $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code";
574 $sql .= " FROM " . $this->db->prefix() . "c_forme_juridique as f, " . $this->db->prefix() . "c_country as c";
575 $sql .= " WHERE f.fk_pays = c.rowid";
576 $sql .= " AND f.active = 1 AND c.active = 1";
577 if ($country_codeid) {
578 $sql .= " AND c.code = '" . $this->db->escape((string) $country_codeid) . "'";
579 }
580
581 $errormsg = '';
582 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 0);
583 if ($filter) {
584 $sqlwhere = $filter;
585 $sql .= " " . $sqlwhere;
586 }
587
588 $sql .= " ORDER BY c.code";
589
590 dol_syslog(get_class($this) . "::select_juridicalstatus", LOG_DEBUG);
591 $resql = $this->db->query($sql);
592 if ($resql) {
593 $out .= '<div id="particulier2" class="visible">';
594 $out .= '<select class="flat minwidth200' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
595 if ($country_codeid) {
596 $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.
597 }
598
599 $num = $this->db->num_rows($resql);
600 if ($num) {
601 $i = 0;
602 $country = '';
604 $arraydata = array();
605 while ($i < $num) {
606 $obj = $this->db->fetch_object($resql);
607
608 if ($obj->code) { // We exclude empty line, we will add it later
609 $labelcountry = (($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) ? $langs->trans("Country" . $obj->country_code) : $obj->country);
610 $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)
611 $arraydata[(int) $obj->code] = array('code' => (int) $obj->code, 'label' => $labeljs, 'label_sort' => $labelcountry . '_' . $labeljs, 'country_code' => (string) $obj->country_code, 'country' => $labelcountry);
612 }
613 $i++;
614 }
615
616 $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC');
617 if (empty($country_codeid)) { // Introduce empty value (if $country_codeid not empty, empty value was already added)
618 $arraydata[0] = array('code' => 0, 'label' => '', 'label_sort' => '_', 'country_code' => '', 'country' => '');
619 }
620
621 foreach ($arraydata as $key => $val) {
622 if (!$country || $country != $val['country']) {
623 // Show break when we are in multi country mode
624 if (empty($country_codeid) && $val['country_code']) {
625 $out .= '<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val['country'] . " -----</option>\n";
626 $country = $val['country'];
627 }
628 }
629
630 if ($selected > 0 && $selected == $val['code']) {
631 $out .= '<option value="' . $val['code'] . '" selected>';
632 } else {
633 $out .= '<option value="' . $val['code'] . '">';
634 }
635 // If translation exists, we use it, otherwise we use default label in database
636 $out .= $val['label'];
637 $out .= '</option>';
638 }
639 }
640 $out .= '</select>';
641 if ($user->admin) {
642 $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
643 }
644
645 // Make select dynamic
646 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
647 $out .= ajax_combobox($htmlname);
648
649 $out .= '</div>';
650 } else {
651 dol_print_error($this->db);
652 }
653
654 return $out;
655 }
656
657
671 public function selectCompaniesForNewContact($object, $var_id, $selected = 0, $htmlname = 'newcompany', $limitto = [], $forceid = 0, $moreparam = '', $morecss = '')
672 {
673 global $conf, $user, $hookmanager;
674
675 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) {
676 // Use Ajax search
677 $minLength = (is_numeric(getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT')) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
678
679 $socid = 0;
680 $name = '';
681 if ($selected > 0) {
682 $tmpthirdparty = new Societe($this->db);
683 $result = $tmpthirdparty->fetch($selected);
684 if ($result > 0) {
685 $socid = $selected;
686 $name = $tmpthirdparty->name;
687 }
688 }
689
690
691 $events = array();
692 // Add an entry 'method' to say 'yes, we must execute url with param action = method';
693 // Add an entry 'url' to say which url to execute
694 // Add an entry htmlname to say which element we must change once url is called
695 // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
696 // To refresh contacts list on thirdparty list change
697 $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
698
699 if (count($events)) { // If there is some ajax events to run once selection is done, we add code here to run events
700 print '<script nonce="' . getNonce() . '" type="text/javascript">
701 jQuery(document).ready(function() {
702 $("#search_' . $htmlname . '").change(function() {
703 var obj = ' . json_encode($events) . ';
704 $.each(obj, function(key,values) {
705 if (values.method.length) {
706 runJsCodeForEvent' . $htmlname . '(values);
707 }
708 });
709
710 $(this).trigger("blur");
711 });
712
713 // Function used to execute events when search_htmlname change
714 function runJsCodeForEvent' . $htmlname . '(obj) {
715 var id = $("#' . $htmlname . '").val();
716 var method = obj.method;
717 var url = obj.url;
718 var htmlname = obj.htmlname;
719 var showempty = obj.showempty;
720 console.log("Run runJsCodeForEvent-' . $htmlname . ' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
721 $.getJSON(url,
722 {
723 action: method,
724 id: id,
725 htmlname: htmlname
726 },
727 function(response) {
728 if (response != null)
729 {
730 console.log("Change select#"+htmlname+" with content "+response.value)
731 $.each(obj.params, function(key,action) {
732 if (key.length) {
733 var num = response.num;
734 if (num > 0) {
735 $("#" + key).removeAttr(action);
736 } else {
737 $("#" + key).attr(action, action);
738 }
739 }
740 });
741 $("select#" + htmlname).html(response.value);
742 }
743 }
744 );
745 }
746 });
747 </script>';
748 }
749
750 print "\n" . '<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' . "\n";
751 print '<input type="text" size="30" id="search_' . $htmlname . '" name="search_' . $htmlname . '" value="' . $name . '" />';
752 print ajax_autocompleter((string) ($socid ? $socid : -1), $htmlname, DOL_URL_ROOT . '/societe/ajax/ajaxcompanies.php', '', $minLength, 0);
753 return $socid;
754 } else {
755 // Search to list thirdparties
756 $sql = "SELECT s.rowid, s.nom as name, s.name_alias";
757 if (getDolGlobalString('SOCIETE_ADD_REF_IN_LIST')) {
758 $sql .= ", s.code_client, s.code_fournisseur";
759 }
760 if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
761 $sql .= ", s.address, s.zip, s.town";
762 $sql .= ", dictp.code as country_code";
763 }
764 $sql .= " FROM " . $this->db->prefix() . "societe as s";
765 if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
766 $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays";
767 }
768 // Filter on active third parties only (status = 1) Closed third parties must not be selectable
769 $sql .= " WHERE s.entity IN (" . getEntity('societe') . ") AND s.status = 1";
770 // For ajax search we limit here. For combo list, we limit later
771 if (is_array($limitto) && count($limitto)) {
772 $sql .= " AND s.rowid IN (" . $this->db->sanitize(implode(',', $limitto)) . ")";
773 }
774 // filter user access
775 if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
776 $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 .")";
777 }
778 if ($user->socid > 0) {
779 $sql .= " AND s.rowid = ".((int) $user->socid);
780 }
781 // Add where from hooks
782 $parameters = array();
783 $reshook = $hookmanager->executeHooks('selectCompaniesForNewContactListWhere', $parameters); // Note that $action and $object may have been modified by hook
784 $sql .= $hookmanager->resPrint;
785 $sql .= " ORDER BY s.nom ASC";
786
787 $resql = $this->db->query($sql);
788 if ($resql) {
789 print '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '"';
790 if ($conf->use_javascript_ajax) {
791 $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;";
792 print ' onChange="' . $javaScript . '"';
793 }
794 print '>';
795 print '<option value="-1">&nbsp;</option>';
796
797 $num = $this->db->num_rows($resql);
798 $i = 0;
799 $firstCompany = 0; // For static analysis
800 if ($num) {
801 while ($i < $num) {
802 $obj = $this->db->fetch_object($resql);
803 if ($i == 0) {
804 $firstCompany = $obj->rowid;
805 }
806 $disabled = 0;
807 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
808 $disabled = 1;
809 }
810 $nameAlias = !empty($obj->name_alias) ? ' (' . $obj->name_alias . ')' : '';
811 if ($selected > 0 && $selected == $obj->rowid) {
812 print '<option value="' . $obj->rowid . '"';
813 if ($disabled) {
814 print ' disabled';
815 }
816 print ' selected>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . $nameAlias . '</option>';
817 $firstCompany = $obj->rowid;
818 } else {
819 print '<option value="' . $obj->rowid . '"';
820 if ($disabled) {
821 print ' disabled';
822 }
823 print '>' . dol_escape_htmltag($obj->name, 0, 0, '', 0, 1) . $nameAlias . '</option>';
824 }
825 $i++;
826 }
827 }
828 print "</select>\n";
829 print ajax_combobox($htmlname);
830 return $firstCompany;
831 } else {
832 dol_print_error($this->db);
833 return 0;
834 }
835 }
836 }
837
852 public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '', $output = 1, $forcehidetooltip = 0)
853 {
854 global $user, $langs;
855
856 $out = '';
857 if (is_object($object) && method_exists($object, 'liste_type_contact')) {
858 '@phan-var-force CommonObject $object'; // CommonObject has the method.
859 $lesTypes = $object->liste_type_contact($source, $sortorder, 2, 1); // List of types into c_type_contact for element=$object->element
860
861 $out .= '<select class="flat valignmiddle' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
862 if ($showempty) {
863 $out .= '<option value="0">&nbsp;</option>';
864 }
865 foreach ($lesTypes as $key => $arrayvalue) {
866 $out .= '<option value="'.$key.'" data-code="'.$arrayvalue['code'].'"';
867 if ($key == $selected) {
868 $out .= ' selected';
869 }
870 $out .= '>'.$arrayvalue['label'].'</option>';
871 }
872 $out .= "</select>";
873 if ($user->admin && empty($forcehidetooltip)) {
874 $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
875 }
876
877 $out .= ajax_combobox($htmlname);
878
879 $out .= "\n";
880 }
881 if (empty($output)) {
882 return $out;
883 } else {
884 print $out;
885 }
886 }
887
899 public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array(), $morecss = 'minwidth500', $placeholder = '')
900 {
901 if ($rendermode === 'view') {
902 $toprint = array();
903 foreach ($contact->roles as $key => $val) {
904 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val['label'] . '</li>';
905 }
906 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname . '"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
907 }
908
909 if ($rendermode === 'edit') { // A multiselect combo list
910 $contactType = $contact->listeTypeContacts('external', 0, 1, '', '', 'agenda'); // We exclude agenda as there is no contact on such element
911 if (count($selected) > 0) {
912 $newselected = array();
913 foreach ($selected as $key => $val) {
914 if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) {
915 $newselected[] = $val['id'];
916 } else {
917 break;
918 }
919 }
920 if (count($newselected) > 0) {
921 $selected = $newselected;
922 }
923 }
924 return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss, 0, '90%', '', '', $placeholder);
925 }
926
927 return 'ErrorBadValueForParameterRenderMode'; // Should not happened
928 }
929
930 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
943 public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
944 {
945 // phpcs:enable
946 global $conf;
947
948 $out = '';
949
950 $size = '';
951 if (!empty($fieldsize)) {
952 $size = 'size="' . $fieldsize . '"';
953 }
954
955 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
956 $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT . '/core/ajax/ziptown.php') . "\n";
957 $moreattrib .= ' autocomplete="off"';
958 }
959 $out .= '<input id="' . $htmlname . '" class="maxwidthonsmartphone' . ($morecss ? ' ' . $morecss : '') . '" type="text"' . ($moreattrib ? ' ' . $moreattrib : '') . ' name="' . $htmlname . '" ' . $size . ' value="' . $selected . '">' . "\n";
960
961 return $out;
962 }
963
964 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
975 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth200')
976 {
977 // phpcs:enable
978 global $hookmanager;
979
980 $formlength = 0;
981 if (!getDolGlobalString('MAIN_DISABLEPROFIDRULES')) {
982 if ($country_code == 'FR') {
983 if ($idprof == 1) {
984 $formlength = 9;
985 } elseif ($idprof == 2) {
986 $formlength = 14;
987 } elseif ($idprof == 3) {
988 $formlength = 5; // 4 digits and 1 letter since january
989 } elseif ($idprof == 4) {
990 $formlength = 32; // No maximum as we need to include a town name in this id
991 }
992 } elseif ($country_code == 'ES') {
993 if ($idprof == 1) {
994 $formlength = 9; //CIF/NIF/NIE 9 digits
995 } elseif ($idprof == 2) {
996 $formlength = 12; //NASS 12 digits without /
997 } elseif ($idprof == 3) {
998 $formlength = 5; //CNAE 5 digits
999 } elseif ($idprof == 4) {
1000 $formlength = 32; //depend of college
1001 }
1002 }
1003 }
1004
1005 $selected = $preselected;
1006 if (!$selected) {
1007 if ($idprof == 1 && !empty($this->idprof1)) {
1008 $selected = $this->idprof1;
1009 } elseif ($idprof == 2 && !empty($this->idprof2)) {
1010 $selected = $this->idprof2;
1011 } elseif ($idprof == 3 && !empty($this->idprof3)) {
1012 $selected = $this->idprof3;
1013 } elseif ($idprof == 4 && !empty($this->idprof4)) {
1014 $selected = $this->idprof4;
1015 }
1016 }
1017
1018 $maxlength = $formlength;
1019 $maxlength += getDolGlobalInt("MAIN_PROFID_MAXLENGTH_PLUS");
1020 if (empty($formlength)) {
1021 $formlength = 24;
1022 $maxlength = 128;
1023 }
1024
1025 $out = '';
1026
1027 // Execute hook getInputIdProf to complete or replace $out
1028 $parameters = array('formlength' => $formlength, 'selected' => $preselected, 'idprof' => $idprof, 'htmlname' => $htmlname, 'country_code' => $country_code);
1029 $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
1030 if (empty($reshook)) {
1031 $out .= '<input type="text" ' . ($morecss ? 'class="' . $morecss . '" ' : '') . 'name="' . $htmlname . '" id="' . $htmlname . '" maxlength="' . $maxlength . '" value="' . $selected . '">';
1032 }
1033 $out .= $hookmanager->resPrint;
1034
1035 return $out;
1036 }
1037
1038 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1047 public function select_localtax($local, $selected, $htmlname)
1048 {
1049 // phpcs:enable
1050 $tax = get_localtax_by_third($local);
1051
1052 if ($tax) {
1053 $valors = explode(":", $tax);
1054 $nbvalues = count($valors);
1055
1056 if ($nbvalues > 1) {
1057 //montar select
1058 print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
1059 $i = 0;
1060 while ($i < $nbvalues) {
1061 if ($selected == $valors[$i]) {
1062 print '<option value="' . $valors[$i] . '" selected>';
1063 } else {
1064 print '<option value="' . $valors[$i] . '">';
1065 }
1066 print $valors[$i];
1067 print '</option>';
1068 $i++;
1069 }
1070 print '</select>';
1071 }
1072 }
1073 }
1074
1086 public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '', $allowempty = '')
1087 {
1088 global $conf, $langs;
1089 if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !isModEnabled('fournisseur')) {
1090 return '';
1091 }
1092
1093 $out = '<select class="flat ' . $morecss . '" name="' . $htmlname . '" id="' . $htmlidname . '">';
1094 if ($typeinput == 'form') {
1095 if ($allowempty || ($selected == '' || $selected == '-1')) {
1096 $out .= '<option value="-1">';
1097 if (is_numeric($allowempty)) {
1098 $out .= '&nbsp;';
1099 } else {
1100 $out .= $langs->trans($allowempty);
1101 }
1102 $out .= '</option>';
1103 }
1104 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1105 $out .= '<option value="2"' . ($selected == 2 ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1106 }
1107 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
1108 $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1109 }
1110 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1111 $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1112 }
1113 $out .= '<option value="0"' . ((string) $selected == '0' ? ' selected' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
1114 } elseif ($typeinput == 'list') {
1115 $out .= '<option value="-1"' . (($selected == '' || $selected == '-1') ? ' selected' : '') . '>&nbsp;</option>';
1116 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1117 $out .= '<option value="2,3"' . ($selected == '2,3' ? ' selected' : '') . '>' . $langs->trans('Prospect') . '</option>';
1118 }
1119 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1120 $out .= '<option value="1,3"' . ($selected == '1,3' ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1121 }
1122 if (isModEnabled("fournisseur")) {
1123 $out .= '<option value="4"' . ($selected == '4' ? ' selected' : '') . '>' . $langs->trans('Supplier') . '</option>';
1124 }
1125 $out .= '<option value="0"' . ($selected == '0' ? ' selected' : '') . '>' . $langs->trans('Other') . '</option>';
1126 } elseif ($typeinput == 'admin') {
1127 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
1128 $out .= '<option value="3"' . ($selected == 3 ? ' selected' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
1129 }
1130 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1131 $out .= '<option value="1"' . ($selected == 1 ? ' selected' : '') . '>' . $langs->trans('Customer') . '</option>';
1132 }
1133 }
1134 $out .= '</select>';
1135 $out .= ajax_combobox($htmlidname);
1136
1137 return $out;
1138 }
1139
1151 public function formThirdpartyType($page, $selected = '', $htmlname = 'socid', $filter = '', $nooutput = 0)
1152 {
1153 // phpcs:enable
1154 global $conf, $langs;
1155
1156 $out = '';
1157 if ($htmlname != "none") {
1158 $out .= '<form method="post" action="' . $page . '">';
1159 $out .= '<input type="hidden" name="action" value="set_thirdpartytype">';
1160 $out .= '<input type="hidden" name="token" value="' . newToken() . '">';
1161 $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.
1162 $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
1163 $out .= '<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans("Modify") . '">';
1164 $out .= '</form>';
1165 } else {
1166 if ($selected > 0) {
1167 $arr = $this->typent_array(0);
1168 $typent = empty($arr[$selected]) ? '' : $arr[$selected];
1169 $out .= $typent;
1170 } else {
1171 $out .= "&nbsp;";
1172 }
1173 }
1174
1175 if ($nooutput) {
1176 return $out;
1177 } else {
1178 print $out;
1179 }
1180 }
1181
1192 public function selectProspectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode = "html")
1193 {
1194 global $user, $langs;
1195
1196 if ($mode === "html") {
1197 $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['code'];
1198 $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect]['picto']) ? '' : $prospectstatic->cacheprospectstatus[$statusprospect]['picto'];
1199
1200 //print $prospectstatic->LibProspCommStatut($statusprospect, 2, $prospectstatic->cacheprospectstatus[$statusprospect]['label'], $prospectstatic->cacheprospectstatus[$statusprospect]['picto']);
1201 print img_action('', $actioncode, $actionpicto, 'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1202 print '<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .'" data-socid="'.$idprospect.'" name="' . $htmlname .'"';
1203 if (!$user->hasRight('societe', 'creer')) {
1204 print ' disabled';
1205 }
1206 print '>';
1207 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1208 //$titlealt = (empty($val['label']) ? 'default' : $val['label']);
1209 $label = $val['label'];
1210 if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
1211 //$titlealt = $val['label'];
1212 $label = (($langs->trans("StatusProspect".$val['code']) != "StatusProspect".$val['code']) ? $langs->trans("StatusProspect".$val['code']) : $label);
1213 } else {
1214 $label = (($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id']) ? $langs->trans("StatusProspect".$val['id']) : $label);
1215 }
1216 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' : '').'>';
1217 print dol_escape_htmltag($label);
1218 print '</option>';
1219 }
1220 print '</select>';
1221 print ajax_combobox($htmlname.$idprospect);
1222 } elseif ($mode === "js") {
1223 print '<script>
1224 jQuery(document).ready(function() {
1225 $(".selectprospectstatus").on("change", function() {
1226 console.log("We change a value into a field selectprospectstatus");
1227 var statusid = $(this).val();
1228 var prospectid = $(this).attr("data-socid");
1229 var image = $(this).prev(".pictoprospectstatus");
1230 $.ajax({
1231 type: "POST",
1232 url: \'' . DOL_URL_ROOT . '/core/ajax/ajaxstatusprospect.php\',
1233 data: { id: statusid, prospectid: prospectid, token: \''. newToken() .'\', action: \'updatestatusprospect\' },
1234 success: function(response) {
1235 console.log(response.img);
1236 image.replaceWith(response.img);
1237 },
1238 error: function() {
1239 console.error("Error on status prospect");
1240 },
1241 });
1242 });
1243 });
1244 </script>';
1245 }
1246 }
1247}
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:50
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:476
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:325
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)
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,...
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
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...
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...
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.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php