<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<body>
<?php
 
$ayuda = 'DI2110A_PR.php';
include("DYAYUDA.php");
?>
<div align="center">
  <form name="form1" method="post" action="">
    <table  align="center">
      <tr>
        <th colspan="2" style="#FFFFFF">CATALOGO DE ARTICULO </th>
      </tr>
      <tr>
        <th> <input name="r1" type="radio" tabindex="1" value="clave" <?php
 if($_REQUEST['r1']<>"nombre")echo 'checked' ?>>
        Clave</th>
        <th><input name="r1" type="radio" value="nombre" tabindex="2" <?php
 if($_REQUEST['r1']=="nombre")echo 'checked' ?>>
        Descripcion</th>
      </tr>
      <tr>
        <td colspan="2"><input name="tbus" type="text" onBlur="may(this)" size="50"
		<?php
 if(isset($_REQUEST['tbus'])) echo 'value="'.$_REQUEST['tbus'].'"';?>
		/></td>
      </tr>
      <tr>
        <td colspan="2"><div align="center">
          <input type="submit" name="Submit" value="Buscar" />
        </div></td>
      </tr>
    </table>
  </form>
</div>
<div align="center">
<form name="frm1" id="frm1" method="post" action="">
<input name="vali" type="hidden" 
<?php
 
