36require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
55 global $langs, $mysoc;
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($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
$conf, $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';
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($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);
585 $arraydata = array();
587 $obj = $this->db->fetch_object($resql);
590 $labelcountry = (($langs->trans(
"Country" . $obj->country_code) !=
"Country" . $obj->country_code) ? $langs->trans(
"Country" . $obj->country_code) : $obj->country);
591 $labeljs = (($langs->trans(
"JuridicalStatus" . $obj->code) !=
"JuridicalStatus" . $obj->code) ? $langs->trans(
"JuridicalStatus" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
592 $arraydata[$obj->code] = array(
'code' => $obj->code,
'label' => $labeljs,
'label_sort' => $labelcountry .
'_' . $labeljs,
'country_code' => $obj->country_code,
'country' => $labelcountry);
598 if (empty($country_codeid)) {
599 $arraydata[0] = array(
'code' => 0,
'label' =>
'',
'label_sort' =>
'_',
'country_code' =>
'',
'country' =>
'');
602 foreach ($arraydata as $key => $val) {
603 if (!$country || $country != $val[
'country']) {
605 if (empty($country_codeid) && $val[
'country_code']) {
606 $out .=
'<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val[
'country'] .
" -----</option>\n";
607 $country = $val[
'country'];
611 if ($selected > 0 && $selected == $val[
'code']) {
612 $out .=
'<option value="' . $val[
'code'] .
'" selected>';
614 $out .=
'<option value="' . $val[
'code'] .
'">';
617 $out .= $val[
'label'];
623 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
627 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
654 global
$conf, $hookmanager;
658 $minLength = (is_numeric(
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) ?
$conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
663 $tmpthirdparty =
new Societe($this->db);
664 $result = $tmpthirdparty->fetch($selected);
667 $name = $tmpthirdparty->name;
678 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
680 if (count($events)) {
681 print
'<script nonce="' .
getNonce() .
'" type="text/javascript">
682 jQuery(document).ready(function() {
683 $("#search_' . $htmlname .
'").change(function() {
684 var obj = ' . json_encode($events) .
';
685 $.each(obj, function(key,values) {
686 if (values.method.length) {
687 runJsCodeForEvent' . $htmlname .
'(values);
691 $(this).trigger("blur");
694 // Function used to execute events when search_htmlname change
695 function runJsCodeForEvent' . $htmlname .
'(obj) {
696 var id = $("#' . $htmlname .
'").val();
697 var method = obj.method;
699 var htmlname = obj.htmlname;
700 var showempty = obj.showempty;
701 console.log("Run runJsCodeForEvent-' . $htmlname .
' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
709 if (response != null)
711 console.log("Change select#"+htmlname+" with content "+response.value)
712 $.each(obj.params, function(key,action) {
714 var num = response.num;
716 $("#" + key).removeAttr(action);
718 $("#" + key).attr(action, action);
722 $("select#" + htmlname).html(response.value);
731 print
"\n" .
'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' .
"\n";
732 print
'<input type="text" size="30" id="search_' . $htmlname .
'" name="search_' . $htmlname .
'" value="' . $name .
'" />';
733 print
ajax_autocompleter((
string) ($socid ? $socid : -1), $htmlname, DOL_URL_ROOT .
'/societe/ajax/ajaxcompanies.php',
'', $minLength, 0);
737 $sql =
"SELECT s.rowid, s.nom as name ";
739 $sql .=
", s.code_client, s.code_fournisseur";
742 $sql .=
", s.address, s.zip, s.town";
743 $sql .=
", dictp.code as country_code";
745 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
747 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
749 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
")";
751 if (is_array($limitto) && count($limitto)) {
752 $sql .=
" AND s.rowid IN (" . $this->db->sanitize(implode(
',', $limitto)) .
")";
755 $parameters = array();
756 $reshook = $hookmanager->executeHooks(
'selectCompaniesForNewContactListWhere', $parameters);
757 $sql .= $hookmanager->resPrint;
758 $sql .=
" ORDER BY s.nom ASC";
760 $resql = $this->db->query($sql);
762 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"';
763 if (
$conf->use_javascript_ajax) {
764 $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;";
765 print
' onChange="' . $javaScript .
'"';
768 print
'<option value="-1"> </option>';
770 $num = $this->db->num_rows($resql);
775 $obj = $this->db->fetch_object($resql);
777 $firstCompany = $obj->rowid;
780 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
783 if ($selected > 0 && $selected == $obj->rowid) {
784 print
'<option value="' . $obj->rowid .
'"';
789 $firstCompany = $obj->rowid;
791 print
'<option value="' . $obj->rowid .
'"';
802 return $firstCompany;
824 public function selectTypeContact(
$object, $selected, $htmlname =
'type', $source =
'internal', $sortorder =
'position', $showempty = 0, $morecss =
'', $output = 1, $forcehidetooltip = 0)
826 global $user, $langs;
829 if (is_object(
$object) && method_exists(
$object,
'liste_type_contact')) {
830 '@phan-var-force CommonObject $object';
831 $lesTypes =
$object->liste_type_contact($source, $sortorder, 2, 1);
833 $out .=
'<select class="flat valignmiddle' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
835 $out .=
'<option value="0"> </option>';
837 foreach ($lesTypes as $key => $arrayvalue) {
838 $out .=
'<option value="'.$key.
'" data-code="'.$arrayvalue[
'code'].
'"';
839 if ($key == $selected) {
842 $out .=
'>'.$arrayvalue[
'label'].
'</option>';
845 if ($user->admin && empty($forcehidetooltip)) {
846 $out .=
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
853 if (empty($output)) {
871 public function showRoles($htmlname,
Contact $contact, $rendermode =
'view', $selected = array(), $morecss =
'minwidth500', $placeholder =
'')
873 if ($rendermode ===
'view') {
875 foreach ($contact->roles as $key => $val) {
876 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val[
'label'] .
'</li>';
878 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname .
'"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
881 if ($rendermode ===
'edit') {
882 $contactType = $contact->listeTypeContacts(
'external', 0, 1,
'',
'',
'agenda');
883 if (count($selected) > 0) {
884 $newselected = array();
885 foreach ($selected as $key => $val) {
886 if (is_array($val) && array_key_exists(
'id', $val) && in_array($val[
'id'], array_keys($contactType))) {
887 $newselected[] = $val[
'id'];
892 if (count($newselected) > 0) {
893 $selected = $newselected;
896 return $this->
multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss, 0,
'90%',
'',
'', $placeholder);
899 return 'ErrorBadValueForParameterRenderMode';
915 public function select_ziptown($selected =
'', $htmlname =
'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib =
'', $morecss =
'')
923 if (!empty($fieldsize)) {
924 $size =
'size="' . $fieldsize .
'"';
927 if (
$conf->use_javascript_ajax && empty($disableautocomplete)) {
929 $moreattrib .=
' autocomplete="off"';
931 $out .=
'<input id="' . $htmlname .
'" class="maxwidthonsmartphone' . ($morecss ?
' ' . $morecss :
'') .
'" type="text"' . ($moreattrib ?
' ' . $moreattrib :
'') .
' name="' . $htmlname .
'" ' . $size .
' value="' . $selected .
'">' .
"\n";
947 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss =
'maxwidth200')
950 global
$conf, $langs, $hookmanager;
954 if ($country_code ==
'FR') {
955 if (isset($idprof)) {
958 } elseif ($idprof == 2) {
960 } elseif ($idprof == 3) {
962 } elseif ($idprof == 4) {
966 } elseif ($country_code ==
'ES') {
982 $selected = $preselected;
983 if (!$selected && isset($idprof)) {
984 if ($idprof == 1 && !empty($this->idprof1)) {
985 $selected = $this->idprof1;
986 } elseif ($idprof == 2 && !empty($this->idprof2)) {
987 $selected = $this->idprof2;
988 } elseif ($idprof == 3 && !empty($this->idprof3)) {
989 $selected = $this->idprof3;
990 } elseif ($idprof == 4 && !empty($this->idprof4)) {
991 $selected = $this->idprof4;
995 $maxlength = $formlength;
997 if (empty($formlength)) {
1005 $parameters = array(
'formlength' => $formlength,
'selected' => $preselected,
'idprof' => $idprof,
'htmlname' => $htmlname,
'country_code' => $country_code);
1006 $reshook = $hookmanager->executeHooks(
'getInputIdProf', $parameters);
1007 if (empty($reshook)) {
1008 $out .=
'<input type="text" ' . ($morecss ?
'class="' . $morecss .
'" ' :
'') .
'name="' . $htmlname .
'" id="' . $htmlname .
'" maxlength="' . $maxlength .
'" value="' . $selected .
'">';
1010 $out .= $hookmanager->resPrint;
1030 $valors = explode(
":", $tax);
1031 $nbvalues = count($valors);
1033 if ($nbvalues > 1) {
1035 print
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1037 while ($i < $nbvalues) {
1038 if ($selected == $valors[$i]) {
1039 print
'<option value="' . $valors[$i] .
'" selected>';
1041 print
'<option value="' . $valors[$i] .
'">';
1063 public function selectProspectCustomerType($selected, $htmlname =
'client', $htmlidname =
'customerprospect', $typeinput =
'form', $morecss =
'', $allowempty =
'')
1065 global
$conf, $langs;
1070 $out =
'<select class="flat ' . $morecss .
'" name="' . $htmlname .
'" id="' . $htmlidname .
'">';
1071 if ($typeinput ==
'form') {
1072 if ($allowempty || ($selected ==
'' || $selected ==
'-1')) {
1073 $out .=
'<option value="-1">';
1074 if (is_numeric($allowempty)) {
1077 $out .= $langs->trans($allowempty);
1079 $out .=
'</option>';
1082 $out .=
'<option value="2"' . ($selected == 2 ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1085 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1088 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1090 $out .=
'<option value="0"' . ((string) $selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'NorProspectNorCustomer') .
'</option>';
1091 } elseif ($typeinput ==
'list') {
1092 $out .=
'<option value="-1"' . (($selected ==
'' || $selected ==
'-1') ?
' selected' :
'') .
'> </option>';
1094 $out .=
'<option value="2,3"' . ($selected ==
'2,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1097 $out .=
'<option value="1,3"' . ($selected ==
'1,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1099 if (isModEnabled(
"fournisseur")) {
1100 $out .=
'<option value="4"' . ($selected ==
'4' ?
' selected' :
'') .
'>' . $langs->trans(
'Supplier') .
'</option>';
1102 $out .=
'<option value="0"' . ($selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'Other') .
'</option>';
1103 } elseif ($typeinput ==
'admin') {
1105 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1108 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1111 $out .=
'</select>';
1127 public function formThirdpartyType($page, $selected =
'', $htmlname =
'socid', $filter =
'', $nooutput = 0)
1130 global
$conf, $langs;
1133 if ($htmlname !=
"none") {
1134 $out .=
'<form method="post" action="' . $page .
'">';
1135 $out .=
'<input type="hidden" name="action" value="set_thirdpartytype">';
1136 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1137 $sortparam = (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' :
$conf->global->SOCIETE_SORT_ON_TYPEENT);
1138 $out .= $this->
selectarray($htmlname, $this->
typent_array(0, $filter), $selected, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1139 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
1142 if ($selected > 0) {
1144 $typent = empty($arr[$selected]) ?
'' : $arr[$selected];
1170 global $user, $langs;
1172 if ($mode ===
"html") {
1173 $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'code'];
1174 $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect][
'picto']) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'picto'];
1177 print
img_action(
'', $actioncode, $actionpicto,
'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1178 print
'<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .
'" data-socid="'.$idprospect.
'" name="' . $htmlname .
'"';
1179 if (!$user->hasRight(
'societe',
'creer')) {
1183 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1185 $label = $val[
'label'];
1186 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1188 $label = (($langs->trans(
"StatusProspect".$val[
'code']) !=
"StatusProspect".$val[
'code']) ? $langs->trans(
"StatusProspect".$val[
'code']) : $label);
1190 $label = (($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id']) ? $langs->trans(
"StatusProspect".$val[
'id']) : $label);
1198 } elseif ($mode ===
"js") {
1200 jQuery(document).ready(function() {
1201 $(".selectprospectstatus").on("change", function() {
1202 console.log("We change a value into a field selectprospectstatus");
1203 var statusid = $(this).val();
1204 var prospectid = $(this).attr("data-socid");
1205 var image = $(this).prev(".pictoprospectstatus");
1208 url: \'' . DOL_URL_ROOT .
'/core/ajax/ajaxstatusprospect.php\',
1209 data: { id: statusid, prospectid: prospectid, token: \''.
newToken() .
'\', action: \
'updatestatusprospect\' },
1210 success: function(response) {
1211 console.log(response.img);
1212 image.replaceWith(response.img);
1215 console.error("Error on status prospect");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...