<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
include("DMMYSQLG.php");
require_once("DF80000.php"); 

 
if ($_REQUEST['bot']=='0' || $_REQUEST['bot']==''){
$_REQUEST['bot']=$_SESSION['foli'];
}

 @$resu3=mysqli_query($con ,"select dgpememd.* from dgpememd left join dginventp on (dginventp.nparte1=dgpememd.nparte1) where dgpememd.cons_ven = '".$_REQUEST['bot']."' and dgpememd.fcomd='".$_SESSION['comand']."' and dgpememd.cancela=0 and dginventp.tipo=1"); 
 
 
if (mysqli_num_rows($resu3)=='0' || mysqli_num_rows($resu3)==''|| mysqli_num_rows($resu3)==0){

echo  "Sin productos <script type='text/javascript'> window.close(); </script> ";

}else{

//Consulta Datos Empresa
$dt_empres = mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM dxempres where cla_emp = '".$_SESSION['empresa']."'"));		
$cvdm = intval($dt_empres['cve_delmun']);
$cves = intval($dt_empres['cve_estado']);
//Consulta Datos Del/Mun
$sqld_encabezado = mysqli_query($con ,"SELECT * FROM dxdelmun where cve_delmun = '$cvdm'");
@$rowd_encabezado = mysqli_fetch_array($sqld_encabezado);
//Consulta Datos Estado 
$sqle_encabezado = mysqli_query($con ,"SELECT * FROM dxestado where cve_estado = '$cves'");
@$rowe_encabezado = mysqli_fetch_array($sqle_encabezado);
@$resu1=mysqli_query($con ,"select * from dgpemema where fol_ven = '".$_REQUEST['bot']."'");
@$rego1=mysqli_fetch_array($resu1);
$dt_ger_cajerosj=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM dgger_cajerosj where pedido='".$rego1['fol_ven']."'"));
?>
<html>
<head>
<title><?php echo "COCINA";?></title>

<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-family:Arial, Helvetica, sans-serif;
	font-size:10px;
}
td{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
.titOrd{
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bolder;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function printWindow() {


window.print();
window.close();
 

}
</script>
 </head>	
 
 <body onLoad="printWindow()">
<form name="form1" method="post" action="">
  <table  border="0" cellspacing="0">
    <tr> <td colspan="3" class="titOrd" align="center"><?php echo 'COCINA &nbsp;'?></td> </tr>	
    <tr>
      <td colspan="3"><?php echo "MESERO(A): "; 
	  $sq_ms=mysqli_fetch_array(mysqli_query($con ,"select * from ctmeser where nparte1=".$rego1['cod_ven']."")); 
	  echo $sq_ms['np_desc1']; ?>
	  </td>
    </tr>
    <tr>
      <td colspan="3"><?php 
	  	$sq_m=mysqli_query($con ,"select * from ctmesas where nparte1='".$_SESSION['mesa']."'");
	$regmp=mysqli_fetch_array($sq_m);

	  echo 'MESA:  '.$regmp['np_desc1'];   echo '&nbsp;&nbsp;&nbsp;&nbsp;PAX  :'.$regmp['posicion'] ?></td></tr>
    <tr>
    <tr> <td colspan="3"><?php echo 'FECHA &nbsp;'.chfecha($_SESSION['fecven'],'Y-m-d','d/m/Y');?></td> </tr>
    <tr> <td colspan="3"><?php echo 'HORA:&nbsp;'.date('H:i:s');?></td> </tr>		
    <tr> <td colspan="3"><?php echo 'FOLIO:'.str_pad($rego1['con_ven'],5,'0',STR_PAD_LEFT); 
	                              if ($_REQUEST['but']==0){ 
								  echo '&nbsp;&nbsp;&nbsp;&nbsp;COMANDA:'.str_pad($_SESSION['comand'],5,'0',STR_PAD_LEFT); }?></td></tr>
    <tr>
      <td class="titOrd" ><div align="left"><strong>CANT.  &nbsp;</strong></div></td>
      <td class="titOrd" colspan="2"><strong>PRODUCTO</strong></td>
    </tr>
	<?php

	if(!isset($_REQUEST['rec_caj']))
		$_REQUEST['rec_caj']=$_REQUEST['bot'];
	@$resu2=mysqli_query($con ,"select * from dgpemema where fol_ven = '".$_REQUEST['bot']."'");
	@$rego2=mysqli_fetch_array($resu2);
	
	//BUSQUEDA DE CUENTA POR COMANDA
	@$resu3=mysqli_query($con ,"select dgpememd.* from dgpememd left join dginventp on (dginventp.nparte1=dgpememd.nparte1) where dgpememd.cons_ven = '".$_REQUEST['bot']."' and dgpememd.fcomd='".$_SESSION['comand']."' and dgpememd.cancela=0 and dginventp.tipo=1");
	
	//BUSQUEDA DE CUENTA TOTAL POR POSICION
	//@$resu3=mysqli_query($con ,"select * from dgpememd where cons_ven ='".$_REQUEST['bot']."' and fcomd!=0 and cancela=0");
	//@$tot=mysqli_fetch_array(mysqli_query($con ,"select sum(total_cd) as total from dgpememd where cons_ven = '".$_REQUEST['bot']."' and cancela=0"));
	
	$numeroArticulos=0;
	
	while(@$rego3=mysqli_fetch_array($resu3)){
		@$resux=mysqli_query($con ,"SELECT * FROM dginventp WHERE nparte1 = '".$rego3['nparte1']."'");
		@$regox=mysqli_fetch_array($resux);
		echo "
		<tr>"
		 ." <td class=\"titOrd\" align=\"center\">".$rego3['can_ref']."</td>"
		 ." <td colspan=\"2\" class=\"titOrd\">".substr($regox['np_desc1'],0,30)."</td>"
		."</tr>";
		
		echo "<tr> <td colspan=\"3\" class=\"titOrd\">".substr($rego3['comenta'],0,35)."</td> </tr>";
		echo "<tr> <td colspan=\"3\" class=\"titOrd\">".substr($rego3['comenta'],35,35)."</td> </tr>";
		
		$numeroArticulos++;	
	
	}
		
	echo "<tr> <td colspan=\"3\">&nbsp;</td> </tr>";
	
	echo "<tr> <td colspan=\"3\">ARTICULOS DESPACHADOS: $numeroArticulos</td> </tr>";
		
	echo "<tr> <td colspan=\"3\">&nbsp;</td> </tr>";
	?>
	
</table>
</form>
</body>
</html>

<?php
 
/*echo  "<script type='text/javascript'>				
				window.close();
</script> ";*/
}  ?>
