<?php echo $header; ?>
<div id="content">
    <div class="container-fluid"><br />
        <br />
        <div class="row">
            <div class="col-sm-offset-4 col-sm-4">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h1 class="panel-title"><i class="fa fa-repeat"></i> <?php echo $heading_title; ?></h1>
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <label for="input-sms_pin">Süre:</label>
                            <div class="input-group">
                                <h3 style="color: green;" id="timer">150</h3>
                            </div>
                        </div>

                        <br>
                        <div class="form-group">
                            <label for="input-sms_pin"><?php echo $entry_sms_pin; ?></label>
                            <div class="input-group"><span class="input-group-addon"><i class="fa fa-envelope"></i></span>
                                <input type="text" name="sms_pin" value="<?php echo $sms_pin; ?>" placeholder="<?php echo $entry_sms_pin; ?>" id="input-sms_pin" class="form-control" />
                            </div>
                        </div>
                        <div class="text-right">
                            <button id="send_sms" class="btn btn-primary"><i class="fa fa-check"></i> Giriş</button>
                            <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


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

    $(function () {
        $('#send_sms').on('click', function () {

            $('.alert-danger').remove();

            var sms_pin = $("input[name='sms_pin']").val();
            if(sms_pin != ""){
                $.ajax({
                    url: 'index.php?route=common/security/security&token=<?=$token;?>',
                    dataType: 'json',
                    type: 'POST',
                    data: {sms_pin: sms_pin},
                    success: function(json){console.log (json);
                    if(json['error']){
                    $('.panel-body').append('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i>' + json['error'] + '<button type="button" class="close" data-dismiss="alert"></button>' + '</div>');
                    }else if(json['redirect']){
                    location.href = json['redirect'].replace ('&amp;', '&');
                }
            }
            });
    }else{
        $('.panel-body').append('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> Sms şifresi yazmalısınız!<button type="button" class="close" data-dismiss="alert">&times;</button>' + '</div>');
    }


    });


    });

    var deger;
    var saniye = 150;

    function saniyeDurdur() {
        window.clearInterval(deger);
    }
    function saniyeBaslat() {
        saniye --;
        if(saniye >=0){
            $('#timer').text(saniye);
        }else{
            window.clearInterval(deger);
            $('#timer').text("Süreniz bitti");

            $.ajax({
                url: 'index.php?route=common/security/reset&token=<?=$token;?>',
                dataType: 'json',
                type: 'POST',
                data: {},
                success: function(json){

                }
            });

            window.location.href = 'https://www.eticaretuzman.com/ps-panel';

        }
    }
    deger = window.setInterval('saniyeBaslat()',1000);



    //-->
</script>

<?php echo $footer; ?>