<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 width="95%" class="table-bordered table-hover fixed" id="tablaReporte">
    <thead>
        <tr>
            <th colspan="3" style="text-align: center; background: #bababa">Producto</th>
            <th colspan="2" style="text-align: center; background: #FAF834">Valor</th>
            <th colspan="3" style="text-align: center; background: #bababa">Otros datos</th>
        </tr>
        <tr style="background: #aa4d0e; color:white">
            <th>Código</th>
            <th>Nombre</th>
            <th>Cant.</th>
            <th>Unitario</th>
            <th>Total</th>
            <th>Fecha</th>            
            <th>Usuario</th>
            <th>Cliente</th>
        </tr>
    </thead>
    <tbody>
        <?php            
            $tvalt = 0;
            $tvalu = 0;
        ?>
       <?php foreach($reporte as $repor): ?>       
    <tr>
        <td align="right"><?php echo e($repor->idProducto); ?></td>
        <td align="left">&nbsp;&nbsp;&nbsp;<?php echo e($repor->Nombre_Produc); ?></td>
        <td align="right"><?php echo e($repor->Cantidad); ?></td>
        <?php if($repor->Cantidad>0){ ?>
            <td align="right"><?php echo e($repor->Valor_Total/$repor->Cantidad); ?></td>
        <?php }else{ ?>
            <td align="right">0</td> 
        <?php } ?>
        <td align="right"><?php echo e($repor->Valor_Total); ?></td>
        <td align="right"><?php echo e(date('d-m-Y',strtotime($repor->created_at))); ?></td>
        <td align="left">&nbsp;&nbsp;&nbsp;<?php echo e($repor->Nombres." ".$repor->Apellidos); ?></td>
        <td align="left">&nbsp;&nbsp;&nbsp;<?php echo e($repor->nomcli." ".$repor->apecli); ?></td>
        <?php
            if($repor->Cantidad>0){
                $tvalu += $repor->Valor_Total/$repor->Cantidad;
            }
            $tvalt += $repor->Valor_Total;
        ?>
    </tr>    
      <?php endforeach; ?>
    </tbody>
    
    <tfoot>
        <tr>
          <td colspan="8"><br/></td>
      </tr>
      <tr>
        <th colspan="3" style="text-align: right">Total:</th>
        <th style="text-align: right"><?php echo e($tvalu); ?></th>
        <th style="text-align: right"><?php echo e($tvalt); ?></th>
        <th style="text-align: right" colspan="3" ></th>
      </tr>
      <tr>
          <td colspan="8"><br/></td>
      </tr>
    </tfoot>      
</table>
</div>