diff --git a/vendor/model/Documents.class.php b/vendor/model/Documents.class.php index d3a12ce..cca2b68 100644 --- a/vendor/model/Documents.class.php +++ b/vendor/model/Documents.class.php @@ -107,7 +107,7 @@ class Documents } /** Lista todos os egistros do banco com ou sem paginação*/ - public function All(? int $start, ? int $max, ? int $documentsCategorysId, ? string $tag, ? string $label) + public function All(? int $start, ? int $max, ? int $documentsCategorysId, ? string $tag, ? string $label, ? int $companyId) { /** Parametros de entrada */ $this->start = $start; @@ -115,6 +115,7 @@ class Documents $this->documentsCategorysId = $documentsCategorysId; $this->tag = $tag; $this->label = $label; + $this->companyId = $companyId; $this->and = ""; /** Se houver categoria informada, crio o filtro de consulta*/ @@ -122,6 +123,12 @@ class Documents $this->and = " and d.documents_categorys_id = {$this->documentsCategorysId}"; //$this->and .= " and json_search(tag, 'all', '".$this->tag."', null, '$.".$this->label."') is not null"; + } + + /** Verifica se o company_id foi informado */ + if($this->companyId > 0){ + + $this->and .= " and company_id = : company_id"; } /** Verifico se há paginação */ @@ -154,7 +161,15 @@ class Documents $this->sql .= $this->limit; /** Preparo o SQL para execução */ - $this->stmt = $this->connection->connect()->prepare($this->sql); + $this->stmt = $this->connection->connect()->prepare($this->sql); + + /** Verifica se o company_id foi informado */ + if($this->companyId > 0){ + + /** Preencho os parâmetros do SQL */ + $this->stmt->bindParam('documents_id', $this->documentsId); + + } /** Executo o SQL */ $this->stmt->execute(); @@ -165,12 +180,13 @@ class Documents } /** Conta a quantidades de registros */ - public function Count(? int $documentsCategorysId, ? string $tag, ? string $label) + public function Count(? int $documentsCategorysId, ? string $tag, ? string $label, ? int $companyId) { /** Parametros de entraa */ $this->documentsCategorysId = $documentsCategorysId; $this->tag = $tag; $this->label = $label; + $this->companyId = $companyId; $this->and = ""; /** Se houver categoria informada, crio o filtro de consulta*/ @@ -180,6 +196,12 @@ class Documents //$this->and .= " and json_search(tag, 'all', '".$this->tag."', null, '$.".$this->label."') is not null"; } + /** Verifica se o company_id foi informado */ + if($this->companyId > 0){ + + $this->and .= " and company_id = : company_id"; + } + /** Consulta SQL */ $this->sql = 'select count(documents_id) as qtde from documents @@ -189,6 +211,14 @@ class Documents /** Preparo o SQL para execução */ $this->stmt = $this->connection->connect()->prepare($this->sql); + /** Verifica se o company_id foi informado */ + if($this->companyId > 0){ + + /** Preencho os parâmetros do SQL */ + $this->stmt->bindParam('documents_id', $this->documentsId); + + } + /** Executo o SQL */ $this->stmt->execute(); diff --git a/vendor/view/companies/companies_documents_datagrid.php b/vendor/view/companies/companies_documents_datagrid.php index 325e878..c3f3791 100644 --- a/vendor/view/companies/companies_documents_datagrid.php +++ b/vendor/view/companies/companies_documents_datagrid.php @@ -77,7 +77,7 @@ try{ All($start, $max, (int)$documentsCategorysId, (string)$tag, (string)$label, $companyId); + $DocumentsResult = $Documents->All($start, $max, (int)$documentsCategorysId, (string)$tag, (string)$label, (int)$companyId); foreach($DocumentsResult as $DocumentsKey => $Result){ ?>