cIdItem = ''
cIdBodega = ''

IF !EMPTY(oJs.cParam)
	DECLARE aParam [1]
	oApp.explode(oJs.cParam,@aParam,'|')
	cIdItem   = aParam[1]
	cIdBodega = aParam[2]
ENDIF

oStock.l_incluye_pedido = .T.
nStock = 0

IF oApp.ghost_USAR_BODEGA=1
	&&nStock = oStock.StockItem(cIdItem,oJs.cIdBodega)
	
	&&STRTOFILE(oJs.cIdBodega+'!!'+cIdItem,'\stock.txt')
	
	*nStock = oStock.MIB_getStock(oJs.cIdBodega,cIdItem)
	
	IF oApp.sqlexec('SELECT cantidad FROM StockBod WHERE idBodega='+oJs.cIdbodega+' and idItem='+cIdItem,'curExistItemBod')>0
		nStock = curExistItemBod.cantidad
	ENDIF
	
	
ELSE
	&&nStock = oStock.StockItem(cIdItem)

	IF oApp.sqlexec('select stock from stock where iditem='+cIdItem,'curStock')>0
		nStock =  curStock.stock
	ENDIF
	
ENDIF

IF oApp.lGhostLocal 
	oApp.sqlexec("update ghost.commander set estado=1,respuesta="+TRANSFORM(nStock)+" WHERE id="+oJs.cIdCmd)
ELSE
	cCmd = 'json/set_respuesta.php?id='+oJs.cIdCmd+'&resp='+TRANSFORM(nStock)
	oApp.runLink(cCmd)
ENDIF
