mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
fix: Variant with multiprice, on creation of variant, percent variation is not save
This commit is contained in:
parent
b5bb71ed63
commit
f8bd644b58
|
|
@ -2668,7 +2668,7 @@ class Product extends CommonObject
|
|||
|
||||
// Load multiprices array
|
||||
if (getDolGlobalString('PRODUIT_MULTIPRICES') && empty($ignore_price_load)) { // prices per segment
|
||||
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
||||
for ($i = 1; $i <= getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); $i++) {
|
||||
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
|
||||
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly";
|
||||
$sql .= " FROM ".$this->db->prefix()."product_price";
|
||||
|
|
@ -2778,7 +2778,7 @@ class Product extends CommonObject
|
|||
return -1;
|
||||
}
|
||||
} elseif (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') && empty($ignore_price_load)) { // prices per customer and quantity
|
||||
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
||||
for ($i = 1; $i <= getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); $i++) {
|
||||
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
|
||||
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly";
|
||||
$sql .= " FROM ".$this->db->prefix()."product_price";
|
||||
|
|
|
|||
|
|
@ -526,12 +526,12 @@ class ProductCombination
|
|||
|
||||
// MultiPrix
|
||||
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
|
||||
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
||||
for ($i = 1; $i <= getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); $i++) {
|
||||
if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) {
|
||||
$new_type = empty($parent->multiprices_base_type[$i]) ? 'HT' : $parent->multiprices_base_type[$i];
|
||||
$new_min_price = $parent->multiprices_min[$i];
|
||||
$variation_price = (float) (!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price);
|
||||
$variation_price_percentage = (float) (!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage);
|
||||
$variation_price_percentage = (bool) (!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage);
|
||||
|
||||
if ($parent->prices_by_qty_list[$i]) {
|
||||
$new_psq = 1;
|
||||
|
|
@ -828,21 +828,21 @@ class ProductCombination
|
|||
$newproduct->description .= '<strong>'.$prodattr->label.':</strong> '.$prodattrval->value;
|
||||
}
|
||||
|
||||
$newcomb->variation_price_percentage = $price_var_percent[1];
|
||||
$newcomb->variation_price_percentage = (bool) $price_var_percent[1];
|
||||
$newcomb->variation_price = $price_impact[1];
|
||||
$newcomb->variation_weight = $weight_impact;
|
||||
$newcomb->variation_ref_ext = $this->db->escape($ref_ext);
|
||||
|
||||
// Init price level
|
||||
if ($conf->global->PRODUIT_MULTIPRICES) {
|
||||
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
||||
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
|
||||
for ($i = 1; $i <= getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); $i++) {
|
||||
$productCombinationLevel = new ProductCombinationLevel($this->db);
|
||||
$productCombinationLevel->fk_product_attribute_combination = $newcomb->id;
|
||||
$productCombinationLevel->fk_price_level = $i;
|
||||
$productCombinationLevel->variation_price = $price_impact[$i];
|
||||
|
||||
if (is_array($price_var_percent)) {
|
||||
$productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]);
|
||||
$productCombinationLevel->variation_price_percentage = (bool) $price_var_percent[$i] ;
|
||||
} else {
|
||||
$productCombinationLevel->variation_price_percentage = $price_var_percent;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
|
|||
|
||||
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
|
||||
$prodcomb->combination_price_levels = array();
|
||||
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
||||
for ($i = 1; $i <= getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); $i++) {
|
||||
$productCombinationLevel = new ProductCombinationLevel($db);
|
||||
$productCombinationLevel->fk_product_attribute_combination = $prodcomb->id;
|
||||
$productCombinationLevel->fk_price_level = $i;
|
||||
|
|
@ -717,14 +717,15 @@ if (!empty($id) || !empty($ref)) {
|
|||
<tr>
|
||||
<td><label for="price_impact"><?php echo $langs->trans('PriceImpact') ?></label></td>
|
||||
<td><input type="text" id="price_impact" name="price_impact" value="<?php echo price($price_impact) ?>">
|
||||
<input type="checkbox" id="price_impact_percent" name="price_impact_percent" <?php echo $price_impact_percent ? ' checked' : '' ?>> <label for="price_impact_percent"><?php echo $langs->trans('PercentageVariation') ?></label>
|
||||
|
||||
<input type="checkbox" id="price_impact_percent" name="price_impact_percent" <?php echo ($price_impact_percent ? ' checked' : '') ?>> <label for="price_impact_percent"><?php echo $langs->trans('PercentageVariation') ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} else {
|
||||
$prodcomb->fetchCombinationPriceLevels();
|
||||
|
||||
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
|
||||
for ($i = 1; $i <= getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); $i++) {
|
||||
$keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
|
||||
$text = $langs->trans('ImpactOnPriceLevel', $i).' - '.getDolGlobalString($keyforlabel);
|
||||
print '<tr>';
|
||||
|
|
@ -734,7 +735,7 @@ if (!empty($id) || !empty($ref)) {
|
|||
}
|
||||
print '</td>';
|
||||
print '<td><input type="text" class="level_price_impact" id="level_price_impact_'.$i.'" name="level_price_impact['.$i.']" value="'.price($prodcomb->combination_price_levels[$i]->variation_price).'">';
|
||||
print '<input type="checkbox" class="level_price_impact_percent" id="level_price_impact_percent_'.$i.'" name="level_price_impact_percent['.$i.']" '.(!empty($prodcomb->combination_price_levels[$i]->variation_price_percentage) ? ' checked' : '').'> <label for="level_price_impact_percent_'.$i.'">'.$langs->trans('PercentageVariation').'</label>';
|
||||
print '<input type="checkbox" class="level_price_impact_percent" id="level_price_impact_percent_'.$i.'" name="level_price_impact_percent['.$i.']" '.($prodcomb->combination_price_levels[$i]->variation_price_percentage ? ' checked' : '').'> <label for="level_price_impact_percent_'.$i.'">'.$langs->trans('PercentageVariation').'</label>';
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
|
@ -761,7 +762,7 @@ if (!empty($id) || !empty($ref)) {
|
|||
let priceImpact = $( "#level_price_impact_1" ).val();
|
||||
let priceImpactPrecent = $( "#level_price_impact_percent_1" ).prop("checked");
|
||||
|
||||
var multipricelimit = <?php print intval($conf->global->PRODUIT_MULTIPRICES_LIMIT); ?>
|
||||
let multipricelimit = <?php print getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); ?>
|
||||
|
||||
for (let i = 2; i <= multipricelimit; i++) {
|
||||
$( "#level_price_impact_" + i ).val(priceImpact);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user