Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit de2c041f erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: #78

Übergeordneter 840cb232
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -530,6 +530,36 @@ define('package/quiqqer/erp/bin/backend/controls/articles/ArticleList', [
this.$priceFactors.splice(prio, 0, priceFactor);
},
/**
* edit a price factor
*
* {
* calculation : 2,
* calculation_basis: 2,
* description : Form.elements.title.value,
* identifier : "",
* index : priority,
* nettoSum : data.nettoSum,
* nettoSumFormatted: data.nettoSumFormatted,
* sum : data.sum,
* sumFormatted : data.sumFormatted,
* title : Form.elements.title.value,
* value : data.sum,
* valueText : data.sumFormatted,
* vat : Form.elements.vat.value,
* visible : 1
* }
*
* @param index
* @param priceFactor
*/
editPriceFactor: function (index, priceFactor) {
for (let k in priceFactor) {
this.$priceFactors[index][k] = priceFactor[k];
}
},
/**
* Return the articles count
*
......
......@@ -21,7 +21,7 @@ define('package/quiqqer/erp/bin/backend/controls/articles/BruttoCalcButton', [
],
options: {
Price: null
Price: null // input element for the price
},
initialize: function (options) {
......
......@@ -2,4 +2,12 @@
font-weight: bold;
font-size: 10px;
margin-right: 5px;
}
\ No newline at end of file
}
.quiqqer-erp-priceFactors-factor button {
border-color: rgba(147, 128, 108, 0.25);
border-style: solid;
border-width: 1px 1px 1px 0;
border-radius: 0;
box-shadow: none;
}
......@@ -13,7 +13,7 @@
{{#priceFactors}}
<tr data-index="{{index}}">
<td>
<div class="field-container">
<div class="field-container quiqqer-erp-priceFactors-factor">
<label style="width: 100%; display: flex;">
<span class="field-container-item">
<span class="pricefactor-index">#{{priority}}</span>
......@@ -21,6 +21,9 @@
</span>
<span class="field-container-field">{{valueText}}</span>
</label>
<button class="qui-button edit" style="width: 50px; cursor: pointer;">
<span class="fa fa-edit"></span>
</button>
<button class="qui-button delete" style="width: 50px; cursor: pointer;">
<span class="fa fa-close"></span>
</button>
......
......@@ -122,6 +122,13 @@ define('package/quiqqer/erp/bin/backend/controls/articles/windows/PriceFactors',
this.refresh();
});
Content.getElements('.edit').addEvent('click', (e) => {
e.stop();
let index = e.target.getParent('tr').get('data-index');
this.editPriceFactor(index);
});
PriceFactorButton.addEvent('click', (e) => {
e.stop();
this.addPriceFactor();
......@@ -248,6 +255,131 @@ define('package/quiqqer/erp/bin/backend/controls/articles/windows/PriceFactors',
}).open();
},
/**
* edit a price factor window
*/
editPriceFactor: function (index) {
const ArticleList = this.getAttribute('ArticleList');
let priceFactors = ArticleList.getPriceFactors();
let calculations = ArticleList.getCalculation();
if (!priceFactors.length) {
return;
}
if (typeof calculations.vatArray === 'undefined') {
calculations.vatArray = {};
}
const factor = priceFactors[index];
new QUIConfirm({
icon : 'fa fa-edit',
title : QUILocale.get(lg, 'pricefactors.edit.window.title'),
maxHeight: 400,
maxWidth : 580,
autoclose: false,
events : {
onOpen: (Win) => {
const Content = Win.getContent();
Win.Loader.show();
Content.set({
html: Mustache.render(templateAdd, {
titlePrice : QUILocale.get(lg, 'title.price'),
titleTitle : QUILocale.get(lg, 'title.title'),
titlePriority: QUILocale.get(lg, 'title.priority'),
titleVat : QUILocale.get(lg, 'title.vat'),
calculationBasis : QUILocale.get(lg, 'calculationBasis'),
calculationBasisNetto : QUILocale.get(lg, 'calculationBasis.netto'),
calculationBasisCalcPrice : QUILocale.get(lg, 'calculationBasis.calculationBasisCalcPrice'),
calculationBasisCalcBrutto: QUILocale.get(lg, 'calculationBasis.calculationBasisCalcBrutto'),
})
});
require([
'package/quiqqer/erp/bin/backend/controls/articles/BruttoCalcButton'
], (Calc) => {
new Calc({
Price: Content.getElement('[name="price"]')
}).inject(
Content.getElement('[name="price"]'),
'after'
);
Content.getElement('[name="priority"]')
.set('value', ArticleList.countPriceFactors() + 1);
// vat
const VatSelect = Content.getElement('[name="vat"]');
for (let vat in calculations.calculations.vatArray) {
new Element('option', {
html : vat + '%',
value: vat
}).inject(VatSelect);
}
const Form = Content.getElement('form');
Form.elements.price.value = factor.nettoSum;
Form.elements.title.value = factor.title;
Form.elements.vat.value = factor.vat;
Form.elements.priority.value = factor.priority;
Win.Loader.hide();
});
},
onSubmit: (Win) => {
const Form = Win.getContent().getElement('form');
const price = Form.elements.price.value;
const currency = ArticleList.getAttribute('currency');
if (!price || price === '') {
return;
}
Win.Loader.show();
this.getPriceFactorData(
price,
Form.elements.vat.value,
currency
).then((data) => {
let priority = Form.elements.priority.value;
if (priority === '') {
priority = 1;
}
ArticleList.editPriceFactor(index, {
calculation : 2,
calculation_basis: 2,
description : Form.elements.title.value,
identifier : "",
index : priority - 1,
nettoSum : data.nettoSum,
nettoSumFormatted: data.nettoSumFormatted,
sum : data.sum,
sumFormatted : data.sumFormatted,
title : Form.elements.title.value,
value : data.sum,
valueText : data.valueText,
vat : Form.elements.vat.value,
visible : 1
});
Win.close();
this.refresh();
});
}
}
}).open();
},
/**
* returns the current currency formatter of the article list
*
......
......@@ -1300,6 +1300,11 @@ Allowed characters: Letters, numbers and _ ä ö ü ß]]></en>
<en><![CDATA[Edit pricefactors]]></en>
</locale>
<locale name="pricefactors.edit.window.title">
<de><![CDATA[Preisfaktor bearbeiten]]></de>
<en><![CDATA[Edit pricefactor]]></en>
</locale>
<locale name="controls.QuantityUnitWindow.title">
<de><![CDATA[Mengeneinheit]]></de>
<en><![CDATA[Quantity unit]]></en>
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren