<table border="1">
   <tr>
        <td width="60%">
            <table style="font-size:10px;">
                <tr>
                    <td colspan="4" style="border-bottom: 1px solid #000;"><b>Valor en letras:</b> 
                        <?php echo isset($totales['totalLetras']) ? $totales['totalLetras'].'<br>' : ''; ?> 
                        <?php echo isset($totales['totalIVAretenidoLetras']) ? $totales['totalIVAretenidoLetras'].'<br>' : ''; ?>
                    </td> 
                </tr>
                <!--Condicion de la operacion-->
                <?php if(isset($totales['condicionOperacion'])):?>
                <tr>
                    <td colspan="4" style="border-bottom: 1px solid #000;"><b>Condici&oacute;n de la operaci&oacute;n:</b> <?php echo $totales['condicionOperacion'];?> <br></td> 
                </tr>
                <?php endif;?>
                <tr>
                    <td colspan="4" style="border-bottom: 1px solid #000;"><b>Notas:</b> <?= isset($extension['observaciones']) ? nl2br($extension['observaciones']) : '';?><br></td>
                </tr>
                <?php if($tipoDte == '11' && isset($extension['nombRecibe'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000;"><b>Responsable del receptor:</b></td>
                    <td style="border-bottom: 1px solid #000;"><?= isset($extension['nombRecibe']) ? $extension['nombRecibe'] : '';?></td>
                    <td style="border-bottom: 1px solid #000;"><b> Documento No: </b></td>
                    <td style="border-bottom: 1px solid #000;"><?= isset($extension['docuRecibe']) ? $extension['docuRecibe'] : '';?></td>
                </tr>
                <?php endif;?>
                <?php if($tipoDte == '11' && isset($extension['nombEntrega'])):?>
                <tr>
                    <td><b> Responsable del emisor:</b></td>
                    <td><?= isset($extension['nombRecibe']) ? $extension['nombEntrega'] : '';?></td>
                    <td><b> Documento No: </b></td>
                    <td><?= isset($extension['docuEntrega']) ? $extension['docuEntrega'] : '';?></td>
                </tr>
                <?php endif;?>
            </table>
        </td>
        <td width="40%">
            <table style="font-size:10px;">
                <tr>
                    <td colspan="3" style="text-align:center"><b>Resumen de operaciones:</b></td>
                </tr>
                <!--Total Sujeto Retencion-->
                <?php if(isset($totales['totalSujetoRetencion'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Total sujeto a retenci&oacute;n:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right" width="24%"> <?php echo number_format($totales['totalSujetoRetencion'], 2);?></td> 
                </tr>
                <?php endif;?>
                <!-- Total IVA Retenido-->
                <?php if(isset($totales['totalIVAretenido'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Total IVA retenido:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right" width="24%"> <?php echo number_format($totales['totalIVAretenido'], 2);?></td>
                </tr>
                <?php endif;?>
                <!--sumas-->
                <?php if(isset($totales['subTotalVentas'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Sumatoria de operaciones:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right" width="24%"> <?php echo number_format($totales['subTotalVentas'], 2);?></td>
                </tr>
                <?php endif;?>
                <!--Subtotal compra-->
                <?php if(isset($totales['totalCompra'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Total compra:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right" width="24%"> <?php echo number_format($totales['totalCompra'], 2);?></td>
                </tr>
                <?php endif;?>

                <!--Tributos-->
                <?php if(isset($totales['tributos']) && $totales['tributos'] && count($totales['tributos'])): foreach($totales['tributos'] as $tributo):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="10%"> <?php echo $tributo['codigo'];?></td>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="65%"> <?php echo $tributo['descripcion'];?></td>
                    <td style="border-bottom: 1px solid #000; text-align: right" width="24%"> <?php echo number_format($tributo['valor'], 2, '.', '');?></td>
                </tr>
                <?php endforeach; endif;?>
                <!--<tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Sub-total:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right" width="24%"> 45.67</td>
                </tr>-->
                <?php if(isset($totales['ivaPercibido'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">IVA Percibido:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"> 0.00</td>
                </tr>
                <?php endif;?>
                <?php if(isset($totales['ivaRete1'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">IVA Retenido:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"> <?php echo number_format($totales['ivaRete1'], 2, '.', '');?></td>
                </tr>
                <?php endif;?>
                <?php if(isset($totales['reteRenta'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Retenci&oacute;n renta:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"> <?php echo number_format($totales['reteRenta'], 2, '.', '');?></td>
                </tr>
                <?php endif;?>
                <?php if(isset($totales['montoTotalOperacion'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Monto total de operaci&oacute;n:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"> <?php echo number_format($totales['montoTotalOperacion'], 2, '.', '');?></td>
                </tr>
                <?php endif;?>
                <?php if(isset($totales['totalNoGravado'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Otros Montos no Afectos:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"> <?php echo number_format($totales['totalNoGravado'], 2, '.', '');?></td>
                </tr>
                <?php endif;?>
                <!--<tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2">Descuentos:</td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"> 0.00</td>
                </tr>-->
                <?php if(isset($totales['totalPagar'])):?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2"><b>TOTAL A PAGAR:</b></td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"><b> <?php echo number_format($totales['totalPagar'], 2, '.', '');?></b></td>
                </tr>
                <?php elseif(isset($totales['valorTotal'])): ?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2"><b>TOTAL:</b></td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"><b> <?php echo number_format($totales['valorTotal'], 2, '.', '');?></b></td>
                </tr>
                <?php elseif(isset($totales['montoTotalOperacion'])): ?>
                <?php 
                    $totalOperacion = $totales['montoTotalOperacion'] ?? 0 - $totales['ivaRete1'] ?? 0;    
                ?>
                <tr>
                    <td style="border-bottom: 1px solid #000; border-right: 1px solid #000;" width="75%" colspan="2"><b>TOTAL:</b></td>
                    <td style="border-bottom: 1px solid #000; text-align: right;" width="24%"><b> <?php echo number_format(($totalOperacion), 2, '.', '');?></b></td>
                </tr>
                <?php endif;?>
            </table>
        </td>
   </tr>
</table>