<?
/*
Autor: Lic. Carlos Alberto Vaca Coronado
Version: 3.2.0
*/
require "conexion/conectar.php";

$conexion = new CONDB();
$conexion->conectar();

if(isset($_REQUEST['buscar'])){
	
	$id=$_REQUEST["id"];
	$buscar=$_REQUEST["buscar"];
	$elementoattr=$_REQUEST["elemento"];
	$upload=$_REQUEST["upload"];
	$query="select buscar from configxml where id='$id'";
	
	$rquery = mysqli_query($conexion->CONEXION,$query);
	
	if(mysqli_num_rows($rquery) > 0){
		$query="update configxml set buscar='$buscar', elementoattr='$elementoattr', upload='$upload' where id='$id'";

		$rquery=mysqli_query($conexion->CONEXION,$query);

	}else{
		$query="insert into configxml set elementoattr='$elementoattr', upload='$upload', buscar='$buscar'";

		$rquery=mysqli_query($conexion->CONEXION,$query);

	}
	
	if(mysqli_errno($conexion->CONEXION) > 0)
		echo "Ocurrio un error al salvar los datos";
	else{
		if($_POST['reloadGridAfterSave'] != ""){
			if($_POST['valLiga'] != ""){
				$valLiga = explode("|",$_POST['valLiga']);
				$ids = "";
				for($i = 0; $i < count($valLiga); $i++){
						$ids.=",'".$valLiga[$i]."'";
				}
			}
			?><script>tools('<?=$_POST['reloadGridAfterSave']?>'<?=$ids?>); $j_6('#closeModal').click();</script><?
		}
	}
}

?>