@php use Carbon\Carbon; @endphp
@extends('adminlte::page')

@section('title', 'IPRS | Contracts')

@section('content_header')
    <div class="col-9 mx-auto d-flex justify-content-between align-items-center">
        <div class="row">
            <div class="col-sm-8">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Dashboard</a></li>
                    <li class="breadcrumb-item active">Contracts</li>
                </ol>
            </div>
            <div class="col-sm-12">
                <h1 class="m-0">Contracts</h1>
            </div>
        </div>
        {{--<div>
            <div class="d-flex justify-content-end align-content-end">
                <a href="{{ route('contract.create') }}" class="btn btn-primary">New Contract</a>
            </div>
        </div>--}}
    </div>
@stop

@section('plugins.Datatables', true)

@section('content')
    <div class="col-9 mx-auto">
        {{-- Setup data for datatables --}}
        @php
            $headings = [
                'ID',
                'Contract No.',
                ['label' => 'Issue Date', 'width' => 12],
                'Client Name',
                ['label' => 'Begin Date', 'width' => 12],
                ['label' => 'End Date', 'width' => 10],
                ['label' => 'Status'],
                ['label' => 'Actions', 'no-export' => true, 'width' => 5],
            ];
        @endphp

        <x-adminlte-card>
            {{-- Minimal example / fill data using the component slot --}}
            <x-adminlte-datatable id="clients-table" :heads="$headings" striped hoverable bordered>
                @foreach($contracts as $row)
                    <tr>
                        <td>{{ $row->rid }}</td>
                        <td>{{ $row->n_doc ?? '-' }}</td>
                        <td>{{ Carbon::parse($row->d_doc)->format("d-m-Y") }}</td>
                        <td>{{ ucfirst($row->client->name_fl ?? "") }}</td>
                        <td>{{ Carbon::parse($row->d_bgn)->format("d-m-Y") }}</td>
                        <td>{{ Carbon::parse($row->d_end)->format("d-m-Y") }}</td>
                        <td>
                            @if($row->in_use == 1)
                                <div class="badge badge-success">Active</div>
                            @else
                                <div class="badge badge-secondary">In Active</div>
                            @endif
                        </td>
                        <td>
                            <nobr>
                                <a href="{{ route('sub-contracts.show', $row->rid) }}"
                                class="btn btn-xs btn-default text-teal mx-1 shadow" title="View Users">
                                    <i class="fa fa-lg fa-fw fa-eye"></i> View Users
                                </a>
                            </nobr>
                        </td>
                    </tr>
                @endforeach
            </x-adminlte-datatable>
        </x-adminlte-card>
    </div>
@stop

@section('css')
    {{-- Add here extra stylesheets --}}
    {{-- <link rel="stylesheet" href="/css/admin_custom.css"> --}}
@stop

@section('js')

@stop
