<!-- Definir el header -->
<htmlpageheader name="distinsa-header">


<div class="area-logo">
    <table style="width: 100%; height: 15mm; border-collapse: collapse;" cellpadding="0" cellspacing="0">
        <tr>
            <td style="vertical-align: middle; padding: 0; width: 15mm;">
                <img src="<?= $data['logoBase64'] ?>" style="max-height: 14mm; max-width: 35mm;">
            </td>
            <td style="vertical-align: middle; padding-left: 3mm; color: #077d2f; line-height: 1.2;">
                <div style="font-weight: bold; font-size: 11pt; margin-bottom: 1mm;">DISTINSA</div>
                <div style="font-size: 9pt;">Distribuidora Técnica Industrial, S.A.</div>
            </td>
        </tr>
    </table>
   
</div>

<div class="area-pedido">
    <table style="width: 100%; border-collapse: collapse;" cellpadding="0" cellspacing="0">
        <tr>
            <td style="vertical-align: middle; text-align: center; color: #000;padding-top:4mm;">
                # PEDIDO<br>
                <span class="numero-pedido"><?=str_pad($data['numero_pedido'], 8, "0", STR_PAD_LEFT)?></span>
            </td>
        </tr>
    </table>
</div>

<div class="area-barcode">
    <table style="width: 100%; height: 15mm; border-collapse: collapse;" cellpadding="0" cellspacing="0">
        <tr>
            <td style="vertical-align: middle; text-align: center; width: 100%; padding: 0; margin: 0;">
                <barcode code="<?= $data['numero_pedido'] ?>" type="C128B" height="1.0" size="1.3" quiet="0" style="margin-right:-5mm;margin-top:3mm;"/>
            </td>
        </tr>
    </table>
</div>
</htmlpageheader>

<htmlpagefooter name="distinsa-mifooter">
    <div class="footer-pagina">
        <table style="width: 100%; border-collapse: collapse;font-size: 7pt;margin-top:0mm;" cellpadding="5" cellspacing="0">
        <tr>
            <td style="width:50%;height: 85mm;vertical-align: top;padding-right: 5mm;border-right: 1px dashed #ccc;">

                    <table style="width: 100%; height: 20mm; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                            <tr>
                                <td style="vertical-align: middle; width: 15mm;">
                                    <?= ($data['logoBase64'] ? '<img src="' . $data['logoBase64'] . '" style="max-height: 14mm; max-width: 35mm;">' : 'LOGO') ?>
                                </td>
                                <td style="vertical-align: top; color: #333; line-height: 1.2;text-align: center;padding-top:2mm;">
                                    <div style="font-weight: bold; font-size: 14pt; margin-bottom: 1mm;">SERVICIO AL CLIENTE</div>
                                    <div style="font-weight: bold;font-size: 11pt;">TEL.: <?= $data['telefono'] ?></div>
                                </td>
                            </tr>
                        </table>

                    <table style="width: 100%; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="padding-top:2mm;vertical-align: middle; width: 15mm;font-size: 11pt;">DESTINATARIO</td>
                            <td style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;"><?= $data['destinatario_parte1'] ?></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;"><?= $data['destinatario_parte2'] ?></td>
                        </tr>
                    </table>
                    <table style="width: 100%; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="padding-top:2mm;vertical-align: middle; width: 15mm;font-size: 11pt;">DIRECCION</td>
                            <td style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;"><?= $data['direccion_parte1'] ?></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;"><?= $data['direccion_parte2'] ?></td>
                        </tr>
                    </table>
                    <table style="width: 100%; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="padding-top:2mm;vertical-align: middle; width: 15mm;font-size: 11pt;">CIUDAD</td>
                            <td style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;color:#f00;">GUATEMALA</td>
                        </tr>
                    </table>
                    <table style="width: 100%; border-collapse: collapse;margin-top:2mm;" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="padding-top:2mm;vertical-align: middle; width: 15mm;font-size: 11pt;">

                                <barcode code="<?= $data['codigo_cliente'] ?>" type="QR" size="0.8" height="10" disableborder="1" />

                            </td>
                            <td style="padding-top:2mm;vertical-align: bottom;text-align:center;">
                                <table style="width: 100%; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                                <tr>
                                    <td style="text-align:center;border-top:1px solid #000;font-size: 10pt;">TRANSPORTE</td>
                                </tr>
                                </table>
                            </td>
                        </tr>
                    </table>

            </td>
            <td style="width:50%;height: 85mm;vertical-align: top;padding-left: 5mm;">

<table style="width: 100%; height: 20mm; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                            <tr>
                                <td style="vertical-align: middle; width: 15mm;">
                                    <?= ($data['logoBase64'] ? '<img src="' . $data['logoBase64'] . '" style="max-height: 14mm; max-width: 35mm;">' : 'LOGO') ?>
                                </td>
                                <td style="vertical-align: top; color: #333; line-height: 1.2;text-align: center;padding-top:2mm;">
                                    <div style="font-weight: bold; font-size: 14pt; margin-bottom: 1mm;">SERVICIO AL CLIENTE</div>
                                    <div style="font-weight: bold;font-size: 11pt;">TEL.: <?= $data['telefono'] ?></div>
                                </td>
                            </tr>
                        </table>

                    <table style="width: 100%; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="padding-top:2mm;vertical-align: middle; width: 15mm;font-size: 11pt;">DESTINATARIO</td>
                            <td style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;"><?= $data['destinatario_parte1'] ?></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;"><?= $data['destinatario_parte2'] ?></td>
                        </tr>
                    </table>
                    <table style="width: 100%; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="padding-top:2mm;vertical-align: middle; width: 15mm;font-size: 11pt;">DIRECCION</td>
                            <td style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;"><?= $data['direccion_parte1'] ?></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;"><?= $data['direccion_parte2'] ?></td>
                        </tr>
                    </table>
                    <table style="width: 100%; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="padding-top:2mm;vertical-align: middle; width: 15mm;font-size: 11pt;">CIUDAD</td>
                            <td style="padding-top:2mm;vertical-align: middle;font-weight: bold;border-bottom:1px solid #000;font-size: 11pt;color:#f00;">GUATEMALA</td>
                        </tr>
                    </table>
                    <table style="width: 100%; border-collapse: collapse;margin-top:2mm;" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="padding-top:2mm;vertical-align: middle; width: 15mm;font-size: 11pt;">

                                <barcode code="<?= $data['codigo_cliente'] ?>" type="QR" size="0.8" height="10" disableborder="1" />

                            </td>
                            <td style="padding-top:2mm;vertical-align: bottom;text-align:center;">
                                <table style="width: 100%; border-collapse: collapse;" cellpadding="5" cellspacing="0">
                                <tr>
                                    <td style="text-align:center;border-top:1px solid #000;font-size: 10pt;">TRANSPORTE</td>
                                </tr>
                                </table>
                            </td>
                        </tr>
                    </table>

            </td>
        </tr>
        </table>
    </div>
</htmlpagefooter>

<sethtmlpageheader name="distinsa-header" value="on" show-this-page="1" />
<sethtmlpagefooter name="distinsa-mifooter" value="on" />


<table class="tabla-bordered" style="width: 100%; border-collapse: collapse;font-size: 7pt;" cellpadding="5" cellspacing="0">
<tr>
    <th style="text-align:left;" width="25mm">CLIENTE</th>
    <td colspan="3"><?= $data['codigo_cliente'] ?></td>
    <th style="text-align:left;" width="25mm">NOMBRE</th>
    <td width="90mm"><?= str_replace('&AMP;', '&', html_entity_decode($data['nombre_cliente'], ENT_QUOTES, 'UTF-8')) ?></td>
</tr>
<tr>
    <th style="text-align:left;vertical-align:top;">NIT</th>
    <td style="vertical-align:top;" colspan="3"><?= $data['nit_cliente'] ?></td>
    <th style="text-align:left;vertical-align:top;">DIRECCIÓN</th>
    <td style="vertical-align:top;"><?= $data['direccion_cliente'] ?></td>
</tr>
<tr>
    <th style="text-align:left;">FECHA PEDIDO</th>
    <td><?= $data['fecha'] ?></td>
    <th style="text-align:left;">ESTADO</th>
    <td><?= $data['estado'] ?></td>
    <th style="text-align:left;vertical-align:top;">VENDEDOR</th>
    <td><?= $data['vendedor'] ?></td>
</tr>
</table>
<table class="tabla-productos tabla-bordered" style="width: 100%; border-collapse: collapse;font-size: 7pt;margin-top:-1px;" cellpadding="5" cellspacing="0">
<tr>
    <th style="text-align:left;width:20mm;">CÓDIGO</th>
    <th style="text-align:left;width:100mm;">DESCRIPCIÓN</th>
    <th style="text-align:right;width:14mm;">CANT</th>
    <th style="text-align:right;width:18mm;">PRECIO</th>
    <th style="text-align:right;width:18mm;">SUBTOTAL</th>
    <th style="text-align:right;width:18mm;">DESCTO</th>
    <th style="text-align:right;width:18mm;">TOTAL</th>
</tr>
<?php
$total_subtotal=0;
$total_descuento=0;
$total_general=0;
if(!empty($data['detalles']) ){
    foreach ($data['detalles'] as $detalle) {
        echo '<tr>';
            echo '<td>' . $detalle['det_cod'] . '</td>';

            echo '<td>' . $detalle['det_descrip'] . '</td>';
            echo '<td style="text-align:right;">' . $detalle['det_cant'] . '</td>';
            echo '<td style="text-align:right;">Q ' . number_format($detalle['det_precio'], 2) . '</td>';
            echo '<td style="text-align:right;">Q ' . number_format($detalle['det_subtotal'], 2) . '</td>';
            echo '<td style="text-align:right;">Q ' . number_format($detalle['det_desc'], 2) . '</td>';
            echo '<td style="text-align:right;">Q ' . number_format($detalle['det_total'], 2) . '</td>';
        echo '</tr>';
        $total_subtotal+= $detalle['det_subtotal'];
        $total_descuento+= $detalle['det_desc'];
        $total_general+= $detalle['det_total'];
    }
}
?>

</table>
<table style="width: 100%; border-collapse: collapse;font-size: 7pt;margin-top:1mm;" cellpadding="0" cellspacing="0">
<tr>
    <td style="width: 134mm;">
        <table class="tabla-bordered" style="width: 100%; border-collapse: collapse;font-size: 7pt;" cellpadding="5" cellspacing="0">
        <tr>
            <th style="width:22mm;text-align:left;">PREPARO</th>
            <td colspan="3" style='color:#f00;'>86 - BODEGA</td>
        </tr>
        <tr>
            <th style="width:22mm;text-align:left;">HORA INICIO</th>
            <td style='color:#f00;'>24/09/2025 09:37:48 AM</td>
            <th style="width:22mm;text-align:left;">HORA FINAL</th>
            <td style='color:#f00;'>24/09/2025 09:37:48 AM</td>
        </tr>
        <tr>
            <th style="width:22mm;text-align:left;">EMPAQUE</th>
            <td colspan="3" style='color:#f00;'>86 - BODEGA</td>
        </tr>
        <tr>
            <th style="width:22mm;text-align:left;">HORA INICIO</th>
            <td style='color:#f00;'>24/09/2025 09:37:48 AM</td>
            <th style="width:22mm;text-align:left;">HORA FINAL</th>
            <td style='color:#f00;'>24/09/2025 09:37:48 AM</td>
        </tr>
        </table>
    </td>
    <td style="width: 72mm;vertical-align:top;">
        <table style="width: 100%; border-collapse: collapse;font-size: 7pt;" cellpadding="5" cellspacing="0">
        <tr>
            <td style="text-align:right;width:18mm;font-weight:bold;">&nbsp;TOTAL</td>
            <td style="text-align:right;width:18mm;border:1px solid #000;font-weight:bold;">Q <?php echo number_format($total_subtotal, 2); ?></td>
            <td style="text-align:right;width:18mm;border:1px solid #000;font-weight:bold;">Q <?php echo number_format($total_descuento, 2); ?></td>
            <td style="text-align:right;width:18mm;border:1px solid #000;font-weight:bold;">Q <?php echo number_format($total_general, 2); ?></td>
        </tr>
        </table>
    </td>
</tr>
</table>

<h4 style="margin-top:2mm;margin-bottom:1mm;">Observaciones:</h4>
<table class="tabla-bordered" style="width: 100%; border-collapse: collapse;font-size: 7pt;margin-top:0mm;" cellpadding="5" cellspacing="0">
<tr>
    <th style="width:25mm;text-align:left;">TELEMARKETING</th>
    <td colspan="3" style='color:#f00;'>Evelyn 09:11 enviar por favor</td>
</tr>
</table>



