36require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
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)) .
")";
67 $sql .=
" " . $sqlwhere;
70 $sql .=
" ORDER by position, id";
72 dol_syslog(get_class($this) .
'::typent_array', LOG_DEBUG);
74 $resql = $this->db->query($sql);
76 $num = $this->db->num_rows($resql);
80 $objp = $this->db->fetch_object($resql);
86 if ($langs->trans($objp->code) != $objp->code) {
87 $effs[$key] = $langs->trans($objp->code);
89 $effs[$key] = $objp->label;
91 if ($effs[$key] ==
'-') {
96 $this->db->free($resql);
115 $sql =
"SELECT id, code, libelle as label";
116 $sql .=
" FROM " . $this->db->prefix() .
"c_effectif";
117 $sql .=
" WHERE active = 1";
123 $sql .=
" " . $sqlwhere;
126 $sql .=
" ORDER BY id ASC";
128 dol_syslog(get_class($this) .
'::effectif_array', LOG_DEBUG);
129 $resql = $this->db->query($sql);
131 $num = $this->db->num_rows($resql);
135 $objp = $this->db->fetch_object($resql);
142 $effs[$key] = $objp->label !=
'-' ? (string) $objp->label :
'';
145 $this->db->free($resql);
149 '@phan-var-force array<string,string> $effs';
167 global $user, $langs;
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() .
'">';
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);
186 while ($obj = $this->db->fetch_object($resql)) {
187 $level = $langs->trans($obj->code);
189 if ($level == $obj->code) {
190 $level = $langs->trans($obj->label);
193 $options[$obj->code] = $level;
198 dol_print_error($this->db);
200 if (!empty($htmlname) && $user->admin) {
201 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
203 print
'<input type="submit" class="button button-save valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
218 global $user, $langs;
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() .
'">';
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);
237 while ($obj = $this->db->fetch_object($resql)) {
238 $level = $langs->trans($obj->code);
240 if ($level == $obj->code) {
241 $level = $langs->trans($obj->label);
244 $options[$obj->code] = $level;
249 dol_print_error($this->db);
251 if (!empty($htmlname) && $user->admin) {
252 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
254 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
273 print $this->
select_state((
int) $selected, $country_codeid, $htmlname);
291 public function select_state($selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300', $showempty = 0)
294 global
$conf, $langs, $user;
296 dol_syslog(get_class($this) .
"::select_departement selected=" . $selected .
", country_codeid=" . $country_codeid, LOG_DEBUG);
298 $langs->load(
"dict");
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) .
"'";
310 if ($country_codeid && !is_numeric($country_codeid)) {
311 $sql .=
" AND c.code = '" . $this->db->escape($country_codeid) .
"'";
313 $sql .=
" ORDER BY c.code, d.code_departement";
315 $result = $this->db->query($sql);
317 if (!empty($htmlname)) {
318 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
320 if ($country_codeid || $showempty) {
321 $out .=
'<option value="0"> </option>';
323 $num = $this->db->num_rows($result);
325 dol_syslog(get_class($this) .
"::select_departement num=" . $num, LOG_DEBUG);
329 $obj = $this->db->fetch_object($result);
330 if ($obj->code ==
'0') {
331 $out .=
'<option value="0"> </option>';
333 if (!$country || $country != $obj->country) {
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;
341 if (!empty($selected) && $selected == $obj->rowid) {
342 $out .=
'<option value="' . $obj->rowid .
'" selected>';
344 $out .=
'<option value="' . $obj->rowid .
'">';
353 $out .= $obj->region_name .
' - ' . $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
355 $out .= $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
359 $out .= $obj->region_name .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
361 $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
370 if (!empty($htmlname)) {
373 if (!empty($htmlname) && $user->admin) {
374 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
377 dol_print_error($this->db);
381 if (!empty($htmlname)) {
382 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
404 public function select_state_ajax($parent_field_id =
'country_id', $selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
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);
413 return $html.
'</script><span id="target_'.$htmlname.
'">'.$this->
select_state($selected, $country_codeid, $htmlname, $morecss).
'</span>';
431 global
$conf, $langs;
432 $langs->load(
"dict");
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";
439 dol_syslog(get_class($this) .
"::select_region", LOG_DEBUG);
440 $resql = $this->db->query($sql);
442 print
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
443 $num = $this->db->num_rows($resql);
448 $obj = $this->db->fetch_object($resql);
449 if ($obj->code == 0) {
450 print
'<option value="0"> </option>';
452 if ($country ==
'' || $country != $obj->country) {
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;
460 if ($selected > 0 && $selected == $obj->code) {
461 print
'<option value="' . $obj->code .
'" selected>' . $obj->label .
'</option>';
463 print
'<option value="' . $obj->code .
'">' . $obj->label .
'</option>';
472 dol_print_error($this->db);
486 public function select_civility($selected =
'', $htmlname =
'civility_id', $morecss =
'maxwidth150', $addjscombo = 1)
489 global $langs, $user;
490 $langs->load(
"dict");
494 $sql =
"SELECT rowid, code, label, active FROM " . $this->db->prefix() .
"c_civility";
495 $sql .=
" WHERE active = 1";
497 dol_syslog(
"Form::select_civility", LOG_DEBUG);
498 $resql = $this->db->query($sql);
500 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
501 $out .=
'<option value=""> </option>';
502 $num = $this->db->num_rows($resql);
506 $obj = $this->db->fetch_object($resql);
507 if ($selected == $obj->code) {
508 $out .=
'<option value="' . $obj->code .
'" selected>';
510 $out .=
'<option value="' . $obj->code .
'">';
513 $out .= ($langs->trans(
"Civility" . $obj->code) !=
"Civility" . $obj->code ? $langs->trans(
"Civility" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
520 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
525 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
529 dol_print_error($this->db);
550 print $this->select_juridicalstatus($selected, $country_codeid, $filter);
565 public function select_juridicalstatus($selected = 0, $country_codeid = 0, $filter =
'', $htmlname =
'forme_juridique_code', $morecss =
'')
568 global $langs, $user;
569 $langs->load(
"dict");
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) .
"'";
586 $sql .=
" " . $sqlwhere;
589 $sql .=
" ORDER BY c.code";
591 dol_syslog(get_class($this) .
"::select_juridicalstatus", LOG_DEBUG);
592 $resql = $this->db->query($sql);
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"> </option>';
600 $num = $this->db->num_rows($resql);
605 $arraydata = array();
607 $obj = $this->db->fetch_object($resql);
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 :
''));
612 $arraydata[(int) $obj->code] = array(
'code' => (
int) $obj->code,
'label' => $labeljs,
'label_sort' => $labelcountry .
'_' . $labeljs,
'country_code' => (string) $obj->country_code,
'country' => $labelcountry);
618 if (empty($country_codeid)) {
619 $arraydata[0] = array(
'code' => 0,
'label' =>
'',
'label_sort' =>
'_',
'country_code' =>
'',
'country' =>
'');
622 foreach ($arraydata as $key => $val) {
623 if (!$country || $country != $val[
'country']) {
625 if (empty($country_codeid) && $val[
'country_code']) {
626 $out .=
'<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val[
'country'] .
" -----</option>\n";
627 $country = $val[
'country'];
631 if ($selected > 0 && $selected == $val[
'code']) {
632 $out .=
'<option value="' . $val[
'code'] .
'" selected>';
634 $out .=
'<option value="' . $val[
'code'] .
'">';
637 $out .= $val[
'label'];
643 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
647 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
652 dol_print_error($this->db);
674 global
$conf, $user, $hookmanager;
678 $minLength = (is_numeric(
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) ?
$conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
683 $tmpthirdparty =
new Societe($this->db);
684 $result = $tmpthirdparty->fetch($selected);
687 $name = $tmpthirdparty->name;
698 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
700 if (count($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);
711 $(this).trigger("blur");
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;
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);
729 if (response != null)
731 console.log("Change select#"+htmlname+" with content "+response.value)
732 $.each(obj.params, function(key,action) {
734 var num = response.num;
736 $("#" + key).removeAttr(action);
738 $("#" + key).attr(action, action);
742 $("select#" + htmlname).html(response.value);
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);
757 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias";
759 $sql .=
", s.code_client, s.code_fournisseur";
762 $sql .=
", s.address, s.zip, s.town";
763 $sql .=
", dictp.code as country_code";
765 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
767 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
770 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
") AND s.status = 1";
772 if (is_array($limitto) && count($limitto)) {
773 $sql .=
" AND s.rowid IN (" . $this->db->sanitize(implode(
',', $limitto)) .
")";
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 .
")";
779 if ($user->socid > 0) {
780 $sql .=
" AND s.rowid = ".((int) $user->socid);
783 $parameters = array();
784 $reshook = $hookmanager->executeHooks(
'selectCompaniesForNewContactListWhere', $parameters);
785 $sql .= $hookmanager->resPrint;
786 $sql .=
" ORDER BY s.nom ASC";
788 $resql = $this->db->query($sql);
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;";
793 print
' onChange="' . $javaScript .
'"';
796 print
'<option value="-1"> </option>';
798 $num = $this->db->num_rows($resql);
803 $obj = $this->db->fetch_object($resql);
805 $firstCompany = $obj->rowid;
808 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
811 $nameAlias = !empty($obj->name_alias) ?
' (' . $obj->name_alias .
')' :
'';
812 if ($selected > 0 && $selected == $obj->rowid) {
813 print
'<option value="' . $obj->rowid .
'"';
817 print
' selected>' .
dol_escape_htmltag($obj->name, 0, 0,
'', 0, 1) . $nameAlias .
'</option>';
818 $firstCompany = $obj->rowid;
820 print
'<option value="' . $obj->rowid .
'"';
824 print
'>' .
dol_escape_htmltag($obj->name, 0, 0,
'', 0, 1) . $nameAlias .
'</option>';
831 return $firstCompany;
833 dol_print_error($this->db);
853 public function selectTypeContact(
$object, $selected, $htmlname =
'type', $source =
'internal', $sortorder =
'position', $showempty = 0, $morecss =
'', $output = 1, $forcehidetooltip = 0)
855 global $user, $langs;
858 if (is_object(
$object) && method_exists(
$object,
'liste_type_contact')) {
859 '@phan-var-force CommonObject $object';
860 $lesTypes =
$object->liste_type_contact($source, $sortorder, 2, 1);
862 $out .=
'<select class="flat valignmiddle' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
864 $out .=
'<option value="0"> </option>';
866 foreach ($lesTypes as $key => $arrayvalue) {
867 $out .=
'<option value="'.$key.
'" data-code="'.$arrayvalue[
'code'].
'"';
868 if ($key == $selected) {
871 $out .=
'>'.$arrayvalue[
'label'].
'</option>';
874 if ($user->admin && empty($forcehidetooltip)) {
875 $out .=
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
882 if (empty($output)) {
900 public function showRoles($htmlname,
Contact $contact, $rendermode =
'view', $selected = array(), $morecss =
'minwidth500', $placeholder =
'')
902 if ($rendermode ===
'view') {
904 foreach ($contact->roles as $key => $val) {
905 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val[
'label'] .
'</li>';
907 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname .
'"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
910 if ($rendermode ===
'edit') {
911 $contactType = $contact->listeTypeContacts(
'external', 0, 1,
'',
'',
'agenda');
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'];
921 if (count($newselected) > 0) {
922 $selected = $newselected;
927 return $this->
multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss, 0,
'90%',
'',
'', $placeholder);
930 return 'ErrorBadValueForParameterRenderMode';
946 public function select_ziptown($selected =
'', $htmlname =
'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib =
'', $morecss =
'')
954 if (!empty($fieldsize)) {
955 $size =
'size="' . $fieldsize .
'"';
958 if (
$conf->use_javascript_ajax && empty($disableautocomplete)) {
960 $moreattrib .=
' autocomplete="off"';
962 $out .=
'<input id="' . $htmlname .
'" class="maxwidthonsmartphone' . ($morecss ?
' ' . $morecss :
'') .
'" type="text"' . ($moreattrib ?
' ' . $moreattrib :
'') .
' name="' . $htmlname .
'" ' . $size .
' value="' . $selected .
'">' .
"\n";
978 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss =
'maxwidth200')
983 require_once DOL_DOCUMENT_ROOT.
'/core/lib/profid.lib.php';
987 if ($country_code ==
'FR') {
990 } elseif ($idprof == 2) {
992 } elseif ($idprof == 3) {
994 } elseif ($idprof == 4) {
997 } elseif ($country_code ==
'ES') {
1000 } elseif ($idprof == 2) {
1002 } elseif ($idprof == 3) {
1004 } elseif ($idprof == 4) {
1010 $selected = $preselected;
1012 $maxlength = $formlength;
1014 if (empty($formlength)) {
1024 $dataprofid .=
isProfIdWithoutDot($idprof, $country_code) ?
' data-profidnodot="1"' :
'';
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 .
'">';
1034 $out .= $hookmanager->resPrint;
1054 $valors = explode(
":", $tax);
1055 $nbvalues = count($valors);
1057 if ($nbvalues > 1) {
1059 print
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1061 while ($i < $nbvalues) {
1062 if ($selected == $valors[$i]) {
1063 print
'<option value="' . $valors[$i] .
'" selected>';
1065 print
'<option value="' . $valors[$i] .
'">';
1087 public function selectProspectCustomerType($selected, $htmlname =
'client', $htmlidname =
'customerprospect', $typeinput =
'form', $morecss =
'', $allowempty =
'')
1089 global
$conf, $langs;
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)) {
1101 $out .= $langs->trans($allowempty);
1103 $out .=
'</option>';
1106 $out .=
'<option value="2"' . ($selected == 2 ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1109 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1112 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
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' :
'') .
'> </option>';
1118 $out .=
'<option value="2,3"' . ($selected ==
'2,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1121 $out .=
'<option value="1,3"' . ($selected ==
'1,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1124 $out .=
'<option value="4"' . ($selected ==
'4' ?
' selected' :
'') .
'>' . $langs->trans(
'Supplier') .
'</option>';
1126 $out .=
'<option value="0"' . ($selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'Other') .
'</option>';
1127 } elseif ($typeinput ==
'admin') {
1129 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1132 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1135 $out .=
'</select>';
1152 public function formThirdpartyType($page, $selected =
'', $htmlname =
'socid', $filter =
'', $nooutput = 0)
1155 global
$conf, $langs;
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() .
'">';
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") .
'">';
1167 if ($selected > 0) {
1169 $typent = empty($arr[$selected]) ?
'' : $arr[$selected];
1195 global $user, $langs;
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'];
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')) {
1208 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1210 $label = $val[
'label'];
1211 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1213 $label = (($langs->trans(
"StatusProspect".$val[
'code']) !=
"StatusProspect".$val[
'code']) ? $langs->trans(
"StatusProspect".$val[
'code']) : $label);
1215 $label = (($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id']) ? $langs->trans(
"StatusProspect".$val[
'id']) : $label);
1223 } elseif ($mode ===
"js") {
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");
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);
1240 console.error("Error on status prospect");
if(! $sortfield) if(! $sortorder) $object
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 ...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
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 ...
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 third parties objects (customers, suppliers, prospects...)
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)
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 ...