<!DOCTYPE html>
<html lang="en">
<head> 
<link rel='icon' type='img/png' href='gpib1.png'>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>Register</title>
  <!-- Custom fonts for this template-->
  <link href="<?=base_url("assets")?>/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
    <link href="https://cdn.datatables.net/1.10.23/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css">
  <!-- Custom styles for this template-->
  <link href="<?=base_url("assets")?>/css/sb-admin-2.min.css" rel="stylesheet">
</head>
<body class="bg-gradient-primary">
  <div class="container">
    <!-- loading-->
        <div id="loading" class="modal" tabindex="-1" role="dialog">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-body">
                <p><p><i class="fa fa-spin fa-spinner"></i> Loading...</p></p>
              </div>
            </div>
          </div>
        </div>
  <!--End loading-->
    <div class="card o-hidden border-0 shadow-lg my-5">
      <div class="card-body p-0">
        <!-- Nested Row within Card Body -->
        <div class="row">
          <div class="col-lg-5 d-none d-lg-block pt-5"><img src="<?=base_url("assets/img/gpib1.png")?>"></div>
          <div class="col-lg-7">
            <div class="p-5">
              <div class="text-center">
                <h1 class="h4 text-gray-900 mb-4">Create an Account!</h1>
              </div>
              <form class="user" id="register">
                <div class="form-group row">
                  <div class="col-sm-12 mb-6 mb-sm-0">
                    <label for="exampleInputEmail1">User Name </label>
                    <input type="text" class="form-control form-control-user" id="username" name="username" required>
                  </div>
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Email</label>
                  <input type="email" class="form-control form-control-user" id="email" name="email" placeholder="" required>
                  <small id="emailHelp" class="form-text text-muted">Masukan email yang aktif</small>
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">No. Whatsapp</label>
                  <input type="text" class="form-control form-control-user" id="tlp" name="tlp" placeholder="" onkeypress="return hanyaAngka(event)" maxlength="15" required>
                  <small id="emailHelp" class="form-text text-muted">Masukan nomor whatsapp yang aktif Contoh:081234567890</small>
                </div>
                <div class="form-group row">
                  <div class="col-sm-12 mb-6 mb-sm-0">
                    <label for="exampleInputEmail1">Unit Misioner </label>
                    <select class="form-control " id="unit_misioner" name="unit_misioner" placeholder="" required>
                      </select>
                  </div>
                </div>
                <div class="form-group row">
                  <div class="col-sm-6 mb-3 mb-sm-0">
                    <label for="exampleInputEmail1">Password </label>
                    <input type="password" class="form-control form-control-user" id="password" name="password" placeholder="" required>
                    <small id="emailHelp" class="form-text text-muted">Password harus 8 karakter atau lebih</small>
                  </div>
                  <div class="col-sm-6">
                    <label for="exampleInputEmail1">Ulang Password </label>
                    <input type="password" class="form-control form-control-user" id="upassword" placeholder="" required>
                  </div>
                </div>
                <button  type="submit" class="btn btn-success btn-user btn-block"><i class="fas fa-user-plus fa-fw"></i> Mendaftar</button>
                <hr>
                <a href="<?=base_url("login.aspx")?>" type="submit" class="btn btn-primary btn-user btn-block" ><i class="fas fa-sign-in-alt fa-fw"></i> Back To Login Page</a>
                 
                <!-- 
                <hr>
                <a href="index.html" class="btn btn-google btn-user btn-block">
                  <i class="fab fa-google fa-fw"></i> Register with Google
                </a>
                <a href="index.html" class="btn btn-facebook btn-user btn-block">
                  <i class="fab fa-facebook-f fa-fw"></i> Register with Facebook
                </a> -->
              </form>
              <!-- <hr>
              <div class="text-center">
                <a class="small" href="forgot-password.html">Forgot Password?</a>
              </div>
              <div class="text-center">
                <a class="small" href="login.html">Already have an account? Login!</a>
              </div>
            </div> -->
          </div>
        </div>
      </div>
      <footer class="sticky-footer bg-white">
          <div class="container my-auto">
            <div class="copyright text-center my-auto">
              <hr color='black'>
              <span><h7><b>Copyright<a target = '_blank' href="https://www.gpibcinere.org/"> ©GPIB CINERE</a> 2021-2022<br><br>Developer <a target = '_blank' href="https://www.instagram.com/maschris25/">@Natal</a></b></h7></span>
            </div>
          </div>
      </footer>
    </div>
  </div>
  <!-- Bootstrap core JavaScript-->
  <script src="<?=base_url("assets")?>/vendor/jquery/jquery.min.js"></script>
    <!-- <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> -->
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <!-- Core plugin JavaScript-->
  <script src="<?=base_url("assets")?>/vendor/jquery-easing/jquery.easing.min.js"></script>
  <script src=" //cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css"/>
  <script src="<?=base_url('assets/')?>vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <!-- Custom scripts for all pages-->
  <script src="<?=base_url("assets")?>/js/sb-admin-2.min.js"></script>
  <script type="text/javascript">
    $(document).ready(function(){
      var base_url = "<?=base_url()?>";
      jQuery.ajax({
        url: base_url+"unit_misioner/data_unit_misioner",
        dataType:'json',
        success:function(response){
          var data = response;
          var $id = $('#unit_misioner');
          $id.empty();
          $id.append('<option value="">- Pilih Unit Misioner -</option>');
          for (var i = 0; i < data.length; i++) {
            $id.append('<option value="'+data[i].id_unit_misioner+','+data[i].nama+'">' + data[i].nama + '</option>');
          }        
        }            
      });
      $("#register").submit(function(){
        var form_data = new FormData($('#register')[0]);
        var password = $("#password").val();
        var upassword = $("#upassword").val();
        if (password.length < 8) {
          // alert("ooooo")
          Command: toastr["error"]("Panjang password harus 8 karakter atau lebih", "Gagal");
        }else if (password != upassword) {
          // alert("ooooo")
          Command: toastr["error"]("Password Tidak Sama", "Gagal");
        }else{
          $.ajax({
                url             : base_url + 'register/add_user', 
                type            : "POST",
                dataType        : 'json',
                mimeType        : 'multipart/form-data',
                data            : form_data,
                contentType     : false,
                cache           : false,
                processData     : false,
                success         : function(response){
                    if(response.cek == "ada"){
                      Command: toastr["info"]("Anda sudah mendaftarkan dengan email ini", "Info");
                    }else if(response.cek == "ok"){
                      Command: toastr["success"]("Selamat, anda berhasil mendaftar, dan tunggu verifikasi dari admin", "Success");
                    }else{
                        Command: toastr["error"]("Simpan error, data tidak berhasil disimpan", "Error");
                    }
                },
                error: function(jqXHR, textStatus, errorThrown) {
                  $('#loading').modal('hide');
                  Command: toastr["error"](errorThrown, "Error");
                },
                beforeSend: function () {
                  $('#loading').modal('show');
                },
                complete: function () {
                    $('#loading').modal('hide');
                }
          });
        }
        return false;
      });
    });
  </script>
  <script type="text/javascript">
    toastr.options = {
          "closeButton": false,
          "debug": false,
          "newestOnTop": false,
          "progressBar": true,
          "positionClass": "toast-top-right",
          "preventDuplicates": false,
          "onclick": null,
          "showDuration": "300",
          "hideDuration": "1000",
          "timeOut": "5000",
          "extendedTimeOut": "1000",
          "showEasing": "swing",
          "hideEasing": "swing",
          "showMethod": "slideDown",
          "hideMethod": "slideUp"
    }
    function hanyaAngka(evt) {
      var charCode = (evt.which) ? evt.which : event.keyCode
       if (charCode > 31 && (charCode < 48 || charCode > 57))
 
        return false;
      return true;
    }
  </script>
    <?php
function getClientIP() {
    if (isset($_SERVER)) {
        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
            return $_SERVER["HTTP_X_FORWARDED_FOR"];
        if (isset($_SERVER["HTTP_CLIENT_IP"]))
            return $_SERVER["HTTP_CLIENT_IP"];
        return $_SERVER["REMOTE_ADDR"];
    }
    if (getenv('HTTP_X_FORWARDED_FOR'))
        return getenv('HTTP_X_FORWARDED_FOR');
    if (getenv('HTTP_CLIENT_IP'))
        return getenv('HTTP_CLIENT_IP');
    return getenv('REMOTE_ADDR');
}
function get_client_browser() {
    $browser = '';
    if(strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape'))
        $browser = 'Netscape';
    else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox'))
        $browser = 'Firefox';
    else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome'))
        $browser = 'Chrome';
    else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera'))
        $browser = 'Opera';
    else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
        $browser = 'Internet Explorer';
    else
        $browser = 'Other';
    return $browser;
}
echo "<h5 align=\"center\">Your IP Address : ".getClientIP()."";
echo "<h5 align=\"center\">Your Browser : ".get_client_browser()."";
?>
</body>
</html>
