{extends file="layout.tpl"}

{* Security *}
{block name="no-return-functions" prepend}
    {check_auth role="CUSTOMER" login_tpl="login"}
{/block}

{* Breadcrumb *}
{block name='no-return-functions' append}
    {$breadcrumbs = [
        ['title' => {intl l="Account"}, 'url'=>{url path="/account"}]
    ]}
{/block}

{block name="body-class"}page-account{/block}

{block name="main-content"}
    <div class="main">

        <article class="col-main" role="main" aria-labelledby="main-label">

            <h1 id="main-label" class="page-header">{intl l="My Account"}</h1>

            <div id="account" class="panel-group">
                <div class="panel account-info">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <a class="accordion-toggle" data-toggle="collapse" data-parent="#account" href="#account-info">
                                {intl l="Personal Information"}
                            </a>
                        </h4>
                    </div>
                    <div id="account-info" class="panel-collapse collapse in">
                        {loop type="customer" name="customer.info"}
                        <div class="panel-body">
                            <p class="fn">{loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$FIRSTNAME|ucwords} {$LASTNAME|upper}</p>
                            {loop type="address" name="address.default" default="true"}
                            <ul class="list-info">
                                <li>
                                    <address class="adr">
                                        <span class="street-address">{$ADDRESS1}</span><br>
                                        {if $ADDRESS2 != ""}
                                            <span class="extended-address">{$ADDRESS2}</span><br>
                                        {/if}
                                        {if $ADDRESS3 != ""}
                                            <span class="extended-address">{$ADDRESS3}</span><br>
                                        {/if}
                                        <span class="postal-code">{$ZIPCODE}</span>
                                        <span class="locality">{$CITY}<br><span class="country-name">{loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop}</span></span>
                                    </address>
                                </li>
                                <li>
                                    {if $PHONE != ""}
                                        <span class="tel">{$PHONE}</span>
                                    {/if}
                                    {if $CELLPHONE != ""}
                                        <span class="mobile">{$CELLPHONE}</span>
                                    {/if}
                                    <span class="email">{mailto address="{$EMAIL}" encode="hex"}</span>
                                </li>
                                <li class="group-btn">
                                    <a href="{url path="/account/update"}" class="btn btn-change-account"><i class="icon-pencil"></i> {intl l="Change my account information"}</a>
                                    <a href="{url path="/account/password"}" class="btn btn-change-password"><i class="icon-lock"></i> {intl l="Change my password"}</a>
                                </li>
                            </ul>
                            {/loop}
                        </div>
                        {/loop}
                    </div>
                </div>
                <div class="panel account-address">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#account" href="#account-address">
                                {intl l="My Address book"}
                            </a>
                        </h4>
                    </div>
                    <div id="account-address" class="panel-collapse collapse">
                        <div class="panel-body">
                            <a href="{url path="/address/create"}" class="btn btn-add-address">{intl l="Add a new address"}</a>
                            <table class="table table-address" role="presentation" summary="{intl l="My Address Books"}">
                                <tbody>
                                {loop type="address" name="customer.addresses" customer="current"}
                                <tr class="{if $DEFAULT == 1}address-primary{else}address-additional{/if}" id="customer-address-{$ID}">
                                    <th>{$LABEL|default:"{intl l='Address %nb' nb={$LOOP_COUNT}}"}</th>
                                    <td>
                                        <ul class="list-address">
                                            <li>
                                                <span class="fn">{loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$FIRSTNAME|ucwords} {$LASTNAME|upper}</span>
                                                {if $COMPANY}
                                                    <span class="org">{$COMPANY}</span>
                                                {/if}
                                            </li>
                                            <li>
                                                <address class="adr">
                                                    <span class="street-address">{$ADDRESS1}</span><br>
                                                    {if $ADDRESS2 != ""}
                                                        <span class="street-address">{$ADDRESS2}</span><br>
                                                    {/if}
                                                    {if $ADDRESS3 != ""}
                                                        <span class="street-address">{$ADDRESS3}</span><br>
                                                    {/if}
                                                    <span class="postal-code">{$ZIPCODE}</span>
                                                    <span class="locality">{$CITY}, <span class="country-name">{loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop}</span></span>
                                                </address>
                                            </li>
                                            <li>
                                                {if $CELLPHONE != ""}
                                                    <span class="tel">{$CELLPHONE}</span><br>
                                                {/if}
                                                {if $PHONE != ""}
                                                    <span class="tel">{$PHONE}</span><br>
                                                {/if}
                                            </li>
                                        </ul>
                                    </td>
                                    <td>
                                        <div class="group-btn">
                                            <a href="{url path="/address/update/{$ID}"}" class="btn btn-edit-address" data-toggle="tooltip" title="{intl l="Edit this address"}"><i class="icon-pencil"></i> <span>{intl l="Edit"}</span></a>
                                            {if $DEFAULT != 1}
                                                <a href="{url path="/address/delete/{$ID}"}" class="btn btn-remove-address" data-confirm="{intl l="Do you really want to delete this address ?"}" data-confirm-callback="address.delete" title="{intl l="Remove this address"}" data-toggle="tooltip"><i class="icon-remove"></i> <span>{intl l="Cancel"}</span></a>
                                            {/if}
                                        </div>
                                    </td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="panel account-orders">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#account" href="#account-orders">
                                {intl l="My Orders"}
                            </a>
                        </h4>
                    </div>
                    <div id="account-orders" class="panel-collapse collapse">
                        <div class="panel-body table-responsive">
                            {ifloop rel="customer.orders"}
                            <table class="table table-orders" summary="{intl l="List of orders"}">
                                <thead>
                                <tr>
                                    <th>{intl l="Order number"}</th>
                                    <th>{intl l="Date"}</th>
                                    <th>{intl l="Amount"}</th>
                                    <th>{intl l="Status"}</th>
                                    <th>{intl l="View"}</th>
                                </tr>
                                </thead>
                                <tbody>
                                {loop type="order" name="customer.orders"}
                                <tr>
                                    <td>{$REF}</td>
                                    <td>{format_date date=$CREATE_DATE}</td>
                                    <td>{format_number number=$TOTAL_TAXED_AMOUNT} {loop type="currency" name="order.currency" id={$CURRENCY}}{$SYMBOL}{/loop}</td>
                                    <td>{loop type="order-status" name="order.status" id={$STATUS}}{assign "orderStatusLabel" "order_$CODE"}<span class="label label-{#$orderStatusLabel#}">{$TITLE}</span>{/loop}</td>
                                    <td>
                                    {if $STATUS >=2}
                                        <a href="{url path="/account/order/pdf/invoice/$ID"}" class="btn btn-order-details" data-toggle="tooltip" title="{intl l="View order %ref as pdf document" ref={$REF}}"><span class="icon-cloud-download"></span> {intl l="Order details"}</a>
                                    {/if}
                                    </td>
                                </tr>
                                {/loop}

                                </tbody>
                            </table>
                            {/ifloop}
                            {elseloop rel="customer.orders"}
                            <div class="orders-warning">
                                <strong>{intl l="Warning"}!</strong> {intl l="You don't have orders yet."}
                            </div>
                            {/elseloop}
                        </div>
                    </div>
                </div>
            </div>
        </article>

    </div><!-- /.layout -->
{/block}

{block name="after-javascript-include"}{/block}