@extends('Layout.employees_master')

@section('title', 'Employees')

@section('header-include')
<link rel="stylesheet" href="/js/select3/bootstrapselect.min.css" type="text/css"/>
<link rel="stylesheet" href="/js/select3/bootstrap.min.css" type="text/css"/>
<style>
form {
    border-radius: 5px; 
    width:100%;   
    background-color: #FFFFFF;
    overflow: hidden;
  }

  p span {
    color: #F00;
  }

  p {
    margin: 0px;
    font-weight: 500;
    line-height: 2;
    color:#333;
  }

  a {
    text-decoration:inherit
  }


  .form-group {
    overflow: hidden;
    clear: both;
  }
  .form-control {
      
      position:relative;
      clear: both;    
      margin-top: 2px;
      display:inline-inline;    
      margin-right: 10px;
  }
  .accordion {
    background-color: #eee;
    color: #444;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 15px;
    transition: 0.4s;
  }
  .panel-row {
    padding: 0 18px;
    background-color: white;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
  }
  ul {
    list-style-type: none;
  }
</style>
@endsection
@section('content')
<section id="content">    
      <section class="scrollable padder">
        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
        <li><a href="/kinetic"><i class="fa fa-home"></i> Home</a></li>
          <li><a href="{{route('employees.index')}}">Employees</a></li>
          <li><a href="{{route('employees.edit',$employee->id)}}">Edit Employees</a></li>
          <li class="active">Emergency Contacts</li>
        </ul>   
        @include('Layout.errors')
        @include('Layout.messages')  
            <div class="container-fluid"  style="margin-bottom:0px;">  
                <div class=col-md-3 id=tabLinks style="width:13.5%">
                  <ul class="list-group">
                    <li class="list-group-item active" ><a href="{{ route('employees.edit',$employee->id) }}">Employee Info</a></li> 
                    <li class="list-group-item "><a href="{{route('personal',$employee->id)}}">Personal</a></li>               
                    <li class="list-group-item "><a href="{{route('salary',$employee->id)}}}">Salary</a></li>  
                    <li class="list-group-item "><a href="{{route('contact',$employee->id)}}}">Contact</a></li>                                                                            
                  </ul>
                </div> 
                <div class=col-md-6  style="width:86.5%;"> 
                  <div class="table-responsive" style="padding:0px 5px 5px 10px">
                      <table class="table table-striped m-b-sm datagrid">
                      @if(count($emergency)>0)
                      <thead>
                        <tr>
                          <th>Name</th>
                          <th>Phone No.</th>
                          <th>Email</th>
                          <th>Relation</th>
                          <th>Action</th>
                        </tr>
                      </thead>
                      <tbody>
                      @foreach($emergency as $contact)
                      <tr class="emergency_contact{{$emergency->id}}">
                        <td>{{$contact->name}}</td>
                        <td>{{$contact->phone_no}}</td>
                        <td>{{$contact->email}}</td>
                        <td>{{$contact->relation}}</td>
                        <td>
                        <form action="{{ route('employees.store') }}" method="post" style=position:relative;float:right>
                            @csrf
                            @method('DELETE')
                            <a href="" ><span class="btn btn-default"><i class="fa fa-edit no-margin"></i></span></a>  
                            <button data-toggle="tooltip" data-placement="top" title="Delete" type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this item?');"><i class="fa fa-trash no-margin"></i></button>
                        </form>
                        </td>
                      </tr>  
                      @endforeach
                      @else                     
                      <tr>
                          <td colspan="2" class="text-center">Nothing to display</td>
                      </tr>
                      @endif
                      </tbody>
                      </table>
                  </div> 
                </div>
            </div>
      </section>
</section>        
@endsection
@section('footer-include')
<script src="/js/select3/bootstrapselect.min.js"></script>
<script src="/js/select3/bootstrap.min.js"></script>
@endsection

@section('j-script')
<!-- Jquery -->
<script>
$("input").click(function(){
        $(this).next().show();
        $(this).next().hide();
    });




// Javascript for rendering tablinks

  $('#tabLinks').on('click', '.list-group a', function (e) {
  clickEvent = true;
  $('.list-group li').removeClass('active');
  $(this).parent().addClass('active');
  localStorage.setItem('tab', $(e.currentTarget).attr('href'));
  });
  $(function() {
  var slide = localStorage.getItem('tab');
  console.log(slide);
  if (slide) {
    $("a[href='" + slide + "']").click().tab('show');
  }
  });
  function tabswitch(item) {
    var divs = document.getElementsByClassName("tabcontainer");
    for (var i = 0; i < divs.length; i++) {
      divs[i].style.display = 'none';
    }
    var myDiv = item.href;
    var target = myDiv.split("#");
    document.getElementById(target[1]).style.display = "inline";
  }

// Javascript for rendering input fields on set conditions

  function inputfieldVisibility(that) {
    if(that.value == "national") {            
      document.getElementById("nationaldocument").style.display = "inline";
      document.getElementById("passportdocument").style.display = "none";
      document.getElementById("militarydocument").style.display = "none";
    }else if(that.value == "passport") {            
      document.getElementById("passportdocument").style.display = "inline";
      document.getElementById("militarydocument").style.display = "none";
      document.getElementById("nationaldocument").style.display = "none";
    }else if(that.value == "military") {            
      document.getElementById("militarydocument").style.display = "inline";
      document.getElementById("nationaldocument").style.display = "none";
      document.getElementById("passportdocument").style.display = "none";
    }else {
      document.getElementById("nationaldocument").style.display = "none";
      document.getElementById("passportdocument").style.display = "none";
      document.getElementById("militarydocument").style.display = "none";  
    }      
  } 
  function ethnicVisibility(that) {
    if (that.value == "kenyan") {            
      document.getElementById("ethnicfield").style.display = "inline";
    }else{
      document.getElementById("ethnicfield").style.display = "none";
    }       
  }
  function durationfieldVisibility(that) {
        if (that.value == "casual"|| that.value == "probation" || that.value =="contract"|| that.value == "temporary") {
            document.getElementById("duration").style.display = "block";
        } else {
            document.getElementById("duration").style.display = "none";
        }
    }
    function relationfieldVisibility(that) {
        if (that.value == "other") {
            document.getElementById("other_relation").style.display = "block";
        } else {
            document.getElementById("other_relation").style.display = "none";
        }
    }

    $(document).on('ready', function(){
  });
       
</script>
@endsection



