34require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
54 global $langs, $mysoc;
58 $sql =
"SELECT id, code, libelle";
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->libelle;
83 if ($effs[$key] ==
'-') {
88 $this->db->free($resql);
107 $sql =
"SELECT id, code, libelle";
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->libelle !=
'-' ? $objp->libelle :
'';
131 $this->db->free($resql);
150 global $user, $langs;
152 print
'<form method="post" action="' . $page .
'">';
153 print
'<input type="hidden" name="action" value="setprospectlevel">';
154 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
156 dol_syslog(get_class($this) .
'::form_prospect_level', LOG_DEBUG);
157 $sql =
"SELECT code, label";
158 $sql .=
" FROM " . $this->db->prefix() .
"c_prospectlevel";
159 $sql .=
" WHERE active > 0";
160 $sql .=
" ORDER BY sortorder";
161 $resql = $this->db->query($sql);
169 while ($obj = $this->db->fetch_object($resql)) {
170 $level = $langs->trans($obj->code);
172 if ($level == $obj->code) {
173 $level = $langs->trans($obj->label);
176 $options[$obj->code] = $level;
183 if (!empty($htmlname) && $user->admin) {
184 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
186 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
201 global $user, $langs;
203 print
'<form method="post" action="' . $page .
'">';
204 print
'<input type="hidden" name="action" value="setprospectcontactlevel">';
205 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
208 $sql =
"SELECT code, label";
209 $sql .=
" FROM " . $this->db->prefix() .
"c_prospectcontactlevel";
210 $sql .=
" WHERE active > 0";
211 $sql .=
" ORDER BY sortorder";
212 $resql = $this->db->query($sql);
220 while ($obj = $this->db->fetch_object($resql)) {
221 $level = $langs->trans($obj->code);
223 if ($level == $obj->code) {
224 $level = $langs->trans($obj->label);
227 $options[$obj->code] = $level;
234 if (!empty($htmlname) && $user->admin) {
235 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
237 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
256 print $this->
select_state($selected, $country_codeid, $htmlname);
273 public function select_state($selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
276 global $conf, $langs, $user;
278 dol_syslog(get_class($this) .
"::select_departement selected=" . $selected .
", country_codeid=" . $country_codeid, LOG_DEBUG);
280 $langs->load(
"dict");
285 $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";
286 $sql .=
" " . $this->db->prefix() .
"c_departements as d, " . $this->db->prefix() .
"c_regions as r," . $this->db->prefix() .
"c_country as c";
287 $sql .=
" WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
288 $sql .=
" AND d.active = 1 AND r.active = 1 AND c.active = 1";
289 if ($country_codeid && is_numeric($country_codeid)) {
290 $sql .=
" AND c.rowid = '" . $this->db->escape($country_codeid) .
"'";
292 if ($country_codeid && !is_numeric($country_codeid)) {
293 $sql .=
" AND c.code = '" . $this->db->escape($country_codeid) .
"'";
295 $sql .=
" ORDER BY c.code, d.code_departement";
297 $result = $this->db->query($sql);
299 if (!empty($htmlname)) {
300 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
302 if ($country_codeid) {
303 $out .=
'<option value="0"> </option>';
305 $num = $this->db->num_rows($result);
307 dol_syslog(get_class($this) .
"::select_departement num=" . $num, LOG_DEBUG);
311 $obj = $this->db->fetch_object($result);
312 if ($obj->code ==
'0') {
313 $out .=
'<option value="0"> </option>';
315 if (!$country || $country != $obj->country) {
317 if (!$country_codeid && $obj->country_code) {
318 $out .=
'<option value="-1" disabled data-html="----- ' . $obj->country .
' -----">----- ' . $obj->country .
" -----</option>\n";
319 $country = $obj->country;
323 if (!empty($selected) && $selected == $obj->rowid) {
324 $out .=
'<option value="' . $obj->rowid .
'" selected>';
326 $out .=
'<option value="' . $obj->rowid .
'">';
331 !empty($conf->global->MAIN_SHOW_STATE_CODE) &&
332 ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE ===
'all')
334 if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) {
335 $out .= $obj->region_name .
' - ' . $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
337 $out .= $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
340 if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) {
341 $out .= $obj->region_name .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
343 $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
352 if (!empty($htmlname)) {
355 if (!empty($htmlname) && $user->admin) {
356 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
363 if (!empty($htmlname)) {
364 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
386 global $conf, $langs;
387 $langs->load(
"dict");
389 $sql =
"SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country";
390 $sql .=
" FROM " . $this->db->prefix() .
"c_regions as r, " . $this->db->prefix() .
"c_country as c";
391 $sql .=
" WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1";
392 $sql .=
" ORDER BY c.code, c.label ASC";
394 dol_syslog(get_class($this) .
"::select_region", LOG_DEBUG);
395 $resql = $this->db->query($sql);
397 print
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
398 $num = $this->db->num_rows($resql);
403 $obj = $this->db->fetch_object($resql);
404 if ($obj->code == 0) {
405 print
'<option value="0"> </option>';
407 if ($country ==
'' || $country != $obj->country) {
409 $key = $langs->trans(
"Country" . strtoupper($obj->country_code));
410 $valuetoshow = ($key !=
"Country" . strtoupper($obj->country_code)) ? $obj->country_code .
" - " . $key : $obj->country;
411 print
'<option value="-2" disabled>----- ' . $valuetoshow .
" -----</option>\n";
412 $country = $obj->country;
415 if ($selected > 0 && $selected == $obj->code) {
416 print
'<option value="' . $obj->code .
'" selected>' . $obj->label .
'</option>';
418 print
'<option value="' . $obj->code .
'">' . $obj->label .
'</option>';
441 public function select_civility($selected =
'', $htmlname =
'civility_id', $morecss =
'maxwidth150', $addjscombo = 1)
444 global $conf, $langs, $user;
445 $langs->load(
"dict");
449 $sql =
"SELECT rowid, code, label, active FROM " . $this->db->prefix() .
"c_civility";
450 $sql .=
" WHERE active = 1";
452 dol_syslog(
"Form::select_civility", LOG_DEBUG);
453 $resql = $this->db->query($sql);
455 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
456 $out .=
'<option value=""> </option>';
457 $num = $this->db->num_rows($resql);
461 $obj = $this->db->fetch_object($resql);
462 if ($selected == $obj->code) {
463 $out .=
'<option value="' . $obj->code .
'" selected>';
465 $out .=
'<option value="' . $obj->code .
'">';
468 $out .= ($langs->trans(
"Civility" . $obj->code) !=
"Civility" . $obj->code ? $langs->trans(
"Civility" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
475 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
480 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
520 public function select_juridicalstatus($selected =
'', $country_codeid = 0, $filter =
'', $htmlname =
'forme_juridique_code', $morecss =
'')
523 global $conf, $langs, $user;
524 $langs->load(
"dict");
529 $sql =
"SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code";
530 $sql .=
" FROM " . $this->db->prefix() .
"c_forme_juridique as f, " . $this->db->prefix() .
"c_country as c";
531 $sql .=
" WHERE f.fk_pays=c.rowid";
532 $sql .=
" AND f.active = 1 AND c.active = 1";
533 if ($country_codeid) {
534 $sql .=
" AND c.code = '" . $this->db->escape($country_codeid) .
"'";
537 $sql .=
" " . $filter;
539 $sql .=
" ORDER BY c.code";
541 dol_syslog(get_class($this) .
"::select_juridicalstatus", LOG_DEBUG);
542 $resql = $this->db->query($sql);
544 $out .=
'<div id="particulier2" class="visible">';
545 $out .=
'<select class="flat minwidth200' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
546 if ($country_codeid) {
547 $out .=
'<option value="0"> </option>';
550 $num = $this->db->num_rows($resql);
554 $arraydata = array();
556 $obj = $this->db->fetch_object($resql);
559 $labelcountry = (($langs->trans(
"Country" . $obj->country_code) !=
"Country" . $obj->country_code) ? $langs->trans(
"Country" . $obj->country_code) : $obj->country);
560 $labeljs = (($langs->trans(
"JuridicalStatus" . $obj->code) !=
"JuridicalStatus" . $obj->code) ? $langs->trans(
"JuridicalStatus" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
561 $arraydata[$obj->code] = array(
'code' => $obj->code,
'label' => $labeljs,
'label_sort' => $labelcountry .
'_' . $labeljs,
'country_code' => $obj->country_code,
'country' => $labelcountry);
567 if (empty($country_codeid)) {
568 $arraydata[0] = array(
'code' => 0,
'label' =>
'',
'label_sort' =>
'_',
'country_code' =>
'',
'country' =>
'');
571 foreach ($arraydata as $key => $val) {
572 if (!$country || $country != $val[
'country']) {
574 if (empty($country_codeid) && $val[
'country_code']) {
575 $out .=
'<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val[
'country'] .
" -----</option>\n";
576 $country = $val[
'country'];
580 if ($selected > 0 && $selected == $val[
'code']) {
581 $out .=
'<option value="' . $val[
'code'] .
'" selected>';
583 $out .=
'<option value="' . $val[
'code'] .
'">';
586 $out .= $val[
'label'];
592 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
596 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
621 public function selectCompaniesForNewContact($object, $var_id, $selected =
'', $htmlname =
'newcompany', $limitto =
'', $forceid = 0, $moreparam =
'', $morecss =
'')
623 global $conf, $hookmanager;
625 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
627 $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
632 $tmpthirdparty =
new Societe($this->db);
633 $result = $tmpthirdparty->fetch($selected);
636 $name = $tmpthirdparty->name;
647 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
649 if (count($events)) {
650 print
'<script nonce="' .
getNonce() .
'" type="text/javascript">
651 jQuery(document).ready(function() {
652 $("#search_' . $htmlname .
'").change(function() {
653 var obj = ' . json_encode($events) .
';
654 $.each(obj, function(key,values) {
655 if (values.method.length) {
656 runJsCodeForEvent' . $htmlname .
'(values);
660 $(this).trigger("blur");
663 // Function used to execute events when search_htmlname change
664 function runJsCodeForEvent' . $htmlname .
'(obj) {
665 var id = $("#' . $htmlname .
'").val();
666 var method = obj.method;
668 var htmlname = obj.htmlname;
669 var showempty = obj.showempty;
670 console.log("Run runJsCodeForEvent-' . $htmlname .
' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
678 if (response != null)
680 console.log("Change select#"+htmlname+" with content "+response.value)
681 $.each(obj.params, function(key,action) {
683 var num = response.num;
685 $("#" + key).removeAttr(action);
687 $("#" + key).attr(action, action);
691 $("select#" + htmlname).html(response.value);
700 print
"\n" .
'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' .
"\n";
701 print
'<input type="text" size="30" id="search_' . $htmlname .
'" name="search_' . $htmlname .
'" value="' . $name .
'" />';
702 print
ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT .
'/societe/ajax/ajaxcompanies.php',
'', $minLength, 0);
706 $sql =
"SELECT s.rowid, s.nom as name ";
707 if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
708 $sql .=
", s.code_client, s.code_fournisseur";
710 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
711 $sql .=
", s.address, s.zip, s.town";
712 $sql .=
", dictp.code as country_code";
714 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
715 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
716 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
718 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
")";
720 if (is_array($limitto) && count($limitto)) {
721 $sql .=
" AND s.rowid IN (" . $this->db->sanitize(join(
',', $limitto)) .
")";
724 $parameters = array();
725 $reshook = $hookmanager->executeHooks(
'selectCompaniesForNewContactListWhere', $parameters);
726 $sql .= $hookmanager->resPrint;
727 $sql .=
" ORDER BY s.nom ASC";
729 $resql = $this->db->query($sql);
731 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"';
732 if ($conf->use_javascript_ajax) {
733 $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;";
734 print
' onChange="' . $javaScript .
'"';
737 print
'<option value="-1"> </option>';
739 $num = $this->db->num_rows($resql);
743 $obj = $this->db->fetch_object($resql);
745 $firstCompany = $obj->rowid;
748 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
751 if ($selected > 0 && $selected == $obj->rowid) {
752 print
'<option value="' . $obj->rowid .
'"';
757 $firstCompany = $obj->rowid;
759 print
'<option value="' . $obj->rowid .
'"';
770 return $firstCompany;
792 public function selectTypeContact($object, $selected, $htmlname =
'type', $source =
'internal', $sortorder =
'position', $showempty = 0, $morecss =
'', $output = 1, $forcehidetooltip = 0)
794 global $user, $langs;
797 if (is_object($object) && method_exists($object,
'liste_type_contact')) {
798 $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1);
800 $out .=
'<select class="flat valignmiddle' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
802 $out .=
'<option value="0"> </option>';
804 foreach ($lesTypes as $key => $value) {
805 $out .=
'<option value="' . $key .
'"';
806 if ($key == $selected) {
809 $out .=
'>' . $value .
'</option>';
812 if ($user->admin && empty($forcehidetooltip)) {
813 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
820 if (empty($output)) {
837 public function showRoles($htmlname,
Contact $contact, $rendermode =
'view', $selected = array(), $morecss =
'minwidth500')
839 if ($rendermode ===
'view') {
841 foreach ($contact->roles as $key => $val) {
842 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val[
'label'] .
'</li>';
844 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname .
'"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
847 if ($rendermode ===
'edit') {
848 $contactType = $contact->listeTypeContacts(
'external',
'', 1,
'',
'',
'agenda');
849 if (count($selected) > 0) {
850 $newselected = array();
851 foreach ($selected as $key => $val) {
852 if (is_array($val) && array_key_exists(
'id', $val) && in_array($val[
'id'], array_keys($contactType))) {
853 $newselected[] = $val[
'id'];
858 if (count($newselected) > 0) {
859 $selected = $newselected;
862 return $this->
multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss);
865 return 'ErrorBadValueForParameterRenderMode';
881 public function select_ziptown($selected =
'', $htmlname =
'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib =
'', $morecss =
'')
889 if (!empty($fieldsize)) {
890 $size =
'size="' . $fieldsize .
'"';
893 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
895 $moreattrib .=
' autocomplete="off"';
897 $out .=
'<input id="' . $htmlname .
'" class="maxwidthonsmartphone' . ($morecss ?
' ' . $morecss :
'') .
'" type="text"' . ($moreattrib ?
' ' . $moreattrib :
'') .
' name="' . $htmlname .
'" ' . $size .
' value="' . $selected .
'">' .
"\n";
913 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss =
'maxwidth200')
916 global $conf, $langs, $hookmanager;
919 if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
920 if ($country_code ==
'FR') {
921 if (isset($idprof)) {
924 } elseif ($idprof == 2) {
926 } elseif ($idprof == 3) {
928 } elseif ($idprof == 4) {
932 } elseif ($country_code ==
'ES') {
948 $selected = $preselected;
949 if (!$selected && isset($idprof)) {
950 if ($idprof == 1 && !empty($this->idprof1)) {
951 $selected = $this->idprof1;
952 } elseif ($idprof == 2 && !empty($this->idprof2)) {
953 $selected = $this->idprof2;
954 } elseif ($idprof == 3 && !empty($this->idprof3)) {
955 $selected = $this->idprof3;
956 } elseif ($idprof == 4 && !empty($this->idprof4)) {
957 $selected = $this->idprof4;
961 $maxlength = $formlength;
962 if (empty($formlength)) {
970 $parameters = array(
'formlength' => $formlength,
'selected' => $preselected,
'idprof' => $idprof,
'htmlname' => $htmlname,
'country_code' => $country_code);
971 $reshook = $hookmanager->executeHooks(
'getInputIdProf', $parameters);
972 if (empty($reshook)) {
973 $out .=
'<input type="text" ' . ($morecss ?
'class="' . $morecss .
'" ' :
'') .
'name="' . $htmlname .
'" id="' . $htmlname .
'" maxlength="' . $maxlength .
'" value="' . $selected .
'">';
975 $out .= $hookmanager->resPrint;
995 $valors = explode(
":", $tax);
996 $nbvalues = count($valors);
1000 print
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1002 while ($i < $nbvalues) {
1003 if ($selected == $valors[$i]) {
1004 print
'<option value="' . $valors[$i] .
'" selected>';
1006 print
'<option value="' . $valors[$i] .
'">';
1028 public function selectProspectCustomerType($selected, $htmlname =
'client', $htmlidname =
'customerprospect', $typeinput =
'form', $morecss =
'', $allowempty =
'')
1030 global $conf, $langs;
1031 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && !isModEnabled(
'fournisseur')) {
1035 $out =
'<select class="flat ' . $morecss .
'" name="' . $htmlname .
'" id="' . $htmlidname .
'">';
1036 if ($typeinput ==
'form') {
1037 if ($allowempty || ($selected ==
'' || $selected ==
'-1')) {
1038 $out .=
'<option value="-1">';
1039 if (is_numeric($allowempty)) {
1042 $out .= $langs->trans($allowempty);
1044 $out .=
'</option>';
1046 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
1047 $out .=
'<option value="2"' . ($selected == 2 ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1049 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
1050 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1052 if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
1053 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1055 $out .=
'<option value="0"' . ((string) $selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'NorProspectNorCustomer') .
'</option>';
1056 } elseif ($typeinput ==
'list') {
1057 $out .=
'<option value="-1"' . (($selected ==
'' || $selected ==
'-1') ?
' selected' :
'') .
'> </option>';
1058 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
1059 $out .=
'<option value="2,3"' . ($selected ==
'2,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1061 if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
1062 $out .=
'<option value="1,3"' . ($selected ==
'1,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1064 if (isModEnabled(
"fournisseur")) {
1065 $out .=
'<option value="4"' . ($selected ==
'4' ?
' selected' :
'') .
'>' . $langs->trans(
'Supplier') .
'</option>';
1067 $out .=
'<option value="0"' . ($selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'Other') .
'</option>';
1068 } elseif ($typeinput ==
'admin') {
1069 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
1070 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1072 if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
1073 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1076 $out .=
'</select>';
1092 public function formThirdpartyType($page, $selected =
'', $htmlname =
'socid', $filter =
'', $nooutput = 0)
1095 global $conf, $langs;
1098 if ($htmlname !=
"none") {
1099 $out .=
'<form method="post" action="' . $page .
'">';
1100 $out .=
'<input type="hidden" name="action" value="set_thirdpartytype">';
1101 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
1102 $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT);
1103 $out .= $this->
selectarray($htmlname, $this->
typent_array(0, $filter), $selected, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1104 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
1107 if ($selected > 0) {
1109 $typent = $arr[$selected];
1137 if ($mode ===
"html") {
1138 $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'code'];
1139 $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect][
'picto']) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'picto'];
1142 print
img_action(
'', $actioncode, $actionpicto,
'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1143 print
'<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .
'" data-socid="'.$idprospect.
'" name="' . $htmlname .
'">';
1144 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1145 $titlealt = (empty($val[
'label']) ?
'default' : $val[
'label']);
1146 $label = $val[
'label'];
1147 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1148 $titlealt = $val[
'label'];
1149 $label = (($langs->trans(
"StatusProspect".$val[
'code']) !=
"StatusProspect".$val[
'code']) ? $langs->trans(
"StatusProspect".$val[
'code']) : $label);
1151 $label = (($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id']) ? $langs->trans(
"StatusProspect".$val[
'id']) : $label);
1159 } elseif ($mode ===
"js") {
1161 jQuery(document).ready(function() {
1162 $(".selectprospectstatus").on("change", function() {
1163 console.log("We change a value into a field selectprospectstatus");
1164 var statusid = $(this).val();
1165 var prospectid = $(this).attr("data-socid");
1166 var image = $(this).prev(".pictoprospectstatus");
1169 url: \'' . DOL_URL_ROOT .
'/core/ajax/ajaxstatusprospect.php\',
1170 data: { id: statusid, prospectid: prospectid, token: \''. newToken() .
'\', action: \
'updatestatusprospect\' },
1171 success: function(response) {
1172console.log(response.img);
1173 image.replaceWith(response.img);
1176 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.
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.
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...