diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index f6eb4c58935..fd08ccf1b6a 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -186,7 +186,7 @@ class ProductCombination { $nb = 0; $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product').")"; - + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -195,7 +195,7 @@ class ProductCombination return $nb; } - + /** * Creates a product attribute combination * @@ -249,9 +249,10 @@ class ProductCombination /** * Deletes a product combination * + * @param User $user * @return int <0 KO >0 OK */ - public function delete() + public function delete(User $user) { $this->db->begin(); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 76a091ad8a2..0ec1bf07b68 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -101,8 +101,8 @@ if ($_POST) { if (!$features) { setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); - } - else + } + else { $weight_impact = price2num($weight_impact); $price_impact = price2num($price_impact); @@ -149,8 +149,8 @@ if ($_POST) { $db->rollback(); } - } - elseif (! empty($massaction)) + } + elseif (! empty($massaction)) { $bulkaction = $massaction; $error = 0; @@ -203,7 +203,7 @@ if ($_POST) { setEventMessage($langs->trans('RecordSaved')); } - } + } elseif ($valueid > 0) { if ($prodcomb->fetch($valueid) < 0) { @@ -234,7 +234,7 @@ if ($action === 'confirm_deletecombination') { $db->begin(); - if ($prodcomb->delete() > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete() > 0) { + if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) { $db->commit(); setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2)); @@ -288,26 +288,26 @@ 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; - + $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'combinations', $titre, 0, $picto); - + $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter=" fk_product_type = ".$object->type; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); - + dol_fiche_end(); - + // Create or edit a varian if ($action == 'add' || ($action == 'edit')) { @@ -343,7 +343,7 @@ if (! empty($id) || ! empty($ref)) info: [] }; - fetch($pc2v->fk_prod_attr_val); ?> @@ -355,8 +355,8 @@ if (! empty($id) || ! empty($ref)) label: 'value ?>' } }; - restoreAttributes = function() { @@ -369,7 +369,7 @@ if (! empty($id) || ! empty($ref)) }); }; - + jQuery(document).ready(function() { jQuery("select#attribute").change(function () { console.log("Change of field variant attribute"); @@ -404,18 +404,18 @@ if (! empty($id) || ! empty($ref)) }); }); - - '."\n"; print ''."\n"; print ''."\n"; - + print dol_fiche_head(); - + ?> - +