Add JS files
This commit is contained in:
882
modules/EcmFkVatTables/EcmFkVatRegisters.js
Executable file
882
modules/EcmFkVatTables/EcmFkVatRegisters.js
Executable file
@@ -0,0 +1,882 @@
|
||||
window.onbeforeunload = function() {
|
||||
//removeDocumentReservations(document.getElementById("temp_id").value);
|
||||
//saveDocumentReservations(document.getElementById("temp_id").value);
|
||||
//alert("Wprowadzone zmiany nie zosta<74>y zapisane");
|
||||
};
|
||||
function changer() {
|
||||
this.list = new Object();
|
||||
|
||||
this.add = function(object, type, do_function, start_value) {
|
||||
if (typeof(object) == "string") {
|
||||
object = document.getElementById(object);
|
||||
}
|
||||
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.list[object.id] = new Object();
|
||||
this.list[object.id].object = object;
|
||||
this.list[object.id].type = type;
|
||||
this.list[object.id].do_function = do_function;
|
||||
this.list[object.id].start_value = start_value;
|
||||
this.list[object.id].value = '';
|
||||
};
|
||||
|
||||
this.getValue = function(element) {
|
||||
var value = null;
|
||||
|
||||
if (element.object) {
|
||||
if (element.type == "innerHTML") {
|
||||
value = element.object.innerHTML;
|
||||
}
|
||||
|
||||
if (element.type == "value") {
|
||||
value = element.object.value;
|
||||
}
|
||||
|
||||
if (element.type == "checked") {
|
||||
value = element.object.checked;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
this.interval = 1000;
|
||||
|
||||
this.timer = null;
|
||||
|
||||
this.startTimer = function() {
|
||||
var cc = this;
|
||||
|
||||
this.timer = setInterval(
|
||||
function() {
|
||||
var list = cc.list;
|
||||
|
||||
for (x in list) {
|
||||
if (list[x].start_value) {
|
||||
list[x].value = cc.getValue(list[x]);
|
||||
list[x].start_value = false;
|
||||
} else {
|
||||
var value = cc.getValue(list[x]);
|
||||
|
||||
if (list[x].value !== value) {
|
||||
if (list[x].do_function) {
|
||||
list[x].do_function(list[x].object);
|
||||
}
|
||||
}
|
||||
|
||||
list[x].value = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
this.interval
|
||||
);
|
||||
};
|
||||
|
||||
this.stopTimer = function() {
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
};
|
||||
}
|
||||
|
||||
function BlockProducts() {
|
||||
return true;
|
||||
var tab = document.getElementById("tbody");
|
||||
var tr = tab.getElementsByTagName("tr");
|
||||
var qty;
|
||||
var total;
|
||||
|
||||
for (var i = 0; i < tr.length; i++) {
|
||||
var inp = tr[i].getElementsByTagName("input");
|
||||
var img = tr[i].getElementsByTagName("img");
|
||||
var tx = tr[i].getElementsByTagName("textarea");
|
||||
//console.log(inp);
|
||||
if (inp[2].value != '') {
|
||||
inp[1].setAttribute('readonly', 'readonly');
|
||||
inp[1].setAttribute('onkeydown', '');
|
||||
img[2].setAttribute('style', 'display:none');
|
||||
//img[1].setAttribute('style', 'display:none');
|
||||
}
|
||||
//if(inp[8].value==1)deleteEmptyComponents(inp[11].value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function saveDocumentReservations(temp_id, operation) {
|
||||
return true;
|
||||
url = 'index.php?module=EcmStockOperations&action=saveDocumentReservations&temp_doc_id=' + temp_id + '&to_pdf=1';
|
||||
|
||||
var req = mint.Request();
|
||||
|
||||
req.OnSuccess = function() {
|
||||
switch (operation)
|
||||
{
|
||||
case 'cancel':
|
||||
case 'list':
|
||||
default:
|
||||
//window.location = "index.php?module=EcmFkVatTables&action=index";
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
req.Send(url);
|
||||
}
|
||||
|
||||
function removeDocumentReservations(temp_id, operation) {
|
||||
return true;
|
||||
url = 'index.php?module=EcmStockOperations&action=deleteDocumentReservations&temp_doc_id=' + temp_id + '&to_pdf=1';
|
||||
|
||||
var req = mint.Request();
|
||||
|
||||
req.OnSuccess = function() {
|
||||
switch (operation)
|
||||
{
|
||||
case 'cancel':
|
||||
case 'list':
|
||||
default:
|
||||
window.location = "index.php?module=EcmFkVatTables&action=index";
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
req.Send(url);
|
||||
}
|
||||
|
||||
function getProductQuantity(rowIndex, operation) {
|
||||
return true;
|
||||
|
||||
//console.log('getProductQuantity');
|
||||
|
||||
var stock_id = document.getElementById("stock_id").value;
|
||||
var product_id = N.row(rowIndex).getData().id;
|
||||
|
||||
url = 'index.php?module=EcmStockStates&action=getProductQuantity&stock_id=' + stock_id + '&product_id=' + product_id + '&to_pdf=1';
|
||||
|
||||
//console.log(url);
|
||||
|
||||
var req = mint.Request();
|
||||
|
||||
req.OnSuccess = function() {
|
||||
//console.log("getProductQuantity:OnSuccess");
|
||||
//return;
|
||||
|
||||
var data = N.row(rowIndex).getData();
|
||||
|
||||
//console.log(data);
|
||||
|
||||
data.stock = this.responseText;
|
||||
|
||||
N.row(rowIndex).setData(data);
|
||||
|
||||
if (!data.reserved)
|
||||
data.reserved = 0;
|
||||
|
||||
if (operation == "saveReservation") {
|
||||
N.row(rowIndex).className = '';
|
||||
|
||||
saveReservation(rowIndex, false);
|
||||
|
||||
//console.log(data);
|
||||
|
||||
if (parseFloat(data.stock) >= data.rq) {
|
||||
N.row(rowIndex).addClass('greenRow');
|
||||
} else {
|
||||
N.row(rowIndex).addClass('redRow');
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
//console.log(data);
|
||||
|
||||
//N.row(rowIndex).className='';
|
||||
|
||||
//if qty = 0 do clear reserved field
|
||||
if (data.rq == 0) {
|
||||
N.row(rowIndex).setData();
|
||||
removeReservation(rowIndex);
|
||||
}
|
||||
|
||||
if (data.quantity >= data.rq)
|
||||
{
|
||||
/*
|
||||
saveReservation(rowIndex, false);
|
||||
return;
|
||||
*/
|
||||
|
||||
if (data.stock >= data.rq) {
|
||||
saveReservation(rowIndex, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((data.stock < data.rq) && (parseFloat(data.stock) + parseFloat(data.rq) > 0)) {
|
||||
console.log(data.stock);
|
||||
console.log(data.rq);
|
||||
|
||||
console.log(parseFloat(data.stock) + parseFloat(data.rq));
|
||||
|
||||
saveReservation(rowIndex, true, parseFloat(data.stock) + parseFloat(data.rq)); // orange row true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.quantity == 0) {
|
||||
data.reserved = 0;
|
||||
N.row(rowIndex).setData();
|
||||
removeReservation(rowIndex);
|
||||
setTimeout(function() {
|
||||
getProductQuantity(rowIndex);
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
//stock > qty - all OK, can reserve
|
||||
if (data.stock>=data.quantity-data.reserved) {
|
||||
saveReservation(rowIndex, false);
|
||||
return;
|
||||
}
|
||||
if ((data.stock<(data.quantity-data.reserved)) && (parseFloat(data.stock)+parseFloat(data.reserved)>0)) {
|
||||
saveReservation(rowIndex, true, parseFloat(data.stock)+parseFloat(data.reserved)); //orange row true;
|
||||
return;
|
||||
}
|
||||
//stock <= qty + res, sand reserve, do nothing
|
||||
if (data.stock<(data.quantity-data.reserved)) {
|
||||
N.row(rowIndex).className = 'redRow';
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
//if (data.stock < data.rq || data.quantity > data.rq) {
|
||||
N.row(rowIndex).addClass('redRow');//className = 'redRow';
|
||||
// return;
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
req.Send(url);
|
||||
}
|
||||
|
||||
function saveReservation(rowIndex, orangeRow, qty) {
|
||||
return true;
|
||||
//console.log('saveReservation');
|
||||
|
||||
var data = N.row(rowIndex).getData();
|
||||
|
||||
//console.log(data);
|
||||
|
||||
var product_id = data.id;
|
||||
var temp_item_id = data.temp_item_id;
|
||||
var quantity;
|
||||
|
||||
if (qty)
|
||||
quantity = qty;
|
||||
else
|
||||
quantity = data.rq;
|
||||
|
||||
var date = document.getElementById("temp_date").value;
|
||||
|
||||
var stock_id = document.getElementById("stock_id").value;
|
||||
|
||||
var temp_doc_id = document.getElementById("temp_id").value;
|
||||
|
||||
var url = 'index.php?module=EcmStockOperations&action=saveReservation&stock_id=' + stock_id + '&product_id=' + product_id + '&temp_doc_id=' + temp_doc_id + '&temp_item_id=' + temp_item_id + '&date=' + date + '&quantity=' + quantity + '&to_pdf=1';
|
||||
|
||||
//console.log(url);
|
||||
|
||||
var req = mint.Request();
|
||||
|
||||
req.OnSuccess = function() {
|
||||
//console.log("saveReservation:OnSuccess");
|
||||
|
||||
var data = N.row(rowIndex).getData();
|
||||
|
||||
data.reserved = quantity;
|
||||
|
||||
N.row(rowIndex).setData(data);
|
||||
|
||||
//N.row(rowIndex).cell(3).getElementById("reservation_info").innerHtml="("+data.reserved+")";
|
||||
|
||||
//N.row(rowIndex).cells.item(4).getElementsByTagName('input')[0].value = NumberToUserFormatNumber(data.reserved);
|
||||
|
||||
//cell(3).getElementById("reservation_info").innerHtml
|
||||
|
||||
if (orangeRow == true)
|
||||
N.row(rowIndex).addClass('orangeRow'); //.className = 'orangeRow';
|
||||
else
|
||||
N.row(rowIndex).addClass('greenRow'); //.className = 'greenRow';
|
||||
|
||||
getProductQuantity(rowIndex);
|
||||
}
|
||||
|
||||
req.Send(url);
|
||||
}
|
||||
|
||||
function removeReservation(index) {
|
||||
//Console.log('removeReservation');
|
||||
|
||||
var data = N.row(index).getData();
|
||||
var temp_item_id = data.temp_item_id;
|
||||
|
||||
url = 'index.php?module=EcmStockOperations&action=deleteReservation&temp_item_id=' + temp_item_id + '&to_pdf=1';
|
||||
|
||||
//console.log('removeReservation: ' + url);
|
||||
|
||||
var req = mint.Request();
|
||||
|
||||
req.OnSuccess = function() {
|
||||
//console.log('removeReservation OnSuccess');
|
||||
}
|
||||
|
||||
req.Send(url);
|
||||
}
|
||||
|
||||
function SetTabIndexs() {
|
||||
|
||||
|
||||
var main = document.getElementById("main");
|
||||
var td = main.getElementsByTagName("td");
|
||||
var selectedTable = null;
|
||||
//var selectingColor = "red";
|
||||
//var selectingCellTable = "green";
|
||||
var TableIndex = 0;
|
||||
for (var i = 0; i < td.length; i++) {
|
||||
if (td[i].className == "tabEditViewDF") {
|
||||
var TI = 0;
|
||||
if (td[i].parentNode.cells.item(1) == td[i])
|
||||
TI = 101 + TableIndex;
|
||||
else
|
||||
TI = 102 + TableIndex;
|
||||
|
||||
var nodes = td[i].getElementsByTagName("input");
|
||||
for (var j = 0; j < nodes.length; j++)
|
||||
nodes[j].tabIndex = TI;
|
||||
var nodes = td[i].getElementsByTagName("select");
|
||||
for (var j = 0; j < nodes.length; j++)
|
||||
nodes[j].tabIndex = TI;
|
||||
var nodes = td[i].getElementsByTagName("textarea");
|
||||
for (var j = 0; j < nodes.length; j++)
|
||||
nodes[j].tabIndex = TI;
|
||||
|
||||
if (td[i].parentNode.parentNode.parentNode !== selectedTable) {
|
||||
//if(selectingColor == "red") selectingColor = "blue"; else selectingColor = "red";
|
||||
selectedTable = td[i].parentNode.parentNode.parentNode;
|
||||
TableIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doRequest(where, post, doFunction, error) {
|
||||
this.Display = function(result) {
|
||||
doFunction(result.responseText);
|
||||
}
|
||||
|
||||
this.Fail = function(result) {
|
||||
if (error)
|
||||
alert(error);
|
||||
}
|
||||
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
"POST",
|
||||
where,
|
||||
{
|
||||
success: this.Display,
|
||||
failure: this.Fail
|
||||
},
|
||||
post
|
||||
);
|
||||
}
|
||||
|
||||
function changeValidateRequired(formname, name, required) {
|
||||
for (var i = 0; i < validate[formname].length; i++)
|
||||
if (validate[formname][i][0] == name) {
|
||||
validate[formname][i][2] = required;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function set_focus() {
|
||||
document.getElementById("name").focus();
|
||||
}
|
||||
|
||||
function my_popup(module, field_array, met, call_back_function, form_name) {
|
||||
if (!call_back_function) {
|
||||
call_back_function = "set_return";
|
||||
}
|
||||
|
||||
if (!form_name) {
|
||||
form_name = "EditView";
|
||||
}
|
||||
|
||||
return open_popup(
|
||||
module,
|
||||
900,
|
||||
700,
|
||||
met,
|
||||
true,
|
||||
false,
|
||||
{
|
||||
"call_back_function": call_back_function,
|
||||
"form_name": form_name,
|
||||
"field_to_name_array": field_array
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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) {
|
||||
return "";
|
||||
}
|
||||
var FkVatTableListSave = function(json) {
|
||||
return "";
|
||||
}
|
||||
var IncomeListSave = function(json) {
|
||||
return "";
|
||||
}
|
||||
|
||||
function ShowLoadingView() {
|
||||
var slv = document.getElementById("ShowLoadingView");
|
||||
if (!slv) {
|
||||
slv = document.createElement("div");
|
||||
slv.id = "ShowLoadingView";
|
||||
slv.className = "transparent_class_loading";
|
||||
slv.style.width = "100%";
|
||||
slv.style.height = "500%";
|
||||
|
||||
var sli = document.createElement("img");
|
||||
sli.className = "transparent_class_loading_image";
|
||||
sli.src = "themes/default/images/loading.gif";
|
||||
slv.appendChild(sli);
|
||||
|
||||
document.body.appendChild(slv);
|
||||
}
|
||||
slv.style.display = "";
|
||||
}
|
||||
|
||||
function HideLoadingView() {
|
||||
var slv = document.getElementById("ShowLoadingView");
|
||||
if (slv)
|
||||
slv.style.display = "none";
|
||||
}
|
||||
|
||||
function ItemsList(json) {
|
||||
var data = '';
|
||||
for(var i=0; i<N.rowCount(); i++) {
|
||||
data = data + '||||' + JSON.stringifyNoSecurity(N.row(i).getData());
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function saveItems() {
|
||||
document.getElementById("decree_list").value = ItemsList(true);
|
||||
}
|
||||
|
||||
function saveFkVatTables() {
|
||||
document.getElementById("fkvattables_list").value = FkVatTablesList(true);
|
||||
}
|
||||
|
||||
function checkStockQuantity() {
|
||||
var tab = document.getElementById("tbody");
|
||||
var tr = tab.getElementsByTagName("tr");
|
||||
var qtyinstock;
|
||||
var qty;
|
||||
var total;
|
||||
for (var i = 0; i < tr.length; i++) {
|
||||
|
||||
qtyinstock = tr[i].getElementsByTagName("input")[18].value;
|
||||
qty = tr[i].getElementsByTagName("input")[17].value;
|
||||
total = parseFloat(qtyinstock) - parseFloat(qty);
|
||||
if (tr[i].getElementsByTagName("input")[17].checked == true && tr[i].getElementsByTagName("input")[2].value && parseInt(qtyinstock) - parseInt(qty) < 0) {
|
||||
alert("Brakuje produkt<6B>w na magazynie aby zrobic rezerwacje");
|
||||
tr[i].getElementsByTagName("input")[17].value = parseInt(qtyinstock);
|
||||
if (tr[i].getElementsByTagName("input")[9].value < tr[i].getElementsByTagName("input")[18].value) {
|
||||
tr[i].getElementsByTagName("input")[18].value = parseInt(tr[i].getElementsByTagName("input")[9].value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function removeHistoryRecord(id) {
|
||||
var historyElement = document.forms.EditView.history;
|
||||
|
||||
var historyValue = JSON.parse(historyElement.value);
|
||||
|
||||
|
||||
historyValue[id] = null;
|
||||
|
||||
//console.log(historyElement.value);
|
||||
//console.log('Length: ' + historyValue.length);
|
||||
|
||||
historyElement.value = JSON.stringifyNoSecurity(historyValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function removeHistory(a) {
|
||||
var paretLi = a.parentNode.parentNode;
|
||||
|
||||
var idParts = paretLi.id.split('_');
|
||||
|
||||
if (idParts[1] >= 0) {
|
||||
removeHistoryRecord(idParts[1]);
|
||||
//paretLi.removeChild(idParts[1]);
|
||||
paretLi.style.display = 'none';
|
||||
}
|
||||
|
||||
//console.log(paretLi.parentNode.children );
|
||||
|
||||
// Hide no-results item if needed.
|
||||
if (paretLi.parentNode.children.length == 0) {
|
||||
//
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function addHistoryRecord(date, owner, record) {
|
||||
var historyRecord = [
|
||||
date,
|
||||
owner,
|
||||
record
|
||||
];
|
||||
|
||||
var historyElement = document.forms.EditView.history;
|
||||
|
||||
var historyValue = JSON.parse(historyElement.value);
|
||||
historyValue.unshift(historyRecord);
|
||||
|
||||
historyElement.value = JSON.stringifyNoSecurity(historyValue);
|
||||
|
||||
// Bof: Build list item.
|
||||
{
|
||||
var recordLi = document.createElement('li');
|
||||
|
||||
var dateP = document.createElement('p');
|
||||
dateP.appendChild(document.createTextNode(date));
|
||||
dateP.appendChild(document.createTextNode(', '));
|
||||
dateP.appendChild(document.createTextNode(owner));
|
||||
dateP.appendChild(document.createTextNode(':'));
|
||||
|
||||
//var ownerP = document.createElement('p');
|
||||
//ownerP.appendChild(document.createTextNode(owner));
|
||||
|
||||
var recordP = document.createElement('p');
|
||||
recordP.appendChild(document.createTextNode(record));
|
||||
|
||||
recordLi.appendChild(dateP);
|
||||
//recordLi.appendChild(ownerP)
|
||||
recordLi.appendChild(recordP);
|
||||
}
|
||||
// Eof: Build list item.
|
||||
|
||||
// Prepend new history record.
|
||||
var wrapperList = document.getElementById('history_wrapper').children[0];
|
||||
|
||||
// Hide no-results item if needed.
|
||||
if (wrapperList.children.length == 1 && wrapperList.children[0].getAttribute('class') == 'no-results') {
|
||||
wrapperList.children[0].style.display = 'none';
|
||||
}
|
||||
|
||||
wrapperList.insertBefore(recordLi, wrapperList.firstChild);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function addHistory() {
|
||||
// Grab important form fields.
|
||||
var owner = document.forms.EditView.history_owner;
|
||||
var date = document.forms.EditView.history_date;
|
||||
var record = document.forms.EditView.history_record;
|
||||
|
||||
// Check values.
|
||||
if (owner.value.length == 0 || date.value.length == 0 || record.value.length == 0) {
|
||||
alert('Wype<70>nij wszystkie pola.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create row, update hidden history value.
|
||||
addHistoryRecord(date.value, owner.value, record.value);
|
||||
|
||||
var date = new Date();
|
||||
|
||||
// Reset form.
|
||||
owner.value = '';
|
||||
date.value = date.toString('d.m.Y');
|
||||
record.value = '';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SaveForm() {
|
||||
ShowLoadingView();
|
||||
|
||||
setTimeout(function() {
|
||||
if (OPT["checkbox_demo"] == 1 && document.forms.EditView.record.value == "") {
|
||||
alert(MOD.LBL_DEMO_VERSION_INFORMATION);
|
||||
return;
|
||||
}
|
||||
|
||||
ERROR = false;
|
||||
|
||||
//document.getElementById("position_list").value = ItemListSave(true);
|
||||
if (ERROR) {
|
||||
alert(MOD["LBL_SAVE_FORM_ERROR"]);
|
||||
HideLoadingView();
|
||||
return false;
|
||||
}
|
||||
|
||||
document.forms.EditView.action.value = "Save";
|
||||
|
||||
if (check_form("EditView")) {
|
||||
//var result = confirm(MOD.LBL_CONFIRM_QUESTION);
|
||||
//if(result) document.forms.EditView.status.value = (OPT["auto_commiting"]?"s30":"s20");
|
||||
|
||||
doRequest(
|
||||
"index.php",
|
||||
getFormPost("Save"),
|
||||
function(result) {
|
||||
/*
|
||||
console.log(result);
|
||||
HideLoadingView();
|
||||
return;
|
||||
*/
|
||||
|
||||
document.forms.EditView.record.value = result.substring(result.length - 36);
|
||||
|
||||
if (OPT["setEmailTab"])
|
||||
setEMAIL(true);
|
||||
else
|
||||
window.location = "index.php?module=" + document.forms.EditView.module.value + "&action=DetailView&record=" + document.forms.EditView.record.value;
|
||||
},
|
||||
MOD["LBL_NOT_SAVED"]
|
||||
);
|
||||
} else {
|
||||
alert(MOD["LBL_NOT_SAVED"]);
|
||||
HideLoadingView();
|
||||
return false;
|
||||
}
|
||||
|
||||
},
|
||||
200);
|
||||
}
|
||||
|
||||
function ItemListClear() {
|
||||
while (N.rowCount() > 0)
|
||||
N.row(0).deleteRow();
|
||||
}
|
||||
|
||||
function getFormPost(action) {
|
||||
if (!action)
|
||||
action = "previewPDF";
|
||||
|
||||
var pd =
|
||||
"to_pdf=1" +
|
||||
"&module=EcmFkVatTables&action=" +
|
||||
action +
|
||||
"&record=" +
|
||||
document.forms.EditView.record.value;
|
||||
|
||||
pd += "&cache=fromJava" + ItemListSave(true) + FkVatTableListSave(true) + IncomeListSave(true);
|
||||
// pd += '&history=' + document.forms.EditView.history.value;
|
||||
|
||||
var pd2 = new Object();
|
||||
|
||||
pd2["module"] = "EcmFkVatTables";
|
||||
pd2["action"] = action;
|
||||
pd2["record"] = document.forms.EditView.record.value;
|
||||
pd2["to_pdf"] = "1";
|
||||
pd2["cache"] = "fromJava";
|
||||
|
||||
//pd2['history'] = document.forms.EditView.history.value;
|
||||
|
||||
// document.forms.EditView.position_list.value = "";
|
||||
document.forms["EditView"].action.value = action;
|
||||
|
||||
var tmp;
|
||||
|
||||
for (var i = 0; i < document.forms["EditView"].elements.length; i++) {
|
||||
tmp = document.forms["EditView"].elements[i];
|
||||
if (tmp.name != "") {
|
||||
if (tmp.type == "checkbox")
|
||||
pd2[document.forms["EditView"].elements[i].name] = (document.forms["EditView"].elements[i].checked ? "1" : "0");
|
||||
else
|
||||
pd2[document.forms["EditView"].elements[i].name] = document.forms["EditView"].elements[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
pd += "&otherFormData=" + JSON.stringifyNoSecurity(pd2);
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
||||
function sendFormPostToPdf(type, panel) {
|
||||
var tab = '_';
|
||||
|
||||
if (type != null) {
|
||||
tab += type.toUpperCase();
|
||||
}
|
||||
|
||||
ERROR = false;
|
||||
|
||||
document.getElementById("position_list").value = ItemListSave(true);
|
||||
document.getElementById("fkvattables_list").value = FkVatTableListSave(true);
|
||||
document.getElementById("income_list").value = IncomeListSave(true);
|
||||
|
||||
if (ERROR) {
|
||||
alert("There are some errors on list");
|
||||
return false;
|
||||
}
|
||||
|
||||
doRequest(
|
||||
"index.php",
|
||||
getFormPost("previewPDF"),
|
||||
function(result) {
|
||||
//console.log(result);
|
||||
//return;
|
||||
|
||||
if (SHOW_PDF_IN_DIV == 1) {
|
||||
HideLoadingView();
|
||||
|
||||
EcmPreviewPDF(
|
||||
"index.php?module=EcmFkVatTables&action=previewPDF&to_pdf=1&from=EcmFkVats&type=" + type,
|
||||
{
|
||||
zoom: 75
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
||||
SetTab((panel ? "panel_" : "") + "PREVIEW" + tab);
|
||||
|
||||
document.getElementById("previewPDF" + tab).innerHTML = '<iframe style="border: none; width: 100%; height: 1200px;" frameborder="no" src="index.php?module=EcmFkVatTables&action=previewPDF&to_pdf=1&from=EcmFkVats&type=' + type + '#zoom=75">Yours browser not accept iframes!</iframe>';
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
preview_pdf = function() {
|
||||
var type = document.getElementById('preview_type').value;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
type = 'income';
|
||||
case 'fault':
|
||||
case 'income':
|
||||
case 'qty':
|
||||
case 'val':
|
||||
case 'warranty':
|
||||
break;
|
||||
}
|
||||
|
||||
doRequest(
|
||||
"index.php",
|
||||
getFormPost("previewPDF"),
|
||||
function(result) {
|
||||
//console.log(result);
|
||||
//return;
|
||||
|
||||
if (SHOW_PDF_IN_DIV == 1) {
|
||||
HideLoadingView();
|
||||
|
||||
EcmPreviewPDF(
|
||||
"index.php?module=EcmFkVatTables&action=previewPDF&to_pdf=1&from=EcmFkVats&type=" + type,
|
||||
{
|
||||
zoom: 75
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
document.getElementById("previewPDF").innerHTML = '<iframe style="border: none; width: 100%; height: 1200px;" frameborder="no" src="index.php?module=EcmFkVatTables&action=previewPDF&to_pdf=1&from=EcmFkVats&type=' + type + '#zoom=75">Yours browser not accept iframes!</iframe>';
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//document.getElementById('previewPDF').innerHTML = '<iframe style="border:none;width:100%;height:1200px;" frameborder="no" src="index.php?module=EcmFkVatTables&action=previewPDF&type=' + type + '&to_pdf=1&method=I&record=' + document.forms.DetailView.record.value + '#zoom=75">Yours browser not accept iframes!</iframe>';
|
||||
}
|
||||
|
||||
function canConfirm() {
|
||||
if (document.forms.EditView.status.value == "accepted" && !OPT.user.confirm_quotes) {
|
||||
alert("This option is disabled for You.");
|
||||
document.forms.EditView.status.value = ((OPT.old_status) ? OPT.old_status : "");
|
||||
}
|
||||
OPT.old_status = document.forms.EditView.status.value;
|
||||
}
|
||||
|
||||
function CheckDiscount(noAlert) {
|
||||
var discount = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
var AjaxSearch1Items;
|
||||
var AjaxSearch2Items;
|
||||
var AjaxSearch3Items;
|
||||
|
||||
var parentFL;
|
||||
var productFL;
|
||||
var contactFL;
|
||||
1079
modules/EcmFkVatTables/EcmFkVatRegistersDetailView.js
Executable file
1079
modules/EcmFkVatTables/EcmFkVatRegistersDetailView.js
Executable file
File diff suppressed because it is too large
Load Diff
1077
modules/EcmFkVatTables/EcmFkVatRegistersEditView.js
Executable file
1077
modules/EcmFkVatTables/EcmFkVatRegistersEditView.js
Executable file
File diff suppressed because it is too large
Load Diff
2434
modules/EcmFkVatTables/MyTable.js
Executable file
2434
modules/EcmFkVatTables/MyTable.js
Executable file
File diff suppressed because it is too large
Load Diff
818
modules/EcmFkVatTables/_EcmFkVatRegistersEditView.js
Executable file
818
modules/EcmFkVatTables/_EcmFkVatRegistersEditView.js
Executable file
@@ -0,0 +1,818 @@
|
||||
function changer() {
|
||||
this.list = new Object();
|
||||
|
||||
this.add = function(object, type, do_function, start_value) {
|
||||
if (typeof(object) == "string") {
|
||||
object = document.getElementById(object);
|
||||
}
|
||||
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.list[object.id] = new Object();
|
||||
this.list[object.id].object = object;
|
||||
this.list[object.id].type = type;
|
||||
this.list[object.id].do_function = do_function;
|
||||
this.list[object.id].start_value = start_value;
|
||||
this.list[object.id].value = '';
|
||||
};
|
||||
|
||||
this.getValue = function(element) {
|
||||
var value = null;
|
||||
|
||||
if (element.object) {
|
||||
if (element.type == "innerHTML") {
|
||||
value = element.object.innerHTML;
|
||||
}
|
||||
|
||||
if (element.type == "value") {
|
||||
value = element.object.value;
|
||||
}
|
||||
|
||||
if (element.type == "checked") {
|
||||
value = element.object.checked;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
this.interval = 1000;
|
||||
|
||||
this.timer = null;
|
||||
|
||||
this.startTimer = function() {
|
||||
var cc = this;
|
||||
|
||||
this.timer = setInterval(
|
||||
function() {
|
||||
var list = cc.list;
|
||||
|
||||
for (x in list) {
|
||||
if (list[x].start_value) {
|
||||
list[x].value = cc.getValue(list[x]);
|
||||
list[x].start_value = false;
|
||||
} else {
|
||||
var value = cc.getValue(list[x]);
|
||||
|
||||
if (list[x].value !== value) {
|
||||
if (list[x].do_function) {
|
||||
list[x].do_function(list[x].object);
|
||||
}
|
||||
}
|
||||
|
||||
list[x].value = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
this.interval
|
||||
);
|
||||
};
|
||||
|
||||
this.stopTimer = function() {
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
};
|
||||
}
|
||||
|
||||
/* Decree */
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
var CHANGER = new changer();
|
||||
CHANGER.interval = 500;
|
||||
|
||||
CHANGER.add(
|
||||
'account_acc_wn',
|
||||
'checked',
|
||||
function(obj) {
|
||||
if (true == obj.checked) {
|
||||
document.getElementById('acc_wn').disabled = true;
|
||||
document.getElementById('acc_wn_code').disabled = true
|
||||
|
||||
document.getElementById('btn_acc_wn_code').disabled = true
|
||||
document.getElementById('btn_clr_acc_wn_code').disabled = true
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
document.getElementById('acc_wn').disabled = false;
|
||||
document.getElementById('acc_wn_code').disabled = false;
|
||||
|
||||
document.getElementById('btn_acc_wn_code').disabled = false;
|
||||
document.getElementById('btn_clr_acc_wn_code').disabled = false;
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
CHANGER.add(
|
||||
'account_acc_ma',
|
||||
'checked',
|
||||
function(obj) {
|
||||
if (true == obj.checked) {
|
||||
document.getElementById('acc_ma').disabled = true;
|
||||
document.getElementById('acc_ma_code').disabled = true
|
||||
|
||||
document.getElementById('btn_acc_ma_code').disabled = true
|
||||
document.getElementById('btn_clr_acc_ma_code').disabled = true
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
document.getElementById('acc_ma').disabled = false;
|
||||
document.getElementById('acc_ma_code').disabled = false;
|
||||
|
||||
document.getElementById('btn_acc_ma_code').disabled = false;
|
||||
document.getElementById('btn_clr_acc_ma_code').disabled = false;
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
// set_focus();
|
||||
|
||||
//initialize table
|
||||
N = new MyTable('decreeTable');
|
||||
N.divParent = document.getElementById('decreeTableDIV');
|
||||
|
||||
var from_popup_return = false;
|
||||
|
||||
function returnedData(popup_reply_data) {
|
||||
from_popup_return = true;
|
||||
|
||||
var form_name = popup_reply_data.form_name;
|
||||
var name_to_value_array = popup_reply_data.name_to_value_array;
|
||||
|
||||
for (var the_key in name_to_value_array) {
|
||||
if (the_key == 'toJSON') {
|
||||
//
|
||||
}
|
||||
else {
|
||||
var displayValue = name_to_value_array[the_key].replace(/&/gi, '&').replace(/</gi, '<').replace(/>/gi, '>').replace(/'/gi, '\'').replace(/"/gi, '"');
|
||||
|
||||
var e = document.getElementById(the_key);
|
||||
|
||||
if (e) {
|
||||
e.value = displayValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if(N.selectedRow)
|
||||
// N.selectedRow.calculateTotal();
|
||||
}
|
||||
|
||||
N.onRefreshRowIndex = function(row) {
|
||||
return true;
|
||||
|
||||
var data = new Object();
|
||||
data['index'] = (row.index + 1).toString();
|
||||
|
||||
row.cells.item(0).setData(data);
|
||||
};
|
||||
|
||||
N.onCreateRow = function(row) {
|
||||
console.log(row);
|
||||
|
||||
row.newPos = false;
|
||||
row.style.height = OPT['row_item_height'];
|
||||
|
||||
row.ondblclick = function() {
|
||||
this.newPos = !this.newPos;
|
||||
|
||||
for (var i = 0; i < this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).change(!this.newPos);
|
||||
}
|
||||
};
|
||||
|
||||
row.onSelect = function() {
|
||||
for (var i = 0; i < this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).style.height = OPT['row_item_height_selected'];
|
||||
this.cells.item(i).change(!this.newPos);
|
||||
}
|
||||
};
|
||||
|
||||
row.onDeselect = function() {
|
||||
for (var i = 0; i < this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).style.height = OPT['row_item_height'];
|
||||
this.cells.item(i).change(false);
|
||||
}
|
||||
};
|
||||
|
||||
row.calculateTotal = function() {
|
||||
console.log('calculateTotal');
|
||||
return true;
|
||||
|
||||
var data = new Object();
|
||||
|
||||
this.cells.item(3).getData(data, true);
|
||||
this.cells.item(5).getData(data, true);
|
||||
this.cells.item(6).getData(data, true);
|
||||
|
||||
if (data.quantity && data.price) {
|
||||
data.price2 = data.price - data.price * data.discount / 100;
|
||||
data.total = data.quantity * data.price2;
|
||||
}
|
||||
else {
|
||||
data.total = 0;
|
||||
data.price2 = 0;
|
||||
}
|
||||
|
||||
this.cells.item(7).setData(data);
|
||||
this.cells.item(10).setData(data);
|
||||
|
||||
calculateTotalItems();
|
||||
};
|
||||
};
|
||||
|
||||
var itd = document.getElementById('decreeTableDIV');
|
||||
|
||||
itd.onscroll = function() {
|
||||
console.log('onscroll');
|
||||
return true;
|
||||
|
||||
if (!AjaxSearch1Items.AjaxSearchFrozen)
|
||||
if (N.selectedCell && N.selectedCell.LeftPosition && N.selectedCell.TopPosition) {
|
||||
var top = N.selectedCell.TopPosition + N.selectedCell.offsetHeight;
|
||||
|
||||
if (((N.selectedCell.offsetTop + N.selectedCell.offsetHeight - this.scrollTop) > (this.offsetHeight + 5)) || ((N.selectedCell.offsetTop - this.scrollTop) < (-10)))
|
||||
AjaxSearch1Items.div.style.display = 'none';
|
||||
else
|
||||
AjaxSearch1Items.div.style.display = '';
|
||||
|
||||
AjaxSearch1Items.div.style.top = top - this.scrollTop;
|
||||
}
|
||||
};
|
||||
|
||||
N.onCreateCell = function(cell) {
|
||||
console.log(cell);
|
||||
|
||||
var i = cell.index;
|
||||
|
||||
cell.change = function(select) {
|
||||
//
|
||||
};
|
||||
|
||||
cell.style.height = OPT['row_item_height'];
|
||||
|
||||
// cell.onDeselect = function() {
|
||||
// var data = this.parentNode.getData();
|
||||
|
||||
// if (!data.id || data.id == '') {
|
||||
// var data2 = new Object();
|
||||
// this.parentNode.setData(data2);
|
||||
// }
|
||||
// };
|
||||
|
||||
// Position.
|
||||
if (i == 0) {
|
||||
cell.select = function() {
|
||||
// this.selectNext();
|
||||
};
|
||||
|
||||
cell.getData = function(data) {
|
||||
data.index = cell.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
if (data.index) {
|
||||
cell.firstChild.value = data.index;
|
||||
}
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type', 'text');
|
||||
edit.setAttribute('readOnly', 'readonly');
|
||||
edit.setAttribute('tabIndex', 1);
|
||||
edit.className = 'inputs';
|
||||
|
||||
cell.appendChild(edit);
|
||||
}
|
||||
|
||||
// Name.
|
||||
if (i == 1) {
|
||||
cell.getData = function(data) {
|
||||
data.vr_name = this.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
this.firstChild.value = data.vr_name;
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type', 'text');
|
||||
// edit.setAttribute('readOnly', 'readonly');
|
||||
edit.setAttribute('tabIndex', 1);
|
||||
edit.className = 'inputs';
|
||||
|
||||
cell.appendChild(edit);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_IMG_SEARCH']);
|
||||
img.setAttribute('src', 'modules/EcmInvoiceOuts/images/search.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
try {
|
||||
// this.parentNode.select();
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
|
||||
this.parentNode.ajax_search = false;
|
||||
|
||||
var ecmpopup = my_popup(
|
||||
'EcmFkVatRegs',
|
||||
{
|
||||
id: 'id_p',
|
||||
name: 'name_p',
|
||||
position: 'position_p',
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
ecmpopup.focus();
|
||||
},
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
// Search image button.
|
||||
// cell.appendChild(img);
|
||||
}
|
||||
|
||||
// Wn.
|
||||
if (i == 2) {
|
||||
cell.getData = function(data) {
|
||||
data.acc_wn_code = this.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
this.firstChild.value = data.acc_wn_code;
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type', 'text');
|
||||
// edit.setAttribute('readOnly', 'readonly');
|
||||
edit.setAttribute('tabIndex', 1);
|
||||
edit.className = 'inputs';
|
||||
|
||||
cell.appendChild(edit);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_IMG_SEARCH']);
|
||||
img.setAttribute('src', 'modules/EcmInvoiceOuts/images/search.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
try {
|
||||
// this.parentNode.select();
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
|
||||
this.parentNode.ajax_search = false;
|
||||
|
||||
var ecmpopup = my_popup(
|
||||
'EcmBankAccounts',
|
||||
{
|
||||
id: 'id_p',
|
||||
name: 'name_p',
|
||||
code: 'code_p',
|
||||
kind: 'kind_p',
|
||||
type: 'type_p',
|
||||
bo: 'bo_p',
|
||||
format: 'format_p',
|
||||
date_created: 'date_created_p',
|
||||
date_modified: 'date_modified_p',
|
||||
deleted: 'deleted_p'
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
ecmpopup.focus();
|
||||
},
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
// Search image button.
|
||||
// cell.appendChild(img);
|
||||
}
|
||||
|
||||
// Ma.
|
||||
if (i == 3) {
|
||||
cell.getData = function(data) {
|
||||
data.acc_ma_code = this.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
this.firstChild.value = data.acc_ma_code;
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type', 'text');
|
||||
// edit.setAttribute('readOnly', 'readonly');
|
||||
edit.setAttribute('tabIndex', 1);
|
||||
edit.className = 'inputs';
|
||||
|
||||
cell.appendChild(edit);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_IMG_SEARCH']);
|
||||
img.setAttribute('src', 'modules/EcmInvoiceOuts/images/search.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
try {
|
||||
// this.parentNode.select();
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
|
||||
this.parentNode.ajax_search = false;
|
||||
|
||||
var ecmpopup = my_popup(
|
||||
'EcmBankAccounts',
|
||||
{
|
||||
id: 'id_p',
|
||||
name: 'name_p',
|
||||
code: 'code_p',
|
||||
kind: 'kind_p',
|
||||
type: 'type_p',
|
||||
bo: 'bo_p',
|
||||
format: 'format_p',
|
||||
date_created: 'date_created_p',
|
||||
date_modified: 'date_modified_p',
|
||||
deleted: 'deleted_p'
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
ecmpopup.focus();
|
||||
},
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
// Search image button.
|
||||
// cell.appendChild(img);
|
||||
}
|
||||
|
||||
// Options.
|
||||
if (i == 4) {
|
||||
var img;
|
||||
|
||||
//insert
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_INSERT_NEW_ROW']);
|
||||
img.setAttribute('src', 'modules/EcmFkPackages/images/insertrow.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
this.parentNode.myTable.addRow(this.parentNode.parentNode.index + 1);
|
||||
};
|
||||
|
||||
//delete
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_DELETE_ROW']);
|
||||
img.setAttribute('src', 'modules/EcmFkPackages/images/deleterow.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
removeReservation(cell);
|
||||
this.parentNode.parentNode.deleteRow();
|
||||
};
|
||||
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createElement('br'));
|
||||
|
||||
//move up
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_MOVE_ROW_UP']);
|
||||
img.setAttribute('src', 'modules/EcmFkPackages/images/moverowup.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
this.parentNode.parentNode.moveUp();
|
||||
};
|
||||
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
|
||||
//move down
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_MOVE_ROW_DOWN']);
|
||||
img.setAttribute('src', 'modules/EcmFkPackages/images/moverowdown.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
this.parentNode.parentNode.moveDown();
|
||||
};
|
||||
|
||||
cell.appendChild(img);
|
||||
}
|
||||
};
|
||||
|
||||
N.onSetCellData = function(row, cell, data) {
|
||||
if (cell.innerHTML == '') {
|
||||
cell.innerHTML = ' ';
|
||||
}
|
||||
};
|
||||
|
||||
var pl = document.getElementById('decree_list').value;
|
||||
|
||||
if (pl && pl != '') {
|
||||
try {
|
||||
pl = eval(pl);
|
||||
// console.log(pl);
|
||||
|
||||
for (x in pl) {
|
||||
var pl_row = pl[x];
|
||||
|
||||
// if (!pl[x].code || pl[x].code == '')
|
||||
// {
|
||||
//
|
||||
// } else {
|
||||
N.addRow().setData(pl_row);
|
||||
// }
|
||||
}
|
||||
} catch (err) {
|
||||
pl = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (N.rowCount() == 0) {
|
||||
N.addRow();
|
||||
}
|
||||
|
||||
calculateTotalItems = function() {
|
||||
return true;
|
||||
|
||||
var vats = new Object();
|
||||
var subtotal = 0;
|
||||
var total = 0;
|
||||
|
||||
for (var i = 0; i < N.rowCount(); i++) {
|
||||
var data = N.row(i).getData();
|
||||
|
||||
if (OPT.to_is_vat_free == 0) {
|
||||
if (data.vat_id && data.name != '') {
|
||||
if (typeof(vats[data.vat_id]) != "object") {
|
||||
vats[data.vat_id] = new Object();
|
||||
vats[data.vat_id]['vat'] = 0;
|
||||
}
|
||||
|
||||
vats[data.vat_id]['vat'] += data.total;
|
||||
}
|
||||
}
|
||||
|
||||
subtotal += data.total;
|
||||
}
|
||||
|
||||
total = subtotal;
|
||||
|
||||
var rt = document.getElementById('position_result_table');
|
||||
|
||||
for (var i = 1; i < rt.rows.length - 1; i++) {
|
||||
if (!vats[rt.rows.item(i).id]) {
|
||||
rt.deleteRow(i);
|
||||
--i;
|
||||
} else {
|
||||
vats[rt.rows.item(i).id]['node'] = rt.rows.item(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (var x in vats) {
|
||||
if (VAT[x]) {
|
||||
vats[x]['vat'] = vats[x]['vat'] * (parseFloat(VAT[x].value) / 100);
|
||||
total += vats[x]['vat'];
|
||||
|
||||
var txL = MOD['LBL_VAT'] + ' (' + VAT[x].name + ')';
|
||||
var txF = NumberToUserFormatNumber(vats[x]['vat']);
|
||||
}
|
||||
|
||||
if (vats[x]['node']) {
|
||||
vats[x]['node'].id = x;
|
||||
vats[x]['node'].cells.item(0).innerHTML = txL;
|
||||
vats[x]['node'].cells.item(1).innerHTML = "<input type='text' readonly='readonly' style='border:0px;font-weight:900;width:100%;text-align:right;' value='" + txF + "'>";
|
||||
} else {
|
||||
rt.insertRow(1);
|
||||
|
||||
rt.rows.item(1).id = x;
|
||||
rt.rows.item(1).insertCell(0);
|
||||
rt.rows.item(1).cells.item(0).className = 'positionsLabel';
|
||||
rt.rows.item(1).cells.item(0).innerHTML = txL;
|
||||
rt.rows.item(1).insertCell(1);
|
||||
rt.rows.item(1).cells.item(1).className = 'positionsField';
|
||||
rt.rows.item(1).cells.item(1).innerHTML = "<input type='text' readonly='readonly' style='border:0px;font-weight:900;width:100%;text-align:right;' value='" + txF + "'>";
|
||||
}
|
||||
}
|
||||
|
||||
var total2 = total;
|
||||
|
||||
total2 = ((OPT['type'] == "correct") ? '-' : '') + NumberToUserFormatNumber(total2).toString();
|
||||
total = ((OPT['type'] == "correct") ? '-' : '') + NumberToUserFormatNumber(total).toString();
|
||||
|
||||
document.getElementById('articles_subtotal').value = NumberToUserFormatNumber(subtotal);
|
||||
|
||||
if (document.getElementById('articles_total'))
|
||||
document.getElementById('articles_total').value = total2;
|
||||
};
|
||||
|
||||
ItemListSave = function(json) {
|
||||
var data = '';
|
||||
|
||||
for (var i = 0; i < N.rowCount(); i++) {
|
||||
data = data + '&decree_' + i.toString() + '=' + JSON.stringifyNoSecurity(N.row(i).getData());
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
ItemsList = function(json) {
|
||||
var data = '';
|
||||
|
||||
for (var i = 0; i < N.rowCount(); i++) {
|
||||
data = data + '||||' + JSON.stringifyNoSecurity(N.row(i).getData());
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
if (typeof sqs_objects != 'undefined') {
|
||||
sqs_objects["code_p"] = {
|
||||
"method": "get_product_array",
|
||||
"modules": ["EcmProducts"],
|
||||
"field_list": ["index_dbf", "id", "name", "currency_id"],
|
||||
"populate_list": ["code_p", "id_p", "name_p", "currency_id_p"],
|
||||
"conditions": [{
|
||||
"name": "index_dbf",
|
||||
"op": "like_custom",
|
||||
"end": "%",
|
||||
"value": ""
|
||||
}],
|
||||
"limit": "30",
|
||||
"order": "index_dbf",
|
||||
"no_match_text": "No Match"
|
||||
};
|
||||
|
||||
sqs_objects["name_p"] = {
|
||||
"method": "get_product_array",
|
||||
"modules": ["EcmProducts"],
|
||||
"field_list": ["date_entered", "name", "id", "index_dbf", "currency_id"],
|
||||
"populate_list": ["name_p", "name_p", "id_p", "code_p", "currency_id_p"],
|
||||
"conditions": [{
|
||||
"name": "name",
|
||||
"op": "like_custom",
|
||||
"end": "%",
|
||||
"value": ""
|
||||
}],
|
||||
"limit": "30",
|
||||
"order": "name",
|
||||
"no_match_text": "No Match"
|
||||
};
|
||||
}
|
||||
|
||||
function generateNumber() {
|
||||
var url = 'to_pdf=1&generate=1&module=EcmFkPackages&action=generateNumber&type=normal&template_id=' + document.getElementById('template_id').value;//+'&record='+document.forms.EditView.record.value;
|
||||
|
||||
//if(document.getElementById('template_id').value == '') { alert('There are no DocumentTemplates in data base!'); return;}
|
||||
doRequest(
|
||||
'index.php',
|
||||
url,
|
||||
function(result) {
|
||||
var arr = eval(result)[0];
|
||||
|
||||
document.getElementById('number').value = arr.number;
|
||||
document.getElementById('document_no').value = arr.document_no;
|
||||
},
|
||||
''
|
||||
);
|
||||
};
|
||||
|
||||
//calculateTotalItems();
|
||||
|
||||
if (OPT['new_number']) {
|
||||
generateNumber();
|
||||
|
||||
document.getElementById('ITEMS_menu').style.display = 'none';
|
||||
document.getElementById('SERVICES_menu').style.display = 'none';
|
||||
|
||||
//save PW
|
||||
document.getElementById('stock_doc_inside_in').value = '1';
|
||||
}
|
||||
|
||||
function setToAddrEmail(str) {
|
||||
if (str && str != '')
|
||||
str = eval(str);
|
||||
else
|
||||
str = '';
|
||||
|
||||
if (typeof(str) == "object")
|
||||
str = str[0];
|
||||
else
|
||||
str = '';
|
||||
|
||||
if (document.getElementById('parent_type').value == 'Accounts') {
|
||||
//= document.getElementById('to_addrs_field'); if(tmp) tmp.value = (str=='')?'':(((str.name)?str.name:'')+' <'+((str.email1)?str.email1:'')+'>; ');
|
||||
tmp = document.getElementById('parent_address_street');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.billing_address_street) ? str.billing_address_street : '';
|
||||
}
|
||||
|
||||
tmp = document.getElementById('parent_address_city');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.billing_address_city) ? str.billing_address_city : '';
|
||||
}
|
||||
|
||||
tmp = document.getElementById('parent_address_postalcode');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.billing_address_postalcode) ? str.billing_address_postalcode : '';
|
||||
}
|
||||
|
||||
tmp = document.getElementById('parent_address_country');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.billing_address_country) ? str.billing_address_country : '';
|
||||
}
|
||||
|
||||
// tmp = document.getElementById('to_nip');
|
||||
//
|
||||
// if (tmp) {
|
||||
// tmp.value = (str.sic_code) ? str.sic_code : '';
|
||||
// }
|
||||
|
||||
tmp = document.getElementById('to_vatid');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.nip) ? str.nip : '';
|
||||
}
|
||||
|
||||
tmp = document.getElementById('to_is_vat_free');
|
||||
|
||||
if (tmp) {
|
||||
tmp.checked = (str.is_vat_free == 1) ? true : false;
|
||||
}
|
||||
|
||||
document.getElementById('parent_name_copy').value = document.getElementById('parent_name').value;
|
||||
|
||||
tmp = document.getElementById('ecmlanguage');
|
||||
|
||||
if (tmp && str.ecmlanguage) {
|
||||
if (tmp.value != str.ecmlanguage) {
|
||||
tmp.value = str.ecmlanguage;
|
||||
setTexts();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ChangeAccessFunction(obj, type) {
|
||||
var objs = obj.getElementsByTagName('input');
|
||||
|
||||
|
||||
for (var i = 0; i < objs.length; i++)
|
||||
if (objs[i].id != 'parent_name' && objs[i].id != 'parent_id' && objs[i].name != 'btn_parent_name' && objs[i].name != 'btn_clr_parent_name' && objs[i].name != 'btn_create_parent_name') {
|
||||
objs[i].disabled = type;
|
||||
}
|
||||
|
||||
var objs = obj.getElementsByTagName('textarea');
|
||||
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
objs[i].disabled = type;
|
||||
}
|
||||
|
||||
var objs = obj.getElementsByTagName('select');
|
||||
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
if (objs[i].id != 'parent_type') {
|
||||
objs[i].disabled = type;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == 'disabled') {
|
||||
TabsMainBlock = true;
|
||||
}
|
||||
else {
|
||||
TabsMainBlock = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log('N done');
|
||||
}
|
||||
);
|
||||
/* /Decree */
|
||||
|
||||
CHANGER.startTimer();
|
||||
1688
modules/EcmFkVatTables/__EcmFkVatRegistersEditView.js
Executable file
1688
modules/EcmFkVatTables/__EcmFkVatRegistersEditView.js
Executable file
File diff suppressed because it is too large
Load Diff
816
modules/EcmFkVatTables/___EcmFkVatRegistersEditView.js
Executable file
816
modules/EcmFkVatTables/___EcmFkVatRegistersEditView.js
Executable file
@@ -0,0 +1,816 @@
|
||||
function changer() {
|
||||
this.list = new Object();
|
||||
|
||||
this.add = function(object, type, do_function, start_value) {
|
||||
if (typeof(object) == "string") {
|
||||
object = document.getElementById(object);
|
||||
}
|
||||
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.list[object.id] = new Object();
|
||||
this.list[object.id].object = object;
|
||||
this.list[object.id].type = type;
|
||||
this.list[object.id].do_function = do_function;
|
||||
this.list[object.id].start_value = start_value;
|
||||
this.list[object.id].value = '';
|
||||
};
|
||||
|
||||
this.getValue = function(element) {
|
||||
var value = null;
|
||||
|
||||
if (element.object) {
|
||||
if (element.type == "innerHTML") {
|
||||
value = element.object.innerHTML;
|
||||
}
|
||||
|
||||
if (element.type == "value") {
|
||||
value = element.object.value;
|
||||
}
|
||||
|
||||
if (element.type == "checked") {
|
||||
value = element.object.checked;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
this.interval = 1000;
|
||||
|
||||
this.timer = null;
|
||||
|
||||
this.startTimer = function() {
|
||||
var cc = this;
|
||||
|
||||
this.timer = setInterval(
|
||||
function() {
|
||||
var list = cc.list;
|
||||
|
||||
for (x in list) {
|
||||
if (list[x].start_value) {
|
||||
list[x].value = cc.getValue(list[x]);
|
||||
list[x].start_value = false;
|
||||
} else {
|
||||
var value = cc.getValue(list[x]);
|
||||
|
||||
if (list[x].value !== value) {
|
||||
if (list[x].do_function) {
|
||||
list[x].do_function(list[x].object);
|
||||
}
|
||||
}
|
||||
|
||||
list[x].value = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
this.interval
|
||||
);
|
||||
};
|
||||
|
||||
this.stopTimer = function() {
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
};
|
||||
}
|
||||
|
||||
/* Decree */
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
var CHANGER = new changer();
|
||||
CHANGER.interval = 500;
|
||||
|
||||
CHANGER.add(
|
||||
'account_acc_wn',
|
||||
'checked',
|
||||
function(obj) {
|
||||
if (true == obj.checked) {
|
||||
document.getElementById('acc_wn').disabled = true;
|
||||
document.getElementById('acc_wn_code').disabled = true
|
||||
|
||||
document.getElementById('btn_acc_wn_code').disabled = true
|
||||
document.getElementById('btn_clr_acc_wn_code').disabled = true
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
document.getElementById('acc_wn').disabled = false;
|
||||
document.getElementById('acc_wn_code').disabled = false;
|
||||
|
||||
document.getElementById('btn_acc_wn_code').disabled = false;
|
||||
document.getElementById('btn_clr_acc_wn_code').disabled = false;
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
CHANGER.add(
|
||||
'account_acc_ma',
|
||||
'checked',
|
||||
function(obj) {
|
||||
if (true == obj.checked) {
|
||||
document.getElementById('acc_ma').disabled = true;
|
||||
document.getElementById('acc_ma_code').disabled = true
|
||||
|
||||
document.getElementById('btn_acc_ma_code').disabled = true
|
||||
document.getElementById('btn_clr_acc_ma_code').disabled = true
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
document.getElementById('acc_ma').disabled = false;
|
||||
document.getElementById('acc_ma_code').disabled = false;
|
||||
|
||||
document.getElementById('btn_acc_ma_code').disabled = false;
|
||||
document.getElementById('btn_clr_acc_ma_code').disabled = false;
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
set_focus();
|
||||
|
||||
//initialize table
|
||||
N = new MyTable('decreeTable');
|
||||
N.divParent = document.getElementById('decreeTableDIV');
|
||||
|
||||
var from_popup_return = false;
|
||||
|
||||
function returnedData(popup_reply_data) {
|
||||
from_popup_return = true;
|
||||
|
||||
var form_name = popup_reply_data.form_name;
|
||||
var name_to_value_array = popup_reply_data.name_to_value_array;
|
||||
|
||||
for (var the_key in name_to_value_array) {
|
||||
if (the_key == 'toJSON') {
|
||||
//
|
||||
}
|
||||
else {
|
||||
var displayValue = name_to_value_array[the_key].replace(/&/gi, '&').replace(/</gi, '<').replace(/>/gi, '>').replace(/'/gi, '\'').replace(/"/gi, '"');
|
||||
|
||||
var e = document.getElementById(the_key);
|
||||
|
||||
if (e) {
|
||||
e.value = displayValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if(N.selectedRow)
|
||||
// N.selectedRow.calculateTotal();
|
||||
}
|
||||
|
||||
N.onRefreshRowIndex = function(row) {
|
||||
return true;
|
||||
|
||||
var data = new Object();
|
||||
data['index'] = (row.index + 1).toString();
|
||||
|
||||
row.cells.item(0).setData(data);
|
||||
};
|
||||
|
||||
N.onCreateRow = function(row) {
|
||||
console.log(row);
|
||||
|
||||
row.newPos = false;
|
||||
row.style.height = OPT['row_item_height'];
|
||||
|
||||
row.ondblclick = function() {
|
||||
this.newPos = !this.newPos;
|
||||
|
||||
for (var i = 0; i < this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).change(!this.newPos);
|
||||
}
|
||||
};
|
||||
|
||||
row.onSelect = function() {
|
||||
for (var i = 0; i < this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).style.height = OPT['row_item_height_selected'];
|
||||
this.cells.item(i).change(!this.newPos);
|
||||
}
|
||||
};
|
||||
|
||||
row.onDeselect = function() {
|
||||
for (var i = 0; i < this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).style.height = OPT['row_item_height'];
|
||||
this.cells.item(i).change(false);
|
||||
}
|
||||
};
|
||||
|
||||
row.calculateTotal = function() {
|
||||
console.log('calculateTotal');
|
||||
return true;
|
||||
|
||||
var data = new Object();
|
||||
|
||||
this.cells.item(3).getData(data, true);
|
||||
this.cells.item(5).getData(data, true);
|
||||
this.cells.item(6).getData(data, true);
|
||||
|
||||
if (data.quantity && data.price) {
|
||||
data.price2 = data.price - data.price * data.discount / 100;
|
||||
data.total = data.quantity * data.price2;
|
||||
}
|
||||
else {
|
||||
data.total = 0;
|
||||
data.price2 = 0;
|
||||
}
|
||||
|
||||
this.cells.item(7).setData(data);
|
||||
this.cells.item(10).setData(data);
|
||||
|
||||
calculateTotalItems();
|
||||
};
|
||||
};
|
||||
|
||||
var itd = document.getElementById('decreeTableDIV');
|
||||
|
||||
itd.onscroll = function() {
|
||||
console.log('onscroll');
|
||||
return true;
|
||||
|
||||
if (!AjaxSearch1Items.AjaxSearchFrozen)
|
||||
if (N.selectedCell && N.selectedCell.LeftPosition && N.selectedCell.TopPosition) {
|
||||
var top = N.selectedCell.TopPosition + N.selectedCell.offsetHeight;
|
||||
|
||||
if (((N.selectedCell.offsetTop + N.selectedCell.offsetHeight - this.scrollTop) > (this.offsetHeight + 5)) || ((N.selectedCell.offsetTop - this.scrollTop) < (-10)))
|
||||
AjaxSearch1Items.div.style.display = 'none';
|
||||
else
|
||||
AjaxSearch1Items.div.style.display = '';
|
||||
|
||||
AjaxSearch1Items.div.style.top = top - this.scrollTop;
|
||||
}
|
||||
};
|
||||
|
||||
N.onCreateCell = function(cell) {
|
||||
console.log(cell);
|
||||
|
||||
var i = cell.index;
|
||||
|
||||
cell.change = function(select) {
|
||||
//
|
||||
};
|
||||
|
||||
cell.style.height = OPT['row_item_height'];
|
||||
|
||||
// cell.onDeselect = function() {
|
||||
// var data = this.parentNode.getData();
|
||||
|
||||
// if (!data.id || data.id == '') {
|
||||
// var data2 = new Object();
|
||||
// this.parentNode.setData(data2);
|
||||
// }
|
||||
// };
|
||||
|
||||
// Position.
|
||||
if (i == 0) {
|
||||
cell.select = function() {
|
||||
this.selectNext();
|
||||
};
|
||||
|
||||
cell.getData = function(data) {
|
||||
data.index = cell.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
if (data.index) {
|
||||
cell.firstChild.value = data.index;
|
||||
}
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type', 'text');
|
||||
edit.setAttribute('readOnly', 'readonly');
|
||||
edit.setAttribute('tabIndex', 1);
|
||||
edit.className = 'inputs';
|
||||
|
||||
cell.appendChild(edit);
|
||||
}
|
||||
|
||||
// Name.
|
||||
if (i == 1) {
|
||||
cell.getData = function(data) {
|
||||
data.vr_name = this.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
this.firstChild.value = data.vr_name;
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type', 'text');
|
||||
// edit.setAttribute('readOnly', 'readonly');
|
||||
edit.setAttribute('tabIndex', 1);
|
||||
edit.className = 'inputs';
|
||||
|
||||
cell.appendChild(edit);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_IMG_SEARCH']);
|
||||
img.setAttribute('src', 'modules/EcmInvoiceOuts/images/search.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
try {
|
||||
// this.parentNode.select();
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
|
||||
this.parentNode.ajax_search = false;
|
||||
|
||||
var ecmpopup = my_popup(
|
||||
'EcmFkVatRegs',
|
||||
{
|
||||
id: 'id_p',
|
||||
name: 'name_p',
|
||||
position: 'position_p',
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
// ecmpopup.focus();
|
||||
},
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
// Search image button.
|
||||
// cell.appendChild(img);
|
||||
}
|
||||
|
||||
// Wn.
|
||||
if (i == 2) {
|
||||
cell.getData = function(data) {
|
||||
data.acc_wn_code = this.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
this.firstChild.value = data.acc_wn_code;
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type', 'text');
|
||||
// edit.setAttribute('readOnly', 'readonly');
|
||||
edit.setAttribute('tabIndex', 1);
|
||||
edit.className = 'inputs';
|
||||
|
||||
cell.appendChild(edit);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_IMG_SEARCH']);
|
||||
img.setAttribute('src', 'modules/EcmInvoiceOuts/images/search.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
try {
|
||||
// this.parentNode.select();
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
|
||||
this.parentNode.ajax_search = false;
|
||||
|
||||
var ecmpopup = my_popup(
|
||||
'EcmBankAccounts',
|
||||
{
|
||||
id: 'id_p',
|
||||
name: 'name_p',
|
||||
code: 'code_p',
|
||||
kind: 'kind_p',
|
||||
type: 'type_p',
|
||||
bo: 'bo_p',
|
||||
format: 'format_p',
|
||||
date_created: 'date_created_p',
|
||||
date_modified: 'date_modified_p',
|
||||
deleted: 'deleted_p'
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
// ecmpopup.focus();
|
||||
},
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
// Search image button.
|
||||
// cell.appendChild(img);
|
||||
}
|
||||
|
||||
// Ma.
|
||||
if (i == 3) {
|
||||
cell.getData = function(data) {
|
||||
data.acc_ma_code = this.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
this.firstChild.value = data.acc_ma_code;
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type', 'text');
|
||||
// edit.setAttribute('readOnly', 'readonly');
|
||||
edit.setAttribute('tabIndex', 1);
|
||||
edit.className = 'inputs';
|
||||
|
||||
cell.appendChild(edit);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_IMG_SEARCH']);
|
||||
img.setAttribute('src', 'modules/EcmInvoiceOuts/images/search.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
try {
|
||||
// this.parentNode.select();
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
|
||||
this.parentNode.ajax_search = false;
|
||||
|
||||
var ecmpopup = my_popup(
|
||||
'EcmBankAccounts',
|
||||
{
|
||||
id: 'id_p',
|
||||
name: 'name_p',
|
||||
code: 'code_p',
|
||||
kind: 'kind_p',
|
||||
type: 'type_p',
|
||||
bo: 'bo_p',
|
||||
format: 'format_p',
|
||||
date_created: 'date_created_p',
|
||||
date_modified: 'date_modified_p',
|
||||
deleted: 'deleted_p'
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
// ecmpopup.focus();
|
||||
},
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
// Search image button.
|
||||
// cell.appendChild(img);
|
||||
}
|
||||
|
||||
// Options.
|
||||
if (i == 4) {
|
||||
var img;
|
||||
|
||||
//insert
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_INSERT_NEW_ROW']);
|
||||
img.setAttribute('src', 'modules/EcmFkPackages/images/insertrow.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
this.parentNode.myTable.addRow(this.parentNode.parentNode.index + 1);
|
||||
};
|
||||
|
||||
//delete
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_DELETE_ROW']);
|
||||
img.setAttribute('src', 'modules/EcmFkPackages/images/deleterow.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
removeReservation(cell);
|
||||
this.parentNode.parentNode.deleteRow();
|
||||
};
|
||||
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createElement('br'));
|
||||
|
||||
//move up
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_MOVE_ROW_UP']);
|
||||
img.setAttribute('src', 'modules/EcmFkPackages/images/moverowup.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
this.parentNode.parentNode.moveUp();
|
||||
};
|
||||
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
|
||||
//move down
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt', MOD['LBL_MOVE_ROW_DOWN']);
|
||||
img.setAttribute('src', 'modules/EcmFkPackages/images/moverowdown.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
|
||||
img.onclick = function() {
|
||||
this.parentNode.parentNode.moveDown();
|
||||
};
|
||||
|
||||
cell.appendChild(img);
|
||||
}
|
||||
};
|
||||
|
||||
N.onSetCellData = function(row, cell, data) {
|
||||
if (cell.innerHTML == '') {
|
||||
cell.innerHTML = ' ';
|
||||
}
|
||||
};
|
||||
|
||||
var pl = document.getElementById('decree_list').value;
|
||||
|
||||
if (pl && pl != '') {
|
||||
try {
|
||||
pl = eval(pl);
|
||||
// console.log(pl);
|
||||
|
||||
for (x in pl) {
|
||||
var pl_row = pl[x];
|
||||
|
||||
// if (!pl[x].code || pl[x].code == '')
|
||||
// {
|
||||
//
|
||||
// } else {
|
||||
N.addRow().setData(pl_row);
|
||||
// }
|
||||
}
|
||||
} catch (err) {
|
||||
pl = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (N.rowCount() == 0) {
|
||||
N.addRow();
|
||||
}
|
||||
|
||||
calculateTotalItems = function() {
|
||||
return true;
|
||||
|
||||
var vats = new Object();
|
||||
var subtotal = 0;
|
||||
var total = 0;
|
||||
|
||||
for (var i = 0; i < N.rowCount(); i++) {
|
||||
var data = N.row(i).getData();
|
||||
|
||||
if (OPT.to_is_vat_free == 0) {
|
||||
if (data.vat_id && data.name != '') {
|
||||
if (typeof(vats[data.vat_id]) != "object") {
|
||||
vats[data.vat_id] = new Object();
|
||||
vats[data.vat_id]['vat'] = 0;
|
||||
}
|
||||
|
||||
vats[data.vat_id]['vat'] += data.total;
|
||||
}
|
||||
}
|
||||
|
||||
subtotal += data.total;
|
||||
}
|
||||
|
||||
total = subtotal;
|
||||
|
||||
var rt = document.getElementById('position_result_table');
|
||||
|
||||
for (var i = 1; i < rt.rows.length - 1; i++) {
|
||||
if (!vats[rt.rows.item(i).id]) {
|
||||
rt.deleteRow(i);
|
||||
--i;
|
||||
} else {
|
||||
vats[rt.rows.item(i).id]['node'] = rt.rows.item(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (var x in vats) {
|
||||
if (VAT[x]) {
|
||||
vats[x]['vat'] = vats[x]['vat'] * (parseFloat(VAT[x].value) / 100);
|
||||
total += vats[x]['vat'];
|
||||
|
||||
var txL = MOD['LBL_VAT'] + ' (' + VAT[x].name + ')';
|
||||
var txF = NumberToUserFormatNumber(vats[x]['vat']);
|
||||
}
|
||||
|
||||
if (vats[x]['node']) {
|
||||
vats[x]['node'].id = x;
|
||||
vats[x]['node'].cells.item(0).innerHTML = txL;
|
||||
vats[x]['node'].cells.item(1).innerHTML = "<input type='text' readonly='readonly' style='border:0px;font-weight:900;width:100%;text-align:right;' value='" + txF + "'>";
|
||||
} else {
|
||||
rt.insertRow(1);
|
||||
|
||||
rt.rows.item(1).id = x;
|
||||
rt.rows.item(1).insertCell(0);
|
||||
rt.rows.item(1).cells.item(0).className = 'positionsLabel';
|
||||
rt.rows.item(1).cells.item(0).innerHTML = txL;
|
||||
rt.rows.item(1).insertCell(1);
|
||||
rt.rows.item(1).cells.item(1).className = 'positionsField';
|
||||
rt.rows.item(1).cells.item(1).innerHTML = "<input type='text' readonly='readonly' style='border:0px;font-weight:900;width:100%;text-align:right;' value='" + txF + "'>";
|
||||
}
|
||||
}
|
||||
|
||||
var total2 = total;
|
||||
|
||||
total2 = ((OPT['type'] == "correct") ? '-' : '') + NumberToUserFormatNumber(total2).toString();
|
||||
total = ((OPT['type'] == "correct") ? '-' : '') + NumberToUserFormatNumber(total).toString();
|
||||
|
||||
document.getElementById('articles_subtotal').value = NumberToUserFormatNumber(subtotal);
|
||||
|
||||
if (document.getElementById('articles_total'))
|
||||
document.getElementById('articles_total').value = total2;
|
||||
};
|
||||
|
||||
ItemListSave = function(json) {
|
||||
var data = '';
|
||||
|
||||
for (var i = 0; i < N.rowCount(); i++) {
|
||||
data = data + '&decree_' + i.toString() + '=' + JSON.stringifyNoSecurity(N.row(i).getData());
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
ItemsList = function(json) {
|
||||
var data = '';
|
||||
|
||||
for (var i = 0; i < N.rowCount(); i++) {
|
||||
data = data + '||||' + JSON.stringifyNoSecurity(N.row(i).getData());
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
if (typeof sqs_objects != 'undefined') {
|
||||
sqs_objects["code_p"] = {
|
||||
"method": "get_product_array",
|
||||
"modules": ["EcmProducts"],
|
||||
"field_list": ["index_dbf", "id", "name", "currency_id"],
|
||||
"populate_list": ["code_p", "id_p", "name_p", "currency_id_p"],
|
||||
"conditions": [{
|
||||
"name": "index_dbf",
|
||||
"op": "like_custom",
|
||||
"end": "%",
|
||||
"value": ""
|
||||
}],
|
||||
"limit": "30",
|
||||
"order": "index_dbf",
|
||||
"no_match_text": "No Match"
|
||||
};
|
||||
|
||||
sqs_objects["name_p"] = {
|
||||
"method": "get_product_array",
|
||||
"modules": ["EcmProducts"],
|
||||
"field_list": ["date_entered", "name", "id", "index_dbf", "currency_id"],
|
||||
"populate_list": ["name_p", "name_p", "id_p", "code_p", "currency_id_p"],
|
||||
"conditions": [{
|
||||
"name": "name",
|
||||
"op": "like_custom",
|
||||
"end": "%",
|
||||
"value": ""
|
||||
}],
|
||||
"limit": "30",
|
||||
"order": "name",
|
||||
"no_match_text": "No Match"
|
||||
};
|
||||
}
|
||||
|
||||
function generateNumber() {
|
||||
var url = 'to_pdf=1&generate=1&module=EcmFkPackages&action=generateNumber&type=normal&template_id=' + document.getElementById('template_id').value;//+'&record='+document.forms.EditView.record.value;
|
||||
|
||||
//if(document.getElementById('template_id').value == '') { alert('There are no DocumentTemplates in data base!'); return;}
|
||||
doRequest(
|
||||
'index.php',
|
||||
url,
|
||||
function(result) {
|
||||
var arr = eval(result)[0];
|
||||
|
||||
document.getElementById('number').value = arr.number;
|
||||
document.getElementById('document_no').value = arr.document_no;
|
||||
},
|
||||
''
|
||||
);
|
||||
};
|
||||
|
||||
//calculateTotalItems();
|
||||
|
||||
if (OPT['new_number']) {
|
||||
generateNumber();
|
||||
|
||||
document.getElementById('ITEMS_menu').style.display = 'none';
|
||||
document.getElementById('SERVICES_menu').style.display = 'none';
|
||||
|
||||
//save PW
|
||||
document.getElementById('stock_doc_inside_in').value = '1';
|
||||
}
|
||||
|
||||
function setToAddrEmail(str) {
|
||||
if (str && str != '')
|
||||
str = eval(str);
|
||||
else
|
||||
str = '';
|
||||
|
||||
if (typeof(str) == "object")
|
||||
str = str[0];
|
||||
else
|
||||
str = '';
|
||||
|
||||
if (document.getElementById('parent_type').value == 'Accounts') {
|
||||
//= document.getElementById('to_addrs_field'); if(tmp) tmp.value = (str=='')?'':(((str.name)?str.name:'')+' <'+((str.email1)?str.email1:'')+'>; ');
|
||||
tmp = document.getElementById('parent_address_street');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.billing_address_street) ? str.billing_address_street : '';
|
||||
}
|
||||
|
||||
tmp = document.getElementById('parent_address_city');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.billing_address_city) ? str.billing_address_city : '';
|
||||
}
|
||||
|
||||
tmp = document.getElementById('parent_address_postalcode');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.billing_address_postalcode) ? str.billing_address_postalcode : '';
|
||||
}
|
||||
|
||||
tmp = document.getElementById('parent_address_country');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.billing_address_country) ? str.billing_address_country : '';
|
||||
}
|
||||
|
||||
// tmp = document.getElementById('to_nip');
|
||||
//
|
||||
// if (tmp) {
|
||||
// tmp.value = (str.sic_code) ? str.sic_code : '';
|
||||
// }
|
||||
|
||||
tmp = document.getElementById('to_vatid');
|
||||
|
||||
if (tmp) {
|
||||
tmp.value = (str.nip) ? str.nip : '';
|
||||
}
|
||||
|
||||
tmp = document.getElementById('to_is_vat_free');
|
||||
|
||||
if (tmp) {
|
||||
tmp.checked = (str.is_vat_free == 1) ? true : false;
|
||||
}
|
||||
|
||||
document.getElementById('parent_name_copy').value = document.getElementById('parent_name').value;
|
||||
|
||||
tmp = document.getElementById('ecmlanguage');
|
||||
|
||||
if (tmp && str.ecmlanguage) {
|
||||
if (tmp.value != str.ecmlanguage) {
|
||||
tmp.value = str.ecmlanguage;
|
||||
setTexts();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ChangeAccessFunction(obj, type) {
|
||||
var objs = obj.getElementsByTagName('input');
|
||||
|
||||
for (var i = 0; i < objs.length; i++)
|
||||
if (objs[i].id != 'parent_name' && objs[i].id != 'parent_id' && objs[i].name != 'btn_parent_name' && objs[i].name != 'btn_clr_parent_name' && objs[i].name != 'btn_create_parent_name') {
|
||||
objs[i].disabled = type;
|
||||
}
|
||||
|
||||
var objs = obj.getElementsByTagName('textarea');
|
||||
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
objs[i].disabled = type;
|
||||
}
|
||||
|
||||
var objs = obj.getElementsByTagName('select');
|
||||
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
if (objs[i].id != 'parent_type') {
|
||||
objs[i].disabled = type;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == 'disabled') {
|
||||
TabsMainBlock = true;
|
||||
} else {
|
||||
TabsMainBlock = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log('N done');
|
||||
}
|
||||
);
|
||||
/* /Decree */
|
||||
|
||||
CHANGER.startTimer();
|
||||
1603
modules/EcmFkVatTables/____EcmFkVatRegistersEditView.js
Executable file
1603
modules/EcmFkVatTables/____EcmFkVatRegistersEditView.js
Executable file
File diff suppressed because it is too large
Load Diff
48
modules/EcmFkVatTables/fkbooks.js
Executable file
48
modules/EcmFkVatTables/fkbooks.js
Executable file
@@ -0,0 +1,48 @@
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
var rhandle=new RevisionListHandler();var from_popup_return=false;function ecmfkvattable_set_return(popup_reply_data)
|
||||
{from_popup_return=true;var form_name=popup_reply_data.form_name;var name_to_value_array=popup_reply_data.name_to_value_array;related_doc_id='EMPTY';for(var the_key in name_to_value_array)
|
||||
{if(the_key=='toJSON')
|
||||
{}
|
||||
else
|
||||
{var displayValue=name_to_value_array[the_key];displayValue=displayValue.replace(''',"'");displayValue=displayValue.replace('&',"&");displayValue=displayValue.replace('>',">");displayValue=displayValue.replace('<',"<");displayValue=displayValue.replace('" ',"\"");if(the_key=='related_doc_id'){related_doc_id=displayValue;}
|
||||
window.ecmfkvattable.forms[form_name].elements[the_key].value=displayValue;}}
|
||||
related_doc_id=JSON.stringifyNoSecurity(related_doc_id);var conditions=new Array();conditions[conditions.length]={"name":"ecmfkvattable_id","op":"starts_with","value":related_doc_id};var query=new Array();var query={"module":"EcmFkVatTableRevisions","field_list":['id','revision','date_entered'],"conditions":conditions,"order":'date_entered desc'};result=global_rpcClient.call_method('query',query,true);rhandle.display(result);}
|
||||
function RevisionListHandler(){}
|
||||
RevisionListHandler.prototype.display=function(result){var names=result['list'];var rev_tag=ecmfkvattable.getElementById('related_doc_rev_id');rev_tag.options.length=0;for(i=0;i<names.length;i++){rev_tag.options[i]=new Option(names[i].fields['revision'],names[i].fields['id'],false,false);}
|
||||
rev_tag.disabled=false;}
|
||||
function setvalue(source){src=new String(source.value);target=new String(source.form.ecmfkvattable_name.value);if(target.length==0){lastindex=src.lastIndexOf("/");if(lastindex==-1){lastindex=src.lastIndexOf("\\");}
|
||||
if(lastindex==-1){source.form.ecmfkvattable_name.value=src;source.form.escaped_document_name.value=src;}else{source.form.document_name.value=src.substr(++lastindex,src.length);source.form.escaped_document_name.value=src.substr(lastindex,src.length);}}}
|
||||
function toggle_template_type(istemplate){template_type=ecmfkvattable.getElementById('template_type');if(istemplate.checked){template_type.disabled=false;}else{template_type.disabled=true;}}
|
||||
Reference in New Issue
Block a user