From 8edebd56be708cffdb8c4098dd875389e74c5ac1 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Sun, 18 Feb 2024 15:40:10 +0100 Subject: [PATCH] fix: Init bar code page must filter by entity (#28218) * fix: Init bar code page must filter by entity * missing one filter --- htdocs/barcode/codeinit.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 9c45d29cf79..4aff6593448 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -108,6 +108,7 @@ if ($action == 'initbarcodethirdparties') { $nbok = 0; if (!empty($eraseallthirdpartybarcode)) { $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; + $sql .= " AND entity IN (".getEntity('societe').")"; $sql .= " SET barcode = NULL"; $resql = $db->query($sql); if ($resql) { @@ -120,6 +121,7 @@ if ($action == 'initbarcodethirdparties') { $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; $sql .= " WHERE barcode IS NULL or barcode = ''"; + $sql .= " AND entity IN (".getEntity('societe').")"; $sql .= $db->order("datec", "ASC"); $sql .= $db->plimit($maxperinit); @@ -211,6 +213,7 @@ if ($action == 'initbarcodeproducts') { if (!empty($eraseallproductbarcode)) { $sql = "UPDATE ".MAIN_DB_PREFIX."product"; $sql .= " SET barcode = NULL"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $db->query($sql); if ($resql) { setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs'); @@ -222,6 +225,7 @@ if ($action == 'initbarcodeproducts') { $sql = "SELECT rowid, ref, fk_product_type"; $sql .= " FROM ".MAIN_DB_PREFIX."product"; $sql .= " WHERE barcode IS NULL or barcode = ''"; + $sql .= " AND entity IN (".getEntity('product').")"; $sql .= $db->order("datec", "ASC"); $sql .= $db->plimit($maxperinit); @@ -322,6 +326,7 @@ if (isModEnabled('societe')) { } $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe"; + $sql .= " WHERE entity IN (".getEntity('societe').")"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -376,6 +381,7 @@ if (isModEnabled('product') || isModEnabled('service')) { $sql = "SELECT count(rowid) as nb, fk_product_type, datec"; $sql .= " FROM ".MAIN_DB_PREFIX."product"; $sql .= " WHERE barcode IS NULL OR barcode = ''"; + $sql .= " AND entity IN (".getEntity('product').")"; $sql .= " GROUP BY fk_product_type, datec"; $sql .= " ORDER BY datec"; $resql = $db->query($sql); @@ -394,6 +400,7 @@ if (isModEnabled('product') || isModEnabled('service')) { } $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql);