@extends('layouts.layout-2')

@section('content')
    <h4 class="font-weight-bold py-2 mb-2 d-flex justify-content-between align-items-center w-100 ">
        <div>{{ __('navigation.promotion') }} / {{ __('navigation.overview') }}</div>
        <a href="{{route('admin_promotion_detail', ['new'])}}" class="btn btn-secondary rounded-pill d-block float-right"><span class="ion ion-md-add"></span>&nbsp; Neue Promotion anlegen</a>
    </h4>

    <div class="row">
        <div class="col-12">

            @foreach($values as $value)
            <div class="card mb-4">
                <div class="card-body d-flex justify-content-between align-items-start pb-2">
                    <div>
                        <a href="{{route('admin_promotion_detail', [$value->id])}}" class="text-body text-big font-weight-semibold">{{$value->name}}</a>
                    </div>
                    @if($value->canDelete())
                    <div class="btn-group project-actions">
                        <a href="{{ route('admin_promotion_delete', [$value->id, 'admin_promotion']) }}"
                            class=" dropdown-item" onclick="return confirm('Promotion wirklich löschen?');">
                             <span class="ion ion-md-trash text-danger"></span>
                         </a>
                    </div>
                     @endif
                 </div>
                 <div class="progress rounded-0" style="height: 2px;">
                     <div class="progress-bar" style="width: 100%;"></div>
                 </div>
                <div class="card-body pt-3 pb-1">
                    {{$value->description}}
                    <hr>
                </div>
                <div class="card-body pt-0">
                    <div class="row">
                        <div class="col">
                            <div class="text-muted small">Typ</div>
                            <div class="font-weight-bold">{{$value->getPromotionType()}}</div>
                        </div>
                        <div class="col">
                            <div class="text-muted small">Produkte</div>
                            <div class="font-weight-bold">{{$value->promotion_admin_products->count()}}</div>
                        </div>
                        <div class="col">
                            <div class="text-muted small">max Budget</div>
                            <div class="font-weight-bold">{{ $value->getFormattedMaxBugdet() }}</div>
                        </div>
                        <div class="col">
                            <div class="text-muted small">max Produkte</div>
                            <div class="font-weight-bold">{{$value->max_items}}</div>
                        </div>
                        <div class="col">
                            <div class="text-muted small">Datum von</div>
                            <div class="font-weight-bold">{{ $value->from }}</div>
                        </div>
                        <div class="col">
                            <div class="text-muted small">Datum bis</div>
                            <div class="font-weight-bold">{{ $value->to }}</div>
                        </div>
                        <div class="col">
                            <div class="text-muted small">Aktiv</div>
                            <div class="font-weight-bold">{!! get_active_badge($value->active) !!}</div>
                        </div>
                    </div>
                </div>
              
                <hr class="m-0">
                <div class="card-body py-3">
                    <div class="d-flex flex-wrap">
                            <a href="{{route('admin_promotion_detail', [$value->id])}}" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-ios-cog"></i> Bearbeiten</a>
                            <a href="{{route('admin_promotion_show', ['promotion', $value->id])}}" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-md-rocket"></i> User Promotions ansehen</a>
                           {{--
                            <a href="#" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-md-basket"></i> Bestellung ansehen (n.b!)</a>
                            --}}
                    </div>
                </div>
            </div>
            @endforeach
        </div>
        <div class="col-12">
            <hr class="mt-0">
            <a href="{{route('admin_promotion_show', ['all'])}}" class="btn btn-secondary mr-2 mb-2"><i class="ion ion-md-rocket"></i> Alle User Promotions ansehen</a>
        </div>
    </div>
    <script>
        $( document ).ready(function() {
        
        });
    </script>
@endsection