From 9efd0988405bec96e0715281124428f87f969747 Mon Sep 17 00:00:00 2001 From: Kenio de Souza Date: Tue, 29 Jul 2025 14:48:05 -0300 Subject: [PATCH] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20Companies.class.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/model/Companies.class.php | 47 +++++++++++++------- vendor/view/companies/companies_datagrid.php | 6 +-- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/vendor/model/Companies.class.php b/vendor/model/Companies.class.php index 78dfd94..b1f2407 100644 --- a/vendor/model/Companies.class.php +++ b/vendor/model/Companies.class.php @@ -129,23 +129,31 @@ class Companies } /** Consulta SQL */ - $this->sql = 'select * from companies '; + $this->sql = 'select * from companies c '; /** Verifica se há pesquisa */ if($this->typeSearch && $this->search){ /** Verifica o tipo de pesquisa */ - if($this->typeSearch == 1){ //Pesquisa por nome da empresa + if($this->typeSearch == 1){ //CNS - $this->sql .= 'where name_fantasy like :search '; + $this->sql .= 'where c.cns = :search'; - }else if($this->typeSearch == 2){ //Pesquisa por CNPJ + }else if($this->typeSearch == 2){ //Pesquisa por Nome Fantasia - $this->sql .= 'where cnpj like :search '; + $this->sql .= 'where c.name_fantasy like :search'; - }else if($this->typeSearch == 3){ //Pesquisa por CEP + }else if($this->typeSearch == 3){ //Pesquisa por responsável - $this->sql .= 'where cep like :search '; + $this->sql .= 'where c.responsible like :search'; + + }else if($this->typeSearch == 4){ //Pesquisa por e-mail + + $this->sql .= 'where c.email like :search'; + + }else if($this->typeSearch == 5){ //Pesquisa por estado + + $this->sql .= 'where (select count(s.state_id) from states s where uf = :search and s.state_id = c.state_id) > 0'; } } @@ -177,28 +185,35 @@ class Companies $this->search = $search; /** Consulta SQL */ - $this->sql = 'select count(company_id) as qtde - from companies '; + $this->sql = 'select count(c.company_id) as qtde + from companies c'; /** Verifica se há pesquisa */ if($this->typeSearch && $this->search){ /** Verifica o tipo de pesquisa */ - if($this->typeSearch == 1){ //Pesquisa por nome da empresa + if($this->typeSearch == 1){ //CNS - $this->sql .= 'where name_fantasy like :search'; + $this->sql .= 'where c.cns = :search'; - }else if($this->typeSearch == 2){ //Pesquisa por CNPJ + }else if($this->typeSearch == 2){ //Pesquisa por Nome Fantasia - $this->sql .= 'where cnpj like :search'; + $this->sql .= 'where c.name_fantasy like :search'; - }else if($this->typeSearch == 3){ //Pesquisa por CEP + }else if($this->typeSearch == 3){ //Pesquisa por responsável - $this->sql .= 'where cep like :search'; + $this->sql .= 'where c.responsible like :search'; + + }else if($this->typeSearch == 4){ //Pesquisa por e-mail + + $this->sql .= 'where c.email like :search'; + + }else if($this->typeSearch == 5){ //Pesquisa por estado + + $this->sql .= 'where (select count(s.state_id) from states s where uf = :search and s.state_id = c.state_id) > 0'; } } - echo $this->sql; /** Preparo o SQL para execução */ diff --git a/vendor/view/companies/companies_datagrid.php b/vendor/view/companies/companies_datagrid.php index 5b4ccba..bed8358 100644 --- a/vendor/view/companies/companies_datagrid.php +++ b/vendor/view/companies/companies_datagrid.php @@ -71,13 +71,13 @@ if($Main->verifyToken()){