<?
	include("../../conexion/class-sb-conexion.php");

//	Autorización
	$id_empresa = $_SESSION['ss_empresa'];
	$id_user = $_SESSION['ss_user'];
	$id_autoriza=76;
	include("../../../conex.php");
	include("../../../autoriza.php");
	
			switch($evento){
			case "inst":
				//$id_autoriza=76;
				//include("../../../conex.php");
				//include("../../../seguridad/autoriza.php");
				if ($grabar==0)  
				{
				?>
				<script>
					alert ("No Autorizado");
				</script>
				<?
				exit();
				}
			break;
			case "upda":
				//$id_autoriza=76;
				//include("../../../conex.php");
				//include("../../../seguridad/autoriza.php");
				if ($grabar==0)  
				{
				?>
				<script>
					alert ("No Autorizado");
				</script>
				<?
				exit();
				}
			break;
			case "dele":
				//$id_autoriza=76;
				//include("../../../conex.php");
				//include("../../../seguridad/autoriza.php");
				if ($eliminar==0)  
				{
				?>
				<script>
					alert ("No Autorizado");
				</script>
				<?
				exit();
				}
			break;
		default:
			print ("Error");
		break;
		}

	
	
	
	
	$dbx = new sb_mysql();
	//1
	$campos_update="";
	foreach( $campo1 as $key => $value ) {
  	$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	if(str_replace("'","",$key)=='Codigo_Renta'){
		$condicion=$value;
	}
	}
	$Query_update="update sb_impuesto_renta 
					set ".rtrim($campos_update,",").
					" where Codigo_Renta='".$condicion."'";
	$consulta = $dbx->consulta_free($Query_update);
	echo  $Query_update."<br>";
	
	//2
	$campos_update="";
	foreach( $campo2 as $key => $value ) {
  	$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	if(str_replace("'","",$key)=='Codigo_Renta'){
		$condicion=$value;
	}
	}
	$Query_update="update sb_impuesto_renta 
					set ".rtrim($campos_update,",").
					" where Codigo_Renta='".$condicion."'";
	$consulta = $dbx->consulta_free($Query_update);
	echo  $Query_update."<br>";
	
	//3
	$campos_update="";
	foreach( $campo3 as $key => $value ) {
  	$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	if(str_replace("'","",$key)=='Codigo_Renta'){
		$condicion=$value;
	}
	}
	$Query_update="update sb_impuesto_renta 
					set ".rtrim($campos_update,",").
					" where Codigo_Renta='".$condicion."'";
	$consulta = $dbx->consulta_free($Query_update);
	echo  $Query_update."<br>";
	
	//4
	$campos_update="";
	foreach( $campo4 as $key => $value ) {
  	$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	if(str_replace("'","",$key)=='Codigo_Renta'){
		$condicion=$value;
	}
	}
	$Query_update="update sb_impuesto_renta 
					set ".rtrim($campos_update,",").
					" where Codigo_Renta='".$condicion."'";
	$consulta = $dbx->consulta_free($Query_update);
	echo  $Query_update."<br>";
	
	//5
	$campos_update="";
	foreach( $campo5 as $key => $value ) {
  	$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	if(str_replace("'","",$key)=='Codigo_Renta'){
		$condicion=$value;
	}
	}
	$Query_update="update sb_impuesto_renta 
					set ".rtrim($campos_update,",").
					" where Codigo_Renta='".$condicion."'";
	$consulta = $dbx->consulta_free($Query_update);
	echo  $Query_update."<br>";
	
	//6
	$campos_update="";
	foreach( $campo6 as $key => $value ) {
  	$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	if(str_replace("'","",$key)=='Codigo_Renta'){
		$condicion=$value;
	}
	}
	$Query_update="update sb_impuesto_renta 
					set ".rtrim($campos_update,",").
					" where Codigo_Renta='".$condicion."'";
	$consulta = $dbx->consulta_free($Query_update);
	echo  $Query_update."<br>";
	
	//7
	$campos_update="";
	foreach( $campo7 as $key => $value ) {
  	$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	if(str_replace("'","",$key)=='Codigo_Renta'){
		$condicion=$value;
	}
	}
	$Query_update="update sb_impuesto_renta 
					set ".rtrim($campos_update,",").
					" where Codigo_Renta='".$condicion."'";
	$consulta = $dbx->consulta_free($Query_update);
	echo  $Query_update."<br>";
	
	//8
	$campos_update="";
	foreach( $campo8 as $key => $value ) {
  	$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	if(str_replace("'","",$key)=='Codigo_Renta'){
		$condicion=$value;
	}
	}
	$Query_update="update sb_impuesto_renta 
					set ".rtrim($campos_update,",").
					" where Codigo_Renta='".$condicion."'";
	$consulta = $dbx->consulta_free($Query_update);
	echo  $Query_update."<br>";
		
	
?>
<script>
alert("Registros Actualizados");//	window.parent.actualizar();
</script>
 