<?php

 @session_start();

if(!isset($_SESSION['PCOSESS_SesionAbierta'])) {
	echo '<head><title>Error</title><style type="text/css"> body { background-color: #000000; color: #7f7f7f; font-family: sans-serif,helvetica; } </style></head><body><table width="100%" height="100%" border=0><tr><td align=center>&#9827; Acceso no autorizado !</td></tr></table></body>';
	die();
}

$otrosCostos = $liq['otrosCostos'];
$sub_total = $liq['subTotal'];
$total = $liq['total'];
// $codigobarra = $factura["codigo_gs1"]; // "7709998678439";
// $BarcodeParent = "(415)$codigobarra(8020)" . $factura["id"] . "(3900)$totalBr(96)$fechaSinRecargoBr";

$descargar = 0;
/* if ($PCO_Accion == "FACTURAS_descargarFactura")
    $descargar = 1; */

?>

<html>

<head>
   <meta charset="utf-8">
   <title>Factura</title>
   <style>
      * {
         border: 0;
         box-sizing: content-box;
         color: inherit;
         font-family: Verdana;
         font-size: inherit;
         font-style: inherit;
         font-weight: inherit;
         line-height: inherit;
         list-style: none;
         margin: 0;
         padding: 0;
         text-decoration: none;
         vertical-align: top;
      }

      /* heading */
      h1 {
         font: bold 100% sans-serif;
         letter-spacing: 0.5em;
         text-align: center;
         text-transform: uppercase;
      }

      /* table */
      table {
         font-size: 75%;
         table-layout: fixed;
         width: 100%;
         break-after: auto;
         border-collapse: separate;
         border-spacing: 3px;
      }

      th,
      td {
         border-width: 1px;
         padding: 0.5em;
         position: relative;
         text-align: center;
      }

      th,
      td {
         border-radius: 0.25em;
         border-style: solid;
      }

      th {
         background: #1f60a0;
         color: #fff;
         border-color: #BBB;
      }

      td {
         border-color: #DDD;
      }

      /* page */
      html {
         font: 13px/1 "Open Sans", sans-serif;
         overflow: auto;
         padding: 0.5in;
      }

      html {
         background: #999;
         cursor: default;
      }

      body {
         box-sizing: border-box;
         min-height: 11in;
         margin: 0 auto;
         overflow: hidden;
         padding: 0.5in;
         width: 8.5in;
      }

      body {
         background: #FFF;
         border-radius: 1px;
         box-shadow: 0 0 1in -0.25in rgba(0, 0, 0, 0.5);
      }

      /* header */

      header {
         margin: 0 0 3em;
      }

      header:after {
         clear: both;
         content: "";
         display: table;
      }

      header h1 {
         background: #000;
         border-radius: 0.25em;
         color: #FFF;
         margin: 0 0 1em;
         padding: 0.5em 0;
      }

      header address {
         float: left;
         font-size: 75%;
         font-style: normal;
         line-height: 1.25;
         margin: 0 1em 1em 0;
      }

      header address p {
         margin: 0 0 0.25em;
      }

      header span,
      header img {
         display: block;
         float: right;
      }

      header span {
         margin: 0 0 1em 1em;
         max-height: 25%;
         max-width: 60%;
         position: relative;
      }

      header img {
         max-height: 100%;
         max-width: 100%;
      }

      header input {
         cursor: pointer;
         -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
         height: 100%;
         left: 0;
         opacity: 0;
         position: absolute;
         top: 0;
         width: 100%;
      }

      /* article */

      article,
      article address,
      table.meta,

      article:after {
         clear: both;
         content: "";
         display: table;
      }

      article h1 {
         clip: rect(0 0 0 0);
         position: absolute;
      }

      article address {
         float: left;
         font-size: 125%;
      }

      /* table meta & balance */

      table.meta,
      table.balance {
         float: right;
         width: 36%;
      }

      table.meta:after,
      table.balance:after {
         clear: both;
         content: "";
         display: table;
      }

      /* table meta */

      table.meta th {
         width: 40%;
      }

      table.meta td {
         width: 60%;
      }

      table.inventory {
         margin: 0 0 1.3em;
      }
      /* table items */

      table.inventory {
         clear: both;
         width: 100%;
      }

      table.inventory th {
         font-weight: bold;
         text-align: center;
      }

      /* table balance */

      table.balance th {
         width: 60%;
         text-align: center;
      }

      table.balance td {
         width: 60%;
         text-align: center;
      }

      /* aside */

      aside h1 {
         border: none;
         border-width: 0 0 1px;
         margin: 0 0 1em;
      }

      aside h1 {
         border-color: #999;
         border-bottom-style: solid;
      }

      /* javascript */

      @media print {
         * {
            -webkit-print-color-adjust: exact;
         }

         html {
            background: none;
            padding: 0;
         }

         body {
            box-shadow: none;
            margin: 0;
         }

         span:empty {
            display: none;
         }
      }

      @page {
         margin: 0;
         page: letter;
      }
   </style>
    <!--<link rel="stylesheet" href="inc/pdfLib/all.min.css">-->
    <!--<script type="text/javascript" src="inc/pdfLib/html2pdf.bundle.min.js"></script>-->
    <!--<script type="text/javascript" src="inc/bwip/bwip-js-min.js"></script>-->
    
            <!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">-->
            <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"
              integrity="sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg=="
              crossorigin="anonymous" referrerpolicy="no-referrer"></script>-->
