@extends('layouts.dashboard')

@section('page_title')
  Leave
@endsection

@section('page_header_title')
HR
@endsection


<style type="text/css">
  div.hid 
  {
  display: none;
  }
</style>


@section('page_body')
{{ Breadcrumbs::render('leave') }}
	<div class="row row-cards row-deck">
  <div class="col-12">
                <div class="card">
                	  <div class="card-header">
					    
				   
					    

      @if(Auth::user()->hasAnyPermission(['All','Add Leave']))
					     <button  class="float-right btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#md_add_leave"><i class="fa fa-plus"></i></button> &nbsp;&nbsp;
               @endif

					     <h3 class="card-title">Add Leave</h3>
					  </div>

                	<div class="card-status card-status-left bg-blue"></div>
                  <div class="table-responsive table-height">
                    <table class="table table-hover table-outline table-vcenter text-nowrap card-table cls_datatable">
                      <thead>
                        <tr>
                          
                          <th>#</th>
                          <th>Employee Name</th>
                          <th>Duration</th>
                          <th>Number Of Hours</th>
                          <th>Type</th>
                          <th>Reason</th>
                          <th>Status</th>
                          <th>Date Created</th>
                          <th style="text-align: center;"><i class="dropdown-icon fa fa-cogs"></i></th>
                          
                        </tr>
                      </thead>
                      <tbody>
                      	@isset($leave_list)
                          @php($pass_data = [])
                      		@foreach($leave_list as $rows)

@php(
  $pass_data = array(
    
    'leave'         => Crypt::encrypt($rows->id),
    
    'employee_name' => $rows->user->name,
    
    'start_date'    => EF::dateHtml($rows->start_date),
    
    'end_date'      => EF::dateHtml($rows->end_date), 
        
    'no_of_hours'   => ($rows->no_of_hours),
        
    'type'          => $rows->type,
        
    'reason'        => $rows->reason,
        
    'status'        => $rows->status,
                       
                        )
    )
            
            <tr>
            
            <td>{{$loop->iteration}}</td>
            <td>{{$rows->user->name}}</td>
            <td>{{EF::dateFormat($rows->start_date)}} - {{EF::dateFormat($rows->end_date)}}</td>
            <td>
              {{($rows->no_of_hours)}}
            </td>
            <td>{{$rows->type}}
            <td>{{$rows->reason}}
            <td>
              @if($rows->status == "Approved") 
                <span class="badge badge-success">{{$rows->status}}</span>
                @elseif($rows->status == "Pending") 
                <span class="badge badge-primary">{{$rows->status}}</span>   
              @endif 
            </td>
            <td>{{EF::dateFormat($rows->created_at)}}</td>
            
            <td class="text-center">

              <div class="item-action dropdown">
                <a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fa fa-list-ul"></i></a>
              <div class="dropdown-menu dropdown-menu-right">
                <a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fa fa-cogs"></i> Action</a>
               <div class="dropdown-divider"></div>

                  @if(Auth::user()->hasAnyPermission(['All','Update Leave']))
                    <a onclick="update(event,'{{json_encode($pass_data)}}','form_update_leave','md_update_leave')" href="javascript:void(0)" class    ="dropdown-item"><i class="       dropdown-icon fa fa-edit"></i>   Update </a>
                  @endif
                                     
                                     
                                     
                </div>
                </div>
              </td>
            </tr>


        @endforeach
      @endisset	
                        
      </tbody>
    </table>
    </div>
    </div>
 </div>
 </div>

@endsection

@section('page_modal')
  @include('hr.leave.modals.add_leave')
  @include('hr.leave.modals.update_leave')

@endsection

@section('page_script')
  @include('hr.scripts.leave')
@endsection
