<div id="account-history-info">
    <h1 class="breaking-headline">
        {txt key=TEXT_PAGE_TITLE_ACCOUNT_HISTORY_INFO}
        <small>- {txt key=TEXT_ORDER_NUMBER}: {$order_data.orders_id}</small>
    </h1>

    <div class="row">
        <div class="col col-md-3">
            <div class="well">
                <p class="headline">{txt key=TEXT_SHIPPING_ADDRESS}</p>
                {if $order_data.delivery_company}{$order_data.delivery_company}<br />{/if}
                {if $order_data.delivery_company_2}{$order_data.delivery_company_2}<br />{/if}
                {if $order_data.delivery_company_3}{$order_data.delivery_company_3}<br />{/if}
                {$order_data.delivery_title}
                {$order_data.delivery_firstname} {$order_data.delivery_lastname}<br />
                {$order_data.delivery_street_address}<br />
                {if $order_data.delivery_suburb}{$order_data.delivery_suburb}<br />{/if}
                {$order_data.delivery_postcode} {$order_data.delivery_city}<br />
                {if $order_data.delivery_state}{$order_data.delivery_state}<br />{/if}
                {$order_data.delivery_country}
            </div><!-- .box -->
            <div class="well">
                <p class="headline">{txt key=TEXT_PAYMENT_ADDRESS}</p>
                {if $order_data.billing_company}{$order_data.billing_company}<br />{/if}
                {if $order_data.billing_company_2}{$order_data.billing_company_2}<br />{/if}
                {if $order_data.billing_company_3}{$order_data.billing_company_3}<br />{/if}
                {$order_data.billing_title}
                {$order_data.billing_firstname}{$order_data.billing_lastname}<br />
                {$order_data.billing_street_address}<br />
                {if $order_data.billing_suburb}{$order_data.billing_suburb}<br />{/if}
                {$order_data.billing_postcode} {$order_data.billing_city}<br />
                {if $order_data.billing_state}{$order_data.billing_state}<br />{/if}
                {$order_data.billing_country}
            </div><!-- .box -->
            {if $order_data.shipping_method!=''}
            <div class="well">
                <p class="headline">{txt key=TEXT_SHIPPING_METHOD}</p>
                {$order_data.shipping_method}
            </div><!-- .box -->
            {/if}
            {if $order_data.payment_name}
            <div class="well">
                <p class="headline">{txt key=TEXT_PAYMENT_METHOD}</p>
                {$order_data.payment_name}
            </div><!-- .box -->
            {/if}
            {if $order_data.payment_info!=''}
            <div class="well">
                <p class="headline">{txt key=TEXT_PAYMENT_INFO}</p>
                {$order_data.payment_info}
            </div><!-- .box -->
            {/if}

            {if $order_data.bank_details}
            <div class="well">
                <p class="headline-underline">{txt key='TEXT_BANK_DETAILS'}</p>
                {foreach from=$order_data.bank_details item=bd}
                    {txt key='TEXT_BAD_ACCOUNT_NAME'}: {$bd.bad_account_name}<br />
                    {txt key='TEXT_BAD_BANK_IDENTIFIER_CODE'}: {$bd.bad_bank_identifier_code}<br />
                    {if $bd.bad_due_date}{txt key='TEXT_BAD_DUE_DATE'}: {$bd.bad_due_date}<br />{/if}
                    {txt key='TEXT_BAD_INTERNATIONAL_BANK_ACCOUNT_NUMBER'}: {$bd.bad_international_bank_account_number}<br />
                    {txt key='TEXT_BAD_REFERENCE_NUMBER'}: {$bd.bad_reference_number}
                {/foreach}
            </div>
            {/if}

            {if $order_data.comments!=''}
            <div class="well">
                <p class="headline">{txt key=TEXT_ORDER_COMMENTS}</p>
                {$order_data.comments|nl2br}
            </div><!-- .box -->
            {/if}
            {hook key=account_history_info_left}
        </div><!-- .column .xt-grid-4 -->

        <div class="col col-sm-8 col-md-9">

            {$message}
            <p class="pull-right clear"><a href="{link page='customer' paction=order_overview conn=SSL}">{css_button text=$smarty.const.BUTTON_BACK}</a></p>

            <p class="headline">{txt key=TEXT_ORDER_DATE}</p>
            <p>{$order_data.date_purchased}</p>
            <hr />
            <p class="headline">{txt key=TEXT_ORDER_STATUS_HISTORY}</p>
            {foreach name=aussen item=history_values from=$order_history}
            <p>{$history_values.date_added|date_format:"%d.%m.%Y - %H:%M"}  - {$history_values.status_name}</p>
            {if $history_values.customer_show_comment eq '1'}
            <p>{$history_values.comments}</p>
            {/if}
            {/foreach}
            <br />



            {hook key=account_history_info_main_table_top}

            <script>
                document.addEventListener("DOMContentLoaded", function(event)
                {
                    let qtsInputs = document.querySelectorAll('form[id=rpt_form] input[name^=qty]');
                    //console.log(qtsInputs);
                    qtsInputs.forEach(function(el) {
                        el.disabled = false;
                    });
                });
            </script>

            {form type=form id=rpt_form name=rpt_form action='dynamic' link_params=getParams method=post conn=SSL}
            {form type=hidden name=action value=repeat_order}

            <button type="submit" class="btn btn-default" style="margin-bottom: 7px;">
                <i class="fa fa-cart-plus"></i>
                {txt key=TEXT_ADD_SELECTED_TO_CART}
            </button>

            <div id="cart-table" class="div-table table-hover table-bordered">
                <div class="row th">
                    <div class="col col-sm-8">
                        {txt key=TEXT_ARTICLE}
                    </div>
                    <div class="col col-sm-2 hidden-xs text-right">
                        {txt key=TEXT_SINGLE_PRICE}
                    </div>
                    <div class="col col-sm-2 hidden-xs text-right">
                        {txt key=TEXT_TOTAL_PRICE}
                    </div>
                </div>

                {foreach name=aussen key=key item=data from=$order_products}
                {hook key=account_history_info_foreach_order_products_top}

                <div class="row tr">
                    <div class="col col-xs-5 col-sm-2">
                        <p class="image">
                            {if !$data.products_image || $data.products_image == 'product:noimage.gif'}
                            {if $data.is_product}
                            <a href="{$data.products_link}" class="vertical-helper image-link no-image img-thumbnail">
                                <i class="no-image-icon"></i>
                            </a>
                            {else}
                            <span class="vertical-helper image-link no-image img-thumbnail">
                                    <i class="no-image-icon"></i>
                                </span>
                            {/if}
                            {elseif $data.is_product}
                            <a href="{$data.products_link}" class="vertical-helper image-link img-thumbnail">{img img=$data.products_image type=m_thumb class="productImageBorder img-responsive" alt=$data.products_name|escape:"html"}</a>
                            {else}
                            {img img=$data.products_image type=m_thumb class="productImageBorder img-responsive" alt=$data.products_name|escape:"html"}
                            {/if}
                        </p>
                    </div>
                    <div class="col col-xs-7 col-sm-6 col-lg-6">
                        {if $data.is_product}
                        <p class="product-name break-word bold"><a href="{$data.products_link}">{$data.products_name}</a></p>
                        {else}
                        <p class="product-name break-word bold">{$data.products_name}</p>
                        {/if}
                        {hook key=account_history_info_bundle}
                        {hook key=account_history_info_xt_options pid=$data.products_id}
                        <ul class="label-list fixed-padding">
                            {if $data.products_information.content}<li><span class="badge">{$data.products_information.content|replace:'<tr class="contentrow1">':''|replace:'<tr class="contentrow2">':''|replace:'<td>':''|replace:'<td class="left" colspan="4">':''|replace:'</td>':''|replace:'</tr>':''}</span></li>{/if}
                            {if $data.products_model!=''}<li><span class="badge">{txt key=TEXT_PRODUCTS_MODEL} {$data.products_model}</span></li>{/if}
                            {if $data.products_weight > 0}<li><span class="badge">{txt key=TEXT_PRODUCTS_WEIGHT} {$data.products_weight|number_format:2:",":"."} kg</span></li>{/if}
                            {if $data.shipping_status_data.name}<li><span class="badge">{txt key=TEXT_SHIPPING_STATUS} {$data.shipping_status_data.name}</span></li>{/if}
                            {if $data.base_price}<li><span class="badge">{$data.products_vpe_value|number_format_prec} {$data.base_price.vpe.name} / {$data.base_price.price} {txt key=TEXT_SHIPPING_BASE_PER} {$data.base_price.vpe.name}</span></li>{/if}
                            {if $data.stock_image}
                            <!--li class="product-stock-image">
                                <img src="{img img=$data.stock_image.image type=t_img_stockrules path_only=true}"
                                     class="img-responsive cursor-help"
                                     alt="{$data.stock_image.name}"
                                     title="{$data.stock_image.name}"
                                     data-toggle="tooltip" />
                                <span class="sr-only">{$stock_image.name}</span>
                            </li-->
                            {/if}
                        </ul>

                        {*<!-- price info visible-xs part --- start -->*}
                        <div class="hidden-sm hidden-md hidden-lg text-left-xs">
                            <span>{txt key=TEXT_SINGLE_PRICE}:</span><br />
                            <p class="product-price">
                                {$data.products_price.formated}
                            </p>
                            <span>{txt key=TEXT_TOTAL_PRICE}:</span><br />
                            <p class="product-price final-price">{$data.products_final_price.formated}</p>
                        </div>
                        {*<!-- / price info visible-xs part --- end -->*}

                        <div class="form-inline">
                            {if $data.is_product}
                            <div class="form-group form-group-sm">
                                <div class="input-group">

                                    <input type="number"
                                           class="form-control"
                                           {if $smarty.const._STORE_ALLOW_DECIMAL_QUANTITIY == 'false'}min="1"{/if}
                                    required="required"
                                    step="any"
                                    name="qty[]"
                                    autocomplete="off"
                                    id="form-qty-{$data.products_id}"
                                    value="{$data.products_quantity}"
                                    placeholder="{txt key=TEXT_QTY}"
                                    style="width: 6em"
                                    disabled="disabled" />
                                    <label for="form-qty-{$data.products_id}" class="input-group-addon text-regular">{$data.products_unit_name}</label>
                                </div>
                            </div>
                            {/if}

                            {if $data.is_product && $data.allow_add_cart}
                            <input type="checkbox" name="rpo_add_product_{$data.orders_products_id}" id="rpo_add_product_{$data.orders_products_id}" checked="checked" value="1"> <label for="rpo_add_product_{$data.orders_products_id}"> {txt key=TEXT_BUY_AGAIN}</label>
                            {form type=hidden name='orders_products_id[]' value=$data.orders_products_id}
                            {else}
                            <div class="alert alert-warning" style="margin-top: 5px; padding: 0 2px; font-size: 0.9em; display: table">{txt key=ERROR_NOT_ALLOWED_TO_PURCHASE}</div>

                            {/if}

                            {hook key=account_history_info_product}
                        </div>
                    </div>
                    <div class="col col-sm-2 hidden-xs text-right">
                        <p class="product-price">
                            {$data.products_price.formated}
                            {if $data._cart_discount_data.plain}<br />
                            <span class="price-old">{$data._original_products_price.formated}</span><br />
                            <span class="small">(-{$data._cart_discount} %)</span>
                            {/if}
                        </p>
                    </div>
                    <div class="col col-sm-2 hidden-xs text-right">
                        <p class="product-price final-price">{$data.products_final_price.formated}</p>
                    </div>
                </div>
                {/foreach}
                {hook key=account_history_info_total_top}
                <div class="row tfoot bold text-right">

                    <div class="col col-sm-offset-4 col-xs-7 col-sm-6">
                        {txt key=TEXT_SUB_TOTAL}
                    </div>
                    <div class="col  col-xs-5 col-sm-2">
                        {$total.product_total.formated}
                    </div>

                    {foreach name=aussen item=order_total_values from=$order_total_data}
                    <div class="col col-sm-offset-4 col-xs-7 col-sm-6">
                        {$order_total_values.orders_total_name}
                    </div>
                    <div class="col  col-xs-5 col-sm-2">
                        {$order_total_values.orders_total_price.formated}
                    </div>
                    {/foreach}

                    <div class="col col-sm-offset-4 col-xs-7 col-sm-6">
                        {txt key=TEXT_TOTAL}
                    </div>
                    <div class="col  col-xs-5 col-sm-2">
                        {$total.total.formated}
                    </div>

                    {foreach name=aussen item=tax_data from=$total.total_tax}
                    <div class="col col-sm-offset-4 col-xs-7 col-sm-6">
                        {txt key=TEXT_TAX} {$tax_data.tax_key}%
                    </div>
                    <div class="col  col-xs-5 col-sm-2">
                        {$tax_data.tax_value.formated}
                    </div>
                    {/foreach}

                </div>
                {hook key=account_history_info_total_tpl}
                {foreach name=aussen item=tax_data from=$cart_tax}
                <div class="row tfoot text-right">
                    <div class="col col-sm-offset-4  col-xs-7 col-sm-6">
                        {txt key=TEXT_TAX} {$tax_data.tax_key}%
                        {if $shipping_link}<br /><span class="shipping-link"><a href="{$shipping_link}" target="_blank" rel="nofollow">{txt key=TEXT_EXCL_SHIPPING}</a></span>{/if}
                    </div>
                    <div class="col  col-xs-5 col-sm-2 text-right">
                        {$tax_data.tax_value.formated|replace:"*":""}
                    </div>
                </div>
                {/foreach}

                {hook key=account_history_info_total_bottom}
            </div><!-- .div-table -->

            <button type="submit" class="btn btn-default" style="margin-top: 7px;">
                <i class="fa fa-cart-plus"></i>
                {txt key=TEXT_ADD_SELECTED_TO_CART}
            </button>
            {form type=formend}

            {hook key=account_history_info_main_table_bottom}

            <p class="pull-left"><br /><a href="{link page='customer' paction=order_overview conn=SSL}">{css_button text=$smarty.const.BUTTON_BACK}</a></p>
        </div>
    </div><!-- .row -->

    {hook key=account_history_info_bottom}

</div><!-- #account-history-info -->
