@extends('backend.layouts.app')
@section('title', @$data['title'])

@section('content')
    {!! breadcrumb([
        'title' => @$data['title'],
        route('admin.dashboard') => _trans('common.Dashboard'),
        '#' => @$data['title'],
    ]) !!}

    @include('travel::travel-plans.nav', ['plan_id' => $data['travelExpense']->travel_plan_id, 'is_approved' => true])

    <div class="card ot-card">
        <div class="card-body">
            <div class="d-flex align-items-center justify-content-between gap-2 mb-3">
                <h3 class="mb-0">{{ _trans('Travel Expense') }} #{{ $data['travelExpense']->id }}</h3>
                <div>
                    <?php for ($i = 1; $i <= 5; $i++): ?>
                        <i class="las la-star fs-3 <?= $i <= $data['travelExpense']->rating_of_travel_experience ? 'text-warning' : '' ?>"></i>
                    <?php endfor; ?>
                </div>
            </div>

            <small class="text-muted mb-3">{{ _trans('common.Basic Info') }}: </small>
            <div class="row mb-3">
                <div class="col-lg-6">
                    <table class="table table-striped table-borderless w-100">
                        <tr>
                            <th class="w-50">{{ _trans('common.Employee Name') }}</th>
                            <td class="w-50">: {{ $data['travelExpense']->employee->name }}</td>
                        </tr>
                        <tr>
                            <th class="w-50">{{ _trans('common.Department') }}</th>
                            <td class="w-50">: {{ $data['travelExpense']->employee->department->title }}</td>
                        </tr>
                        <tr>
                            <th class="w-50">{{ _trans('common.Designation') }}</th>
                            <td class="w-50">: {{ $data['travelExpense']->employee->designation->title }}</td>
                        </tr>
                        <tr>
                            <th class="w-50">{{ _trans('common.Email') }}</th>
                            <td class="w-50">: <a href="mailto:{{ $data['travelExpense']->employee->email }}">{{ $data['travelExpense']->employee->email }}</a></td>
                        </tr>
                        <tr>
                            <th class="w-50">{{ _trans('common.Phone') }}</th>
                            <td class="w-50">: <a href="tel:{{ $data['travelExpense']->employee->phone }}">{{ $data['travelExpense']->employee->phone }}</a></td>
                        </tr>
                    </table>
                </div>
                <div class="col-lg-6">
                    <table class="table table-striped table-borderless w-100">
                        <tr>
                            <th class="w-50">{{ _trans('common.Date') }}</th>
                            <td class="w-50">: {{ $data['travelExpense']->date }}</td>
                        </tr>
                        <tr>
                            <th class="w-50">{{ _trans('common.Mode Of Transportation') }}</th>
                            <td class="w-50">: {{ $data['travelExpense']->mode_of_transportation }}</td>
                        </tr>
                        <tr>
                            <th class="w-50">{{ _trans('common.Total Amount') }}</th>
                            <td class="w-50">: {{ showAmount($data['travelExpense']->total_amount) }}</td>
                        </tr>
                        <tr>
                            <th class="w-50">{{ _trans('common.Approved Amount') }}</th>
                            <td class="w-50">: {{ showAmount($data['travelExpense']->approved_amount) }}</td>
                        </tr>
                        <tr>
                            <th class="w-50">{{ _trans('common.Status') }}</th>
                            <td class="w-50">: 
                                <span class="badge badge-{{ $data['travelExpense']->status->class }}">
                                    {{ $data['travelExpense']->status->name }}
                                </span>
                                @if ($data['travelExpense']->status_id == 5)
                                    <small class="fw-bold">{{ $data['travelExpense']->approvedBy->name }}: {{ date('Y-m-d h:i A', strtotime($data['travelExpense']->approved_at)) }}</small>
                                @endif
                            </td>
                        </tr>
                    </table>
                </div>
            </div>

            <small class="text-muted mb-3">{{ _trans('common.Expenses') }}: </small>
            <div class="table-responsive">
                <table class="table table-striped">
                    <tbody>
                        @foreach ($data['travelExpense']->travelExpenseLogs ?? [] as $travelExpenseLog)
                            <tr>
                                <td class="w-75">
                                    <div class="d-flex flex-column gap-0">
                                        <div>
                                            <b>{{ $travelExpenseLog->expenseCategory->name }}: </b> {{ $travelExpenseLog->title }}
                                        </div>
                                        <span class="text-muted">{{ $travelExpenseLog->remark }}</span>
                                    </div>
                                </td>
                                <td class="w-25">
                                    <div class="d-flex flex-column gap-0">
                                        <span class="text-end">{{ showAmount($travelExpenseLog->amount) }}</span>
                                        <span class="text-end">
                                            @if ($travelExpenseLog->file_id)
                                                <a href="{{ uploaded_asset($travelExpenseLog->file_id) }}" download class="text-primary">
                                                    <i class="fas fa-download"></i>
                                                </a>
                                            @else
                                                <span class="text-muted">{{ _trans('common.No File') }}</span>
                                            @endif
                                        </span>
                                    </div>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
