@extends('layouts.layout-2')

@section('content')

<h4 class="font-weight-bold py-2 mb-2">
    {{  __('navigation.promotion')  }} / 
    @if($by === 'promotion')
        {{ $promotion->name }}  User Promotions 
    @endif
    @if($by === 'all')
        Alle User Promotions 
    @endif
</h4>

<div class="text-left mt-0 mb-2">
    <a href="{{ route('admin_promotions') }}" class="btn btn-default">{{ __('back') }}</a>
</div>

<div class="row">
    <div class="col-12">
    <div class="card">
        <div class="card-datatable table-responsive">
            <table class="datatable-users table table-striped table-bordered">

                <thead>
                <tr>
                    <th>#</th>
                    <th>{{__('User')}}</th>
                    <th>{{__('Name')}}</th>
                    <th>{{__('aktive Produkte')}}</th>
                    <th>{{__('geplant Produkte')}}</th>
                    <th>{{__('geordert Produkte')}}</th>
                    <th>{{__('Potentielle Kosten')}}</th>
                    <th>{{__('User Guthaben')}}</th>
                    <th>{{__('Kosten bisher')}}</th>
                    <th>{{__('aktiv')}}</th>
                    <th>{{__('Abholung')}}</th>
                    <th>{{__('Gelöscht')}}</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
    </div>
</div>
    <script>
        $( document ).ready(function() {
            $('.datatable-users').dataTable({
                "processing": true,
                "serverSide": true,
                "ajax": '{!! route('admin_promotion_datatable', [$by, $id]) !!}',
                "order": [[0, "desc" ]],
                "columns": [
                    {data: 'id', name: 'id'},
                    { data: 'user', name: 'user', orderable: false, searchable: false  },
                    { data: 'name', name: 'name' },
                    { data: 'products_active', name: 'products_active', orderable: false, searchable: false  },
                    { data: 'count_open_items', name: 'count_open_items', orderable: false, searchable: false  },
                    { data: 'count_sell_items', name: 'count_sell_items', orderable: false, searchable: false  },
                    { data: 'user_promotion_cart_price', name: 'user_promotion_cart_price', orderable: false, searchable: false  },
                    { data: 'user_credit', name: 'user_credit', orderable: false, searchable: false },
                    { data: 'user_promotion_sell_price', name: 'user_promotion_sell_price', orderable: false, searchable: false  },
                    { data: 'active', name: 'active', searchable: false },
                    { data: 'pick_up', name: 'pick_up', searchable: false },
                    { data: 'user_delete', name: 'user_delete', orderable: false, searchable: false },
                ],
                "bLengthChange": false,
                "iDisplayLength": 50,
                "language": {
                    "url": "/js/German.json"
                }
            });

        });
    </script>
@endsection