Merge pull request #9803 from simnandez/develop
NEW Child label of variants change if parent label changes
This commit is contained in:
commit
b12769e5c1
@ -330,6 +330,8 @@ class ProductCombination
|
||||
$child->price_autogen = $parent->price_autogen;
|
||||
$child->weight = $parent->weight + $this->variation_weight;
|
||||
$child->weight_units = $parent->weight_units;
|
||||
$varlabel = $this->getCombinationLabel($this->fk_product_child);
|
||||
$child->label = $parent->label.$varlabel;
|
||||
|
||||
if ($child->update($child->id, $user) > 0) {
|
||||
|
||||
@ -338,14 +340,33 @@ class ProductCombination
|
||||
|
||||
// MultiPrix
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
|
||||
$new_type = $parent->multiprices_base_type[1];
|
||||
$new_min_price = $parent->multiprices_min[1];
|
||||
$new_psq = $parent->multiprices_recuperableonly[1];
|
||||
for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
|
||||
{
|
||||
if ($parent->multiprices[$i] != '') {
|
||||
$new_type = $parent->multiprices_base_type[$i];
|
||||
$new_min_price = $parent->multiprices_min[$i];
|
||||
if ($parent->prices_by_qty_list[$i]) {
|
||||
$new_psq = 1;
|
||||
} else {
|
||||
$new_psq = 0;
|
||||
}
|
||||
|
||||
if ($new_type == 'TTC') {
|
||||
$new_price = $parent->multiprices_ttc[1];
|
||||
} else {
|
||||
$new_price = $parent->multiprices[1];
|
||||
if ($new_type == 'TTC') {
|
||||
$new_price = $parent->multiprices_ttc[$i];
|
||||
} else {
|
||||
$new_price = $parent->multiprices[$i];
|
||||
}
|
||||
|
||||
if ($this->variation_price_percentage) {
|
||||
if ($new_price != 0) {
|
||||
$new_price *= 1 + ($this->variation_price / 100);
|
||||
}
|
||||
} else {
|
||||
$new_price += $this->variation_price;
|
||||
}
|
||||
|
||||
$child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$new_type = $parent->price_base_type;
|
||||
@ -357,15 +378,17 @@ class ProductCombination
|
||||
} else {
|
||||
$new_price = $parent->price;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->variation_price_percentage) {
|
||||
$new_price *= 1 + ($this->variation_price/100);
|
||||
} else {
|
||||
$new_price += $this->variation_price;
|
||||
}
|
||||
if ($this->variation_price_percentage) {
|
||||
if ($new_price != 0) {
|
||||
$new_price *= 1 + ($this->variation_price / 100);
|
||||
}
|
||||
} else {
|
||||
$new_price += $this->variation_price;
|
||||
}
|
||||
|
||||
$child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, 1, $new_npr, $new_psq);
|
||||
$child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, 1, $new_npr, $new_psq);
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
@ -682,4 +705,39 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return label for combinations
|
||||
* @param int $prod_child id of child
|
||||
* @return string combination label
|
||||
*/
|
||||
public function getCombinationLabel($prod_child)
|
||||
{
|
||||
$label = '';
|
||||
$sql = 'SELECT pav.value AS label';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'product_attribute_combination pac';
|
||||
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product_attribute_combination2val pac2v ON pac2v.fk_prod_combination=pac.rowid';
|
||||
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product_attribute_value pav ON pav.rowid=pac2v.fk_prod_attr_val';
|
||||
$sql.= ' WHERE pac.fk_product_child='.$prod_child;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
if ($obj->label)
|
||||
{
|
||||
$label.=' '.$obj->label;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,6 +318,66 @@ if (! empty($id) || ! empty($ref))
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border tableforfield" width="100%">';
|
||||
|
||||
// TVA
|
||||
print '<tr><td class="titlefield">' . $langs->trans("DefaultTaxRate") . '</td><td>';
|
||||
|
||||
$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';
|
||||
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);*/
|
||||
print '</td></tr>';
|
||||
|
||||
// Price
|
||||
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
|
||||
if ($object->price_base_type == 'TTC') {
|
||||
print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type);
|
||||
} else {
|
||||
print price($object->price) . ' ' . $langs->trans($object->price_base_type);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Price minimum
|
||||
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
|
||||
if ($object->price_base_type == 'TTC') {
|
||||
print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type);
|
||||
} else {
|
||||
print price($object->price_min) . ' ' . $langs->trans($object->price_base_type);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Weight
|
||||
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
||||
if ($object->weight != '')
|
||||
{
|
||||
print $object->weight." ".measuring_units_string($object->weight_units,"weight");
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
|
||||
|
||||
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print '</div>';
|
||||
print '<div style="clear:both"></div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user