@extends('layouts.master')

@section('content')
<section class="content-header"  >
      <h1>
     Users  show
     <small>عرض المستخدمين</small>
      </h1>
      <img   src="{{asset('dist/img/users.png')}}"  alt="User Image" style="width: 200px;height: 150px;position: absolute;top: -9px;z-index: 1;right: 150px;">

    </section>
    <br/>
    @if( auth()->user()->is_superadmin )
    <a href="{{ url('/user/create') }}"  class="btn btn-success">Create New User </a>
    <a href="{{ url('/credential/create') }}"  class="btn btn-success">Create Supplier Credentials</a><br/>
    @else
	    <span>&nbsp;&nbsp;</span>
    @endif
    <br/>
<div class="box" >
            <div class="box-header">
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example1"  class="table table-bordered table-striped">
                <thead>
                <tr>




                  <th style="text-align:center;vertical-align: middle;"> Name - الاسم  </th>
                  <th style="text-align:center;vertical-align: middle;"> Email - Username   </th>
                  <th style="text-align:center;vertical-align: middle;"> Created at - وقت الانشاء   </th>
                  <th style="text-align:center;vertical-align: middle;"> Type - النوع  </th>
                  <th style="text-align:center;vertical-align: middle;"> Actions  </th>
                </tr>
                </thead>
                <tbody>
                 @foreach( $users as $user )   
                
                 
                
                 <tr>
                  
                  <td style="text-align:center; width:50px;word-break: break-word;" >  {{$user->name}} </td>
                  <td style="text-align:center; width:50px;word-break: break-word;">{{$user->email}} </td>



                  <td style="text-align:center; width:50px;word-break: break-word;" >  {{$user->created_at}} </td>

                  <td style="text-align:center; width:50px;word-break: break-word;" >  
                  @if (  $user->is_superadmin ) 
                    <span> Super Admin  </span>
                  @elseif ( $user->is_admin )
                    <span>  Admin  </span>
                  @elseif ( $user->is_supervisor )
                    <span> Suppervisor </span>
                  @elseif ($user->is_supplier )
                    <span>  {{ $user->supplier->name }} </span>
                  @endif
                  </td>

                  <td style="text-align:center; width:50px;word-break: break-word;" > 
                  
                  @if( auth()->user()->is_superadmin )
                  <a   href='{{ $user->is_supplier ? url("/credential/edit/$user->id") : url("/user/edit/$user->id") }}'  > <i class="fa fa-edit" style="font-size:18px"></i> </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  @else
	                  <span>&nbsp;&nbsp;</span>
                  @endif
                  @if( auth()->user()->is_superadmin )
                  <a   href='{{url("/user/delete/$user->id")}}' onclick="return confirm('Are you sure you want to delete this item?');" > <i class="fa fa-trash" style="font-size:18px; color:red"></i>  </a>
                  @else
	                  <span>&nbsp;&nbsp;</span>
                  @endif
                </td>
                </tr>
                @endforeach
                </tbody>
                
              </table>
            </div>
            <!-- /.box-body -->
          </div>

@endsection
