@if (!sizeof($sales) > 0)
    <p>No sales for today yet.</p>
@else
    <div class="table-responsive mb-0"
         data-list="{&quot;valueNames&quot;: [&quot;goal-project&quot;, &quot;goal-status&quot;, &quot;goal-progress&quot;, &quot;goal-date&quot;]}">
        <table class="table table-sm table-nowrap card-table">
            <thead>
        <tr>
            <th>SN</th>
            <th>Product</th>
            <th>Quantity</th>
            <th>Amount</th>
            <th>Payment Channel</th>
            <th>Review</th>
            <th>Sale Date</th>
            <th>Action</th>
        </tr>
        </thead>
        <tbody>
        @foreach ($sales as $sale)
            <tr>
                <td>
                    <a href="">
                        #{{ $sale->id}}
                    </a>
                </td>

                <td>
                    {{ $sale->product->name }} - {{ $sale->product->description }}
                </td>

                <td>
                    {{ $sale->quantity }}
                </td>

                <td>
                    NGN{{ number_format($sale->amount, 2) }}
                </td>

                <td>
                    <span class="label ">{{ $sale->pay_channel}}</span>
                </td>

                <td>
                    <span class="label ">{{ $sale->review}}</span>
                </td>

                <td>
                    {{ $sale->date }}
                </td>
                <td>
                    @if(Auth::user() !== null && Auth::user()->is_admin)
                        <div class="btn-group">
                        <button type="button" class="btn btn-primary btn-raised">Action</button>
                        <button type="button" class="btn btn-primary btn-raised dropdown-toggle" data-toggle="dropdown"
                                aria-haspopup="true" aria-expanded="false">
                            <i class="zmdi zmdi-chevron-down right only"></i>
                        </button>
                        <ul class="dropdown-menu dropdown-menu-primary">
                            <li class="dropdown-header">Actions</li>
                            <li>
                                delete
                            </li>
                            <li>
                                {{--<a href="{{route('invoice', $sale->id)}}">Details</a>--}}
                            </li>
                            <li role="separator" class="divider"></li>
                            <li>
                                <a href="javascript:void(0)">More</a>
                            </li>
                        </ul>
                    </div>
                    @else
                        <div class="btn-group">
                        <button type="button" class="btn btn-primary btn-raised">Action</button>
                        <button type="button" class="btn btn-primary btn-raised dropdown-toggle"
                                data-toggle="dropdown"
                                aria-haspopup="true" aria-expanded="false">
                            <i class="zmdi zmdi-chevron-down right only"></i>
                        </button>
                        <ul class="dropdown-menu dropdown-menu-primary">
                            <li class="dropdown-header">Actions</li>
                            <li>
                                <a href="">Details</a>
                            </li>
                            <li role="separator" class="divider">Change</li>
                        </ul>
                    </div>
                    @endif
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
    </div>
    <div class="card-footer table-responsive">
        <table class="table">
            <tbody>
            <tr>
                <td><h4>POS:</h4></td>
                <td>
                    <span class="pull-right"><strong>{{number_format($sales->where('pay_channel', 'POS')->sum('amount'), 2)}}</strong></span>
                </td>
                <td></td>
            </tr>
            <tr>
                <td>
                    <h4 style="color: orange;">TOTAL CASH: </h4>

                </td>
                <td>
                                <span class="pull-right">
                                        <strong>{{number_format($sales->where('pay_channel', 'CASH')->sum('amount'), 2)}}</strong>
                                    </span>
                </td>
            </tr>
            <tr>
                <td>
                    <h4 style="color: orange;">TOTAL TRANSFERS: </h4>

                </td>
                <td>
                                <span class="pull-right">
                                        <strong>{{number_format($sales->where('pay_channel', 'TRANSFER')->sum('amount'), 2)}}</strong>
                                    </span>
                </td>
            </tr>
            <tr>
                <td>
                    <h4 style="color: RED;">TOTAL DEBT: </h4>

                </td>
                <td>
                                <span class="pull-right">
                                        <strong>{{number_format($sales->where('pay_channel', 'PENDING')->sum('amount'), 2)}}</strong>
                                    </span>
                </td>
            </tr>
            </tbody>

        </table>

    </div>
    <div class="card-footer" style="background: darkgreen!important;">

        <h2>GRAND TOTAL:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
                    class="pull-right"><strong>{{number_format($sales->sum('amount'), 2)}}</strong></span>
        </h2>

    </div>
{{--    {{ $sales->render() }}--}}
@endif
