<?php

session_start();
include("DMMYSQLG.php");
require_once("DF80000.php");

//Consulta Datos Empresa
$dt_empres = mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM geoyos_jc.dxempres where cla_emp = '".$_SESSION['empresa']."'"));		
$sql_encabezado = mysqli_query($con ,"SELECT * FROM dgtipven where tip_ven = '".$_SESSION['tipven']."'");
@$row_encabezado = mysqli_fetch_array($sql_encabezado);
$cvdm = intval($row_encabezado['cve_delmun']);
$cves = intval($row_encabezado['cve_estado']);
//Consulta Datos Del/Mun
$sqld_encabezado = mysqli_query($con ,"SELECT * FROM geoyos_jc.dxdelmun where cve_delmun = '$cvdm'");
@$rowd_encabezado = mysqli_fetch_array($sqld_encabezado);
//Consulta Datos Estado 
$sqle_encabezado = mysqli_query($con ,"SELECT * FROM geoyos_jc.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 "Ticket";?></title>
 <!-- MeadCo Security Manager -->
<!-- ********************************************************************************* -->
<!-- * DO NOT copy this codebase - it can change at any time                         * -->
<!-- * download the (free) ScriptX Resource Kit and store the cab on your own server * -->
<!-- ********************************************************************************* -->
<!-- MeadCo ScriptX -->
<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;
}
.tit{
font-family:Arial, Helvetica, sans-serif;
font-size:10px;
}
.tot{
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
}

.dom{
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"><object id=factory style="display:none"
  classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  codebase="archivos/smsx.cab#Version=6,5,439,50">
</object>

<script>
function printWindow() {
factory.printing.header = "";
factory.printing.footer = "";
factory.printing.portrait = true;
factory.printing.leftMargin = 1.0;
factory.printing.topMargin = 1.0;
factory.printing.rightMargin = 1.0;
factory.printing.bottomMargin = 1.0;
//factory.printing.copies = 2;
factory.printing.Print(false);
}
</script>

 
</head>
 
<body onLoad="printWindow()">
<form name="form1" method="post" action="">
  <table  border="0" cellspacing="0">
    <tr>
      <td colspan="3" scope="col" class="tit"><?php
echo $dt_empres['nom_emp'];?></td>
    </tr>
    <tr>
      <td colspan="3" class="dom"><?php
 echo $row_encabezado['calle']." ".$row_encabezado['no_ext'];?></td>
    </tr>
    <tr>
      <td colspan="3" class="dom"><?php
echo 'COL. '.$row_encabezado['des_col'].", ".$rowd_encabezado['des_delmun']." ".$rowe_encabezado['des_estado'];?></td>
    </tr>
    <tr>
      <td colspan="3" class="dom"><?php
echo 'C.P.'.$row_encabezado['cod_pos'].' TEL: '.$row_encabezado['telefono'];?></td>
    </tr>
    <tr>
      <td colspan="3"><div align="center"><?php
echo 'RFC:'.$row_encabezado['rfc'];?></div></td>
    </tr>
    <tr>
      <td colspan="3"><?php
echo "CLAVE DEL MESERO(A): ".$rego1['cod_ven'];?></td>
    </tr>
    <tr>
      <td colspan="3" class="titOrd"><?php
echo 'FECHA Y HORA:&nbsp;&nbsp;'.chfecha($_SESSION['fecven'],'Y-m-d','d/m/Y').'&nbsp;'.date('H:i:s');?></td>
    </tr>	
    <tr>
      <td colspan="3" class="titOrd"><?php
echo 'FOLIO:'.str_pad($rego1['fol_ven'],5,'0',STR_PAD_LEFT);?></td>
    </tr>

    <tr>
      <td width="30"><div align="left"><strong>Can</strong></div></td>
      <td width="90"><strong>Prod.</strong></td>
      <td width="38"><div align="left"><strong>Total</strong></div></td>
      <td width="38"><div align="left"><strong>No. Com</strong></div></td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</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);
	@$resu3=mysqli_query($con ,"select * from dgpememd where cons_ven = '".$_REQUEST['bot']."'");
	$noRegsDetalle=mysqli_num_rows($resu3);
	@$re=mysqli_query($con ,"select * from dgpemema where fol_ven = '".$_REQUEST['bot']."' and dgpemema.fol_ven=dgger_cajerosj.pedido and dgger_cajerosj.n_rec=dgger_cajerosd.n_rec and dgger_cajerosd.tip_pag=4'");
	@$res=mysqli_fetch_array($re);
	
	
	$numeroArticulos=0;
	while(@$rego3=mysqli_fetch_array($resu3)){
		@$resux=mysqli_query($con ,"SELECT * FROM dginvent WHERE nparte1 = '".$rego3['nparte1']."'");
		@$regox=mysqli_fetch_array($resux);
		echo "
		<tr>
		  <td>'".$rego3['can_ref']."'</td>
		  <td>".substr($regox['np_desc1'],0,17)."</td>
		  <td><div align=\"right\">".number_format($rego3['total_cd'],2,'.',',')."</div></td>		
		  <td><div align=\"right\">".number_format($rego3['fcomd'],0,'.',',')."</div></td>		
		</tr>";
		/*echo "
		<tr>
		  <td colspan=\"3\">$regox['np_desc1']</td>
		</tr>";*/
		$numeroArticulos++;	
		
		//echo res("nparte1");
	}
	echo "
	<tr>
	  <td colspan=\"3\">&nbsp;</td>
	</tr>";
	echo "    
	<tr>
      <td colspan=\"2\" class=\"tot\">TOTAL : $</td>
      <td class=\"tot\"><div align=\"right\">".number_format($rego2['tot_ven'],2,'.',',')."</div></td>
    </tr>";
	echo "    
	<tr>
      <td colspan=\"2\" class=\"tot\">PAGADO : $</td>
      <td class=\"tot\"><div align=\"right\">".number_format($rego2['tot_ven']+$dt_ger_cajerosj['cambio'],2,'.',',')."</div></td>
    </tr>";
	echo "    
	<tr>
      <td colspan=\"2\" class=\"tot\">CAMBIO : $</td>
      <td class=\"tot\"><div align=\"right\">".number_format($dt_ger_cajerosj['cambio'],2,'.',',')."</div></td>
    </tr>";

	include("DF10000.php");
	$can=round($rego2['tot_ven'],2);
	$parTot=explode(".","$can");
	if($parTot[1]==0 || $parTot[1]==''){
		$parTot[1]='00';
	}	
	$pre_let=num2letras(number_format($parTot[0], 2, '.', ''));
	/*echo "
	<tr>
	  <td colspan=\"3\">".$pre_let.' PESOS '."$parTot[1]".'/100 M.N.'."</td>
	</tr>";*/
	echo "
	<tr>
	  <td colspan=\"3\">ARTICULOS DESPACHADOS: $numeroArticulos</td>
	</tr>";
	
	echo "
	<tr>
	  <td colspan=\"3\">&nbsp;</td>
	</tr>";
	echo "
	<tr>
	  <td colspan=\"3\">&nbsp;</td>
	</tr>";
/*	echo "
	<tr>
	  <td colspan=\"3\"><strong><div align=\"center\">*SI NO LE ENTREGAN SU TICKET*</div></strong></td>
	</tr>";*/	
	echo "
	<tr>
	  <td colspan=\"3\"><strong><div align=\"center\">*GRACIAS POR SU PREFERENCIA*</div></strong></td>
	</tr>";			
	?>

  </table>

</form>
 

</body>
</html>

