<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <script type="text/javascript">
        function ver(detfac) {
            var elElemento=document.getElementById(detfac);
                if(elElemento.style.display == 'block') {
                   elElemento.style.display = 'none';
                } else {
                   elElemento.style.display = 'block';
                }
        }
    </script>
    
	<div class="row">
		<div class="col-md-8 col-md-offset-2">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <center><a href="javascript:void(0);" onclick="ver('detfac')" style="color: #222">Detallado de factura:</a><b> <?php echo e($fac); ?></b>. <br>Crédito del Cliente: <b><?php echo e($ccli." ".$dcli); ?></b></center>
                        </div>
                        <div class="row col-md-12" ><br></div>
                        <div class="col-md-12" id="detfac" style="display:none;">
                            <div class="form-group">
                                <div class="col-md-3 control-label"> 
                                    <?php echo Form::label('factura','Factura detallada'); ?>

                                </div>
                                <div class="col-md-10 table-responsive">
                                    <?php
                                        $facdett="";
                                        $valtu=0;
                                        $valtt=0;
                                        $valtd=0;
                                        
                                        echo "<table border='1' class='table table-striped table-hover table-bordered'><tr><th colspan='3' class='text-center'>Producto</th><th colspan='3' class='text-center'>Valor</th></tr><tr class='text-info'><th>Código</th><th>Nombre</th><th>Cant.</th><th>Unitario</th><th>Total</th><th>Descuento</th></tr>";
                                        foreach($facdet as $facdet){
                                            $facdett="<tr><td>&nbsp;$facdet->idProducto&nbsp;</td><td>&nbsp;&nbsp;&nbsp;$facdet->Nompro</td><td align='right'>$facdet->Cantidad</td><td align='right'>".$facdet->Valor_Total/$facdet->Cantidad."</td><td align='right'>$facdet->Valor_Total</td><td align='right'>$facdet->descuento</td></tr>";
                                            echo $facdett;
                                            
                                            $valtu+=$facdet->Valor_Total/$facdet->Cantidad;
                                            $valtt+=$facdet->Valor_Total;
                                            $valtd+=$facdet->descuento;
                                        }
                                        
                                        echo "<tr><td colspan='3' align='right'>Total: </td><td align='right'>$valtu</td><td align='right'>$valtt</td><td align='right'>$valtd</td></tr></table>"
                                    ?>
                                </div>
                            </div>
                        </div>
                        <div class="row col-md-12" ><br></div>
                        
                            <div class="panel-body">
                                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                                    <ul class="nav navbar-nav navbar-right">				
                                      <!--  <li><a href="<?php echo e(url('/')); ?>"> Opciones </a></li>--> 
                                       <!-- <li><a href="<?php echo e(url('/Mod_usuario')); ?>"> Atras </a></li>-->
                                    </ul>
                                </div>
                                <?php if(count($errors) > 0): ?>
                                        <div class="alert alert-danger">
						<strong>Whoops!</strong> Hay algunos problemas!!!.<br><br>
                                                    <ul>
							<?php foreach($errors->all() as $error): ?>
                                                            <li><?php echo e($error); ?></li>
							<?php endforeach; ?>
                                                    </ul>
					</div>
				    <?php endif; ?>                                
                                        
                                    <div class="row table-responsive">
                                        <div class="col-md-12 control-label"> 
                                            <?php echo Form::label('abono','Abono detallado'); ?>

                                        </div>
                                        
                                        <table class="table table-striped table-hover table-bordered">
                                            <tr>
                                                <th class="text-center">Cuota</th>
                                                <th class="text-center" colspan="2">Valor</th>
                                                <th class="text-center">Usuario</th>
                                                <th class="text-center" colspan="2">Fecha</th>
                                            </tr>
                                            
                                            <tr class="text-info">
                                                <th class="text-center">#</th>                                                
                                                <th class="text-center">Abonado</th>
                                                <th class="text-center">Restante</th>
                                                <th class="text-center">Recibe</th>
                                                <th class="text-center">Recibido</th>
                                                <th class="text-center">Observación</th>
                                            </tr>
                                            
                                            <?php $i=0; ?>
                                            
                                            <?php foreach($crecli as $crecli): ?>
                                                <?php $i=$i+1;?>
                                                <tr>
                                                  <td class="text-right"><?php echo e($i); ?></a></td>
                                                  <td class="text-right"><?php echo e($crecli->creabo); ?></td>
                                                  <td class="text-right"><?php echo e($crecli->creres); ?></td>                                                  
                                                  <td class="text-right"><?php echo e($crecli->Nombres); ?> <?php echo e($crecli->Apellidos); ?></td>
                                                  <td class="text-right"><?php echo e($crecli->created_at); ?></td>
                                                  <td class="text-left"><?php echo e($crecli->obspag); ?></td>
                                                </tr>
                                            <?php endforeach; ?>
                                                <tr><td colspan="6"></td></tr>
                                                <tr>
                                                  <td class="text-right"><b>Total:</b></td>
                                                  <td class="text-right"><?php echo e($sumabo); ?></td>
                                                  <td class="text-right"><?php echo e($sumres); ?></td>                                                  
                                                  <td></td>
                                                  <td></td>
                                                  <td></td>
                                                </tr>
                                                
                                        </table>                                        
                                    </div>                               
			</div>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>