{extends file="layout.tpl"}

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

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

{block name="main-content"}

    {* This page should not replace the current previous URL *}
    {set_previous_url ignore_current="1"}

    <div class="main">

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

            <h1 id="main-label" class="page-header">{intl l="Create New Account"}</h1>
            {hook name="register.top"}
            {form name="thelia.front.customer.create"}
            <form id="form-register" class="form-horizontal" action="{url path="/register"}" method="post">
                {form_field field='success_url'}
                    <input type="hidden" name="{$name}" value="{navigate to="previous"}" /> {* the url the user is redirected to on registration success *}
                {/form_field}

                {form_field field='error_message'}
                    <input type="hidden" name="{$name}" value="{intl l="missing or invalid data"}" />
                {/form_field}
                {form_hidden_fields}
                {if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
                {hook name="register.form-top"}
                <fieldset id="register-info" class="panel panel-default">
                    <div class="panel-heading">
                        1. {intl l="Personal Information"}
                    </div>

                    <div class="panel-body">
                        {form_field field="title"}
                            <div class="form-group group-title{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <select name="{$name}" id="{$label_attr.for}" class="form-control"{if $required} aria-required="true" required{/if}{if !$value || $error} autofocus{/if}>
                                        <option value="">-- {intl l="Select Title"} --</option>
                                        {loop type="title" name="country.list"}
                                            <option value="{$ID}" {if $value == $ID}selected{/if} >{$LONG}</option>
                                        {/loop}
                                    </select>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {elseif !$value}
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}
                        {form_field field="firstname"}
                        <div class="form-group group-firstname{if $error} has-error{/if}">
                            <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                            <div class="control-input col-sm-5">
                                <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder firstname"}" value="{$value}" {if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                {if $error }
                                    <span class="help-block">{$message}</span>
                                    {assign var="error_focus" value="true"}
                                {/if}
                            </div>
                        </div><!--/.form-group-->
                        {/form_field}
                        {form_field field="lastname"}
                            <div class="form-group group-lastname{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder lastname"}" value="{$value}" {if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}
                        {form_field field="email"}
                        <div class="form-group group-email{if $error} has-error{/if}">
                            <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>

                            <div class="control-input col-sm-5">
                                <input type="email" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder email"}" value="{$smarty.get.email|default:$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                {if $error }
                                    <span class="help-block">{$message}</span>
                                    {assign var="error_focus" value="true"}
                                {/if}
                            </div>
                        </div><!--/.form-group-->
                        {/form_field}
                        {if {config key="customer_confirm_email"}}
                        {form_field field="email_confirm"}
                            <div class="form-group group-email{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>

                                <div class="control-input col-sm-5">
                                    <input type="email" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder email confirm"}" value="{$smarty.get.email|default:$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}
                        {/if}

                        {form_field field="lang_id"}
                            <div class="form-group group-lastname {if $error}has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <select name="{$name}" id="{$label_attr.for}" class="form-control">
                                        {loop type="lang" name="lang.list" visible="*" order="alpha"}
                                            <option value="{$ID}"{if (empty($value) && $ID == {lang attr='id'}) || (! empty($value) && $value == $ID)} selected{/if}>{$TITLE}</option>
                                        {/loop}
                                    </select>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}

                        {form_field field="phone"}
                            <div class="form-group group-phone{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="20" placeholder="{intl l="Placeholder phone"}" value="{$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}
                        {form_field field="cellphone"}
                            <div class="form-group group-cellphone{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="20" placeholder="{intl l="Placeholder cellphone"}" value="{$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}
                    </div>
                </fieldset>

                <fieldset id="register-delivery" class="panel panel-default">
                    <div class="panel-heading">
                        2. {intl l="Delivery Information"}
                    </div>

                    <div class="panel-body">
                        {form_field field="company"}
                            <div class="form-group group-company{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder company"}" value="{$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}

                        {form_field field="address1"}
                            <div class="form-group group-address1{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder address1"}" value="{$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}

                        {form_field field="address2"}
                            <div class="form-group group-address2{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder address2"}" value="{$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}

                        {form_field field="zipcode"}
                            <div class="form-group group-zip{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="10" placeholder="{intl l="Placeholder zipcode"}" value="{$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}

                        {form_field field="city"}
                            <div class="form-group group-city{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder city"}" value="{$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}

                        {form_field field="country"}
                            {$countryFieldId=$label_attr.for}
                            <div class="form-group group-country{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <select name="{$name}" id="{$label_attr.for}" class="form-control"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                        <option value="">-- {intl l="Select Country"} --</option>
                                        {loop type="country" name="country.list" order="alpha"}
                                            <option value="{$ID}"
                                                    {if $value != ""}
                                                        {if $value == $ID}selected{/if}
                                                    {else}
                                                        {if $IS_DEFAULT}selected{/if}
                                                    {/if}

                                            >{$TITLE}</option>
                                        {/loop}
                                    </select>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}

                        {form_field field="state"}
                            <div class="form-group group-state{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <select name="{$name}" id="{$label_attr.for}"
                                            data-thelia-state="1" data-thelia-country="#{$countryFieldId}" data-thelia-toggle=".group-state"
                                            class="form-control"{if !isset($error_focus) && $error} autofocus{/if}>
                                        <option value="">-- {intl l="Select State"} --</option>
                                        {loop type="state" name="state.list"}
                                            <option value="{$ID}" data-country="{$COUNTRY}"
                                                {if $value != ""}
                                                    {if $value == $ID}selected{/if}
                                                {/if}
                                                >{$TITLE}</option>
                                        {/loop}
                                    </select>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}
                    </div>
                </fieldset>
                <fieldset id="register-login" class="panel panel-info">
                    <div class="panel-heading">
                        3. {intl l="Login Information"}
                    </div>

                    <div class="panel-body">
                        {form_field field="password"}
                            <div class="form-group group-password{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" autocomplete="off"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}

                        {form_field field="password_confirm"}
                            <div class="form-group group-password_confirm{if $error} has-error{/if}">
                                <label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
                                <div class="control-input col-sm-5">
                                    <input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" autocomplete="off"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
                                    {if $error }
                                        <span class="help-block">{$message}</span>
                                        {assign var="error_focus" value="true"}
                                    {/if}
                                </div>
                            </div><!--/.form-group-->
                        {/form_field}
                    </div>
                </fieldset>

                {form_field field="newsletter"}
                    <div class="form-group group-newsletter{if $error} has-error{/if}">
                        <div class="control-input col-xs-11 col-sm-9 col-xs-offset-1 col-md-offset-3">
                            <div class="checkbox">
                                <label class="control-label" for="{$label_attr.for}">
                                    <input type="checkbox" name="{$name}" id="{$label_attr.for}" value="{$value}"{if $checked} checked{/if}  {if $required} aria-required="true" required{/if}>{$label}
                                </label>
                                {if $error }
                                    <span class="help-block">{$message}</span>
                                {/if}
                            </div>
                        </div>
                    </div><!--/.form-group-->
                {/form_field}

                {hook name="register.form-bottom"}

                <div class="form-group group-btn">
                    <div class="control-btn col-sm-5 col-sm-offset-3">
                        <button type="submit" class="btn btn-primary"><i class="fa fa-chevron-right"></i> {intl l="Register"}</button>
                    </div>
                </div><!--/.form-group-->
            </form>
            {/form}

            {hook name="register.bottom"}
        </article>

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


{block name="stylesheet"}
{hook name="register.stylesheet"}
{/block}

{block name="after-javascript-include"}
{hook name="register.after-javascript-include"}
{/block}

{block name="javascript-initialization"}
{hook name="register.javascript-initialization"}
{/block}
