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