@extends('layouts.dashboard')

@section('page_title')
  Contract
@endsection

@section('page_header_title')
HR
@endsection



@section('page_body')
{{ Breadcrumbs::render('contract') }}

<div class="row row-cards row-deck">
  <div class="col-12">
                <div class="card">
                	  <div class="card-header">




      @if(Auth::user()->hasAnyPermission(['All','Add Contract']))

      <button class="float-right btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#md_add_contract"><i class="fa fa-plus"></i></button> &nbsp;&nbsp;

      @endif

      <h3 class="card-title">Add Contract</h3>

    </div>

    <div class="card-status card-status-left bg-blue">
    </div>

    <div class="table-responsive table-height">

    	<table class="table table-sm table-hover table-outline table-vcenter text-nowrap card-table cls_datatable">

    		<thead>
                        <tr>
                          <th>#</th>
                          <th>Employee Name</th>
                          <th>Employee Type</th>
                          <th>{{ucwords(EF::branchWhiteLabel()['module'])}}</th>
                          <th>Designation</th>
                          <th>Basic Salary</th>
                          <th>Duration</th>
                          <th>Status</th>
                          <th>Created Date</th>
                          <th></th>
                          <th style="text-align: center;"><i class="dropdown-icon fa fa-cogs"></i></th>
                        </tr>
                      </thead>

                      <tbody>

@php($pass_data = [])
                       @foreach($contract_list as $rows)

@php(
      $pass_data = array(

        'contract'        => Crypt::encrypt($rows->id),
        'scale'           => Crypt::encrypt(0),
        'employee_name'   => $rows->user->name,

         EF::branchWhiteLabel()['module']   => $rows->branch->code.' '.$rows->branch->name,

        'designation'     => trim($rows->designation->title),
        'start_date'      => EF::dateHtml($rows->start_date),
        'end_date'        => EF::dateHtml($rows->end_date),
        'basic_salary'    => $rows->basic_salary,
        'location'        => $rows->location,
        'status'          => $rows->status,
        'amount_in_words' => EF::numberToWords($rows->basic_salary)


      )
   )
                       <tr>

                       	<td>{{$loop->iteration}}</td>
                       	<td>{{ucwords($rows->user->name)}}</td>
                        <td>{{ucwords($rows->user->employee_type)}}</td>
                        <td>{{$rows->branch->code}} {{$rows->branch->name}}</td>
                       	<td>{{$rows->designation->title}}</td>

                       	<td>{{EF::numberFormat($rows->basic_salary)}}</td>


                       	<td>@if($rows->user->employee_type == 'Permanent') <b>N-A</b> @else  {{EF::dateDiffForHumans($rows->start_date,now())}}  @endif</td>

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

                       	<td>{{EF::dateFormat($rows->created_at)}}</td>

                         <td><a href="{{EF::getFile($rows->contract_form)}}">View Document</a></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>
               @if(Auth::user()->hasAnyPermission(['All','Assign Allowances/Assets']))
                 <div class="dropdown-divider"></div>
               <a  href="{{route('contracts.assignment',['id' => Crypt::encrypt($rows->id)])}}" content="Assignment" class="dropdown-item"><i class="dropdown-icon fa fa-tasks "></i>Assign Assets/Allowances</a>
               @endif


               @if(Auth::user()->hasAnyPermission(['All','View Contract Allowances']))
                <div class="dropdown-divider"></div>
                              <a onclick="showDetailModal(event,'{{Crypt::encrypt($rows->id)}}');" href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fa fa-file"></i> View Allowances</a>
               @endif

           @if(Auth::user()->hasAnyPermission(['All','Update Contract']))
            <div class="dropdown-divider"></div>

                       		<a onclick="update(event,'{{json_encode($pass_data)}}','form_update_contract','md_update_contract')" href="javascript:void(0)" class="dropdown-item" data-toggle="modal" data-target="#md_update_contract"><i class="dropdown-icon fa fa-edit"></i> Update</a>
                                      @endif



                       	</div>

                       </td>

                      </tr>
                       @endforeach

                      </tbody>
    	            </table>
                  </div>
                </div>
              </div>
            </div>




@endsection

@section('page_modal')
  @include('hr.contract.modals.add_contract')
  @include('hr.contract.modals.update_contract')
  @include('hr.contract.modals.contract_detail')

@endsection

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