<?php
/*session_start();
require_once __DIR__."/objetos/database/repositorioTablas.php";
use share\objetos\ward\Ward;
$contextPath=Ward::getContextPath()["contextPath"];
if(isset($_SESSION["session"])){
    header("location:lista/cita/calendarioCitas");
}*/

?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Mi Proyecto</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="<?=base_url()?>assets/AdminLTE-2.4.5/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="<?=base_url()?>assets/AdminLTE-2.4.5/bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="<?=base_url()?>assets/AdminLTE-2.4.5/bower_components/Ionicons/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="<?=base_url()?>assets/AdminLTE-2.4.5/dist/css/AdminLTE.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="<?=base_url()?>assets/AdminLTE-2.4.5/plugins/iCheck/square/blue.css">

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  <script>path="<?=base_url()?>"</script>
</head>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    <a href="#"><b>Ingreso Al Sistema</b></a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
    <p class="login-box-msg">Ingrese sus datos para iniciar sessión</p>

    <form action="" method="post">
      <div class="form-group has-feedback">
        <input id="user" type="email" class="form-control" placeholder="Username or Email">
        <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input id="pwd" type="password" class="form-control" placeholder="Password">
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
      <div class="row">
        <div class="col-xs-8">
        <!--
          <div class="checkbox icheck">
            <label>
              <input type="checkbox"> Remember Me
            </label>
          </div>  -->
        </div>
        <!-- /.col -->
        <div class="col-xs-4">
          <button type="button" id="btnLogin" class="btn btn-primary btn-block btn-flat">Entrar</button>
        </div>
        <!-- /.col -->
      </div>
    </form>
	
	<!--
    <div class="social-auth-links text-center">
      <p>- OR -</p>
      <a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign in using
        Facebook</a>
      <a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google-plus"></i> Sign in using
        Google+</a>
    </div>
    <a href="<?=base_url("pacientes/paciente/listPaciente")?>" class="text-center">Registrarse</a>
	-->
  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 3 -->
<script src="<?=base_url()?>assets/AdminLTE-2.4.5/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="<?=base_url()?>assets/AdminLTE-2.4.5/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="<?=base_url()?>assets/AdminLTE-2.4.5/plugins/iCheck/icheck.min.js"></script>
<script>
$(function () {
	$("#user").val("");
	$("#pwd").val("");
	$('input').iCheck({
		checkboxClass: 'icheckbox_square-blue',
		radioClass: 'iradio_square-blue',
		increaseArea: '20%' /* optional */
	});
	$("#btnLogin").click(function(){
		login();
	});
	$("#pwd").keyup(function(e){
		switch(e.keyCode){
		case 13:
			login();
			break;
		}
	});
});
function login()
{
	var pass=$("#pwd");
	//var pwd=btoa($(pass).val());
	var pwd=btoa($(pass).val());
	$(pass).val("");
	$.ajax({url:"login/signin",
		data:{"usuario":$("#user").val(),"password":pwd},
		method:"POST",
		dataType:"JSON",
		cache:false,
		success:function(res){
			if(res.res)
			{
				$(location).attr("href",path+"pacientes/paciente/listPaciente");
				//window.location.href = res.url;
			}else{
				alert(res.mensage);
			}
	},error:function(res){
		console.log(res.responseText);
	}});
}
</script>
</body>
</html>