<?php
 
session_start();
$com = "M";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
require_once("DFJQUERY.inc");
include("DF30000.inc");
include("DF80000.php");

?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<?php

if ($_REQUEST['bot']==""){
	echo '<h2>!!! SELECCIONE UN REGISTRO !!!</h2>';
	echo '<meta content="1; url=CO10300_PR.php"  HTTP-EQUIV="REFRESH">';
}else{
	if(!isset($_REQUEST['tap2'])){
		include('CO10300_CL.php');
		$varible_clase = new clase();
		$res=$varible_clase->lista_busqueda($_REQUEST["bot"]);
		$reg=mysqli_fetch_array($res);
		$_REQUEST['id_pro']=$reg['id_pro'];
		$_REQUEST['tap2']=$reg['np_desc1'];
		$_REQUEST['precio']=$reg['lim_vta1'];
		$_REQUEST['afe_inv']=$reg['afe_inv'];
		$_REQUEST['cve_iva_ven']=$reg['cve_iva_ven'];
		$_REQUEST['afe_coman']=$reg['afe_coman'];
		$_REQUEST['select']=$reg['linea'];
		$_REQUEST['select2']=$reg['gpo_basico'];
		$_REQUEST['tap4']=$reg['exi_min'];
		$_REQUEST['tap5']=$reg['exi_max'];
		$_REQUEST['tap18']=$reg['tip_mon'];
		$_REQUEST['tap14']=$reg['cve_uni_com'];
		$_REQUEST['capacidad']=$reg['capacidad'];
		//$_REQUEST['tap15']=$reg['cve_uni_vta'];
		$_REQUEST['almacen']=$reg['almacen'];
		$_REQUEST['factor']=$reg['factor'];
		$_REQUEST['unidad']=$reg['unidad'];
		$_REQUEST['capacidad']=$reg['capacidad'];
		$_REQUEST['descripcion']=$reg['descripcion'];
		$_REQUEST['invmin']=$reg['invmin'];
		$_REQUEST['invmax']=$reg['invmax'];
		$_REQUEST['ultimoc']=$reg['ultimoc'];
		$_REQUEST['costop']=$reg['costop'];
		$_REQUEST['existencia']=$reg['existencia'];
		$_REQUEST['codigo']=$reg['codigo'];
	}
?>
<style type="text/css">
<!--
.Estilo18 {color: #FFFFFF}
.Estilo19 {font-size: 16px}
.Estilo24 {	font-size: 18px;
	font-weight: bold;
}
-->
</style>
<script language="javascript">
$(document).ready(function(){
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0];
	}
	$("#tap2").autocomplete('CO10300_AU.php',{
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		//max:3                        //maximo de resultados mostrados, se manda como limit en autosugestion
		delay: 200,                  //Retardo de autocompletar 
		width: 500,                  //ancho del cuadro de despliegue
		highlight: false,            //Resalta letras coincidentes
		autoFill: false,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 300,           //alto del cuadro para el scroll
		formatItem:formatItem,	     //formato de presentacion de las posibles busquedas
		extraParams:{tipBus:'d'}     //Parametros Extra a Mandar en autosugestion
	});
});
</script>
<body>
<form name="frm1" method="post" action="" enctype="multipart/form-data">
<input name="bot" type="hidden" value="<?php
 echo $_REQUEST['bot'];?>"> 
  <table width="458"  align="center">
    <tr>
      <th colspan="4">CONSULTAR DATOS DE RECETA. </th>
    </tr>
    <tr>
      <td>FOLIO.</td>
      <td colspan="3"><span class="Estilo19">
        <input name="n_reg" type="text" id="n_reg" size="15" disabled="disabled"
		  <?php
 
		if(isset($_REQUEST['bot'])){
		echo 'value="'.$reg['n_reg'].'"';
		}
		?>
		
		>
      </span></td>
    </tr>
    <tr>
      <td colspan="4"><strong>NOMBRE</strong>.
        <label>
        <input name="tap2" id="tap2" type="text" tabindex="2"
		  onBlur="may(this)" size="60"
		 <?php
 
		if(isset($_REQUEST['bot'])){
		echo 'value="'.$reg['np_desc1'].'"';
		}
		?>>
      </label></td>
    </tr>
    <!--tr>
      <td width="58">&nbsp;</td>
      <td width="384" colspan="3"><select name="p1" id="p1" onChange="javascript: document.getElementById('frm1').submit()" tabindex="6">
        <option value="">-----SELECCIONE-----</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM cotimp");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['p1']==$reg['np_desc1'] ){
		echo '<option value="' . $reg['np_desc1'] . '" selected>' . $reg['np_desc1'] . '</option>';
	}else{
		echo '<option value="' . $reg['np_desc1'] . '">' . $reg['np_desc1'] . '</option>';
	}
}
?>
      </select></td>
    </tr-->
  </table>
  <div id="divVent" style="display:">
    <table width="711"  align="center"  >
      <tr>
        <th width="51" height="22">CODIGO</th>
		<th width="300" height="22">DESCRIPCION</th>
		<th width="80" height="22">UNIDAD</th>
		<th width="80" height="22">CANTIDAD</th>
		<th width="50" height="22">PEDIDO</th>
		<th width="110" height="22"><div align="center">PORCION TOTAL</div></th>
		<th width="50" height="22">COSTO</th>
		
		<th width="80">TOTAL</th>
      </tr>
