<?php 	
	include('../conexion.php');
		
		session_start();
		 
		if($_SESSION['tipo_usu']=='a' or $_SESSION['tipo_usu']=='u'  or $_SESSION['tipo_usu']=='c'){
		}else{
			header('location:acceso_denegado.php');
		}
		
		
$cdgart=$_GET["cdgart"];

if (!isset($_GET["cadena_busqueda"])) { $cadena_busqueda=""; } else  { $cadena_busqueda=$_GET["cadena_busqueda"]; } 
 

$consulta = "SELECT * FROM web_1001 WHERE cdgart='$cdgart'";
$resultado = $mysqli->query($consulta);
$row = $resultado->fetch_array();
  

?>

<html>
	<head>
		<title>Principal</title>
		<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
		<script type="text/javascript" src="../funciones/validar.js"></script>
		<script language="javascript">
		
		
		
				function validarproveedor(){
			var codigo=document.getElementById("cdgpro").value;
			miPopup = window.open("comprobarproveedor.php?cdgpro="+codigo,"frame_datos1","width=700,height=80,scrollbars=yes");

		document.getElementById("Familia").focus();
		document.getElementById("Familia").select();
		}	
	
		
		function aceptar(cdgart, cadena_busqueda ) {
		     cdgart.disable=false;
			document.getElementById("formulario").submit();
		}
		
		
		function cancelar() {
			location.href="index.php?cadena_busqueda=<?php echo $cadena_busqueda?>";
		}
		
		var cursor;
		if (document.all) {
		// Está utilizando EXPLORER
		cursor='hand';
		} else {
		// Está utilizando MOZILLA/NETSCAPE
		cursor='pointer';
		}
		
		</script>
	</head>
		<body onLoad=" enfoque_inicial(); nobackbutton(); ">
		<div id="">
			<div id="zonaContenido">
				<div align="center">
				  <p>&nbsp;</p>
				  <div id="tituloForm" class="header">Visualizar Articulo</div>
				  <p>&nbsp;</p>
				  <div id="frmBusqueda" class="contenidoCliente">
				  
				  <form id="formulario" name="formulario" method="post" action="anular_articulo.php">
				    <table class="fuente8" width="101%" cellspacing=0 cellpadding=3 border=0>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td colspan="4">&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Código </td>
                        <td colspan="4"><input name="cdgart" type="text" class="cajaMedia" id="cdgart" size="70" maxlength="15"  readonly=""                  value="<?php echo $row["CDGART"]?>"  width="29%" rowspan="7" align="left" valign="top" ></td>
                        <td>&nbsp;</td>
                      </tr>
							<input id="cadena_busqueda" name="cadena_busqueda" value="<?php echo $cadena_busqueda?>" type="hidden">
                      <tr>
                        <td width="1%">&nbsp;</td>
                        <td width="3%">&nbsp;</td>
                        <td width="19%">Cód Barras </td>
                        <td colspan="2"><input name="Acdgbar" type="text" class="cajaMedia" id="Acdgbar" size="70" maxlength="15"  readonly=""                  value="<?php echo $row["CDGBAR"]?>"  width="29%" rowspan="7" align="left" valign="top"  onChange="validararticulo()" onFocus= "siguienteCampo ='Adscart';"></td>
                       
					   <?php
					        $estart= $row["ESTART"];
                            $query_estart = "SELECT * FROM  estatus ORDER BY nomest ASC";
                            $result = $mysqli->query($query_estart);
					  ?>
					   
					    <td>Estatus</td>
                        <td><select id="comboestatus" name="comboestatus" class="comboGrande" disabled="disabled"  onFocus="siguienteCampo ='combotipousuario';">
                       
					      <?php
						while ($fila = $result->fetch_assoc()) { 
									if ($estart ==  $fila["codest"]) { ?>
                              <option value="<?php echo  $fila["codest"]?>" selected="selected"><?php echo  $fila["nomest"]?></option>
                              <?php } else { ?>
                              <option value="<?php echo  $fila["codest"]?>"><?php echo  $fila["nomest"]?></option>
                              <?php } ;
								} ?>
                          
                          </select></td>
                        <input name="barras2" type="hidden"  id="barras2" value="<?php echo $row["CDGBAR"]?>"> 
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Descripcion</td>
                       
                        <td colspan="4"><input id="Adscart" autocomplete="off" class="cajaGrande" disabled="disabled" name="Adscart" maxlength="365"  type="text" value="<?php echo htmlspecialchars($row["DSCART"])?>"    onFocus="siguienteCampo ='Acosart';"></td>
                        <td>&nbsp;</td>
                      </tr>
           
					  		  
					   <?php
					        $artexe= $row["COB_IV"];
                            $query_artexe = "SELECT * FROM tipocliente ORDER BY cdgtipcli ASC";
                            $result = $mysqli->query($query_artexe);
					  ?>
					  
					  
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Tipo</td>
                        <td width="21%"><select id="cob_iv" name="cob_iv" class="cajaGrande" disabled="disabled"  onFocus="siguienteCampo ='comboestatus';" onChange="calcular_precio001()">
                            <?php
					 while ($fila = $result->fetch_assoc()) { 
					          if ($artexe ==  $fila["cdgtipcli"]) { ?>
                              <option value="<?php echo  $fila["cdgtipcli"]?>" selected="selected"><?php echo  $fila["dsctipcli"]?></option>
                              <?php } else { ?>
                              <option value="<?php echo  $fila["cdgtipcli"]?>"><?php echo  $fila["dsctipcli"]?></option>
                              <?php } ;
								} ?>
                            </select>                          </td>
                        <td width="15%">&nbsp;</td>
          
                        <td width="17%">% Imp </td>
                        <td width="20%"><input id="ivporc" name="ivporc" type="text" class="cajaGrande" readonly=""  autocomplete="off"  style='text-align:right;' align="right" maxlength="14" value="<?php echo  $row["ivporc"]?>"  onChange="calcular_precio001()" onFocus=" siguienteCampo ='Acosart';" ></td>
                        <td width="4%">&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Costo </td>
                        <td><input id="Acosart" name="Acosart" autocomplete="off" type="text" class="cajaGrande" readonly="" maxlength="14"  style='text-align:right;'  value="<?php  echo number_format( $row["cosart"],2,".",",")?>"   onkeypress="mascara(this,moneda) "  onBlur="calcular_precio001();" onFocus=" siguienteCampo ='Adesart';" ></td>
                        <td>&nbsp;</td>
                        <td><div align="left">Descuento</div></td>
                        <td><input id="Adesart" name="Adesart" type="text" class="cajaGrande"  style='text-align:right;' readonly="" align="right" maxlength="14" value="<?php echo  $row["DESART"]?>"  onChange="calcular_precio001()" onFocus=" siguienteCampo ='fleart';" ></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Impuesto</td>
                        <td><input id="impart" name="impart"  autocomplete="off" type="text" class="cajaGrande" readonly=""  style='text-align:right;'  maxlength="14" align="right" value="<?php echo number_format( $row["impart"],2,".",",")?>"  onChange="calcular_precio001() ;  ponDecimales(2)" onFocus="ponDecimales(2);" ></td>
                        <td>&nbsp;</td>
                        <td>Flete</td>
                        <td><input id="fleart" name="fleart" type="text" class="cajaGrande"  style='text-align:right;' readonly="" align="right" maxlength="14" value="<?php echo  $row["fleart"]?>"  onChange="calcular_precio001()" onFocus=" siguienteCampo ='utiart1';" ></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Utilidad  </td>
                        <td><input id="utiart1" name="utiart1"  autocomplete="off" type="text" class="cajaGrande"  readonly="" style='text-align:right;' maxlength="14" value="<?php echo number_format( $row["utiart1"],2,".",",")?>"  onChange="calcular_precio001() " onFocus=" siguienteCampo ='desmax'" ></td>
                        <td>&nbsp;</td>
                        <td>Precio</td>
                        <td><input id="pre001" name="pre001" autocomplete="off" type="text"  readonly="" class="cajaGrande" maxlength="14" style='text-align:right;' value="<?php echo number_format( $row["PRE001"],2,".",",")?>"  ></td>
                        <td>&nbsp;</td>
                      </tr>
                      
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Dcto Maximo</td>
                        <td><input id="desmax" name="desmax" autocomplete="off" type="text" class="cajaGrande" readonly="" maxlength="14" style='text-align:right;' value="<?php echo number_format( $row["desmax"],2,".",",")?>"  onFocus=" siguienteCampo ='desmin';" ></td>
                        <td><input id="pre002" name="pre002" autocomplete="off" type="hidden" class="cajaGrande"  maxlength="14" style='text-align:right;' value="<?php echo number_format( $row["PRE002"],2,".",",")?>"  readonly="" >
                        <input id="utiart2" name="utiart2" autocomplete="off" type="hidden" class="cajaGrande" readonly="" style='text-align:right;' maxlength="14" value="<?php echo number_format( $row["utiart2"],2,".",",")?>"  onChange="calcular_precio001()" onFocus=" siguienteCampo ='desmax';" >
                        <input id="utisug" name="utisug" autocomplete="off" type="hidden" class="cajaGrande"  readonly="" maxlength="14" style='text-align:right;' value="<?php echo number_format( $row["utisug"],2,".",",")?>"  onFocus=" siguienteCampo ='Aexiact';" ></td>
                        <td>Dcto Minimo </td>
                        <td><input id="desmin" name="desmin" autocomplete="off" type="text" class="cajaGrande"  readonly="" maxlength="14" style='text-align:right;' value="<?php echo number_format( $row["desmin"],2,".",",")?>"  onFocus=" siguienteCampo ='cdgpro';" ></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
						                             <?php
						$query_medida = "SELECT * FROM hac_unidad_medida ORDER BY dscunimed ASC";
                        $result2 = $mysqli->query($query_medida);			  
										  
					    $unimed= $row["UNIMED"];
                          
				?>
                        <td>U.Medida</td>
                        <td><select id="unimed" name="unimed" class="cajaGrande"   disabled="disabled" onFocus="siguienteCampo ='comboestatus';" onChange="calcular_precio001()">
                            <?php 

				        	 while ($fila2 = $result2->fetch_assoc()) { 
					          if ( $unimed ==  $fila2["simunimed"]) { ?>
                            <option value="<?php echo  $fila2["simunimed"]?>" selected="selected"><?php echo  $fila2["dscunimed"]?></option>
                            <?php } else { ?>
                            <option value="<?php echo  $fila2["simunimed"]?>"><?php echo  $fila2["dscunimed"]?></option>
                            <?php } ;
								} ?>
                        </select></td>
                        <td>&nbsp;</td>
                        <td><div align="left">Existencia</div></td>
                        <td><input id="Aexiact" name="Aexiact"  autocomplete="off"  readonly="" type="text" class="cajaGrande" style='text-align:right;' maxlength="14"  align="right" value="<?php echo number_format($row["EXIACT"],2,".",",")?>" onFocus="siguienteCampo ='Acosart';"></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Tipo Articulo</td>
										
										   <?php
					        $cdgtipart= $row["CDGTIPART"];
                                $query_tipo_codigo = "SELECT * FROM hac_tipo_articulo ORDER BY dsctipart DESC";
                                $result2 = $mysqli->query($query_tipo_codigo);
					  ?>
                        <td><select id="cdgtipart" name="cdgtipart" class="cajaGrande"  disabled="disabled" onFocus="siguienteCampo ='comboestatus';" onChange="calcular_precio001()">
                            <?php
					 while ($fila2 = $result2->fetch_assoc()) { 
					          if ($cdgtipart ==  $fila2["cdgtipart"]) { ?>
                            <option value="<?php echo  $fila2["cdgtipart"]?>" selected="selected"><?php echo  $fila2["dsctipart"]?></option>
                            <?php } else { ?>
                            <option value="<?php echo  $fila2["cdgtipart"]?>"><?php echo  $fila2["dsctipart"]?></option>
                            <?php } ;
								} ?>
                        </select></td>
                        <td colspan="3">&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Proveedor </td>
                        <td><input id="cdgpro" name="cdgpro" type="text"   readonly=""  class="cajaMedia" maxlength="6" style='text-align:center;'  value="<?php echo $row["cdgpro"]?>" autocomplete="off"  onFocus=" siguienteCampo ='Acosart';"  onChange="validarproveedor()"     >
                            <img src="../img/Search_Male_User_Icon_32.png" alt="Buscar" width="25" height="27" title="Buscar proveedor"  onClick="abreVentana()" onMouseOver="style.cursor=cursor"></td>
                        <td colspan="3"><input id="dscpro" name="dscpro"  readonly="" type="text"   class="cajaGrande" maxlength="6" onFocus="siguienteCampo ='Familia';" ></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Familia</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Linea</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
					  
					        <?php
								
	$cdgfam=$row["CDGFAM"];
	$query = "SELECT cdgfam, dscfam FROM familias  ORDER BY dscfam";
	$resultado=$mysqli->query($query);
	
	$cdglin=$row["CDGLIN"];
	$query2 = "SELECT cdglin, dsclin FROM lineas WHERE cdgfam = $cdgfam AND cdglin = $cdglin ";
	$resultado2=$mysqli->query($query2);
	$row2 = $resultado2->fetch_assoc()

					  ?>
					  
                        <td height="23">&nbsp;</td>
                        <td>&nbsp;</td>
           <td colspan="2"><select name="Familia" id="Familia" disabled="disabled" class="comboGrande" >
  
				            <?php
							while($row = $resultado->fetch_assoc()) {
									if ($cdgfam ==  $row["cdgfam"]) { ?>
                              <option value="<?php echo   $row['cdgfam']?>" selected="selected"><?php echo  $row['dscfam']?></option>
                              <?php } else { ?>
                              <option value="<?php echo  $row['cdgfam']?>"><?php echo  $row['dscfam']?></option>
                              <?php } ;
								} ?>

			          </select></td>
                        <td>&nbsp;</td>
                        <td colspan="2"><select name="Linea" id="Linea" disabled="disabled" class="comboGrande">
					        
				
                         <option value="<?php echo   $row2['cdglin']?>" selected="selected"><?php echo  $row2['dsclin']?></option>
                

			            </select>						</td>
                        <td colspan="2"></td>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
				    <div id="botonBusqueda">
								<div id="" align="center">
					<img src="../img/Symbol-Check_48x48-32.png" width="48" height="48" onClick="aceptar('<?php echo $cdgart?>' , '<?php echo $cadena_busqueda?>')" border="0"  class="aCentro" onMouseOver="style.cursor=cursor" title="Eliminar Articulo">
					<img src="../img/Symbol-Delete_48x48-32.png" width="48" height="48" onClick="cancelar()" border="0"  class="aCentro" onMouseOver="style.cursor=cursor" title="Cancelar">
					    <input id="accion" name="accion" value="modificar" type="hidden">
					    <input id="id" name="id" value="" type="hidden">
					    <input id="cdgart" name="cdgart" value="<?php echo $cdgart ?>" type="hidden">
				      </div>
			        </div>
					 <input id="id" name="Zid" value="" type="hidden">
			        <div id="botonBusqueda">
					<iframe id="frame_datos2" name="frame_datos2" width="0" height="0" frameborder="0">
					<ilayer width="0" height="0" id="frame_datos2" name="frame_datos2"></ilayer>
					</iframe>
			  </form>
		  </div>
		  
		    <div    style="display:none; position:absolute; top:10%;  left:50%;  height:15%;  width:30%; background-color:white"   id="VentanaEmergente">
           
		  <p>
            <form id="formulario_emergente" name="formulario_emergente"  >
				
			     <table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0>
					   <tr>
       <td colspan="27" align="center" >Codigo de Barras ya fue Registrado !!     Favor Verifique</td>
			       </tr>
					   <tr>
				
					   
					     <td  width="20%" align="center" >&nbsp;</td>
	<td  width="63%" align="center"  ><input  type="botton" value="OK" id="boton"   border="0" onClick= "ocultarVentana()"  style='text-align:center;' onMouseOver="style.cursor=cursor"  /></td>
					     <td  width="17%" align="center" >&nbsp;</td>
			       </tr>
					   <tr>
					     <td colspan="12" align="center" ><input type="image" value="Botón" id="boton2"   src="../img/Symbol-Error_128x128-32.png"  width="128" height="128" border="0" onClick= "ocultarVentana(),limpiar_codigo()"  onMouseOver="style.cursor=cursor"  /> </td>
                         
                        
			       </tr>

                        
		<input id="codfactura" name="codfactura" value=""  onkeypress="chequearEnter(event)" type="hidden">	
							
					</table>
					
			  </div>

			  </div>
	
	</body>
</html>
