{extends file="layout.tpl"}

{* Body Class *}
{block name="body-class"}page-product{/block}

{* Breadcrumb *}
{block name='no-return-functions' append}
    {$breadcrumbs = []}
    {loop type="product" name="product_breadcrumb" id="{product attr="id"}"}
        {loop name="category_path" type="category-path" category="{$DEFAULT_CATEGORY}"}
            {$breadcrumbs[] = ['title' => {$TITLE}, 'url'=> {$URL}]}
        {/loop}
        {$breadcrumbs[] = ['title' => {$TITLE}, 'url'=> {$URL}]}
    {/loop}
{/block}


{block name="main-content"}
    <div class="main">
        {loop name="product.details" type="product" id="{product attr="id"}"}
        <article id="product" class="col-main" role="main" itemscope itemtype="http://schema.org/Product">

            <!-- Use the meta tag to specify content that is not visible on the page in any way -->
            {loop name="brand.feature" type="feature" product="{$ID}" title="brand"}
                {loop name="brand.value" type="feature_value" feature="{$ID}" product="{product attr="id"}"}
                    <meta itemprop="brand" content="{$TITLE}">
                {/loop}
            {/loop}
            {loop name="brand.feature" type="feature" product="{$ID}" title="isbn"}
                {loop name="brand.value" type="feature_value" feature="{$ID}" product=$product_id}
                    <meta itemprop="productID" content="isbn:{$TITLE}">
                {/loop}
            {/loop}

            <section id="product-gallery">
                <figure class="product-image">
                    {loop type="image" name="image.main" product="{$ID}" width="560" height="445" resize_mode="borders" limit="1"}
                        <img src="{$IMAGE_URL}" alt="{$TITLE}" class="img-responsive" itemprop="image" data-toggle="magnify">
                    {/loop}
                </figure>

                <div id="product-thumbnails" class="slide" style="position:relative;">
                    <div class="carousel-inner">
                        <div class="item active">
                            <ul>
                                {loop name="image.carousel" type="image" product="{$ID}"  width="560" height="445" resize_mode="borders" limit="5"}
                                <li>
                                    <a href="{$IMAGE_URL}" class="thumbnail {if $LOOP_COUNT == 1}active{/if}">
                                        {loop type="image" name="image.thumbs" id="{$ID}" product="$OBJECT_ID" width="118" height="85" resize_mode="borders"}
                                            <img src="{$IMAGE_URL}" alt="{$TITLE}">
                                        {/loop}
                                    </a>
                                </li>
                                {/loop}
                            </ul>
                        </div>
                        {ifloop rel="image.carouselsup"}
                        <div class="item">
                            <ul>

                                {loop name="image.carouselsup" type="image" product="{$ID}"  width="560" height="445" resize_mode="borders" offset="5"}
                                    <li>
                                        <a href="{$IMAGE_URL}" class="thumbnail">
                                            {loop type="image" name="image.thumbssup" id="{$ID}" product="$OBJECT_ID" width="118" height="85" resize_mode="borders"}
                                                <img src="{$IMAGE_URL}" alt="{$TITLE}">
                                            {/loop}
                                        </a>
                                    </li>
                                {/loop}
                            </ul>
                        </div>
                        {/ifloop}
                    </div>
                    {ifloop rel="image.carouselsup"}
                        <a class="left carousel-control" href="#product-thumbnails" data-slide="prev"><i class="icon-prev"></i></a>
                        <a class="right carousel-control" href="#product-thumbnails" data-slide="next"><i class="icon-next"></i></a>
                    {/ifloop}
                </div>
            </section>

            <section id="product-details">
                <div class="product-info">
                    <h1 class="name"><span itemprop="name">{$TITLE}</span></h1>
                    <span itemprop="sku" class="sku">{intl l='Ref.'}: {$REF}</span>

                    <div class="short-description">
                        <p>{$POSTSCRIPTUM}</p>
                    </div>
                </div>

                {loop name="stock_meta" type="product_sale_elements" product="$ID"}
                    {loop name="combi_meta" type="attribute_combination" product_sale_elements="$ID"}
                       {if $LOOP_COUNT == 0}
                           {if $QUANTITY == 0}

                               {assign  var="current_stock_class" value = "out-of-stock"}
                               {assign  var="current_stock_href" value = "http://schema.org/OutOfStock"}

                               {else}

                               {assign  var="current_stock_class" value = "out-of-stock"}
                               {assign  var="current_stock_href" value = "http://schema.org/OutOfStock"}

                           {/if}
                       {/if}
                    {/loop}
                {/loop}

                <div class="product-price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                    <div class="availability">
                        <span class="availibity-label">{intl l="Availability"}: </span>
                        <span itemprop="availability" href="{$current_stock_href}" class="{$current_stock_class}" id="stockInformations">
                            <span class="in">{intl l='In stock'}</span><span class="out">{intl l='Out of stock'}</span>

                        </span>
                    </div>

                    <div class="price-container">
                        {loop type="category" name="category_tag" id=$DEFAULT_CATEGORY}
                            <meta itemprop="category" content="{$TITLE}">
                        {/loop}
                        <meta itemprop="itemCondition" itemscope itemtype="http://schema.org/NewCondition"> <!-- List of condition : NewCondition, DamagedCondition, UsedCondition, RefurbishedCondition -->
                        <meta itemprop="priceCurrency" content="{currency attr="symbol"}"> <!-- List of currency : The currency used to describe the product price, in three-letter ISO format. -->
                        {if $IS_PROMO }
                        {loop name="productSaleElements_promo" type="product_sale_elements" product="{$ID}" limit="1" order="min_price"}
                            {assign var="default_product_sale_elements" value="$ID"}
                            <span class="special-price"><span itemprop="price" class="price-label">{intl l="Special Price:"} </span><span class="price">{format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"}</span></span>
                            <span class="old-price"><span class="price-label">{intl l="Regular Price:"} </span><span class="price">{format_number number="{$TAXED_PRICE}"} {currency attr="symbol"}</span></span>
                        {/loop}
                        {else}
                            <span class="regular-price"><span itemprop="price" class="price">{format_number number="{$BEST_TAXED_PRICE}"} {currency attr="symbol"}</span></span>
                        {/if}
                    </div>
                </div>

                {form name="thelia.cart.add" }
                <form id="form-product-details" action="{url path="/cart/add" }" method="post" role="form" class="form-product">
                    {form_hidden_fields form=$form}
                    <input type="hidden" name="view" value="product">
                    <input type="hidden" name="product_id" value="{$ID}">
                    {form_field form=$form field="append"}
                        <input type="hidden" name="{$name}" value="1">
                    {/form_field}


                    {if $form_error}<div class="alert alert-error">{$form_error_message}</div>{/if}


                    {form_field form=$form field="product"}
                        <input id="{$label_attr.for}" type="hidden" name="{$name}" value="{$ID}" {$attr} >
                    {/form_field}

                    <fieldset class="product-options">
                        {ifloop rel="stock"}
                        <div class="option">
                            <label for="options" class="option-heading">Options</label>
                            <div class="option-content">
                                {form_field form=$form field='product_sale_elements_id'}
                                    <select name="{$name}" class="form-control">
                                        {loop name="stock" type="product_sale_elements" product="$ID" order="min_price"}
                                            {loop name="combi" type="attribute_combination" product_sale_elements="$ID" order="alpha"}
                                                <option value="{$ID}" data-quantity="{$QUANTITY}" data-price="{format_number number="{$BEST_TAXED_PRICE}"} {currency attr="symbol"}" data-old-price="{format_number number="{$TAXED_PRICE}"} {currency attr="symbol"}">{$ATTRIBUTE_AVAILABILITY_TITLE}</option>
                                            {/loop}
                                        {/loop}
                                    </select>
                                {/form_field}
                            </div>
                        </div>
                        {/ifloop}
                    </fieldset>
                    <fieldset class="product-cart form-inline">
                        {form_field form=$form field='quantity'}
                        <div class="form-group group-qty {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
                            <label for="{$label_attr.for}">{$label}</label>
                                <input type="number" name="{$name}" id="{$label_attr.for}" class="form-control" value="{$value|default:1}" min="1" required>
                                {if $error }
                                    <span class="help-block"><i class="icon-remove"></i> {$message}</span>
                                {elseif $value != "" && !$error}
                                    <span class="help-block"><i class="icon-ok"></i></span>
                                {/if}
                        </div>
                        {/form_field}

                        <div class="form-group group-btn">
                            <button type="submit" class="btn btn_add_to_cart">{intl l="Add to cart"}</button>
                        </div>
                    </fieldset>
                </form>
                {/form}
            </section>

            <section id="product-tabs">
                <ul class="nav nav-tabs" role="tablist">
                    <li class="active" role="presentation"><a id="tab1" href="#description" data-toggle="tab" role="tab">{intl l="Description"}</a></li>
                    <li role="presentation"><a id="tab2" href="#additional" data-toggle="tab" role="tab">{intl l="Additional Info"}</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active in" id="description" itemprop="description" role="tabpanel" aria-labelledby="tab1">
                        <p>{$DESCRIPTION}</p>
                    </div>
                    <div class="tab-pane" id="additional" role="tabpanel" aria-labelledby="tab2">
                        {ifloop rel="feature_value_info"}
                        <ul>
                        {loop name="feature_info" type="feature" product="{$ID}"}
                            <li>
                                <strong>{$TITLE}</strong> :
                                {loop name="feature_value_info" type="feature_value" feature="{$ID}" product="{product attr="id"}"}
                                    {$TITLE}
                                {/loop}
                            </li>
                        {/loop}
                        </ul>
                        {/ifloop}
                    </div>
                </div>
            </section>
        </article><!-- /product -->

        <ul class="pager">
            {if $HAS_PREVIOUS == 1}
                {loop type="product" name="prev_product" id="{$PREVIOUS}"}
                    <li class="previous"><a href="{$URL}">{intl l="Previous product"}</a></li>
                {/loop}
            {/if}
            {if $HAS_NEXT == 1}
                {loop type="product" name="next_product" id="{$NEXT}"}
                    <li class="next"><a href="{$URL}">{intl l="Next product"}</a></li>
                {/loop}
            {/if}
        </ul>
       {/loop}
        </div>

    </div><!-- /.container -->


{/block}