214 lines
5.2 KiB
JavaScript
Executable File
214 lines
5.2 KiB
JavaScript
Executable File
|
|
function addEvent(object, eventName, do_function) {
|
|
if (typeof (object) == "string") object = document.getElementById(object);
|
|
if (!object) { alert('No object in function addEvent!'); return; }
|
|
if (object.addEventListener) {
|
|
object.addEventListener(eventName, do_function, false);
|
|
} else {
|
|
object.attachEvent('on' + eventName, do_function);
|
|
}
|
|
}
|
|
|
|
function findPos(obj) {
|
|
var nleft = 0;
|
|
var ntop = 0;
|
|
if (obj.offsetParent) {
|
|
nleft = obj.offsetLeft
|
|
ntop = obj.offsetTop
|
|
while (obj = obj.offsetParent) {
|
|
nleft += obj.offsetLeft
|
|
ntop += obj.offsetTop
|
|
}
|
|
}
|
|
return [nleft, ntop];
|
|
}
|
|
|
|
function cursorEOT(isField) {
|
|
isRange = isField.createTextRange();
|
|
isRange.move('textedit');
|
|
isRange.select();
|
|
testOverflow = isField.scrollTop;
|
|
if (testOverflow != 0) { return true }
|
|
else { return false }
|
|
}
|
|
|
|
function adjustRows(isField) {
|
|
while (cursorEOT(isField)) { isField.rows++ }
|
|
}
|
|
|
|
function insertText(isField, isText) {
|
|
isField.value = testText;
|
|
isField.focus();
|
|
}
|
|
|
|
var ERROR = false;
|
|
|
|
var ItemListSave = function (json) { }
|
|
|
|
|
|
function ItemListClear() {
|
|
while (N.rowCount() > 0) N.row(0).deleteRow();
|
|
}
|
|
|
|
|
|
|
|
var AjaxSearchProducts;
|
|
|
|
var parentFL;
|
|
var productFL;
|
|
var contactFL;
|
|
|
|
addEvent(
|
|
window,
|
|
'load',
|
|
function () {
|
|
|
|
/*
|
|
N.onCreateCell = function (cell) {
|
|
|
|
var i = cell.index;
|
|
cell.change = function (select) { };
|
|
cell.style.height = OPT['row_item_height'];
|
|
cell.noSelect = true;
|
|
|
|
if (i == 0) {
|
|
|
|
cell.setData = function (data) {
|
|
if (data.index) cell.firstChild.value = data.index;
|
|
};
|
|
cell.getData = function (data) {
|
|
data.index = cell.firstChild.value;
|
|
}
|
|
cell.select = function () { this.selectNext(); }
|
|
|
|
var edit = document.createElement('input');
|
|
edit.setAttribute('type', 'text');
|
|
edit.setAttribute('readOnly', 'readonly');
|
|
edit.setAttribute('tabIndex', 1);
|
|
edit.className = 'inputs';
|
|
cell.appendChild(edit);
|
|
}
|
|
|
|
if (i == 1) {
|
|
|
|
cell.getData = function (data) {
|
|
|
|
var cn = this.getElementsByTagName('input');
|
|
|
|
data.code = cn[0].value;
|
|
|
|
data.id = cn[1].value;
|
|
|
|
data.unit_id = cn[2].value;
|
|
|
|
data.vat_id = cn[3].value;
|
|
|
|
data.category_id = cn[4].value;
|
|
|
|
}
|
|
|
|
cell.setData = function (data) {
|
|
|
|
var cn = this.getElementsByTagName('input');
|
|
|
|
if (data.code) cn[0].value = data.code;
|
|
|
|
if (data.id) cn[1].value = data.id;
|
|
|
|
if (data.unit_id) cn[2].value = data.unit_id;
|
|
|
|
if (data.vat_id) cn[3].value = data.vat_id;
|
|
|
|
if (data.category_id) cn[4].value = data.category_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" autocomplete="off" >';
|
|
|
|
cell.innerHTML = edit;
|
|
|
|
cell.align = 'right';
|
|
|
|
var id = document.createElement('input');
|
|
|
|
id.setAttribute('type', 'hidden');
|
|
|
|
cell.appendChild(id);
|
|
|
|
var unit_id = document.createElement('input');
|
|
|
|
unit_id.setAttribute('type', 'hidden');
|
|
|
|
unit_id.setAttribute('value', OPT['default_unit']);
|
|
|
|
cell.appendChild(unit_id);
|
|
|
|
var vat_id = document.createElement('input');
|
|
|
|
vat_id.setAttribute('type', 'hidden');
|
|
|
|
vat_id.setAttribute('value', OPT['default_vat']);
|
|
|
|
cell.appendChild(vat_id);
|
|
|
|
var category_id = document.createElement('input');
|
|
|
|
category_id.setAttribute('type', 'hidden');
|
|
|
|
category_id.setAttribute('value', OPT['default_category']);
|
|
|
|
cell.appendChild(category_id);
|
|
|
|
var img = document.createElement('img');
|
|
img.setAttribute('alt', MOD['LBL_IMG_SEARCH']);
|
|
img.setAttribute('src', 'modules/EcmQuotes/images/search.gif');
|
|
img.style.cursor = 'pointer';
|
|
img.onclick = function () {
|
|
window.open("index.php?module=EcmProducts&action=DetailView&record=" + cell.getElementsByTagName('input')[1].value);
|
|
};
|
|
cell.appendChild(img);
|
|
|
|
|
|
calculateTotal = function () {
|
|
|
|
var product_total = 0;
|
|
var work_total = 0;
|
|
var total = 0;
|
|
var red = false;
|
|
|
|
for (var i = 0; i < N.rowCount(); i++) {
|
|
var data = N.row(i).getData();
|
|
if (data.ems_price > 0) {
|
|
var t = data.quantity * data.ems_price;
|
|
if (data.category_id == 'd7f876b0-1a3d-43a1-7c9b-511ba40df3d1')
|
|
work_total += t;
|
|
else
|
|
product_total += t;
|
|
total += t;
|
|
}
|
|
else red = true;
|
|
}
|
|
|
|
|
|
document.getElementById('total_all').value = NumberToUserFormatNumber(total);
|
|
document.getElementById('total_products').value = NumberToUserFormatNumber(product_total);
|
|
document.getElementById('total_work').value = NumberToUserFormatNumber(work_total);
|
|
if (red) document.getElementById('subtotal').style.color = 'red';
|
|
|
|
}
|
|
|
|
|
|
calculateTotal();
|
|
|
|
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
);
|
|
|
|
|
|
|