<?php
/* Smarty version 3.1.36, created on 2024-02-25 14:13:57
  from '/home/speedwincom/public_html/sistema/templates/digit/account-paymentmethods-manage.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.36',
  'unifunc' => 'content_65db755507ebd0_56280710',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '9f1266c0f3b278075c564421ebfc39addf21f8ff' => 
    array (
      0 => '/home/speedwincom/public_html/sistema/templates/digit/account-paymentmethods-manage.tpl',
      1 => 1708881089,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_65db755507ebd0_56280710 (Smarty_Internal_Template $_smarty_tpl) {
echo '<script'; ?>
 type="text/javascript" src="<?php echo $_smarty_tpl->tpl_vars['BASE_PATH_JS']->value;?>
/StatesDropdown.js"><?php echo '</script'; ?>
>
<h3 style="margin-top:0;">
    <?php if ($_smarty_tpl->tpl_vars['editMode']->value) {?>
        <?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['editPaymentMethod'];?>

    <?php } else { ?>
        <?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['addPaymentMethod'];?>

    <?php }?>
</h3>

<form id="frmManagePaymentMethod" class="form-horizontal frm-credit-card-input" role="form" method="post" action="<?php if ($_smarty_tpl->tpl_vars['editMode']->value) {
echo routePath('account-paymentmethods-save',$_smarty_tpl->tpl_vars['payMethod']->value->id);
} else {
echo routePath('account-paymentmethods-add');
}?>">
    <div class="alert alert-warning text-center gateway-errors assisted-cc-input-feedback" style="display: none;">
        <?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['invalidCardDetails'];?>

    </div>

    <div class="form-group">
        <label for="inputPaymentMethodType" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethods']['type'];?>
</label>
        <div class="col-sm-8">
            <?php if ($_smarty_tpl->tpl_vars['enabledTypes']->value['tokenGateways']) {?>
                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['tokenGateways']->value, 'tokenGateway');
$_smarty_tpl->tpl_vars['tokenGateway']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['tokenGateway']->value) {
$_smarty_tpl->tpl_vars['tokenGateway']->do_else = false;
?>
                    <label class="radio-inline icheck-label">
                        <input type="radio" class="icheck-button" name="type" value="token_<?php echo $_smarty_tpl->tpl_vars['tokenGateway']->value;?>
" data-tokenised="true" data-gateway="<?php echo $_smarty_tpl->tpl_vars['tokenGateway']->value;?>
"<?php if ($_smarty_tpl->tpl_vars['editMode']->value && $_smarty_tpl->tpl_vars['payMethod']->value->isCreditCard() && $_smarty_tpl->tpl_vars['payMethod']->value->gateway_name == $_smarty_tpl->tpl_vars['tokenGateway']->value) {?> checked<?php }
if ($_smarty_tpl->tpl_vars['editMode']->value) {?> disabled<?php }?>>
                        <?php echo $_smarty_tpl->tpl_vars['gatewayDisplayNames']->value[$_smarty_tpl->tpl_vars['tokenGateway']->value];?>

                    </label>
                <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
            <?php }?>
            <?php if ($_smarty_tpl->tpl_vars['enabledTypes']->value['localCreditCard']) {?>
                <label class="radio-inline icheck-label">
                    <input type="radio" class="icheck-button" name="type" value="localcard"<?php if (($_smarty_tpl->tpl_vars['editMode']->value && $_smarty_tpl->tpl_vars['payMethod']->value->isCreditCard() && !$_smarty_tpl->tpl_vars['payMethod']->value->isTokenised()) || (!$_smarty_tpl->tpl_vars['editMode']->value && $_smarty_tpl->tpl_vars['paymentMethodType']->value != 'bankacct')) {?> checked<?php }
if ($_smarty_tpl->tpl_vars['editMode']->value) {?> disabled<?php }?>>
                    <?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['creditCard'];?>

                </label>
            <?php }?>
            <?php if ($_smarty_tpl->tpl_vars['enabledTypes']->value['bankAccount']) {?>
                <label class="radio-inline icheck-label">
                    <input type="radio" class="icheck-button" name="type" value="bankacct"<?php if (($_smarty_tpl->tpl_vars['editMode']->value && !$_smarty_tpl->tpl_vars['payMethod']->value->isCreditCard()) || ($_smarty_tpl->tpl_vars['paymentMethodType']->value == 'bankacct')) {?> checked<?php }
if ($_smarty_tpl->tpl_vars['editMode']->value) {?> disabled<?php }?>>
                    <?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['bankAccount'];?>

                </label>
            <?php }?>
        </div>
    </div>
    <div class="fieldgroup-auxfields<?php if ($_smarty_tpl->tpl_vars['remoteUpdate']->value) {?> hidden<?php }?>">
        <div class="form-group">
            <label for="inputDescription" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethods']['description'];?>
</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" id="inputDescription" name="description" autocomplete="off" value="<?php echo $_smarty_tpl->tpl_vars['payMethod']->value->description;?>
" style="display:inline-block;width:400px;">
                <span class="text-muted"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['optional'];?>
</span>
            </div>
        </div>
    </div>
    <div class="fieldgroup-loading hidden">
        <div style="padding:30px;text-align:center;">
            <i class="fas fa-spinner fa-spin"></i>
            <?php echo $_smarty_tpl->tpl_vars['LANG']->value['pleasewait'];?>

        </div>
    </div>
    <div class="fieldgroup-creditcard<?php if ($_smarty_tpl->tpl_vars['editMode']->value && !$_smarty_tpl->tpl_vars['payMethod']->value->isCreditCard() || $_smarty_tpl->tpl_vars['paymentMethodType']->value == 'bankacct' || $_smarty_tpl->tpl_vars['remoteUpdate']->value) {?> hidden<?php }?>">
        <div class="cc-details">
            <div class="form-group">
                <label for="inputCardNumber" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['creditcardcardnumber'];?>
</label>
                <div class="col-sm-8">
                    <div class="row">
                        <div class="col-sm-6">
                            <input type="tel" class="form-control cc-number-field <?php echo strtolower($_smarty_tpl->tpl_vars['creditCard']->value->getCardType());?>
" id="inputCardNumber" name="ccnumber" autocomplete="cc-number" value="<?php echo $_smarty_tpl->tpl_vars['creditCard']->value->getMaskedCardNumber();?>
"<?php if (!$_smarty_tpl->tpl_vars['creditCardNumberFieldEnabled']->value) {?> disabled<?php }?> aria-describedby="cc-type" data-message-unsupported="<?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['lang'][0], array( array('key'=>'paymentMethodsManage.unsupportedCardType'),$_smarty_tpl ) );?>
" data-message-invalid="<?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['lang'][0], array( array('key'=>'paymentMethodsManage.cardNumberNotValid'),$_smarty_tpl ) );?>
" data-supported-cards="<?php echo $_smarty_tpl->tpl_vars['supportedCardTypes']->value;?>
">
                        </div>
                    </div>
                    <span class="field-error-msg"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['cardNumberNotValid'];?>
</span>
                </div>
            </div>
            <?php if ($_smarty_tpl->tpl_vars['startDateEnabled']->value) {?>
                <div class="form-group">
                    <label for="inputCardStart" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['creditcardcardstart'];?>
</label>
                    <div class="col-sm-8">
                        <div class="row">
                            <div class="col-sm-4">
                                <input type="tel" class="form-control" id="inputCardStart" name="ccstart" autocomplete="off" value="<?php if ($_smarty_tpl->tpl_vars['creditCard']->value->getStartDate()) {
echo $_smarty_tpl->tpl_vars['creditCard']->value->getStartDate()->format('m / y');
}?>">
                            </div>
                        </div>
                    </div>
                </div>
            <?php }?>
            <div class="form-group">
                <label for="inputCardExpiry" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['creditcardcardexpires'];?>
</label>
                <div class="col-sm-8">
                    <div class="row">
                        <div class="col-sm-4">
                            <input type="tel" class="form-control" id="inputCardExpiry" name="ccexpiry" autocomplete="cc-exp" value="<?php if ($_smarty_tpl->tpl_vars['creditCard']->value->getExpiryDate()) {
echo $_smarty_tpl->tpl_vars['creditCard']->value->getExpiryDate()->format('m / y');
}?>"<?php if (!$_smarty_tpl->tpl_vars['creditCardExpiryFieldEnabled']->value) {?> disabled<?php }?>>
                        </div>
                    </div>
                    <span class="field-error-msg"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['expiryDateNotValid'];?>
</span>
                </div>
            </div>
            <?php if ($_smarty_tpl->tpl_vars['issueNumberEnabled']->value) {?>
                <div class="form-group">
                    <label for="inputCardIssue" class="col-sm-4 col-xs-12 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['creditcardcardissuenum'];?>
</label>
                    <div class="col-sm-2 col-xs-4">
                        <input type="tel" class="form-control" id="inputCardIssue" name="ccissuenum" autocomplete="off" value="<?php echo $_smarty_tpl->tpl_vars['creditCard']->value->getIssueNumber();?>
">
                    </div>
                </div>
            <?php }?>
            <?php if ($_smarty_tpl->tpl_vars['creditCardCvcFieldEnabled']->value) {?>
                <div class="form-group">
                    <label for="inputCardCvc" class="col-sm-4 col-xs-12 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['creditcardcvvnumber'];?>
</label>
                    <div class="col-sm-8">
                        <input type="tel" class="form-control input-inline input-inline-100" id="inputCardCvc" name="cardcvv" autocomplete="off">
                        <button id="cvvWhereLink" type="button" class="btn btn-link" data-toggle="popover" data-content="<img src='<?php echo $_smarty_tpl->tpl_vars['BASE_PATH_IMG']->value;?>
/ccv.gif' width='210'>">
                            <?php echo $_smarty_tpl->tpl_vars['LANG']->value['creditcardcvvwhere'];?>

                        </button>
                        <div class="clearfix"></div>
                        <span class="field-error-msg"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['cvcNumberNotValid'];?>
</span>
                    </div>
                </div>
            <?php }?>
        </div>
    </div>
    <div class="fieldgroup-bankaccount<?php if ($_smarty_tpl->tpl_vars['remoteUpdate']->value || ($_smarty_tpl->tpl_vars['editMode']->value && $_smarty_tpl->tpl_vars['payMethod']->value->isCreditCard()) || ($_smarty_tpl->tpl_vars['paymentMethodType']->value != 'bankacct' && !$_smarty_tpl->tpl_vars['editMode']->value)) {?> hidden<?php }?>">
        <div class="form-group">
            <label for="inputBankAcctType" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['accountType'];?>
</label>
            <div class="col-sm-8">
                <label class="radio-inline icheck-label">
                    <input type="radio" class="icheck-button" name="bankaccttype" id="inputBankAcctType" value="Checking"<?php if (!$_smarty_tpl->tpl_vars['bankAccount']->value->getAccountType() || $_smarty_tpl->tpl_vars['bankAccount']->value->getAccountType() == 'Checking') {?> checked<?php }?>>
                    <?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['checking'];?>

                </label>
                <label class="radio-inline icheck-label">
                    <input type="radio" class="icheck-button" name="bankaccttype" value="Savings"<?php if ($_smarty_tpl->tpl_vars['bankAccount']->value->getAccountType() == 'Savings') {?> checked<?php }?>>
                    <?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['savings'];?>

                </label>
            </div>
        </div>
        <div class="form-group">
            <label for="inputBankAcctHolderName" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['accountHolderName'];?>
</label>
            <div class="col-sm-4">
                <input type="tel" class="form-control" id="inputBankAcctHolderName" name="bankacctholdername" autocomplete="off" value="<?php echo $_smarty_tpl->tpl_vars['bankAccount']->value->getAccountHolderName();?>
">
                <span class="field-error-msg"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethods']['fieldRequired'];?>
</span>
            </div>
        </div>
        <div class="form-group">
            <label for="inputBankName" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['bankName'];?>
</label>
            <div class="col-sm-4">
                <input type="tel" class="form-control" id="inputBankName" name="bankname" autocomplete="off" value="<?php echo $_smarty_tpl->tpl_vars['bankAccount']->value->getBankName();?>
">
                <span class="field-error-msg"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethods']['fieldRequired'];?>
</span>
            </div>
        </div>
        <div class="form-group">
            <label for="inputBankRoutingNum" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['sortCodeRoutingNumber'];?>
</label>
            <div class="col-sm-4">
                <input type="tel" class="form-control" id="inputBankRoutingNum" name="bankroutingnum" autocomplete="off" value="<?php echo $_smarty_tpl->tpl_vars['bankAccount']->value->getRoutingNumber();?>
">
                <span class="field-error-msg"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['routingNumberNotValid'];?>
</span>
            </div>
        </div>
        <div class="form-group">
            <label for="inputBankAcctNum" class="col-sm-4 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['accountNumber'];?>
</label>
            <div class="col-sm-4">
                <input type="tel" class="form-control" id="inputBankAcctNum" name="bankacctnum" autocomplete="off" value="<?php echo $_smarty_tpl->tpl_vars['bankAccount']->value->getAccountNumber();?>
">
                <span class="field-error-msg"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['accountNumberNotValid'];?>
</span>
            </div>
        </div>
    </div>
    <div class="fieldgroup-auxfields<?php if ($_smarty_tpl->tpl_vars['remoteUpdate']->value) {?> hidden<?php }?>">
        <div class="form-group">
            <label for="inputBillingAddress" class="col-sm-4 col-xs-12 control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['billingAddress'];?>
</label>
            <div class="col-sm-8">
                <div id="billingContactsContainer">
                    <?php $_smarty_tpl->_subTemplateRender(((string)$_smarty_tpl->tpl_vars['template']->value)."/account-paymentmethods-billing-contacts.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, true);
?>
                </div>
                <br>
                <a href="#" class="btn btn-default btn-sm" data-toggle="modal" data-target="#modalBillingAddress"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['addNewAddress'];?>
</a>
            </div>
        </div>
        <div class="form-group submit-container">
            <div class="col-sm-8 col-sm-offset-4">
                <button type="submit" name="submit" id="btnSubmit" class="btn btn-primary"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareasavechanges'];?>
</button>
                <a href="<?php echo routePath('account-paymentmethods');?>
" class="btn btn-default"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['cancel'];?>
</a>
            </div>
        </div>
    </div>
    <input type="hidden" name="billing_name" id="inputBillingName" value="">
    <input type="hidden" name="billing_address_1" id="inputBillingAddress1" value="">
    <input type="hidden" name="billing_address_2" id="inputBillingAddress2" value="">
    <input type="hidden" name="billing_city" id="inputBillingCity" value="">
    <input type="hidden" name="billing_state" id="inputBillingState" value="">
    <input type="hidden" name="billing_postcode" id="inputBillingPostcode" value="">
    <input type="hidden" name="billing_country" id="inputBillingCountry" value="">
</form>

<div class="fieldgroup-remoteinput <?php if (($_smarty_tpl->tpl_vars['editMode']->value && !$_smarty_tpl->tpl_vars['remoteUpdate']->value) || !$_smarty_tpl->tpl_vars['editMode']->value) {?>hidden<?php }?>">
    <?php if ($_smarty_tpl->tpl_vars['remoteUpdate']->value) {?>
        <div id="tokenGatewayRemoteUpdateOutput" class="text-center"><?php echo $_smarty_tpl->tpl_vars['remoteUpdate']->value;?>
</div>
    <?php } else { ?>
        <div id="tokenGatewayRemoteInputOutput" class="text-center" align="center"></div>
        <div class="text-center">
            <iframe name="ccframe" class="auth3d-area" width="90%" height="600" scrolling="auto" src="about:blank"></iframe>
        </div>
    <?php }?>
</div>

<div class="modal fade" id="modalBillingAddress" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <form id="billingContactForm" action="<?php echo routePath('account-paymentmethods-billing-contacts-create');?>
" data-role="json-form">
                <input type="hidden" name="token" value="<?php echo $_smarty_tpl->tpl_vars['csrfToken']->value;?>
" />
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethodsManage']['addNewBillingAddress'];?>
</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label for="inputFirstName" class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareafirstname'];?>
</label>
                                <input type="text" name="firstname" id="inputFirstName" value="<?php echo $_smarty_tpl->tpl_vars['contactfirstname']->value;?>
"
                                       class="form-control">
                            </div>

                            <div class="form-group">
                                <label for="inputLastName" class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientarealastname'];?>
</label>
                                <input type="text" name="lastname" id="inputLastName" value="<?php echo $_smarty_tpl->tpl_vars['contactlastname']->value;?>
"
                                       class="form-control">
                            </div>

                            <div class="form-group">
                                <label for="inputCompanyName"
                                       class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareacompanyname'];?>
</label>
                                <input type="text" name="companyname" id="inputCompanyName"
                                       value="<?php echo $_smarty_tpl->tpl_vars['contactcompanyname']->value;?>
"
                                       class="form-control">
                            </div>

                            <div class="form-group">
                                <label for="inputPhone" class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareaphonenumber'];?>
</label>
                                <input type="tel" name="phonenumber" id="inputPhone" value="<?php echo $_smarty_tpl->tpl_vars['contactphonenumber']->value;?>
"
                                       class="form-control">
                            </div>

                            <?php if ($_smarty_tpl->tpl_vars['showTaxIdField']->value) {?>
                                <div class="form-group">
                                    <label for="inputTaxId" class="control-label"><?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['lang'][0], array( array('key'=>$_smarty_tpl->tpl_vars['taxIdLabel']->value),$_smarty_tpl ) );?>
</label>
                                    <input type="text" name="tax_id" id="inputTaxId" class="form-control"
                                           value="<?php echo $_smarty_tpl->tpl_vars['contactTaxId']->value;?>
">
                                </div>
                            <?php }?>

                        </div>
                        <div class="col-sm-6">

                            <div class="form-group">
                                <label for="inputAddress1" class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareaaddress1'];?>
</label>
                                <input type="text" name="address1" id="inputAddress1" value="<?php echo $_smarty_tpl->tpl_vars['contactaddress1']->value;?>
"
                                       class="form-control">
                            </div>

                            <div class="form-group">
                                <label for="inputAddress2" class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareaaddress2'];?>
</label>
                                <input type="text" name="address2" id="inputAddress2" value="<?php echo $_smarty_tpl->tpl_vars['contactaddress2']->value;?>
"
                                       class="form-control">
                            </div>

                            <div class="form-group">
                                <label for="inputCity" class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareacity'];?>
</label>
                                <input type="text" name="city" id="inputCity" value="<?php echo $_smarty_tpl->tpl_vars['contactcity']->value;?>
"
                                       class="form-control">
                            </div>

                            <div class="form-group">
                                <label for="inputState" class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareastate'];?>
</label>
                                <input type="text" name="state" id="inputState" value="<?php echo $_smarty_tpl->tpl_vars['contactstate']->value;?>
"
                                       class="form-control">
                            </div>

                            <div class="form-group">
                                <label for="inputPostcode" class="control-label"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareapostcode'];?>
</label>
                                <input type="text" name="postcode" id="inputPostcode" value="<?php echo $_smarty_tpl->tpl_vars['contactpostcode']->value;?>
"
                                       class="form-control">
                            </div>

                            <div class="form-group">
                                <label class="control-label" for="inputCountry"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['clientareacountry'];?>
</label>
                                <select class="form-control" name="country" id="inputCountry">
                                    <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['countries']->value, 'countryName', false, 'countryCode');
$_smarty_tpl->tpl_vars['countryName']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['countryCode']->value => $_smarty_tpl->tpl_vars['countryName']->value) {
$_smarty_tpl->tpl_vars['countryName']->do_else = false;
?>
                                        <option value="<?php echo $_smarty_tpl->tpl_vars['countryCode']->value;?>
"<?php if (($_smarty_tpl->tpl_vars['countryCode']->value == $_smarty_tpl->tpl_vars['clientCountry']->value)) {?> selected="selected"<?php }?>>
                                            <?php echo $_smarty_tpl->tpl_vars['countryName']->value;?>

                                        </option>
                                    <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
                                </select>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethods']['close'];?>
</button>
                    <button type="submit" class="btn btn-primary"><?php echo $_smarty_tpl->tpl_vars['LANG']->value['paymentMethods']['saveChanges'];?>
</button>
                </div>
            </form>
        </div>
    </div>
</div>

<input type="hidden" name="paymentmethod" id="inputPaymentMethod" value="">
<div id="tokenGatewayAssistedOutput"></div>

<?php echo '<script'; ?>
 type="text/javascript" src="<?php echo $_smarty_tpl->tpl_vars['BASE_PATH_JS']->value;?>
/jquery.payment.js"><?php echo '</script'; ?>
>
<?php echo '<script'; ?>
>
jQuery(document).ready(function() {
    var ccNumberFieldEnabled = '<?php echo $_smarty_tpl->tpl_vars['creditCardNumberFieldEnabled']->value;?>
';
    var ccExpiryFieldEnabled = '<?php echo $_smarty_tpl->tpl_vars['creditCardExpiryFieldEnabled']->value;?>
';
    var ccCvcFieldEnabled = '<?php echo $_smarty_tpl->tpl_vars['creditCardCvcFieldEnabled']->value;?>
';

    var ccForm = jQuery('.frm-credit-card-input');

    ccForm.find('#inputCardNumber').payment('formatCardNumber');
    ccForm.find('#inputCardStart').payment('formatCardExpiry');
    ccForm.find('#inputCardExpiry').payment('formatCardExpiry');
    ccForm.find('#inputCardCvc').payment('formatCardCVC');
    ccForm.find('#inputCardIssue').payment('restrictNumeric');
    ccForm.find('#inputBankRoutingNum').payment('restrictNumeric');
    ccForm.find('#inputBankAcctNum').payment('restrictNumeric');

    var reloadBillingContacts = function (selectContactId) {
        WHMCS.http.jqClient.get({
            url: "<?php echo routePath('account-paymentmethods-billing-contacts',$_smarty_tpl->tpl_vars['payMethod']->value->id);?>
",
            data: {
                'contact_id': selectContactId ? selectContactId : 0
            },
            success: function(response) {
                jQuery('#billingContactsContainer').html(response);
            }
        });
    };

    jQuery(document).on('click', '.frm-credit-card-input button[type="submit"]', function(e) {
        ccForm.find('.form-group').removeClass('has-error');
        ccForm.find('.field-error-msg').hide();

        var checkedInput = jQuery('input[name="type"]:checked', ccForm);

        if (checkedInput.val() === 'bankacct') {
            if (!jQuery('#inputBankAcctHolderName').val()) {
                jQuery('#inputBankAcctHolderName').showInputError();
                e.preventDefault();
            }
            if (!jQuery('#inputBankName').val()) {
                jQuery('#inputBankName').showInputError();
                e.preventDefault();
            }
            if (!jQuery('#inputBankRoutingNum').val()) {
                jQuery('#inputBankRoutingNum').showInputError();
                e.preventDefault();
            }
            if (!jQuery('#inputBankAcctNum').val()) {
                jQuery('#inputBankAcctNum').showInputError();
                e.preventDefault();
            }
        } else if (checkedInput.val() === 'localcard') {
            var cardType = $.payment.cardType(ccForm.find('#inputCardNumber').val()),
                cardNumber = ccForm.find('#inputCardNumber');
            if (
                ccNumberFieldEnabled
                && (!$.payment.validateCardNumber(cardNumber.val()) || cardNumber.hasClass('unsupported'))
            ) {
                var error = cardNumber.data('message-invalid');
                if (cardNumber.hasClass('unsupported')) {
                    error = cardNumber.data('message-unsupported');
                }
                ccForm.find('#inputCardNumber').setInputError(error).showInputError();
                e.preventDefault();
            }
            if (ccExpiryFieldEnabled && !$.payment.validateCardExpiry(ccForm.find('#inputCardExpiry').payment('cardExpiryVal'))) {
                ccForm.find('#inputCardExpiry').showInputError();
                e.preventDefault();
            }
            if (ccCvcFieldEnabled && !$.payment.validateCardCVC(ccForm.find('#inputCardCvc').val(), cardType)) {
                ccForm.find('#inputCardCvc').showInputError();
                e.preventDefault();
            }
        }
    });

    jQuery('input[name="type"]').on('ifChecked', function(e) {
        jQuery('.fieldgroup-creditcard').hide();
        jQuery('.fieldgroup-bankaccount').hide();
        jQuery('.fieldgroup-remoteinput').hide();
        jQuery('.fieldgroup-auxfields').hide();
        jQuery('.fieldgroup-loading').removeClass('hidden').show();
        jQuery('#tokenGatewayAssistedOutput').html('');
        if (jQuery(this).data('tokenised') === true) {
            jQuery('#inputPaymentMethod').val(jQuery(this).data('gateway'));
            WHMCS.http.jqClient.jsonPost({
                url: "<?php echo routePath('account-paymentmethods-inittoken');?>
",
                data: 'gateway=' + jQuery(this).data('gateway'),
                success: function(response) {
                    jQuery('.fieldgroup-loading').hide();
                    if (response.remoteInputForm) {
                        jQuery('#tokenGatewayRemoteInputOutput').html(response.remoteInputForm);
                        jQuery('#tokenGatewayRemoteInputOutput').find('form:first').attr('target', 'ccframe');
                        setTimeout("autoSubmitFormByContainer('tokenGatewayRemoteInputOutput')", 1000);
                        jQuery('.fieldgroup-remoteinput').removeClass('hidden').show();
                    } else if (response.assistedOutput) {
                        jQuery('.fieldgroup-creditcard').removeClass('hidden').show('fast', function() {
                            jQuery('#tokenGatewayAssistedOutput').html(response.assistedOutput);
                        });
                        jQuery('.fieldgroup-auxfields').show();
                    } else {
                        jQuery('.fieldgroup-creditcard').removeClass('hidden').show();
                        jQuery('.fieldgroup-auxfields').show();
                    }
                },
            });
        } else if (jQuery(this).val() === 'bankacct') {
            jQuery('.fieldgroup-loading').hide();
            jQuery('.fieldgroup-bankaccount').removeClass('hidden').show();
            jQuery('.fieldgroup-auxfields').show();
        } else {
            jQuery('.fieldgroup-loading').hide();
            jQuery('.fieldgroup-creditcard').removeClass('hidden').show();
            jQuery('.fieldgroup-auxfields').show();
        }
    });
    jQuery('input[name="billingcontact"]').on('ifChecked', function(e) {
        var contact = jQuery('.billing-contact-' + jQuery(this).val());
        jQuery('#inputBillingName').val(contact.find('.name').html());
        jQuery('#inputBillingAddress1').val(contact.find('.address1').html());
        jQuery('#inputBillingAddress2').val(contact.find('.address2').html());
        jQuery('#inputBillingCity').val(contact.find('.city').html());
        jQuery('#inputBillingState').val(contact.find('.state').html());
        jQuery('#inputBillingPostcode').val(contact.find('.postcode').html());
        jQuery('#inputBillingCountry').val(contact.find('.country').html());
    });

    if (jQuery('input[name="type"]:checked', ccForm).length === 0) {
        jQuery('input[name="type"]', ccForm).first().parents('label').trigger('click');
    }

    jQuery('#billingContactForm')
        .data('on-success', function(data) {
            jQuery('#modalBillingAddress').modal('hide');
            reloadBillingContacts(data.id);
        });
});
<?php echo '</script'; ?>
>
<?php }
}
