コード例 #1
0
 function searchGerente(Gerente $c)
 {
     require_once '../conexion.php';
     require_once '../model.business/Gerente.php';
     require_once '../model.business/Persona.php';
     try {
         $conexion = new conexion();
         $gerente = new Gerente();
         $sql = "SELECT c.nombre, c.apellido,c.rut,c.telefono, c.email FROM gerente c " . "INNER JOIN login l ON c.username = l.username " . "WHERE l.username = '******' AND l.contraseña = '" . $c->getPassword() . "';";
         $conn = $conexion->conn();
         $query = $conn->query($sql);
         $rows = $query->fetchAll();
         foreach ($rows as $row) {
             $gerente->setUsername($c->getUsername());
             $gerente->setPassword($c->getPassword());
             $gerente->setRol(1);
             $gerente->setNombre($row["nombre"]);
             $gerente->setApellido($row["apellido"]);
             $gerente->setRut($row["rut"]);
             $gerente->setTelefono($row["telefono"]);
             $gerente->setEmail($row["email"]);
             return $gerente;
         }
         return null;
     } catch (Exception $ex) {
         $ex->getTraceAsString();
     }
 }
コード例 #2
0
$username = $_POST["txt_rut"];
$password = $_POST["txt_password"];
if (crypt($password, $clientesDal->passwordClient($username)) == $clientesDal->passwordClient($username)) {
    $esIgual = TRUE;
} else {
    $esIgual = FALSE;
}
////SET Admin
$admin->setUsername($username);
$admin->setPassword(crypt($password, $adminDal->passwordAdmin($username)));
////SET Cliente
$cliente->setUsername($username);
$cliente->setPassword(crypt($password, $clientesDal->passwordClient($username)));
////SET Gerente
$gerente->setUsername($username);
$gerente->setPassword(crypt($password, $gerenteDal->passwordGerente($username)));
////Consulta si existe el cliente
if ($clientesDal->searchClient($cliente) != NULL || $esIgual == TRUE) {
    $cliente = $clientesDal->searchClient($cliente);
    $admin = $adminDal->searchAdmin($admin);
    $gerente = $gerenteDal->searchGerente($gerente);
    if ($cliente->getNombre() != null) {
        //Pagina
        $nombre = $cliente->getNombre() . ' </br> ' . $cliente->getApellido();
        $nombreReporte = $cliente->getNombre() . ' ' . $cliente->getApellido();
        $arrayCliente = array('nombre' => $nombre, 'rut' => $cliente->getRut(), 'email' => $cliente->getEmail(), 'telefono' => $cliente->getTelefono(), 'nombreReporte' => $nombreReporte);
        $_SESSION['cliente'] = $arrayCliente;
        //$_SESSION['carro'] = array();
        header("Location: ../redirect_index_sesion_iniciada.php");
    } else {
        if ($admin->getNombre() != null) {