<?php
/**
 * OpenMage
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available at https://opensource.org/license/afl-3-0-php
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://www.openmage.org)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * @see Mage_Authorizenet_Block_Directpost_Form
 * @var Mage_Authorizenet_Block_Directpost_Form $this 
 */
?>
<?php
$_form = $this;
$_code = $_form->getMethodCode();
$_method = $_form->getMethod();
$_controller = $this->helper('authorizenet')->getControllerName();
$_orderUrl = $this->helper('authorizenet')->getPlaceOrderFrontUrl();
?>
<div class="buttons-set">
<!-- IFRAME for request to Authorize.net -->
<iframe id="directpost-iframe" allowtransparency="true" frameborder="0"  name="iframeDirectPost" style="display:none;width:100%;background-color:transparent" src="<?php echo $this->getJsUrl() ?>blank.html"></iframe>

<form id="co-directpost-form" action="#" method="post">
<div class="fieldset">
<dl class="sp-methods">
<dt class="a-center"><?php echo $this->__('Credit Card Information') ?></dt>
<dd>
<ul id="payment_form_<?php echo $_code ?>" class="form-list">
    <li>
        <label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
        <div class="input-box">
            <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
                <option value=""><?php echo $this->__('--Please Select--')?></option>
            <?php $_ccType = $_form->getInfoData('cc_type') ?>
            <?php foreach ($_form->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
                <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
            <?php endforeach ?>
            </select>
        </div>
    </li>
    <li>
        <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
        <div class="input-box">
            <input type="text" pattern="\d*" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Credit Card Number')) ?>" class="input-text validate-cc-number validate-cc-type" value="" />
        </div>
    </li>
    <li id="<?php echo $_code ?>_cc_type_exp_div">
        <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
        <div class="input-box">
            <div class="v-fix">
                <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
                <?php $_ccExpMonth = $_form->getInfoData('cc_exp_month') ?>
                <?php foreach ($_form->getCcMonths() as $k=>$v): ?>
                    <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
                <?php endforeach ?>
                </select>
            </div>
            <div class="v-fix">
                <?php $_ccExpYear = $_form->getInfoData('cc_exp_year') ?>
                <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
                <?php foreach ($_form->getCcYears() as $k=>$v): ?>
                    <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
                <?php endforeach ?>
                </select>
            </div>
        </div>
    </li>
    <?php echo $_form->getChildHtml() ?>
    <?php if($_form->hasVerification()): ?>
    <li id="<?php echo $_code ?>_cc_type_cvv_div">
        <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
        <div class="input-box">
            <div class="v-fix">
                <input type="text" pattern="\d*" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Card Verification Number')) ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" />
            </div>
            <a href="#" id="directpost-cvv-what-is-this" style="cursor:help; margin-left:5px;"><?php echo $this->__('What is this?') ?></a>
        </div>
    </li>
    <?php endif ?>
</ul>
</dd>
</dl>
</div>
</form>
</div>
<div class="tool-tip" id="directpost-tool-tip" style="display:none;">
    <div class="btn-close"><a href="#" id="directpost-tool-tip-close" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Close')) ?>"><?php echo $this->__('Close') ?></a></div>
    <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Card Verification Number Visual Reference')) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Card Verification Number Visual Reference')) ?>" /></div>
</div>
<script type="text/javascript">
//<![CDATA[
if ($('directpost-cvv-what-is-this')) {
    $('directpost-cvv-what-is-this').observe('click', toggleCvvToolTip);
}
new Validation('co-directpost-form');
function toggleCvvToolTip(event){
    if($('directpost-tool-tip')){
        $('directpost-tool-tip').setStyle({
            top: (Event.pointerY(event)-560)+'px'
        })
        $('directpost-tool-tip').toggle();
    }
    Event.stop(event);
}
if($('directpost-tool-tip-close')){
    Event.observe($('directpost-tool-tip-close'), 'click', toggleCvvToolTip);
}
directPostModel = new directPost(
    '<?php echo $_code ?>',
    'directpost-iframe',
    '<?php echo $_controller ?>',
    '<?php echo $_orderUrl ?>',
    '<?php echo $_method->getCgiUrl() ?>',
    '<?php echo $this->getUrl('checkout/onepage/saveOrder', ['_secure' => $this->getRequest()->isSecure()]) ?>');
//]]>
</script>
