@extends('layouts.app')
@section('title', __('medsurgery::lang.cases'))
@section('content')
<section class="content-header"><h1>@lang('medsurgery::lang.cases')</h1>
    <p>@lang('medsurgery::lang.cases_help')</p>
</section>
<section class="content">
    @component('components.widget', ['class' => 'box-primary'])
        <div class="row" style="margin-bottom:12px;">
            <div class="col-md-6">
                <a class="btn btn-primary btn-sm" href="{{ route('medsx.cases.create') }}">
                    <i class="fa fa-plus"></i> @lang('medsurgery::lang.add_case')
                </a>
            </div>
            <div class="col-md-3 col-md-offset-3">
                <select id="medsx_status_filter" class="form-control input-sm">
                    <option value="">@lang('medsurgery::lang.all')</option>
                    @foreach($statuses as $st)
                        <option value="{{ $st }}">@lang('medsurgery::lang.status_' . $st)</option>
                    @endforeach
                </select>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered table-striped" id="medsx_cases_table">
                <thead><tr>
                    <th>@lang('medsurgery::lang.case_no')</th>
                    <th>@lang('medsurgery::lang.patient')</th>
                    <th>@lang('medsurgery::lang.surgeon')</th>
                    <th>@lang('medsurgery::lang.or_room')</th>
                    <th>@lang('medsurgery::lang.priority')</th>
                    <th>@lang('medsurgery::lang.scheduled_date')</th>
                    <th>@lang('medsurgery::lang.status')</th>
                    <th>@lang('medsurgery::lang.actions')</th>
                </tr></thead>
            </table>
        </div>
    @endcomponent
</section>
@endsection
@section('javascript')
<script>
$(function () {
    var table = $('#medsx_cases_table').DataTable({
        processing: true, serverSide: true,
        ajax: {
            url: '{{ route('medsx.cases.index') }}',
            data: function (d) { d.status = $('#medsx_status_filter').val(); }
        },
        columns: [
            { data: 'case_no', name: 'case_no' },
            { data: 'patient_name', name: 'patient_name', orderable: false, searchable: false },
            { data: 'surgeon_name', name: 'surgeon_name', orderable: false, searchable: false },
            { data: 'room_name', name: 'room_name', orderable: false, searchable: false },
            { data: 'priority', name: 'priority' },
            { data: 'scheduled_date', name: 'scheduled_date' },
            { data: 'status', name: 'status' },
            { data: 'action', name: 'action', orderable: false, searchable: false },
        ],
        order: [[0, 'desc']],
    });
    $('#medsx_status_filter').on('change', function () { table.ajax.reload(); });
});
</script>
@endsection
