48 function ajax_autocompleter($selected, $htmlname, $url, $urloption =
'', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams =
'')
50 if (empty($minLength)) {
54 $dataforrenderITem =
'ui-autocomplete';
55 $dataforitem =
'ui-autocomplete-item';
57 if (defined(
'JS_QUERY_AUTOCOMPLETE_RENDERITEM')) {
58 $dataforrenderITem = constant(
'JS_QUERY_AUTOCOMPLETE_RENDERITEM');
60 if (defined(
'JS_QUERY_AUTOCOMPLETE_ITEM')) {
61 $dataforitem = constant(
'JS_QUERY_AUTOCOMPLETE_ITEM');
64 $htmlnamejquery = str_replace(
'.',
'\\\\.', $htmlname);
68 $script =
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.$selected.
'" '.($moreparams ? $moreparams :
'').
' />';
70 $script .=
'<!-- Javascript code for autocomplete of field '.$htmlname.
' -->'.
"\n";
71 $script .=
'<script>'.
"\n";
72 $script .=
'$(document).ready(function() {
73 var autoselect = '.((int) $autoselect).
';
74 var options = '.json_encode($ajaxoptions).
'; /* Option of actions to do after keyup, or after select */
76 /* 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 */
77 $("input#search_'.$htmlnamejquery.
'").keydown(function(e) {
78 if (e.keyCode != 9) /* If not "Tab" key */
80 if (e.keyCode == 13) { return false; } /* disable "ENTER" key useful for barcode readers */
81 console.log("Clear id previously selected for field '.$htmlname.
'");
82 $("#'.$htmlnamejquery.
'").val("");
86 // Check options for secondary actions when keyup
87 $("input#search_'.$htmlnamejquery.
'").keyup(function() {
88 if ($(this).val().length == 0)
90 $("#search_'.$htmlnamejquery.
'").val("");
91 $("#'.$htmlnamejquery.
'").val("").trigger("change");
92 if (options.option_disabled) {
93 $("#" + options.option_disabled).removeAttr("disabled");
95 if (options.disabled) {
96 $.each(options.disabled, function(key, value) {
97 $("#" + value).removeAttr("disabled");
100 if (options.update) {
101 $.each(options.update, function(key, value) {
102 $("#" + key).val("").trigger("change");
106 $.each(options.show, function(key, value) {
107 $("#" + value).hide().trigger("hide");
110 if (options.update_textarea) {
111 $.each(options.update_textarea, function(key, value) {
112 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances[key] != "undefined") {
113 CKEDITOR.instances[key].setData("");
115 $("#" + key).html("");
122 // Activate the autocomplete to execute the GET
123 $("input#search_'.$htmlnamejquery.
'").autocomplete({
124 source: function( request, response ) {
125 $.get("'.$url.($urloption ?
'?'.$urloption :
'').
'", { "'.str_replace(
'.',
'_', $htmlname).
'": request.term }, function(data){
128 response($.map( data, function(item) {
129 if (autoselect == 1 && data.length == 1) {
130 $("#search_'.$htmlnamejquery.
'").val(item.value);
131 $("#'.$htmlnamejquery.
'").val(item.key).trigger("change");
134 if (item.label != null) {
135 label = item.label.toString();
138 if (options.update) {
139 $.each(options.update, function(key, value) {
140 update[key] = item[value];
144 if (options.update_textarea) {
145 $.each(options.update_textarea, function(key, value) {
146 textarea[key] = item[value];
150 console.log("Return value from GET to the rest of code");
151 return { label: label,
154 disabled: item.disabled,
160 discount: item.discount,
161 pricebasetype: item.pricebasetype,
162 price_ht: item.price_ht,
163 price_ttc: item.price_ttc,
164 price_unit_ht: item.price_unit_ht,
165 price_unit_ht_locale: item.price_unit_ht_locale,
166 multicurrency_code: item.multicurrency_code,
167 multicurrency_unitprice: item.multicurrency_unitprice,
168 description : item.description,
169 ref_customer: item.ref_customer,
171 default_vat_code: item.default_vat_code,
172 supplier_ref: item.supplier_ref
176 console.error("Error: Ajax url '.$url.($urloption ?
'?'.$urloption :
'').
' has returned an empty page. Should be an empty json array.");
181 minLength: '.((
int) $minLength).
',
182 select: function( event, ui ) { // Function ran once a new value has been selected into the javascript combo
183 console.log("We will trigger change on input '.$htmlname.
' because of the select definition of autocomplete code for input#search_'.$htmlname.
'");
184 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");
186 console.log("Before, we propagate some properties, retrieved by the ajax of the get, into the data-xxx properties of the component #'.$htmlnamejquery.
'");
187 //console.log(ui.item);
189 // For supplier price and customer when price by quantity is off
190 $("#'.$htmlnamejquery.
'").attr("data-up", ui.item.price_ht);
191 $("#'.$htmlnamejquery.
'").attr("data-up-locale", ui.item.price_unit_ht_locale);
192 $("#'.$htmlnamejquery.
'").attr("data-base", ui.item.pricebasetype);
193 $("#'.$htmlnamejquery.
'").attr("data-qty", ui.item.qty);
194 $("#'.$htmlnamejquery.
'").attr("data-discount", ui.item.discount);
195 $("#'.$htmlnamejquery.
'").attr("data-description", ui.item.description);
196 $("#'.$htmlnamejquery.
'").attr("data-ref-customer", ui.item.ref_customer);
197 $("#'.$htmlnamejquery.
'").attr("data-tvatx", ui.item.tva_tx);
198 $("#'.$htmlnamejquery.
'").attr("data-default-vat-code", ui.item.default_vat_code);
199 $("#'.$htmlnamejquery.
'").attr("data-supplier-ref", ui.item.supplier_ref); // supplier_ref of price
201 // For multi-currency values
202 $("#'.$htmlnamejquery.
'").attr("data-multicurrency-code", ui.item.multicurrency_code);
203 $("#'.$htmlnamejquery.
'").attr("data-multicurrency-unitprice", ui.item.multicurrency_unitprice);
207 // For customer price when PRODUIT_CUSTOMER_PRICES_BY_QTY is on
208 console.log("PRODUIT_CUSTOMER_PRICES_BY_QTY is on, so we propagate also prices by quantity into data-pbqxxx properties");
209 $("#'.$htmlnamejquery.
'").attr("data-pbq", ui.item.pbq);
210 $("#'.$htmlnamejquery.
'").attr("data-pbqup", ui.item.price_ht);
211 $("#'.$htmlnamejquery.
'").attr("data-pbqbase", ui.item.pricebasetype);
212 $("#'.$htmlnamejquery.
'").attr("data-pbqqty", ui.item.qty);
213 $("#'.$htmlnamejquery.
'").attr("data-pbqpercent", ui.item.discount);
217 // A new value has been selected, we trigger the handlers on #htmlnamejquery
218 console.log("Now, we trigger changes on #'.$htmlnamejquery.
'");
219 $("#'.$htmlnamejquery.
'").val(ui.item.id).trigger("change"); // Select new value
221 // Complementary actions
223 // Disable an element
224 if (options.option_disabled) {
225 console.log("Make action option_disabled on #"+options.option_disabled+" with disabled="+ui.item.disabled)
226 if (ui.item.disabled) {
227 $("#" + options.option_disabled).prop("disabled", true);
229 $.jnotify(options.error, "error", true); // Output with jnotify the error message
231 if (options.warning) {
232 $.jnotify(options.warning, "warning", false); // Output with jnotify the warning message
235 $("#" + options.option_disabled).removeAttr("disabled");
239 if (options.disabled) {
240 console.log("Make action \'disabled\' on each "+options.option_disabled)
241 $.each(options.disabled, function(key, value) {
242 $("#" + value).prop("disabled", true);
246 console.log("Make action \'show\' on each "+options.show)
247 $.each(options.show, function(key, value) {
248 $("#" + value).show().trigger("show");
253 if (ui.item.update) {
254 console.log("Make action \'update\' on each ui.item.update (if there is)")
255 // loop on each "update" fields
256 $.each(ui.item.update, function(key, value) {
257 console.log("Set value "+value+" into #"+key);
258 $("#" + key).val(value).trigger("change");
261 if (ui.item.textarea) {
262 console.log("Make action \'textarea\' on each ui.item.textarea (if there is)")
263 $.each(ui.item.textarea, function(key, value) {
264 if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances[key] != "undefined") {
265 CKEDITOR.instances[key].setData(value);
266 CKEDITOR.instances[key].focus();
268 $("#" + key).html(value);
269 $("#" + key).focus();
273 console.log("ajax_autocompleter new value selected, we trigger change also on original component so on field #search_'.$htmlname.
'");
275 $("#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.
278 }).data("'.$dataforrenderITem.
'")._renderItem = function( ul, item ) {
280 .data( "'.$dataforitem.
'", item ) // jQuery UI > 1.10.0
281 .append( \'<a><span class="tag">\' + item.label + "</span></a>" )
286 $script .=
'</script>';
307 $script =
'<!-- Autocomplete -->'.
"\n";
308 $script .=
'<script>';
309 $script .=
'jQuery(document).ready(function() {
310 var fields = '.json_encode($fields).
';
311 var nboffields = fields.length;
312 var autoselect = '.$autoselect.
';
313 //alert(fields + " " + nboffields);
315 // Activate the autocomplete to execute the GET
316 jQuery("input#'.$htmlname.
'").autocomplete({
318 minLength: '.$minLength.
',
319 source: function( request, response ) {
320 jQuery.getJSON( "'.$url.($option ?
'?'.$option :
'').
'", { '.$htmlname.
': request.term }, function(data){
321 response( jQuery.map( data, function( item ) {
322 if (autoselect == 1 && data.length == 1) {
323 jQuery("#'.$htmlname.
'").val(item.value);
324 // TODO move this to specific request
326 jQuery("#state_id").html(item.states);
328 for (i=0;i<nboffields;i++) {
329 if (item[fields[i]]) { // If defined
330 //alert(item[fields[i]]);
331 jQuery("#" + fields[i]).val(item[fields[i]]);
339 select: function( event, ui ) {
341 for (i=0;i<nboffields;i++) {
342 //alert(fields[i] + " = " + ui.item[fields[i]]);
343 if (fields[i]=="selectcountry_id")
345 if (ui.item[fields[i]] > 0) // Do not erase country if unknown
347 oldvalue=jQuery("#" + fields[i]).val();
348 newvalue=ui.item[fields[i]];
349 //alert(oldvalue+" "+newvalue);
350 jQuery("#" + fields[i]).val(ui.item[fields[i]]);
351 if (oldvalue != newvalue) // To force select2 to refresh visible content
353 needtotrigger="#" + fields[i];
356 // If we set new country and new state, we need to set a new list of state to allow change
357 if (ui.item.states && ui.item["state_id"] != jQuery("#state_id").value) {
358 jQuery("#state_id").html(ui.item.states);
362 else if (fields[i]=="state_id" || fields[i]=="state_id")
364 if (ui.item[fields[i]] > 0) // Do not erase state if unknown
366 oldvalue=jQuery("#" + fields[i]).val();
367 newvalue=ui.item[fields[i]];
368 //alert(oldvalue+" "+newvalue);
369 jQuery("#" + fields[i]).val(ui.item[fields[i]]); // This may fails if not correct country
370 if (oldvalue != newvalue) // To force select2 to refresh visible content
372 needtotrigger="#" + fields[i];
376 else if (ui.item[fields[i]]) { // If defined
377 oldvalue=jQuery("#" + fields[i]).val();
378 newvalue=ui.item[fields[i]];
379 //alert(oldvalue+" "+newvalue);
380 jQuery("#" + fields[i]).val(ui.item[fields[i]]);
381 if (oldvalue != newvalue) // To force select2 to refresh visible content
383 needtotrigger="#" + fields[i];
387 if (needtotrigger != "") // To force select2 to refresh visible content
389 // We introduce a delay so hand is back to js and all other js change can be done before the trigger that may execute a submit is done
390 // This is required for example when changing zip with autocomplete that change the country
391 jQuery(needtotrigger).delay(500).queue(function() {
392 jQuery(this).trigger("change");
399 $script .=
'</script>';
416 $msg =
'<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).
'">';
418 $msg .=
'</div>'.
"\n";
421 jQuery("#dialog-info").dialog({
428 jQuery(this).dialog(\'close\');
456 function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = 0, $forcefocus = 0, $widthTypeOfAutocomplete =
'resolve', $idforemptyvalue =
'-1', $morecss =
'')
461 if (!empty($conf->browser->layout) && $conf->browser->layout ==
'phone' &&
getDolGlobalString(
'MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE')) {
468 if (empty($conf->use_javascript_ajax)) {
471 if (!
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') && !defined(
'REQUIRE_JQUERY_MULTISELECT')) {
478 if (empty($minLengthToAutocomplete)) {
479 $minLengthToAutocomplete = 0;
482 $moreselect2theme = ($morecss ?
dol_escape_js(
' '.$morecss) :
'');
483 $moreselect2theme = preg_replace(
'/widthcentpercentminus[^\s]*/',
'', $moreselect2theme);
485 $tmpplugin =
'select2';
486 $msg =
"\n".
'<!-- JS CODE TO ENABLE '.$tmpplugin.
' for id = '.$htmlname.
' -->
488 $(document).ready(function () {
489 $(\''.(preg_match(
'/^\./', $htmlname) ? $htmlname :
'#'.$htmlname).
'\').
'.$tmpplugin.'({
491 if (preg_match(
'/onrightofpage/', $morecss)) {
492 $msg .=
' dropdownAutoWidth: true, dropdownParent: $(\'#'.$htmlname.
'\').parent(),
'."\n";
494 $msg .= ' width: \
''.dol_escape_js($widthTypeOfAutocomplete).
'\',
495 minimumInputLength:
'.((int) $minLengthToAutocomplete).',
496 language: select2arrayoflanguage,
497 matcher:
function (params, data) {
498 if ($.trim(params.term) ===
"") {
501 keywords = (params.term).split(
" ");
502 for (var i = 0; i < keywords.length; i++) {
503 if (((data.text).toUpperCase()).indexOf((keywords[i]).toUpperCase()) == -1) {
509 theme: \
'default'.$moreselect2theme.
'\',
510 containerCssClass: \
':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
511 selectionCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
512 dropdownCssClass: \'ui-dialog\',
513 templateResult: function (data, container) { /* Format visible output into combo list */
514 /* Code to add class of origin OPTION propagated to the new select2 <li> tag */
515 if (data.element) { $(container).addClass($(data.element).attr("class")); }
516 //console.log("data html is "+$(data.element).attr("data-html"));
517 if (data.id == '.((int) $idforemptyvalue).
' && $(data.element).attr("data-html") == undefined) {
520 if ($(data.element).attr("data-html") != undefined) {
521 /* If property html set, we decode html entities and use this. */
522 /* Note that HTML content must have been sanitized from js with dol_escape_htmltag(xxx, 0, 0, \'\', 0, 1) when building the select option. */
523 if (typeof htmlEntityDecodeJs === "function") {
524 return htmlEntityDecodeJs($(data.element).attr("data-html"));
529 templateSelection: function (selection) { /* Format visible output of selected value */
530 if (selection.id == '.((int) $idforemptyvalue).
') return \'<span class="placeholder">\'+selection.text+\'</span>\';
531 return selection.text;
533 escapeMarkup: function(markup) {
538 $msg .=
'.select2(\'focus\')';
543 $msg .=
"</script>\n";
563 if (is_array($events) && count($events)) {
564 $out =
'<!-- JS code to manage event for id = ' . $htmlname .
' -->
566 $(document).ready(function () {
567 jQuery("#'.$htmlname.
'").change(function () {
568 var obj = '.json_encode($events) .
';
569 $.each(obj, function(key,values) {
570 if (values.method.length) {
571 runJsCodeForEvent'.$htmlname.
'(values);
575 function runJsCodeForEvent'.$htmlname.
'(obj) {
576 var id = $("#'.$htmlname.
'").val();
577 var method = obj.method;
579 var htmlname = obj.htmlname;
580 var showempty = obj.showempty;
581 console.log("Run runJsCodeForEvent-'.$htmlname.
' from ajax_combobox id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
590 $.each(obj.params, function(key,action) {
592 var num = response.num;
594 $("#" + key).removeAttr(action);
596 $("#" + key).attr(action, action);
601 console.log("Replace HTML content of select#"+htmlname);
602 $("select#" + htmlname).html(response.value);
604 var selecthtml_str = response.value; /* response.value is the HTML string with list of options */
605 var selecthtml_dom=$.parseHTML(selecthtml_str);
606 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
607 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
610 $("#inputautocomplete"+htmlname).val("");
612 $("select#" + htmlname).change(); /* Trigger event change */
641 function ajax_constantonoff($code, $input = array(), $entity =
null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0, $setzeroinsteadofdel = 0, $suffix =
'', $mode =
'', $morecss =
'inline-block')
643 global $conf, $langs, $user;
645 $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
646 if (!isset($input)) {
650 if (empty($conf->use_javascript_ajax) || $forcenoajax) {
651 if (empty($conf->global->$code)) {
652 $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>';
654 $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>';
657 $out =
"\n<!-- Ajax code to switch constant ".$code.
" -->".
'
659 $(document).ready(function() {
660 var input = '.json_encode($input).
';
661 var url = \''.DOL_URL_ROOT.
'/core/ajax/constantonoff.php\';
663 var entity = \
''.dol_escape_js($entity).
'\';
664 var strict = \
''.dol_escape_js($strict).
'\';
665 var userid = \
''.dol_escape_js($user->id).
'\';
666 var yesButton = \
''.dol_escape_js($langs->transnoentities(
"Yes")).
'\';
667 var noButton = \
''.dol_escape_js($langs->transnoentities(
"No")).
'\';
668 var token = \
''.currentToken().
'\';
671 $(
"#set_" +
code).click(
function() {
672 if (input.alert && input.alert.set) {
673 if (input.alert.set.yesButton) yesButton = input.alert.set.yesButton;
674 if (input.alert.set.noButton) noButton = input.alert.set.noButton;
675 confirmConstantAction(
"set", url,
code, input, input.alert.set, entity, yesButton, noButton, strict, userid, token);
677 setConstant(url,
code, input, entity, 0,
'.((int) $forcereload).', userid, token);
682 $(
"#del_" +
code).click(
function() {
683 if (input.alert && input.alert.del) {
684 if (input.alert.del.yesButton) yesButton = input.alert.del.yesButton;
685 if (input.alert.del.noButton) noButton = input.alert.del.noButton;
686 confirmConstantAction(
"del", url,
code, input, input.alert.del, entity, yesButton, noButton, strict, userid, token);
688 if (empty($setzeroinsteadofdel)) {
689 $out .= ' delConstant(url,
code, input, entity, 0,
'.((int) $forcereload).', userid, token);
';
691 $out .= ' setConstant(url,
code, input, entity, 0,
'.((int) $forcereload).', userid, token, 0);
';
698 $out .= '<div
id=
"confirm_'.$code.'" title=
"" style=
"display: none;"></div>
';
699 $out .= '<span
id=
"set_'.$code.'" class=
"valignmiddle inline-block linkobject '.(!empty($conf->global->$code) ? 'hideobject' : '').'">
'.($revertonoff ? img_picto($langs->trans("Enabled"), 'switch_on
', '', false, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Disabled"), 'switch_off
', '', false, 0, 0, '', '', $marginleftonlyshort)).'</span>
';
700 $out .= '<span
id=
"del_'.$code.'" class=
"valignmiddle inline-block linkobject '.(!empty($conf->global->$code) ? '' : 'hideobject').'">
'.($revertonoff ? img_picto($langs->trans("Disabled"), 'switch_off
'.$suffix, '', false, 0, 0, '', '', $marginleftonlyshort) : img_picto($langs->trans("Enabled"), 'switch_on
'.$suffix, '', false, 0, 0, '', '', $marginleftonlyshort)).'</span>
';
722 function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array(), $morecss = '', $htmlname = '', $forcenojs = 0)
724 global $conf, $langs;
726 if (empty($htmlname)) {
729 //var_dump($object->module); var_dump($object->element);
733 if (!empty($conf->use_javascript_ajax)) {
736 var input =
'.json_encode($input).';
739 $(
"#set_'.$htmlname.'_'.$object->id.'").click(
function() {
740 console.log(
"Click managed by ajax_object_onoff");
741 $.get(
"'.DOL_URL_ROOT.'/core/ajax/objectonoff.php", {
743 field: \''.dol_escape_js($field).
'\',
746 id: \
''.((int)
$object->id).
'\',
747 token: \
''.currentToken().
'\'
750 $(
"#set_'.$htmlname.'_'.$object->id.'").hide();
751 $(
"#del_'.$htmlname.'_'.$object->id.'").show();
753 if (input.disabled && input.disabled.length > 0) {
754 $.each(input.disabled,
function(key,value) {
755 $(
"#" + value).removeAttr(
"disabled");
756 if ($(
"#" + value).hasClass(
"butActionRefused") ==
true) {
757 $(
"#" + value).removeClass(
"butActionRefused");
758 $(
"#" + value).addClass(
"butAction");
762 }
else if (input.showhide && input.showhide.length > 0) {
763 $.each(input.showhide,
function(key,value) {
764 $(
"#" + value).show();
771 $(
"#del_'.$htmlname.'_'.$object->id.'").click(
function() {
772 console.log(
"Click managed by ajax_object_onoff");
773 $.get(
"'.DOL_URL_ROOT.'/core/ajax/objectonoff.php", {
775 field: \''.dol_escape_js($field).
'\',
778 id: \
''.((int)
$object->id).
'\',
779 token: \
''.currentToken().
'\'
782 $(
"#del_'.$htmlname.'_'.$object->id.'").hide();
783 $(
"#set_'.$htmlname.'_'.$object->id.'").show();
785 if (input.disabled && input.disabled.length > 0) {
786 $.each(input.disabled,
function(key,value) {
787 $(
"#" + value).prop(
"disabled",
true);
788 if ($(
"#" + value).hasClass(
"butAction") ==
true) {
789 $(
"#" + value).removeClass(
"butAction");
790 $(
"#" + value).addClass(
"butActionRefused");
794 }
else if (input.showhide && input.showhide.length > 0) {
795 $.each(input.showhide,
function(key,value) {
796 $(
"#" + value).hide();
805 $switchon = 'switch_on
';
806 $switchoff = 'switch_off
';
809 $tmparray = explode(':
', $text_on);
810 if (!empty($tmparray[1])) {
811 $text_on = $tmparray[0];
812 $switchon = $tmparray[1];
813 if (!empty($tmparray[2])) {
814 $cssswitchon = $tmparray[2];
817 $tmparray = explode(':
', $text_off);
818 if (!empty($tmparray[1])) {
819 $text_off = $tmparray[0];
820 $switchoff = $tmparray[1];
821 if (!empty($tmparray[2])) {
822 $cssswitchoff = $tmparray[2];
826 if (empty($conf->use_javascript_ajax) || $forcenojs) {
827 $out .= '<a
id=
"set_'.$htmlname.'_'.$object->id.'" class=
"linkobject '.($object->$code == 1 ? 'hideobject' : '').($morecss ? ' '.$morecss : '').'" href=
"'.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).'">
'.img_picto($langs->trans($text_off), $switchoff, '', false, 0, 0, '', $cssswitchoff).'</a>
';
828 $out .= '<a
id=
"del_'.$htmlname.'_'.$object->id.'" class=
"linkobject '.($object->$code == 1 ? '' : 'hideobject').($morecss ? ' '.$morecss : '').'" href=
"'.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).'">
'.img_picto($langs->trans($text_on), $switchon, '', false, 0, 0, '', $cssswitchon).'</a>
';
830 $out .= '<span
id=
"set_'.$htmlname.'_'.$object->id.'" class=
"linkobject '.($object->$code == 1 ? 'hideobject' : '').($morecss ? ' '.$morecss : '').'">
'.img_picto($langs->trans($text_off), $switchoff, '', false, 0, 0, '', $cssswitchoff).'</span>
';
831 $out .= '<span
id=
"del_'.$htmlname.'_'.$object->id.'" class=
"linkobject '.($object->$code == 1 ? '' : 'hideobject').($morecss ? ' '.$morecss : '').'">
'.img_picto($langs->trans($text_on), $switchon, '', false, 0, 0, '', $cssswitchon).'</span>
';
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_dialog($title, $message, $w=350, $h=150)
Show an ajax dialog.
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 ...
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='inline-block')
On/off button for constant.
ajax_event($htmlname, $events)
Add event management script.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
print *****$script_file(".$version.") pid code
1: frais de port 2: ecotaxe 3: option line (when qty = 0)