@extends('layouts.yellow')

@section('title')
{{__('view-patients.titleView')}}
@endsection

@section('content')
<div class="container-lg">
  <div class="row">
    <div class="col-12">
      <div class="card bg-soft">
        <div class="card-header bg-transparent">
          <div class="float-start">
            <h3 class="card-title">{{__('view-patients.titleViewDoctors')}}</h3>
          </div>
          <div class="float-end">
            <a href="{{URL::to('/admin/create-users?newDoctor=true')}}" class="btn btn-primary">
              {{__('view-patients.createUser')}}
            </a>
          </div>
        </div>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>{{__('user.name')}}</th>
                  <th>{{__('user.email')}}</th>
                  <th>{{__('user.role')}}</th>
                  <th>{{__('doctor.signature.title')}}</th>
                  <th>{{__('common.actions')}}</th>
                </tr>
              </thead>
              <tbody>
                @foreach($data as $user)
                <tr>
                <td>{{$user->profile()->first()->firstname}} {{$user->profile()->first()->lastname}}</td>
                <td>{{$user->email}}</td>
                  <td>{{$user->getRolName()}}</td>
                  <td>
                    @if($user->hasDigitalSignature())
                      <span class="badge bg-success">{{__('doctor.dashboard.hasSignature')}}</span>
                    @else
                      <span class="badge bg-warning">{{__('doctor.dashboard.noSignature')}}</span>
                    @endif
                  </td>
                  <td>
                    <a href="{{URL::route('/admin/update-doctor',['id' => $user->id])}}" class="btn btn-sm btn-warning">
                      <i class="fa fa-edit"></i>
                    </a>
                    @if(App\Models\User::isADoctor($user) && Auth::user()->id === $user->id)
                    <a href="{{URL::route('doctor.signature')}}" class="btn btn-sm btn-info">
                      <i class="fa fa-signature"></i>
                    </a>
                    @endif
                  </td>
                </tr>
                @endforeach
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
@endsection