<script src="js/scroll.js"></script>

<div class="row text-center">
    <b>
        <?php if($titulo!="d"): ?>
            <?php echo e($titulo); ?>

        <?php endif; ?>
    </b>
</div>
<div class="table-responsive"><br/>
<table class="table-bordered table-hover fixed" id="tablaReporte">
    <thead>
        <tr>
            <th colspan="2" style="text-align: center; background: #bababa">Cajero</th>
            <th colspan="2" style="text-align: center; background: #FAF834">Fecha</th>
            <th colspan="4" style="text-align: center; background: #FCFB98">Saldo</th>
            <th colspan="3" style="text-align: center; background: #bababa">Otras Operaciones</th>
            <th colspan="2" style="background:#ffffff"></th>
        </tr>
        <tr style="background: #aa4d0e; color:white">
            <th>Caja</th>
            <th>Nombre &nbsp;&nbsp;&nbsp;</th>
            <th>Apertura</th>
            <th>Cierre</th>
            <th>Inicial</th>
            <th>Venta</th>
            <th>Abono</th>
            <th>Final</th>            
            <th>Descuento</th>
            <th>Puntos</th>
            <th>Crédito</th>
            <th>Diferencia&nbsp;&nbsp;&nbsp;</th>
            <th>Estado</th>
        </tr>
    </thead>
    <tbody>
        <?php
            $TCantidad = 0;
            $TDescuento=0;
            $TDiferencia = 0;
            $TApertura = 0;
            $TAbono=0;
            $TPtos=0;
            $TCredito=0;
       ?>
       <?php foreach($reporte as $repor): ?>
    <tr>
       
        <td width="10%"><?php echo e($repor->Nombre_Caja); ?></td>
        <td width="20%"><?php echo e($repor->Nombre); ?></td>       
        <td width="12%" align="right"><?php echo e($repor->FechaApertura); ?></td>
        <td width="12%" align="right"><?php echo e($repor->FechaCierre); ?></td>        
        <td width="10%" align="right"><?php echo e($repor->SaldoInicial_Caja); ?></td>
        <?php if($repor->SaldoFinal_Caja<$repor->SaldoInicial_Caja): ?>
            <td width="10%" align="right"><?php echo e(0); ?></td>
        <?php endif; ?>
        <?php if($repor->SaldoFinal_Caja>=$repor->SaldoInicial_Caja): ?>
        <td width="10%" align="right"><?php echo e($repor->SaldoFinal_Caja-($repor->SaldoInicial_Caja+$repor->Abono)); ?></td>
        <?php endif; ?>
        <td width="12%" align="right"><?php echo e($repor->Abono); ?></td>
        <td width="12%" align="right"><?php echo e($repor->SaldoFinal_Caja); ?></td>
        <td width="12%" align="right"><?php echo e($repor->Descuento); ?></td>
        <td width="12%" align="right"><?php echo e($repor->Puntos); ?></td>
        <td width="12%" align="right"><?php echo e($repor->Credito); ?></td>
        <td width="12%" align="right"><?php echo e($repor->Total-($repor->Descuento+$repor->Puntos+$repor->Credito)); ?></td>
        <td width="10%"><a href="<?php echo e(url('/detciecaja/'.$repor->idecaja)); ?>" target="_blank"> <?php echo e($repor->estado); ?> </a></td>
        <?php
                $TCantidad  += $repor->SaldoFinal_Caja;
                $TDescuento += $repor->Descuento;
                $TDiferencia += $repor->Total;
                $TApertura += $repor->SaldoInicial_Caja;
                $TAbono += $repor->Abono;
                $TPtos += $repor->Puntos;
                $TCredito += $repor->Credito;
                ?>
             
    </tr>    
      <?php endforeach; ?>
    </tbody>
    
    <tfoot>
    <tr>
        <td colspan="13"><br></td>
    </tr>  
    <tr>
        <th colspan="6" style="text-align: right">Total: </th>        
        <th style="text-align: right"><?=$TAbono ?></th>
        <th style="text-align: right"><?=$TCantidad ?></th>
        <th style="text-align: right"><?=$TDescuento ?></th>
        <th style="text-align: right"><?=$TPtos ?></th>
        <th style="text-align: right"><?=$TCredito ?></th>
        <th style="text-align: right"><?=($TDiferencia)-($TDescuento+$TPtos+$TCredito)?></th>
        <th></th>
    </tr>
    <tr>
        <td colspan="13"><br></td>
    </tr>
    </tfoot>
</table>
</div>