From 25fac2abfb2afc4dfd0819b8da4f41d8bac614d8 Mon Sep 17 00:00:00 2001 From: Kenio de Souza Date: Sat, 2 Aug 2025 18:16:49 -0300 Subject: [PATCH] Atualizando companies_save.php --- vendor/model/ProductsCompanies.class.php | 30 ++++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/vendor/model/ProductsCompanies.class.php b/vendor/model/ProductsCompanies.class.php index 9c0bf75..9200757 100644 --- a/vendor/model/ProductsCompanies.class.php +++ b/vendor/model/ProductsCompanies.class.php @@ -120,19 +120,23 @@ class ProductsCompanies $this->companyId = $companyId; /** Consulta SQL */ - $this->sql = 'select cp.product_company_id, - cp.product_id, - cp.company_id, - cp.description, - p.description as product, - p.reference, - cp.readjustment, - cp.product_value, - cp.maturity - from products_companies cp - left join products p on cp.product_id = p.product_id - where cp.company_id = :company_id - and cp.status = \'A\''; + $this->sql = 'SELECT cp.maturity, + cp.readjustment, + GROUP_CONCAT(cp.product_company_id ORDER BY cp.product_company_id SEPARATOR ', ') AS product_company_ids, + GROUP_CONCAT(cp.product_id ORDER BY cp.product_company_id SEPARATOR ', ') AS product_ids, + GROUP_CONCAT(cp.description ORDER BY cp.product_company_id SEPARATOR ', ') AS descriptions, + GROUP_CONCAT(p.description ORDER BY cp.product_company_id SEPARATOR ', ') AS products, + GROUP_CONCAT(p.reference ORDER BY cp.product_company_id SEPARATOR ', ') AS references, + GROUP_CONCAT(cp.product_value ORDER BY cp.product_company_id SEPARATOR ', ') AS product_values + FROM + products_companies cp + LEFT JOIN + products p ON cp.product_id = p.product_id + WHERE + cp.company_id = :company_id + AND cp.status = 'A' + GROUP BY + cp.maturity, cp.readjustment;'; /** Preparo o SQL para execução */ $this->stmt = $this->connection->connect()->prepare($this->sql);