<?php	
function seleccionar_proveedor_lista($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Proveedor('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			$objResponse->assign("xcod", "value", "");
			}
		$objResponse->assign("xnom", "value", $retorna);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("xnom", "value", "");
		return $objResponse;
		}	
	}
	
function seleccionar_gasto_asignacion($ide, $varCod, $varNom, $varAbr, $varCos, $varIde, $varNum, $varForm=NULL) {
	$objResponse = new xajaxResponse();
	if($ide<>"") {
		//Verificamos si Ya esta Agregado el Item seleccionado
		$varExiste = "NO";
		$varCant = $varForm["num3"];
		for($i=0; $i<$varCant;$i++) {
			if($ide==$varForm[$varIde][$i] && $i+1 <> $varNum) {
				$varExiste = "SI";
				}
			}
		if($varExiste=="NO") {		
			$var = VarServer("MYSQLI");
			$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
			$obj->AbrirConexion();
			$sql = "call spQuery_Lista_Gasto('$ide','','');";
			$rs = $obj->Query($sql);
			$obj->CerrarConexion();
			$Fila = $obj->FetchArray($rs);
			if($obj->NumFilas($rs)>0) {
				$objResponse->assign($varNom, "value", utf8_encode($Fila[1]));
				$objResponse->assign($varAbr, "value", utf8_encode($Fila[2]));
				$objResponse->assign($varCos, "value", number_format($Fila[3],2,".",","));
				}
			else {
				$objResponse->assign($varCod, "value", "");
				$objResponse->assign($varNom, "value", "NO EXISTE");
				$objResponse->assign($varAbr, "value", "");
				$objResponse->assign($varCos, "value", "");
				}
			}
		else {
			$objResponse->assign($varCod, "value", "");
			$objResponse->assign($varNom, "value", "EL CODIGO ".$ide." YA ESTA AGREGADO");
			$objResponse->assign($varDni, "value", "");
			$objResponse->assign($varCos, "value", "");
			}
		}
	else {
		$objResponse->assign($varCod, "value", "");
		$objResponse->assign($varNom, "value", "");
		$objResponse->assign($varAbr, "value", "");
		$objResponse->assign($varCos, "value", "");		
		}
	return $objResponse;
	}


function seleccionar_repartidor_asignacion($ide, $varCod, $varNom, $varDni, $varCos, $varIde, $varNum, $varForm=NULL) {
	$objResponse = new xajaxResponse();
	if($ide<>"") {
		//Verificamos si Ya esta Agregado el Item seleccionado
		$varExiste = "NO";
		$varCant = $varForm["num2"];
		for($i=0; $i<$varCant;$i++) {
			if($ide==$varForm[$varIde][$i] && $i+1 <> $varNum) {
				$varExiste = "SI";
				}
			}
		if($varExiste=="NO") {		
			$var = VarServer("MYSQLI");
			$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
			$obj->AbrirConexion();
			$sql = "call spQuery_Lista_Repartidor('$ide','','');";
			$rs = $obj->Query($sql);
			$obj->CerrarConexion();
			$Fila = $obj->FetchArray($rs);
			if($obj->NumFilas($rs)>0) {
				$objResponse->assign($varNom, "value", utf8_encode($Fila[1]));
				$objResponse->assign($varDni, "value", utf8_encode($Fila[2]));
				$objResponse->assign($varCos, "value", number_format($Fila[3],2,".",","));
				}
			else {
				$objResponse->assign($varCod, "value", "");
				$objResponse->assign($varNom, "value", "NO EXISTE");
				$objResponse->assign($varDni, "value", "");
				$objResponse->assign($varCos, "value", "");
				}
			}
		else {
			$objResponse->assign($varCod, "value", "");
			$objResponse->assign($varNom, "value", "EL CODIGO ".$ide." YA ESTA AGREGADO");
			$objResponse->assign($varDni, "value", "");
			$objResponse->assign($varCos, "value", "");
			}
		}
	else {
		$objResponse->assign($varCod, "value", "");
		$objResponse->assign($varNom, "value", "");
		$objResponse->assign($varDni, "value", "");
		$objResponse->assign($varCos, "value", "");		
		}
	return $objResponse;
	}

