@extends('layouts.app')
@section('title', __('medbilling::lang.claims'))
@section('content')
<section class="content-header"><h1>@lang('medbilling::lang.claims')</h1>
    <p>@lang('medbilling::lang.claims_help')</p>
</section>
<section class="content">
    @component('components.widget', ['class' => 'box-primary'])
        <div class="row" style="margin-bottom:12px;">
            <div class="col-md-4">
                <label>@lang('medbilling::lang.status')</label>
                <select id="medbill_claim_status_filter" class="form-control">
                    <option value="">@lang('medbilling::lang.all')</option>
                    @foreach($statuses as $st)
                        <option value="{{ $st }}">@lang('medbilling::lang.claim_status_' . $st)</option>
                    @endforeach
                </select>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered table-striped" id="medbill_claims_table">
                <thead><tr>
                    <th>@lang('medbilling::lang.claim_no')</th>
                    <th>@lang('medbilling::lang.patient')</th>
                    <th>@lang('medbilling::lang.payer')</th>
                    <th class="text-right">@lang('medbilling::lang.total_claimed')</th>
                    <th class="text-right">@lang('medbilling::lang.total_approved')</th>
                    <th class="text-right">@lang('medbilling::lang.payer_share')</th>
                    <th>@lang('medbilling::lang.status')</th>
                    <th>@lang('medbilling::lang.date')</th>
                    <th>@lang('medbilling::lang.actions')</th>
                </tr></thead>
            </table>
        </div>
    @endcomponent
    <div class="modal fade medbill_modal" tabindex="-1" role="dialog"></div>
</section>
@endsection
@section('javascript')
@include('medbilling::partials.crud_scripts')
<script>
$(function () {
    var table = $('#medbill_claims_table').DataTable({
        processing: true, serverSide: true, order: [[7, 'desc']],
        ajax: {
            url: '{{ route('medbill.claims.index') }}',
            data: function (d) { d.status = $('#medbill_claim_status_filter').val(); }
        },
        columns: [
            { data: 'claim_no', name: 'claim_no' },
            { data: 'patient_name', name: 'patient_name', orderable: false, searchable: false },
            { data: 'payer_name', name: 'medbill_payers.name' },
            { data: 'total_claimed', name: 'total_claimed', className: 'text-right' },
            { data: 'total_approved', name: 'total_approved', className: 'text-right' },
            { data: 'payer_share', name: 'payer_share', className: 'text-right' },
            { data: 'status', name: 'status' },
            { data: 'created_at', name: 'medbill_claims.created_at' },
            { data: 'action', name: 'action', orderable: false, searchable: false },
        ],
    });
    window.__medBillTables.push(table);
    $('#medbill_claim_status_filter').on('change', function () { table.ajax.reload(); });
});
</script>
@endsection
