<?
include("../conexion/class-sb-conexion.php");
	$campos_insert="";
	foreach( $campo as $key => $value ) {
    	$campos_insert=$campos_insert."".$key.",";
		//echo $key."<br>";
		$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	}

	$Query_insert="insert into codigos_contables 
	(".rtrim(str_replace("'","",$campos_insert),",").")  values ('".implode('\',\'',$campo)."')";
	$Query_update="update codigos_contables set ".rtrim($campos_update,",");
    
		switch($evento){
		case "inst":
			$dbx = new sb_mysql();
			$consulta = $dbx->consulta_free($Query_insert);
			echo $Query_insert;
			//echo $Query_update." where Codigo_HabDes=".$id;
		break;
		case "upda":
			$dbx = new sb_mysql();
			//echo $Query_update." where Codigo_Apv=".$id;
			$consulta = $dbx->consulta_free($Query_update." where codigo=".$id);
			echo $Query_update;
			
			//echo $Query_update." where Codigo_HabDes=".$id;
			
		break;
		case "dele":
			print ("delete");
		break;
		default:
			print ("Error");
		break;
		}
?>

     <script>
	window.parent.actualizar();
	 </script>
 