function seleccionar_conductor($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Conductor('$ide','','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		
		$objResponse = new xajaxResponse();
		
		if($obj->NumFilas($rs)>0) {
			$objResponse->assign("cnom", "value", utf8_encode($Fila[1]));
			$objResponse->assign("ccos", "value", number_format($Fila[3],2,".",","));
			}
		else {
			$objResponse->assign("cnom", "value", "NO EXISTE");
			$objResponse->assign("ccod", "value", "");
			$objResponse->assign("ccos", "value", "");
			}		
		return $objResponse;		
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("cnom", "value", "");
		$objResponse->assign("ccos", "value", "");
		return $objResponse;
		}
	}

function seleccionar_vehiculo($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Vehiculo('$ide','','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		
		$objResponse = new xajaxResponse();
		
		if($obj->NumFilas($rs)>0) {
			$objResponse->assign("vnom", "value", utf8_encode($Fila[2]." : ".$Fila[1]));
			$objResponse->assign("vcos", "value", number_format($Fila[3],2,".",","));
			}
		else {
			$objResponse->assign("vnom", "value", "NO EXISTE");
			$objResponse->assign("vcod", "value", "");
			$objResponse->assign("vcos", "value", "");
			}		
		return $objResponse;		
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("vnom", "value", "");
		$objResponse->assign("vcos", "value", "");
		return $objResponse;
		}
	}

function comboComisionLis($varAnio, $varMes, $varProv){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Combo_Lista_Precios_Comision('$varAnio','$varMes', '$varProv');";	
	$comboTip = $obj->SetCombo("lis", $sql, NULL, "250", NULL, "--[[SELECCIONAR]]--");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divTip","innerHTML",utf8_encode($comboTip));
	return $respuestaXajax;
	}
function seleccionar_cliente_bonif($ide, $varCod, $varNom) {	
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Cliente('$ide','','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		
		$objResponse = new xajaxResponse();
		
		if($obj->NumFilas($rs)>0) {
			$objResponse->assign($varNom, "value", utf8_encode($Fila["CLIENTE"]));
			}
		else {
			$objResponse->assign($varCod, "value", "");
			$objResponse->assign($varNom, "value", "NO EXISTE");
			}
		
		return $objResponse;		
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign($varCod, "value", "");
		$objResponse->assign($varNom, "value", "");
		return $objResponse;
		}		
	}

// 16/01/2012
function seleccionar_producto_bonif($ide, $varCod, $varNom, $varUMe) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Producto('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			$objResponse->assign($varCod, "value", "");
			$objResponse->assign($varNom, "value", "");
			$objResponse->assign($varUMe, "value", "");
			}
		$objResponse->assign($varNom, "value", $retorna);
		$objResponse->assign($varUMe, "value", $Fila["UM_VENTA"]);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign($varNom, "value", "");
		$objResponse->assign($varUMe, "value", "");
		return $objResponse;
		}	
	}
	
// Combo Seleccion de Ruta para Bonificaciones
function comboSeleccion($tipo){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	if($tipo=="R") {
		$sql = "call spQuery_Lista_Ruta('','%');";	
		$combo = $obj->SetCombo("sel", $sql, NULL, "280", NULL);	
		}
	elseif($tipo=="P") {
		$sql = "call spQuery_Combo_Lista_Precios();";	
		$combo = $obj->SetCombo("lp", $sql, NULL, "280", NULL);	
		}
	else {
		$combo="";
		}
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divSel","innerHTML",utf8_encode($combo));	
	return $respuestaXajax;
	}
	
