@extends('layout.base')

@section('content')
<div class="page-heading">
  <h2>Comisiones - {{$proyecto->descripcion}}</h2>
</div>
<table class="table table-striped">
  <thead>
    <tr>
      <th>Departamento</th>
      <th>Propietario</th>
      <th class="text-center">Estacionamientos</th>
      <th class="text-center">Bodegas</th>
      <th colspan="2" class="text-center">Precio</th>
      <th colspan="2" class="text-center">Comisi&oacute;n</th>
      <th>Operador</th>
    </tr>
    <tr>
      <th colspan="4"></th>
      <th class="text-right">Promesa</th>
      <th class="text-right">Neto</th>
      <th class="text-center">%</th>
      <th class="text-right">UF</th>
    </tr>
  </thead>
  <tbody>
    @foreach ($ventas as $venta)
    <tr>
      <td><a href="{{nUrl('ventas', 'show', ['venta' => $venta->id])}}">{{$venta->unidad()->descripcion}}</a></td>
      <td>{{$venta->propietario()->nombreCompleto()}}</td>
      <td class="text-center">{{implode(' - ', $venta->propiedad()->estacionamientos('array'))}}</td>
      <td class="text-center">{{implode(' - ', $venta->propiedad()->bodegas('array'))}}</td>
      <td class="text-right">{{format('ufs', $venta->valor_uf, null, true)}}</td>
      <td class="text-right">{{format('ufs', $venta->valorCorredora(), null, true)}}</td>
      <td class="text-center">1,5 %</td>
      <td class="text-right">{{format('ufs', $venta->valorCorredora() * 1.5 / 100, null, true)}}</td>
      <td>{{($venta->agente != 0 and $venta->agente()->agente != 1) ? $venta->agente()->agente()->descripcion : ''}}</td>
    </tr>
    @endforeach
    <tr>
      <td colspan="4"><b>Total</b></td>
      <td class="text-right"><b>{{format('ufs', $totales->precio, null, true)}}</b></td>
      <td class="text-right"><b>{{format('ufs', $totales->neto, null, true)}}</b></td>
      <td class="text-center"><b>1,5 %</b></td>
      <td class="text-right"><b>{{format('ufs', $totales->comision, null, true)}}</b></td>
  </tbody>
</table>
<!-- <a href="{{nUrl('informes', 'comisiones_xlsx', ['ventas' => implode(',', $ids)])}}">Excel</a> -->
@endsection
