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

//	Autorización
	$id_empresa = $_SESSION['ss_empresa'];
	$id_user = $_SESSION['ss_user'];
	$id_autoriza=73;
	include("../../../conex.php");
	include("../../../autoriza.php");

		switch($evento){
			case "inst":
				//$id_autoriza=73;
				//include("../../../conex.php");
				//include("../../../seguridad/autoriza.php");
				if ($grabar==0)  
				{
				?>
				<script>
					alert ("No Autorizado");
				</script>
				<?
				exit();
				}
			break;
			case "upda":
				//$id_autoriza=73;
				//include("../../../conex.php");
				//include("../../../seguridad/autoriza.php");
				if ($grabar==0)  
				{
				?>
				<script>
					alert ("No Autorizado");
				</script>
				<?
				exit();
				}
			break;
			case "dele":
				//$id_autoriza=73;
				//include("../../../conex.php");
				//include("../../../seguridad/autoriza.php");
				if ($eliminar==0)  
				{
				?>
				<script>
					alert ("No Autorizado");
				</script>
				<?
				exit();
				}
			break;
		default:
			print ("Error");
		break;
		}




	$campos_insert="";
	foreach( $campo as $key => $value ) {
    	$campos_insert=$campos_insert."".$key.",";
		$campos_update=$campos_update.str_replace("'","",$key)."='".$value."',";	
	}
	$Query_insert="insert into sb_empresas_lista  
			   	 (".rtrim(str_replace("'","",$campos_insert),",").")  values ('".implode('\',\'',$campo)."')";
	$Query_update="update sb_empresas_lista set ".rtrim($campos_update,",");

	switch($evento){
		case "inst":
			$dbx = new sb_mysql();
			$consulta = $dbx->consulta_free($Query_insert);
			echo $campos_insert;
			//echo $Query_update." where Codigo_HabDes=".$id;
		break;
		case "upda":
			$dbx = new sb_mysql();
			$consulta = $dbx->consulta_free($Query_update." where Codigo_Empresa=".$id);
			//echo $Query_update." where Codigo_HabDes=".$id;
		break;
		case "dele":
			print ("delete");
		break;
		default:
			print ("Error");
		break;
		}
?>

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