35require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
54 global $langs, $mysoc;
58 $sql =
"SELECT id, code, libelle as label";
59 $sql .=
" FROM " . $this->db->prefix() .
"c_typent";
60 $sql .=
" WHERE active = 1 AND (fk_country IS NULL OR fk_country = " . (empty($mysoc->country_id) ?
'0' : $mysoc->country_id) .
")";
62 $sql .=
" " . $filter;
64 $sql .=
" ORDER by position, id";
65 dol_syslog(get_class($this) .
'::typent_array', LOG_DEBUG);
66 $resql = $this->db->query($sql);
68 $num = $this->db->num_rows($resql);
72 $objp = $this->db->fetch_object($resql);
78 if ($langs->trans($objp->code) != $objp->code) {
79 $effs[$key] = $langs->trans($objp->code);
81 $effs[$key] = $objp->label;
83 if ($effs[$key] ==
'-') {
88 $this->db->free($resql);
107 $sql =
"SELECT id, code, libelle as label";
108 $sql .=
" FROM " . $this->db->prefix() .
"c_effectif";
109 $sql .=
" WHERE active = 1";
111 $sql .=
" " . $filter;
113 $sql .=
" ORDER BY id ASC";
114 dol_syslog(get_class($this) .
'::effectif_array', LOG_DEBUG);
115 $resql = $this->db->query($sql);
117 $num = $this->db->num_rows($resql);
121 $objp = $this->db->fetch_object($resql);
128 $effs[$key] = $objp->label !=
'-' ? $objp->label :
'';
131 $this->db->free($resql);
152 global $user, $langs;
154 print
'<form method="post" action="' . $page .
'">';
155 print
'<input type="hidden" name="action" value="setprospectlevel">';
156 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
158 dol_syslog(get_class($this) .
'::form_prospect_level', LOG_DEBUG);
159 $sql =
"SELECT code, label";
160 $sql .=
" FROM " . $this->db->prefix() .
"c_prospectlevel";
161 $sql .=
" WHERE active > 0";
162 $sql .=
" ORDER BY sortorder";
163 $resql = $this->db->query($sql);
171 while ($obj = $this->db->fetch_object($resql)) {
172 $level = $langs->trans($obj->code);
174 if ($level == $obj->code) {
175 $level = $langs->trans($obj->label);
178 $options[$obj->code] = $level;
185 if (!empty($htmlname) && $user->admin) {
186 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
188 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
203 global $user, $langs;
205 print
'<form method="post" action="' . $page .
'">';
206 print
'<input type="hidden" name="action" value="setprospectcontactlevel">';
207 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
210 $sql =
"SELECT code, label";
211 $sql .=
" FROM " . $this->db->prefix() .
"c_prospectcontactlevel";
212 $sql .=
" WHERE active > 0";
213 $sql .=
" ORDER BY sortorder";
214 $resql = $this->db->query($sql);
222 while ($obj = $this->db->fetch_object($resql)) {
223 $level = $langs->trans($obj->code);
225 if ($level == $obj->code) {
226 $level = $langs->trans($obj->label);
229 $options[$obj->code] = $level;
236 if (!empty($htmlname) && $user->admin) {
237 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
239 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
258 print $this->
select_state($selected, $country_codeid, $htmlname);
275 public function select_state($selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
278 global $conf, $langs, $user;
280 dol_syslog(get_class($this) .
"::select_departement selected=" . $selected .
", country_codeid=" . $country_codeid, LOG_DEBUG);
282 $langs->load(
"dict");
287 $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";
288 $sql .=
" " . $this->db->prefix() .
"c_departements as d, " . $this->db->prefix() .
"c_regions as r," . $this->db->prefix() .
"c_country as c";
289 $sql .=
" WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
290 $sql .=
" AND d.active = 1 AND r.active = 1 AND c.active = 1";
291 if ($country_codeid && is_numeric($country_codeid)) {
292 $sql .=
" AND c.rowid = '" . $this->db->escape($country_codeid) .
"'";
294 if ($country_codeid && !is_numeric($country_codeid)) {
295 $sql .=
" AND c.code = '" . $this->db->escape($country_codeid) .
"'";
297 $sql .=
" ORDER BY c.code, d.code_departement";
299 $result = $this->db->query($sql);
301 if (!empty($htmlname)) {
302 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
304 if ($country_codeid) {
305 $out .=
'<option value="0"> </option>';
307 $num = $this->db->num_rows($result);
309 dol_syslog(get_class($this) .
"::select_departement num=" . $num, LOG_DEBUG);
313 $obj = $this->db->fetch_object($result);
314 if ($obj->code ==
'0') {
315 $out .=
'<option value="0"> </option>';
317 if (!$country || $country != $obj->country) {
319 if (!$country_codeid && $obj->country_code) {
320 $out .=
'<option value="-1" disabled data-html="----- ' . $obj->country .
' -----">----- ' . $obj->country .
" -----</option>\n";
321 $country = $obj->country;
325 if (!empty($selected) && $selected == $obj->rowid) {
326 $out .=
'<option value="' . $obj->rowid .
'" selected>';
328 $out .=
'<option value="' . $obj->rowid .
'">';
337 $out .= $obj->region_name .
' - ' . $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
339 $out .= $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
343 $out .= $obj->region_name .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
345 $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
354 if (!empty($htmlname)) {
357 if (!empty($htmlname) && $user->admin) {
358 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
365 if (!empty($htmlname)) {
366 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
388 public function select_state_ajax($parent_field_id =
'country_id', $selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
391 $html.=
'$("select[name=\"'.$parent_field_id.
'\"]").change(function(){
392 $.ajax( "'.
dol_buildpath(
'/core/ajax/ziptown.php', 2).
'", { data:{ selected: $("select[name=\"'.$htmlname.
'\"]").val(), country_codeid: $(this).val(), htmlname:"'.$htmlname.
'", morecss:"'.$morecss.
'" } } )
393 .done(function(msg) {
394 $("span#target_'.$htmlname.
'").html(msg);
397 return $html.
'</script><span id="target_'.$htmlname.
'">'.$this->
select_state($selected, $country_codeid, $htmlname, $morecss).
'</span>';
414 global $conf, $langs;
415 $langs->load(
"dict");
417 $sql =
"SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country";
418 $sql .=
" FROM " . $this->db->prefix() .
"c_regions as r, " . $this->db->prefix() .
"c_country as c";
419 $sql .=
" WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1";
420 $sql .=
" ORDER BY c.code, c.label ASC";
422 dol_syslog(get_class($this) .
"::select_region", LOG_DEBUG);
423 $resql = $this->db->query($sql);
425 print
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
426 $num = $this->db->num_rows($resql);
431 $obj = $this->db->fetch_object($resql);
432 if ($obj->code == 0) {
433 print
'<option value="0"> </option>';
435 if ($country ==
'' || $country != $obj->country) {
437 $key = $langs->trans(
"Country" . strtoupper($obj->country_code));
438 $valuetoshow = ($key !=
"Country" . strtoupper($obj->country_code)) ? $obj->country_code .
" - " . $key : $obj->country;
439 print
'<option value="-2" disabled>----- ' . $valuetoshow .
" -----</option>\n";
440 $country = $obj->country;
443 if ($selected > 0 && $selected == $obj->code) {
444 print
'<option value="' . $obj->code .
'" selected>' . $obj->label .
'</option>';
446 print
'<option value="' . $obj->code .
'">' . $obj->label .
'</option>';
469 public function select_civility($selected =
'', $htmlname =
'civility_id', $morecss =
'maxwidth150', $addjscombo = 1)
472 global $conf, $langs, $user;
473 $langs->load(
"dict");
477 $sql =
"SELECT rowid, code, label, active FROM " . $this->db->prefix() .
"c_civility";
478 $sql .=
" WHERE active = 1";
480 dol_syslog(
"Form::select_civility", LOG_DEBUG);
481 $resql = $this->db->query($sql);
483 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
484 $out .=
'<option value=""> </option>';
485 $num = $this->db->num_rows($resql);
489 $obj = $this->db->fetch_object($resql);
490 if ($selected == $obj->code) {
491 $out .=
'<option value="' . $obj->code .
'" selected>';
493 $out .=
'<option value="' . $obj->code .
'">';
496 $out .= ($langs->trans(
"Civility" . $obj->code) !=
"Civility" . $obj->code ? $langs->trans(
"Civility" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
503 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
508 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
548 public function select_juridicalstatus($selected =
'', $country_codeid = 0, $filter =
'', $htmlname =
'forme_juridique_code', $morecss =
'')
551 global $conf, $langs, $user;
552 $langs->load(
"dict");
557 $sql =
"SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code";
558 $sql .=
" FROM " . $this->db->prefix() .
"c_forme_juridique as f, " . $this->db->prefix() .
"c_country as c";
559 $sql .=
" WHERE f.fk_pays=c.rowid";
560 $sql .=
" AND f.active = 1 AND c.active = 1";
561 if ($country_codeid) {
562 $sql .=
" AND c.code = '" . $this->db->escape($country_codeid) .
"'";
565 $sql .=
" " . $filter;
567 $sql .=
" ORDER BY c.code";
569 dol_syslog(get_class($this) .
"::select_juridicalstatus", LOG_DEBUG);
570 $resql = $this->db->query($sql);
572 $out .=
'<div id="particulier2" class="visible">';
573 $out .=
'<select class="flat minwidth200' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
574 if ($country_codeid) {
575 $out .=
'<option value="0"> </option>';
578 $num = $this->db->num_rows($resql);
582 $arraydata = array();
584 $obj = $this->db->fetch_object($resql);
587 $labelcountry = (($langs->trans(
"Country" . $obj->country_code) !=
"Country" . $obj->country_code) ? $langs->trans(
"Country" . $obj->country_code) : $obj->country);
588 $labeljs = (($langs->trans(
"JuridicalStatus" . $obj->code) !=
"JuridicalStatus" . $obj->code) ? $langs->trans(
"JuridicalStatus" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
589 $arraydata[$obj->code] = array(
'code' => $obj->code,
'label' => $labeljs,
'label_sort' => $labelcountry .
'_' . $labeljs,
'country_code' => $obj->country_code,
'country' => $labelcountry);
595 if (empty($country_codeid)) {
596 $arraydata[0] = array(
'code' => 0,
'label' =>
'',
'label_sort' =>
'_',
'country_code' =>
'',
'country' =>
'');
599 foreach ($arraydata as $key => $val) {
600 if (!$country || $country != $val[
'country']) {
602 if (empty($country_codeid) && $val[
'country_code']) {
603 $out .=
'<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val[
'country'] .
" -----</option>\n";
604 $country = $val[
'country'];
608 if ($selected > 0 && $selected == $val[
'code']) {
609 $out .=
'<option value="' . $val[
'code'] .
'" selected>';
611 $out .=
'<option value="' . $val[
'code'] .
'">';
614 $out .= $val[
'label'];
620 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
624 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
651 global $conf, $hookmanager;
653 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) {
655 $minLength = (is_numeric(
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
660 $tmpthirdparty =
new Societe($this->db);
661 $result = $tmpthirdparty->fetch($selected);
664 $name = $tmpthirdparty->name;
675 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
677 if (count($events)) {
678 print
'<script nonce="' .
getNonce() .
'" type="text/javascript">
679 jQuery(document).ready(function() {
680 $("#search_' . $htmlname .
'").change(function() {
681 var obj = ' . json_encode($events) .
';
682 $.each(obj, function(key,values) {
683 if (values.method.length) {
684 runJsCodeForEvent' . $htmlname .
'(values);
688 $(this).trigger("blur");
691 // Function used to execute events when search_htmlname change
692 function runJsCodeForEvent' . $htmlname .
'(obj) {
693 var id = $("#' . $htmlname .
'").val();
694 var method = obj.method;
696 var htmlname = obj.htmlname;
697 var showempty = obj.showempty;
698 console.log("Run runJsCodeForEvent-' . $htmlname .
' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
706 if (response != null)
708 console.log("Change select#"+htmlname+" with content "+response.value)
709 $.each(obj.params, function(key,action) {
711 var num = response.num;
713 $("#" + key).removeAttr(action);
715 $("#" + key).attr(action, action);
719 $("select#" + htmlname).html(response.value);
728 print
"\n" .
'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' .
"\n";
729 print
'<input type="text" size="30" id="search_' . $htmlname .
'" name="search_' . $htmlname .
'" value="' . $name .
'" />';
730 print
ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT .
'/societe/ajax/ajaxcompanies.php',
'', $minLength, 0);
734 $sql =
"SELECT s.rowid, s.nom as name ";
736 $sql .=
", s.code_client, s.code_fournisseur";
739 $sql .=
", s.address, s.zip, s.town";
740 $sql .=
", dictp.code as country_code";
742 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
744 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
746 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
")";
748 if (is_array($limitto) && count($limitto)) {
749 $sql .=
" AND s.rowid IN (" . $this->db->sanitize(implode(
',', $limitto)) .
")";
752 $parameters = array();
753 $reshook = $hookmanager->executeHooks(
'selectCompaniesForNewContactListWhere', $parameters);
754 $sql .= $hookmanager->resPrint;
755 $sql .=
" ORDER BY s.nom ASC";
757 $resql = $this->db->query($sql);
759 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"';
760 if ($conf->use_javascript_ajax) {
761 $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;";
762 print
' onChange="' . $javaScript .
'"';
765 print
'<option value="-1"> </option>';
767 $num = $this->db->num_rows($resql);
771 $obj = $this->db->fetch_object($resql);
773 $firstCompany = $obj->rowid;
776 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
779 if ($selected > 0 && $selected == $obj->rowid) {
780 print
'<option value="' . $obj->rowid .
'"';
785 $firstCompany = $obj->rowid;
787 print
'<option value="' . $obj->rowid .
'"';
798 return $firstCompany;
820 public function selectTypeContact(
$object, $selected, $htmlname =
'type', $source =
'internal', $sortorder =
'position', $showempty = 0, $morecss =
'', $output = 1, $forcehidetooltip = 0)
822 global $user, $langs;
825 if (is_object(
$object) && method_exists(
$object,
'liste_type_contact')) {
826 $lesTypes =
$object->liste_type_contact($source, $sortorder, 0, 1);
828 $out .=
'<select class="flat valignmiddle' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
830 $out .=
'<option value="0"> </option>';
832 foreach ($lesTypes as $key => $value) {
833 $out .=
'<option value="' . $key .
'"';
834 if ($key == $selected) {
837 $out .=
'>' . $value .
'</option>';
840 if ($user->admin && empty($forcehidetooltip)) {
841 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
848 if (empty($output)) {
865 public function showRoles($htmlname,
Contact $contact, $rendermode =
'view', $selected = array(), $morecss =
'minwidth500')
867 if ($rendermode ===
'view') {
869 foreach ($contact->roles as $key => $val) {
870 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val[
'label'] .
'</li>';
872 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname .
'"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
875 if ($rendermode ===
'edit') {
876 $contactType = $contact->listeTypeContacts(
'external',
'', 1,
'',
'',
'agenda');
877 if (count($selected) > 0) {
878 $newselected = array();
879 foreach ($selected as $key => $val) {
880 if (is_array($val) && array_key_exists(
'id', $val) && in_array($val[
'id'], array_keys($contactType))) {
881 $newselected[] = $val[
'id'];
886 if (count($newselected) > 0) {
887 $selected = $newselected;
890 return $this->
multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss, 0,
'90%');
893 return 'ErrorBadValueForParameterRenderMode';
909 public function select_ziptown($selected =
'', $htmlname =
'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib =
'', $morecss =
'')
917 if (!empty($fieldsize)) {
918 $size =
'size="' . $fieldsize .
'"';
921 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
923 $moreattrib .=
' autocomplete="off"';
925 $out .=
'<input id="' . $htmlname .
'" class="maxwidthonsmartphone' . ($morecss ?
' ' . $morecss :
'') .
'" type="text"' . ($moreattrib ?
' ' . $moreattrib :
'') .
' name="' . $htmlname .
'" ' . $size .
' value="' . $selected .
'">' .
"\n";
941 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss =
'maxwidth200')
944 global $conf, $langs, $hookmanager;
948 if ($country_code ==
'FR') {
949 if (isset($idprof)) {
952 } elseif ($idprof == 2) {
954 } elseif ($idprof == 3) {
956 } elseif ($idprof == 4) {
960 } elseif ($country_code ==
'ES') {
976 $selected = $preselected;
977 if (!$selected && isset($idprof)) {
978 if ($idprof == 1 && !empty($this->idprof1)) {
979 $selected = $this->idprof1;
980 } elseif ($idprof == 2 && !empty($this->idprof2)) {
981 $selected = $this->idprof2;
982 } elseif ($idprof == 3 && !empty($this->idprof3)) {
983 $selected = $this->idprof3;
984 } elseif ($idprof == 4 && !empty($this->idprof4)) {
985 $selected = $this->idprof4;
989 $maxlength = $formlength;
990 if (empty($formlength)) {
998 $parameters = array(
'formlength' => $formlength,
'selected' => $preselected,
'idprof' => $idprof,
'htmlname' => $htmlname,
'country_code' => $country_code);
999 $reshook = $hookmanager->executeHooks(
'getInputIdProf', $parameters);
1000 if (empty($reshook)) {
1001 $out .=
'<input type="text" ' . ($morecss ?
'class="' . $morecss .
'" ' :
'') .
'name="' . $htmlname .
'" id="' . $htmlname .
'" maxlength="' . $maxlength .
'" value="' . $selected .
'">';
1003 $out .= $hookmanager->resPrint;
1023 $valors = explode(
":", $tax);
1024 $nbvalues = count($valors);
1026 if ($nbvalues > 1) {
1028 print
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1030 while ($i < $nbvalues) {
1031 if ($selected == $valors[$i]) {
1032 print
'<option value="' . $valors[$i] .
'" selected>';
1034 print
'<option value="' . $valors[$i] .
'">';
1056 public function selectProspectCustomerType($selected, $htmlname =
'client', $htmlidname =
'customerprospect', $typeinput =
'form', $morecss =
'', $allowempty =
'')
1058 global $conf, $langs;
1063 $out =
'<select class="flat ' . $morecss .
'" name="' . $htmlname .
'" id="' . $htmlidname .
'">';
1064 if ($typeinput ==
'form') {
1065 if ($allowempty || ($selected ==
'' || $selected ==
'-1')) {
1066 $out .=
'<option value="-1">';
1067 if (is_numeric($allowempty)) {
1070 $out .= $langs->trans($allowempty);
1072 $out .=
'</option>';
1075 $out .=
'<option value="2"' . ($selected == 2 ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1078 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1081 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1083 $out .=
'<option value="0"' . ((string) $selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'NorProspectNorCustomer') .
'</option>';
1084 } elseif ($typeinput ==
'list') {
1085 $out .=
'<option value="-1"' . (($selected ==
'' || $selected ==
'-1') ?
' selected' :
'') .
'> </option>';
1087 $out .=
'<option value="2,3"' . ($selected ==
'2,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1090 $out .=
'<option value="1,3"' . ($selected ==
'1,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1092 if (isModEnabled(
"fournisseur")) {
1093 $out .=
'<option value="4"' . ($selected ==
'4' ?
' selected' :
'') .
'>' . $langs->trans(
'Supplier') .
'</option>';
1095 $out .=
'<option value="0"' . ($selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'Other') .
'</option>';
1096 } elseif ($typeinput ==
'admin') {
1098 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1101 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1104 $out .=
'</select>';
1120 public function formThirdpartyType($page, $selected =
'', $htmlname =
'socid', $filter =
'', $nooutput = 0)
1123 global $conf, $langs;
1126 if ($htmlname !=
"none") {
1127 $out .=
'<form method="post" action="' . $page .
'">';
1128 $out .=
'<input type="hidden" name="action" value="set_thirdpartytype">';
1129 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1130 $sortparam = (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT);
1131 $out .= $this->
selectarray($htmlname, $this->
typent_array(0, $filter), $selected, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1132 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
1135 if ($selected > 0) {
1137 $typent = empty($arr[$selected]) ?
'' : $arr[$selected];
1163 global $user, $langs;
1165 if ($mode ===
"html") {
1166 $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'code'];
1167 $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect][
'picto']) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'picto'];
1170 print
img_action(
'', $actioncode, $actionpicto,
'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1171 print
'<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .
'" data-socid="'.$idprospect.
'" name="' . $htmlname .
'"';
1172 if (!$user->hasRight(
'societe',
'creer')) {
1176 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1178 $label = $val[
'label'];
1179 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1181 $label = (($langs->trans(
"StatusProspect".$val[
'code']) !=
"StatusProspect".$val[
'code']) ? $langs->trans(
"StatusProspect".$val[
'code']) : $label);
1183 $label = (($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id']) ? $langs->trans(
"StatusProspect".$val[
'id']) : $label);
1191 } elseif ($mode ===
"js") {
1193 jQuery(document).ready(function() {
1194 $(".selectprospectstatus").on("change", function() {
1195 console.log("We change a value into a field selectprospectstatus");
1196 var statusid = $(this).val();
1197 var prospectid = $(this).attr("data-socid");
1198 var image = $(this).prev(".pictoprospectstatus");
1201 url: \'' . DOL_URL_ROOT .
'/core/ajax/ajaxstatusprospect.php\',
1202 data: { id: statusid, prospectid: prospectid, token: \''.
newToken() .
'\', action: \
'updatestatusprospect\' },
1203 success: function(response) {
1204 console.log(response.img);
1205 image.replaceWith(response.img);
1208 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 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...