<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Reporte</title>
<style type='text/css'>
    <? require('./Assets/css/' . $data['estilo']) ?>
</style>

</head>

<body style="padding: 0;">

<table id="datos-empresa" cellpadding='5' style='margin-bottom:0px;'>
        <tr>
            <td class="logo" width='20%'>
                <img src="<?php echo base_url . 'Assets/img/logo-factura.png'; ?>" alt="" width='152'>
            </td>
            <td class="info-empresa" width='40%'>
                <table>
                    <tr><td style='background:#000;font-size:5mm;color:#fff;font-weight:bold;'>PEDIDO</td></tr>
                    <tr><td style='font-size:4mm;color:#000;font-weight:bold;'><?php echo $data['sucursal']['comercio']; ?></td></tr>
                    <tr><td style='font-size:3mm;color:#000;font-weight:bold;'><?php echo $data['sucursal']['emisor']; ?></td></tr>
                    <tr><td style='font-size:3mm;color:#000;line-height:4mm;'>
                        <?php echo $data['sucursal']['direccion']; ?>, <?php echo $data['sucursal']['municipio']; ?><br/>
                        <?php echo $data['sucursal']['departamento']; ?><br/>
                        
                        <strong>
                    </td></tr>
                </table>
            </td>

            <td class="info-detalle" width='40%'>
                <table align='right'>
                    <tr><td style='font-size:3.5mm;color:#000;font-weight:bold;padding:0px;' colspan='2'>Fecha y Hora:</td></tr>
                    <tr><td style='font-size:3mm;color:#000;font-weight:bold;padding:0px;' colspan='2'><?php echo date('d/m/Y h:i:s A',strtotime($data['venta']['enc_fecha'])); ?></td></tr>
                </table>
            </td>

        </tr>
    </table>

    <div id="container-info">
        <table>
            <tr>
                <td width='70%' style='vertical-align:top;'>
                    <p style='font-size:3.5mm;'><strong>DIA:</strong> <?php echo date('d',strtotime($data['venta']['enc_fecha'])); ?>&nbsp;&nbsp;<strong>MES:</strong> <?php echo date('m',strtotime($data['venta']['enc_fecha'])); ?>&nbsp;&nbsp;<strong>AÑO:</strong> <?php echo date('Y',strtotime($data['venta']['enc_fecha'])); ?></p>
                    <p style='font-size:1mm;'>&nbsp;</p>
                    <p style='font-size:3.5mm;'><strong>NOMBRE:</strong> <?php echo $data['venta']['enc_nom']; ?></p>
                    <p style='font-size:3.5mm;'>
                        <strong><? if($data['venta']['tipoid']==1) { echo 'NIT:'; } else if($data['venta']['tipoid']==2) { echo 'CUI:'; } else if($data['venta']['tipoid']==3) { echo 'PASAPORTE:'; } ?></strong>
                        <?php echo $data['venta']['nitcliente']; ?></p>                        
                    <p style='font-size:3.5mm;'><strong>DIRECCIÓN:</strong> <?php echo $data['venta']['enc_dir']; ?></p><br/>
                    <p style='font-size:3.5mm;'><strong>CODIGO: </strong><span><?php echo $data['venta']['enc_cliente']; ?></span>
                    &nbsp;&nbsp;&nbsp;&nbsp;<strong>VENDEDOR:</strong> <span><?php echo $data['venta']['enc_vend']; ?></span>
                    &nbsp;&nbsp;&nbsp;&nbsp;<strong>FORMA DE PAGO:</strong><span>
                    
                    <?php 
                        if ($data['venta']['forma_pago'] == 1) 
                        {
                            $dataformapago = '<span class="badge badge-info">CONTADO</span>';
                        } else {
                            $dataformapago = '<span class="badge badge-warning">CREDITO</span>';
                        };
                    ?>
                    
                    <?php echo $dataformapago; ?></span></p><br/>

                </td>
                <td width='30%' style='text-align:center;'>
                    <p style='font-size:3.5mm;'><strong>CORRELATIVO # <span><?php echo $data['venta']['id']; ?></span></strong></p><br/>
                </td>                
            </tr>

        </table>
    </div>

    <div id="detalle-factura">
        <table id="container-producto" cellpadding='0' cellspacing='0'>
            <thead>
                <tr>
                    <th style='width:15mm;'>CODIGO</th>
                    <th style='width:18mm;'>CANTIDAD</th>
                    <th>DESCRIPCION</th>
                    <th style='width:20mm;'>PRECIO<BR/>UNITARIO</th>
                    <th style='width:20mm;'>IMPORTE</th>
                    <th style='width:23mm;border-right:0 none;'>CHEQUEO</th>
                </tr>
            </thead>
            <tbody>

                <?php
                $descuento = 0;
                $padding_init='padding-top:0.5mm;';
                foreach ($data['detalle'] as $producto) {
                    $descuento += $producto['descuento']; ?>
                    <tr>
                        <td style='text-align:right;<?php echo $padding_init;?>'><?php echo $producto['det_cod']; ?></td>
                        <td style='text-align:right;<?php echo $padding_init;?>'><?php echo $producto['det_cant']; ?></td>
                        <td style='<?php echo $padding_init;?>'><?php echo $producto['det_descrip']; ?></td>
                        <td style='text-align:right;<?php echo $padding_init;?>'>Q.<?php echo number_format($producto['det_precio'], 2); ?></td>
                        <td style='text-align:right;<?php echo $padding_init;?>'>Q.<?php echo number_format($producto['det_total'], 2); ?></td>
                    </tr>
                <?php
                        $padding_init='';
                    } 
                ?>
                <?php
                for($n=0;$n<(18-count($data['detalle']));$n++)
                {
                    ?>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td style='border-right:0 none;'>&nbsp;</td>
                    </tr>                    
                    <?php
                }
                ?>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style='border-right:0 none;'>&nbsp;</td>
                </tr>                
                
                <tr>
                    <td style='border-right:0.25mm solid #000;border-top:0.25mm solid #000;font-size:2.5mm;line-height:3mm;padding-top:1mm;padding-bottom:1mm;' colspan='3'>
                    <BR/>
                    </td>
                    <td style='background-color:#b3b3b3;border-top:0.25mm solid #000;font-weight:bold;font-size:3mm;text-align:right'>TOTAL</td>
                    <td style='border-right:0.25mm solid #000;border-top:0.25mm solid #000;text-align:right;font-weight:bold;font-size:3mm;'>Q.<?php echo number_format($data['venta']['enc_total'], 2); ?></td>
                    <td style='background-color:#b3b3b3;border-right:0 none;border-top:0.25mm solid #000;'>&nbsp;</td>
                </tr>                

            </tbody>
        </table>
    </div>

    <div style='height:2mm;'></div>


    <table cellpadding='0' cellspacing='0' style='width:100%;height:24mm;margin-left:3mm;'>
        <tr>
            <td id='anotacion_qr2'>
                <div id='observaciones' style='width:201mm;'>
                    <strong>OBSERVACIONES:</strong><br/><br/><?php echo nl2br($data['venta']['anotacion']); ?>
                    
                </div>
            </td>
        </tr>
    </table>

    <div id='firma_sello'>FIRMA Y SELLO DEL COMPRADOR-CLIENTE</div>
    <div id='firma_nombre'>NOMBRE:</div>
    <div id='firma_dpi'>DPI No.:</div>
    <div id='por_divemosa'>POR <?php echo $data['sucursal']['comercio']; ?></div>
    <div id='hoja'>1. ORIGINAL CLIENTE</div>


</body>

</html>
