@extends('layouts.app')
@section('title', __('medbloodbank::lang.donors'))
@section('content')
<section class="content-header"><h1>@lang('medbloodbank::lang.donors')</h1>
    <p>@lang('medbloodbank::lang.donors_help')</p>
</section>
<section class="content">
    @component('components.widget', ['class' => 'box-primary'])
        <div style="margin-bottom:12px;">
            <button class="btn btn-primary btn-sm mbb-modal-btn" data-href="{{ route('mbb.donors.create') }}">
                <i class="fa fa-plus"></i> @lang('medbloodbank::lang.add_donor')
            </button>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered table-striped" id="mbb_donors_table">
                <thead><tr>
                    <th>@lang('medbloodbank::lang.donor')</th>
                    <th>@lang('medbloodbank::lang.blood_group')</th>
                    <th>@lang('medbloodbank::lang.last_donation')</th>
                    <th>@lang('medbloodbank::lang.total_donations')</th>
                    <th>@lang('medbloodbank::lang.eligibility')</th>
                    <th>@lang('medbloodbank::lang.actions')</th>
                </tr></thead>
            </table>
        </div>
    @endcomponent
    <div class="modal fade mbb_modal" tabindex="-1" role="dialog"></div>
</section>
@endsection
@section('javascript')
@include('medbloodbank::partials.crud_scripts')
<script>
$(function () {
    var table = $('#mbb_donors_table').DataTable({
        processing: true, serverSide: true,
        ajax: '{{ route('mbb.donors.index') }}',
        columns: [
            { data: 'donor_name', name: 'contacts.name' },
            { data: 'blood_group', name: 'mbb_donors.blood_group' },
            { data: 'last_donation_at', name: 'mbb_donors.last_donation_at' },
            { data: 'total_donations', name: 'mbb_donors.total_donations' },
            { data: 'eligibility', name: 'mbb_donors.deferred_until', orderable: false, searchable: false },
            { data: 'action', name: 'action', orderable: false, searchable: false },
        ],
    });
    window.__mbbTables.push(table);
});
</script>
@endsection
