@extends('admin.base')

@section('content')
<div class="row page-heading">
  <div class="col-md-12 h3">{{$user->name}}</div>
</div>
<a href="{{nUrl('admin', 'reset_user', ['user' => $user->id])}}">
  Resetear Clave
</a>
<div class="section-heading row">
  <div class="col-md-6 h4">Roles</div>
  <div class="col-md-6 h4 text-right"><a href="{{url('', ['p' => 'admin', 'a' => 'add_user_role', 'user' => $user->id])}}"><span class="glyphicon glyphicon-plus"></span></a></div>
</div>
<table class="table">
  @foreach ($user->roles() as $role)
  <tr>
    <td><a href="{{nUrl('admin', 'role', ['role' => $role->id])}}">{{$role->description}}</a></td>
    <td><a href="{{url('', ['p' => 'admin', 'a' => 'remove_user_role', 'user' => $user->id, 'role' => $role->id])}}"><span class="glyphicon glyphicon-minus"></span></a></td>
  </tr>
  @endforeach
</table>
<div class="row section-heading">
  <div class="col-md-6 h4">Permisos</div>
  <div class="col-md-6 h4 text-right"><a href="{{nUrl('admin', 'add_user_permissions', ['user' => $user->id])}}"><span class="glyphicon glyphicon-plus"></span></a></div>
</div>
@if ($user->permissions())
<table class="table">
  <thead>
    <tr>
      <th>P&aacute;ginas</th>
      <th>Rol</th>
      <th>Acceso</th>
    </tr>
  </thead>
  <tbody>
    @foreach ($user->permissions() as $permission)
    <tr>
      <td>
        {{$permission->action()->description}}
      </td>
      <td>
        @if ($permission->type == 2)
        {{$permission->who()->description}}
        @endif
      </td>
      <td>
        @if ($permission->all == 0)
          @if ($permission->access == 1)
            Permitido
          @else
            Denegado
          @endif
        @else
          Permitido
        @endif
      </td>
    </tr>
    @endforeach
  </tbody>
</table>
@endif
@endsection
