Update ajax.lib.php

This commit is contained in:
Frédéric FRANCE 2014-10-18 15:48:59 +02:00
parent 2466a55193
commit 96aee6eed4

View File

@ -460,21 +460,18 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0,
} }
/** /**
* On/off button for product tosell or tobuy * On/off button for object
* *
* @param int $id Id product to set * @param int $object Object to set
* @param string $code Name of constant : status or status_buy * @param string $code Name of constant : status or status_buy for product by example
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
* @return void * @return void
*/ */
function ajax_productonoff($id, $code, $input=array()) function ajax_object_onoff($object, $code, $input=array())
{ {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
global $conf, $langs, $db; global $conf, $langs, $db;
$object = new Product($db);
$object->fetch($id);
$out= '<script type="text/javascript"> $out= '<script type="text/javascript">
$(function() { $(function() {
var input = '.json_encode($input).'; var input = '.json_encode($input).';
@ -484,7 +481,7 @@ function ajax_productonoff($id, $code, $input=array())
$.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: \''.$id.'\' id: \''.$object->id.'\'
}, },
function() { function() {
$("#set_'.$code.'").hide(); $("#set_'.$code.'").hide();
@ -512,7 +509,7 @@ function ajax_productonoff($id, $code, $input=array())
$.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: \''.$id.'\' id: \''.$object->id.'\'
}, },
function() { function() {
$("#del_'.$code.'").hide(); $("#del_'.$code.'").hide();