@extends('layouts.dashboard')

@section('page_title')
  Department
@endsection

@section('page_header_title')
HR
@endsection



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

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

					     <h3 class="card-title">Add Department</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>Code</th>
                          <th>Name</th>
                          <th>Description</th>
                          <th>Status</th>
                          <th>Reg Date</th>
                          <th style="text-align: center;"><i class="dropdown-icon fa fa-cogs"></i></th>
                          
                        </tr>
                      </thead>
                      <tbody>
                      	@isset($department_list)
                          @php($pass_data = [])
                      		@foreach($department_list as $rows)

    @php(
        $pass_data = array(
          'department'                                     => Crypt::encrypt($rows->id),
          $department_label_list['department_code']        => $rows->code,
          $department_label_list['department_name']        => $rows->name,
          $department_label_list['department_description'] => $rows->description,
                       
                        )
                        )
                      			<tr>
                      				<td>{{$loop->iteration}}</td>

                      				<td>{{$rows->code}}</td>

                      				<td>{{$rows->name}}</td>

                      				<td>{{$rows->description}}</td>

                      				<td>
                             @if($rows->status == "Active") 
                <span class="badge badge-success">{{$rows->status}}</span>
                @elseif($rows->status == "Inactive") 
                <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 Department']))
                                      <a onclick="update(event,'{{json_encode($pass_data)}}','form_update_department','md_update_department')" 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.department.modals.add_department')
  @include('hr.department.modals.update_department')

@endsection

@section('page_script')
  
@endsection
