<?php


class User extends Database{

	public function getUser($username,$password){
		$sql = "SELECT * FROM t_usuario u, t_personales per WHERE u.id_per=per.id_per AND (per.correo_per = '$username' || per.numDoc_per='$username' ) AND u.pass_user = '$password' AND u.estado_user='ACTIVO' ";

		$result = $this->connect()->query($sql);

		$numRows = $result->num_rows;

		if($numRows == 1){
			foreach ($result as $fila) {
				$_SESSION['nom_per']=$fila['nom_per'];
				$_SESSION['primerAp_per']=$fila['primerAp_per'];
				$_SESSION['segundoAp_per']=$fila['segundoAp_per'];
				$_SESSION['estado_user']=$fila['estado_user'];
				$_SESSION['tipo_user']=$fila['tipo_user'];
			}
			return true;
		}

		return false;
	}

	public function limpiar1($username){
		$resul=mysqli_real_escape_string($this->connect(),$username);
		return $resul;
	}
	public function limpiar2($password){
		$cadena=mysqli_real_escape_string($this->connect(),$password);
		$resul=sha1($cadena);
		return $resul;
	}
}

?>