36require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
59 $sql =
"SELECT id, code, libelle as label";
60 $sql .=
" FROM " . $this->db->prefix() .
"c_typent";
61 $sql .=
" WHERE active = 1 AND (fk_country IS NULL OR fk_country = " . (empty(
$mysoc->country_id) ?
'0' :
$mysoc->country_id) .
")";
64 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 0);
67 $sql .=
" " . $sqlwhere;
70 $sql .=
" ORDER by position, id";
72 dol_syslog(get_class($this) .
'::typent_array', LOG_DEBUG);
74 $resql = $this->db->query($sql);
76 $num = $this->db->num_rows($resql);
80 $objp = $this->db->fetch_object($resql);
86 if ($langs->trans($objp->code) != $objp->code) {
87 $effs[$key] = $langs->trans($objp->code);
89 $effs[$key] = $objp->label;
91 if ($effs[$key] ==
'-') {
96 $this->db->free($resql);
115 $sql =
"SELECT id, code, libelle as label";
116 $sql .=
" FROM " . $this->db->prefix() .
"c_effectif";
117 $sql .=
" WHERE active = 1";
120 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 0);
123 $sql .=
" " . $sqlwhere;
126 $sql .=
" ORDER BY id ASC";
128 dol_syslog(get_class($this) .
'::effectif_array', LOG_DEBUG);
129 $resql = $this->db->query($sql);
131 $num = $this->db->num_rows($resql);
135 $objp = $this->db->fetch_object($resql);
142 $effs[$key] = $objp->label !=
'-' ? (
string) $objp->label :
'';
145 $this->db->free($resql);
149 '@phan-var-force array<string,string> $effs';
167 global $user, $langs;
169 print
'<form method="post" action="' . $page .
'">';
170 print
'<input type="hidden" name="action" value="setprospectlevel">';
171 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
173 dol_syslog(get_class($this) .
'::form_prospect_level', LOG_DEBUG);
174 $sql =
"SELECT code, label";
175 $sql .=
" FROM " . $this->db->prefix() .
"c_prospectlevel";
176 $sql .=
" WHERE active > 0";
177 $sql .=
" ORDER BY sortorder";
178 $resql = $this->db->query($sql);
186 while ($obj = $this->db->fetch_object($resql)) {
187 $level = $langs->trans($obj->code);
189 if ($level == $obj->code) {
190 $level = $langs->trans($obj->label);
193 $options[$obj->code] = $level;
200 if (!empty($htmlname) && $user->admin) {
201 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
203 print
'<input type="submit" class="button button-save valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
218 global $user, $langs;
220 print
'<form method="post" action="' . $page .
'">';
221 print
'<input type="hidden" name="action" value="setprospectcontactlevel">';
222 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
225 $sql =
"SELECT code, label";
226 $sql .=
" FROM " . $this->db->prefix() .
"c_prospectcontactlevel";
227 $sql .=
" WHERE active > 0";
228 $sql .=
" ORDER BY sortorder";
229 $resql = $this->db->query($sql);
237 while ($obj = $this->db->fetch_object($resql)) {
238 $level = $langs->trans($obj->code);
240 if ($level == $obj->code) {
241 $level = $langs->trans($obj->label);
244 $options[$obj->code] = $level;
251 if (!empty($htmlname) && $user->admin) {
252 print
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
254 print
'<input type="submit" class="button button-save valignmiddle small" value="' . $langs->trans(
"Modify") .
'">';
273 print $this->
select_state((
int) $selected, $country_codeid, $htmlname);
290 public function select_state($selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
293 global
$conf, $langs, $user;
295 dol_syslog(get_class($this) .
"::select_departement selected=" . $selected .
", country_codeid=" . $country_codeid, LOG_DEBUG);
297 $langs->load(
"dict");
302 $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";
303 $sql .=
" " . $this->db->prefix() .
"c_departements as d, " . $this->db->prefix() .
"c_regions as r," . $this->db->prefix() .
"c_country as c";
304 $sql .=
" WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
305 $sql .=
" AND d.active = 1 AND r.active = 1 AND c.active = 1";
306 if ($country_codeid && is_numeric($country_codeid)) {
307 $sql .=
" AND c.rowid = '" . $this->db->escape($country_codeid) .
"'";
309 if ($country_codeid && !is_numeric($country_codeid)) {
310 $sql .=
" AND c.code = '" . $this->db->escape($country_codeid) .
"'";
312 $sql .=
" ORDER BY c.code, d.code_departement";
314 $result = $this->db->query($sql);
316 if (!empty($htmlname)) {
317 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
319 if ($country_codeid) {
320 $out .=
'<option value="0"> </option>';
322 $num = $this->db->num_rows($result);
324 dol_syslog(get_class($this) .
"::select_departement num=" . $num, LOG_DEBUG);
328 $obj = $this->db->fetch_object($result);
329 if ($obj->code ==
'0') {
330 $out .=
'<option value="0"> </option>';
332 if (!$country || $country != $obj->country) {
334 if (!$country_codeid && $obj->country_code) {
335 $out .=
'<option value="-1" disabled data-html="----- ' . $obj->country .
' -----">----- ' . $obj->country .
" -----</option>\n";
336 $country = $obj->country;
340 if (!empty($selected) && $selected == $obj->rowid) {
341 $out .=
'<option value="' . $obj->rowid .
'" selected>';
343 $out .=
'<option value="' . $obj->rowid .
'">';
352 $out .= $obj->region_name .
' - ' . $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
354 $out .= $obj->code .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
358 $out .= $obj->region_name .
' - ' . ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
360 $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
369 if (!empty($htmlname)) {
372 if (!empty($htmlname) && $user->admin) {
373 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
380 if (!empty($htmlname)) {
381 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
403 public function select_state_ajax($parent_field_id =
'country_id', $selected = 0, $country_codeid = 0, $htmlname =
'state_id', $morecss =
'maxwidth200onsmartphone minwidth300')
406 $html .=
'$("select[name=\"'.$parent_field_id.
'\"]").change(function(){
407 $.ajax( "'.
dol_buildpath(
'/core/ajax/ziptown.php', 2).
'", { data:{ selected: $("select[name=\"'.$htmlname.
'\"]").val(), country_codeid: $(this).val(), htmlname:"'.$htmlname.
'", morecss:"'.$morecss.
'" } } )
408 .done(function(msg) {
409 $("span#target_'.$htmlname.
'").html(msg);
412 return $html.
'</script><span id="target_'.$htmlname.
'">'.$this->
select_state($selected, $country_codeid, $htmlname, $morecss).
'</span>';
430 global
$conf, $langs;
431 $langs->load(
"dict");
433 $sql =
"SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country";
434 $sql .=
" FROM " . $this->db->prefix() .
"c_regions as r, " . $this->db->prefix() .
"c_country as c";
435 $sql .=
" WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1";
436 $sql .=
" ORDER BY c.code, c.label ASC";
438 dol_syslog(get_class($this) .
"::select_region", LOG_DEBUG);
439 $resql = $this->db->query($sql);
441 print
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
442 $num = $this->db->num_rows($resql);
447 $obj = $this->db->fetch_object($resql);
448 if ($obj->code == 0) {
449 print
'<option value="0"> </option>';
451 if ($country ==
'' || $country != $obj->country) {
453 $key = $langs->trans(
"Country" . strtoupper($obj->country_code));
454 $valuetoshow = ($key !=
"Country" . strtoupper($obj->country_code)) ? $obj->country_code .
" - " . $key : $obj->country;
455 print
'<option value="-2" disabled>----- ' . $valuetoshow .
" -----</option>\n";
456 $country = $obj->country;
459 if ($selected > 0 && $selected == $obj->code) {
460 print
'<option value="' . $obj->code .
'" selected>' . $obj->label .
'</option>';
462 print
'<option value="' . $obj->code .
'">' . $obj->label .
'</option>';
485 public function select_civility($selected =
'', $htmlname =
'civility_id', $morecss =
'maxwidth150', $addjscombo = 1)
488 global $langs, $user;
489 $langs->load(
"dict");
493 $sql =
"SELECT rowid, code, label, active FROM " . $this->db->prefix() .
"c_civility";
494 $sql .=
" WHERE active = 1";
496 dol_syslog(
"Form::select_civility", LOG_DEBUG);
497 $resql = $this->db->query($sql);
499 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
500 $out .=
'<option value=""> </option>';
501 $num = $this->db->num_rows($resql);
505 $obj = $this->db->fetch_object($resql);
506 if ($selected == $obj->code) {
507 $out .=
'<option value="' . $obj->code .
'" selected>';
509 $out .=
'<option value="' . $obj->code .
'">';
512 $out .= ($langs->trans(
"Civility" . $obj->code) !=
"Civility" . $obj->code ? $langs->trans(
"Civility" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
519 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
524 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
549 print $this->select_juridicalstatus($selected, $country_codeid, $filter);
564 public function select_juridicalstatus($selected = 0, $country_codeid = 0, $filter =
'', $htmlname =
'forme_juridique_code', $morecss =
'')
567 global $langs, $user;
568 $langs->load(
"dict");
573 $sql =
"SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code";
574 $sql .=
" FROM " . $this->db->prefix() .
"c_forme_juridique as f, " . $this->db->prefix() .
"c_country as c";
575 $sql .=
" WHERE f.fk_pays = c.rowid";
576 $sql .=
" AND f.active = 1 AND c.active = 1";
577 if ($country_codeid) {
578 $sql .=
" AND c.code = '" . $this->db->escape((
string) $country_codeid) .
"'";
582 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 0);
585 $sql .=
" " . $sqlwhere;
588 $sql .=
" ORDER BY c.code";
590 dol_syslog(get_class($this) .
"::select_juridicalstatus", LOG_DEBUG);
591 $resql = $this->db->query($sql);
593 $out .=
'<div id="particulier2" class="visible">';
594 $out .=
'<select class="flat minwidth200' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
595 if ($country_codeid) {
596 $out .=
'<option value="0"> </option>';
599 $num = $this->db->num_rows($resql);
604 $arraydata = array();
606 $obj = $this->db->fetch_object($resql);
609 $labelcountry = (($langs->trans(
"Country" . $obj->country_code) !=
"Country" . $obj->country_code) ? $langs->trans(
"Country" . $obj->country_code) : $obj->country);
610 $labeljs = (($langs->trans(
"JuridicalStatus" . $obj->code) !=
"JuridicalStatus" . $obj->code) ? $langs->trans(
"JuridicalStatus" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
611 $arraydata[(int) $obj->code] = array(
'code' => (
int) $obj->code,
'label' => $labeljs,
'label_sort' => $labelcountry .
'_' . $labeljs,
'country_code' => (
string) $obj->country_code,
'country' => $labelcountry);
617 if (empty($country_codeid)) {
618 $arraydata[0] = array(
'code' => 0,
'label' =>
'',
'label_sort' =>
'_',
'country_code' =>
'',
'country' =>
'');
621 foreach ($arraydata as $key => $val) {
622 if (!$country || $country != $val[
'country']) {
624 if (empty($country_codeid) && $val[
'country_code']) {
625 $out .=
'<option value="0" disabled class="selectoptiondisabledwhite">----- ' . $val[
'country'] .
" -----</option>\n";
626 $country = $val[
'country'];
630 if ($selected > 0 && $selected == $val[
'code']) {
631 $out .=
'<option value="' . $val[
'code'] .
'" selected>';
633 $out .=
'<option value="' . $val[
'code'] .
'">';
636 $out .= $val[
'label'];
642 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
646 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
673 global
$conf, $user, $hookmanager;
677 $minLength = (is_numeric(
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) ?
$conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2);
682 $tmpthirdparty =
new Societe($this->db);
683 $result = $tmpthirdparty->fetch($selected);
686 $name = $tmpthirdparty->name;
697 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
699 if (count($events)) {
700 print
'<script nonce="' . getNonce() .
'" type="text/javascript">
701 jQuery(document).ready(function() {
702 $("#search_' . $htmlname .
'").change(function() {
703 var obj = ' . json_encode($events) .
';
704 $.each(obj, function(key,values) {
705 if (values.method.length) {
706 runJsCodeForEvent' . $htmlname .
'(values);
710 $(this).trigger("blur");
713 // Function used to execute events when search_htmlname change
714 function runJsCodeForEvent' . $htmlname .
'(obj) {
715 var id = $("#' . $htmlname .
'").val();
716 var method = obj.method;
718 var htmlname = obj.htmlname;
719 var showempty = obj.showempty;
720 console.log("Run runJsCodeForEvent-' . $htmlname .
' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
728 if (response != null)
730 console.log("Change select#"+htmlname+" with content "+response.value)
731 $.each(obj.params, function(key,action) {
733 var num = response.num;
735 $("#" + key).removeAttr(action);
737 $("#" + key).attr(action, action);
741 $("select#" + htmlname).html(response.value);
750 print
"\n" .
'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->' .
"\n";
751 print
'<input type="text" size="30" id="search_' . $htmlname .
'" name="search_' . $htmlname .
'" value="' . $name .
'" />';
752 print
ajax_autocompleter((
string) ($socid ? $socid : -1), $htmlname, DOL_URL_ROOT .
'/societe/ajax/ajaxcompanies.php',
'', $minLength, 0);
756 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias";
758 $sql .=
", s.code_client, s.code_fournisseur";
761 $sql .=
", s.address, s.zip, s.town";
762 $sql .=
", dictp.code as country_code";
764 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
766 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
769 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
") AND s.status = 1";
771 if (is_array($limitto) && count($limitto)) {
772 $sql .=
" AND s.rowid IN (" . $this->db->sanitize(implode(
',', $limitto)) .
")";
775 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
776 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = s.rowid AND sc.fk_user = ".(int) $user->id .
")";
778 if ($user->socid > 0) {
779 $sql .=
" AND s.rowid = ".((int) $user->socid);
782 $parameters = array();
783 $reshook = $hookmanager->executeHooks(
'selectCompaniesForNewContactListWhere', $parameters);
784 $sql .= $hookmanager->resPrint;
785 $sql .=
" ORDER BY s.nom ASC";
787 $resql = $this->db->query($sql);
789 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"';
790 if (
$conf->use_javascript_ajax) {
791 $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;";
792 print
' onChange="' . $javaScript .
'"';
795 print
'<option value="-1"> </option>';
797 $num = $this->db->num_rows($resql);
802 $obj = $this->db->fetch_object($resql);
804 $firstCompany = $obj->rowid;
807 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
810 $nameAlias = !empty($obj->name_alias) ?
' (' . $obj->name_alias .
')' :
'';
811 if ($selected > 0 && $selected == $obj->rowid) {
812 print
'<option value="' . $obj->rowid .
'"';
816 print
' selected>' .
dol_escape_htmltag($obj->name, 0, 0,
'', 0, 1) . $nameAlias .
'</option>';
817 $firstCompany = $obj->rowid;
819 print
'<option value="' . $obj->rowid .
'"';
823 print
'>' .
dol_escape_htmltag($obj->name, 0, 0,
'', 0, 1) . $nameAlias .
'</option>';
830 return $firstCompany;
852 public function selectTypeContact(
$object, $selected, $htmlname =
'type', $source =
'internal', $sortorder =
'position', $showempty = 0, $morecss =
'', $output = 1, $forcehidetooltip = 0)
854 global $user, $langs;
857 if (is_object(
$object) && method_exists(
$object,
'liste_type_contact')) {
858 '@phan-var-force CommonObject $object';
859 $lesTypes =
$object->liste_type_contact($source, $sortorder, 2, 1);
861 $out .=
'<select class="flat valignmiddle' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
863 $out .=
'<option value="0"> </option>';
865 foreach ($lesTypes as $key => $arrayvalue) {
866 $out .=
'<option value="'.$key.
'" data-code="'.$arrayvalue[
'code'].
'"';
867 if ($key == $selected) {
870 $out .=
'>'.$arrayvalue[
'label'].
'</option>';
873 if ($user->admin && empty($forcehidetooltip)) {
874 $out .=
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
881 if (empty($output)) {
899 public function showRoles($htmlname,
Contact $contact, $rendermode =
'view', $selected = array(), $morecss =
'minwidth500', $placeholder =
'')
901 if ($rendermode ===
'view') {
903 foreach ($contact->roles as $key => $val) {
904 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb;">' . $val[
'label'] .
'</li>';
906 return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="' . $htmlname .
'"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
909 if ($rendermode ===
'edit') {
910 $contactType = $contact->listeTypeContacts(
'external', 0, 1,
'',
'',
'agenda');
911 if (count($selected) > 0) {
912 $newselected = array();
913 foreach ($selected as $key => $val) {
914 if (is_array($val) && array_key_exists(
'id', $val) && in_array($val[
'id'], array_keys($contactType))) {
915 $newselected[] = $val[
'id'];
920 if (count($newselected) > 0) {
921 $selected = $newselected;
924 return $this->
multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss, 0,
'90%',
'',
'', $placeholder);
927 return 'ErrorBadValueForParameterRenderMode';
943 public function select_ziptown($selected =
'', $htmlname =
'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib =
'', $morecss =
'')
951 if (!empty($fieldsize)) {
952 $size =
'size="' . $fieldsize .
'"';
955 if (
$conf->use_javascript_ajax && empty($disableautocomplete)) {
957 $moreattrib .=
' autocomplete="off"';
959 $out .=
'<input id="' . $htmlname .
'" class="maxwidthonsmartphone' . ($morecss ?
' ' . $morecss :
'') .
'" type="text"' . ($moreattrib ?
' ' . $moreattrib :
'') .
' name="' . $htmlname .
'" ' . $size .
' value="' . $selected .
'">' .
"\n";
975 public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss =
'maxwidth200')
982 if ($country_code ==
'FR') {
985 } elseif ($idprof == 2) {
987 } elseif ($idprof == 3) {
989 } elseif ($idprof == 4) {
992 } elseif ($country_code ==
'ES') {
995 } elseif ($idprof == 2) {
997 } elseif ($idprof == 3) {
999 } elseif ($idprof == 4) {
1005 $selected = $preselected;
1007 if ($idprof == 1 && !empty($this->idprof1)) {
1008 $selected = $this->idprof1;
1009 } elseif ($idprof == 2 && !empty($this->idprof2)) {
1010 $selected = $this->idprof2;
1011 } elseif ($idprof == 3 && !empty($this->idprof3)) {
1012 $selected = $this->idprof3;
1013 } elseif ($idprof == 4 && !empty($this->idprof4)) {
1014 $selected = $this->idprof4;
1018 $maxlength = $formlength;
1020 if (empty($formlength)) {
1028 $parameters = array(
'formlength' => $formlength,
'selected' => $preselected,
'idprof' => $idprof,
'htmlname' => $htmlname,
'country_code' => $country_code);
1029 $reshook = $hookmanager->executeHooks(
'getInputIdProf', $parameters);
1030 if (empty($reshook)) {
1031 $out .=
'<input type="text" ' . ($morecss ?
'class="' . $morecss .
'" ' :
'') .
'name="' . $htmlname .
'" id="' . $htmlname .
'" maxlength="' . $maxlength .
'" value="' . $selected .
'">';
1033 $out .= $hookmanager->resPrint;
1053 $valors = explode(
":", $tax);
1054 $nbvalues = count($valors);
1056 if ($nbvalues > 1) {
1058 print
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
1060 while ($i < $nbvalues) {
1061 if ($selected == $valors[$i]) {
1062 print
'<option value="' . $valors[$i] .
'" selected>';
1064 print
'<option value="' . $valors[$i] .
'">';
1086 public function selectProspectCustomerType($selected, $htmlname =
'client', $htmlidname =
'customerprospect', $typeinput =
'form', $morecss =
'', $allowempty =
'')
1088 global
$conf, $langs;
1093 $out =
'<select class="flat ' . $morecss .
'" name="' . $htmlname .
'" id="' . $htmlidname .
'">';
1094 if ($typeinput ==
'form') {
1095 if ($allowempty || ($selected ==
'' || $selected ==
'-1')) {
1096 $out .=
'<option value="-1">';
1097 if (is_numeric($allowempty)) {
1100 $out .= $langs->trans($allowempty);
1102 $out .=
'</option>';
1105 $out .=
'<option value="2"' . ($selected == 2 ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1108 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1111 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1113 $out .=
'<option value="0"' . ((
string) $selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'NorProspectNorCustomer') .
'</option>';
1114 } elseif ($typeinput ==
'list') {
1115 $out .=
'<option value="-1"' . (($selected ==
'' || $selected ==
'-1') ?
' selected' :
'') .
'> </option>';
1117 $out .=
'<option value="2,3"' . ($selected ==
'2,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Prospect') .
'</option>';
1120 $out .=
'<option value="1,3"' . ($selected ==
'1,3' ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1123 $out .=
'<option value="4"' . ($selected ==
'4' ?
' selected' :
'') .
'>' . $langs->trans(
'Supplier') .
'</option>';
1125 $out .=
'<option value="0"' . ($selected ==
'0' ?
' selected' :
'') .
'>' . $langs->trans(
'Other') .
'</option>';
1126 } elseif ($typeinput ==
'admin') {
1128 $out .=
'<option value="3"' . ($selected == 3 ?
' selected' :
'') .
'>' . $langs->trans(
'ProspectCustomer') .
'</option>';
1131 $out .=
'<option value="1"' . ($selected == 1 ?
' selected' :
'') .
'>' . $langs->trans(
'Customer') .
'</option>';
1134 $out .=
'</select>';
1151 public function formThirdpartyType($page, $selected =
'', $htmlname =
'socid', $filter =
'', $nooutput = 0)
1154 global
$conf, $langs;
1157 if ($htmlname !=
"none") {
1158 $out .=
'<form method="post" action="' . $page .
'">';
1159 $out .=
'<input type="hidden" name="action" value="set_thirdpartytype">';
1160 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
1162 $out .= $this->
selectarray($htmlname, $this->
typent_array(0, $filter), $selected, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1163 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
1166 if ($selected > 0) {
1168 $typent = empty($arr[$selected]) ?
'' : $arr[$selected];
1194 global $user, $langs;
1196 if ($mode ===
"html") {
1197 $actioncode = empty($prospectstatic->cacheprospectstatus[$statusprospect]) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'code'];
1198 $actionpicto = empty($prospectstatic->cacheprospectstatus[$statusprospect][
'picto']) ?
'' : $prospectstatic->cacheprospectstatus[$statusprospect][
'picto'];
1201 print
img_action(
'', $actioncode, $actionpicto,
'class="inline-block valignmiddle paddingright pictoprospectstatus"');
1202 print
'<select class="flat selectprospectstatus maxwidth150" id="'. $htmlname.$idprospect .
'" data-socid="'.$idprospect.
'" name="' . $htmlname .
'"';
1203 if (!$user->hasRight(
'societe',
'creer')) {
1207 foreach ($prospectstatic->cacheprospectstatus as $key => $val) {
1209 $label = $val[
'label'];
1210 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1212 $label = (($langs->trans(
"StatusProspect".$val[
'code']) !=
"StatusProspect".$val[
'code']) ? $langs->trans(
"StatusProspect".$val[
'code']) : $label);
1214 $label = (($langs->trans(
"StatusProspect".$val[
'id']) !=
"StatusProspect".$val[
'id']) ? $langs->trans(
"StatusProspect".$val[
'id']) : $label);
1222 } elseif ($mode ===
"js") {
1224 jQuery(document).ready(function() {
1225 $(".selectprospectstatus").on("change", function() {
1226 console.log("We change a value into a field selectprospectstatus");
1227 var statusid = $(this).val();
1228 var prospectid = $(this).attr("data-socid");
1229 var image = $(this).prev(".pictoprospectstatus");
1232 url: \'' . DOL_URL_ROOT .
'/core/ajax/ajaxstatusprospect.php\',
1233 data: { id: statusid, prospectid: prospectid, token: \''. newToken() .
'\', action: \
'updatestatusprospect\' },
1234 success: function(response) {
1235 console.log(response.img);
1236 image.replaceWith(response.img);
1239 console.error("Error on status prospect");
if(! $sortfield) if(! $sortorder) $object
ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams='')
Generic function that return javascript to add to transform a common input text or select field into ...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLength=2, $autoselect=0)
Generic function that return javascript to add to a page to transform a common input text field into ...
Class to manage third parties objects (customers, suppliers, prospects...)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
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...
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php