@section('title', 'Commission History')
@section('commission-history', 'active')
@include('adminDashboard.layout.header')

<div class="main-content">
    <section class="section">
        <div class="section-body">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h4>Commission History</h4>
                        </div>
                        <form id="commissionHistoryForm">
                            @csrf
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>Search User by Mobile</label>
                                            <input type="text" class="form-control" name="user_mobile" id="user_mobile" required>
                                            <div id="user_error" class="error"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="card-footer p-0">
                                    <input type="submit" class="btn btn-primary mr-1" value="Submit" />
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <section class="section">
        <div class="section-body">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h4>Records</h4>
                        </div>
                        <div class="card-body p-0">
                            <div class="table-responsive">
                                <table class="table table-striped table-md">
                                    <tr>
                                        <th>ID</th>
                                        <th>Mobile</th>
                                        <th>Amount</th>
                                        <th>Type</th>
                                        <th>Date</th>
                                    </tr>
                                    <tbody id="record_table">
                                        @if(count($commissions) > 0)
                                        @foreach ($commissions as $commission)
                                        <tr>
                                            <td>{{ $commission->id }}</td>
                                            <td>
                                                @if (env('DEMO'))
                                                {{ substr_replace($commission->mobile, "****", 3, 4) }}
                                                @else
                                                {{ $commission->mobile }}
                                                @endif
                                            </td>
                                            <td>{{ $commission->commission }}</td>
                                            @if ($commission->level1 == 1)
                                            <td>Level 1</td>
                                            @elseif ($commission->level2 == 1)
                                            <td>Level 2</td>
                                            @elseif ($commission->level3 == 1)
                                            <td>Level 3</td>
                                            @endif
                                            <td>{{ $commission->created_at }}</td>
                                        </tr>
                                        @endforeach
                                        @else
                                        <tr>
                                            <td colspan="7" class="text-center">No Data Found.</td>
                                        </tr>
                                        @endif
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="card-footer text-right" id="pagination">
                            <nav class="d-inline-block">
                                {{$commissions->links('adminDashboard.pagination')}}
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
</div>
@include('adminDashboard.layout.footer')