diff --git a/app/classes/config.php b/app/classes/config.php index 5ca1ade..96b94c0 100644 --- a/app/classes/config.php +++ b/app/classes/config.php @@ -1,11 +1,11 @@ LOGIN; + $NOME = $params->NOME; $CIDADE = $params->CIDADE; $Log = new Controller(); - $Logins = $Log->getAcessoFirebird($LOGIN,$CIDADE); + $Logins = $Log->getAcessoFirebird($NOME,$CIDADE); echo json_encode($Logins); return json_encode($Logins); } @@ -18,6 +18,14 @@ class AcessoController{ echo json_encode($Logins); return json_encode($Logins); } + public function pesquisaAcesso($params){ + $NOME = $params->NOME; + $CIDADE = $params->CIDADE; + $Log = new Controller(); + $Logins = $Log->getPesquisaAcessoMariaDB($NOME,$CIDADE); + echo json_encode($Logins); + return json_encode($Logins); + } public function inserir(){ $Log = new Controller(); $Logins = $Log->inserirAcesso(); diff --git a/app/controllers/Controller.php b/app/controllers/Controller.php index 3bdf727..b68e290 100644 --- a/app/controllers/Controller.php +++ b/app/controllers/Controller.php @@ -35,22 +35,33 @@ class Controller extends DBA{ return null; } } - public function getAcessoFirebird($LOGIN,$CIDADE){ + public function getAcessoFirebird($NOME,$CIDADE){ $this->sql = "SELECT L.CD_LOGIN, L.CD_USUARIO_SISTEMA, L.NO_USERNAME, L.SENHA, US.NO_USUARIO_SISTEMA - FROM LOGIN L - INNER JOIN USUARIO_SISTEMA US ON L.CD_USUARIO_SISTEMA = US.CD_USUARIO_SISTEMA WHERE NO_USERNAME LIKE ?"; + FROM USUARIO_SISTEMA US + INNER JOIN LOGIN L ON L.CD_USUARIO_SISTEMA = US.CD_USUARIO_SISTEMA + WHERE US.NO_USUARIO_SISTEMA LIKE ?"; $Con = new Controller(); $this->stmt = $Con -> getSTMT($CIDADE,$this->sql); - $this->stmt->bindValue(1,"%".$LOGIN."%"); + $this->stmt->bindValue(1,"%".$NOME."%"); $this->stmt->execute(); $this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC); return $this-> res; } public function getAcessoMariaDB($LOGIN,$CIDADE){ - $this->sql = "SELECT * FROM acessos WHERE ID_USUARIO LIKE ? AND CIDADE = ?"; + $this->sql = "SELECT * FROM acessos WHERE ID_USUARIO = ? AND CIDADE = ?"; $Con = new Controller(); $this->stmt = $this->getMARIA()->prepare($this->sql); - $this->stmt->bindValue(1,"%".$LOGIN."%"); + $this->stmt->bindValue(1,$LOGIN); + $this->stmt->bindValue(2,$CIDADE); + $this->stmt->execute(); + $this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC); + return $this-> res; + } + public function getPesquisaAcessoMariaDB($NOME,$CIDADE){ + $this->sql = "SELECT * FROM acessos WHERE NO_USUARIO_SISTEMA LIKE ? AND CIDADE = ?"; + $Con = new Controller(); + $this->stmt = $this->getMARIA()->prepare($this->sql); + $this->stmt->bindValue(1,"%".$NOME."%"); $this->stmt->bindValue(2,$CIDADE); $this->stmt->execute(); $this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC); @@ -58,7 +69,7 @@ class Controller extends DBA{ } public function getLoginControle($NO_USERNAME,$CIDADE){ if(!$NO_USERNAME==''){ - $this->sql = "SELECT L.CD_USUARIO_SISTEMA,L.SENHA, L.NO_USERNAME, US.CD_CENTRO_CUSTO, CC.CD_UNIDADE, CD.NO_FANTASIA + $this->sql = "SELECT L.CD_USUARIO_SISTEMA,L.SENHA, US.NO_USUARIO_SISTEMA, L.NO_USERNAME, US.CD_CENTRO_CUSTO, CC.CD_UNIDADE, CD.NO_FANTASIA FROM LOGIN L INNER JOIN USUARIO_SISTEMA US ON L.CD_USUARIO_SISTEMA = US.CD_USUARIO_SISTEMA INNER JOIN CENTRO_CUSTO CC ON US.CD_CENTRO_CUSTO = CC.CD_CENTRO_CUSTO diff --git a/routes/router.php b/routes/router.php index df384a2..cf082e2 100644 --- a/routes/router.php +++ b/routes/router.php @@ -32,6 +32,7 @@ $router= [ "/calendario" => function(){load("CalendarioController","calendario");}, "/ocorrencia" => function(){load("OcorrenciaController","ocorrencia");}, "/acesso_base" => function(){load("AcessoController","acessoFirebird");}, + "/pesquisa_acesso" => function(){load("AcessoController","pesquisaAcesso");}, "/acesso_maria" => function(){load("AcessoController","acessoMariaDB");}, "/matriculas_aluno" => function(){load("AlunoController","matriculaHistorico");}, "/passe" => function(){load("PasseController","buscarPasse");},