<?php

//include("alertas.php");

 include("conexion.php");

			$usuario=$_POST['email'];
			$password=$_POST['p'];



			 if ($password=="" || $usuario=="") {
    	header("location:index.php");
    }
    else
    {


     $query="SELECT  `id_usu`, `nombre_usu`, `clave_usu`, `rol`, `op1`, `op2`, `op3`, `op4`, `op5`, `op6`, `op7`, `op8`, `op9`, `op10`, `id_cliente` FROM `usuarios` WHERE nombre_usu= '$usuario'";
    $resultadoc=$conexion->query($query);
    $row=$resultadoc->fetch_assoc();
    //print_r($row);return;
    $password2=$row['clave_usu'];
	$password2 = hash('sha512', $password2);


	if ($password== $password2) {


	 	session_start();
         $_SESSION["nombre"] = $row ["nombre_usu"];
                $_SESSION["roles"] = $row ["rol"];
                $_SESSION["clienteid"] = $row ["id_cliente"];

                $_SESSION["op1"] = $row ["op1"];
                $_SESSION["op2"] = $row ["op2"];
                $_SESSION["op3"] = $row ["op3"];
                $_SESSION["op4"] = $row ["op4"];
                $_SESSION["op5"] = $row ["op5"];
                $_SESSION["op6"] = $row ["op6"];
                $_SESSION["op7"] = $row ["op7"];
                $_SESSION["op8"] = $row ["op8"];
                $_SESSION["op9"] = $row ["op9"];
                $_SESSION["op10"] = $row ["op10"];


                if($_SESSION['roles']==1){ $_SESSION['roles']=='master';  }
                if($_SESSION['roles']==2){ $_SESSION['roles']=='operador';  }
				if($_SESSION['roles']==3){ $_SESSION['roles']=='usuario';  }



?>
<script>window.location = "checklist.php?filtro=1"; </script>;
<?php

}else{

/*echo $password2;
echo "<script type='text/javascript'>
                            window.onunload = alerta1();
                               function alerta1(){
                                	 $.alert({
                                	 	icon: 'fa fa-warning',
                                	 	animation: 'zoom',
    									closeAnimation: 'scale',
    									type:'red',
                                        title: 'Termobondin SAS',
                                        content: 'Usuario y/o Contraseña Incorrecta!',
                                        buttons: {
                                         	aceptar:  {
                                         	         		btnClass: 'btn-red',
                                         	         		action: function(){	 window.location= 'index.php'}
                                         	          },

                                         	          }
                                    });
                                }
                            </script>";*/
                            echo "<script type='text/javascript'>alert('Datos Incorrectos');window.location= 'index.php'</script>";

}

}



	?>
