<!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>
    <link rel="stylesheet" href="<?php echo base_url . 'Assets/css/reporte.css'; ?>">
</head>

<body>
    <table id="datos-empresa">
        <tr>
            <td class="logo">
                <img src="<?php echo base_url . 'Assets/img/logo.png'; ?>" alt="" width="150">
            </td>
            <td class="info-empresa">
                <p><b><?php echo $data['empresa']['nombre']; ?></b></p>
            </td>
        </tr>
    </table>

    <h2 style='text-align:center;'>ESTADO DE CUENTA</h2>

    <P>
        <strong>CLIENTE:</strong> <?php echo $data['cliente']['id'] ?><br/>
        <strong>NOMBRE:</strong> <?php echo $data['cliente']['nombre'] ?>
    </P>


    <table cellspacing=0>
        <thead>
            <tr>
                <th class="text-right">DOCUMENTO</th>
                <th class="text-left">FECHA</th>
                <th class="text-right">CARGO</th>
                <th class="text-right">ABONO</th>
                <th class="text-left">REFERENCIA</th>
                <th class="text-right">SALDO</th>
            </tr>
            <tr class='blanco'>
                <th colspan='6'>&nbsp;</th>
            </tr>            
        </thead>
        <tbody>
            <?php
            $saldo = 0;
            $total_cargo = 0;
            $total_saldo = 0;
            foreach ($data['detalle'] as $producto) {
                $saldo += $producto['CARGO']+$producto['ABONO'];
                $total_cargo += $producto['CARGO'];
                $total_saldo += $producto['ABONO'];
                ?>
                <tr>
                    <td class="text-right"><?php echo $producto['DOCUMENTO']; ?></td>
                    <td><?php echo date('d/m/Y', strtotime($producto['FECHA'])); ?></td>
                    <td class="text-right"><?php echo number_format($producto['CARGO'],2,'.',','); ?></td>
                    <td class="text-right"><?php echo number_format($producto['ABONO'],2,'.',','); ?></td>
                    <td class="text-left"><?php echo $producto['REFERENCIA']; ?></td>
                    <td class="text-right"><?php echo number_format($saldo,2,'.',','); ?></td>
                </tr> 
            <?php } ?>
        </tbody>
        <tfoot>
            <tr>
                <th></th>
                <th></th>
                <th class="text-right fborder"><?php echo number_format($total_cargo,2,'.',','); ?></th>
                <th class="text-right fborder"><?php echo number_format($total_saldo,2,'.',','); ?></th>
                <th class="text-right fborder"></th>
                <th class="text-right fborder"><?php echo number_format($saldo,2,'.',','); ?></th>
            </tr>
            <tr>
                <th colspan='2'></th>
                <th class="text-right fdborder" colspan='4'>&nbsp;</th>
            </tr>            
        </tfoot>
    </table>

</body>

</html>

<style type='text/css'>
THEAD TR TH {
    background: #ccc;
    border-top: 1px solid #000;
    padding-left:5mm;
    padding-right:5mm;
    font-size:3mm;
}


THEAD TR.blanco TH {
    background: #fff;
    border-bottom: 1px solid #000;
    height:2px;
    font-size:2px;
    line-height:2px;
}
.text-left { text-align:left; }
.text-right { text-align:right; }
TBODY TR TD {
    font-size:3mm;
    padding-top:0.5mm;
    padding-bottom:0.5mm;
    padding-left:5mm;
    padding-right:5mm;
}
TFOOT TR TH {
    padding-left:5mm;
    padding-right:5mm;
    font-size:3mm;
}
TFOOT TR TH.fborder {
    border-top: 1px solid #000;
}
TFOOT TR TH.fdborder {
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    height:2px;
    font-size:2px;
    line-height:2px;
}
</style>