Update ajax.lib.php

For use in a list of object
This commit is contained in:
Frédéric FRANCE 2014-10-18 16:32:32 +02:00
parent b80b45c086
commit 2107a61bbe

View File

@ -477,15 +477,15 @@ function ajax_object_onoff($object, $code, $input=array())
var input = '.json_encode($input).'; var input = '.json_encode($input).';
// Set constant // Set constant
$("#set_'.$code.'").click(function() { $("#set_'.$code.'_'.$object->id.'").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", { $.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", {
action: \'set'.$code.'\', action: \'set'.$code.'\',
value: \'1\', value: \'1\',
id: \''.$object->id.'\' id: \''.$object->id.'\'
}, },
function() { function() {
$("#set_'.$code.'").hide(); $("#set_'.$code.'_'.$object->id.'").hide();
$("#del_'.$code.'").show(); $("#del_'.$code.'_'.$object->id.'").show();
// Enable another element // Enable another element
if (input.disabled && input.disabled.length > 0) { if (input.disabled && input.disabled.length > 0) {
$.each(input.disabled, function(key,value) { $.each(input.disabled, function(key,value) {
@ -505,15 +505,15 @@ function ajax_object_onoff($object, $code, $input=array())
}); });
// Del constant // Del constant
$("#del_'.$code.'").click(function() { $("#del_'.$code.'_'.$object->id.'").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", { $.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", {
action: \'set'.$code.'\', action: \'set'.$code.'\',
value: \'0\', value: \'0\',
id: \''.$object->id.'\' id: \''.$object->id.'\'
}, },
function() { function() {
$("#del_'.$code.'").hide(); $("#del_'.$code.'_'.$object->id.'").hide();
$("#set_'.$code.'").show(); $("#set_'.$code.'_'.$object->id.'").show();
// Disable another element // Disable another element
if (input.disabled && input.disabled.length > 0) { if (input.disabled && input.disabled.length > 0) {
$.each(input.disabled, function(key,value) { $.each(input.disabled, function(key,value) {
@ -534,12 +534,12 @@ function ajax_object_onoff($object, $code, $input=array())
}); });
</script>'; </script>';
if ($code=='status') { if ($code=='status') {
$out.= '<span id="set_'.$code.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans("ProductStatusNotOnSell"),'switch_off').'</span>'; $out.= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans("ProductStatusNotOnSell"),'switch_off').'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans("ProductStatusOnSell"),'switch_on').'</span>'; $out.= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans("ProductStatusOnSell"),'switch_on').'</span>';
} }
if ($code=='status_buy') { if ($code=='status_buy') {
$out.= '<span id="set_'.$code.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans("ProductStatusNotOnBuy"),'switch_off').'</span>'; $out.= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans("ProductStatusNotOnBuy"),'switch_off').'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans("ProductStatusOnBuy"),'switch_on').'</span>'; $out.= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans("ProductStatusOnBuy"),'switch_on').'</span>';
} }
return $out; return $out;
} }