@extends('layouts.app')
@section('title', __('medportal::lang.dependents'))
@section('content')
<section class="content-header">
    <h1>@lang('medportal::lang.dependents')</h1>
    <p>@lang('medportal::lang.dependents_help')</p>
</section>
<section class="content">
    @component('components.widget', ['class' => 'box-primary'])
        <div style="margin-bottom:12px;">
            <button class="btn btn-primary btn-sm mportal-modal-btn" data-href="{{ route('mportal.dependents.create') }}">
                <i class="fa fa-plus"></i> @lang('medportal::lang.add_dependent')
            </button>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered table-striped">
                <thead><tr>
                    <th>@lang('medportal::lang.guardian')</th>
                    <th>@lang('medportal::lang.dependent_patient')</th>
                    <th>@lang('medportal::lang.relationship')</th>
                    <th>@lang('medportal::lang.can_book')</th>
                    <th>@lang('medportal::lang.can_view_records')</th>
                    <th class="text-right">@lang('medportal::lang.actions')</th>
                </tr></thead>
                <tbody>
                @forelse($rows as $r)
                    <tr>
                        <td>{{ $guardianNames[$r->guardian_contact_id] ?? ('Contact #' . $r->guardian_contact_id) }}</td>
                        <td>{{ $patientNames[$r->dependent_patient_id] ?? ('Patient #' . $r->dependent_patient_id) }}</td>
                        <td>@lang('medportal::lang.rel_' . $r->relationship)</td>
                        <td>{!! $r->can_book ? '<i class="fa fa-check text-green"></i>' : '<i class="fa fa-times text-red"></i>' !!}</td>
                        <td>{!! $r->can_view_records ? '<i class="fa fa-check text-green"></i>' : '<i class="fa fa-times text-red"></i>' !!}</td>
                        <td class="text-right">
                            <button class="btn btn-xs btn-default mportal-modal-btn" data-href="{{ route('mportal.dependents.edit', $r->id) }}">
                                <i class="fa fa-edit"></i> @lang('medportal::lang.edit')
                            </button>
                            <button class="btn btn-xs btn-danger mportal-delete-btn" data-href="{{ route('mportal.dependents.destroy', $r->id) }}">
                                <i class="fa fa-trash"></i>
                            </button>
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="6" class="text-center text-muted">@lang('medportal::lang.no_dependents')</td></tr>
                @endforelse
                </tbody>
            </table>
        </div>
        <div class="modal fade mportal_modal" tabindex="-1" role="dialog"></div>
    @endcomponent
</section>
@endsection
@section('javascript')
@include('medportal::partials.crud_scripts')
@endsection
