@extends($user_shop ?'web.user.layouts.layout' : 'web.layouts.layout')

@section('content')

    <section class="page-header page-header-xlg parallax parallax-3"
             style="background-image:url('/assets/images/vision-min.jpg')">
        <div class="overlay dark-1"><!-- dark overlay [1 to 9 opacity] --></div>

        <div class="container">
        </div>
    </section>
    <!-- /PAGE HEADER -->

    <style>
     /*   div.shop-item {
            margin-bottom:30px;
            border: 1px solid #ddd;
        }
        div.shop-item > .thumbnail, .thumbnail {
            border: none;
        }
        div.shop-item-summary {
            padding: 8px;
        }
        div.shop-item-summary h2 a {
            color: #9aa983;
            font-size: 1.2em;
            margin: 0 0 10px 0;
        }
        div.shop-item-buttons {
            padding: 0 8px 10px 8px;
        }
        div.shop-item-buttons .btn-xs{
            padding: 4px;
        }
        .cartContent a.remove_item {
            background: transparent;
        }
        .cartContent .product_name {
            font-size: 1.15em;
        }
        .cartContent .product_name > small {
            line-height: 20px;
        }

        .cartContent .head .product_name {
            min-height: auto;
            padding-left: 20px;
        }

        a.shop-item-hl {
            color: #9aa983;
            font-size: 1.2em;
        }

        .table-mi-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #ddd !important;
        }


        @media only screen and (max-width: 1200px) {
            .cartContent .yard .product_name {
                padding-bottom: 0;
                min-height: 60px;
                width: 60%;
            }
            .cartContent .yard .remove_item {
                clear: right;
            }
            .cartContent .yard .total_price {
                width: auto;
                padding-top: 30px;
                clear: right;
            }
            .cartContent .yard .item .qty {
                float: left;
                text-align: left;
            }
            .cartContent .yard .item.head {
                display: none;
            }

        }
        @media only screen and (min-width: 768px) {

            .cartContent .yard .total_price {
                padding-top: 10px;
            }

        }
        @media only screen and (min-width: 992px) {
            .cartContent .yard .total_price {
                padding-top: 30px;
            }
        }
        @media only screen and (min-width: 1200px) {
            .cartContent .yard .total_price {
                padding-top: 10px;
            }
        }
        */

     select.form-control:not([size]):not([multiple]) {
         height: 38px;
         color: #6f6f6f;
         font-weight: 600;
     }

     .yard-items-head {
         border-bottom: 1px solid #ddd;
         padding-bottom: 8px;
         margin-bottom: 8px;
     }
     .yard-item {
         position: relative;
         border-bottom: 1px solid #ddd;
         padding-bottom: 8px;

     }
     .yard-item a.shop-item-hl {
         color: #9aa983;
         font-size: 1.1em;
         font-weight: bold;
     }
     .yard-item .options {
         margin-top: 4px;
     }
     .yard-item a.auto-delete-product {
         font-size: 0.7em;
         font-weight: bold;
         text-transform: uppercase;
     }

     .yard-item .quantity {
         position: relative;
     }
     .quantity-select {
         text-align: right;
     }
     .quantity-select select.form-control:not([size]):not([multiple]) {
         width: auto;
         min-width: 5em;
         display: inline-block;
     }
     .yard-item .price-total {
        margin-top: 6px;
         white-space: nowrap;

     }
     .yard-item .font-semi-bold {
            color: #393939;
            font-weight: 500;
     }

     .yard-item .font-semi-bold .small {
        font-size: 1rem;
     }

     .yard-item .font-bold {
         color:#393939;
         font-weight: bold;
     }
     .price-single {
         white-space: nowrap;
     }

     .btn-default {
         border: none;
         font-size: 0.9em;
     }



    </style>
    <!-- -->
    <section>
        <div class="container">

            <h1 class="mb-0">Warenkorb</h1>

            <!-- EMPTY CART -->
          <!--  <div class="panel panel-default">
                <div class="panel-body">
                    <strong>Shopping cart is empty!</strong><br />
                    You have no items in your shopping cart.<br />
                    Click <a href="index.html">here</a> to continue shopping. <br />
                    <span class="label label-warning">this is just an empty cart example</span>
                </div>
            </div>-->
            <!-- /EMPTY CART -->
            <!-- CART -->
            <div class="row">

                <!-- LEFT -->
                <div class="col-lg-9 col-md-8 col-sm-12">

                    <h4 class="weight-400">Du hast {{ Yard::instance('shopping')->count() }} Artikel in Deinem Warenkorb</h4>



                    @if(Yard::instance('shopping')->content()->count())
                    <!-- CART -->
                        {!! Form::open(['url' => url(Util::getPostRoute().'card/update'), 'class' => 'cartContent clearfix', 'id'=>'']) !!}

                        <!-- cart content -->
                            <div id="cartContent">

                                <div class="yard-items-head">
                                    <div class="row hidden-sm-down">

                                        <div class="col-xs-3 col-sm-2">

                                        </div>

                                        <div class="col-xs-9 col-sm-10">
                                            <div class="row">
                                                <div class="col-sm-6 col-md-7">
                                                    Artikel
                                                </div>
                                                <div  class="col-sm-3 col-md-2 text-left">
                                                    Einzelpreis
                                                </div>
                                                <div  class="ol-sm-3 col-md-3 text-right">
                                                    Anzahl
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>





                            @foreach(Yard::instance('shopping')->content() as $row)
                                @php($product = \App\Models\Product::find($row->id))

                                    <div class="row yard-item">

                                        <div class="col-xs-3 col-sm-2">
                                            <a href="{{ url('/produkte/alle-produkte/'.$row->options->slug) }}" title="" class="image">
                                                @if($row->options->has('image'))
                                                    <img src="{{ route('product_image', [$row->options->image]) }}" class="img-responsive" alt="">
                                                @else
                                                    <img src="{{ asset('/assets/images/1x1.png') }}" width="80" alt="">
                                                @endif
                                            </a>
                                        </div>

                                        <div class="col-xs-9 col-sm-10">
                                            <div class="row">
                                                <div class="col-xs-12 col-sm-6 col-md-7 description">
                                                    <a href="{{ url('/produkte/alle-produkte/'.$row->options->slug) }}" class="shop-item-hl"><span>{{ $row->name }}</span></a>
                                                    <div style="font-size: 13px; color:#1d1d1d; font-weight: 500;">Inhalt: {{ $product->contents }}</div>
                                                    <div style="font-size: 13px; color:#1d1d1d; font-weight: 500;">Art.-Nr.: {{ $product->number }}</div>
                                                    <div style="font-size: 13px; color:#6e6e6e;  font-weight: 400;"><em>Lieferzeit: 1-3 Werktage</em></div>

                                                    <div class="options">
                                                        <a class="auto-delete-product" href="{{ url(Util::getPostRoute().'card/remove', $row->rowId) }}"><i class="fa fa-times"></i>  Artikel entfernen</a>
                                                    </div>
                                                </div>

                                                <div class="col-xs-6 col-sm-3 col-md-2 text-left font-semi-bold price-single">
                                                    <div style="">{{  $row->price() }} &euro;</div>
                                                    <div class="small">{{$product->getBasePriceFormattedFull()}}</div>
                                                    <div class="small">inkl. {{ number_format($row->taxRate, 0)}}% MwSt.</div>
                                                    <!---->
                                                </div>

                                                <div class="col-xs-6 col-sm-3 col-md-3 quantity">
                                                    <div class="quantity-select">
                                                        <select class="form-control" name="quantity[{{$row->rowId}}]" onchange="this.form.submit()">
                                                            {!! HTMLHelper::getOptionRange($row->qty, 1, 50) !!}
                                                        </select>
                                                    </div>
                                                    <div class="price-total text-right">
                                                        <span class="font-bold text-price-total">{{  $row->subtotal() }}</span> &euro;
                                                    </div>

                                                </div>
                                            </div>
                                        </div>

                                    </div>

                            @endforeach


                            <a href="{{url(Util::getPostRoute().'card/delete')}}" class="btn btn-default btn-xs pull-left"><i class="glyphicon glyphicon-remove"></i> Warenkorb löschen</a>
                            <button type="submit" class="btn btn-xs btn-default pull-right "><i class="glyphicon glyphicon-refresh"></i> Warenkorb aktualisieren</button>
                            <div class="clearfix"></div>
                        </div>
                        {!! Form::close() !!}
                    <!-- /CART -->
                    @endif

                </div>

                <!-- RIGHT -->
                <div class="col-sm-8 col-sm-offset-4 col-md-4 col-md-offset-0 col-lg-3 col-lg-offset-0">

                    @if(Yard::instance('shopping')->content()->count())
                    <h3>Warenkorb Summe</h3>


                    <div class="toggle-transparent toggle-bordered-full clearfix">
                        <div class="toggle active cart-content">
                            <div class="toggle-content">

                                <div class="clearfix mb-2">
                                    <span class="pull-right">{{ Yard::instance('shopping')->total() }} €</span>
                                    <strong class="pull-left">Zwischensumme:</strong>
                                </div>
                                <hr class="mt-4 mb-4">

                                <div class="clearfix mb-2">
                                    <div class=" small">Lieferland:</div>
                                    <div class="small">
                                        <form action="{{ url(Util::getPostRoute().'card/show') }}" method="GET" style="margin-bottom: 0;">
                                            <select name="selected_country" class="form-control" onchange="this.form.submit()">
                                                {!! HTMLHelper::getCountriesForShipping(Yard::instance('shopping')->getShippingCountryId(), false) !!}
                                            </select>
                                        </form>
                                    </div>
                                </div>
                                <div class="clearfix mb-2">
                                    <span class="pull-right small">{{  Yard::instance('shopping')->shipping() }} € </span>
                                    <span class="pull-left small">Versandkosten:</span>
                                </div>
                                <hr class="mt-4 mb-4">
                                <div class="clearfix mb-2" style="font-size: 90%">
                                    <span class="pull-right small">{{  Yard::instance('shopping')->subtotalWithShipping() }} €</span>
                                    <span class="pull-left small">Summe ohne MwSt:</span>
                                </div>
                                <div class="clearfix mb-2" style="font-size: 90%">
                                    <span class="pull-right small">{{  Yard::instance('shopping')->taxWithShipping() }} €</span>
                                    <span class="pull-left small"> zzgl. {{-- Yard::getTaxRate() --}} MwSt:</span>
                                </div>
                                <hr />
                                <span class="clearfix ">
                                    <span class="pull-right size-20"><strong>{{ Yard::instance('shopping')->totalWithShipping() }} €</strong></span>
                                    <strong class="pull-left">Gesamtsumme:</strong>
                                </span>
                                <a href="{{ url(Util::getPostRoute().'card/checkout/server') }}" class="btn btn-primary btn-lg btn-block mt-4 btn-text-500 faa-parent animated-hover"><i class="fa fa-mail-forward faa-horizontal"></i> zur Kasse</a>
                                <hr>
                                <p class="text-center" style="line-height: 1.2em;"><em class="small text-center"> <i class="fa fa-lock"></i> Du werden auf unseren checkout weitergeletet, die Verbindung ist mit SSL verschlüsselt.</em></p>
                            </div>
                        </div>
                    </div>
                    @endif

                </div>
            </div>
            <br><br>
            <hr>
            <p><em class="small" style="color: #828282">Alle Preise inkl. gesetzl. Mehrwertsteuer zzgl. Versandkosten, wenn nicht anders beschrieben</em></p>
            <!-- /CART -->
        </div>
    </section>

@endsection