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' :
$mysoc->country_id) .
")";
63 $sql .=
" " . $filter;
65 $sql .=
" ORDER by position, id";
66 dol_syslog(get_class($this) .
'::typent_array', LOG_DEBUG);
67 $resql = $this->db->query($sql);
69 $num = $this->db->num_rows($resql);
73 $objp = $this->db->fetch_object($resql);
79 if ($langs->trans($objp->code) != $objp->code) {
80 $effs[$key] = $langs->trans($objp->code);
82 $effs[$key] = $objp->label;
84 if ($effs[$key] ==
'-') {
89 $this->db->free($resql);
108 $sql =
"SELECT id, code, libelle as label";
109 $sql .=
" FROM " . $this->db->prefix() .
"c_effectif";
110 $sql .=
" WHERE active = 1";
112 $sql .=
" " . $filter;
114 $sql .=
" ORDER BY id ASC";
115 dol_syslog(get_class($this) .
'::effectif_array', LOG_DEBUG);
116 $resql = $this->db->query($sql);
118 $num = $this->db->num_rows($resql);
122 $objp = $this->db->fetch_object($resql);
129 $effs[$key] = $objp->label !=
'-' ? (string) $objp->label :
'';
132 $this->db->free($resql);
136 '@phan-var-force array<string,string> $effs';
154 global $user, $langs;
156 print
'<form method="post" action="' . $page .
'">';
157 print
'<input type="hidden" name="action" value="setprospectlevel">';
158 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
160 dol_syslog(get_class($this) .
'::form_prospect_level', LOG_DEBUG);
161 $sql =
"SELECT code, label";
162 $sql .=
" FROM " . $this->db->prefix() .
"c_prospectlevel";
163 $sql .=
" WHERE active > 0";
164 $sql .=
" ORDER BY sortorder";
165 $resql = $this->db->query($sql);
173 while ($obj = $this->db->fetch_object($resql)) {
174 $level = $langs->trans($obj->code);
176 if ($level == $obj->code) {
177 $level = $langs->trans($obj->label);
180 $options[$obj->code] = $level;
187 if (!empty($htmlname) && $user->admin) {
188 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
190 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
205 global $user, $langs;
207 print
'<form method="post" action="' . $page .
'">';
208 print
'<input type="hidden" name="action" value="setprospectcontactlevel">';
209 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
212 $sql =
"SELECT code, label";
213 $sql .=
" FROM " . $this->db->prefix() .
"c_prospectcontactlevel";
214 $sql .=
" WHERE active > 0";
215 $sql .=
" ORDER BY sortorder";
216 $resql = $this->db->query($sql);
224 while ($obj = $this->db->fetch_object($resql)) {
225 $level = $langs->trans($obj->code);
227 if ($level == $obj->code) {
228 $level = $langs->trans($obj->label);
231 $options[$obj->code] = $level;
238 if (!empty($htmlname) && $user->admin) {
239 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
241 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
260 print $this->
select_state((
int) $selected, $country_codeid, $htmlname);
277 public function select_state($selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
280 global $conf, $langs, $user;
282 dol_syslog(get_class($this) .
"::select_departement selected=" . $selected .
", country_codeid=" . $country_codeid, LOG_DEBUG);
284 $langs->load(
"dict");
289 $sql =
"SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM";
290 $sql .=
" " . $this->db->prefix() .
"c_departements as d, " . $this->db->prefix() .
"c_regions as r," . $this->db->prefix() .
"c_country as c";
291 $sql .=
" WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
292 $sql .=
" AND d.active = 1 AND r.active = 1 AND c.active = 1";
293 if ($country_codeid && is_numeric($country_codeid)) {
294 $sql .=
" AND c.rowid = '" . $this->db->escape($country_codeid) .
"'";
296 if ($country_codeid && !is_numeric($country_codeid)) {
297 $sql .=
" AND c.code = '" . $this->db->escape($country_codeid) .
"'";
299 $sql .=
" ORDER BY c.code, d.code_departement";
301 $result = $this->db->query($sql);
303 if (!empty($htmlname)) {
304 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
306 if ($country_codeid) {
307 $out .=
'<option value="0"> </option>';
309 $num = $this->db->num_rows($result);
311 dol_syslog(get_class($this) .
"::select_departement num=" . $num, LOG_DEBUG);
315 $obj = $this->db->fetch_object($result);
316 if ($obj->code ==
'0') {
317 $out .=
'<option value="0"> </option>';
319 if (!$country || $country != $obj->country) {
321 if (!$country_codeid && $obj->country_code) {
322 $out .=
'<option value="-1" disabled data-html="----- ' . $obj->country .
' -----">----- ' . $obj->country .
" -----</option>\n";
323 $country = $obj->country;
327 if (!empty($selected) && $selected == $obj->rowid) {
328 $out .=
'<option value="' . $obj->rowid .
'" selected>';
330 $out .=
'<option value="' . $obj->rowid .
'">';
339 $out .= $obj->region_name .
' - ' . $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
341 $out .= $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
345 $out .= $obj->region_name .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
347 $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
356 if (!empty($htmlname)) {
359 if (!empty($htmlname) && $user->admin) {
360 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
367 if (!empty($htmlname)) {
368 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
390 public function select_state_ajax($parent_field_id =
'country_id', $selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
393 $html .=
'$("select[name=\"'.$parent_field_id.
'\"]").change(function(){
394 $.ajax( "'.
dol_buildpath(
'/core/ajax/ziptown.php', 2).
'", { data:{ selected: $("select[name=\"'.$htmlname.
'\"]").val(), country_codeid: $(this).val(), htmlname:"'.$htmlname.
'", morecss:"'.$morecss.
'" } } )
395 .done(function(msg) {
396 $("span#target_'.$htmlname.
'").html(msg);
399 return $html.
'</script><span id="target_'.$htmlname.
'">'.$this->
select_state($selected, $country_codeid, $htmlname, $morecss).
'</span>';
417 global $conf, $langs;
418 $langs->load(
"dict");
420 $sql =
"SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country";
421 $sql .=
" FROM " . $this->db->prefix() .
"c_regions as r, " . $this->db->prefix() .
"c_country as c";
422 $sql .=
" WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1";
423 $sql .=
" ORDER BY c.code, c.label ASC";
425 dol_syslog(get_class($this) .
"::select_region", LOG_DEBUG);
426 $resql = $this->db->query($sql);
428 print
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
429 $num = $this->db->num_rows($resql);
434 $obj = $this->db->fetch_object($resql);
435 if ($obj->code == 0) {
436 print
'<option value="0"> </option>';
438 if ($country ==
'' || $country != $obj->country) {
440 $key = $langs->trans(
"Country" . strtoupper($obj->country_code));
441 $valuetoshow = ($key !=
"Country" . strtoupper($obj->country_code)) ? $obj->country_code .
" - " . $key : $obj->country;
442 print
'<option value="-2" disabled>----- ' . $valuetoshow .
" -----</option>\n";
443 $country = $obj->country;
446 if ($selected > 0 && $selected == $obj->code) {
447 print
'<option value="' . $obj->code .
'" selected>' . $obj->label .
'</option>';
449 print
'<option value="' . $obj->code .
'">' . $obj->label .
'</option>';
472 public function select_civility($selected =
'', $htmlname =
'civility_id', $morecss =
'maxwidth150', $addjscombo = 1)
475 global $langs, $user;
476 $langs->load(
"dict");
480 $sql =
"SELECT rowid, code, label, active FROM " . $this->db->prefix() .
"c_civility";
481 $sql .=
" WHERE active = 1";
483 dol_syslog(
"Form::select_civility", LOG_DEBUG);
484 $resql = $this->db->query($sql);
486 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
487 $out .=
'<option value=""> </option>';
488 $num = $this->db->num_rows($resql);
492 $obj = $this->db->fetch_object($resql);
493 if ($selected == $obj->code) {
494 $out .=
'<option value="' . $obj->code .
'" selected>';
496 $out .=
'<option value="' . $obj->code .
'">';
499 $out .= ($langs->trans(
"Civility" . $obj->code) !=
"Civility" . $obj->code ? $langs->trans(
"Civility" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
506 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
511 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
536 print $this->select_juridicalstatus($selected, $country_codeid, $filter);
551 public function select_juridicalstatus($selected = 0, $country_codeid = 0, $filter =
'', $htmlname =
'forme_juridique_code', $morecss =
'')
554 global $conf, $langs, $user;
555 $langs->load(
"dict");
560 $sql =
"SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code";
561 $sql .=
" FROM " . $this->db->prefix() .
"c_forme_juridique as f, " . $this->db->prefix() .
"c_country as c";
562 $sql .=
" WHERE f.fk_pays=c.rowid";
563 $sql .=
" AND f.active = 1 AND c.active = 1";
564 if ($country_codeid) {
565 $sql .=
" AND c.code = '" . $this->db->escape((
string) $country_codeid) .
"'";
568 $sql .=
" " . $filter;
570 $sql .=
" ORDER BY c.code";
572 dol_syslog(get_class($this) .
"::select_juridicalstatus", LOG_DEBUG);
573 $resql = $this->db->query($sql);
575 $out .=
'<div id="particulier2" class="visible">';
576 $out .=
'<select class="flat minwidth200' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
577 if ($country_codeid) {
578 $out .=
'<option value="0"> </option>';
581 $num = $this->db->num_rows($resql);
586 $arraydata = array();
588 $obj = $this->db->fetch_object($resql);
591 $labelcountry = (($langs->trans(
"Country" . $obj->country_code) !=
"Country" . $obj->country_code) ? $langs->trans(
"Country" . $obj->country_code) : $obj->country);
592 $labeljs = (($langs->trans(
"JuridicalStatus" . $obj->code) !=
"JuridicalStatus" . $obj->code) ? $langs->trans(
"JuridicalStatus" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
593 $arraydata[(int) $obj->code] = array(
'code' => (
int) $obj->code,
'label' => $labeljs,
'label_sort' => $labelcountry .
'_' . $labeljs,
'country_code' => (string) $obj->country_code,
'country' => $labelcountry);
599 if (empty($country_codeid)) {
600 $arraydata[0] = array(
'code' => 0,
'label' =>
'',
'label_sort' =>
'_',
'country_code' =>
'',
'country' =>
'');
603 foreach ($arraydata as $key => $val) {
604 if (!$country || $country != $val[
'country']) {
606 if (empty($country_codeid) && $val[
'country_code']) {
607 $out .=
'<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val[
'country'] .
" -----</option>\n";
608 $country = $val[
'country'];
612 if ($selected > 0 && $selected == $val[
'code']) {
613 $out .=
'<option value="' . $val[
'code'] .
'" selected>';
615 $out .=
'<option value="' . $val[
'code'] .
'">';
618 $out .= $val[
'label'];
624 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
628 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
655 global $conf, $user, $hookmanager;
657 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) {
659 $minLength = (is_numeric(
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
664 $tmpthirdparty =
new Societe($this->db);
665 $result = $tmpthirdparty->fetch($selected);
668 $name = $tmpthirdparty->name;
679 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
681 if (count($events)) {
682 print
'<script nonce="' .
getNonce() .
'" type="text/javascript">
683 jQuery(document).ready(function() {
684 $("#search_' . $htmlname .
'").change(function() {
685 var obj = ' . json_encode($events) .
';
686 $.each(obj, function(key,values) {
687 if (values.method.length) {
688 runJsCodeForEvent' . $htmlname .
'(values);
692 $(this).trigger("blur");
695 // Function used to execute events when search_htmlname change
696 function runJsCodeForEvent' . $htmlname .
'(obj) {
697 var id = $("#' . $htmlname .
'").val();
698 var method = obj.method;
700 var htmlname = obj.htmlname;
701 var showempty = obj.showempty;
702 console.log("Run runJsCodeForEvent-' . $htmlname .
' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
710 if (response != null)
712 console.log("Change select#"+htmlname+" with content "+response.value)
713 $.each(obj.params, function(key,action) {
715 var num = response.num;
717 $("#" + key).removeAttr(action);
719 $("#" + key).attr(action, action);
723 $("select#" + htmlname).html(response.value);
732 print
"\n" .
'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' .
"\n";
733 print
'<input type="text" size="30" id="search_' . $htmlname .
'" name="search_' . $htmlname .
'" value="' . $name .
'" />';
734 print
ajax_autocompleter((
string) ($socid ? $socid : -1), $htmlname, DOL_URL_ROOT .
'/societe/ajax/ajaxcompanies.php',
'', $minLength, 0);
738 $sql =
"SELECT s.rowid, s.nom as name ";
740 $sql .=
", s.code_client, s.code_fournisseur";
743 $sql .=
", s.address, s.zip, s.town";
744 $sql .=
", dictp.code as country_code";
746 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
748 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
751 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
") AND s.status = 1";
753 if (is_array($limitto) && count($limitto)) {
754 $sql .=
" AND s.rowid IN (" . $this->db->sanitize(implode(
',', $limitto)) .
")";
757 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
758 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = s.rowid AND sc.fk_user = ".(int) $user->id .
")";
760 if ($user->socid > 0) {
761 $sql .=
" AND s.rowid = ".((int) $user->socid);
764 $parameters = array();
765 $reshook = $hookmanager->executeHooks(
'selectCompaniesForNewContactListWhere', $parameters);
766 $sql .= $hookmanager->resPrint;
767 $sql .=
" ORDER BY s.nom ASC";
769 $resql = $this->db->query($sql);
771 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"';
772 if ($conf->use_javascript_ajax) {
773 $javaScript =
"window.location='" .
dol_escape_js($_SERVER[
'PHP_SELF']) .
"?" . $var_id .
"=" . ($forceid > 0 ? $forceid :
$object->id) . $moreparam .
"&" . $htmlname .
"=' + form." . $htmlname .
".options[form." . $htmlname .
".selectedIndex].value;";
774 print
' onChange="' . $javaScript .
'"';
777 print
'<option value="-1"> </option>';
779 $num = $this->db->num_rows($resql);
784 $obj = $this->db->fetch_object($resql);
786 $firstCompany = $obj->rowid;
789 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
792 if ($selected > 0 && $selected == $obj->rowid) {
793 print
'<option value="' . $obj->rowid .
'"';
798 $firstCompany = $obj->rowid;
800 print
'<option value="' . $obj->rowid .
'"';
811 return $firstCompany;
833 public function selectTypeContact(
$object, $selected, $htmlname =
'type', $source =
'internal', $sortorder =
'position', $showempty = 0, $morecss =
'', $output = 1, $forcehidetooltip = 0)
835 global $user, $langs;
838 if (is_object(
$object) && method_exists(
$object,
'liste_type_contact')) {
839 '@phan-var-force CommonObject $object';
840 $lesTypes =
$object->liste_type_contact($source, $sortorder, 2, 1);
842 $out .=
'<select class="flat valignmiddle' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
844 $out .=
'<option value="0"> </option>';
846 foreach ($lesTypes as $key => $arrayvalue) {
847 $out .=
'<option value="'.$key.
'" data-code="'.$arrayvalue[
'code'].
'"';
848 if ($key == $selected) {
851 $out .=
'>'.$arrayvalue[
'label'].
'</option>';
854 if ($user->admin && empty($forcehidetooltip)) {
855 $out .=
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
862 if (empty($output)) {
880 public function showRoles($htmlname,
Contact $contact, $rendermode =
'view', $selected = array(), $morecss =
'minwidth500', $placeholder =
'')
882 if ($rendermode ===
'view') {
884 foreach ($contact->roles as $key => $val) {
885 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val[
'label'] .
'</li>';
887 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname .
'"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
890 if ($rendermode ===
'edit') {
891 $contactType = $contact->listeTypeContacts(
'external', 0, 1,
'',
'',
'agenda');
892 if (count($selected) > 0) {
893 $newselected = array();
894 foreach ($selected as $key => $val) {
895 if (is_array($val) && array_key_exists(
'id', $val) && in_array($val[
'id'], array_keys($contactType))) {
896 $newselected[] = $val[
'id'];
901 if (count($newselected) > 0) {
902 $selected = $newselected;
905 return $this->
multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss, 0,
'90%',
'',
'', $placeholder);
908 return 'ErrorBadValueForParameterRenderMode';
924 public function select_ziptown($selected =
'', $htmlname =
'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib =
'', $morecss =
'')
932 if (!empty($fieldsize)) {
933 $size =
'size="' . $fieldsize .
'"';
936 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
938 $moreattrib .=
' autocomplete="off"';
940 $out .=
'<input id="' . $htmlname .
'" class="maxwidthonsmartphone' . ($morecss ?
' ' . $morecss :
'') .
'" type="text"' . ($moreattrib ?
' ' . $moreattrib :
'') .
' name="' . $htmlname .
'" ' . $size .
' value="' . $selected .
'">' .
"\n";
956 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss =
'maxwidth200')
959 global $conf, $langs, $hookmanager;
963 if ($country_code ==
'FR') {
964 if (isset($idprof)) {
967 } elseif ($idprof == 2) {
969 } elseif ($idprof == 3) {
971 } elseif ($idprof == 4) {
975 } elseif ($country_code ==
'ES') {
991 $selected = $preselected;
992 if (!$selected && isset($idprof)) {
993 if ($idprof == 1 && !empty($this->idprof1)) {
994 $selected = $this->idprof1;
995 } elseif ($idprof == 2 && !empty($this->idprof2)) {
996 $selected = $this->idprof2;
997 } elseif ($idprof == 3 && !empty($this->idprof3)) {
998 $selected = $this->idprof3;
999 } elseif ($idprof == 4 && !empty($this->idprof4)) {
1000 $selected = $this->idprof4;
1004 $maxlength = $formlength;
1006 if (empty($formlength)) {
1014 $parameters = array(
'formlength' => $formlength,
'selected' => $preselected,
'idprof' => $idprof,
'htmlname' => $htmlname,
'country_code' => $country_code);
1015 $reshook = $hookmanager->executeHooks(
'getInputIdProf', $parameters);
1016 if (empty($reshook)) {
1017 $out .=
'<input type="text" ' . ($morecss ?
'class="' . $morecss .
'" ' :
'') .
'name="' . $htmlname .
'" id="' . $htmlname .
'" maxlength="' . $maxlength .
'" value="' . $selected .
'">';
1019 $out .= $hookmanager->resPrint;
1039 $valors = explode(
":", $tax);
1040 $nbvalues = count($valors);
1042 if ($nbvalues > 1) {
1044 print
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1046 while ($i < $nbvalues) {
1047 if ($selected == $valors[$i]) {
1048 print
'<option value="' . $valors[$i] .
'" selected>';
1050 print
'<option value="' . $valors[$i] .
'">';
1072 public function selectProspectCustomerType($selected, $htmlname =
'client', $htmlidname =
'customerprospect', $typeinput =
'form', $morecss =
'', $allowempty =
'')
1074 global $conf, $langs;
1079 $out =
'<select class="flat ' . $morecss .
'" name="' . $htmlname .
'" id="' . $htmlidname .
'">';
1080 if ($typeinput ==
'form') {
1081 if ($allowempty || ($selected ==
'' || $selected ==
'-1')) {
1082 $out .=
'<option value="-1">';
1083 if (is_numeric($allowempty)) {
1086 $out .= $langs->trans($allowempty);
1088 $out .=
'</option>';
1091 $out .=
'<option value="2"' . ($selected == 2 ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1094 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1097 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1099 $out .=
'<option value="0"' . ((string) $selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'NorProspectNorCustomer') .
'</option>';
1100 } elseif ($typeinput ==
'list') {
1101 $out .=
'<option value="-1"' . (($selected ==
'' || $selected ==
'-1') ?
' selected' :
'') .
'> </option>';
1103 $out .=
'<option value="2,3"' . ($selected ==
'2,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1106 $out .=
'<option value="1,3"' . ($selected ==
'1,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1109 $out .=
'<option value="4"' . ($selected ==
'4' ?
' selected' :
'') .
'>' . $langs->trans(
'Supplier') .
'</option>';
1111 $out .=
'<option value="0"' . ($selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'Other') .
'</option>';
1112 } elseif ($typeinput ==
'admin') {
1114 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1117 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1120 $out .=
'</select>';
1137 public function formThirdpartyType($page, $selected =
'', $htmlname =
'socid', $filter =
'', $nooutput = 0)
1140 global $conf, $langs;
1143 if ($htmlname !=
"none") {
1144 $out .=
'<form method="post" action="' . $page .
'">';
1145 $out .=
'<input type="hidden" name="action" value="set_thirdpartytype">';
1146 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1148 $out .= $this->
selectarray($htmlname, $this->
typent_array(0, $filter), $selected, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1149 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
1152 if ($selected > 0) {
1154 $typent = empty($arr[$selected]) ?
'' : $arr[$selected];
1180 global $user, $langs;
1182 if ($mode ===
"html") {
1183 $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'code'];
1184 $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect][
'picto']) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'picto'];
1187 print
img_action(
'', $actioncode, $actionpicto,
'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1188 print
'<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .
'" data-socid="'.$idprospect.
'" name="' . $htmlname .
'"';
1189 if (!$user->hasRight(
'societe',
'creer')) {
1193 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1195 $label = $val[
'label'];
1196 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1198 $label = (($langs->trans(
"StatusProspect".$val[
'code']) !=
"StatusProspect".$val[
'code']) ? $langs->trans(
"StatusProspect".$val[
'code']) : $label);
1200 $label = (($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id']) ? $langs->trans(
"StatusProspect".$val[
'id']) : $label);
1208 } elseif ($mode ===
"js") {
1210 jQuery(document).ready(function() {
1211 $(".selectprospectstatus").on("change", function() {
1212 console.log("We change a value into a field selectprospectstatus");
1213 var statusid = $(this).val();
1214 var prospectid = $(this).attr("data-socid");
1215 var image = $(this).prev(".pictoprospectstatus");
1218 url: \'' . DOL_URL_ROOT .
'/core/ajax/ajaxstatusprospect.php\',
1219 data: { id: statusid, prospectid: prospectid, token: \''.
newToken() .
'\', action: \
'updatestatusprospect\' },
1220 success: function(response) {
1221 console.log(response.img);
1222 image.replaceWith(response.img);
1225 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='')
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 ...
Class to manage third parties objects (customers, suppliers, prospects...)
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
get_localtax_by_third($local)
Get values of localtaxes (1 or 2) for company country for the common vat with the highest value.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getNonce()
Return a random string to be used as a nonce value for js.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...