Files
crm.e5.pl/modules/EcmProducts/javascript/ProductionSummary.js
2024-04-27 09:23:34 +02:00

77 lines
2.0 KiB
JavaScript

getProductionSummary = function() {
STABLE = new EcmJsTable(columns, $('#summaryTable'),
'DetailView');
//calculate summary
var comp = 0;
var act_n = 0;
var act_b = 0;
var total_n = 0;
var total_b = 0;
var components = CTABLE.getItems();
$.each(components, function(i, c) {
comp+=c.quantity*c.purchase_price;
});
var actions = ATABLE.getItems();
$.each(actions, function(i, a) {
act_n+=a.quantity*a.price_netto;
act_b+=a.quantity*a.price_brutto;
});
total_n = comp + act_n;
total_b = comp + act_b;
var items = new Array();
items[0] = new Array();
items[0]['name'] = 'Wartość komponentów';
items[0]['value'] = comp;
items[1] = new Array();
items[1]['name'] = 'Wartość czynności - netto';
items[1]['value'] = act_n
items[2] = new Array();
items[2]['name'] = 'Wartość czynności - brutto';
items[2]['value'] = act_b;
items[3] = new Array();
items[3]['name'] = 'Suma netto';
items[3]['value'] = total_n;
items[4] = new Array();
items[4]['name'] = 'Suma brutto';
items[4]['value'] = total_b;
STABLE.setItems(items);
STABLE.getHeaders();
STABLE.fillTable();
//hide table header
STABLE.container.find('#EcmJsItemsTable > thead').remove();
//set align right
STABLE.container.find('#itemsTableDIV').attr('align', 'right');
}
var columns = new Array();
//end: number
//begin: code
columns[0] = {
'name' : 'name',
'label' : '',
'width' : 50, // %
'content' : new Array(),
};
columns[0]['content'][0] = {
'name' : '',
'css' : {
'text-align' : 'left',
'background-color' : 'rgb(224,240,255)',
}
};
columns[1] = {
'name' : 'value',
'label' : '',
'width' : 50, // %
'content' : new Array(),
};
columns[1]['content'][0] = {
'name' : '',
'dataType' : 'number',
'precision' : 4,
'css' : {
'text-align' : 'right',
}
};