
<?php



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

$cdgart=$_GET["cdgart"];
$cdgbar_xml=$_GET["cdgbar_xml"];
$barras=$_GET["barras"];
$cdgbar=$_GET["cdgbar"];
$uniemp=$_GET["uniemp"];


$borrado=$_GET["borrado"];
$cdgpro=$_GET["cdgpro"];


if ($barras==2){



if ($borrado==0){


$consulta1 ="SELECT CDGBAR2 FROM web_1001 WHERE cdgart='$cdgart' ";
$resultado1 = $mysqli->query($consulta1);
$fila = $resultado1->fetch_array();
$nrs=$fila["CDGBAR2"];
//$nrs = $resultado1->num_rows;

				
				
	if ( $nrs == "") {
	
	
	

		$sel_act1="UPDATE  web_1001 SET CDGBAR2='$cdgbar_xml',cdgpro='$cdgpro'  WHERE cdgart='$cdgart'";	
		 $mysqli->query($sel_act1);	
		 
		 
		 		} else {
				?>
				<script>
				alert("ARTICULO YA TIENE 2DO CODIGO DE BARRAS");
				</script>
				<?php		 
		 
		 
		 }
		 
		 
		 }else {
		 
		 
		 		$sel_act1="UPDATE  web_1001 SET CDGBAR2='$cdgbar',cdgpro='$cdgpro' WHERE cdgart='$cdgart'";
		 		 $mysqli->query($sel_act1);	
		 
		 }
		 
		 

		 

		 
		 
		 
		 
		 
		 
		 

}




else if ($barras==3){


if ($borrado==0){


$consulta1 ="SELECT CDGBAR3 FROM web_1001 WHERE cdgart='$cdgart' ";
$resultado1 = $mysqli->query($consulta1);
$fila = $resultado1->fetch_array();
$nrs=$fila["CDGBAR3"];
//$nrs = $resultado1->num_rows;

				
				
	if ( $nrs == "") {
	
	
	

		$sel_act1="UPDATE  web_1001 SET CDGBAR3='$cdgbar_xml',cdgpro='$cdgpro'  WHERE cdgart='$cdgart'";	
		 $mysqli->query($sel_act1);	
		 
		 
		 		} else {
				?>
				<script>
				alert("ARTICULO YA TIENE 3RO CODIGO DE BARRAS");
				</script>
				<?php		 
		 
		 
		 }
		 
		 
		 }else {
		 
		 
		 		$sel_act1="UPDATE  web_1001 SET CDGBAR3='$cdgbar',cdgpro='$cdgpro'  WHERE cdgart='$cdgart'";
		 		 $mysqli->query($sel_act1);	
		 
		 }
		 
		 

		 

		 
		 
		 
	

}



		 


	 ?>
		<script languaje="javascript">  
		
			parent.enviar();
			
        </script>
	 <?php

				