diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php
index 64209076916..f5467760a89 100644
--- a/htdocs/variants/admin/admin.php
+++ b/htdocs/variants/admin/admin.php
@@ -25,8 +25,9 @@ $langs->loadLangs(array("admin", "products"));
$action = GETPOST('action', 'alphanohtml');
// Security check
-if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled)))
+if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) {
accessforbidden();
+}
$error = 0;
diff --git a/htdocs/variants/ajax/getCombinations.php b/htdocs/variants/ajax/getCombinations.php
index 67c1dd4284c..adb227c2fd6 100644
--- a/htdocs/variants/ajax/getCombinations.php
+++ b/htdocs/variants/ajax/getCombinations.php
@@ -16,11 +16,21 @@
* along with this program. If not, see .
*/
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
-if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', '1');
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREHTML')) {
+ define('NOREQUIREHTML', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOREQUIRESOC')) {
+ define('NOREQUIRESOC', '1');
+}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php
index e80cb9aae2b..e61676339ee 100644
--- a/htdocs/variants/ajax/get_attribute_values.php
+++ b/htdocs/variants/ajax/get_attribute_values.php
@@ -15,11 +15,21 @@
* along with this program. If not, see .
*/
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
-if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', '1');
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREHTML')) {
+ define('NOREQUIREHTML', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOREQUIRESOC')) {
+ define('NOREQUIRESOC', '1');
+}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
diff --git a/htdocs/variants/ajax/orderAttribute.php b/htdocs/variants/ajax/orderAttribute.php
index 8b851c9be6b..c787517e5c7 100644
--- a/htdocs/variants/ajax/orderAttribute.php
+++ b/htdocs/variants/ajax/orderAttribute.php
@@ -16,12 +16,24 @@
* along with this program. If not, see .
*/
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable token renewal
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
-if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
-if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', '1'); // Disable token renewal
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREHTML')) {
+ define('NOREQUIREHTML', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOREQUIRESOC')) {
+ define('NOREQUIRESOC', '1');
+}
+if (!defined('NOREQUIRETRAN')) {
+ define('NOREQUIRETRAN', '1');
+}
require '../../main.inc.php';
diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php
index 986db1b14bc..ecaa4e77948 100644
--- a/htdocs/variants/card.php
+++ b/htdocs/variants/card.php
@@ -41,7 +41,9 @@ if ($object->fetch($id) < 1) {
* Actions
*/
-if ($cancel) $action = '';
+if ($cancel) {
+ $action = '';
+}
if ($action) {
if ($action == 'update') {
@@ -60,19 +62,16 @@ if ($action) {
$objectval->ref = $ref;
$objectval->value = GETPOST('value', 'alpha');
- if (empty($objectval->ref))
- {
+ if (empty($objectval->ref)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
}
- if (empty($objectval->value))
- {
+ if (empty($objectval->value)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
}
- if (!$error)
- {
+ if (!$error) {
if ($objectval->update($user) > 0) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} else {
@@ -102,8 +101,7 @@ if ($confirm == 'yes') {
header('Location: '.dol_buildpath('/variants/list.php', 2));
}
exit();
- } elseif ($action == 'confirm_deletevalue')
- {
+ } elseif ($action == 'confirm_deletevalue') {
if ($objectval->fetch($valueid) > 0) {
if ($objectval->delete($user) < 1) {
setEventMessages($langs->trans('CoreErrorMessage'), $objectval->errors, 'errors');
diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php
index bbc3a188137..b823cbea470 100644
--- a/htdocs/variants/class/ProductAttribute.class.php
+++ b/htdocs/variants/class/ProductAttribute.class.php
@@ -116,8 +116,7 @@ class ProductAttribute extends CommonObject
$sql = 'SELECT rowid, ref, ref_ext, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getEntity('product').')';
$sql .= $this->db->order('rang', 'asc');
$query = $this->db->query($sql);
- if ($query)
- {
+ if ($query) {
while ($result = $this->db->fetch_object($query)) {
$tmp = new ProductAttribute($this->db);
$tmp->id = $result->rowid;
@@ -128,8 +127,9 @@ class ProductAttribute extends CommonObject
$return[] = $tmp;
}
+ } else {
+ dol_print_error($this->db);
}
- else dol_print_error($this->db);
return $return;
}
@@ -159,8 +159,7 @@ class ProductAttribute extends CommonObject
VALUES ('".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->escape($this->label)."', ".(int) $this->entity.", ".(int) $this->rang.")";
$query = $this->db->query($sql);
- if ($query)
- {
+ if ($query) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'product_attribute');
return $this->id;
diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php
index 9152336bbe4..e60b99298fa 100644
--- a/htdocs/variants/class/ProductCombination.class.php
+++ b/htdocs/variants/class/ProductCombination.class.php
@@ -174,8 +174,7 @@ class ProductCombination
*/
if ($fk_price_level > 0) {
$combination_price_levels[$fk_price_level] = ProductCombinationLevel::createFromParent($this->db, $this, $fk_price_level);
- }
- else {
+ } else {
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$combination_price_levels[$i] = ProductCombinationLevel::createFromParent($this->db, $this, $i);
}
@@ -227,8 +226,7 @@ class ProductCombination
if ($error) {
return $error * -1;
- }
- else {
+ } else {
return 1;
}
}
@@ -327,7 +325,9 @@ class ProductCombination
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
- if ($obj) $nb = $obj->nb;
+ if ($obj) {
+ $nb = $obj->nb;
+ }
}
return $nb;
@@ -506,8 +506,7 @@ class ProductCombination
// MultiPrix
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
- for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
- {
+ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) {
$new_type = $parent->multiprices_base_type[$i];
$new_min_price = $parent->multiprices_min[$i];
@@ -709,8 +708,7 @@ class ProductCombination
//Final price impact
if (!is_array($forced_pricevar)) {
$price_impact[1] = (float) $forced_pricevar; // If false, return 0
- }
- else {
+ } else {
$price_impact = $forced_pricevar;
}
@@ -765,8 +763,7 @@ class ProductCombination
// Manage Price levels
if ($conf->global->PRODUIT_MULTIPRICES) {
- for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
- {
+ for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$price_impact[$i] += (float) price2num($variations[$currcombattr][$currcombval]['price']);
}
}
@@ -826,8 +823,7 @@ class ProductCombination
$newproduct->barcode = -1;
$result = $newproduct->create($user);
- if ($result < 0)
- {
+ if ($result < 0) {
//In case the error is not related with an already existing product
if ($newproduct->error != 'ErrorProductAlreadyExists') {
$this->error[] = $newproduct->error;
@@ -867,8 +863,7 @@ class ProductCombination
}
} else {
$result = $newproduct->update($newproduct->id, $user);
- if ($result < 0)
- {
+ if ($result < 0) {
$this->db->rollback();
return -1;
}
@@ -876,8 +871,7 @@ class ProductCombination
$newcomb->fk_product_child = $newproduct->id;
- if ($newcomb->update($user) < 0)
- {
+ if ($newcomb->update($user) < 0) {
$this->error = $newcomb->error;
$this->errors = $newcomb->errors;
$this->db->rollback();
@@ -925,8 +919,7 @@ class ProductCombination
$combination->variation_price_percentage,
$combination->variation_price,
$combination->variation_weight
- ) < 0)
- {
+ ) < 0) {
return -1;
}
}
@@ -954,12 +947,10 @@ class ProductCombination
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($resql);
- if ($obj->label)
- {
+ if ($obj->label) {
$label .= ' '.$obj->label;
}
$i++;
diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php
index 933d379e48a..f950f764ad7 100644
--- a/htdocs/variants/combinations.php
+++ b/htdocs/variants/combinations.php
@@ -58,8 +58,7 @@ $prodattr = new ProductAttribute($db);
$prodattr_val = new ProductAttributeValue($db);
$object = new Product($db);
-if ($id > 0 || $ref)
-{
+if ($id > 0 || $ref) {
$object->fetch($id, $ref);
}
@@ -80,16 +79,13 @@ if (!$object->isProduct() && !$object->isService()) {
header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2));
exit();
}
-if ($action == 'add')
-{
+if ($action == 'add') {
unset($selectedvariant);
unset($_SESSION['addvariant_'.$object->id]);
}
-if ($action == 'create' && GETPOST('selectvariant', 'alpha')) // We click on select combination
-{
+if ($action == 'create' && GETPOST('selectvariant', 'alpha')) { // We click on select combination
$action = 'add';
- if (GETPOST('attribute') != '-1' && GETPOST('value') != '-1')
- {
+ if (GETPOST('attribute') != '-1' && GETPOST('value') != '-1') {
$selectedvariant[GETPOST('attribute').':'.GETPOST('value')] = GETPOST('attribute').':'.GETPOST('value');
$_SESSION['addvariant_'.$object->id] = $selectedvariant;
}
@@ -101,9 +97,8 @@ $prodcomb2val = new ProductCombination2ValuePair($db);
$productCombination2ValuePairs1 = array();
-if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST('selectvariant', 'alpha')) // We click on Create all defined combinations
-{
- //$features = GETPOST('features', 'array');
+if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST('selectvariant', 'alpha')) { // We click on Create all defined combinations
+//$features = GETPOST('features', 'array');
$features = $_SESSION['addvariant_'.$object->id];
if (!$features) {
@@ -121,8 +116,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
// for conf PRODUIT_MULTIPRICES
if ($conf->global->PRODUIT_MULTIPRICES) {
$level_price_impact = array_map('price2num', $level_price_impact);
- }
- else {
+ } else {
$level_price_impact = array(1 => $price_impact);
$level_price_impact_percent = array(1 => $price_impact_percent);
}
@@ -156,11 +150,9 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
// sanit_feature is an array with 1 (and only 1) value per attribute.
// For example: Color->blue, Size->Small, Option->2
//var_dump($sanit_features);
- if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features))
- {
+ if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) {
$result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference);
- if ($result > 0)
- {
+ if ($result > 0) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
unset($_SESSION['addvariant_'.$object->id]);
@@ -243,8 +235,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
$prodcomb->variation_price = $level_price_impact[1];
$prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1];
- }
- else {
+ } else {
$level_price_impact = array(1 => $price_impact);
$level_price_impact_percent = array(1 => $price_impact_percent);
@@ -330,12 +321,13 @@ if ($action === 'confirm_deletecombination') {
$form = new Form($db);
-if (!empty($id) || !empty($ref))
-{
+if (!empty($id) || !empty($ref)) {
llxHeader("", "", $langs->trans("CardProduct".$object->type));
$showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
- if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0;
+ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
+ $showbarcode = 0;
+ }
$head = product_prepare_head($object);
$titre = $langs->trans("CardProduct".$object->type);
@@ -357,17 +349,25 @@ if (!empty($id) || !empty($ref))
print '
| '.$langs->trans("DefaultTaxRate").' | ';
$positiverates = '';
- if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx);
- if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx);
- if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx);
- if (empty($positiverates)) $positiverates = '0';
+ if (price2num($object->tva_tx)) {
+ $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx);
+ }
+ if (price2num($object->localtax1_type)) {
+ $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx);
+ }
+ if (price2num($object->localtax2_type)) {
+ $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx);
+ }
+ if (empty($positiverates)) {
+ $positiverates = '0';
+ }
echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr);
/*
- if ($object->default_vat_code)
- {
- print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')';
- }
- else print vatrate($object->tva_tx, true, $object->tva_npr, true);*/
+ if ($object->default_vat_code)
+ {
+ print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')';
+ }
+ else print vatrate($object->tva_tx, true, $object->tva_npr, true);*/
print ' |
';
// Price
@@ -390,8 +390,7 @@ if (!empty($id) || !empty($ref))
// Weight
print '| '.$langs->trans("Weight").' | ';
- if ($object->weight != '')
- {
+ if ($object->weight != '') {
print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units);
} else {
print ' ';
@@ -466,14 +465,14 @@ if (!empty($id) || !empty($ref))
foreach ($productCombination2ValuePairs1 as $pc2v) {
$prodattr_val->fetch($pc2v->fk_prod_attr_val);
?>
- variants_selected.index.push(fk_prod_attr ?>);
- variants_selected.info[fk_prod_attr ?>] = {
- attribute: variants_available[fk_prod_attr ?>],
- value: {
- id: fk_prod_attr_val ?>,
- label: 'value ?>'
- }
- };
+ variants_selected.index.push(fk_prod_attr ?>);
+ variants_selected.info[fk_prod_attr ?>] = {
+ attribute: variants_available[fk_prod_attr ?>],
+ value: {
+ id: fk_prod_attr_val ?>,
+ label: 'value ?>'
+ }
+ };
@@ -604,8 +603,7 @@ if (!empty($id) || !empty($ref))
print ' |