
<?php
include ("../conexion.php");
    
require_once '../dompdf/autoload.inc.php';


require_once '../dompdf/lib/html5lib/Parser.php';
require_once '../dompdf/lib/php-font-lib/src/FontLib/Autoloader.php';
require_once '../dompdf/lib/php-svg-lib/src/autoload.php';
require_once '../dompdf/src/Autoloader.php';
Dompdf\Autoloader::register();

use Dompdf\Dompdf;

$codigoHTML='
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lista</title>
<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">

</head>


   <script type="text/php">

        if ( isset($pdf) ) {

          $font = Font_Metrics::get_font("helvetica", "bold");
          $pdf->page_text(72, 18, "Header: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));

        }
  

</script>

	    <style type="text/css">      
		tabla {
  border-collapse: separate;
  border-spacing:  3px;
}
 </style>
<body>
<div align="center">
  <p>&nbsp;</p>';
  

       $parametros = "SELECT * FROM web_0000 ";
       $result_parametros = $mysqli->query($parametros);
       $row_para = $result_parametros->fetch_array();
     
	   $NombreComercial =  $row_para["NOMCOM"];
	   $razsoc          =  $row_para["RAZSOC"];
	   $Direccion       =  $row_para["DIREMP"];
	   $Cedula          =  $row_para["CEDJUR"];
	   $Telefono        =  $row_para["NUMTEL"];
	   
	   
	   $numcie=$_GET["numcie"];
	 
			  
$consulta = "SELECT * FROM cierres WHERE numcie='$numcie'";
$resultado = $mysqli->query($consulta);
$fila = $resultado->fetch_array();

		$monsis = $fila["monsis"];
		$mondig = $fila["mondig"];
		$monefe = $fila["monefe"];
		$moncks = $fila["moncks"];
		$monvou = $fila["monvou"];
		$mondol = $fila["mondol"];
		$monval = $fila["monval"];
		$mondif = $fila["mondif"];
		$totcre = $fila["totcre"];
		$totfac = $fila["totfac"];
		$totrec = $fila["totrec"];
		$totnotdeb = $fila["totnotdeb"];
		$totnotcre = $fila["totnotcre"];
		$totval = $fila["totval"];
		$totcom = $fila["totcom"];
		$totent = $fila["totent"];
		$totsal = $fila["totsal"];
		$cdgcaj = $fila["cdgcaj"];
		$cincuentamil = $fila["cincuentamil"];
		$veintemil    = $fila["veintemil"];
		$diezmil      = $fila["diezmil"];
		$cincomil     = $fila["cincomil"];
		$dosmil       = $fila["dosmil"];
		$mil          = $fila["mil"];
		$quinientos   = $fila["quinientos"];
		$cien         = $fila["cien"];
		$cincuenta    = $fila["cincuenta"];
		$veinticinco  = $fila["veinticinco"];
		$diez         = $fila["diez"];
		$cinco        = $fila["cinco"];
		$tipcamdol    = $fila["tipcamdol"];
		$candol       = $fila["candol"];
		$monapecaj    = $fila["monapecaj"];
		$feccie       = $fila["feccie"];
        $feccie= implode("-", array_reverse(explode("-", $feccie)));
		$total_digitado=$monefe+$monval+$moncks+$monvou+$mondol;
		$total_sistema=$totfac+$totrec-$totnotcre + $totnotdeb;
		$total_ventas=$totfac+$totcre;
 

 if ($cdgcaj==9999) {
	 
	 $nomcomusu="TODOS LOS CAJEROS";
	 
	     } else {
	 
	 							
		$consulta = "SELECT * FROM usuarios  WHERE codusu=$cdgcaj ";
		$resultado = $mysqli->query($consulta);
		$row = $resultado->fetch_array();
		$nomcomusu = $row["nomcomusu"];
     }
 
 
$codigoHTML='
    <table width="100%"  cellpadding="0" cellspacing="0"  border="0">
      <tr>
        <td width="28%" align="" rowspan="3"><img src="../img/logo_reportes.png" /></td>
        <td width="42%" align="center"><font color="blue" size=4><strong>'.$NombreComercial.'</strong></font></td>
        <td width="30%">&nbsp;</td>
      </tr>
      <tr>	
        <td height="12" align="center"><font size=2 >Cierre de caja del día: '.$feccie.'</font></td>
        <td height="12">&nbsp;</td>
      </tr>
      <tr>
        <td height="12" align="center"><font size=2 ></font><font size="3" ><strong>Cajero: '.$cdgcaj.' - '.$nomcomusu.'</strong></font></td>
        <td height="12">&nbsp;</td>
      </tr>
    </table>
    ';
  
   

	 

	 
	 $codigoHTML.='
  
  ';
	
	
    $codigoHTML.='</p>
    <hr  color="#000000"/>
    <table cellspacing="0" align="center" cellpadding="0" style=" border-width: 2px;"  width="48%" border="1" bordercolor="#000000">
      <tr>
        <td colspan="4"  align="center" bgcolor="#CCCCCC" class="titulo">VALORES DIGITADOS</td>
      </tr>
      <tr>
        <td width="11%"   style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td width="21%"   style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td width="43%"   style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td width="25%"   style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Monto Efectivo</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;"><font size="3" > '.number_format($monefe,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Monto Vouchers</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($monvou,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Monto Cheques</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($moncks,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Monto Dólares</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($mondol,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Otros Valores </td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($monval,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td colspan="2"  style="padding-bottom: 1px; border:0px solid black;">___________________________________</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;"><strong>Total Digitado</strong></td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><strong><font size="3" >'.number_format($total_digitado,2).'</font></strong></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4"  align="center" bgcolor="#CCCCCC" class="titulo">VALORES DEL SISTEMA</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Ventas Contado</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totfac,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Recibos de Pago</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totrec,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
	        <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Entradas Efectivo(+)</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totent,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
	        <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Vale Funcionarios(-)</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totval,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
	        <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Compras Contado(-)</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totcom,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
	        <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Salidas Efectivo(-)</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totsal,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>

      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Notas de Credito(-)</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totnotcre,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
	        <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Notas de Debito(+)</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totnotdeb,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td colspan="2"  style="padding-bottom: 1px; border:0px solid black;">___________________________________</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;"><strong>Total Sistema</strong></td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><strong><font size="3" >'.number_format($total_sistema,2).'</font></strong></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4"  align="center" bgcolor="#CCCCCC" class="titulo">DIFERENCIA</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Total Sistema</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($total_sistema,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Total Digitado</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($total_digitado,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td colspan="2"  style="padding-bottom: 1px; border:0px solid black;">___________________________________</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;"><strong>Diferencia</strong></td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><strong><font size="3" >'.number_format($mondif,2).'</font></strong></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4"  align="center" bgcolor="#CCCCCC" class="titulo">VENTAS TOTALES</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Ventas Contado</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totfac,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">Ventas Crédito</td>
        <td align="right"  style="padding-bottom: 1px; border:0px solid black;"><font size="3" >'.number_format($totcre,2).'</font></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td colspan="2"  style="padding-bottom: 1px; border:0px solid black;">___________________________________</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;"><strong>Total Ventas</strong></td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;"><strong><font size="3" >'.number_format($total_ventas,2).'</font></strong></td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
      <tr>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  align="right" style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
        <td  style="padding-bottom: 1px; border:0px solid black;">&nbsp;</td>
      </tr>
  </table>
  ';
          

			
$codigoHTML.='
   
   <p>';
   
   //  } 
$codigoHTML.='   </p>
   <table width="100%" border="0">
     <tr>
       <td align="center">_____________________________</td>
     </tr>
     <tr>
      <td align="center"><strong><em><font size=2 >'.$nomcomusu.'</font></em></strong></td>
     </tr>
     <tr>
       <td align="center"><strong><em><font size=2 >Firma y sello</font></em></strong></td>
     </tr>
  </table>
   <p>&nbsp;</p>
</div>
</body>
</html>';

$codigoHTML=utf8_decode($codigoHTML);
$dompdf=new DOMPDF();
$dompdf->set_paper( "A4", "portrait" ); // a4,vertical
$dompdf->load_html($codigoHTML);
ini_set("memory_limit","256M");
$dompdf->render();
$dompdf->stream("Cierre de Caja.pdf", array("Attachment" => false));

?>
