@extends('layouts.app')
@section('page-title')
    {{ __('Member Detail') }}
@endsection
@section('breadcrumb')
    <ul class="breadcrumb mb-0">
        <li class="breadcrumb-item">
            <a href="{{ route('dashboard') }}">
                {{ __('Dashboard') }}
            </a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ route('member.index') }}">{{ __('Member') }}</a>
        </li>
        <li class="breadcrumb-item active">
            <a href="#"> {{ __('Details') }} {{ memberPrefix() . $member->member_id }}</a>
        </li>
    </ul>
@endsection

@section('content')
    <div class="row">
        <div class="col-sm-12">
            <div class="card">
                <div class="card-body">
                    <div class="row">
                        <div class="col-lg-6 col col-xxl-4">
                            <div class="card border">
                                <div class="card-header">
                                    <div class="d-flex align-items-center">
                                        <div class="flex-shrink-0">
                                            <img class="img-radius img-fluid wid-80"
                                                src="{{ !empty($member->image) ? asset(Storage::url('upload/image/' . $member->image)) : asset(Storage::url('upload/profile/avatar.png')) }}"
                                                alt="User image" />
                                        </div>
                                        <div class="flex-grow-1 mx-3">
                                            <h5 class="mb-1">
                                                {{ $member->first_name }} {{ $member->last_name }}
                                            </h5>
                                            <h6 class="mb-0 text-secondary">
                                                {{ memberPrefix() }}{{ $member->member_id }}</h6>
                                        </div>
                                    </div>
                                </div>
                                <div class="card-body px-2 pb-0">
                                    <div class="list-group list-group-flush">
                                        <a href="#" class="list-group-item list-group-item-action">
                                            <div class="d-flex align-items-center">
                                                <div class="flex-shrink-0">
                                                    <i class="material-icons-two-tone f-20">email</i>
                                                </div>
                                                <div class="flex-grow-1 mx-3">
                                                    <h5 class="m-0">{{ __('Email') }}</h5>
                                                </div>
                                                <div class="flex-shrink-0">
                                                    <small>{{ $member->email }}</small>
                                                </div>
                                            </div>
                                        </a>
                                        <a href="#" class="list-group-item list-group-item-action">
                                            <div class="d-flex align-items-center">
                                                <div class="flex-shrink-0">
                                                    <i class="material-icons-two-tone f-20">phonelink_ring</i>
                                                </div>
                                                <div class="flex-grow-1 mx-3">
                                                    <h5 class="m-0">{{ __('Phone') }}</h5>
                                                </div>
                                                <div class="flex-shrink-0">
                                                    <small>{{ $member->phone }}
                                                    </small>
                                                </div>
                                            </div>
                                        </a>

                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="col-lg-6 col-auto col-xxl-8">
                            <div class="card border">
                                <div class="card-header">
                                    <h5>{{ __('Additional Detail') }}</h5>
                                </div>
                                <div class="card-body">

                                    <div class="table-responsive">
                                        <table class="table table-borderless">
                                            <tbody>
                                                <tr>
                                                    <td><b class="text-header">{{ __('Date of Birth') }}</b></td>
                                                    <td>:</td>
                                                    <td>{{ dateFormat($member->dob) }} </td>
                                                </tr>
                                                <tr>
                                                    <td><b class="text-header">{{ __('Gender') }}</b></td>
                                                    <td>:</td>
                                                    <td>{{ $member->gender }}
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td><b class="text-header">{{ __('Address') }}</b></td>
                                                    <td>:</td>
                                                    <td>{{ $member->address }}
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td><b
                                                            class="text-header">{{ __('Emergency Contact Information') }}</b>
                                                    </td>
                                                    <td>:</td>
                                                    <td>{{ $member->emergency_contact_information }}
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td><b class="text-header">{{ __('Notes') }}</b></td>
                                                    <td>:</td>
                                                    <td>{{ $member->notes }}
                                                    </td>
                                                </tr>

                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-12">
            <div class="card table-card">
                <div class="card-header">
                    <div class="row align-items-center g-2">
                        <div class="col">
                            <h5>
                                {{ __('Documents') }}
                            </h5>
                        </div>
                        <div class="col-auto">


                            <a class="btn btn-secondary customModal" href="#" data-size="lg"
                                data-url="{{ route('member.document.create', $member->id) }}"
                                data-title="{{ __('Create Document') }}">
                                <i class="ti ti-circle-plus align-text-bottom"></i>
                                {{ __('Create Document') }}
                            </a>
                        </div>
                    </div>
                </div>
                <div class="card-body pt-0">
                    <div class="dt-responsive table-responsive">
                        <table class="table table-hover advance-datatable">
                            <thead>
                                <tr>
                                    <th>{{ __('Name') }}</th>
                                    <th>{{ __('Type') }}</th>
                                    <th>{{ __('Upload Date') }}</th>
                                    <th>{{ __('Status') }}</th>
                                    <th>{{ __('Document') }}</th>
                                    <th>{{ __('Action') }}</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($documents as $document)
                                    <tr>
                                        <td>{{ $document->document_name }} </td>
                                        <td>{{ !empty($document->types) ? $document->types->type : '' }} </td>
                                        <td>{{ dateFormat($document->upload_date) }} </td>
                                        <td>{{ $document->status }} </td>
                                        <td>
                                            <a href="{{ asset(Storage::url('upload/member/document')) . '/' . $document->document }}"
                                                download="download">
                                                <i data-feather="download" class=""></i>
                                            </a>
                                        </td>
                                        <td>
                                            <div class="cart-action">
                                                {!! Form::open(['method' => 'DELETE', 'route' => ['member.document.destroy', $document->id]]) !!}
                                                <a class="avtar avtar-xs btn-link-secondary text-secondary customModal"
                                                    data-bs-toggle="tooltip" data-bs-original-title="{{ __('Edit') }}"
                                                    href="#" data-size="md"
                                                    data-url="{{ route('member.document.edit', $document) }}"
                                                    data-title="{{ __('Edit Document') }}"> <i data-feather="edit"></i></a>
                                                <a class=" avtar avtar-xs btn-link-danger text-danger confirm_dialog"
                                                    data-bs-toggle="tooltip" data-bs-original-title="{{ __('Detete') }}"
                                                    href="#"> <i data-feather="trash-2"></i></a>
                                                {!! Form::close() !!}
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        @if (!empty($plans))
            <div class="col-sm-12">
                <div class="card table-card">
                    <div class="card-header">
                        <div class="row align-items-center g-2">
                            <div class="col">
                                <h5>
                                    {{ __('Membership Plan Details') }}
                                </h5>
                            </div>

                        </div>
                    </div>
                    <div class="card-body pt-0">
                        <div class="dt-responsive table-responsive">
                            <table class="table table-hover advance-datatable">
                                <thead>
                                    <tr>
                                        <th>{{ __('ID') }}</th>
                                        <th>{{ __('Plan Name') }}</th>
                                        <th>{{ __('Duration') }}</th>
                                        <th>{{ __('Price') }}</th>
                                        <th>{{ __('Billing Frequency') }}</th>
                                        @if (Gate::check('edit membership plan') || Gate::check('delete membership plan'))
                                            <th>{{ __('Action') }}</th>
                                        @endif
                                    </tr>
                                </thead>
                                <tbody>

                                    <tr>
                                        <td>{{ planPrefix() . $plans->plan_id }} </td>
                                        <td>{{ $plans->plan_name }} </td>
                                        <td>{{ $plans->duration }} </td>
                                        <td>{{ priceFormat($plans->price) }} </td>
                                        <td>{{ $plans->billing_frequency }} </td>
                                        @if (Gate::check('edit membership plan') || Gate::check('delete membership plan'))
                                            <td>
                                                <div class="cart-action">
                                                    {!! Form::open(['method' => 'DELETE', 'route' => ['membership-plan.destroy', $plans->id]]) !!}
                                                    @can('show membership plan')
                                                        <a class="avtar avtar-xs btn-link-warning text-warning customModal"
                                                            data-bs-toggle="tooltip"
                                                            data-bs-original-title="{{ __('Show') }}" href="#"
                                                            data-size="lg" data-title="{{ __('Show membership plan') }}"
                                                            data-url="{{ route('membership-plan.show', $plans->id) }}">
                                                            <i data-feather="eye"></i></a>
                                                    @endcan
                                                    @can('edit membership plan')
                                                        <a class="avtar avtar-xs btn-link-secondary text-secondary customModal"
                                                            data-bs-toggle="tooltip"
                                                            data-bs-original-title="{{ __('Edit') }}" href="#"
                                                            data-size="lg"
                                                            data-url="{{ route('membership-plan.edit', $plans) }}"
                                                            data-title="{{ __('Edit membership plan') }}"> <i
                                                                data-feather="edit"></i></a>
                                                    @endcan
                                                    @can('delete membership plan')
                                                        <a class=" avtar avtar-xs btn-link-danger text-danger confirm_dialog"
                                                            data-bs-toggle="tooltip"
                                                            data-bs-original-title="{{ __('Detete') }}" href="#"> <i
                                                                data-feather="trash-2"></i></a>
                                                    @endcan
                                                    {!! Form::close() !!}
                                                </div>
                                            </td>
                                        @endif
                                    </tr>

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

                </div>
            </div>
        @endif
    </div>
@endsection