</head>
<body id="Invoices">
   <article>
      <table class="meta">
        <tr>
            <th style="width: 120px !important;"><span>Fecha inicio</span></th>
            <td><span><?php echo $liq["fecha_inicio"] ?></span></td>
         </tr>
        <tr>
            <th style="width: 120px !important;"><span>Fecha fin</span></th>
            <td><span><?php echo $liq["fecha_fin"] ?></span></td>
         </tr>
      </table>
      <address>
         <!--<p style="color:#14406b; font-size: 18px; font-weight: bold;">AUTONORTE</p>
         <p style="font-size: 12px;">NIT: 811018300-6</p>
         <p style="font-size: 12px;">CLL 21 # 8-78 San Jerónimo, Ant</p> -->
         <BR>
         <p style="font-size: 12px;">
            <span style="font-weight: bold;">Nombre: </span><?php echo $liq["nombre_completo"] ?><br>
            <span style="font-weight: bold;">Dirección: </span><?php echo  $liq["direccion"] ?><br>
         </p>
      </address>

      <table class="inventory">
         <thead>
            <tr>
               <th><span>Valor venta</span></th>
               <th><span>Valor abono</span></th>
               <th><span>Valor débito</span></th>
               <th><span>Seguridad social</span></th>
            </tr>
         </thead>
         <tbody>
            <tr>
               <td><span><?php echo $liq["valor_venta"] ?></span></td>
               <td><span><?php echo  $liq["valor_novedad_abonar"] ?></span></td>
               <td><span><?php echo $liq["valor_novedad_debitar"] ?></span></td>
               <td><span><?php echo  $liq["seguridad_social"] ?></span></td>
            </tr>
         </tbody>
      </table>
      <?php 
        if (count($ventas)) {
    ?>
    <br>
         <p style="font-size: 12px;">
            <span style="font-weight: bold;">Ventas: </span>
         </p>
        <table class="inventory">
         <thead>
            <tr>
               <th width="6%"><span>Factura</span></th>
               <th width="17%"><span>Fecha</span></th>
               <th width="34%"><span>Cliente</span></th>
               <th width="35%"><span>Producto</span></th>
               <th width="8%"><span>Total Mecánico</span></th>
            </tr>
         </thead>
         <tbody>
         <?php
         foreach ($ventas as $venta) {
             ?>
            <tr>
               <td><?php echo $venta["id"] ?></td>
               <td><?php echo $venta["fecha"] ?></td>
               <td><?php echo $venta["nombre_completo"] ?></td>
               <td><?php echo $venta["nombre"] ?></td>
               <td style="align: 'right' !important;"><?php echo $venta["total_mecanico2"] ?></td>
            </tr>
        <?php
         }
      }
         ?>
                  </tbody>
      </table>
         <br>
        <?php 
        if (count($novedades)) {
    ?>
    <br>
         <p style="font-size: 12px;">
            <span style="font-weight: bold;">Novedades: </span>
         </p>
        <table class="inventory">
         <thead>
            <tr>
               <th><span>Fecha</span></th>
               <th><span>Tipo novedad</span></th>
               <th><span>Valor novedad</span></th>
            </tr>
         </thead>
         <tbody>
         <?php
         foreach ($novedades as $novedad) {
             ?>
            <tr>
               <td><?php echo  $novedad["fecha"] ?></td>
               <td><?php echo  $novedad["tipo_novedad"] ?></td>
               <td><?php echo  $novedad["tipo_novedad"] == "Debitar" ? -$novedad["valor_novedad2"] : $novedad["valor_novedad2"] ?></td>
            </tr>
        <?php
         }
      }
         ?>
         </tbody>
      </table>

      <table class="balance" style="font-size: 11px;">
         <tr>
            <td style="background-color: #1f60a0; font-weight: bold;"><span>SUBTOTAL</span></td>
            <th style="background-color: #14406b;"><span><?php echo $sub_total ?></span></th>
         </tr>
         <tr>
            <td style="background-color: #1f60a0; font-weight: bold;"><span>TOTAL COBROS</span></td>
            <th style="background-color: #14406b;"><span><?php echo $otrosCostos ?></span></th>
         </tr>
         <tr style="color: #fff; font-size: 12px;">
            <td style="background-color: #1f60a0; font-weight: bold;"><span>TOTAL</span></td>
            <th style="background-color: #14406b;"><span><?php echo $total ?></span></th>
         </tr>
       
            
        </tr>
         </tr>
      </table>
      </div>
   </article>

</body>
</html>