51function ajax_autocompleter($selected, $htmlname, $url, $urloption =
'', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams =
'')
53 if (empty($minLength)) {
57 $dataforrenderITem =
'ui-autocomplete';
58 $dataforitem =
'ui-autocomplete-item';
60 if (defined(
'JS_QUERY_AUTOCOMPLETE_RENDERITEM')) {
61 $dataforrenderITem = constant(
'JS_QUERY_AUTOCOMPLETE_RENDERITEM');
63 if (defined(
'JS_QUERY_AUTOCOMPLETE_ITEM')) {
64 $dataforitem = constant(
'JS_QUERY_AUTOCOMPLETE_ITEM');
67 $htmlnamejquery = str_replace(
'.',
'\\\\.', $htmlname);
71 $script =
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.$selected.
'" '.($moreparams ? $moreparams :
'').
' />';
73 $script .=
'<!-- Javascript code for autocomplete of field '.$htmlname.
' -->'.
"\n";
74 $script .=
'<script>'.
"\n";
75 $script .=
'$(document).ready(function() {
76 var autoselect = '.((int) $autoselect).
';
77 var options = '.json_encode($ajaxoptions).
'; /* Option of actions to do after keyup, or after select */
79 /* Remove selected id as soon as we type or delete a char (it means old selection is wrong). Use keyup/down instead of change to avoid losing the product id. This is needed only for select of predefined product */
80 $("input#search_'.$htmlnamejquery.
'").keydown(function(e) {
81 if (e.keyCode != 9) /* If not "Tab" key */
83 if (e.keyCode == 13) { return false; } /* disable "ENTER" key useful for barcode readers */
84 console.log("Clear id previously selected for field '.$htmlname.
'");
85 $("#'.$htmlnamejquery.
'").val("");
89 // Check options for secondary actions when keyup
90 $("input#search_'.$htmlnamejquery.
'").keyup(function() {
91 if ($(this).val().length == 0)
93 $("#search_'.$htmlnamejquery.
'").val("");
94 $("#'.$htmlnamejquery.
'").val("").trigger("change");
95 if (options.option_disabled) {
96 $("#" + options.option_disabled).removeAttr("disabled");
98 if (options.disabled) {
99 $.each(options.disabled, function(key, value) {
100 $("#" + value).removeAttr("disabled");
103 if (options.update) {
104 $.each(options.update, function(key, value) {
105 $("#" + key).val("").trigger("change");
109 $.each(options.show, function(key, value) {
110 $("#" + value).hide().trigger("hide");
113 if (options.update_textarea) {
114 $.each(options.update_textarea, function(key, value) {
115 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances[key] != "undefined") {
116 CKEDITOR.instances[key].setData("");
118 $("#" + key).html("");
125 // Activate the autocomplete to execute the GET
126 $("input#search_'.$htmlnamejquery.
'").autocomplete({
127 source: function( request, response ) {
128 $.get("'.$url.($urloption ?
'?'.$urloption :
'').
'", { "'.str_replace(
'.',
'_', $htmlname).
'": request.term }, function(data){
131 /* If nothing found, show a line that can not be selected (if a label was provided in options.noresultlabel) */
132 if (data.length == 0 && options.noresultlabel) {
133 response([{ label: options.noresultlabel, value: "", id: "", noresult: true }]);
136 response($.map( data, function(item) {
137 console.log("Received answer from ajax GET, we populate array to return to the jquery autocomplete");
138 if (autoselect == 1 && data.length == 1) {
139 $("#search_'.$htmlnamejquery.
'").val(item.value);
143 // When product has only one price by qty and 1 result, must set data attributes before triggering change
144 $("#'.$htmlname.
'").attr("data-pbq", item.pbq);
145 $("#'.$htmlname.
'").attr("data-pbqup", item.price_ht);
146 $("#'.$htmlname.
'").attr("data-pbqbase", item.pricebasetype);
147 $("#'.$htmlname.
'").attr("data-pbqqty", item.qty);
148 $("#'.$htmlname.
'").attr("data-pbqpercent", item.discount);
152 $("#'.$htmlnamejquery.
'").val(item.key).trigger("change");
155 if (item.labelhtml != null) {
156 label = item.labelhtml.toString();
157 } else if (item.label != null) {
158 label = item.label.toString();
161 if (options.update) {
162 $.each(options.update, function(key, value) {
163 update[key] = item[value];
167 if (options.update_textarea) {
168 $.each(options.update_textarea, function(key, value) {
169 textarea[key] = item[value];
173 return { label: label,
176 disabled: item.disabled,
182 discount: item.discount,
183 pricebasetype: item.pricebasetype,
184 price_ht: item.price_ht,
185 price_ttc: item.price_ttc,
186 price_unit_ht: item.price_unit_ht,
187 price_unit_ht_locale: item.price_unit_ht_locale,
188 multicurrency_code: item.multicurrency_code,
189 multicurrency_unitprice: item.multicurrency_unitprice,
190 description : item.description,
191 ref_customer: item.ref_customer,
193 default_vat_code: item.default_vat_code,
194 supplier_ref: item.supplier_ref
198 console.error("Error: Ajax url '.$url.($urloption ?
'?'.$urloption :
'').
' has returned an empty page. Should be an empty json array.");
203 minLength: '.((
int) $minLength).
',
204 focus: function( event, ui ) {
205 if (ui.item.noresult) { return false; }
207 select: function( event, ui ) { // Function ran once a new value has been selected into the javascript combo
208 if (ui.item.noresult) { return false; }
209 console.log("We will trigger change on input '.$htmlname.
' because of the select definition of autocomplete code for input#search_'.$htmlname.
'");
210 console.log("Selected id = "+ui.item.id+" - If this value is null, it means you select a record with key that is null so selection is not effective");
212 console.log("Before, we propagate some properties, retrieved by the ajax of the get, into the data-xxx properties of the component #'.$htmlnamejquery.
'");
213 //console.log(ui.item);
215 // For supplier price and customer when price by quantity is off
216 $("#'.$htmlnamejquery.
'").attr("data-up", ui.item.price_ht);
217 $("#'.$htmlnamejquery.
'").attr("data-up-locale", ui.item.price_unit_ht_locale);
218 $("#'.$htmlnamejquery.
'").attr("data-base", ui.item.pricebasetype);
219 $("#'.$htmlnamejquery.
'").attr("data-qty", ui.item.qty);
220 $("#'.$htmlnamejquery.
'").attr("data-discount", ui.item.discount);
221 $("#'.$htmlnamejquery.
'").attr("data-description", ui.item.description);
222 $("#'.$htmlnamejquery.
'").attr("data-ref-customer", ui.item.ref_customer);
223 $("#'.$htmlnamejquery.
'").attr("data-tvatx", ui.item.tva_tx);
224 $("#'.$htmlnamejquery.
'").attr("data-default-vat-code", ui.item.default_vat_code);
225 $("#'.$htmlnamejquery.
'").attr("data-supplier-ref", ui.item.supplier_ref); // supplier_ref of price
227 // For multi-currency values
228 $("#'.$htmlnamejquery.
'").attr("data-multicurrency-code", ui.item.multicurrency_code);
229 $("#'.$htmlnamejquery.
'").attr("data-multicurrency-unitprice", ui.item.multicurrency_unitprice);
233 // For customer price when PRODUIT_CUSTOMER_PRICES_BY_QTY is on
234 console.log("PRODUIT_CUSTOMER_PRICES_BY_QTY is on, so we propagate also prices by quantity into data-pbqxxx properties");
235 $("#'.$htmlnamejquery.
'").attr("data-pbq", ui.item.pbq);
236 $("#'.$htmlnamejquery.
'").attr("data-pbqup", ui.item.price_ht);
237 $("#'.$htmlnamejquery.
'").attr("data-pbqbase", ui.item.pricebasetype);
238 $("#'.$htmlnamejquery.
'").attr("data-pbqqty", ui.item.qty);
239 $("#'.$htmlnamejquery.
'").attr("data-pbqpercent", ui.item.discount);
243 // A new value has been selected, we trigger the handlers on #htmlnamejquery
244 console.log("Now, we trigger changes on #'.$htmlnamejquery.
'");
245 $("#'.$htmlnamejquery.
'").val(ui.item.id).trigger("change"); // Select new value
247 // Complementary actions
249 // Disable an element
250 if (options.option_disabled) {
251 console.log("Make action option_disabled on #"+options.option_disabled+" with disabled="+ui.item.disabled)
252 if (ui.item.disabled) {
253 $("#" + options.option_disabled).prop("disabled", true);
255 $.jnotify(options.error, "error", true); // Output with jnotify the error message
257 if (options.warning) {
258 $.jnotify(options.warning, "warning", false); // Output with jnotify the warning message
261 $("#" + options.option_disabled).removeAttr("disabled");
265 if (options.disabled) {
266 console.log("Make action \'disabled\' on each "+options.option_disabled)
267 $.each(options.disabled, function(key, value) {
268 $("#" + value).prop("disabled", true);
272 console.log("Make action \'show\' on each "+options.show)
273 $.each(options.show, function(key, value) {
274 $("#" + value).show().trigger("show");
279 if (ui.item.update) {
280 console.log("Make action \'update\' on each ui.item.update (if there is)")
281 // loop on each "update" fields
282 $.each(ui.item.update, function(key, value) {
283 console.log("Set value "+value+" into #"+key);
284 $("#" + key).val(value).trigger("change");
287 if (ui.item.textarea) {
288 console.log("Make action \'textarea\' on each ui.item.textarea (if there is)")
289 $.each(ui.item.textarea, function(key, value) {
290 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances[key] != "undefined") {
291 CKEDITOR.instances[key].setData(value);
292 CKEDITOR.instances[key].focus();
294 $("#" + key).html(value);
295 $("#" + key).focus();
299 console.log("ajax_autocompleter new value selected, we trigger change also on original component so on field #search_'.$htmlname.
'");
301 $("#search_'.$htmlnamejquery.
'").trigger("change"); // We have changed value of the combo select, we must be sure to trigger all js hook binded on this event. This is required to trigger other javascript change method binded on original field by other code.
305 const widgetData = $("input#search_'.$htmlnamejquery.
'").data("'.$dataforrenderITem.
'");
307 widgetData._renderItem = function( ul, item ) {
309 .addClass(item.noresult ? "ui-state-disabled" : "")
310 .data( "'.$dataforitem.
'", item ) // jQuery UI > 1.10.0
311 .append( \'<a><span class="tag">\' + item.label + "</span></a>" )
317 $script .=
'</script>';
488function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = 0, $forcefocus = 0, $widthTypeOfAutocomplete =
'resolve', $idforemptyvalue =
'-1', $morecss =
'', $placeholder =
'')
493 if (!empty(
$conf->browser->layout) &&
$conf->browser->layout ==
'phone' &&
getDolGlobalString(
'MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE')) {
500 if (empty(
$conf->use_javascript_ajax)) {
503 if (!
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') && !defined(
'REQUIRE_JQUERY_MULTISELECT')) {
510 if (empty($minLengthToAutocomplete)) {
511 $minLengthToAutocomplete = 0;
514 $moreselect2theme = ($morecss ?
dol_escape_js(
' '.$morecss) :
'');
515 $moreselect2theme = preg_replace(
'/widthcentpercentminus[^\s]*/',
'', $moreselect2theme);
517 $tmpplugin =
'select2';
518 $componentname = (preg_match(
'/^\./', $htmlname) ? $htmlname :
'#'.$htmlname);
520 $msg .=
'<!-- JS CODE TO ENABLE '.$tmpplugin.
' for id = '.$htmlname.
' -->'.
"\n";
521 $msg .=
"<script>\n";
522 $msg .=
'$(document).ready(function () {
523 $(\''.dol_escape_js($componentname).
'\').
'.$tmpplugin.'({
';
524 // when $morecss contains 'onrightofpage
', the select2 component must also be inside a parent with class="parentonrightofpage"
525 if (preg_match('/onrightofpage/
', $morecss)) { // In this case, htmlname must be an ID not a class.
526 $msg .= ' dropdownAutoWidth:
true,
';
527 $msg .= ' dropdownParent: $(\
'#'.$htmlname.
'\').parent(),
';
533 text: \''.dol_escape_js($placeholder).
'\'
538 width: \''.dol_escape_js($widthTypeOfAutocomplete).
'\',
539 minimumInputLength:
'.((int) $minLengthToAutocomplete).',
540 language: (typeof select2arrayoflanguage === \
'undefined\') ? \'en\' : select2arrayoflanguage,
541 matcher: function (params, data) {
542 if ($.trim(params.term) === "") { return data; }';
545 var term = params.term.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase()
546 var searchText = data.element ? $(data.element).attr("data-search") : undefined;
547 var text = (searchText !== undefined ? searchText : (data.text || "")).normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase() || "";';
550 var term = params.term.toLowerCase();
551 var searchText = data.element ? $(data.element).attr("data-search") : undefined;
552 var text = (searchText !== undefined ? searchText : (data.text || "")).toLowerCase();';
555 var keywords = term.split(" ");
556 for (var i = 0; i < keywords.length; i++) {
557 if (text.indexOf(keywords[i]) === -1) {
563 theme: \'default'.dol_escape_js($moreselect2theme).
'\',
564 containerCssClass: \
':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
565 selectionCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
566 dropdownCssClass: \'dol-dropdown-dialog dol-dropdown-dialogmono\',
567 templateResult: function (data, container) { /* Format visible output into combo list */
568 /* Code to add class of origin OPTION propagated to the new select2 <li> tag */
569 if (data.element) { $(container).addClass($(data.element).attr("class")); }
570 /* console.log("data html is "+$(data.element).attr("data-html")); */
571 if (data.id == \''.(dol_escape_js($idforemptyvalue)).
'\' && $(data.element).attr(
"data-html") == undefined) {
574 if ($(data.element).attr("data-html") != undefined) {
575 /* If property html set, we decode html entities and use this. */
576 /* Note that HTML content must have been sanitized against js injection with dol_escape_htmltag(xxx, 0, 0, \'\', 0, 1) when building the select option. */
577 if (typeof htmlEntityDecodeJs === "function") {
578 return htmlEntityDecodeJs($(data.element).attr("data-html"));
583 templateSelection: function (selection) { /* Format visible output of selected value */
584 if (selection.id == \''.(dol_escape_js($idforemptyvalue)).
'\')
return \
'<span class="placeholder">\'+selection.text+\'</span>\';
585 if (selection.element && $(selection.element).attr("data-select-html") != undefined) {
586 if (typeof htmlEntityDecodeJs === "function") {
587 return htmlEntityDecodeJs($(selection.element).attr("data-select-html"));
590 return selection.text;
592 escapeMarkup: function(markup) {
597 $msg .=
'.select2(\'focus\')';
602 $msg .=
"</script>\n";
708function ajax_constantonoff($code, $input = array(), $entity =
null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0, $setzeroinsteadofdel = 0, $suffix =
'', $mode =
'', $morecss =
'inline-block', $userconst = 0, $showwarning =
'', $disabled = 0)
710 global
$conf, $langs, $user, $db;
712 $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity :
$conf->entity);
713 if (!isset($input)) {
719 if (empty(
$conf->use_javascript_ajax) || $forcenoajax) {
721 $out =
'<a '.($morecss ?
'class="'.$morecss.
'" ' :
'').
'href="'.$_SERVER[
'PHP_SELF'].
'?action=set_'.$code.
'&token='.
newToken().
'&entity='.$entity.($mode ?
'&mode='.$mode :
'').($forcereload ?
'&dol_resetcache=1' :
'').
'">'.img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
723 $out =
'<a '.($morecss ?
'class="'.$morecss.
'" ' :
'').
' href="'.$_SERVER[
'PHP_SELF'].
'?action=del_'.$code.
'&token='.
newToken().
'&entity='.$entity.($mode ?
'&mode='.$mode :
'').($forcereload ?
'&dol_resetcache=1' :
'').
'">'.img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
727 if (is_object($userconst)) {
728 $userconstid = $userconst->id;
729 } elseif (is_numeric($userconst) && $userconst > 0) {
730 $userconstid = $userconst;
731 $userconst =
new User($db);
732 $userconst->fetch($userconstid);
736 $morecss .=
' disabled opacitymedium';
738 $out =
"\n<!-- Ajax code to switch constant ".$code.
" -->".
'
740 $(document).ready(function() {
741 var input = '.json_encode($input).
';
742 var url = \''.DOL_URL_ROOT.
'/core/ajax/constantonoff.php\';
744 var entity = \
''.dol_escape_js((
string) $entity).
'\';
745 var strict = \
''.dol_escape_js((
string) $strict).
'\';
746 var userid = \
''.dol_escape_js((
string) $user->id).
'\';
747 var userconst =
'.((int) $userconstid).';
748 var yesButton = \
''.dol_escape_js($langs->transnoentities(
"Yes")).
'\';
749 var noButton = \
''.dol_escape_js($langs->transnoentities(
"No")).
'\';
750 var token = \
''.currentToken().
'\';
751 var warning = \
''.dol_escape_js($showwarning).
'\';
754 $(
"#set_" + code).click(
function() {
759 if (input.alert && input.alert.set) {
760 if (input.alert.set.yesButton) yesButton = input.alert.set.yesButton;
761 if (input.alert.set.noButton) noButton = input.alert.set.noButton;
762 confirmConstantAction(
"set", url, code, input, input.alert.set, entity, yesButton, noButton, strict, userid, token);
764 setConstant(url, code, input, entity, 0,
'.((int) $forcereload).', userid, token, 1, userconst);
769 $(
"#del_" + code).click(
function() {
770 if (input.alert && input.alert.del) {
771 if (input.alert.del.yesButton) yesButton = input.alert.del.yesButton;
772 if (input.alert.del.noButton) noButton = input.alert.del.noButton;
773 confirmConstantAction(
"del", url, code, input, input.alert.del, entity, yesButton, noButton, strict, userid, token);
775 if (empty($setzeroinsteadofdel)) {
776 $out .= ' delConstant(url, code, input, entity, 0,
'.((int) $forcereload).', userid, token, userconst);
';
778 $out .= ' setConstant(url, code, input, entity, 0,
'.((int) $forcereload).', userid, token, 0, userconst);
';
786 if (!empty($userconst) && $userconst instanceof User) {
787 $value = getDolUserString($code, '', $userconst);
789 $value = getDolGlobalString($code);
792 if (is_array($suffix)) {
793 $suffixon = $suffix['ifon
'];
794 $suffixoff = $suffix['ifoff
'];
795 } else { // old mode deprecated
796 $suffixon = (string) $suffix;
800 $out .= '<div
id=
"confirm_'.$code.'" title=
"" style=
"display: none;"></div>
';
801 $out .= '<span
id=
"set_'.$code.'" class=
"valignmiddle inline-block linkobject '.($value ? 'hideobject' : '').($morecss ? ' '.$morecss : '').'">
'.($revertonoff ? img_picto($langs->trans("Enabled"), 'switch_on
'.$suffixoff, '', 0, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Disabled"), 'switch_off
'.$suffixoff, '', 0, 0, 0, '', '', $marginleftonlyshort)).'</span>
';
802 $out .= '<span
id=
"del_'.$code.'" class=
"valignmiddle inline-block linkobject '.($value ? '' : 'hideobject').($morecss ? ' '.$morecss : '').'">
'.($revertonoff ? img_picto($langs->trans("Disabled"), 'switch_off
'.$suffixon, '', 0, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Enabled"), 'switch_on
'.$suffixon, '', 0, 0, 0, '', '', $marginleftonlyshort)).'</span>
';
827function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array(), $morecss = '
', $htmlname = '', $forcenojs = 0, $moreparam = '', $readonly = 0)
829 global $conf, $langs;
831 if (empty($htmlname)) {
837 if (!empty($conf->use_javascript_ajax) && empty($forcenojs) && empty($readonly)) {
840 var input =
'.json_encode($input).';
843 $(
"#set_'.$htmlname.'_'.$object->id.'").click(
function() {
844 console.log(
"Click managed by ajax_object_onoff");
845 $.get(
"'.DOL_URL_ROOT.'/core/ajax/objectonoff.php", {
847 field: \''.dol_escape_js($field).
'\',
850 id: \
''.((int)
$object->id).
'\',
851 token: \
''.currentToken().
'\'
855 var data = JSON.parse(response);
858 console.log(response);
861 $(
"#set_'.$htmlname.'_'.$object->id.'").hide();
862 $(
"#del_'.$htmlname.'_'.$object->id.'").show();
864 if (input.disabled && input.disabled.length > 0) {
865 $.each(input.disabled,
function(key,value) {
866 $(
"#" + value).removeAttr(
"disabled");
867 if ($(
"#" + value).hasClass(
"butActionRefused") == true) {
868 $(
"#" + value).removeClass(
"butActionRefused");
869 $(
"#" + value).addClass(
"butAction");
873 }
else if (input.showhide && input.showhide.length > 0) {
874 $.each(input.showhide,
function(key,value) {
875 $(
"#" + value).show();
881 console.warn(response.responseText);
882 Dolibarr.tools.setEventMessage(response.responseText,
"errors");
888 $(
"#del_'.$htmlname.'_'.$object->id.'").click(
function() {
889 console.log(
"Click managed by ajax_object_onoff");
890 $.get(
"'.DOL_URL_ROOT.'/core/ajax/objectonoff.php", {
892 field: \''.dol_escape_js($field).
'\',
895 id: \''.((int)
$object->id).
'\',
900 var data = JSON.parse(response);
903 console.log(response);
906 $("#del_'.$htmlname.
'_'.
$object->id.
'").hide();
907 $("#set_'.$htmlname.
'_'.
$object->id.
'").show();
908 // Disable another element
909 if (input.disabled && input.disabled.length > 0) {
910 $.each(input.disabled, function(key,value) {
911 $("#" + value).prop("disabled", true);
912 if ($("#" + value).hasClass("butAction") == true) {
913 $("#" + value).removeClass("butAction");
914 $("#" + value).addClass("butActionRefused");
917 // Hide another element
918 } else if (input.showhide && input.showhide.length > 0) {
919 $.each(input.showhide, function(key,value) {
920 $("#" + value).hide();
925 //alert(response.responseText);
926 console.warn(response.responseText);
927 Dolibarr.tools.setEventMessage(response.responseText, "errors");
935 $switchon =
'switch_on';
936 $switchoff =
'switch_off';
939 $tmparray = explode(
':', $text_on);
940 if (!empty($tmparray[1])) {
941 $text_on = $tmparray[0];
942 $switchon = $tmparray[1];
943 if (!empty($tmparray[2])) {
944 $cssswitchon = $tmparray[2];
947 $tmparray = explode(
':', $text_off);
948 if (!empty($tmparray[1])) {
949 $text_off = $tmparray[0];
950 $switchoff = $tmparray[1];
951 if (!empty($tmparray[2])) {
952 $cssswitchoff = $tmparray[2];
956 if (empty(
$conf->use_javascript_ajax) || $forcenojs) {
957 $url = DOL_URL_ROOT.
'/core/ajax/objectonoff.php?action=set&token='.
newToken().
'&id='.((int)
$object->id).
'&element='.urlencode(
$object->element).
'&field='.urlencode($field).
'&value=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.($moreparam ?
'&'.$moreparam :
''));
961 $out .=
'<a id="set_'.$htmlname.
'_'.
$object->id.
'" class="linkobject '.(
$object->$code == 1 ?
'hideobject' :
'').($morecss ?
' '.$morecss :
'').
'" href="'.$url.
'">'.img_picto($langs->trans($text_off), $switchoff,
'', 0, 0, 0,
'', $cssswitchoff).
'</a>';
962 $url = DOL_URL_ROOT.
'/core/ajax/objectonoff.php?action=set&token='.
newToken().
'&id='.((int)
$object->id).
'&element='.urlencode(
$object->element).
'&field='.urlencode($field).
'&value=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.($moreparam ?
'&'.$moreparam :
''));
966 $out .=
'<a id="del_'.$htmlname.
'_'.
$object->id.
'" class="linkobject '.(
$object->$code == 1 ?
'' :
'hideobject').($morecss ?
' '.$morecss :
'').
'" href="'.$url.
'">'.img_picto($langs->trans($text_on), $switchon,
'', 0, 0, 0,
'', $cssswitchon).
'</a>';
968 $out .=
'<span id="set_'.$htmlname.
'_'.
$object->id.
'" class="linkobject '.(
$object->$code == 1 ?
'hideobject' :
'').($morecss ?
' '.$morecss :
'').
'">'.img_picto($langs->trans($text_off), $switchoff,
'', 0, 0, 0,
'', $cssswitchoff).
'</span>';
969 $out .=
'<span id="del_'.$htmlname.
'_'.
$object->id.
'" class="linkobject '.(
$object->$code == 1 ?
'' :
'hideobject').($morecss ?
' '.$morecss :
'').
'">'.img_picto($langs->trans($text_on), $switchon,
'', 0, 0, 0,
'', $cssswitchon).
'</span>';
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='', $placeholder='')
Convert a html select field into an ajax combobox.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined: