34require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
53 global $langs, $mysoc;
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) .
")";
61 $sql .=
" " . $filter;
63 $sql .=
" ORDER by position, id";
64 dol_syslog(get_class($this) .
'::typent_array', LOG_DEBUG);
65 $resql = $this->db->query($sql);
67 $num = $this->db->num_rows($resql);
71 $objp = $this->db->fetch_object($resql);
77 if ($langs->trans($objp->code) != $objp->code) {
78 $effs[$key] = $langs->trans($objp->code);
80 $effs[$key] = $objp->label;
82 if ($effs[$key] ==
'-') {
87 $this->db->free($resql);
106 $sql =
"SELECT id, code, libelle as label";
107 $sql .=
" FROM " . $this->db->prefix() .
"c_effectif";
108 $sql .=
" WHERE active = 1";
110 $sql .=
" " . $filter;
112 $sql .=
" ORDER BY id ASC";
113 dol_syslog(get_class($this) .
'::effectif_array', LOG_DEBUG);
114 $resql = $this->db->query($sql);
116 $num = $this->db->num_rows($resql);
120 $objp = $this->db->fetch_object($resql);
127 $effs[$key] = $objp->label !=
'-' ? $objp->label :
'';
130 $this->db->free($resql);
149 global $user, $langs;
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() .
'">';
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);
168 while ($obj = $this->db->fetch_object($resql)) {
169 $level = $langs->trans($obj->code);
171 if ($level == $obj->code) {
172 $level = $langs->trans($obj->label);
175 $options[$obj->code] = $level;
182 if (!empty($htmlname) && $user->admin) {
183 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
185 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
200 global $user, $langs;
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() .
'">';
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);
219 while ($obj = $this->db->fetch_object($resql)) {
220 $level = $langs->trans($obj->code);
222 if ($level == $obj->code) {
223 $level = $langs->trans($obj->label);
226 $options[$obj->code] = $level;
233 if (!empty($htmlname) && $user->admin) {
234 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
236 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
255 print $this->
select_state($selected, $country_codeid, $htmlname);
272 public function select_state($selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
275 global $conf, $langs, $user;
277 dol_syslog(get_class($this) .
"::select_departement selected=" . $selected .
", country_codeid=" . $country_codeid, LOG_DEBUG);
279 $langs->load(
"dict");
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) .
"'";
291 if ($country_codeid && !is_numeric($country_codeid)) {
292 $sql .=
" AND c.code = '" . $this->db->escape($country_codeid) .
"'";
294 $sql .=
" ORDER BY c.code, d.code_departement";
296 $result = $this->db->query($sql);
298 if (!empty($htmlname)) {
299 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
301 if ($country_codeid) {
302 $out .=
'<option value="0"> </option>';
304 $num = $this->db->num_rows($result);
306 dol_syslog(get_class($this) .
"::select_departement num=" . $num, LOG_DEBUG);
310 $obj = $this->db->fetch_object($result);
311 if ($obj->code ==
'0') {
312 $out .=
'<option value="0"> </option>';
314 if (!$country || $country != $obj->country) {
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;
322 if (!empty($selected) && $selected == $obj->rowid) {
323 $out .=
'<option value="' . $obj->rowid .
'" selected>';
325 $out .=
'<option value="' . $obj->rowid .
'">';
334 $out .= $obj->region_name .
' - ' . $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
336 $out .= $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
340 $out .= $obj->region_name .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
342 $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
351 if (!empty($htmlname)) {
354 if (!empty($htmlname) && $user->admin) {
355 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
362 if (!empty($htmlname)) {
363 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
385 public function select_state_ajax($parent_field_id =
'country_id', $selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
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);
394 return $html.
'</script><span id="target_'.$htmlname.
'">'.$this->
select_state($selected, $country_codeid, $htmlname, $morecss).
'</span>';
411 global $conf, $langs;
412 $langs->load(
"dict");
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";
419 dol_syslog(get_class($this) .
"::select_region", LOG_DEBUG);
420 $resql = $this->db->query($sql);
422 print
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
423 $num = $this->db->num_rows($resql);
428 $obj = $this->db->fetch_object($resql);
429 if ($obj->code == 0) {
430 print
'<option value="0"> </option>';
432 if ($country ==
'' || $country != $obj->country) {
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;
440 if ($selected > 0 && $selected == $obj->code) {
441 print
'<option value="' . $obj->code .
'" selected>' . $obj->label .
'</option>';
443 print
'<option value="' . $obj->code .
'">' . $obj->label .
'</option>';
466 public function select_civility($selected =
'', $htmlname =
'civility_id', $morecss =
'maxwidth150', $addjscombo = 1)
469 global $conf, $langs, $user;
470 $langs->load(
"dict");
474 $sql =
"SELECT rowid, code, label, active FROM " . $this->db->prefix() .
"c_civility";
475 $sql .=
" WHERE active = 1";
477 dol_syslog(
"Form::select_civility", LOG_DEBUG);
478 $resql = $this->db->query($sql);
480 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
481 $out .=
'<option value=""> </option>';
482 $num = $this->db->num_rows($resql);
486 $obj = $this->db->fetch_object($resql);
487 if ($selected == $obj->code) {
488 $out .=
'<option value="' . $obj->code .
'" selected>';
490 $out .=
'<option value="' . $obj->code .
'">';
493 $out .= ($langs->trans(
"Civility" . $obj->code) !=
"Civility" . $obj->code ? $langs->trans(
"Civility" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
500 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
505 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
545 public function select_juridicalstatus($selected =
'', $country_codeid = 0, $filter =
'', $htmlname =
'forme_juridique_code', $morecss =
'')
548 global $conf, $langs, $user;
549 $langs->load(
"dict");
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) .
"'";
562 $sql .=
" " . $filter;
564 $sql .=
" ORDER BY c.code";
566 dol_syslog(get_class($this) .
"::select_juridicalstatus", LOG_DEBUG);
567 $resql = $this->db->query($sql);
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"> </option>';
575 $num = $this->db->num_rows($resql);
579 $arraydata = array();
581 $obj = $this->db->fetch_object($resql);
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 :
''));
586 $arraydata[$obj->code] = array(
'code' => $obj->code,
'label' => $labeljs,
'label_sort' => $labelcountry .
'_' . $labeljs,
'country_code' => $obj->country_code,
'country' => $labelcountry);
592 if (empty($country_codeid)) {
593 $arraydata[0] = array(
'code' => 0,
'label' =>
'',
'label_sort' =>
'_',
'country_code' =>
'',
'country' =>
'');
596 foreach ($arraydata as $key => $val) {
597 if (!$country || $country != $val[
'country']) {
599 if (empty($country_codeid) && $val[
'country_code']) {
600 $out .=
'<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val[
'country'] .
" -----</option>\n";
601 $country = $val[
'country'];
605 if ($selected > 0 && $selected == $val[
'code']) {
606 $out .=
'<option value="' . $val[
'code'] .
'" selected>';
608 $out .=
'<option value="' . $val[
'code'] .
'">';
611 $out .= $val[
'label'];
617 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
621 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
646 public function selectCompaniesForNewContact($object, $var_id, $selected =
'', $htmlname =
'newcompany', $limitto =
'', $forceid = 0, $moreparam =
'', $morecss =
'')
648 global $conf, $hookmanager;
650 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) {
652 $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
657 $tmpthirdparty =
new Societe($this->db);
658 $result = $tmpthirdparty->fetch($selected);
661 $name = $tmpthirdparty->name;
672 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
674 if (count($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);
685 $(this).trigger("blur");
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;
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);
703 if (response != null)
705 console.log("Change select#"+htmlname+" with content "+response.value)
706 $.each(obj.params, function(key,action) {
708 var num = response.num;
710 $("#" + key).removeAttr(action);
712 $("#" + key).attr(action, action);
716 $("select#" + htmlname).html(response.value);
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);
731 $sql =
"SELECT s.rowid, s.nom as name ";
733 $sql .=
", s.code_client, s.code_fournisseur";
736 $sql .=
", s.address, s.zip, s.town";
737 $sql .=
", dictp.code as country_code";
739 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
741 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
743 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
")";
745 if (is_array($limitto) && count($limitto)) {
746 $sql .=
" AND s.rowid IN (" . $this->db->sanitize(join(
',', $limitto)) .
")";
749 $parameters = array();
750 $reshook = $hookmanager->executeHooks(
'selectCompaniesForNewContactListWhere', $parameters);
751 $sql .= $hookmanager->resPrint;
752 $sql .=
" ORDER BY s.nom ASC";
754 $resql = $this->db->query($sql);
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 .
'"';
762 print
'<option value="-1"> </option>';
764 $num = $this->db->num_rows($resql);
768 $obj = $this->db->fetch_object($resql);
770 $firstCompany = $obj->rowid;
773 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
776 if ($selected > 0 && $selected == $obj->rowid) {
777 print
'<option value="' . $obj->rowid .
'"';
782 $firstCompany = $obj->rowid;
784 print
'<option value="' . $obj->rowid .
'"';
795 return $firstCompany;
817 public function selectTypeContact($object, $selected, $htmlname =
'type', $source =
'internal', $sortorder =
'position', $showempty = 0, $morecss =
'', $output = 1, $forcehidetooltip = 0)
819 global $user, $langs;
822 if (is_object($object) && method_exists($object,
'liste_type_contact')) {
823 $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1);
825 $out .=
'<select class="flat valignmiddle' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
827 $out .=
'<option value="0"> </option>';
829 foreach ($lesTypes as $key => $value) {
830 $out .=
'<option value="' . $key .
'"';
831 if ($key == $selected) {
834 $out .=
'>' . $value .
'</option>';
837 if ($user->admin && empty($forcehidetooltip)) {
838 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
845 if (empty($output)) {
862 public function showRoles($htmlname,
Contact $contact, $rendermode =
'view', $selected = array(), $morecss =
'minwidth500')
864 if ($rendermode ===
'view') {
866 foreach ($contact->roles as $key => $val) {
867 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val[
'label'] .
'</li>';
869 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname .
'"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
872 if ($rendermode ===
'edit') {
873 $contactType = $contact->listeTypeContacts(
'external',
'', 1,
'',
'',
'agenda');
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'];
883 if (count($newselected) > 0) {
884 $selected = $newselected;
887 return $this->
multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss);
890 return 'ErrorBadValueForParameterRenderMode';
906 public function select_ziptown($selected =
'', $htmlname =
'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib =
'', $morecss =
'')
914 if (!empty($fieldsize)) {
915 $size =
'size="' . $fieldsize .
'"';
918 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
920 $moreattrib .=
' autocomplete="off"';
922 $out .=
'<input id="' . $htmlname .
'" class="maxwidthonsmartphone' . ($morecss ?
' ' . $morecss :
'') .
'" type="text"' . ($moreattrib ?
' ' . $moreattrib :
'') .
' name="' . $htmlname .
'" ' . $size .
' value="' . $selected .
'">' .
"\n";
938 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss =
'maxwidth200')
941 global $conf, $langs, $hookmanager;
945 if ($country_code ==
'FR') {
946 if (isset($idprof)) {
949 } elseif ($idprof == 2) {
951 } elseif ($idprof == 3) {
953 } elseif ($idprof == 4) {
957 } elseif ($country_code ==
'ES') {
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;
986 $maxlength = $formlength;
987 if (empty($formlength)) {
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 .
'">';
1000 $out .= $hookmanager->resPrint;
1020 $valors = explode(
":", $tax);
1021 $nbvalues = count($valors);
1023 if ($nbvalues > 1) {
1025 print
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1027 while ($i < $nbvalues) {
1028 if ($selected == $valors[$i]) {
1029 print
'<option value="' . $valors[$i] .
'" selected>';
1031 print
'<option value="' . $valors[$i] .
'">';
1053 public function selectProspectCustomerType($selected, $htmlname =
'client', $htmlidname =
'customerprospect', $typeinput =
'form', $morecss =
'', $allowempty =
'')
1055 global $conf, $langs;
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)) {
1067 $out .= $langs->trans($allowempty);
1069 $out .=
'</option>';
1072 $out .=
'<option value="2"' . ($selected == 2 ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1075 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1078 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
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' :
'') .
'> </option>';
1084 $out .=
'<option value="2,3"' . ($selected ==
'2,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1087 $out .=
'<option value="1,3"' . ($selected ==
'1,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1089 if (isModEnabled(
"fournisseur")) {
1090 $out .=
'<option value="4"' . ($selected ==
'4' ?
' selected' :
'') .
'>' . $langs->trans(
'Supplier') .
'</option>';
1092 $out .=
'<option value="0"' . ($selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'Other') .
'</option>';
1093 } elseif ($typeinput ==
'admin') {
1095 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1098 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1101 $out .=
'</select>';
1117 public function formThirdpartyType($page, $selected =
'', $htmlname =
'socid', $filter =
'', $nooutput = 0)
1120 global $conf, $langs;
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);
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") .
'">';
1132 if ($selected > 0) {
1134 $typent = $arr[$selected];
1160 global $user, $langs;
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'];
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')) {
1173 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1175 $label = $val[
'label'];
1176 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1178 $label = (($langs->trans(
"StatusProspect".$val[
'code']) !=
"StatusProspect".$val[
'code']) ? $langs->trans(
"StatusProspect".$val[
'code']) : $label);
1180 $label = (($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id']) ? $langs->trans(
"StatusProspect".$val[
'id']) : $label);
1188 } elseif ($mode ===
"js") {
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");
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);
1205 console.error("Error on status prospect");
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...
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 field into an au...
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...