<!-- Progress Bar -->
<?php echo $this->progressBar;?>

<!-- Main Page -->
<script type="text/javascript">

function checkPhoneVerification() {

    var received = function (response) {
        var data = Ext.util.JSON.decode(response.responseText);

        // Validate the data
        if(data.verified == true) {
            // Submit the form
            document.forms["phone"].submit();
        } else if(data.verified == '-1') {
            // Too many retrys
            Ext.Msg.show({
               title: '<?php echo $this->lang('Too many Attempts');?>',
               msg: '<?php echo $this->lang('Sorry, you have attempted to enter the code incorrectly too many times.');?>',
               buttons: Ext.Msg.OK,
               icon: Ext.MessageBox.WARNING,
               minWidth: '300'
            });
        } else {
            // Invalid
            Ext.Msg.show({
               title: '<?php echo $this->lang('Verification Code Invalid');?>',
               msg: '<?php echo $this->lang('Sorry, the verification code you entered is invalid. Please try again.');?>',
               buttons: Ext.Msg.OK,
               icon: Ext.MessageBox.WARNING,
               minWidth: '300'
            });
        }
    }
    Ext.Ajax.request({
       url: 'index.php?fuse=admin&action=Signup_VerifyPhoneCode',
       success: received,
       failure: received,
       params: { verificationCode: document.forms['phone'].phonecode.value, checksum: '<?php echo $this->codeChecksum;?>' }
    });
}

</script>

<h3><?php echo $this->lang("Telephone Verification");?></h3>
<?php echo $this->lang('In order to help prevent fraudulent orders we require new customers to verify their phone number');?>.
<form name='phone' action='order.php?step=process' method=post>
    <?php foreach($this->hiddenFields AS $field => $value) { ?>
        <input type="hidden" name="<?php echo $field;?>" value="<?php echo $value;?>">
    <?php } ?>

    <div class="block">
        <br>
        <?php if(!$this->isCalled) { ?>
            <strong><?php echo $this->lang("Please wait, you will be called at")." ". @$this->phoneNumber ." ".$this->lang("within 30 seconds.");?> </strong>
        <?php } else { ?>
            <strong><?php echo $this->lang("According to our records we have previously called you. If you did not receive a call within 30 seconds please click the back button and verify that your phone number is in the correct format. Please be aware that a new code will be issued");?> </strong>
        <?php } ?>
        <br><br>
        <table class="ts2" cellspacing="0">
         <tr>
           <td class="label" valign="top"><?php echo $this->lang('Verification Code');?>:</td>
           <td>
             <input maxlength='10' name='phonecode' size='20' onkeypress='return noenter(event)' type='text'>
             <br />
             <span style="font-size:11px; color:#666;"><?php echo $this->lang("Please enter the code given to you by the robotic system above");?></span>
           </td>
         </tr>
        </table>
        
    </div>
    <div class="block_footer">
        <input class="button" onclick="checkPhoneVerification();" id="submitButton" type="button" value="<?php echo $this->lang('Continue');?>" />
    </div>
</form>