function comboMesComision($varAnio){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_ComboMesComision('$varAnio');";	
	$combo = $obj->SetCombo("mes", $sql, NULL, "160", NULL, "--[[ MES ]]--");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divMes","innerHTML",$combo);	
	return $respuestaXajax;
	}
	
function comboMesMetas($varAnio){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_ComboMesMetas('$varAnio');";	
	$combo = $obj->SetCombo("mes", $sql, NULL, "160", NULL, "--[[ MES ]]--");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divMes","innerHTML",$combo);	
	return $respuestaXajax;
	}		

function comboMetasPro($varAnio, $varMes, $varVen){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Combo_Proveedor_Meta('$varAnio','$varMes', '$varVen');";	
	$comboTip = $obj->SetCombo("pro", $sql, NULL, "250", NULL, "--[[SELECCIONAR]]--", NULL, "NO");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divPro","innerHTML",utf8_encode($comboTip));
	return $respuestaXajax;
	}
	
function comboComisionTip($varAnio, $varMes, $varProv){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Combo_Tipo_Vendedor_Comision('$varAnio','$varMes', '$varProv');";	
	$comboTip = $obj->SetCombo("tip", $sql, NULL, "250", NULL, "--[[SELECCIONAR]]--");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divTip","innerHTML",utf8_encode($comboTip));
	return $respuestaXajax;
	}
	
function comboNivel2($varTip){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "select id_menu, nombre from _sys_menu where length(id_menu)=4 and substring(id_menu,1,2)=substring('".$varTip."',1,2);";
	$combo = $obj->SetCombo("niv2", $sql, NULL, "300", NULL, " --[[ SELECCIONAR ]]-- ");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divFam","innerHTML",utf8_encode($combo));	
	return $respuestaXajax;
	}
	
function comboFamilia($varTip){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Combo_Producto_Familia('$varTip');";	
	$combo = $obj->SetCombo("fam", $sql, NULL, "250", "xajax_comboSubFamilia(this.value)", " --[[ SELECCIONAR ]]-- ", NULL, "SI");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divFam","innerHTML",utf8_encode($combo));	
	return $respuestaXajax;
	}

function comboSubFamilia($varTip){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Combo_Producto_Sub_Familia('$varTip');";	
	$combo = $obj->SetCombo("sub", $sql, NULL, "250", NULL, " --[[ SELECCIONAR ]]-- ", NULL, "NO");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divSub","innerHTML",utf8_encode($combo));	
	return $respuestaXajax;
	}
	
function comboProv($varDep){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Lista_Ubigeo_Pro('$varDep');";	
	$combo = $obj->SetCombo("pro", $sql, NULL, "150", "xajax_comboDist(this.value)", " --[[ SELECCIONAR ]]-- ", NULL, "NO");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divProv","innerHTML",utf8_encode($combo));	
	return $respuestaXajax;
	}
	
function comboDist($varPro){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Lista_Ubigeo_Dis('$varPro');";	
	$combo = $obj->SetCombo("dis", $sql, NULL, "150", NULL, " --[[ SELECCIONAR ]]-- ", NULL, "NO");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divDist","innerHTML",utf8_encode($combo));	
	return $respuestaXajax;
	}

function comboModulo($varRuta){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Combo_Modulo('$varRuta');";	
	$combo = $obj->SetCombo("mod", $sql, NULL, "280", NULL, " --[[ SELECCIONAR ]]-- ", NULL, "NO");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divMod","innerHTML",utf8_encode($combo));	
	return $respuestaXajax;
	}

function seleccionar_unidad_medida_factor($ide, $padre) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Unidad_Medida_Factor('$ide','','$padre');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		if($obj->NumFilas($rs)>0) $retorna = $Fila[1];
		else $retorna = "NO EXISTE";		
		}
	else $retorna = "";
	
	$objResponse = new xajaxResponse();
	if ($retorna=="NO EXISTE") {
		$objResponse->assign("ucod", "value", "");
		}
	$objResponse->assign("unom", "value", $retorna);
	
	
	return $objResponse;		
	}
