<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = 'index.php';
		</script>
		<? 
		exit();
		}
$id_empresa =$_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];

include("../conex.php");

$cont=0;

$sql_bpro = "SELECT * FROM antofagasta_rutas";
$res_bpro = mysql_query($sql_bpro,$enlace);
 
while (mysql_fetch_object ($res_bpro))
	{
	$Id_old = mysql_result($res_bpro, $cont, "Rut_codigo");
	$descripcion = mysql_result($res_bpro, $cont, "Rut_nombre");
	$detalle = mysql_result($res_bpro, $cont, "Rut_descri");
	
	
	$id_bodega = 3;
	$id_empresa = 1;
	
	
	
   	
 ///    graba en nombres
 
 	$sql_bus = "SELECT * FROM zona WHERE Id_old=$Id_old and id_bodega=$id_bodega";

	$con_bus = mysql_query($sql_bus, $enlace);
	if (!mysql_fetch_row($con_bus))
		{
	$esql = "INSERT INTO zona (descripcion, detalle, Id_old, id_bodega, id_empresa)
	VALUES ('$descripcion', '$detalle', $Id_old, $id_bodega, $id_empresa)";

		$consulta = mysql_query($esql,$enlace);
			

   
   }

 
   
  $cont=$cont+1;
  }

	
?>


<script language="javascript" type="text/javascript">
alert ("<?='\nListo Rutas !';?>");
	parent.location.href = 'index.php';
</script>