From 1cc673a9c61722dd9c628f3dde9d386c374bc7bb Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 12 Aug 2020 08:53:24 +0000 Subject: [PATCH] Fixing style errors. --- .../class/ProductCombination.class.php | 65 +++++++++---------- htdocs/variants/combinations.php | 32 ++++----- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 777cb136b05..17d1688d268 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -139,13 +139,13 @@ class ProductCombination public function fetchCombinationPriceLevels($fk_price_level = 0, $useCache = true) { // Check cache - if(!empty($this->combination_price_levels) && $useCache){ - if((!empty($fk_price_level) && isset($this->combination_price_levels[$fk_price_level])) || empty($fk_price_level)){ + if (!empty($this->combination_price_levels) && $useCache){ + if ((!empty($fk_price_level) && isset($this->combination_price_levels[$fk_price_level])) || empty($fk_price_level)){ return 1; } } - if(!is_array($this->combination_price_levels) + if (!is_array($this->combination_price_levels) || empty($fk_price_level) // if fetch an unique level dont erase all already fetched ){ $this->combination_price_levels = array(); @@ -178,15 +178,15 @@ class ProductCombination $staticProductCombinationLevel = new ProductCombinationLevel($this->db); // Delete all - if(empty($this->combination_price_levels)){ + if (empty($this->combination_price_levels)){ return $staticProductCombinationLevel->deleteAllForCombination($this->id); } // Clean not needed price levels - if($clean){ + if ($clean){ $res = $staticProductCombinationLevel->clean($this->id); - if($res<0){ + if ($res<0){ $this->errors[] = 'Fail to clean not needed price levels'; return -1; } @@ -194,17 +194,17 @@ class ProductCombination foreach ($this->combination_price_levels as $fk_price_level => $combination_price_level){ $res = $combination_price_level->save(); - if($res<1){ + if ($res<1){ $this->error = 'save combination price level '.$fk_price_level . ' '.$combination_price_level->error; $this->errors[] = $this->error; $errors ++; } } - if($errors > 0){ + if ($errors > 0){ return $errors*-1; } - else{ + else { return 1; } } @@ -331,7 +331,7 @@ class ProductCombination if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $res = $this->saveCombinationPriceLevels(); - if($res<0){ + if ($res<0){ return -2; } } @@ -365,7 +365,7 @@ class ProductCombination if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $res = $this->saveCombinationPriceLevels(); - if($res<0){ + if ($res<0){ return -2; } } @@ -392,7 +392,7 @@ class ProductCombination $comb2val->deleteByFkCombination($this->id); // remove combination price levels - if(!$this->db->query("DELETE FROM ".MAIN_DB_PREFIX."product_attribute_combination_price_level WHERE fk_product_attribute_combination = ".(int) $this->id)) { + if (!$this->db->query("DELETE FROM ".MAIN_DB_PREFIX."product_attribute_combination_price_level WHERE fk_product_attribute_combination = ".(int) $this->id)) { $this->db->rollback(); return -1; } @@ -682,10 +682,10 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $weight_impact = (float) $forced_weightvar; // If false, return 0 //Final price impact - if(!is_array($forced_pricevar)){ + if (!is_array($forced_pricevar)){ $price_impact[1] = (float) $forced_pricevar; // If false, return 0 } - else{ + else { $price_impact = $forced_pricevar; } @@ -732,7 +732,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $price_impact[1] += (float) price2num($variations[$currcombattr][$currcombval]['price']); // Manage Price levels - if($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES){ for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $price_impact[$i] += (float) price2num($variations[$currcombattr][$currcombval]['price']); @@ -760,16 +760,16 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $newcomb->variation_weight = $weight_impact; // Init price level - if($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES){ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ $productCombinationLevel = new ProductCombinationLevel($this->db); $productCombinationLevel->fk_product_attribute_combination = 0; $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - if(is_array($price_var_percent)){ + if (is_array($price_var_percent)){ $productCombinationLevel->variation_price_percentage = !empty($price_var_percent[$i]) ? $price_var_percent[$i] : 0; - }else{ + }else { $productCombinationLevel->variation_price_percentage = $price_var_percent; } @@ -1000,11 +1000,11 @@ class ProductCombinationLevel */ public function fetch($rowid) { - $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage FROM " . MAIN_DB_PREFIX . $this->table_element." WHERE rowid = " . (int)$rowid; + $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage FROM " . MAIN_DB_PREFIX . $this->table_element." WHERE rowid = " . (int) $rowid; $obj = $this->db->getRow($sql); - if($obj){ + if ($obj){ return $this->fetchFormObj($obj); } @@ -1026,7 +1026,7 @@ class ProductCombinationLevel ." FROM ".MAIN_DB_PREFIX.$this->table_element ." WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination); - if(!empty($fk_price_level)){ + if (!empty($fk_price_level)){ $sql.= ' AND fk_price_level = '.intval($fk_price_level); } @@ -1039,7 +1039,7 @@ class ProductCombinationLevel $result = array(); // For more simple usage set level as array key - foreach($combination_price_levels as $k => $row){ + foreach ($combination_price_levels as $k => $row){ $productCombinationLevel = new ProductCombinationLevel($this->db); $productCombinationLevel->fetchFormObj($row); $result[$row->fk_price_level] = $productCombinationLevel; @@ -1064,7 +1064,7 @@ class ProductCombinationLevel $this->fk_product_attribute_combination = doubleval($obj->fk_product_attribute_combination); $this->fk_price_level = intval($obj->fk_price_level); $this->variation_price = doubleval($obj->variation_price); - $this->variation_price_percentage = (bool)$obj->variation_price_percentage; + $this->variation_price_percentage = (bool) $obj->variation_price_percentage; return 1; } @@ -1080,41 +1080,41 @@ class ProductCombinationLevel $errors = 0; - if(empty($this->fk_product_attribute_combination) || empty($this->fk_price_level)){ + if (empty($this->fk_product_attribute_combination) || empty($this->fk_price_level)){ return -1; } // check if level exist in DB before add - if(empty($this->id)){ + if (empty($this->id)){ $sql = "SELECT rowid id" ." FROM ".MAIN_DB_PREFIX . $this->table_element ." WHERE fk_product_attribute_combination = ".(int) $this->fk_product_attribute_combination .' AND fk_price_level = '.intval($this->fk_price_level); $existObj = $this->db->getRow($sql); - if($existObj){ + if ($existObj){ $this->id = $existObj->id; } } // Update - if(!empty($this->id)) { + if (!empty($this->id)) { $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET ' . ' variation_price = '.doubleval($this->variation_price) . ' , variation_price_percentage = '.intval($this->variation_price_percentage) . ' WHERE rowid = '.intval($this->id); $res = $this->db->query($sql); - if($res>0){ + if ($res>0){ return $this->id; } - else{ + else { $this->error = $this->db->error(); $this->errors[] = $this->error; return -1; } } - else{ + else { // ADD $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " (" . " fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage" @@ -1126,10 +1126,10 @@ class ProductCombinationLevel . " )"; $res = $this->db->query($sql); - if($res){ + if ($res){ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); } - else{ + else { $this->error = $this->db->error(); $this->errors[] = $this->error; return -1; @@ -1186,5 +1186,4 @@ class ProductCombinationLevel return $res ? 1 : -1; } - } diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 5ad7b38af2e..b9f62bdcf73 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -118,11 +118,11 @@ if ($_POST) { $price_impact = price2num($price_impact); // for conf PRODUIT_MULTIPRICES - if($conf->global->PRODUIT_MULTIPRICES) { + if ($conf->global->PRODUIT_MULTIPRICES) { $level_price_impact = array_map('price2num', $level_price_impact); $level_price_impact_percent = array_map('price2num', $level_price_impact_percent); } - else{ + else { $level_price_impact = array(1 => $weight_impact); $level_price_impact_percent = array(1 => $price_impact_percent); } @@ -243,19 +243,20 @@ if ($_POST) { $prodcomb->variation_weight = $weight_impact; // for conf PRODUIT_MULTIPRICES - if($conf->global->PRODUIT_MULTIPRICES) { + if ($conf->global->PRODUIT_MULTIPRICES) { $level_price_impact = array_map('price2num', $level_price_impact); - $level_price_impact_percent = array_map(function($a){ return !empty($a);}, $level_price_impact_percent); + $level_price_impact_percent = array_map(function ($a) { + return !empty($a);}, $level_price_impact_percent); $prodcomb->variation_price = $level_price_impact[1]; - $prodcomb->variation_price_percentage = (bool)$level_price_impact_percent[1]; + $prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1]; } - else{ + else { $level_price_impact = array(1 => $weight_impact); $level_price_impact_percent = array(1 => $price_impact_percent); } - if($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES){ $prodcomb->combination_price_levels = array(); for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ $productCombinationLevel = new ProductCombinationLevel($db); @@ -634,23 +635,22 @@ if (!empty($id) || !empty($ref)) -global->PRODUIT_MULTIPRICES)){ ?> + global->PRODUIT_MULTIPRICES)){ ?> > -fetchCombinationPriceLevels(); for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { - print ''; - print ''; - if($i===1){ + print ''; + if ($i===1){ print ' ('.$langs->trans('ApplyToAllPriceImpactLevel').')'; } print ''; @@ -672,7 +672,7 @@ if (!empty($id) || !empty($ref)) } if (!empty($conf->global->PRODUIT_MULTIPRICES)){ -?> + ?> - + ?>
value="trans('Create') : $langs->trans('Save') ?>" class="button">