<?php $__env->startSection('metatags'); ?>
    <meta name="description" content="<?php echo str_limit($product->description, 254); ?>">
    <meta property="og:title" content="<?php echo $product->subfamily->family->name; ?> | Beirateca - Ferramentas e Acessórios">
    <meta property="og:description" content="<?php echo str_limit($product->description, 254); ?>">
    <?php if($product->images->isEmpty()): ?>
        <meta property="og:image" content="<?php echo asset('assets/img/default/product.png'); ?>">
    <?php else: ?>
        <meta property="og:image" content="<?php echo asset($product->images->first()->getThumb()); ?>">
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('title'); ?>
    <?php echo $product->name; ?> |
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <?php echo $__env->make('products.modal.share_email', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <?php echo $__env->make('products.partials.contact', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <div class="row">
        <div class="col-sm-12">
            <ol class="breadcrumb">
                <li>
                    <a href="<?php echo route('home'); ?>">Início</a>
                </li>
                <li class="active"><?php echo $product->family->group->name; ?></li>
                <li>
                    <a href="<?php echo route('products.index', array($product->family->group->slug, $product->family->slug)); ?>">
                        <?php echo $product->family->name; ?>

                    </a>
                </li>
                <?php if($product->subfamily): ?>
                    <li>
                        <a href="<?php echo route('products.index', array($product->family->group->slug, $product->family->slug, $product->subfamily->slug)); ?>">
                            <?php echo $product->subfamily->name; ?>

                        </a>
                    </li>
                <?php endif; ?>
                <li class="active"><?php echo $product->name; ?></li>
            </ol>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-4 col-md-5">
            <?php if($product->new): ?>
                <div class="product-label">Novo</div>
            <?php endif; ?>

            <?php if($product->highlight): ?>
                <div class="product-label">Destaque</div>
            <?php endif; ?>

            <?php if($product->top_sales): ?>
                <div class="product-label">Top Vendas</div>
            <?php endif; ?>

            <div class="product-images">
                <?php if($product->images->isEmpty()): ?>
                    <img src="<?php echo asset('assets/img/default/product.png'); ?>" class="width-100"/>
                <?php else: ?>
                    <ul id="imageGallery" class="list-unstyled">
                        <?php foreach($product->images as $image): ?>
                            <li data-thumb="<?php echo asset($image->getOriginalFileUrl()); ?>" data-src="<?php echo asset($image->getOriginalFileUrl()); ?>">
                                <img src="<?php echo $image->getCroppa(400); ?>" class="width-100" onerror="this.onerror=null;this.src='<?php echo asset($image->getOriginalFileUrl()); ?>';"/>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </div>
        </div>
        <div class="col-sm-4">
            <h2 class="product-title">
                <small>
                    <?php if($product->subfamily): ?>
                        <?php echo $product->subfamily->name; ?>

                    <?php else: ?>
                        <?php echo $product->family->name; ?>

                    <?php endif; ?>
                </small>
                <?php echo $product->name; ?>

            </h2>
            <p><?php echo $product->description; ?></p>

            <?php if(!$product->tables->isEmpty()): ?>
                <table class="table margin-top-30">
                    <?php foreach($product->tables as $key => $row): ?>
                        <tr>
                            <?php foreach($row as $key => $column): ?>
                                <?php if($column->th): ?>
                                    <th><?php echo $column->content; ?></th>
                                <?php else: ?>
                                    <td><?php echo $column->content; ?></td>
                                <?php endif; ?>
                            <?php endforeach; ?>
                        </tr>
                    <?php endforeach; ?>
                </table>
            <?php endif; ?>
        </div>
        <div class="col-sm-4 col-md-3">
            <div class="panel-price padding-15">
                <h1 class="pull-left">
                    <?php echo $product->price_whole; ?><sub>,<?php echo $product->price_decimal; ?></sub><sup>€</sup>
                </h1>
                <?php if($product->promo_price): ?>
                    <h4 class="pull-right text-right">
                        <div class="spacer-15"></div>
                        <span class="discount"><strike><?php echo money(getValueBasedOnVatType($product->base_price, $product->vat_rate), '€'); ?></strike></span><br/>
                    <?php /*<!--<span class="old-price"><?php echo money($product->base_price, '€'); ?></span>-->*/ ?>
                    </h4>
                <?php endif; ?>

                <div class="clearfix"></div>
                <hr/>
                <p>
                    <small>
                        IVA incluído à taxa de
                        <?php if($product->vat_rate == 'intermediate'): ?>
                            13%
                        <?php else: ?>
                            23%
                        <?php endif; ?>
                    </small>
                </p>
                <?php if($product->status == Product::STATUS_AVAILABLE): ?>
                    <p class="green"><i class="fa fa-circle"></i> Disponível em loja</p>
                <?php elseif($product->status == Product::STATUS_ORDER): ?>
                    <p class="yellow"><i class="fa fa-circle"></i> Produto sob encomenda</p>
                <?php else: ?>
                    <p class="red"><i class="fa fa-circle"></i> Esgotado</p>
                <?php endif; ?>
                <ul class="margin-top-10 margin-bottom-5 list-inline text-center">
                    <li><a href="#" data-toggle="modal" data-target="#mail-product-share"><i class="fa fa-envelope"></i></a>
                    </li>
                    <li>
                        <a href="http://www.facebook.com/share.php?u=<?php echo Request::fullUrl(); ?>&title=<?php echo $product->name; ?>"
                           data-toggle="share" title="facebook">
                                <span class="social-square facebook">
                                    <i class="fa fa-facebook-f"></i>
                                </span>
                        </a>
                    </li>
                    <li>
                        <a href="http://twitter.com/home?status=<?php echo $product->name; ?>+<?php echo Request::fullUrl(); ?>"
                           data-toggle="share" title="Twitter">
                                <span class="social-square twitter">
                                    <i class="fa fa-twitter"></i>
                                </span>
                        </a>
                    </li>
                    <li>
                        <a href="https://plus.google.com/share?url=<?php echo $product->name; ?>" data-toggle="share"
                           title="Google +">
                                <span class="social-square google-plus">
                                    <i class="fa fa-google-plus"></i>
                                </span>
                        </a>
                    </li>
                </ul>
                <a href="#" data-toggle="modal" data-target="#mail-product-info"
                   class="btn btn-primary btn-block text-uppercase bold">Pedir Informações</a>

            </div>
        </div>
    </div>
    <div class="spacer-30"></div>
    <div class="row">
        <div class="col-sm-8 col-md-9">
            <div class="panel">
                <div class="panel-heading">
                    <h4>Produtos Relacionados</h4>
                </div>
                <div class="panel-body padding-left-0 padding-right-0">
                    <div class="row row-10">
                        <?php foreach($related as $product): ?>
                            <div class="col-sm-6 col-md-4 col-lg-3">
                                <?php echo $__env->make('products.partials.item', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                            </div>
                        <?php endforeach; ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-4 col-md-3">
            <?php echo $__env->make('products.partials.topSales', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        </div>
    </div>
    <h4>Veja produtos para outras marcas</h4>
    <?php echo $__env->make('partials.brandsSection', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <?php /* RECAPTCHA */ ?>
    <script src="https://www.google.com/recaptcha/api.js?render=6Lf_hswoAAAAANVgObYz3En3uGvQ-POnJYFtBlAq"></script>
    <script>
        grecaptcha.ready(function () {
        grecaptcha.execute('6Lf_hswoAAAAANVgObYz3En3uGvQ-POnJYFtBlAq', { action: 'contact' }).then(function (token) {
         var recaptchaResponse = document.getElementById('recaptchaResponse');
         recaptchaResponse.value = token;
          });
         });
    </script>
    <script>
        $(window).load(function () {
            $('#imageGallery').lightSlider({
                gallery: true,
                item: 1,
                loop: true,
                thumbItem: 3,
                slideMargin: 0,
                enableDrag: false,
                currentPagerPosition: 'left',
                onSliderLoad: function (el) {
                    el.lightGallery({
                        selector: '#imageGallery .lslide'
                    });
                }
            });
        });

        $(document).ready(function () {

            $('a[data-toggle=share]').on('click', function (e) {
                e.preventDefault();
                var href = $(this).attr('href');
                popupCenter(href, '', 600, 400);
                return false;
            })
        });

        $(document).on('submit', '#mail-product-share form', function(e){
            e.preventDefault();
            var url = $(this).attr('action');

            $(this).find('[type="submit"]').button('loading');

            $.post(url, $(this).serialize(), function(data){
                $('#mail-product-share').modal('hide');

                swal({
                    title: "",
                    text: data.feedback,
                    type: 'success',
                    showCancelButton: false,
                    confirmButtonClass: "btn-default btn-sm",
                    closeOnConfirm: false,
                    closeOnCancel: false
                });


            }).fail(function () {

                $('#mail-product-share').modal('hide');

                swal({
                    title: "",
                    text: 'Não foi possível enviar a mensagem! \nTente novamente mais tarde.',
                    type: "error",
                    showCancelButton: false,
                    confirmButtonClass: "btn-default btn-sm",
                    closeOnConfirm: false,
                    closeOnCancel: false
                });

            }).always(function(){
                $(this).find('[type="submit"]').button('reset');
            })
        })
    </script>
<?php $__env->stopSection(); ?>