From e9a12b5324064adc35e5cd3a4ae0ea7f9cf5058f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 5 Dec 2020 08:56:17 +0100 Subject: [PATCH 1/2] fix missing fields in box --- htdocs/core/boxes/box_produits.php | 43 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index dc7f79721d1..57f964d09ce 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -84,21 +84,25 @@ class box_produits extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); - if ($user->rights->produit->lire || $user->rights->service->lire) - { + if ($user->rights->produit->lire || $user->rights->service->lire) { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; $sql .= ", p.accountancy_code_sell"; $sql .= ", p.accountancy_code_sell_intra"; $sql .= ", p.accountancy_code_sell_export"; $sql .= ", p.accountancy_code_buy"; + $sql .= ", p.accountancy_code_buy_intra"; + $sql .= ", p.accountancy_code_buy_export"; $sql .= ', p.barcode'; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; - if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; - if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; + if (empty($user->rights->produit->lire)) { + $sql .= ' AND p.fk_product_type != 0'; + } + if (empty($user->rights->service->lire)) { + $sql .= ' AND p.fk_product_type != 1'; + } // Add where from hooks - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array('boxproductlist'=>1); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -107,18 +111,15 @@ class box_produits extends ModeleBoxes $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) - { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datem = $this->db->jdate($objp->tms); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { + if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active $sqld = "SELECT label"; $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sqld .= " WHERE fk_product=".$objp->rowid; @@ -126,11 +127,11 @@ class box_produits extends ModeleBoxes $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); - if ($resultd) - { + if ($resultd) { $objtp = $this->db->fetch_object($resultd); - if (isset($objtp->label) && $objtp->label != '') + if (isset($objtp->label) && $objtp->label != '') { $objp->label = $objtp->label; + } } } $productstatic->id = $objp->rowid; @@ -145,6 +146,8 @@ class box_produits extends ModeleBoxes $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra; $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export; $productstatic->accountancy_code_buy = $objp->accountancy_code_buy; + $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra; + $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', @@ -162,13 +165,12 @@ class box_produits extends ModeleBoxes $price_base_type = $langs->trans($objp->price_base_type); $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); } else //Parse the dynamic price - { + { $productstatic->fetch($objp->rowid, '', '', 1); $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProduct($productstatic); if ($price_result >= 0) { - if ($objp->price_base_type == 'HT') - { + if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); } else { $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); @@ -176,7 +178,7 @@ class box_produits extends ModeleBoxes } $price = price($price_result); } - } + } $this->info_box_contents[$line][] = array( 'td' => 'class="right"', 'text' => $price, @@ -206,11 +208,12 @@ class box_produits extends ModeleBoxes $line++; } - if ($num == 0) + if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedProducts"), ); + } $this->db->free($result); } else { From 325951877be9ae30aef2fbc30f78e8ff5a7f1138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 5 Dec 2020 08:58:20 +0100 Subject: [PATCH 2/2] fix missing fields in box --- htdocs/core/boxes/box_produits.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 57f964d09ce..f36b0500655 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -164,8 +164,8 @@ class box_produits extends ModeleBoxes if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { $price_base_type = $langs->trans($objp->price_base_type); $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + } else { + //Parse the dynamic price $productstatic->fetch($objp->rowid, '', '', 1); $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProduct($productstatic);