<?php
/**
 * Maho
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2018-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Create account form template
 *
 * @var Mage_Customer_Block_Form_Register $this
 */
?>
<div class="account-create">
    <div class="page-title">
        <h1><?= $this->__('Create an Account') ?></h1>
    </div>
    <?= $this->getChildHtml('form_fields_before') ?>
    <?= $this->getMessagesBlock()->toHtml() ?>
    <?php /* Extensions placeholder */ ?>
    <?= $this->getChildHtml('customer.form.register.extra') ?>
    <form action="<?= $this->getPostActionUrl() ?>" method="post" id="form-validate" enctype="multipart/form-data">
        <div class="fieldset">
            <input type="hidden" name="success_url" value="<?= $this->getSuccessUrl() ?>" />
            <input type="hidden" name="error_url" value="<?= $this->getErrorUrl() ?>" />
            <input type="hidden" name="form_key" value="<?= Mage::getSingleton('core/session')->getFormKey() ?>" />
            <p class="required"><?= $this->__('* Required Fields') ?></p>
            <h2 class="legend"><?= $this->__('Personal Information') ?></h2>
            <ul class="form-list">
                <li class="fields">
                    <?= $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
                </li>
                <li>
                    <label for="email_address" class="required"><em>*</em><?= $this->__('Email Address') ?></label>
                    <div class="input-box">
                        <input type="email" autocapitalize="off" autocorrect="off" spellcheck="false" name="email" id="email_address" value="<?= $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?= $this->quoteEscape($this->__('Email Address')) ?>" class="input-text validate-email required-entry" />
                    </div>
                </li>
                <?php if ($this->isNewsletterEnabled()): ?>
                <li class="control">
                    <div class="input-box">
                        <input type="checkbox" name="is_subscribed" title="<?= $this->quoteEscape($this->__('Sign Up for Newsletter')) ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif ?> class="checkbox" />
                    </div>
                    <label for="is_subscribed"><?= $this->__('Sign Up for Newsletter') ?></label>
                    <?php /* Extensions placeholder */ ?>
                    <?= $this->getChildHtml('customer.form.register.newsletter') ?>
                </li>
                <?php endif ?>
            <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
            <?php if ($_dob->isEnabled()): ?>
                <li><?= $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
            <?php endif ?>
            <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
            <?php if ($_taxvat->isEnabled()): ?>
                <li><?= $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
            <?php endif ?>
            <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
            <?php if ($_gender->isEnabled()): ?>
                <li><?= $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
            <?php endif ?>
            </ul>
        </div>
    <?php if($this->getShowAddressFields()): ?>
        <div class="fieldset">
            <input type="hidden" name="create_address" value="1" />
            <h2 class="legend"><?= $this->__('Address Information') ?></h2>
            <ul class="form-list">
                <li class="fields">
                    <div class="field">
                        <label for="company"><?= $this->__('Company') ?></label>
                        <div class="input-box">
                            <input type="text" name="company" id="company" value="<?= $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?= $this->quoteEscape($this->__('Company')) ?>" class="input-text <?= $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="telephone" class="required"><em>*</em><?= $this->__('Telephone') ?></label>
                        <div class="input-box">
                            <input type="tel" name="telephone" id="telephone" value="<?= $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?= $this->quoteEscape($this->__('Telephone')) ?>" class="input-text <?= $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />
                        </div>
                    </div>
                </li>
            <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
                <li class="wide">
                    <label for="street_1" class="required"><em>*</em><?= $this->__('Street Address') ?></label>
                    <div class="input-box">
                        <input type="text" name="street[]" value="<?= $this->escapeHtml($this->getFormData()->getStreet(0)) ?>" title="<?= $this->quoteEscape($this->__('Street Address')) ?>" id="street_1" class="input-text <?= $_streetValidationClass ?>" />
                    </div>
                </li>
            <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
            <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
                <li class="wide">
                    <label for="street_<?= $_i ?>"><?= $this->__('Street Address %s', $_i) ?></label>
                    <div class="input-box">
                        <input type="text" name="street[]" value="<?= $this->escapeHtml($this->getFormData()->getStreet($_i-1)) ?>" title="<?= $this->quoteEscape($this->__('Street Address %s', $_i)) ?>" id="street_<?= $_i ?>" class="input-text <?= $_streetValidationClass ?>" />
                    </div>
                </li>
            <?php endfor ?>
                <li class="fields">
                    <div class="field">
                        <label for="city" class="required"><em>*</em><?= $this->__('City') ?></label>
                        <div class="input-box">
                            <input type="text" name="city" value="<?= $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?= $this->quoteEscape($this->__('City')) ?>" class="input-text <?= $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="region_id" class="required"><em>*</em><?= $this->__('State/Province') ?></label>
                        <div class="input-box">
                            <select id="region_id" name="region_id" title="<?= $this->quoteEscape($this->__('State/Province')) ?>" class="validate-select" style="display:none;">
                                <option value=""><?= $this->__('Please select region, state or province') ?></option>
                            </select>
                            <script type="text/javascript">
                                document.getElementById('region_id').setAttribute('defaultValue', "<?= $this->getFormData()->getRegionId() ?>");
                            </script>
                            <input type="text" id="region" name="region" value="<?= $this->escapeHtml($this->getRegion()) ?>" title="<?= $this->quoteEscape($this->__('State/Province')) ?>" class="input-text <?= $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
                        </div>
                    </div>
                </li>
                <li class="fields">
                    <div class="field">
                        <label for="zip" class="required"><em>*</em><?= $this->__('Zip/Postal Code') ?></label>
                        <div class="input-box">
                            <input type="text" name="postcode" value="<?= $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?= $this->quoteEscape($this->__('Zip/Postal Code')) ?>" id="zip" class="input-text validate-zip-international <?= $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
                        </div>
                    </div>
                    <div class="field">
                        <label for="country" class="required"><em>*</em><?= $this->__('Country') ?></label>
                        <div class="input-box">
                            <?= $this->getCountryHtmlSelect() ?>
                        </div>
                    </div>
                </li>
            </ul>
            <input type="hidden" name="default_billing" value="1" />
            <input type="hidden" name="default_shipping" value="1" />
        </div>
    <?php endif ?>
        <div class="fieldset">
            <h2 class="legend"><?= $this->__('Login Information') ?></h2>
            <ul class="form-list">
                <li class="fields">
                    <div class="field">
                        <label for="password" class="required"><em>*</em><?= $this->__('Password') ?></label>
                        <div class="input-box">
                            <?php $minPasswordLength = $this->getMinPasswordLength(); ?>
                            <input type="password"
                                   name="password"
                                   id="password"
                                   title="<?= $this->quoteEscape($this->__('Password')) ?>"
                                   class="input-text required-entry validate-password min-pass-length-<?= $minPasswordLength ?>"
                                   autocomplete="new-password" />
                            <p class="form-instructions">
                                <?= $this->__('The minimum password length is %s', $minPasswordLength) ?>
                            </p>
                        </div>
                    </div>
                    <div class="field">
                        <label for="confirmation" class="required"><em>*</em><?= $this->__('Confirm Password') ?></label>
                        <div class="input-box">
                            <input type="password" name="confirmation" title="<?= $this->quoteEscape($this->__('Confirm Password')) ?>" id="confirmation" class="input-text required-entry validate-cpassword" autocomplete="new-password" />
                        </div>
                    </div>
                </li>
                <?= $this->getChildHtml('form.additional.info') ?>
                <?= $this->getChildHtml('remember.me') ?>
            </ul>
        </div>
        <div class="buttons-set">
            <p class="back-link"><a href="<?= $this->escapeUrl($this->getBackUrl()) ?>" class="back-link"><small>&laquo; </small><?= $this->__('Back') ?></a></p>
            <button type="submit" title="<?= $this->quoteEscape($this->__('Register')) ?>" class="button"><?= $this->__('Register') ?></button>
        </div>
        <?php if (Mage::helper('checkout')->isContextCheckout()): ?>
            <input name="context" type="hidden" value="checkout" />
        <?php endif ?>
    </form>
    <script type="text/javascript">
        var dataForm = new VarienForm('form-validate', true);
        <?php if($this->getShowAddressFields()): ?>
        new RegionUpdater('country', 'region', 'region_id', <?= Mage::helper('directory')->getRegionJsonByStore() ?>, undefined, 'zip');
        <?php endif ?>
    </script>
</div>
