@extends('app')



@section('content')
    <div class="row">
        <div class="col-md-6">
            <div class="row">
                <div class="bigimg">
                    <img class="mainimg" src="{{ $product->pictures()->first()->mid() }}" alt="img"/>
                </div>
                <div class="smallimgs">
                    @foreach($product->pictures as $pic)
                    <img class="haspic" src="{{ $pic->mini() }}" data-big="{{ $pic->mid() }}"/>
                    @endforeach
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <span style="font-size:40px">{{ $product->sort }}
                @if($product->user_id == Auth::user()->id)
                    <?php $i = 0; ?>
                    <button class="btn btn-default" id="settings_button" type="button" data-toggle="modal" data-target="#myModal{{ $i }}" aria-expanded="true">
                        <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
                    </button>
                @endif
                <div class="product_rating"><input type="hidden" class="rating" disabled value="4"/></div></span>
            <hr class="productpage_heading_line">
            <div class="productpage_heading">{{ $product->fruit() }}</div>


            <table class="product_table">
                <tr>
                    <td>{{ Lang::get('product.price') }}:</td>
                    <td>{{ $product->price() }} €/kg</td>
                </tr>
                <tr>
                    <td>{{ Lang::get('product.amount') }}:</td>
                    <td>{{ $product->amount }} kg</td>
                </tr>
                <tr>
                    <td>{{ Lang::get('product.location') }}:</td>
                    <td>{{ $product->location }}, {{ $product->country }}</td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                </tr>
            </table>
            <!--
            <p style="align-content: center">OR</p>
            <div class="input-group col-md-6">
                {!! Form::submit("Make an offer", ['class' => 'btn btn-blue form-control']) !!}
            </div>
            </div>
-->


            @unless(\Auth::user()->id == $product->user_id)
                {!! Form::open(['url' => 'product/'.$product->id.'/buy']) !!}
                <div class="transport_radios">

                    @foreach($product->transports as $tr)
                        <div class="radio">
                            <label>
                                <input type="radio" name="trans" id="optionsRadios1" value="{{ $tr->id }}">
                                <span class="badge">{{ $tr->cost }} €</span>
                                {{ Lang::get('product.trans'.$tr->text) }}
                            </label>
                        </div>
                    @endforeach
                </div>
                <div class="input-group col-md-6 ">
                    {!! Form::text('amount', Input::get('buy'), ['class' => 'form-control', 'placeholder' =>Lang::get('product.enteramount')]) !!}
                    <span class="input-group-btn">
                        <div class="form-group">
                            {!! Form::submit(Lang::get('product.buy'), ['class' => 'btn btn-green buy_button']) !!}
                        </div>
                    </span>
                </div>

                @include('errors.list')

                {!! Form::close() !!}
            @endunless


        </div>
        <iframe
                height="200"
                width="500"
                frameborder="0" style="border:0"
                src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDABruOrZ7MFGy8Rf6gvU7yRByBkex3AQQ
    &q={{ $product->location }}">
        </iframe>
    </div>

    <div class="row">
        <div class="col-md-12">
            <h3>{{ Lang::get('product.info') }}</h3>
            <hr>
            <div class="product_info">
                {{ $product->info }}
            </div>
        </div>
    </div>
    <div>
        <div class="col-md-12">
            <div role="tabpanel">
                <!-- Nav tabs -->
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active"><a href="#auctions" aria-controls="auctions" role="tab"
                                                              data-toggle="tab">{{ Lang::get('product.auctions') }} ({{ count($product->auctions) }})</a>
                    </li>
                    <li role="presentation"><a href="#sales" aria-controls="sales" role="tab"
                                               data-toggle="tab">{{ Lang::get('product.sales') }} (0)</a></li>
                    <li role="presentation"><a href="#comments" aria-controls="comments" role="tab"
                                               data-toggle="tab">{{ Lang::get('product.comments') }}
                            ({{ count($product->comments) }})</a>
                    </li>
                </ul>

                <!-- Tab panes -->
                <div class="tab-content">

                    <div role="tabpanel" class="tab-pane active" id="auctions">
                        <div class="tab-inside">
                            @include('partials.auctions')
                        </div>
                    </div>

                    <div role="tabpanel" class="tab-pane" id="sales">
                        <div class="tab-inside">
                            {{ Lang::get('product.nosales') }}
                        </div>
                    </div>

                    <div role="tabpanel" class="tab-pane" id="comments">
                        <div class="tab-inside">
                            @include('partials.comments')
                        </div>
                    </div>

                </div>

            </div>
        </div>
    </div>
    @if($product->user_id == Auth::user()->id)
        @include('modals.productsettings')
    @endif

@stop


@section('footer')

    <script type="text/javascript">
    @if(Auth::user()->id== $product->user_id)
            $(function () {
                var locale = $('#locale').text();
                $('.datetimepicker').datetimepicker({
                    inline: true,
                    sideBySide: true,
                    format: 'MM/dd/YYYY HH/mm',
                    locale: locale
                }).on('dp.change', function (e) {
                    $('.enddate').val(e.date.format('DD-MM-YYYY HH:mm'));
                });
            });

    @endif

        $('.smallimgs').children().first().addClass('shownpic');
        $( '.haspic' ).each(function(){
                $(this).on('click', function(){
                    $('.mainimg').attr('src', $(this).data('big'));
                    $('.shownpic').removeClass('shownpic');
                    $(this).addClass('shownpic');
                })
            })
    </script>
@stop
