@extends('layouts.app')
@section('page-title')
    {{ rentalAgreementPrefix() . $rentalAgreement->agreement_id }}
@endsection
@section('breadcrumb')
    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">{{ __('Dashboard') }}</a></li>
    <li class="breadcrumb-item"><a href="{{ route('rental-agreement.index') }}">{{ __('Rental Agreement') }}</a></li>
    <li class="breadcrumb-item" aria-current="page">{{ rentalAgreementPrefix() . $rentalAgreement->agreement_id }}</li>
@endsection
@section('card-action-btn')
    <a class="btn btn-secondary print ml-5" href="javascript:void(0);"><i class="fa fa-print"></i> {{ __('Print') }}</a>
@endsection
@section('content')
    <div class="row">
        <div id="invoice-print">
            <div class="col-lg-12 col-md-12">
                <div class="card">
                    <div class="card-body cdx-invoice">
                        <div id="cdx-invoice">
                            <div class="head-invoice">
                                <div class="codex-brand row d-flex align-items-center">
                                    <div class="col-sm-12 col-md-10">
                                        <a class="codexdark-logo" href="Javascript:void(0);">
                                            <img class="img-fluid"
                                                src="{{ asset(Storage::url('upload/logo/')) . '/' . (isset($settings['company_logo']) && !empty($settings['company_logo']) ? $settings['company_logo'] : 'logo.png') }}"
                                                alt="invoice-logo">
                                        </a>
                                    </div>
                                    <ul class="col-sm-12 col-md-2" style="list-style: none;">
                                        <li>
                                            <i class="fa fa-user text-secondary f-18"></i>
                                            <span class="mb-2 ms-2">{{ $settings['company_name'] }}</span>
                                        </li>
                                        <li>
                                            <i class="fa fa-phone text-secondary f-18"></i>
                                            <span class="mb-2 ms-2">{{ $settings['company_phone'] }}</span>
                                        </li>
                                        <li>
                                            <i class="fa fa-envelope text-secondary f-18"></i>
                                            <span class="mb-2 ms-2">{{ $settings['company_email'] }}</span>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="row">
                                    <h3 class="text-primary mb-10">
                                        {{ __('Agreement') }} : </h3>

                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Agreement ID') }}</h5>
                                            <p class="mb-20">
                                                {{ rentalAgreementPrefix() . $rentalAgreement->agreement_id }}
                                            </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Agreement Date') }}</h5>
                                            <p class="mb-20"> {{ dateFormat($rentalAgreement->date) }} </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Rental Start Date') }}</h5>
                                            <p class="mb-20">{{ dateFormat($rentalAgreement->rental_start_date) }} </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Rental End Date') }}</h5>
                                            <p class="mb-20">{{ dateFormat($rentalAgreement->rental_end_date) }} </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Rental Duration') }}</h5>
                                            <p class="mb-20">{{ $rentalAgreement->rental_duration . __(' Days') }} </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Status') }}</h5>
                                            <p class="mb-20">
                                                @if ($rentalAgreement->status == 'draft')
                                                    <span
                                                        class="badge bg-light-info">{{ \App\Models\RentalAgreement::$status[$rentalAgreement->status] }}</span>
                                                @elseif($rentalAgreement->status == 'pending')
                                                    <span
                                                        class="badge bg-light-warning">{{ \App\Models\RentalAgreement::$status[$rentalAgreement->status] }}</span>
                                                @elseif($rentalAgreement->status == 'confirmed' || $rentalAgreement->status == 'active')
                                                    <span
                                                        class="badge bg-light-success">{{ \App\Models\RentalAgreement::$status[$rentalAgreement->status] }}</span>
                                                @else
                                                    <span
                                                        class="badge bg-light-danger">{{ \App\Models\RentalAgreement::$status[$rentalAgreement->status] }}</span>
                                                @endif
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <hr>
                                <div class="row">
                                    <h3 class="text-primary mb-10">
                                        {{ __('Driver') }} : </h3>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Name') }}</h5>
                                            <p class="mb-20">
                                                {{ !empty($rentalAgreement->drivers) ? $rentalAgreement->drivers->name : '' }}
                                            </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Email') }}</h5>
                                            <p class="mb-20">
                                                {{ !empty($rentalAgreement->drivers) ? $rentalAgreement->drivers->email : '' }}
                                            </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Phone Number') }}</h5>
                                            <p class="mb-20">
                                                {{ !empty($rentalAgreement->drivers) ? $rentalAgreement->drivers->phone_number : '' }}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <hr>
                                <div class="row">
                                    <h3 class="text-primary mb-10">
                                        {{ __('Vehicle') }} : </h3>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Vehicle') }}</h5>
                                            <p class="mb-20">
                                                {{ !empty($rentalAgreement->vehicles) ? $rentalAgreement->vehicles->name : '' }}
                                            </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('Model') }}</h5>
                                            <p class="mb-20">
                                                {{ !empty($rentalAgreement->vehicles) ? $rentalAgreement->vehicles->model : '' }}
                                            </p>
                                        </div>
                                    </div>
                                    <div class="col-md-4 col-lg-4 col-sm-4">
                                        <div class="detail-group">
                                            <h5>{{ __('License Plate') }}</h5>
                                            <p class="mb-20">
                                                {{ !empty($rentalAgreement->vehicles) ? $rentalAgreement->vehicles->license_plate : '' }}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <hr>
                                <div class="row">
                                    <h3 class="text-primary mb-10">
                                        {{ __('Terms & Conditions') }} : </h3>
                                    <div class="col-md-12 col-lg-12 col-sm-4">
                                        <p>
                                            {{ $rentalAgreement->terms_condition }}
                                        </p>
                                    </div>
                                </div>
                                <hr>
                                <div class="row">
                                    <h3 class="text-primary mb-10">
                                        {{ __('Description') }} : </h3>
                                    <div class="col-md-12 col-lg-12 col-sm-4">
                                        <p>
                                            {{ $rentalAgreement->description }}
                                        </p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12 text-end mt-20">
                                <h3>{{ __('Signature') }}</h3>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
@endsection
@push('script-page')
    <script>
        $(document).on('click', '.print', function() {
            $('.action').addClass('d-none');
            var printContents = document.getElementById('invoice-print').innerHTML;
            var originalContents = document.body.innerHTML;

            document.body.innerHTML = printContents;

            window.print();

            document.body.innerHTML = originalContents;
            $('.action').removeClass('d-none');
        });
    </script>
@endpush