function seleccionar_lista_precios($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Precios('$ide','', NULL, NULL);";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		if($obj->NumFilas($rs)>0) $retorna = $Fila[1];
		else $retorna = "NO EXISTE";		
		}
	else $retorna = "";
	
	$objResponse = new xajaxResponse();
	if ($retorna=="NO EXISTE") {
		$objResponse->assign("lcod", "value", "");
		}
	$objResponse->assign("lnom", "value", $retorna);
	
	
	return $objResponse;		
	}
	
function comboUM($varUM){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_Combo_UM('$varUM');";
	$varUMV = $obj->SetCombo("umv", $sql, NULL, "250", NULL, NULL);
	$varUMS = $obj->SetCombo("ums", $sql, NULL, "250", NULL, NULL);	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divUMV", "innerHTML", $varUMV);
	$respuestaXajax->assign("divUMS", "innerHTML", $varUMS);
	return $respuestaXajax;
	}

function comboMes($varAnio){
	$var = VarServer("MYSQLI");
	$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
	$sql = "call spQuery_ComboMes('$varAnio');";	
	$combo = $obj->SetCombo("mes", $sql, NULL, "160", NULL, "--[[ MES ]]--");	
	$respuestaXajax = new xajaxResponse();
	$respuestaXajax->assign("divMes","innerHTML",$combo);	
	return $respuestaXajax;
	}

function seleccionar_tipo($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Tipo('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		if($obj->NumFilas($rs)>0) $retorna = $Fila[1];
		else $retorna = "NO EXISTE";		
		}
	else $retorna = "";
	
	$objResponse = new xajaxResponse();
	$objResponse->assign("tnom", "value", $retorna);
	return $objResponse;		
	}
	
function seleccionar_material($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Material('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		if($obj->NumFilas($rs)>0) $retorna = $Fila[1];
		else $retorna = "NO EXISTE";		
		}
	else $retorna = "";
	
	$objResponse = new xajaxResponse();
	$objResponse->assign("xnom", "value", $retorna);
	return $objResponse;		
	}

function seleccionar_marca($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Marca('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		if($obj->NumFilas($rs)>0) $retorna = $Fila[1];
		else $retorna = "NO EXISTE";		
		}
	else $retorna = "";
	
	$objResponse = new xajaxResponse();
	$objResponse->assign("mnom", "value", $retorna);
	return $objResponse;		
	}


function seleccionar_ruta($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Ruta('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			$objResponse->assign("rnom", "value", "");
			$objResponse->assign("mcod", "value", "");
			$objResponse->assign("mnom", "value", "");
			}
		$objResponse->assign("rnom", "value", $retorna);
		$objResponse->assign("mcod", "value", "");
		$objResponse->assign("mnom", "value", "");
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("rnom", "value", "");
		$objResponse->assign("mcod", "value", "");
		$objResponse->assign("mnom", "value", "");
		return $objResponse;
		}
	}
		
function seleccionar_producto_listap($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Producto('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			$objResponse->assign("pcod", "value", "");
			$objResponse->assign("pum", "value", "");
			}
		$objResponse->assign("pnom", "value", $retorna);
		$objResponse->assign("pum", "value", $Fila["UM_VENTA"]);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("pnom", "value", "");
		$objResponse->assign("pum", "value", "");
		return $objResponse;
		}	
	}

function seleccionar_articulo($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Producto('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			$objResponse->assign("acod", "value", "");
			$objResponse->assign("aum", "value", "");
			}
		$objResponse->assign("anom", "value", $retorna);
		$objResponse->assign("aum", "value", $Fila["UM_VENTA"]);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("anom", "value", "");
		$objResponse->assign("aum", "value", "");
		return $objResponse;
		}	
	}

function seleccionar_proveedor($ide) {
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Proveedor('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			$objResponse->assign("pcod", "value", "");
			}
		$objResponse->assign("pnom", "value", $retorna);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("pnom", "value", "");
		return $objResponse;
		}	
	}

