Просмотр исходного кода

[Administration] Produits > prix spécifiques : calcul des prix via un champs de remises en pourcentage #1156

feature/souke
Guillaume Bourgeois 1 год назад
Родитель
Сommit
15c1a1777c
2 измененных файлов: 32 добавлений и 2 удалений
  1. +9
    -2
      backend/views/product/update/prices/_form.php
  2. +23
    -0
      backend/web/js/backend.js

+ 9
- 2
backend/views/product/update/prices/_form.php Просмотреть файл

@@ -40,13 +40,20 @@ $productManager = $this->getProductManager();
<?= $form->field($model, 'price', [
'template' => '
<div class="row">
<div class="col-xs-6">
<div class="col-xs-4">
<label for="reduction-increase-percent" class="control-label">Réduction / augmentation</label>
<div class="input-group">
<input type="text" id="reduction-increase-percent" class="form-control" name="" value="" data-price-base="'.$productManager->getPrice($modelProduct).'">
<span class="input-group-addon">%</span>
</div>
</div>
<div class="col-xs-4">
<label for="product-price" class="control-label without-tax">Prix ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording_unit').') HT</label>
<div class="input-group">
{input} <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>
</div>
</div>
<div class="col-xs-6">
<div class="col-xs-4">
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label>
<div class="input-group">
<input type="text" id="productprice-price-with-tax" class="form-control" name="" value="" data-tax-rate-value="'.$taxRateValue.'">

+ 23
- 0
backend/web/js/backend.js Просмотреть файл

@@ -262,6 +262,9 @@ function opendistrib_product_prices() {
opendistrib_product_prices_event_price_with_tax();
$('#productprice-price').change(opendistrib_product_prices_event_price_with_tax);
$('#productprice-price-with-tax').change(opendistrib_product_prices_event_price);
$('#reduction-increase-percent').change(function() {
opendistrib_product_prices_event_reduction_increase();
});
}
}

@@ -272,6 +275,8 @@ function opendistrib_product_prices_event_price_with_tax() {
$('#productprice-price-with-tax').val(getPriceWithTax(price, taxRateValue));
// formattage
$('#productprice-price').val(parseFloat(price).toFixed(5));

opendistrib_product_prices_update_reduction_increase();
}
}

@@ -282,6 +287,24 @@ function opendistrib_product_prices_event_price() {
$('#productprice-price').val(getPrice(priceWithTax, taxRateValue));
// formattage
$('#productprice-price-with-tax').val(parseFloat(priceWithTax).toFixed(2));

opendistrib_product_prices_update_reduction_increase();
}
}
function opendistrib_product_prices_update_reduction_increase() {
var productPriceBase = $('#reduction-increase-percent').data('price-base');
var productPriceSpecific = $('#productprice-price').val().replace(',', '.');
var reductionIncreasePercent = (productPriceSpecific / productPriceBase) * 100 - 100;
$('#reduction-increase-percent').val(parseFloat(reductionIncreasePercent).toFixed(5));
}

function opendistrib_product_prices_event_reduction_increase() {
var productPriceBase = $('#reduction-increase-percent').data('price-base');
var reductionIncreasePercent = $('#reduction-increase-percent').val();
if(reductionIncreasePercent) {
var newPrice = productPriceBase + productPriceBase * (reductionIncreasePercent / 100);
$('#productprice-price').val(parseFloat(newPrice).toFixed(5));
opendistrib_product_prices_event_price_with_tax();
}
}


Загрузка…
Отмена
Сохранить