if (isset($_REQUEST['vali'])){
	echo ' value = "'.$_REQUEST['vali'].'"';
	$nr = $_REQUEST['vali'];
}else{
	echo ' value = "0"';
	$nr = 0;
}
$nr2 =  20;
?>
/>
<?php
 /*
	$sql = mysqli_query($con ,"SELECT * FROM dginvent order by nparte1");
	if($_REQUEST['r1']=="clave"){
	  	@$sql = mysqli_query($con ,"SELECT * FROM dginvent WHERE dginvent.modulo='".$_SESSION['mod_sis']."' AND   nparte1 like '%".$_REQUEST['tbus']."%'");
	}elseif($_REQUEST['r1']=="nombre"){
		@$sql = mysqli_query($con ,"SELECT * FROM dginvent WHERE dginvent.modulo='".$_SESSION['mod_sis']."' AND   np_desc1 like '%".$_REQUEST['tbus']."%'");
	}
	$num_reg = mysqli_num_rows($sql);
	//echo 'numero: '.$num_reg;
	$sql = mysqli_query($con ,"SELECT * FROM dginvent order by nparte1 Limit ".$nr.",".$nr2);
	if(isset($_REQUEST['ttw'])){
		echo '<input name="ttw" type="hidden" value="'.$_REQUEST['ttw'].'">';
	}else{
		echo '<input name="ttw" type="hidden" value="'.$_REQUEST['ttw'].'">';
	}
	include("DE10000.php");
	echo '<table border="0" align="center" >
  	<tr><td width="100%">';
  	$y = 0;
	$paginas = $num_reg / 20;
	//$pag2 = $num_reg % 10;
	//if ($pag2 <> 0)	$paginas++;
  	for ($i=0;$i<=$paginas;$i++){
		//$j = $y - 1;
		if($i == 0){
echo '<a class="thcon" href="'.$_SERVER["PHP_SELF"].'?vali='.$y.'&r1='.$_REQUEST['t1'].'&tbus='.$_REQUEST['t2'].'&t3='.$_REQUEST['t3'].'&t4='.$_REQUEST['t4'].'&tbus='.$_REQUEST['tbus'].'&r1='.$_REQUEST['r1'].'">1</a> . ';
	    }else{
echo '<a class="thcon" href="'.$_SERVER["PHP_SELF"].'?vali='.$y.'&r1='.$_REQUEST['t1'].'&tbus='.$_REQUEST['t2'].'&t3='.$_REQUEST['t3'].'&t4='.$_REQUEST['t4'].'&tbus='.$_REQUEST['tbus'].'&r1='.$_REQUEST['r1'].'">'.$y.'</a> . ';
		 }
		$y+=20;
	}
 echo '</td></tr>
</table>';
	*/?>
    <table width="698" border='1'>
      <tr>
        <th colspan="7"> <div align="left">
          <input type="button" name="Submit6" value="Agregar" onClick="openpage('RC10000_AG.php','_self')"/>
          <input type="Submit" name="bot3" value="Consultar"  onClick="openpage('RC10000_CO.php','_self')"/>
          <input type="button" name="bot2" value="Modificar" onClick="openpage('RC10000_MO.php','_self')"/>
          <input type="button" name="bot1" value="Eliminar" onClick="openpage('RC10000_EL.php','_self')"/>
          <input type="button" name="bot4" value="Imprimir " onClick="openpage('RC10000_IM.php','_self')"/>
        </div></th>
      </tr>
      <tr>
        <th  nowrap><div align="center">Sel</div></th>
        <th  nowrap><div align="center">Clave</div></th>
		<th  nowrap><div align="center">Imagen</div></th>
        <th  nowrap><div align="center">Descripcion</div></th>
		<th  nowrap><div align="center"> Disponible</div></th>
		<th  nowrap><div align="center">Tipo de Moneda</div></th>
		<th  nowrap><div align="center">Precio</div></th>
      </tr>
      <?php

	echo '<input name="txt_bus" type="hidden" value="'.$_REQUEST['tbus'].'">';
	if($_REQUEST['r1']=="clave"){
		echo '<input name="tip_bus" type="hidden" value="clave">';
	  	@$sql = mysqli_query($con ,"SELECT * FROM dginvent WHERE dginvent.modulo='".$_SESSION['mod_sis']."' AND   nparte1 like '%".$_REQUEST['tbus']."%' order by nparte1 ");
	}elseif($_REQUEST['r1']=="nombre"){
		echo '<input name="tip_bus" type="hidden" value="nombre">';
		@$sql = mysqli_query($con ,"SELECT * FROM dginvent WHERE dginvent.modulo='".$_SESSION['mod_sis']."' AND   np_desc1 like '%".$_REQUEST['tbus']."%' order by np_desc1");
	}
	echo mysqli_error($con);
	while($reg = mysqli_fetch_array($sql)){
	  	echo "<tr height=\"60\">";
		echo '<td> <div align="center"><input name="bot" type="radio" value="'.htmlentities($reg["nparte1"]).'"></div></td>';
		echo "<td> <div align='center'>" . $reg["nparte1"] . "&nbsp;</div></td>";
		$fotografia = 'foto/dginvent/NO_'. $reg["nparte1"] . '.JPG';
		if (file_exists($fotografia)) {
			echo '<td class="inputcodigo"><div align="center"><img src="foto/dginvent/NO_'.$reg["nparte1"].'.JPG" width="52" height="60"></div></td>';
		}else{
			echo '<td class="inputcodigo"><div align="center"><img src="foto/sin_producto.jpg" width="40" height="40">&nbsp</div></td>';
		}
		echo "<td> <div align='left'>" . $reg["np_desc1"] . "&nbsp;</div></td>";
		echo "<td> <div align='right'>" . $reg["exi_dis"] . "&nbsp;</div></td>";
		if($reg["tip_mon"]==1 || $reg["tip_mon"]=='N'){
			$tp = "NACIONAL";
		}elseif($reg["tip_mon"]==2 || $reg["tip_mon"]=='E'){
			$tp = "EXTRANJERA";		
		}
		echo "<td> <div align='left'>" . $tp . "&nbsp;</div></td>";
		echo "<td> <div align='right'>$ " .  number_format($reg["precio"], 2, '.', ',') . "&nbsp;</div></td>";
		echo "</tr>";
	}
	mysqli_close($con);
	?>
    </table>
  </form>
</div>
</body>
</html>