@extends('layouts.master')

@section('content')
<style type="text/css">
  .list-group-item{
    height: auto !important;
    display: flex !important;
    padding: 10px 5px;
  }
  .list-group-item b i{
    margin-right: 5px;
    border: 1px solid #c0c0c0;
    border-radius: 50%;
    padding: 4px;
    color: #333 !important;
  }
  .list-group-item b i:hover{
    color: #23B7E5 !important;
  }
</style>
 <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
 

    <!-- Main content -->
    <section class="content">
        <header class="panel-heading" style="height:50px;">
            <div class="pull-left">
                {{$title}}
            </div>
            <div>
                 @if(\Auth::user()->utype==1)
                    <a style="margin-right:3px" href="{{ url('admin/employee') }}" class="btn btn-sm btn-info pull-right"><i class="fa fa-list"></i> Employee List</a>
                     <a style="margin-right:3px"  href="{{ url('admin/employee/edit_employee') }}/{{ $employee->id }}" class="btn btn-sm btn-info pull-right"><i class="fa fa-edit"></i> Employee Edit</a> <br><br>
                @endif
            </div>
        </header><br/>
      <div class="row">
        <div class="col-md-4">

          <!-- Profile Image -->
          <div class="box box-primary">
            <div class="box-body box-profile">
                <div class="text-center">
                    <img class="profile-user-img img-circle" width="150" height="140" src="{{ asset('assets/document/employee/'.$employee->image) }}" alt="Employee Photo">
                </div>
             
              <h3 class="profile-username text-center">{{$employee->name}} </h3>
              <p class="text-muted text-center">{{$emp_details->designation->name}}</p>
              <p class="text-center">
                @foreach($emp_star as $row)
                    <i style="color:#f39c12 " class="fa fa-star"></i>
                @endforeach
              </p>

              <ul class="list-group list-group-unbordered">
                <li class="list-group-item">
                  <b class="pull-left">Joining Date : </b> <span class=""> {{ date("d-m-Y", strtotime($emp_details->joining_date)) }}</span>
                </li>
                <li class="list-group-item">
                  <b>Date of birth : </b> <span class=""> {{ date("d-m-Y", strtotime($employee->birth_day)) }}</span>
                </li>
                <li class="list-group-item">
                  <b>Salary Grade : </b> <span class=""> {{ $emp_details->grade->name }}</span>
                </li>
                <li class="list-group-item">
                  <a href="mailto:{!! @$employee->personal_email !!}" target="_blank"><b><i class="fa fa-envelope"></i></b></a> <span class="pull-right">{{ @$employee->personal_email }}</span>
                </li>
                <li class="list-group-item">
                  <a href="tel:{!! @$employee->phone !!}" target="_blank"><b><i class="fa fa-phone"></i></b></a> <span class="pull-right">{{ @$employee->phone }}</span>
                </li>
                <li class="list-group-item">
                  <a href="tel:{!! @$employee->phone2 !!}" target="_blank"><b><i class="fa fa-phone"></i></b></a> <span class="pull-right">{{ @$employee->phone2 }}</span>
                </li>
                <li class="list-group-item">
                  <a href="http://{!! @$employee->facebook !!}" target="_blank"><b><i class="fa fa-facebook"></i></b></a> <span class="pull-right">{{ @$employee->facebook }}</span>
                </li>
                <li class="list-group-item">
                  <a href="http://{!! @$employee->skype !!}" target="_blank"><b><i class="fa fa-skype"></i></b></a> <span class="pull-right">{{ @$employee->skype }}</span>
                <li class="list-group-item">
                  <a href="http://{!! @$employee->linkedin !!}" target="_blank"><b><i class="fa fa-linkedin"></i></b></a> <span class="pull-right">{{ @$employee->linkedin }}</span>
                </li>
              </ul>

            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->

          <!-- About Me Box -->
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">About Me</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <strong><i class="fa fa-book margin-r-5"></i> Education</strong>

              <p class="text-muted">
                {{@$last_education->education_name->level_name}} from {{@$last_education->institute_name}} ({{@$last_education->major}}) - {{ date("Y", strtotime(@$last_education->passing_year)) }}
              </p>
              <hr>
              <strong><i class="fa fa-map-marker margin-r-5"></i> Present Address</strong>
              <p class="text-muted">{{ @$employee->present_address }}</p>

              <strong><i class="fa fa-map-marker margin-r-5"></i> Permanent Address</strong>
              <p class="text-muted">{{ @$employee->per_address }}</p>

              <hr>
              <strong><i class="fa fa-file-text-o margin-r-5"></i> Notes</strong>
              <p>{{ @$employee->note }}</p>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
        <div class="col-md-8">
             <div class="box">
            <div class="box-header with-border" style="background: #ddd">
              <h3 class="box-title"><i class="fa fa-history"></i> Employment History</h3>
                @if($emp_details->type !=4)
                <div class="pull-right" style="margin-top: 6px;margin-right: 10px;">
                    <input type="hidden" id="emp_id_div" class="hidden" value="{{ $employee->id }}" />
                    <button type='button'class='btn btn-sm btn-info pull-right rejoining' data-toggle="modal" data-target="#rejoining" title='Rejoining'><i class="fa fa-power-off"></i> Rejoining</button>
                </div>
                @endif
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th width="15%">Date</th>
                            <th width="35%">Designation</th>
                            <th>Grade</th>
                            <th>Type</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($emp_history as $key => $epm_h)
                        <tr>
                            <td>{{ ++$key }}</td>
                            <td>{{ date("d-m-Y", strtotime(@$epm_h->joining_date)) }}</td>
                            <td>{{ @$epm_h->designation->name }}</td>
                            <td>{{ @$epm_h->grade->name }}</td>
                            <td>
                                @if(@$epm_h->type==1)
                                <label class="label label-info">Joining</label>
                                @elseif($epm_h->type==2)
                                <label class="label label-success">Promotion</label>
                                @elseif($epm_h->type==3)
                                <label class="label label-info"></label>
                                @elseif($epm_h->type==4)
                                <label class="label label-primary">Rejoining</label>
                                @endif
                            </td>
                        </tr>
                    @endforeach
                  </tbody>
                </table>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <!-- /.col -->
        <div class="col-md-8">
             <div class="box">
            <div class="box-header with-border" style="background: #ddd">
              <h3 class="box-title"><i class="fa fa-university"></i> Academic Information</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th width="15%">Education</th>
                            <th width="35%">Institute</th>
                            <th>Group</th>
                            <th>CGPA</th>
                            <th width="15%">Passing Year</th>
                            <th>Duration</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($employee_education as $key => $emp_edu)
                        <tr>
                            <td>{{ ++$key }}</td>
                            <td>{{ $emp_edu->education_name->level_name }}</td>
                            <td>{{ $emp_edu->institute_name }}</td>
                            <td>{{ $emp_edu->major }}</td>
                            <td>{{ $emp_edu->marks }}</td>
                            <td>{{ $emp_edu->passing_year }}</td>
                            <td>{{ $emp_edu->duration }} Years</td>
                        </tr>
                    @endforeach
                  </tbody>
                </table>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <!-- /.col -->
        <div class="col-md-8">
             <div class="box">
            <div class="box-header with-border" style="background: #ddd">
              <h3 class="box-title"><i class="fa fa-building-o"></i> Work Experience</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-hover">
                    <thead>
                        <tr>
                            <th width="5%">#</th>
                            <th width="25%">Org Name</th>
                            <th width="15%">Org Contact</th>
                            <th width="20%">Designation</th>
                            <th width="12%">Start Date</th>
                            <th width="12%">End Date</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($employee_ewe as $exp => $emp_exp)
                        <tr>
                            <td>{{ ++$exp }}</td>  
                            <td>{{ $emp_exp->org_name }}</td>
                            <td>{{ $emp_exp->org_contact }}</td>
                            <td>{{ $emp_exp->designation->name }}</td>
                            <td>{{ date("d-m-Y", strtotime($emp_exp->start_date)) }}</td>
                            <td>{{ date("d-m-Y", strtotime($emp_exp->end_date)) }}</td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <!-- /.col -->
        <div class="col-md-8">
             <div class="box">
            <div class="box-header with-border" style="background: #ddd">
              <h3 class="box-title"><i class="fa fa-phone"></i> Reference / Emergence Contact </h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-hover">
                    <thead>
                        <tr>
                            <th width="5%">#</th>
                            <th width="20%">Person Name</th>
                            <th width="15%">Relation</th>
                            <th width="15%">Phone 1</th>
                            <th width="15%">Phone 2</th>
                            <th width="15%">Email</th>
                            <th width="20%">Address</th>
                        </tr>
                    </thead>
                    <tbody>
                        
                        @foreach($employee_ref as $keyid => $emp_ref)
                        <tr>
                            <td>{{ ++$keyid }}</td>  
                            <td>{{ $emp_ref->person_name }}</td>
                            <td>{{ $emp_ref->relation }}</td>
                            <td>{{ $emp_ref->phone1 }}</td>
                            <td>{{ $emp_ref->phone2 }}</td>
                            <td>{{ $emp_ref->email }}</td>
                            <td>{{ $emp_ref->address }}</td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <!-- /.col -->
        <div class="col-md-8">
             <div class="box">
            <div class="box-header with-border" style="background: #ddd">
              <h3 class="box-title"><i class="fa fa-file"></i> Important File</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th width="50%">Document Type</th>
                            <th>File</th>
                        </tr>
                    </thead>
                    <tbody class="filebody">
                        @php $i=1; @endphp
                        @foreach($employee_document as $emp_doc)
                        <tr>
                            <td>{{ $i++ }}</td>
                            <td>{{ $emp_doc->document_type->document_name }}</td>
                            <td><a class="btn btn-info btn-xs" type="application/octet-stream" download="{{$emp_doc->file}}" href="{{ asset('/assets/document/employeedocument/'.$emp_doc->file) }}"> Download File</a></td>
                            
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <div class="col-md-8">
             <div class="box">
            <div class="box-header with-border" style="background: #ddd">
              <h3 class="box-title"><i class="fa fa-credit-card"></i> Payment History</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-bordered ">
                <thead>
                  <tr>
                    <th>#</th>
                    <th>Date</th>
                    <th class="text-right">Total Salary</th>
                    <th class="text-right">Paid</th>
                    <th class="text-right">Due</th>
                    <th style="text-align: center;">Status</th>
                  </tr>
                </thead>
                <tbody>
                @if($pay_history)
                <?php $i=1; $total_due=0;?>
                @foreach($pay_history as $pay_history)
                  <tr>
                    <td>{{ $i++ }}</td>
                    <td>{{ date("d/m/Y", strtotime(@$pay_history->date)) }}</td>
                    <td class="text-right"> 
                      <span>{{ number_format( @$pay_history->gross_amount,2) }} </span>
                    </td>
                    <td class="text-right"> 
                      <span>{{ number_format( @$pay_history->paid_amount,2) }} </span>
                    </td>
                    <td class="text-right"> 
                      <span>{{ number_format( $total_due = @$pay_history->gross_amount - @$pay_history->paid_amount,2) }} </span>
                    </td>
                    <td class="text-center">
                      @if($total_due <= 0)
                      <label class="label label-success">Paid</label>
                      @else
                      <label class="label label-info">Due</label>
                      @endif                      
                    </td>
                    
                  </tr>
                @endforeach

                @endif
                </tbody>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <!-- /.col -->
      </div>
      <!-- /row -->

    </section>
    <!-- /.content -->
  </div>

<!-- Change password start -->
<div class="modal fade" id="rejoining" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="gridSystemModalLabel">Change password</h4>
      </div>
      <div class="modal-body">

        <form action="{{url('admin/employee/rejoining')}}" method="POST">

            {{ csrf_field() }}

            <input type="hidden" class="hidden" name="emp_id" id="rejoining_id">
            
            <div class="form-group">
                <label for="rejoining_date">Rejoining Date</label>
                <input type="text" name="rejoining_date" class="form-control date" id="rejoining_date" placeholder="Date" required="">
            </div>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Submit</button>
      </div>
      </form>  
    </div>
  </div>
</div>
<!-- Change password end -->
<style>
    b {
        font-weight: bold
    }
    .coustom_list {
        list-style-type: none;
    }
</style>    
<script type="text/javascript">
    $('.rejoining').click(function(event) {           
        var id = $("#emp_id_div").val();
        $('#rejoining_id').val(id);      
    });
</script>
<script type="text/javascript">
$(document).ready(function() {
     $( ".date" ).datepicker({
          changeMonth: true,
          changeYear: true,
          yearRange: "c-100:c+10", 
          dateFormat:"yy-mm-dd"
     });
});
</script>
@endsection