function seleccionar_tipo_docventa($ide) {	
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Tipo_DocVenta('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			//$objResponse1 = new xajaxResponse();
			$objResponse->assign("tcod", "value", "");
			//return $objResponse1;
			}
		$objResponse->assign("tnom", "value", $retorna);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("tnom", "value", "");
		return $objResponse;
		}
	}
		
function seleccionar_tipo_docpago($ide) {	
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Tipo_DocPago('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			//$objResponse1 = new xajaxResponse();
			$objResponse->assign("tcod", "value", "");
			//return $objResponse1;
			}
		$objResponse->assign("tnom", "value", $retorna);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("tnom", "value", "");
		return $objResponse;
		}
	}


function seleccionar_tipo_vendedor($ide) {	
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Tipo_Vendedor('$ide','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			$objResponse->assign("tcod", "value", "");
			}
		$objResponse->assign("tnom", "value", $retorna);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("tnom", "value", "");
		return $objResponse;
		}
	}
	
function seleccionar_vendedor($ide) {	
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Vendedor('$ide','','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		
		$objResponse = new xajaxResponse();
		if($obj->NumFilas($rs)>0) $retorna = utf8_encode($Fila[1]);
		else {
			$retorna = "NO EXISTE";		
			$objResponse->assign("vcod", "value", "");
			}
		$objResponse->assign("vnom", "value", $retorna);
		return $objResponse;
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("vnom", "value", "");
		return $objResponse;
		}
	}

function seleccionar_cliente($ide) {	
	if($ide<>"") {
		$var = VarServer("MYSQLI");
		$obj = new clsConexion($var[0],$var[1],$var[2],$var[3],$var[4]);
		$obj->AbrirConexion();
		$sql = "call spQuery_Lista_Cliente('$ide','','');";
		$rs = $obj->Query($sql);
		$obj->CerrarConexion();
		$Fila = $obj->FetchArray($rs);
		
		$objResponse = new xajaxResponse();
		
		if($obj->NumFilas($rs)>0) {
			$objResponse->assign("cnom", "value", utf8_encode($Fila["CLIENTE"]));
			$objResponse->assign("txtdir", "value", utf8_encode($Fila["DIRECCION"]));
			$objResponse->assign("dni", "value", $Fila["DNI"]);
			$objResponse->assign("ruc", "value", $Fila["RUC"]);
			$objResponse->assign("lcod", "value", $Fila["CLIS"]);
			$objResponse->assign("lnom", "value", utf8_encode($Fila["LISTA"]));
			$objResponse->assign("rcod", "value", $Fila["CRUT"]);
			$objResponse->assign("rnom", "value", utf8_encode($Fila["RUTA"]));
			$objResponse->assign("lmin", "value", number_format($Fila["MMIN"],"2",".",","));
			}
		else {
			$objResponse->assign("cnom", "value", "NO EXISTE");
			$objResponse->assign("ccod", "value", "");
			$objResponse->assign("txtdir", "value", "");
			$objResponse->assign("dni", "value", "");
			$objResponse->assign("ruc", "value", "");
			$objResponse->assign("lcod", "value", "");
			$objResponse->assign("lnom", "value", "");
			$objResponse->assign("rcod", "value", "");
			$objResponse->assign("rnom", "value", "");
			$objResponse->assign("lmin", "value", "");
			}
		
		return $objResponse;		
		}
	else {
		$objResponse = new xajaxResponse();
		$objResponse->assign("cnom", "value", "");
		$objResponse->assign("txtdir", "value", "");
		$objResponse->assign("dni", "value", "");
		$objResponse->assign("ruc", "value", "");
		$objResponse->assign("lcod", "value", "");
		$objResponse->assign("lnom", "value", "");
		$objResponse->assign("rcod", "value", "");
		$objResponse->assign("rnom", "value", "");
		$objResponse->assign("lmin", "value", "");
		return $objResponse;
		}		
	}

?>