Add JS files
This commit is contained in:
415
modules/EcmReceipts2/AjaxSearch/AjaxSearch.js
Executable file
415
modules/EcmReceipts2/AjaxSearch/AjaxSearch.js
Executable file
@@ -0,0 +1,415 @@
|
||||
|
||||
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 setSelectionRange(obj) {
|
||||
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
|
||||
if(obj.createTextRange) {
|
||||
var range = obj.createTextRange();
|
||||
range.moveStart("character", 0);
|
||||
range.moveEnd("character", obj.value.lengh-1);
|
||||
range.select();
|
||||
} else {
|
||||
if(obj.setSelectionRange) {
|
||||
obj.setSelectionRange(0,obj.value.length);
|
||||
}
|
||||
}
|
||||
obj.focus();
|
||||
}
|
||||
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
|
||||
}
|
||||
|
||||
var AjaxSearchItems;
|
||||
function AjaxSearch(div,displayNone) {
|
||||
|
||||
//fields
|
||||
|
||||
this.parentDIV = div; //pole w ktorym zawiera sie pole wyszukiwania
|
||||
this.div; //pole glowne wyszukiwania
|
||||
this.inputSearch; //input wyszukiwania
|
||||
this.timeout; //wskaznik zwracany przez setTimeout przy wcisnieciu klawisza
|
||||
this.searchDelay = 1000; //opoznienie wyszukiwania
|
||||
this.divList; //pole w ktorym wyswietlana bedzie lista znalezionnych elementow
|
||||
this.ajaxSearchItem; //unikalny identyfikator;
|
||||
this.module = 'EcmSales';
|
||||
this.inputCode;
|
||||
|
||||
this.positionSelected;
|
||||
|
||||
//functions
|
||||
this.setInputCode = function(input) {
|
||||
this.inputCode = input;
|
||||
this.inputCode.previousCode = this.inputCode.value;
|
||||
}
|
||||
|
||||
this.inputSearchOnKeyDown = function(e,other) {
|
||||
var keynum;
|
||||
if(typeof(e) == "number")
|
||||
keynum = e;
|
||||
else {
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
}
|
||||
|
||||
if(keynum == 38) { this.selectPreviousPosition(); return false; }
|
||||
if(keynum == 40) { this.selectNextPosition(); return false; }
|
||||
if(keynum == 13 || keynum == 9) {
|
||||
//if(parseInt(this.positionSelected.positionData['on_stock'])>0 && this.positionSelected.positionData['on_stock']!=""){
|
||||
this.inputSearchEnterPressed(other);
|
||||
return false;
|
||||
//}
|
||||
//else{
|
||||
//// alert(MOD['LBL_NO_PRODUCTS_IN_STOCK']);
|
||||
// this.div.style.display='block';
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
if(keynum == 27) { this.div.style.display = 'none'; }
|
||||
|
||||
if(this.timeout) { clearTimeout(this.timeout); this.timeout = null; }
|
||||
this.timeout = setTimeout("document.getElementById('"+this.div.id+"').AjaxSearch.search();", 2000);
|
||||
}
|
||||
|
||||
this.inputSearchEnterPressed = function(other) {
|
||||
if(this.positionSelected) {
|
||||
var row;
|
||||
if(N.selectedRow) {
|
||||
N.selectedRow.setData(this.positionSelected.positionData);
|
||||
row = N.selectedRow;
|
||||
}
|
||||
else {
|
||||
row = N.addRow().setData(this.positionSelected.positionData);
|
||||
}
|
||||
row.calculateTotal();
|
||||
if((other && other == "clear") || OPT['quick_product_item_adding']==0) {
|
||||
this.clearList();
|
||||
this.div.style.display = 'none';
|
||||
if(OPT['quick_product_item_adding'] == 0) if(N.selectedCell && N.selectedCell.index == 1) N.selectedCell.selectNext();
|
||||
} else {
|
||||
row.noHideASP = true;
|
||||
if(N.selectedRow) row = row.myTable.addRow(row.index+1);
|
||||
row.select();
|
||||
row.cells.item(0).select();
|
||||
setSelectionRange(this.inputSearch);
|
||||
}
|
||||
}
|
||||
else if(N.selectedRow) {
|
||||
if(this.inputSearch.value != this.inputCode.previousCode || this.inputCode.previousCode == '') {
|
||||
var data = new Object();
|
||||
N.selectedRow.setData(data);
|
||||
N.selectedRow.cells.item(1).select();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//N.addRow();
|
||||
}
|
||||
|
||||
this.selectNextPosition = function() {
|
||||
if(this.positionSelected) {
|
||||
if(this.positionSelected.nextSibling) {
|
||||
this.positionSelect(this.positionSelected.nextSibling);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.positionSelect(this.divList.lastChild);
|
||||
}
|
||||
|
||||
this.selectPreviousPosition = function() {
|
||||
if(this.positionSelected) {
|
||||
if(this.positionSelected.previousSibling) {
|
||||
this.positionSelect(this.positionSelected.previousSibling);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.positionSelect(this.divList.firstChild);
|
||||
}
|
||||
|
||||
this.search = function() {
|
||||
|
||||
if(this.inputSearch.value == '') { this.clearList(); return; }
|
||||
var _ajax_search_process_search_ = this;
|
||||
this.Display = function(result) { _ajax_search_process_search_.processSearch(result.responseText); }
|
||||
this.Fail = function(result) { alert(result.responseText); }
|
||||
YAHOO.util.Connect.asyncRequest('POST','index.php',{success:this.Display,failure:this.Fail},'module='+this.module+'&action=AjaxSearchQuery&to_pdf=1&as_inputSearch='+this.inputSearch.value+'&ecmlanguage='+document.forms.EditView.ecmlanguage.value+'&stock_id='+document.forms.EditView.stock_id.value);
|
||||
|
||||
}
|
||||
|
||||
this.processSearch = function(result) {
|
||||
this.clearList();
|
||||
var list = eval(result);
|
||||
if(typeof(list) != "object") return;
|
||||
this.fillList(list);
|
||||
}
|
||||
|
||||
this.clearList = function() {
|
||||
this.divList.innerHTML = '';
|
||||
this.divList.style.height = '';
|
||||
this.positionDeselect();
|
||||
}
|
||||
|
||||
this.fillList = function(list) {
|
||||
for(x in list) {
|
||||
this.addPosition(list[x]);
|
||||
}
|
||||
this.positionSelect();
|
||||
this.setScrolls();
|
||||
}
|
||||
|
||||
this.setScrolls = function() {
|
||||
var clientH = -1;
|
||||
if(window.innerHeight && window.innerHeight > 0) clientH = window.innerHeight;
|
||||
else if(document.documentElement && document.documentElement.clientHeight > 0) clientH = document.documentElement.clientHeight;
|
||||
else if(document.body && document.body.clientHeight > 0) clientH = document.body.clientHeight;
|
||||
var XY = YAHOO.util.Dom.getXY(this.div);
|
||||
var divTop = (XY[1]+this.div.offsetHeight);
|
||||
if((divTop - (clientH+document.body.scrollTop)) > 0) {
|
||||
var newPos = divTop-clientH;
|
||||
document.body.scrollTop = newPos;
|
||||
}
|
||||
}
|
||||
|
||||
this.positionSelect = function(div,noScroll) {
|
||||
if(!div) {
|
||||
if(!this.positionSelected) {
|
||||
if(this.divList.firstChild) this.positionSelect(this.divList.firstChild);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.positionDeselect();
|
||||
div.className = 'AjaxSearchPositionDivSelected';
|
||||
this.positionSelected = div;
|
||||
if(!noScroll) this.divList.scrollTop = div.offsetTop;
|
||||
}
|
||||
|
||||
this.positionDeselect = function() {
|
||||
if(this.positionSelected) {
|
||||
this.positionSelected.className = '';
|
||||
this.positionSelected = null;
|
||||
}
|
||||
}
|
||||
|
||||
this.addPosition = function(list) {
|
||||
var position = document.createElement('div');
|
||||
position.positionData = list;
|
||||
//if(list['on_stock']>0)
|
||||
position.onclick = function() {
|
||||
this.parentNode.AjaxSearch.inputSearchEnterPressed(this); }
|
||||
|
||||
//else position.onclick = function() { alert(MOD['LBL_NO_PRODUCTS_IN_STOCK']); }
|
||||
position.onmouseover = function() { this.parentNode.AjaxSearch.positionSelect(this,true); };
|
||||
position.innerHTML = '<table width="100%" class="AjaxSearchPositionTable"><tr><td style="width:40%" class="AjaxSearchPositionTableCode">'+this.markElement(list['code'])+'</td><td style="width:20%" align="center" class="AjaxSearchPositionTablePrice">'+list['on_stock']+'</td><td style="width:40%" align="right" class="AjaxSearchPositionTablePrice">'+list['purchase_price']+' '+list['currency_symbol']+'<span style="color:black"> - </span><b>'+list['selling_price']+' '+list['currency_symbol']+'</b></td></tr><tr><td colspan="3" class="AjaxSearchPositionTableName">'+this.markElement(list['name'])+'</td></tr></table>';
|
||||
this.divList.appendChild(position);
|
||||
if((position.offsetTop+position.offsetHeight) > 300) this.divList.style.height = '300px'; else this.divList.style.height = '';
|
||||
}
|
||||
|
||||
this.markElement = function(str) {
|
||||
var s = "("+this.inputSearch.value+")";
|
||||
var regExp = new RegExp(s,'gi');
|
||||
return str.replace(regExp,"<b>$1</b>");
|
||||
}
|
||||
|
||||
this.AjaxSearchFrozen = false;
|
||||
this.AjaxSearchGetSettings = function () {
|
||||
var AjaxSearchToReq = this;
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'index.php',
|
||||
{
|
||||
success: function(response) {
|
||||
if(response.responseText) {
|
||||
var str = response.responseText;
|
||||
var obj = eval(str);
|
||||
if(obj && obj[0]) {
|
||||
obj = obj[0];
|
||||
//if(obj.frozen) {
|
||||
AjaxSearchToReq.div.style.left = obj.pos_left;
|
||||
AjaxSearchToReq.div.style.top = obj.pos_top;
|
||||
AjaxSearchToReq.AjaxSearchFrozen = !(obj.frozen == "true" ? true : false);
|
||||
AjaxSearchToReq.AjaxSearchFreezePosition(true);
|
||||
//}
|
||||
}
|
||||
}
|
||||
},
|
||||
failure: function(response) {}
|
||||
},
|
||||
'module=Home&action=EcmAjaxSearchSettings&function=GetSettings&to_pdf=1&from_module='+this.module
|
||||
);
|
||||
}
|
||||
this.AjaxSearchSaveSettings = function () {
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'index.php',
|
||||
{
|
||||
success: function(response) {},
|
||||
failure: function(response) {}
|
||||
},
|
||||
'module=Home&action=EcmAjaxSearchSettings&function=SaveSettings&to_pdf=1&from_module='+this.module+'&pos_top='+this.div.style.top+'&pos_left='+this.div.style.left+'&frozen='+this.AjaxSearchFrozen
|
||||
);
|
||||
}
|
||||
this.AjaxSearchFreezePosition = function (dontSave) {
|
||||
var img = document.getElementById('AjaxSearchPin');
|
||||
if(this.AjaxSearchFrozen) {
|
||||
img.src='modules/'+this.module+'/AjaxSearch/AjaxSearchPinOff.gif';
|
||||
this.AjaxSearchFrozen = false;
|
||||
} else {
|
||||
img.src='modules/'+this.module+'/AjaxSearch/AjaxSearchPinOn.gif';
|
||||
this.AjaxSearchFrozen = true;
|
||||
}
|
||||
if(!dontSave) this.AjaxSearchSaveSettings();
|
||||
}
|
||||
|
||||
this.createForm = function() {
|
||||
/*
|
||||
var div = document.createElement('div');
|
||||
div.className = 'AjaxSearch';
|
||||
div.AjaxSearch = this;
|
||||
*/
|
||||
var tmp = document.createElement('div');
|
||||
var div = "<div></div>";
|
||||
tmp.innerHTML = div;
|
||||
div = tmp.firstChild;
|
||||
|
||||
div.className = 'AjaxSearch';
|
||||
div.AjaxSearch = this;
|
||||
div.onMouseMoveEvent = function(ev) {
|
||||
if(!this.isOnMouseDown) return;
|
||||
ev = ev || window.event;
|
||||
var x = 0; var y = 0;
|
||||
if(ev.pageX || ev.pageY) {
|
||||
x = ev.pageX;
|
||||
y = ev.pageY;
|
||||
} else {
|
||||
x = ev.clientX + document.body.scrollLeft - document.body.clientLeft,
|
||||
y = ev.clientY + document.body.scrollTop - document.body.clientTop
|
||||
}
|
||||
this.style.left = x-this.MouseX;
|
||||
this.style.top = y-this.MouseY;
|
||||
}
|
||||
div.onMouseDownEvent = function(ev) {
|
||||
if(this.noDrag) { this.noDrag = false; return; }
|
||||
ev = ev || window.event;
|
||||
var x = 0; var y = 0;
|
||||
if(ev.pageX || ev.pageY) {
|
||||
x = ev.pageX;
|
||||
y = ev.pageY;
|
||||
} else {
|
||||
x = ev.clientX + document.body.scrollLeft - document.body.clientLeft,
|
||||
y = ev.clientY + document.body.scrollTop - document.body.clientTop
|
||||
}
|
||||
this.MouseX = x-this.offsetLeft;
|
||||
this.MouseY = y-this.offsetTop;
|
||||
this.isOnMouseDown = true;
|
||||
this.style.cursor = 'move';
|
||||
}
|
||||
div.onmouseup = function() {
|
||||
this.isOnMouseDown = false;
|
||||
this.style.cursor = '';
|
||||
//this.AjaxSearch.AjaxSearchSaveSettings();
|
||||
}
|
||||
//div.onmouseout = function() { this.onmouseup(); }
|
||||
ddiv = document.createElement('div');
|
||||
ddiv.id = 'AjaxSearch_ddiv';
|
||||
ddiv.className = 'AjaxSearch_ddiv';
|
||||
ddiv.appendChild(document.createTextNode('Search Product:'));
|
||||
ddiv.appendChild(document.createElement('br'));
|
||||
div.appendChild(ddiv);
|
||||
/*
|
||||
var inputSearch = document.createElement('input');
|
||||
inputSearch.type = 'text';
|
||||
inputSearch.id = 'as_inputSearch';
|
||||
inputSearch.className = 'AjaxSearchInputSearch';
|
||||
inputSearch.AjaxSearch = this;
|
||||
inputSearch.onkeydown = this.inputSearchOnKeyDown;
|
||||
this.inputSearch = inputSearch;
|
||||
div.appendChild(inputSearch);
|
||||
*/
|
||||
var img = '<img src="modules/'+this.module+'/AjaxSearch/AjaxSearchPinOff.gif" id="AjaxSearchPin" class="AjaxSearchPin" onclick="this.parentNode.AjaxSearch.AjaxSearchFreezePosition();" />';
|
||||
img += '<img src="modules/'+this.module+'/AjaxSearch/AjaxSearchCloseIcon.gif" class="AjaxSearchCloseIcon" onclick="this.parentNode.AjaxSearch.inputSearchOnKeyDown(27);" />';
|
||||
div.innerHTML += img;
|
||||
|
||||
|
||||
var inputSearch = '<input type="text" id="as_inputSearch" class="AjaxSearchInputSearch" onKeyDown="return this.AjaxSearch.inputSearchOnKeyDown(event);">';
|
||||
div.innerHTML = div.innerHTML + inputSearch;
|
||||
this.inputSearch = div.lastChild;
|
||||
this.inputSearch.AjaxSearch = this;
|
||||
this.inputSearch.onmousedown = function() { this.parentNode.noDrag = true; }
|
||||
|
||||
div.appendChild(document.createElement('br'));
|
||||
div.appendChild(document.createElement('br'));
|
||||
|
||||
/*
|
||||
div.appendChild(document.createTextNode('List:'));
|
||||
|
||||
var separator = document.createElement('hr');
|
||||
separator.className = 'AjaxSearchSeparator';
|
||||
div.appendChild(separator);
|
||||
*/
|
||||
|
||||
var divList = document.createElement('div');
|
||||
|
||||
divList.id = 'as_divList';
|
||||
divList.className = 'AjaxSearchDivList';
|
||||
divList.AjaxSearch = this;
|
||||
this.divList = divList;
|
||||
divList.onmousedown = function() { this.parentNode.noDrag = true; }
|
||||
div.appendChild(divList);
|
||||
|
||||
var tmpDiv = document.createElement('div');
|
||||
tmpDiv.style.height = '10px';
|
||||
div.appendChild(tmpDiv);
|
||||
|
||||
this.parentDIV.appendChild(div);
|
||||
this.div = div;
|
||||
|
||||
}
|
||||
|
||||
this.KeyDown = function(e) {
|
||||
|
||||
var keynum;
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//constructor
|
||||
|
||||
if(AjaxSearchItems) {
|
||||
if(typeof(AjaxSearchItems) == "number")
|
||||
AjaxSearchItem++;
|
||||
else
|
||||
AjaxSearchItem = 0;
|
||||
this.ajaxSearchItem = AjaxSearchItem;
|
||||
}
|
||||
|
||||
this.createForm();
|
||||
|
||||
this.div.AjaxSearch = this;
|
||||
this.div.id = 'AjaxSearch_'+this.AjaxSearchItem;
|
||||
var AjaxSearch_draganddrop = new YAHOO.util.DD(this.div.id);
|
||||
AjaxSearch_draganddrop.AjaxSearch = this;
|
||||
AjaxSearch_draganddrop.endDrag = function(e) {
|
||||
this.AjaxSearch.AjaxSearchSaveSettings();
|
||||
};
|
||||
AjaxSearch_draganddrop.setHandleElId("AjaxSearch_ddiv");
|
||||
this.div.style.left = (screen.availWidth - this.div.offsetWidth) / 2;
|
||||
this.div.style.top = (screen.availHeight - this.div.offsetHeight) / 2;
|
||||
if(displayNone == true) this.div.style.display = 'none';
|
||||
this.AjaxSearchGetSettings();
|
||||
|
||||
|
||||
};
|
||||
2843
modules/EcmReceipts2/EcmReceipts.js
Executable file
2843
modules/EcmReceipts2/EcmReceipts.js
Executable file
File diff suppressed because it is too large
Load Diff
851
modules/EcmReceipts2/EcmReceiptsDetailView.js
Executable file
851
modules/EcmReceipts2/EcmReceiptsDetailView.js
Executable file
@@ -0,0 +1,851 @@
|
||||
//add mz 2013-04-18
|
||||
function register_print() {
|
||||
doRequest('index.php', "module=EcmReceipts&action=create_print_request&to_pdf=1&record=" + document.forms.DetailView.record.value,
|
||||
function(result) {
|
||||
alert('printed = 1');
|
||||
}
|
||||
);
|
||||
}
|
||||
//end mz
|
||||
|
||||
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, call_back_function, form_name) {
|
||||
|
||||
if (!call_back_function)
|
||||
call_back_function = "set_return";
|
||||
|
||||
if (!form_name)
|
||||
form_name = "EditView";
|
||||
|
||||
return open_popup(module, 600, 400, "", 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 ItemListClear() {
|
||||
|
||||
while (N.rowCount() > 0)
|
||||
N.row(0).deleteRow();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
//initialize table
|
||||
|
||||
N = new MyTable('itemsTable');
|
||||
|
||||
|
||||
N.onRefreshRowIndex = function(row) {
|
||||
|
||||
var data = new Object();
|
||||
|
||||
data['index'] = (row.index + 1).toString();
|
||||
|
||||
row.cells.item(0).setData(data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
N.onCreateRow = function(row) {
|
||||
|
||||
row.newPos = false;
|
||||
|
||||
row.ondblclick = function() {
|
||||
|
||||
|
||||
|
||||
this.newPos = !this.newPos;
|
||||
|
||||
|
||||
|
||||
var img = this.cells.item(1).getElementsByTagName('img');
|
||||
|
||||
if (!this.newPos)
|
||||
img[0].src = "modules/EcmReceipts/images/edit.gif";
|
||||
|
||||
else
|
||||
img[0].src = "modules/EcmReceipts/images/editset.gif";
|
||||
|
||||
|
||||
|
||||
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() {
|
||||
var data = new Object();
|
||||
this.cells.item(3).getData(data, true);
|
||||
this.cells.item(4).getData(data, true);
|
||||
this.cells.item(5).getData(data, true);
|
||||
this.cells.item(6).getData(data, true);
|
||||
this.cells.item(7).getData(data, true);
|
||||
this.cells.item(8).getData(data, true);
|
||||
this.cells.item(9).getData(data, true);
|
||||
//this.cells.item(10).getData(data,true);
|
||||
// this.cells.item(11).getData(data,true);
|
||||
// this.cells.item(12).getData(data,true);
|
||||
|
||||
//calculate selling_price
|
||||
if (data.price) {
|
||||
if (data.discount)
|
||||
data.selling_price = (data.price - (data.price * data.discount / 100)).toFixed(2);
|
||||
else
|
||||
data.selling_price = (data.price).toFixed(2);
|
||||
}
|
||||
else
|
||||
data.selling_price = 0;
|
||||
//calculate total
|
||||
if (data.price && data.quantity)
|
||||
data.total = (data.price * data.quantity).toFixed(2);
|
||||
else
|
||||
data.total = 0;
|
||||
//alert(data.total+' '+data.price+' '+data.quantity);
|
||||
this.cells.item(9).setData(data);
|
||||
this.cells.item(6).setData(data);
|
||||
calculateTotal();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
N.onCreateCell = function(cell) {
|
||||
|
||||
|
||||
|
||||
var i = cell.index;
|
||||
cell.change = function(select) {
|
||||
};
|
||||
//cell.style.height = OPT['row_item_height'];
|
||||
cell.style.height = 50;
|
||||
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_name = 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_name)
|
||||
cn[2].value = data.unit_name;
|
||||
|
||||
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']);
|
||||
unit_id.setAttribute('value', 'TMP');
|
||||
|
||||
cell.appendChild(unit_id);
|
||||
|
||||
var vat_id = document.createElement('input');
|
||||
|
||||
vat_id.setAttribute('type', 'hidden');
|
||||
|
||||
//vat_id.setAttribute('value',OPT['default_vat']);
|
||||
vat_id.setAttribute('value', '23');
|
||||
|
||||
cell.appendChild(vat_id);
|
||||
|
||||
var category_id = document.createElement('input');
|
||||
|
||||
category_id.setAttribute('type', 'hidden');
|
||||
|
||||
category_id.setAttribute('value', '');
|
||||
|
||||
cell.appendChild(category_id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (i == 2) {
|
||||
|
||||
|
||||
|
||||
cell.getData = function(data) {
|
||||
|
||||
var cn = this.getElementsByTagName('textarea');
|
||||
|
||||
data.name = cn[0].value;
|
||||
|
||||
}
|
||||
|
||||
cell.setData = function(data) {
|
||||
|
||||
var cn = this.getElementsByTagName('textarea');
|
||||
|
||||
if (data.name)
|
||||
cn[0].value = data.name;
|
||||
|
||||
}
|
||||
|
||||
var textarea = '<textarea tabindex="1" readonly="readonly" style="height:100%" class="inputs"></textarea>';
|
||||
|
||||
cell.innerHTML = textarea;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (i == 3) {
|
||||
|
||||
|
||||
|
||||
cell.getData = function(data, noAlert) {
|
||||
|
||||
var tmp = UserFormatNumberToNumber(this.firstChild.value);
|
||||
|
||||
if (tmp == -1) {
|
||||
|
||||
ERROR = true;
|
||||
|
||||
//if(!noAlert)
|
||||
|
||||
//alert(MOD['LBL_FORMAT_NUMBER_ERROR']+' ('+this.firstChild.value+')');
|
||||
|
||||
data.quantity = 0;
|
||||
|
||||
this.firstChild.style.color = 'red';
|
||||
|
||||
} else {
|
||||
|
||||
data.quantity = tmp;
|
||||
|
||||
this.firstChild.style.color = 'black';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cell.setData = function(data) {
|
||||
|
||||
if (data.quantity)
|
||||
this.firstChild.value = NumberToUserFormatNumber(data.quantity);
|
||||
else
|
||||
this.firstChild.value = NumberToUserFormatNumber(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" style="text-align:right;" autocomplete="off" class="inputs" value="' + NumberToUserFormatNumber(1) + '">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
|
||||
}
|
||||
|
||||
if (i == 4) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
data.unit_id = this.firstChild.value;
|
||||
}
|
||||
cell.setData = function(data) {
|
||||
this.firstChild.value = data.unit_id;
|
||||
}
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="">';
|
||||
cell.innerHTML = edit;
|
||||
}
|
||||
if (i == 5) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
|
||||
}
|
||||
cell.setData = function(data) {
|
||||
var value;
|
||||
if ((data.price) && (data.discount))
|
||||
value = (100 * data.price) / (100 - data.discount);
|
||||
else
|
||||
if ((data.price) && !(data.discount))
|
||||
value = data.price;
|
||||
else
|
||||
value = 0;
|
||||
|
||||
|
||||
this.firstChild.value = NumberToUserFormatNumber(value);
|
||||
}
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="0">';
|
||||
cell.innerHTML = edit;
|
||||
}
|
||||
|
||||
if (i == 6) {
|
||||
|
||||
cell.getData = function(data, noAlert) {
|
||||
|
||||
var tmp = UserFormatNumberToNumber(this.firstChild.value, '%');
|
||||
|
||||
if (tmp == -1) {
|
||||
|
||||
ERROR = true;
|
||||
|
||||
if (!noAlert)
|
||||
alert(MOD['LBL_FORMAT_NUMBER_ERROR'] + ' (' + this.firstChild.value + ')');
|
||||
|
||||
data.discount = 0;
|
||||
|
||||
this.firstChild.style.color = 'red';
|
||||
|
||||
} else {
|
||||
|
||||
data.discount = tmp;
|
||||
|
||||
this.firstChild.style.color = 'black';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cell.setData = function(data) {
|
||||
|
||||
if (data.discount)
|
||||
this.firstChild.value = NumberToUserFormatNumber(data.discount, '%');
|
||||
else
|
||||
this.firstChild.value = NumberToUserFormatNumber(0, '%');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
cell.selectNext = function() {
|
||||
var row = this.parentNode.selectNext();
|
||||
row.select();
|
||||
row.cells.item(0).select();
|
||||
};
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0, '%') + '">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
|
||||
}
|
||||
if (i == 7) {
|
||||
|
||||
|
||||
|
||||
cell.getData = function(data, noAlert) {
|
||||
|
||||
var tmp = UserFormatNumberToNumber(this.firstChild.value);
|
||||
|
||||
if (tmp == -1) {
|
||||
|
||||
ERROR = true;
|
||||
|
||||
if (!noAlert)
|
||||
alert(MOD['LBL_FORMAT_NUMBER_ERROR'] + ' (' + this.firstChild.value + ')');
|
||||
|
||||
data.price = 0;
|
||||
|
||||
this.firstChild.style.color = 'red';
|
||||
|
||||
} else {
|
||||
|
||||
data.price = tmp;
|
||||
|
||||
this.firstChild.style.color = 'black';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cell.setData = function(data) {
|
||||
|
||||
//data.price = 1999;
|
||||
//alert(data.price);
|
||||
|
||||
if (data.price)
|
||||
this.firstChild.value = NumberToUserFormatNumber(data.price);
|
||||
else
|
||||
this.firstChild.value = NumberToUserFormatNumber(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0) + '">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (i == 8) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
data.vat_value = cn[0].value;
|
||||
data.vat_id = cn[1].value;
|
||||
if (VAT[cn[1].value])
|
||||
data.vat_name = VAT[cn[1].value].name;
|
||||
}
|
||||
cell.setData = function(data) {
|
||||
if (data.vat_value)
|
||||
this.getElementsByTagName('input')[0].value = data.vat_value;
|
||||
if (data.vat_id)
|
||||
this.getElementsByTagName('input')[1].value = data.vat_id;
|
||||
if (data.vat_name)
|
||||
this.getElementsByTagName('input')[2].value = data.vat_name;
|
||||
}
|
||||
cell.onDeselect = function() {
|
||||
ERROR = false;
|
||||
var data = new Object();
|
||||
this.getData(data);
|
||||
if (!ERROR) {
|
||||
data.vat_id = data.vat_id;
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
var inp = document.createElement('input');
|
||||
inp.setAttribute('type', 'hidden');
|
||||
cell.appendChild(inp);
|
||||
|
||||
var inp = document.createElement('input');
|
||||
inp.setAttribute('type', 'hidden');
|
||||
cell.appendChild(inp);
|
||||
|
||||
|
||||
var inp;
|
||||
|
||||
inp = document.createElement('input');
|
||||
inp.setAttribute('type', 'text');
|
||||
inp.className = 'inputs';
|
||||
inp.style.textAlign = "right";
|
||||
inp.cell = cell;
|
||||
cell.appendChild(inp);
|
||||
|
||||
}
|
||||
|
||||
if (i == 9) {
|
||||
|
||||
//cell.select = function() { };
|
||||
|
||||
cell.getData = function(data) {
|
||||
|
||||
var cn = this.getElementsByTagName('input');
|
||||
|
||||
data.total = UserFormatNumberToNumber(cn[0].value);
|
||||
data.subtotal = UserFormatNumberToNumber(cn[1].value);
|
||||
|
||||
}
|
||||
|
||||
cell.setData = function(data) {
|
||||
|
||||
var cn = this.getElementsByTagName('input');
|
||||
|
||||
if (data.total)
|
||||
cn[0].value = NumberToUserFormatNumber(data.total);
|
||||
else
|
||||
cn[0].value = NumberToUserFormatNumber(0);
|
||||
|
||||
if (data.subtotal)
|
||||
cn[1].value = NumberToUserFormatNumber(data.subtotal);
|
||||
else
|
||||
cn[1].value = NumberToUserFormatNumber(0);
|
||||
|
||||
}
|
||||
|
||||
var edit = document.createElement('input');
|
||||
|
||||
edit.setAttribute('type', 'text');
|
||||
|
||||
edit.setAttribute('value', NumberToUserFormatNumber(0));
|
||||
|
||||
edit.setAttribute('readOnly', 'readonly');
|
||||
|
||||
edit.className = 'inputs';
|
||||
|
||||
edit.style.textAlign = "right";
|
||||
|
||||
cell.appendChild(edit);
|
||||
|
||||
|
||||
var edit = document.createElement('input');
|
||||
|
||||
edit.setAttribute('hidden', 'hidden');
|
||||
edit.setAttribute('type', 'text');
|
||||
|
||||
edit.setAttribute('value', NumberToUserFormatNumber(0));
|
||||
|
||||
edit.setAttribute('readOnly', 'readonly');
|
||||
|
||||
edit.className = 'inputs';
|
||||
|
||||
edit.style.textAlign = "right";
|
||||
|
||||
cell.appendChild(edit);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
N.onSetCellData = function(row, cell, data) {
|
||||
|
||||
if (cell.innerHTML == '')
|
||||
cell.innerHTML = ' ';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var pl = document.getElementById('position_list').value;
|
||||
|
||||
if (pl && pl != '') {
|
||||
|
||||
try {
|
||||
|
||||
pl = eval(pl);
|
||||
|
||||
for (x in pl) {
|
||||
if (typeof(pl[x].code) != "undefined") {
|
||||
var pl_row = pl[x];
|
||||
N.addRow().setData(pl_row);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
pl = null;
|
||||
}
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (N.rowCount() == 0)
|
||||
N.addRow();
|
||||
|
||||
|
||||
calculateTotal = function() {
|
||||
var vats = new Object();
|
||||
var subtotal = 0;
|
||||
var total = 0;
|
||||
//var cbm_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 - data.subtotal;
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(data);
|
||||
|
||||
subtotal += data.subtotal;
|
||||
total += data.total;
|
||||
//cbm_total += data.cbm;
|
||||
}
|
||||
|
||||
// console.log(total, subtotal);
|
||||
// return;
|
||||
|
||||
// total = subtotal;
|
||||
|
||||
var rt = document.getElementById('result_table');
|
||||
|
||||
for (var i = 1; i < rt.rows.length - 4; i++) {
|
||||
if (!vats[rt.rows.item(i).id]) {
|
||||
rt.deleteRow(i);
|
||||
--i;
|
||||
} else
|
||||
vats[rt.rows.item(i).id]['node'] = rt.rows.item(i);
|
||||
}
|
||||
|
||||
console.log(vats);
|
||||
|
||||
for (var x in vats) {
|
||||
// console.log(x, vats[x]);
|
||||
|
||||
// continue;return;
|
||||
|
||||
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('subtotal').value = NumberToUserFormatNumber(subtotal);
|
||||
|
||||
if (document.getElementById('total_2'))
|
||||
document.getElementById('total_2').value = total2;
|
||||
|
||||
// document.getElementById('discount_2').value = discount2;
|
||||
document.getElementById('total').value = total;
|
||||
//document.getElementById('cbm_total').value = cbm_total;
|
||||
}
|
||||
|
||||
|
||||
|
||||
calculateTotal();
|
||||
|
||||
|
||||
function HideLoadingView() {
|
||||
var slv = document.getElementById('ShowLoadingView');
|
||||
if (slv)
|
||||
slv.style.display = 'none';
|
||||
}
|
||||
|
||||
setPREVIEW = function() {
|
||||
console.log(1);
|
||||
//EcmPreviewPDF('index.php?module=EcmQuotes&action=previewPDF&to_pdf=1&method=I&record='+document.forms.DetailView.record.value,{zoom:75});
|
||||
|
||||
var type = document.getElementById('preview_type').value;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
type = '';
|
||||
break;
|
||||
case 'inv':
|
||||
type = 'inv';
|
||||
break;
|
||||
case 'exp':
|
||||
type = 'exp';
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(type);
|
||||
|
||||
if (SHOW_PDF_IN_DIV == 1) {
|
||||
HideLoadingView();
|
||||
//SetTab('preview_PREVIEW');
|
||||
EcmPreviewPDF('index.php?module=EcmReceipts&action=previewPDF&to_pdf=1&method=I&record=' + document.forms.DetailView.record.value + '&type=' + type, {zoom: 75});
|
||||
}
|
||||
else {
|
||||
SetTab('panel_PREVIEW');
|
||||
|
||||
document.getElementById('previewPDF').innerHTML = '<iframe style="border:none;width:100%;height:1200px;" frameborder="no" src="index.php?module=EcmReceipts&action=previewPDF&to_pdf=1&method=I&record=' + document.forms.DetailView.record.value + '&type=' + type + '#zoom=75">Yours browser not accept iframes!</iframe>';
|
||||
}
|
||||
}
|
||||
|
||||
setEMAIL = function(noCheck) {
|
||||
SetTab('panel_EMAIL');
|
||||
|
||||
document.getElementById('emailTAB').innerHTML = '<iframe id="emailIFRAME" style="border:none;width:100%;height:670px;" frameborder="no" src="index.php?module=EcmReceipts&action=Emails&to_pdf=1&type=out&pTypeTo=' + document.forms.DetailView.parent_type.value + '&pIdTo=' + document.forms.DetailView.parent_id.value + '&pTypeFrom=Users&pIdFrom=' + document.forms.DetailView.assigned_user_id.value + '&receipt_id=' + document.forms.DetailView.record.value + '&record=' + document.forms.DetailView.email_id.value + '&type=' + type + '">Yours browser not accept iframes!</iframe>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
setInterval(function() {
|
||||
doRequest('index.php', "module=EcmReceipts&action=subpanels&to_pdf=1&record=" + document.forms.DetailView.record.value,
|
||||
function(result) {
|
||||
if (result != '' && document.getElementById('subpanels_div'))
|
||||
document.getElementById('subpanels_div').innerHTML = result;
|
||||
}
|
||||
);
|
||||
},
|
||||
10000
|
||||
);
|
||||
|
||||
|
||||
//quick view
|
||||
var main = document.getElementById('main');
|
||||
|
||||
if (main) {
|
||||
var h2 = main.getElementsByTagName('h2')[0];
|
||||
if (h2) {
|
||||
h2.style.display = 'inline';
|
||||
var quickInfoH2 = document.getElementById('quickInfoH2');
|
||||
if (quickInfoH2) {
|
||||
h2.parentNode.appendChild(quickInfoH2);
|
||||
quickInfoH2.style.display = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OPT['setTab'] && OPT['setTab'] != '') {
|
||||
if (OPT['setTab'] == 'EMAIL')
|
||||
setEMAIL();
|
||||
}
|
||||
|
||||
for (var i = 0; i < N.rowCount(); i++) {
|
||||
N.row(i).calculateTotal();
|
||||
}
|
||||
}
|
||||
);
|
||||
1018
modules/EcmReceipts2/Email.js
Executable file
1018
modules/EcmReceipts2/Email.js
Executable file
File diff suppressed because it is too large
Load Diff
2316
modules/EcmReceipts2/MyTable.js
Executable file
2316
modules/EcmReceipts2/MyTable.js
Executable file
File diff suppressed because it is too large
Load Diff
278
modules/EcmReceipts2/PDFLanguages.js
Executable file
278
modules/EcmReceipts2/PDFLanguages.js
Executable file
@@ -0,0 +1,278 @@
|
||||
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, call_back_function, form_name) {
|
||||
if (!call_back_function)
|
||||
call_back_function = "set_return";
|
||||
|
||||
if (!form_name)
|
||||
form_name = "EditView";
|
||||
|
||||
return open_popup(module, 600, 400, "", 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);
|
||||
}
|
||||
}
|
||||
|
||||
var tbody_;
|
||||
var ItemListSave;
|
||||
var ItemListClear;
|
||||
var ItemListFil;
|
||||
var FillText;
|
||||
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
var PDFLanguagesTable = new PDFLanguagesMT('PDFLanguagesTable');
|
||||
|
||||
PDFLanguagesTable.onRefreshRowIndex = function(row) {
|
||||
var data = new Object();
|
||||
|
||||
data['index'] = (row.index + 1).toString();
|
||||
|
||||
row.cells.item(0).setData(data);
|
||||
};
|
||||
|
||||
PDFLanguagesTable.onCreateRow = function(row) {
|
||||
row.newPos = false;
|
||||
row.noAddNew = true;
|
||||
|
||||
row.ondblclick = function() {
|
||||
};
|
||||
|
||||
row.onSelect = function() {
|
||||
for (var i = 0; i < this.myTable.colCount(); i++)
|
||||
this.cells.item(i).change(!this.newPos);
|
||||
};
|
||||
|
||||
row.onDeselect = function() {
|
||||
for (var i = 0; i < this.myTable.colCount(); i++)
|
||||
this.cells.item(i).change(false);
|
||||
};
|
||||
};
|
||||
|
||||
PDFLanguagesTable.onCreateCell = function(cell) {
|
||||
var i = cell.index;
|
||||
|
||||
cell.change = function(select) {
|
||||
};
|
||||
|
||||
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.change = function(select) {
|
||||
};
|
||||
|
||||
cell.getData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
|
||||
data.label = cn[0].value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
|
||||
if (data.label)
|
||||
cn[0].value = data.label;
|
||||
};
|
||||
|
||||
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 == 2) {
|
||||
cell.noNewAdd = true;
|
||||
|
||||
cell.getData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
|
||||
data.translation = cn[0].value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
|
||||
if (data.translation)
|
||||
cn[0].value = data.translation;
|
||||
};
|
||||
|
||||
var edit = '<input type="text" onFocus="this.parentNode.select();" tabindex="1" class="inputs" style="height:16px;" autocomplete="off" onKeyDown="return this.parentNode.myTable.KeyPressed(event,this.parentNode);">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
}
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
PDFLanguagesTable.onSetCellData = function(row, cell, data) {
|
||||
if (cell.innerHTML == '')
|
||||
cell.innerHTML = ' ';
|
||||
};
|
||||
|
||||
ItemListSave = function(json, el) {
|
||||
var data = new Object();
|
||||
var tmp;
|
||||
var ecmlanguage = document.getElementById('ecmlanguage').value;
|
||||
|
||||
if (typeof(el) == "string")
|
||||
ecmlanguage = el;
|
||||
|
||||
if (!PDFLanguagesOptions.ecmlanguage)
|
||||
PDFLanguagesOptions.ecmlanguage = new Object();
|
||||
|
||||
for (var i = 0; i < PDFLanguagesTable.rowCount(); i++) {
|
||||
data[i.toString()] = PDFLanguagesTable.row(i).getData();
|
||||
}
|
||||
|
||||
PDFLanguagesOptions['ecmlanguage'][ecmlanguage]['labels'] = data;
|
||||
|
||||
FillText('header', document.getElementById('header_parent'));
|
||||
FillText('footer', document.getElementById('footer_parent'));
|
||||
FillText('ads', document.getElementById('ads_parent'));
|
||||
|
||||
if (json) {
|
||||
var r = JSON.stringifyNoSecurity(PDFLanguagesOptions['ecmlanguage']);
|
||||
|
||||
doRequest(
|
||||
'index.php',
|
||||
'module=EcmReceipts&action=PDFLanguagesSave&to_pdf=1&ecmlanguage=' + document.getElementById('ecmlanguage').value + '&pdflanguagelist=' + r,
|
||||
function(result) {
|
||||
if (result.indexOf("Saved") >= 0)
|
||||
alert("Saving done!");
|
||||
else
|
||||
alert("Error with saving!");
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
ItemListClear = function(noNew, save) {
|
||||
if (typeof(save) == "string")
|
||||
ItemListSave(null, save);
|
||||
|
||||
while (PDFLanguagesTable.rowCount() > 0)
|
||||
PDFLanguagesTable.row(0).deleteRow(noNew);
|
||||
};
|
||||
|
||||
ItemListFill = function() {
|
||||
var ecmlanguage = document.getElementById('ecmlanguage').value;
|
||||
var pl;
|
||||
|
||||
if (PDFLanguagesOptions && PDFLanguagesOptions.ecmlanguage && PDFLanguagesOptions['ecmlanguage'][ecmlanguage]) {
|
||||
pl = PDFLanguagesOptions['ecmlanguage'][ecmlanguage]['labels'];
|
||||
}
|
||||
|
||||
console.log(ecmlanguage);
|
||||
console.log(pl);
|
||||
|
||||
FillText('header', document.getElementById('header_parent'));
|
||||
FillText('footer', document.getElementById('footer_parent'));
|
||||
FillText('ads', document.getElementById('ads_parent'));
|
||||
|
||||
if (pl && pl != '') {
|
||||
try {
|
||||
pl = eval(pl);
|
||||
|
||||
for (x in pl) {
|
||||
var pl_row = pl[x];
|
||||
PDFLanguagesTable.addRow().setData(pl_row);
|
||||
}
|
||||
} catch (err) {
|
||||
pl = null;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('ecmlanguage').lastSelected = document.getElementById('ecmlanguage').value;
|
||||
//if(PDFLanguagesTable.rowCount() == 0) PDFLanguagesTable.addRow();
|
||||
};
|
||||
|
||||
FillText = function(name, parent) {
|
||||
var text = document.getElementById(name + '_text');
|
||||
var el = document.getElementById('ecmlanguage');
|
||||
|
||||
if (!parent.lastSelected) {
|
||||
parent.lastSelected = parent.value;
|
||||
parent.lastSelectedEcmLanguage = el.value;
|
||||
} else {
|
||||
//PDFLanguagesOptions['ecmlanguage'][parent.lastSelectedEcmLanguage]['texts'][parent.lastSelected][name + '_text'] = text.value;
|
||||
}
|
||||
|
||||
//text.value = PDFLanguagesOptions['ecmlanguage'][el.value]['texts'][parent.value][name + '_text'];
|
||||
|
||||
parent.lastSelected = parent.value;
|
||||
parent.lastSelectedEcmLanguage = el.value;
|
||||
};
|
||||
|
||||
//PDFLanguagesTable.addRow();
|
||||
ItemListFill();
|
||||
}
|
||||
);
|
||||
371
modules/EcmReceipts2/PDFLanguagesMT.js
Executable file
371
modules/EcmReceipts2/PDFLanguagesMT.js
Executable file
@@ -0,0 +1,371 @@
|
||||
|
||||
|
||||
function keyPressedNumber(e) {
|
||||
var keynum;
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
return keynum;
|
||||
}
|
||||
|
||||
function isEnterOrTabPressed(e) {
|
||||
var keynum = keyPressedNumber(e);
|
||||
if(keynum == 9 || keynum == 13) return true; else return false;
|
||||
}
|
||||
|
||||
function setSelectionRange(obj) {
|
||||
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
|
||||
if(obj.createTextRange) {
|
||||
var range = obj.createTextRange();
|
||||
range.moveStart("character", 0);
|
||||
range.moveEnd("character", obj.value.lengh-1);
|
||||
range.select();
|
||||
} else {
|
||||
if(obj.setSelectionRange) {
|
||||
obj.setSelectionRange(0,obj.value.length);
|
||||
}
|
||||
}
|
||||
obj.focus();
|
||||
}
|
||||
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
|
||||
|
||||
}
|
||||
|
||||
function PDFLanguagesMT(name) {
|
||||
|
||||
this.myTableName = name;
|
||||
this.table = document.getElementById(this.myTableName);
|
||||
|
||||
this.thead = this.table.tHead;
|
||||
this.tbody = this.table.tBodies.item(0);
|
||||
|
||||
this.cellSelectedClass = 'selectedCell';
|
||||
this.rowSelectedClass = 'selectedRow';
|
||||
|
||||
this.selectedRow;
|
||||
this.selectedCell;
|
||||
|
||||
this.rowCount = function() {
|
||||
return this.tbody.rows.length;
|
||||
}
|
||||
|
||||
this.colCount = function() {
|
||||
return this.thead.rows.item(0).cells.length;
|
||||
};
|
||||
|
||||
this.colWidth = function(i) {
|
||||
return this.thead.rows.item(0).cells.item(i).width;
|
||||
};
|
||||
|
||||
this.moveUpRow = function() {
|
||||
if(this.selectedRow) this.selectedRow.moveUp();
|
||||
};
|
||||
|
||||
this.moveDownRow = function() {
|
||||
if(this.selectedRow) this.selectedRow.moveDown();
|
||||
};
|
||||
|
||||
this.insertRow = function(row, newRow) {
|
||||
if(!row)
|
||||
if(this.rowCount())
|
||||
if(typeof(row) == "number")
|
||||
row = this.tbody.rows.item(row);
|
||||
else
|
||||
row = this.tbody.rows.item(this.tbody.rows.length-1);
|
||||
|
||||
var row_tmp;
|
||||
if((newRow) && (row)) row_tmp = newRow; else { row_tmp = this.createRow(); this.fillWithDefaultData(row_tmp); }
|
||||
|
||||
if(this.rowCount() > 0 && row.nextSibling)
|
||||
this.tbody.insertBefore(row_tmp, row.nextSibling);
|
||||
else
|
||||
this.tbody.appendChild(row_tmp);
|
||||
|
||||
return row_tmp;
|
||||
};
|
||||
|
||||
this.refreshRowIndex = function() {
|
||||
for(var i=0; i<this.rowCount(); i++) {
|
||||
this.tbody.rows.item(i).index = i;
|
||||
if(this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
|
||||
}
|
||||
}
|
||||
this.onRefreshRowIndex;
|
||||
|
||||
this.addRow = function(i,data) {
|
||||
var row = this.createRow();
|
||||
if(this.selectedRow) this.selectedRow.deselect();
|
||||
if(this.selectedCell) this.selectedCell.deselect();
|
||||
row.myTable = this;
|
||||
if(i || i===0)
|
||||
this.tbody.insertBefore(row,this.tbody.rows.item(i));
|
||||
else
|
||||
this.tbody.appendChild(row);
|
||||
this.refreshRowIndex();
|
||||
this.setRowData(row, data);
|
||||
for(var i=0; i<this.colCount(); i++) row.cells.item(i).afterCreate();
|
||||
return row;
|
||||
}
|
||||
|
||||
this.createRow = function(row) {
|
||||
var row = document.createElement('tr');
|
||||
row.myTable = this;
|
||||
row.isnew = false;
|
||||
row.onclick = function() { this.select(); }
|
||||
row.select = function() {
|
||||
if(!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
|
||||
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
|
||||
this.myTable.selectedRow = this;
|
||||
this.className = this.myTable.rowSelectedClass;
|
||||
if(row.onSelect) row.onSelect();
|
||||
}
|
||||
}
|
||||
row.deselect = function() {
|
||||
if(this.myTable.selectedRow === this) {
|
||||
this.className = '';
|
||||
this.myTable.selectedRow = '';
|
||||
if(row.onDeselect) row.onDeselect();
|
||||
}
|
||||
};
|
||||
|
||||
row.selectNext = function() {
|
||||
if(this.index < this.myTable.rowCount()-1) { this.deselect(); this.nextSibling.select(); return this.nextSibling; }
|
||||
else {
|
||||
if(this.noAddNew) return this;
|
||||
|
||||
this.deselect();
|
||||
var row = this.myTable.addRow(); return row;
|
||||
}
|
||||
}
|
||||
row.selectPrevious = function() {
|
||||
this.deselect();
|
||||
if(this.previousSibling && this.index > 0) { this.previousSibling.select(); return this.previousSibling; }else return this;
|
||||
}
|
||||
row.deleteRow = function(noNew) {
|
||||
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
|
||||
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
|
||||
if(this.myTable.rowCount() == 1 && !noNew) {
|
||||
var MyTaBlE = this.myTable;
|
||||
setTimeout( function() { MyTaBlE.addRow(); } , 1000);
|
||||
}
|
||||
this.myTable.tbody.removeChild(this);
|
||||
this.myTable.refreshRowIndex();
|
||||
}
|
||||
row.moveUp = function() {
|
||||
if(!this.previousSibling) return;
|
||||
this.myTable.tbody.insertBefore(this,this.previousSibling);
|
||||
this.myTable.refreshRowIndex();
|
||||
}
|
||||
row.moveDown = function() {
|
||||
if(!this.nextSibling) this.myTable.addRow(row);
|
||||
this.myTable.tbody.insertBefore(this.nextSibling,this);
|
||||
this.myTable.refreshRowIndex();
|
||||
}
|
||||
row.setData = function(data) {
|
||||
if(!data || typeof(data) != "object") { return; };
|
||||
for(var i=0; i<this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).setData(data);
|
||||
}
|
||||
}
|
||||
row.getData = function() {
|
||||
var data = new Object();
|
||||
for(var i=0; i<this.myTable.colCount(); i++) {
|
||||
if(this.cells.item(i).getData) this.cells.item(i).getData(data,true);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
for(var i=0; i<this.colCount(); i++) {
|
||||
var cell = this.createCell(i);
|
||||
row.appendChild(cell);
|
||||
}
|
||||
if(this.onCreateRow) this.onCreateRow(row);
|
||||
return row;
|
||||
|
||||
};
|
||||
|
||||
|
||||
this.onCreateRow; //function(row) {}
|
||||
|
||||
this.createCell = function(i) {
|
||||
var cell = document.createElement('td');
|
||||
cell.index = i;
|
||||
cell.myTable = this;
|
||||
cell.onclick = function() { this.select(); }
|
||||
cell.select = function() {
|
||||
if(!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
|
||||
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
|
||||
this.myTable.selectedCell = this;
|
||||
if(this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
|
||||
if(this.onSelect) this.onSelect();
|
||||
this.className = this.myTable.cellSelectedClass;
|
||||
}
|
||||
}
|
||||
cell.deselect = function() {
|
||||
if(this.myTable.selectedCell === this) {
|
||||
if(cell.onDeselect) cell.onDeselect();
|
||||
this.className = '';
|
||||
this.selected = false;
|
||||
this.myTable.selectedCell = '';
|
||||
}
|
||||
};
|
||||
cell.selectNext = function() {
|
||||
this.deselect();
|
||||
if(this.nextSibling) this.nextSibling.select();
|
||||
else {
|
||||
if(!this.parentNode.nextSibling) { if(this.noNewAdd) return; else this.myTable.addRow(); }
|
||||
this.parentNode.nextSibling.select();
|
||||
this.parentNode.nextSibling.firstChild.select();
|
||||
}
|
||||
}
|
||||
cell.afterCreate = function() {}
|
||||
cell.setData = function(data) {}
|
||||
cell.getData = function(data) {}
|
||||
if(this.onCreateCell) this.onCreateCell(cell);
|
||||
return cell;
|
||||
};
|
||||
this.onCreateCell; //function(cell) {}
|
||||
|
||||
|
||||
this.setRowData = function(row,data) {
|
||||
for(var i=0; i<this.colCount(); i++) {
|
||||
this.setCellData(row,row.cells.item(i),data);
|
||||
}
|
||||
}
|
||||
|
||||
this.setCellData = function(row,cell,data) {
|
||||
if(typeof(row) == "number")
|
||||
if(this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
|
||||
if(typeof(cell) != "object")
|
||||
if(typeof(cell) == "number" && typeof(row) == "object") {
|
||||
if(row.cells.item(cell))
|
||||
cell = row.cells.item(cell);
|
||||
else return;
|
||||
}
|
||||
else return;
|
||||
if(this.onSetCellData) this.onSetCellData(row,cell,data);
|
||||
}
|
||||
|
||||
this.onSetCellData; //function(row,cell,data) {}
|
||||
|
||||
|
||||
|
||||
|
||||
this.selectRow = function(row) {
|
||||
|
||||
|
||||
if(this.selectedRow === row) return;
|
||||
|
||||
|
||||
if(this.selectedRow) this.deselectRow();
|
||||
|
||||
|
||||
this.selectedRow = row;
|
||||
|
||||
|
||||
this.selectedRow.className = this.rowSelectedClass;
|
||||
|
||||
|
||||
this.setEditNames(this.selectedRow,!this.selectedRow.isnew);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.selectNextRow = function() {
|
||||
|
||||
|
||||
if(!this.selectedRow) return;
|
||||
|
||||
|
||||
if(!this.selectedRow.nextSibling) this.insertRow();
|
||||
|
||||
|
||||
var cell_id = this.selectedCell.lp;
|
||||
|
||||
|
||||
this.selectRow(this.selectedRow.nextSibling);
|
||||
|
||||
|
||||
this.selectCell(this.selectedRow.cells.item(cell_id));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.selectPreviousRow = function() {
|
||||
|
||||
|
||||
if(!this.selectedRow) return;
|
||||
|
||||
|
||||
if(!this.selectedRow.previousSibling) return;
|
||||
|
||||
|
||||
if(this.selectedRow === this.tbody.rows.item(0)) return;
|
||||
|
||||
|
||||
var cell_id = this.selectedCell.lp;
|
||||
|
||||
|
||||
this.selectRow(this.selectedRow.previousSibling);
|
||||
|
||||
|
||||
this.selectCell(this.selectedRow.cells.item(cell_id));
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.refreshNumeration = function() {
|
||||
for(var i=0; i<this.tbody.rows.length; i++)
|
||||
this.tbody.rows.item(i).cells.item(0).firstChild.value = i+1;
|
||||
}
|
||||
|
||||
this.KeyPressedNumber = function(e) {
|
||||
var keynum;
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
return keynum;
|
||||
}
|
||||
|
||||
this.KeyPressed = function(e, cell, method) {
|
||||
var keynum;
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
if((keynum == 9) || (keynum == 13)) {
|
||||
cell.selectNext();
|
||||
return false;
|
||||
}
|
||||
if(keynum == 40) { var id = cell.index; var row = cell.parentNode.selectNext(); if(row) { row.select(); row.cells.item(id).select(); } }
|
||||
if(keynum == 38) { var id = cell.index; var row = cell.parentNode.selectPrevious(); if(row) { row.select(); row.cells.item(id).select(); } }
|
||||
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
|
||||
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
|
||||
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.OnlyNumbers = function(e, noQuote) { var keynum = e, keychar, numcheck;
|
||||
keychar = String.fromCharCode(keynum);
|
||||
numcheck = /\d/;
|
||||
return numcheck.test(keychar) || ((!noQuote)?(keynum == 190):false)
|
||||
|| (keynum == 8) //backspace
|
||||
|| (keynum == 46) //delete
|
||||
|| (keynum == 13) //enter || (keynum == 0) //special keys with FF
|
||||
|| (keynum == 37) //left arrow
|
||||
|| (keynum == 39) //right arrow
|
||||
|| (keynum == 188) //,
|
||||
|| (keynum >= 95 && keynum <= 105) //numeric keyboard
|
||||
|| (keynum == 110);
|
||||
}
|
||||
|
||||
this.row = function(i) { if(this.tbody.rows.item(i)) return this.tbody.rows.item(i); }
|
||||
this.cells = function(i,j) { if(this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i); }
|
||||
}
|
||||
711
modules/EcmReceipts2/_EcmRecepitsDetailView.js
Executable file
711
modules/EcmReceipts2/_EcmRecepitsDetailView.js
Executable file
@@ -0,0 +1,711 @@
|
||||
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, call_back_function, form_name) {
|
||||
if (!call_back_function) {
|
||||
call_back_function = "set_return";
|
||||
}
|
||||
|
||||
if (!form_name) {
|
||||
form_name = "EditView";
|
||||
}
|
||||
|
||||
return open_popup(module, 600, 400, "", 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 ItemListClear() {
|
||||
while (N.rowCount() > 0) {
|
||||
N.row(0).deleteRow();
|
||||
}
|
||||
}
|
||||
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
//initialize table
|
||||
N = new MyTable('itemsTable');
|
||||
|
||||
N.onRefreshRowIndex = function(row) {
|
||||
var data = new Object();
|
||||
|
||||
data['index'] = (row.index + 1).toString();
|
||||
row.cells.item(0).setData(data);
|
||||
};
|
||||
|
||||
N.onCreateRow = function(row) {
|
||||
row.newPos = false;
|
||||
|
||||
row.ondblclick = function() {
|
||||
this.newPos = !this.newPos;
|
||||
|
||||
var img = this.cells.item(1).getElementsByTagName('img');
|
||||
|
||||
if (!this.newPos) {
|
||||
img[0].src = "modules/EcmReceipts/images/edit.gif";
|
||||
}
|
||||
else {
|
||||
img[0].src = "modules/EcmReceipts/images/editset.gif";
|
||||
}
|
||||
|
||||
|
||||
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() {
|
||||
var data = new Object();
|
||||
this.cells.item(3).getData(data, true);
|
||||
this.cells.item(4).getData(data, true);
|
||||
this.cells.item(5).getData(data, true);
|
||||
this.cells.item(6).getData(data, true);
|
||||
this.cells.item(7).getData(data, true);
|
||||
this.cells.item(8).getData(data, true);
|
||||
this.cells.item(9).getData(data, true);
|
||||
|
||||
// this.cells.item(10).getData(data, true);
|
||||
// this.cells.item(11).getData(data, true);
|
||||
// this.cells.item(12).getData(data, true);
|
||||
|
||||
//calculate selling_price
|
||||
if (data.price) {
|
||||
if (data.discount) {
|
||||
data.selling_price = (data.price - (data.price * data.discount / 100)).toFixed(2);
|
||||
} else {
|
||||
data.selling_price = (data.price).toFixed(2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
data.selling_price = 0;
|
||||
}
|
||||
|
||||
//calculate total
|
||||
if (data.price && data.quantity) {
|
||||
data.total = (data.price * data.quantity).toFixed(2);
|
||||
}
|
||||
else {
|
||||
data.total = 0;
|
||||
}
|
||||
|
||||
//alert(data.total+' '+data.price+' '+data.quantity);
|
||||
|
||||
this.cells.item(9).setData(data);
|
||||
this.cells.item(6).setData(data);
|
||||
|
||||
calculateTotal();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
N.onCreateCell = function(cell) {
|
||||
var i = cell.index;
|
||||
|
||||
cell.change = function(select) {
|
||||
//
|
||||
};
|
||||
|
||||
// cell.style.height = OPT['row_item_height'];
|
||||
|
||||
cell.style.height = 50;
|
||||
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_name = 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_name) {
|
||||
cn[2].value = data.unit_name;
|
||||
}
|
||||
|
||||
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']);
|
||||
unit_id.setAttribute('value', 'TMP');
|
||||
cell.appendChild(unit_id);
|
||||
|
||||
var vat_id = document.createElement('input');
|
||||
|
||||
vat_id.setAttribute('type', 'hidden');
|
||||
//vat_id.setAttribute('value',OPT['default_vat']);
|
||||
vat_id.setAttribute('value', '23');
|
||||
cell.appendChild(vat_id);
|
||||
|
||||
var category_id = document.createElement('input');
|
||||
|
||||
category_id.setAttribute('type', 'hidden');
|
||||
category_id.setAttribute('value', '');
|
||||
cell.appendChild(category_id);
|
||||
}
|
||||
|
||||
if (i == 2) {
|
||||
cell.getData = function(data) {
|
||||
var cn = this.getElementsByTagName('textarea');
|
||||
|
||||
data.name = cn[0].value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
var cn = this.getElementsByTagName('textarea');
|
||||
|
||||
if (data.name) {
|
||||
cn[0].value = data.name;
|
||||
}
|
||||
};
|
||||
|
||||
var textarea = '<textarea tabindex="1" readonly="readonly" style="height:100%" class="inputs"></textarea>';
|
||||
|
||||
cell.innerHTML = textarea;
|
||||
}
|
||||
|
||||
if (i == 3) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
var tmp = UserFormatNumberToNumber(this.firstChild.value);
|
||||
|
||||
if (tmp == -1) {
|
||||
ERROR = true;
|
||||
|
||||
// if (!noAlert) {
|
||||
// alert(MOD['LBL_FORMAT_NUMBER_ERROR'] + ' (' + this.firstChild.value + ')');
|
||||
// }
|
||||
|
||||
data.quantity = 0;
|
||||
|
||||
this.firstChild.style.color = 'red';
|
||||
} else {
|
||||
data.quantity = tmp;
|
||||
|
||||
this.firstChild.style.color = 'black';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
if (data.quantity) {
|
||||
this.firstChild.value = NumberToUserFormatNumber(data.quantity);
|
||||
}
|
||||
else {
|
||||
this.firstChild.value = NumberToUserFormatNumber(0);
|
||||
}
|
||||
};
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" style="text-align:right;" autocomplete="off" class="inputs" value="' + NumberToUserFormatNumber(1) + '">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
}
|
||||
|
||||
if (i == 4) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
data.unit_id = this.firstChild.value;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
this.firstChild.value = data.unit_id;
|
||||
};
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
}
|
||||
|
||||
if (i == 5) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
//
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
var value;
|
||||
|
||||
if ((data.price) && (data.discount)) {
|
||||
value = (100 * data.price) / (100 - data.discount);
|
||||
} else {
|
||||
if ((data.price) && !(data.discount)) {
|
||||
value = data.price;
|
||||
}
|
||||
else {
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.firstChild.value = NumberToUserFormatNumber(value);
|
||||
};
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="0">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
}
|
||||
|
||||
if (i == 6) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
var tmp = UserFormatNumberToNumber(this.firstChild.value, '%');
|
||||
|
||||
if (tmp == -1) {
|
||||
ERROR = true;
|
||||
|
||||
if (!noAlert) {
|
||||
alert(MOD['LBL_FORMAT_NUMBER_ERROR'] + ' (' + this.firstChild.value + ')');
|
||||
}
|
||||
|
||||
data.discount = 0;
|
||||
|
||||
this.firstChild.style.color = 'red';
|
||||
|
||||
} else {
|
||||
data.discount = tmp;
|
||||
|
||||
this.firstChild.style.color = 'black';
|
||||
}
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
if (data.discount) {
|
||||
this.firstChild.value = NumberToUserFormatNumber(data.discount, '%');
|
||||
}
|
||||
else {
|
||||
this.firstChild.value = NumberToUserFormatNumber(0, '%');
|
||||
}
|
||||
};
|
||||
|
||||
cell.selectNext = function() {
|
||||
var row = this.parentNode.selectNext();
|
||||
|
||||
row.select();
|
||||
row.cells.item(0).select();
|
||||
};
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0, '%') + '">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
|
||||
}
|
||||
|
||||
if (i == 7) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
var tmp = UserFormatNumberToNumber(this.firstChild.value);
|
||||
|
||||
if (tmp == -1) {
|
||||
ERROR = true;
|
||||
|
||||
if (!noAlert) {
|
||||
alert(MOD['LBL_FORMAT_NUMBER_ERROR'] + ' (' + this.firstChild.value + ')');
|
||||
}
|
||||
|
||||
data.price = 0;
|
||||
|
||||
this.firstChild.style.color = 'red';
|
||||
} else {
|
||||
data.price = tmp;
|
||||
|
||||
this.firstChild.style.color = 'black';
|
||||
}
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
if (data.price) {
|
||||
this.firstChild.value = NumberToUserFormatNumber(data.price);
|
||||
}
|
||||
else {
|
||||
this.firstChild.value = NumberToUserFormatNumber(0);
|
||||
}
|
||||
};
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0) + '">';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
}
|
||||
|
||||
if (i == 8) {
|
||||
cell.getData = function(data, noAlert) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
data.vat_value = cn[0].value;
|
||||
data.vat_id = cn[1].value;
|
||||
if (VAT[cn[1].value])
|
||||
data.vat_name = VAT[cn[1].value].name;
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
if (data.vat_value) {
|
||||
this.getElementsByTagName('input')[0].value = data.vat_value;
|
||||
}
|
||||
|
||||
if (data.vat_id) {
|
||||
this.getElementsByTagName('input')[1].value = data.vat_id;
|
||||
}
|
||||
|
||||
if (data.vat_name) {
|
||||
this.getElementsByTagName('input')[2].value = data.vat_name;
|
||||
}
|
||||
};
|
||||
|
||||
cell.onDeselect = function() {
|
||||
ERROR = false;
|
||||
|
||||
var data = new Object();
|
||||
this.getData(data);
|
||||
|
||||
if (!ERROR) {
|
||||
data.vat_id = data.vat_id;
|
||||
|
||||
this.setData(data);
|
||||
}
|
||||
};
|
||||
|
||||
var inp = document.createElement('input');
|
||||
|
||||
inp.setAttribute('type', 'hidden');
|
||||
cell.appendChild(inp);
|
||||
|
||||
var inp = document.createElement('input');
|
||||
|
||||
inp.setAttribute('type', 'hidden');
|
||||
cell.appendChild(inp);
|
||||
|
||||
var inp;
|
||||
|
||||
inp = document.createElement('input');
|
||||
inp.setAttribute('type', 'text');
|
||||
inp.className = 'inputs';
|
||||
inp.style.textAlign = "right";
|
||||
inp.cell = cell;
|
||||
|
||||
cell.appendChild(inp);
|
||||
}
|
||||
|
||||
if (i == 9) {
|
||||
cell.getData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
|
||||
data.total = UserFormatNumberToNumber(cn[0].value);
|
||||
};
|
||||
|
||||
cell.setData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
|
||||
if (data.total) {
|
||||
cn[0].value = NumberToUserFormatNumber(data.total);
|
||||
}
|
||||
else {
|
||||
cn[0].value = NumberToUserFormatNumber(0);
|
||||
}
|
||||
};
|
||||
|
||||
var edit = document.createElement('input');
|
||||
|
||||
edit.setAttribute('type', 'text');
|
||||
edit.setAttribute('value', NumberToUserFormatNumber(0));
|
||||
edit.setAttribute('readOnly', 'readonly');
|
||||
edit.className = 'inputs';
|
||||
edit.style.textAlign = "right";
|
||||
|
||||
cell.appendChild(edit);
|
||||
}
|
||||
};
|
||||
|
||||
N.onSetCellData = function(row, cell, data) {
|
||||
if (cell.innerHTML == '') {
|
||||
cell.innerHTML = ' ';
|
||||
}
|
||||
};
|
||||
|
||||
var pl = document.getElementById('position_list').value;
|
||||
|
||||
if (pl && pl != '') {
|
||||
try {
|
||||
pl = eval(pl);
|
||||
|
||||
for (x in pl) {
|
||||
if (typeof(pl[x].code) != "undefined") {
|
||||
var pl_row = pl[x];
|
||||
N.addRow().setData(pl_row);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
pl = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (N.rowCount() == 0) {
|
||||
N.addRow();
|
||||
}
|
||||
|
||||
calculateTotal = function() {
|
||||
var vats = new Object();
|
||||
|
||||
var subtotal = 0;
|
||||
var total = 0;
|
||||
// var cbm_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;
|
||||
// cbm_total += data.cbm;
|
||||
}
|
||||
|
||||
total = subtotal;
|
||||
var rt = document.getElementById('result_table');
|
||||
|
||||
for (var i = 1; i < rt.rows.length - 4; 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('subtotal').value = NumberToUserFormatNumber(subtotal);
|
||||
|
||||
if (document.getElementById('total_2')) {
|
||||
document.getElementById('total_2').value = total2;
|
||||
}
|
||||
|
||||
// document.getElementById('discount_2').value = discount2;
|
||||
document.getElementById('total').value = total;
|
||||
// document.getElementById('cbm_total').value = cbm_total;
|
||||
};
|
||||
|
||||
calculateTotal();
|
||||
|
||||
function HideLoadingView() {
|
||||
var slv = document.getElementById('ShowLoadingView');
|
||||
|
||||
if (slv) {
|
||||
slv.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
setPREVIEW = function() {
|
||||
// EcmPreviewPDF('index.php?module=EcmQuotes&action=previewPDF&to_pdf=1&method=I&record='+document.forms.DetailView.record.value,{zoom:75});
|
||||
|
||||
var type = document.getElementById('preview_type').value;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
type = '';
|
||||
break;
|
||||
case 'exp':
|
||||
type = 'exp';
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(type);
|
||||
|
||||
if (SHOW_PDF_IN_DIV == 1) {
|
||||
HideLoadingView();
|
||||
//SetTab('preview_PREVIEW');
|
||||
EcmPreviewPDF('index.php?module=EcmReceipts&action=previewPDF&to_pdf=1&method=I&record=' + document.forms.DetailView.record.value + '&type=' + type, {zoom: 75});
|
||||
}
|
||||
else {
|
||||
SetTab('panel_PREVIEW');
|
||||
|
||||
document.getElementById('previewPDF').innerHTML = '<iframe style="border:none;width:100%;height:1200px;" frameborder="no" src="index.php?module=EcmReceipts&action=previewPDF&to_pdf=1&method=I&record=' + document.forms.DetailView.record.value + '&type=' + type + '#zoom=75">Yours browser not accept iframes!</iframe>';
|
||||
}
|
||||
};
|
||||
|
||||
setEMAIL = function(noCheck) {
|
||||
SetTab('panel_EMAIL');
|
||||
|
||||
document.getElementById('emailTAB').innerHTML = '<iframe id="emailIFRAME" style="border:none;width:100%;height:670px;" frameborder="no" src="index.php?module=EcmReceipts&action=Emails&to_pdf=1&type=out&pTypeTo=' + document.forms.DetailView.parent_type.value + '&pIdTo=' + document.forms.DetailView.parent_id.value + '&pTypeFrom=Users&pIdFrom=' + document.forms.DetailView.assigned_user_id.value + '&receipt_id=' + document.forms.DetailView.record.value + '&record=' + document.forms.DetailView.email_id.value + '&type=' + type + '">Yours browser not accept iframes!</iframe>';
|
||||
};
|
||||
|
||||
setInterval(
|
||||
function() {
|
||||
doRequest(
|
||||
'index.php',
|
||||
"module=EcmReceipts&action=subpanels&to_pdf=1&record=" + document.forms.DetailView.record.value,
|
||||
function(result) {
|
||||
if (result != '' && document.getElementById('subpanels_div'))
|
||||
document.getElementById('subpanels_div').innerHTML = result;
|
||||
}
|
||||
);
|
||||
},
|
||||
10000
|
||||
);
|
||||
|
||||
//quick view
|
||||
var main = document.getElementById('main');
|
||||
|
||||
if (main) {
|
||||
var h2 = main.getElementsByTagName('h2')[0];
|
||||
|
||||
if (h2) {
|
||||
h2.style.display = 'inline';
|
||||
var quickInfoH2 = document.getElementById('quickInfoH2');
|
||||
|
||||
if (quickInfoH2) {
|
||||
h2.parentNode.appendChild(quickInfoH2);
|
||||
quickInfoH2.style.display = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OPT['setTab'] && OPT['setTab'] != '') {
|
||||
if (OPT['setTab'] == 'EMAIL') {
|
||||
setEMAIL();
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < N.rowCount(); i++) {
|
||||
N.row(i).calculateTotal();
|
||||
}
|
||||
}
|
||||
);
|
||||
164
modules/EcmReceipts2/formloader.js
Executable file
164
modules/EcmReceipts2/formloader.js
Executable file
@@ -0,0 +1,164 @@
|
||||
|
||||
|
||||
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 my_popup(module, field_array, 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, "", 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 FormLoader() {
|
||||
|
||||
|
||||
|
||||
this.module;
|
||||
|
||||
this.createModule;
|
||||
|
||||
this.fieldName;
|
||||
|
||||
this.buttonName = 'FormLoaderButton';
|
||||
|
||||
|
||||
|
||||
this.load = function(module,createModule,fieldName) {
|
||||
|
||||
this.module = module;
|
||||
|
||||
this.createModule = createModule;
|
||||
|
||||
this.fieldName = fieldName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.createButton = function() {
|
||||
|
||||
var b = document.createElement('input');
|
||||
|
||||
b.type = 'button';
|
||||
|
||||
b.className = 'button';
|
||||
|
||||
b.name = this.buttonName;
|
||||
|
||||
b.value = 'Create';
|
||||
|
||||
b.FL = this;
|
||||
|
||||
b.onclick = function() {
|
||||
|
||||
if(this.FL.createModule == '') return;
|
||||
|
||||
if(this.FL.onButtonClick) var data = this.FL.onButtonClick();
|
||||
|
||||
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
|
||||
}
|
||||
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
// this.setEditDblClick = function(edit) { edit.FL=this; edit.ondblclick=this.editDblClick; }
|
||||
|
||||
this.editDblClick = function() {
|
||||
|
||||
if(this.FL.createModule == '') return;
|
||||
|
||||
if(this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
|
||||
|
||||
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.responseData = function(data) {
|
||||
|
||||
if(this.onResponseData) this.onResponseData(data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.onResponseData;
|
||||
|
||||
|
||||
|
||||
this.addPostData = function() {
|
||||
|
||||
if(this.onAddPostData)
|
||||
|
||||
return this.onAddPostData();
|
||||
|
||||
else
|
||||
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.onAddPostData;
|
||||
|
||||
this.onButtonClick;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user