@extends('layouts.app')
@section('title','List of Claims | ')
@section('content')
<!-- Content Header (Page header) -->
<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1 class="m-0">All Claims</h1>
            </div><!-- /.col -->
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="#">Home</a></li>
                    <li class="breadcrumb-item active">Claims</li>
                </ol>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- Main content -->
<section class="content">
    <div class="container-fluid pb-5">
        <div class="card mb-5">
            <div class="card-header">
                <h3 class="card-title">List of all claims</h3>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
                <table id="claimListing" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>Sr No.</th>
                            <th>Claim Master ID</th>
                            <th>Emp ID</th>
                            <th>Emp Name</th>
                            <th>Mobile</th>
                            <th>Aadhar</th>
                            <th>Claim Type</th>
                            <th>Claim For</th>
                            <th>Action</th>
                        </tr>
                    </thead>

                    <tbody>
                        @if($claims->count() > 0)
                        @php
                        $count = 1;
                        @endphp
                        @foreach($claims as $data)
                        <tr>
                            <td>{{ $count }}</td>
                            <td>{{ $data->claim_master_id }}</td>
                            <td>{{ $data->emp_id }}</td>
                            <td>{{ $data->emp_name }}</td>
                            <td>{{ $data->emp_mobile }}</td>
                            <td>{{ $data->aadhar_number }}</td>
                            <td>
                                @if($data->claim_type == 1)
                                {{ __('Death') }}
                                @elseif($data->claim_type == 2)
                                {{ __('Accident') }}
                                @endif
                            </td>
                            <td style="width: 150px">
                                @if($data->claim_applied_for->count() > 0)
                                    @foreach($data->claim_applied_for as $items)
                                    <ul class="nav">
                                        <li class="nav-item dropdown">
                                            <a class="nav-link p-0 dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">{{ $items->claim_category }} ({{$items->claim_text_status}})</a>
                                            <div class="dropdown-menu">
                                                <!-- view claim details -->
                                                <a href="{{ route('view.claim.details',$data->claim_id) }}" class="dropdown-item text-primary" data-toggle="tooltip" data-placement="top" title="View Claim Details"><i class="fas fa-eye mr-1"></i> View Details</a>
                                                <!-- edit claim details -->
                                                <a href="{{ route('edit.next.claim.form',[$data->claim_id,$items->claim_category]) }}"  class="dropdown-item text-primary {{ ($items->claim_status == 3) ? 'text-muted' : '' }}" data-toggle="tooltip" data-placement="top" title="Edit Applied {{ $items->claim_category }} Claim" @if($items->claim_status == 3) onclick="return false;" @endif ><i class="fa fa-edit mr-1"></i> Edit</a>
                                                <!-- update remark  -->
                                                <a href="{{ route('create.claim.remark',[1,$items->id]) }}" data-toggle="tooltip" data-placement="top" title="Update Remark on {{ $items->claim_category}} Claim" class="dropdown-item text-primary {{ ($items->claim_status == 3) ? 'text-muted' : '' }}" @if($items->claim_status == 3) onclick="return false;" @endif><i class="fas fa-comment  mr-1"></i>Update Remark</a>
                                                <!-- view remarks -->
                                                <a href="{{ route('view.remark',[1,$items->id])  }}"  data-toggle="tooltip" data-placement="top" title="View Remarks of {{ $items->claim_category}} Claim" class="dropdown-item text-primary" @if($items->claim_status == 3) onclick="return false;" @endif><i class="fas fa-eye  mr-1"></i> View Remarks</a>
                                                <!-- open case -->
                                                @if($items->claim_status == 4 || !empty($items->partial_amount))
                                                @if($items->case_opened != 1)
                                                    <a href="{{ route('create.new.case',[1,$items->id]) }}" data-toggle="tooltip" data-placement="top" title="Open Case" class="dropdown-item text-primary" @if($items->claim_status == 3) onclick="return false;" @endif><i class="fas fa-book-open mr-1"></i>Open Case</a>
                                                @else
                                                    <a href="{{ route('view.cases.details',$items->case_id) }}" data-toggle="tooltip" data-placement="top" title="Case Already Opend Click to View Case Details" class="dropdown-item text-primary" @if($items->claim_status == 3) onclick="return false;" @endif><i class="fas fa-book-open mr-1"></i>Case Already Opened</a>
                                                @endif
                                                @endif
                                            </div>
                                        </li>
                                        @if($items->claim_status == 3)
                                            <span class="ml-3">
                                                <a href="{{ route('upload.claim.document',$items->id) }}" data-toggle="tooltip" data-placement="top" title="Upload Claim Document">
                                                    <i class="fa fa-upload"></i>
                                                </a>
                                                @if(!empty($items->claim_document))
                                                <a href='{{ asset("public/assets/claim_document/$items->claim_document") }}' data-toggle="tooltip" data-placement="top" title="View Claim Document">
                                                    <i class="fas fa-eye ml-2"></i>
                                                </a>
                                                @endif
                                            </span>    
                                        @endif
                                    </ul>
                                    @endforeach
                                @else
                                    <span class="">EPF (Not Applied)</span><br>
                                    <span class="">ESI (Not Applied)</span><br>
                                    <span class="">WC (Not Applied)</span><br>
                                    <span class="">GPA (Not Applied)</span>
                                @endif
                            </td>
                            <td>
                                <ul class="nav">
                                    <li class="nav-item dropdown">
                                        <a class="nav-link p-0 dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">Action</a>
                                        <div class="dropdown-menu">
                                            <!-- view claim details -->
                                            <a href="{{ route('next.claim.form',$data->claim_id) }}" data-toggle="tooltip" data-placement="top" title="Claim" class="dropdown-item text-primary"> Claim</a>
                                            <a href="{{ route('edit.claim.info',$data->claim_id) }}" class="dropdown-item text-primary"> Edit</a>
                                            <a href="{{ route('view.claim.details',$data->claim_id) }}" class="dropdown-item text-primary"> View</a>
                                        </div>
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        @php
                        $count++;
                        @endphp
                        @endforeach
                        @endif
                    </tbody>
                </table>
            </div>
            <!-- /.card-body -->
        </div>
        <!-- /.card -->
    </div>
    <!--/. container-fluid -->
</section>
<!-- /.content -->
@endsection
