<?php
/**
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the GNU General Public License (GPL 3)
 * that is bundled with this package in the file LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
 * versions in the future. If you wish to customize Payone_Core for your
 * needs please refer to http://www.payone.de for more information.
 *
 * @category        Payone
 * @package         design_frontend_base_default
 * @subpackage      template
 * @copyright       Copyright (c) 2012 <info@noovias.com> - www.noovias.com
 * @author          Matthias Walter <info@noovias.com>
 * @license         <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
 * @link            http://www.noovias.com
 */

/** @var $this Payone_Core_Block_Payment_Method_Form_DebitPayment */

$code = $this->getMethodCode();
$paymentConfigId = $this->getPaymentConfig()->getId();
$owner = $this->escapeHtml($this->getInfoData('payone_account_owner') ? $this->getInfoData('payone_account_owner') : $this->getBillingName());

$configShowBankData = $this->getPaymentConfig()->getSepaDeShowBankData();
?>
<fieldset class="form-list">
    <ul id="payment_form_<?php echo $code ?>" style="display:none">
        <li>
            <div class="input-box">
                <label for="<?php echo $code ?>_bank_country">
                    <?php echo $this->__('Bank country') ?>&nbsp;<span class="required">*</span>
                </label>
                <br class="clear"/>
                <select id="<?php echo $code ?>_bank_country" name="payment[payone_bank_country]"
                    class="no-submit required-entry" onchange="showBankData('<?php echo $code ?>', <?php echo $configShowBankData; ?>);">
                <option value=""><?php echo $this->__('--Please Select--') ?></option>
                <?php
                foreach ($this->getSelectedSepaCountries() as $key => $country):
                    $selected = $this->getCountry() == $key ? 'selected="selected"' : '';
                    ?>
                    <option value="<?php echo $key ?>"<?php echo $selected; ?>>
                        <?php echo $this->__($country) ?>
                    </option>
                    <?php endforeach; ?>
            </select>
            </div>
        </li>
        <li id="input_box_payone_sepa_iban">
            <div class="input-box">
                <label for="<?php echo $code ?>_sepa_iban_xxx">
                    <?php echo $this->__('IBAN') ?>
                </label>
                <br class="clear"/>
                <input type="text" id="<?php echo $code ?>_sepa_iban_xxx"
                       title="<?php echo $this->__('IBAN') ?>"
                       class="validate-sepa-iban required-entry input-text"
                       value="<?php echo $this->strToXXX($this->getSavedCustomerData('payone_sepa_iban'));?>"
                       autocomplete="off" maxlength="34"
                       onchange="inputToUppaerCaseAndNumbers(this); copyDebitPaymentSepaIban('<?php echo $code ?>'); blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>); checkIbanCountryCode('<?php echo $code ?>');"
                       oninput="inputToUppaerCaseAndNumbers(this); copyDebitPaymentSepaIban('<?php echo $code ?>'); blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>); checkIbanCountryCode('<?php echo $code ?>');"/>
                <input type="hidden" id="<?php echo $code ?>_sepa_iban" name="payment[payone_sepa_iban]"
                       value="<?php echo $this->getSavedCustomerData('payone_sepa_iban');?>">
            </div>
        </li>
        <?php if ($this->getSepaRequestBic() === true): ?>
            <li id="input_box_payone_sepa_bic">
                <div class="input-box">
                    <label for="<?php echo $code ?>_sepa_bic">
                        <?php echo $this->__('BIC') ?>
                    </label>
                    <br class="clear"/>
                    <input type="text" id="<?php echo $code ?>_sepa_bic" name="payment[payone_sepa_bic]"
                           title="<?php echo $this->__('BIC') ?>"
                           class="validate-sepa-bic required-entry input-text"
                           value="<?php echo $this->getSavedCustomerData('payone_sepa_bic');?>"
                           autocomplete="off" maxlength="11"
                           onchange="inputToUppaerCaseAndNumbers(this); blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>);"
                           oninput="inputToUppaerCaseAndNumbers(this); blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>);"/>
                </div>
            </li>
        <?php endif; ?>
        <?php if ($configShowBankData): ?>
        <li id="input_box_payone_account_number">
            <?php echo $this->__('or enter your bank account data (only for German accounts):'); ?>
            <div class="input-box">
                <label for="<?php echo $code ?>_account_number">
                    <?php echo $this->__('Account number') ?>
                </label>
                <br class="clear"/>
                <input type="text" id="<?php echo $code ?>_account_number" name="payment[payone_account_number]"
                       title="<?php echo $this->__('Account number') ?>"
                       class="validate-digits input-text"
                       value="<?php echo $this->getSavedCustomerData('payone_account_number');?>"
                       autocomplete="off" maxlength="10"
                       onchange="inputToNumbers(this); blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>);"
                       oninput="inputToNumbers(this); blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>);"/>
            </div>
        </li>
        <li id="input_box_payone_bank_code">
            <div class="input-box">
                <label for="<?php echo $code ?>_bank_code">
                    <?php echo $this->__('Bank code') ?>
                </label>
                <br class="clear"/>
                <input type="text" id="<?php echo $code ?>_bank_code" name="payment[payone_bank_code]"
                       title="<?php echo $this->__('Bank code') ?>" class="validate-bank-code validate-digits input-text"
                       value="<?php echo $this->getSavedCustomerData('payone_bank_code');?>"
                       maxlength="8"
                       onchange="inputToNumbers(this); blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>);"
                       oninput="inputToNumbers(this); blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>);"/>
            </div>
        </li>
        <?php endif; ?>
        <li>
            <input type="hidden" name="payment[payone_config_payment_method_id]"
                   value="<?php echo $paymentConfigId; ?>"/>
        </li>
    </ul>
</fieldset>

<script type="text/javascript">
    //    Add validation messages translation
    Translator.add('Bank code must contain 8 digits', '<?php echo $this->__('Bank code must contain 8 digits'); ?>');
    Translator.add('IBAN should contain only letters and digits', '<?php echo $this->__('IBAN should contain only letters and digits'); ?>');
    Translator.add('BIC can contain only 8-11 characters (letters and digits)', '<?php echo $this->__('BIC can contain only 8-11 characters (letters and digits)'); ?>');
    Translator.add('Entered IBAN is not valid for selected bank country', '<?php echo $this->__('IBAN ist nicht gültig für gewähltes Bankland'); ?>');

    showBankData('<?php echo $code ?>', <?php echo $configShowBankData; ?>);
    blockPaymentMethodInputs('<?php echo $code ?>', <?php echo $configShowBankData; ?>)
</script>
