<?php
class GSignin{    

    public function listarLoginUsuario(){
      return "SELECT u.id_usuario, e.id_tipo_documento, u.login, e.nu_documento, CONCAT(e.no_apepat,' ', e.no_apemat,' ', e.no_empleado) as no_completo 
      ,TRIM(CONCAT_WS(' ', e.no_apepat, e.no_apemat)) AS apellidos, e.no_empleado as username, e.no_correo as email, u.id_rol_sistema, rs.no_rol_sistema,
       ws.no_win_sistemas, 'dashboard.home' as name_state 
      FROM tb_usuario AS u  
      LEFT OUTER JOIN rol_sistema AS rs ON rs.id_rol_sistema=u.id_rol_sistema  
      LEFT OUTER JOIN win_sistemas AS ws ON ws.id_win_sistemas=rs.state_default  
      LEFT OUTER JOIN tb_empleado AS e ON e.id_empleado=u.id_empleado  
      WHERE u.status='1' AND u.login=? AND u.password=?";
    }

      public function listarLoginAula(){
        return "SELECT e.id_cliente as id, no_cliente as no_completo, e.no_cliente as username , no_email as email
        FROM tb_cliente e WHERE e.no_email =? AND e.no_password=?";
    }

    public function updateCliente(){
      return "UPDATE tb_cliente SET no_password = ? where id_cliente = ?";
    }


    public function listarCliente(){
      return "SELECT e.id_cliente as id, no_cliente as no_completo, e.no_cliente as username , no_email as email
      FROM tb_cliente e WHERE  e.id_cliente = ?";
    }
    
    public function guardarPasswordRecovery(){
      return "INSERT INTO tb_password_recovery(no_email,token) VALUES (?,?)";
    }

    public function obtenerDatosCliente(){
      return 'SELECT e.id_cliente as id, no_email as email FROM tb_cliente e WHERE UPPER(e.no_email) = UPPER(?)';
    }

    public function validarToken(){
      return "SELECT count(1) as isValid FROM tb_password_recovery pr WHERE token = ? and status = '1'";
    }

    public function validarCorreo(){
      return "SELECT count(1) as isValid FROM tb_cliente WHERE no_email = ? and status = '1'";
    }

    public function limpiarSolicitudes(){
      return "UPDATE tb_password_recovery SET status='0'  WHERE no_email = ?";
    }

    public function guardarAccesoDispositivo(){
      return "INSERT INTO tb_access_device(browser,browser_version,device,deviceType,orientation,os,os_version,userAgent,dispositivo,id_cliente) VALUES (?,?,?,?,?,?,?,?,?,?)";
    }

}
?>