<!DOCTYPE html>
<html lang="<?php echo e(app()->getLocale()); ?>">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, user-scalable=no">
    <meta name="description" content="Sistema Integrado">
    <meta name="description" content="Sistema Contable">
    <link media="all" rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <title>Informe Factura Detallado</title>
</head>
<body>
    <div class="container-fluid">
        <div class="row clearfix">
            <table style="width: 100%">
                <tr>
                    <th rowspan="3" style="width: 1%">
                        <img src="<?php echo e($compania->logo); ?>" style="width:55px; float: left; margin-top: 0px">
                    </th>
                    <th style="text-align: center">
                        <span class="bold" style="margin-left: -55px"><?php echo e($compania->razonsocial); ?></span>
                    </th>
                </tr>
                <tr>
                    <th style="text-align: center; font-size: 12px">
                        <span class="bold" style="margin-left: -55px">NIT: <?php echo e($compania->numeroi); ?></span>
                    </th>
                </tr>
                <tr>
                    <th style="text-align: center; font-size: 12px">
                        <span class="bold" style="margin-left: -55px">DIRECCIÓN: <?php echo e($compania->direccion); ?></span>
                    </th>
                </tr>
            </table>
        </div>
        <br/>
        <br/>
        <h4 style="text-align: center; font-size: 14px">DETALLE PAGO FACTURA N° <?php echo e($xpr->numerof); ?></h4>
        <table style="width: 100%; font-size: 10">
            <thead">
                <tr>
                    <th>COD. CATASTRAL</th>
                    <th style="font-weight: 0"><?php echo e($datap->codigo_catastral); ?></th>
                    <th>NOMBRE PREDIO</th>
                    <th style="font-weight: 0" colspan="3"><?php echo e($datap->nombre); ?></th>
                    <th>DIR. PREDIO</th>
                    <th style="font-weight: 0" colspan="3"><?php echo e($datap->direccion); ?></th>
                </tr>
            </thead>
        </table>

        <div class="row clearfix">
            <table style="width: 100%; margin-top: 20px; font-size: 10" class="col-12" >
                <?php list($tf, $tp, $sal) = array(0, 0, 0); ?>
                <thead>
                    <tr>
                        <th style="text-align: center">AÑO</th>
                        <th style="text-align: center">CONCEPTO</th>
                        <th style="text-align: center">VALOR FACTURA</th>
                        <th style="text-align: center">VALOR PAGO</th>
                        <th style="text-align: center">SALDO</th>
                    </tr>
                </thead>

                <tbody style="border-top: 1px solid #000">
                    <?php
                    /*$xinf = DB::table('gr_detalle_factura_predial as gdf')
                        ->leftJoin('gr_detalle_pago_predial as gdp', 'gdp.detallefactura', '=', 'gdf.id_unico')
                        ->leftJoin('gr_concepto_predial as cp', 'gdf.concepto', '=', 'cp.id_unico')
                        ->leftJoin('gr_concepto as c', 'cp.id_concepto', '=', 'c.id_unico')
                        ->where('gdf.factura', $xpr->idf)
                        ->select('cp.anno as anio','c.nombre as concepto','gdf.valor as vf','gdp.valor as vp')
                        ->get();*/
                        //                        var_dump($xinf);
                        $xinf = DB::table('gr_detalle_factura_predial AS gdf')
                        ->select('cp.anno AS anio', 'c.nombre AS concepto', 'gdf.valor AS vf', DB::raw('SUM(gdp.valor) AS vp'))
                        ->leftJoin('gr_detalle_pago_predial AS gdp', 'gdp.detallefactura', '=', 'gdf.id_unico')
                        ->leftJoin('gr_concepto_predial AS cp', 'gdf.concepto', '=', 'cp.id_unico')
                        ->leftJoin('gr_concepto AS c', 'cp.id_concepto', '=', 'c.id_unico')
                        ->where('gdf.factura', $xpr->idf)
                        ->groupBy('c.nombre', 'cp.anno')
                        ->orderBy('cp.anno', 'asc')
                        ->get();
                    ?>
                    <?php $__currentLoopData = $xinf; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php if ($row->vf !=0 ) { 
                            $dif = $row->vf-$row->vp;?>
                        <tr>
                            <td><?php echo e($row->anio); ?></td>
                            <td><?php echo e($row->concepto); ?></td>
                            <td style="text-align: right">$<?php echo e(number_format($row->vf, 0 ,',' ,'.')); ?></td>
                            <td style="text-align: right">$<?php echo e(number_format($row->vp, 0 ,',' ,'.')); ?></td>
                            <td style="text-align: right">$<?php echo e(number_format($dif, 0 ,',' ,'.')); ?></td>
                        </tr>
                        <?php $tf +=$row->vf; $tp+=$row->vp; $sal +=$dif;
                         } ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
                <tfoot style="border-top: 1px solid #000">
                    <tr>
                        <td colspan="2" style="text-align: center; font-weight: 700">TOTAL</td>
                        <td style="text-align: right">$<?php echo e(number_format($tf, 0 ,',' ,'.')); ?></td>
                        <td style="text-align: right">$<?php echo e(number_format($tp, 0 ,',' ,'.')); ?></td>
                        <td style="text-align: right">$<?php echo e(number_format($sal, 0 ,',' ,'.')); ?></td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
</body>
</html>