<?php

	 // SACAO EL NUMERO DE REGISTRO
	  $bot = $_REQUEST['bot'];
	  //SACO LAS RECETAS Y LAS PORCIONES 
	  $sakjs = mysqli_query($con ,"select * from cos_ped_det where nparte1 = '$bot'");
	  while ($kwjkl = mysqli_fetch_array($sakjs)){
	  //for ($i=0; $i<$kjiuj; $i++){
	  $des = $kwjkl["nparte1_det"];//RECETA
	  $uwu = $kwjkl["can_ref"];//PORCIONES
	  //}
	  $jklsd = mysqli_query($con ,"SELECT * FROM dginvend where nparte1 = '$des'");
	  while ($kskdl = mysqli_fetch_array($jklsd)){
	  echo "<tr>";
		$ves = $kskdl["nparte1_det"];
		//if ($ves == $ves){
		//echo "<td> <div align='center'>" . $ves . "&nbsp;</div></td>";
		//}
		echo "<td> <div align='center'>" . $ves . "&nbsp;</div></td>";
		
		$akslj = mysqli_fetch_array(mysqli_query($con ,"SELECT * from farticulos where nparte1 = '$ves'"));
		echo "<td> <div align='center'>" . $akslj["np_desc1"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $akslj["pais"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $kskdl["can_ref"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $kwjkl["can_ref"] . "&nbsp;</div></td>";
		//CANTIDAD X PORCION
		$por_tot = $kskdl["can_ref"] * $uwu;
		echo "<td> <div align='center'>" .number_format($por_tot,2,'.',',')."&nbsp;</div></td>";
		// PRECIO DEL ARTICULO.
		$precio = $akslj["cos_prom"];
		echo "<td> <div align='center'>$" .number_format($precio,2,'.',','). "&nbsp;</div></td>";
		
		$total = $por_tot * $precio;
		echo "<td> <div align='center'>$" .number_format($total,2,'.',',')."&nbsp;</div></td></tr>";
	  }
	 }
	  
	  ?>
	  <tr>
        <td height="29" colspan="8">
          <div align="center">
            <input type="button" name="bot4" value="Regresar" onClick="openpage('CO10300_PR.php','_self')"/>
        </div></td>
      </tr>
    </table>
  </div>
</form>
 <?php
 
}
?>
</body>
</html>
<?php
 mysqli_close($con);?>

</body>
</html>