@extends('layouts.layout-2')

@section('content')
    <div class="card">
        <h6 class="card-header">
            Berater Bestellungen
        </h6>
        <div class="col-sm-6 mb-2">
            {!! Form::open(['action' => route('user_revenue'), 'class' => 'form-horizontal', 'id'=>'filter_sales_member']) !!}

            <label class="form-label" for="filter_user_shop_id">Filter Jahr</label>
            <select class="custom-select" name="filter_sales_year" id="filter_sales_year">
                @foreach($years as $year)
                    <option value="{{$year}}" @if($active_year == $year) selected @endif>{{$year}}</option>
                @endforeach
            </select>
            {!! Form::close() !!}

        </div>
   
        <div class="card-datatable table-responsive">
            <table class="datatables-style table table-striped table-bordered">
                <thead>
                <tr>
                    <th>{{__('Vorname')}}</th>
                    <th>{{__('Nachname') }}</th>
                    <th>{{__('E-Mail') }}</th>
                    <th>{{__('Betrag') }}</th>
                    <th>{{__('Datum') }}</th>
                    <th>{{__('Order')}}</th>
                    <th>{{__('Status')}}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($values as $value)
                    <tr>
                        <td>{{ $value->shopping_user->billing_firstname }}</td>
                        <td>{{ $value->shopping_user->billing_lastname }}</td>
                        <td>{{ $value->shopping_user->billing_email }}</td>
                        <td>{{ $value->getFormattedTotalShipping()." €" }}</td>
                        <td>{{ $value->created_at->format("d.m.Y") }}</td>
                        <td>@foreach($value->shopping_order_items as $shopping_order_item)
                            {{ $shopping_order_item->product->name }}<br>
                            @endforeach

                        </td>

                        <td>{!! App\Services\Payment::getShoppingOrderBadge($value) !!}</td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>

    </div>

    <script>

        $('#filter_sales_year').on('change', function(){
            $('#filter_sales_member').submit();
        });

    
    </script>
@endsection
