Add JS files
This commit is contained in:
409
modules/EcmInsideOrders.cp/AjaxSearch/AjaxSearch.js
Executable file
409
modules/EcmInsideOrders.cp/AjaxSearch/AjaxSearch.js
Executable file
@@ -0,0 +1,409 @@
|
||||
|
||||
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 = 800; //opoznienie wyszukiwania
|
||||
this.divList; //pole w ktorym wyswietlana bedzie lista znalezionnych elementow
|
||||
this.ajaxSearchItem; //unikalny identyfikator;
|
||||
this.module = 'EcmInsideOrders';
|
||||
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) { this.inputSearchEnterPressed(other); 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();", 500);
|
||||
}
|
||||
|
||||
this.inputSearchEnterPressed = function(other) {
|
||||
if(this.positionSelected) {
|
||||
var row;
|
||||
if(N.selectedRow) {
|
||||
N.selectedRow.setData(this.positionSelected.positionData);
|
||||
row = N.selectedRow;
|
||||
if(this.positionSelected.positionData.components){
|
||||
for(var i=0;i<this.positionSelected.positionData.components.length;i++)row = N.addRow().setData(this.positionSelected.positionData.components[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
row = N.addRow().setData(this.positionSelected.positionData);
|
||||
if(this.positionSelected.positionData.components){
|
||||
for(var i=0;i<this.positionSelected.positionData.components.length;i++)row = N.addRow().setData(this.positionSelected.positionData.components[i]);
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
if(typeof(list.code) == "undefined") return;
|
||||
var position = document.createElement('div');
|
||||
position.positionData = list;
|
||||
position.onclick = function() { this.parentNode.AjaxSearch.inputSearchEnterPressed(this); }
|
||||
position.onmouseover = function() { this.parentNode.AjaxSearch.positionSelect(this,true); };
|
||||
position.innerHTML = '<table width="100%" class="AjaxSearchPositionTable"><tr><td class="AjaxSearchPositionTableCode">'+this.markElement(list['code'])+'</td><td align="right" class="AjaxSearchPositionTablePrice">'+list['price']+' '+list['currency_symbol']+'</td></tr><tr><td colspan="2" 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();
|
||||
|
||||
|
||||
};
|
||||
9
modules/EcmInsideOrders.cp/CreateItem.js
Executable file
9
modules/EcmInsideOrders.cp/CreateItem.js
Executable file
@@ -0,0 +1,9 @@
|
||||
// JavaScript Document
|
||||
/*
|
||||
function komunikat() {
|
||||
var cos = new YAHOO.widget.Dialog("CreateItemDialog",{width:"450px",height:"520px",fixedcenter:true,draggable:false,visible:false,effect:[{effect:YAHOO.widget.ContainerEffect.SLIDETOP,duration:0.5},{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5}],modal:true,close:false});
|
||||
document.getElementById('CreateItemDialog').style.display=''
|
||||
}
|
||||
|
||||
YAHOO.util.Event.addListener(window, "load", komunikat);
|
||||
*/
|
||||
1307
modules/EcmInsideOrders.cp/EcmInsideOrders.js
Executable file
1307
modules/EcmInsideOrders.cp/EcmInsideOrders.js
Executable file
File diff suppressed because it is too large
Load Diff
773
modules/EcmInsideOrders.cp/EcmInsideOrdersDetailView.js
Executable file
773
modules/EcmInsideOrders.cp/EcmInsideOrdersDetailView.js
Executable file
@@ -0,0 +1,773 @@
|
||||
function setColor(inp,tr){
|
||||
var color="#F0FFA0";
|
||||
for(var i=0;i<inp.length;i++){
|
||||
if(inp[10].value!=1){
|
||||
inp[i].style.backgroundColor=color;
|
||||
tr.style.backgroundColor=color;
|
||||
}
|
||||
else {
|
||||
inp[i].style.backgroundColor="";
|
||||
tr.style.backgroundColor="";
|
||||
}
|
||||
}
|
||||
}
|
||||
function setNo(){
|
||||
var tab=document.getElementById("tbody");
|
||||
var tr=tab.getElementsByTagName("tr");
|
||||
var n=0;
|
||||
for(var i=0;i<tr.length;i++){
|
||||
var inp=tr[i].getElementsByTagName("input");
|
||||
if(inp[10].value!=1){
|
||||
n++;
|
||||
inp[0].value=n;
|
||||
}
|
||||
else inp[0].value="";
|
||||
}
|
||||
}
|
||||
function updateStyles(){
|
||||
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");
|
||||
setColor(inp,tr[i]);
|
||||
}
|
||||
setNo();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
function CheckDiscount(noAlert) {
|
||||
var discount = 0;
|
||||
var tmp = UserFormatNumberToNumber(document.getElementById('discount').value);
|
||||
if(tmp == -1) {
|
||||
if(!noAlert)
|
||||
alert(MOD['LBL_DISCOUNT_ERROR']+' ('+document.getElementById('discount').value+')');
|
||||
discount = -1;
|
||||
document.getElementById('discount').style.color = 'red';
|
||||
} else {
|
||||
discount = tmp;
|
||||
document.getElementById('discount').value = NumberToUserFormatNumber(discount);
|
||||
document.getElementById('discount').style.color = 'black';
|
||||
}
|
||||
return discount;
|
||||
}
|
||||
|
||||
function sendToConfirmEcmInsideeOrder(record) {
|
||||
if(typeof(record) == "string") {
|
||||
var status = "s20";
|
||||
doRequest(
|
||||
'index.php',
|
||||
'module=EcmInsideOrders&action=SetStatus&to_pdf=1&status='+status+'&record='+record,
|
||||
function(results) {
|
||||
var obj = eval(results);
|
||||
if(obj[0]) obj = obj[0];
|
||||
if(typeof(obj) == "object") {
|
||||
if(document.forms.DetailView.record.value == obj['record']) {
|
||||
document.getElementById('statusEcmInsideeOrder').innerHTML = obj['status']['text'];
|
||||
if(obj['status']['code'] == "s20") {
|
||||
document.forms.DetailView.send_to_confirm.style.display = 'none';
|
||||
document.forms.DetailView.edit_button.style.display = 'none';
|
||||
var c = document.getElementById('confirmingEcmInsideeOrder');
|
||||
if(c) c.style.display = '';
|
||||
}
|
||||
if(obj['status']['code'] == "s30") {
|
||||
document.forms.DetailView.send_to_confirm.style.display = 'none';
|
||||
document.forms.DetailView.edit_button.style.display = 'none';
|
||||
document.getElementById('confirmingEcmInsideeOrder').style.display = 'none';
|
||||
document.forms.DetailView.quote_to_sale.style.display = '';
|
||||
document.forms.DetailView.quote_to_invoice.style.display = '';
|
||||
}
|
||||
}
|
||||
alert(obj['message']);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function AcceptEcmInsideeOrder(record) {
|
||||
if(typeof(record) == "string") {
|
||||
var status = "accepted";
|
||||
doRequest(
|
||||
'index.php',
|
||||
'module=EcmInsideOrders&action=SetStatus&to_pdf=1&status='+status+'&record='+record,
|
||||
function(results) {
|
||||
var obj = eval(results);
|
||||
if(obj[0]) obj = obj[0];
|
||||
if(typeof(obj) == "object") {
|
||||
if(document.forms.DetailView.record.value == obj['record']) {
|
||||
document.getElementById('statusEcmInsideeOrder').innerHTML = obj['status']['text'];
|
||||
if(obj['status']['code'] == "accepted") {
|
||||
document.forms.DetailView.send_to_confirm.style.display = 'none';
|
||||
document.forms.DetailView.edit_button.style.display = 'none';
|
||||
document.getElementById('confirmingEcmInsideeOrder').style.display = 'none';
|
||||
document.forms.DetailView.quote_to_sale.style.display = '';
|
||||
document.forms.DetailView.quote_to_invoice.style.display = '';
|
||||
}
|
||||
}
|
||||
alert(obj['message']);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
location.href='index.php?module=EcmInsideOrders&action=DetailView&record='+document.forms.DetailView.record.value;
|
||||
}
|
||||
|
||||
function RejectEcmInsideeOrder(record) {
|
||||
if(typeof(record) == "string") {
|
||||
var status = "not_accepted";
|
||||
doRequest(
|
||||
'index.php',
|
||||
'module=EcmInsideOrders&action=SetStatus&to_pdf=1&status='+status+'&record='+record,
|
||||
function(results) {
|
||||
var obj = eval(results);
|
||||
if(obj[0]) obj = obj[0];
|
||||
if(typeof(obj) == "object") {
|
||||
if(document.forms.DetailView.record.value == obj['record']) {
|
||||
document.getElementById('statusEcmInsideeOrder').innerHTML = obj['status']['text'];
|
||||
if(obj['status']['code'] == "not_accepted") {
|
||||
document.getElementById('confirmingEcmInsideeOrder').style.display = 'none';
|
||||
document.forms.DetailView.edit_button.style.display = '';
|
||||
}
|
||||
}
|
||||
alert(obj['message']);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
location.href='index.php?module=EcmInsideOrders&action=DetailView&record='+document.forms.DetailView.record.value;
|
||||
}
|
||||
|
||||
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/EcmInsideOrders/images/edit.gif";
|
||||
|
||||
else img[0].src = "modules/EcmInsideOrders/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);
|
||||
|
||||
if(data.quantity && data.price)
|
||||
|
||||
data.total = data.quantity*data.price;
|
||||
|
||||
else
|
||||
|
||||
data.total = 0;
|
||||
|
||||
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.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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" autocomplete="off" >';
|
||||
|
||||
cell.innerHTML = edit;
|
||||
|
||||
cell.align = 'right';
|
||||
|
||||
var id = document.createElement('input');
|
||||
|
||||
id.setAttribute('type','hidden');
|
||||
|
||||
cell.appendChild(id);
|
||||
|
||||
var unit_id = document.createElement('input');
|
||||
|
||||
unit_id.setAttribute('type','hidden');
|
||||
|
||||
unit_id.setAttribute('value',OPT['default_unit']);
|
||||
|
||||
cell.appendChild(unit_id);
|
||||
|
||||
var vat_value = document.createElement('input');
|
||||
|
||||
vat_value.setAttribute('type','hidden');
|
||||
|
||||
vat_value.setAttribute('value',OPT['default_vat']);
|
||||
|
||||
cell.appendChild(vat_value);
|
||||
|
||||
var category_id = document.createElement('input');
|
||||
|
||||
category_id.setAttribute('type','hidden');
|
||||
|
||||
category_id.setAttribute('value',OPT['default_category']);
|
||||
|
||||
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;
|
||||
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,'',4,2); 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) {
|
||||
var tmp = UserFormatNumberToNumber(this.firstChild.value);
|
||||
if(tmp == -1) {
|
||||
ERROR = true;
|
||||
data.prod_quantity = 0;
|
||||
this.firstChild.style.color = 'red';
|
||||
}
|
||||
else {
|
||||
data.prod_quantity = tmp;
|
||||
this.firstChild.style.color = 'black';
|
||||
}
|
||||
}
|
||||
cell.setData = function(data) {
|
||||
if(data.prod_quantity) this.firstChild.value = NumberToUserFormatNumber(data.prod_quantity,'',4,2); 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 == 5) {
|
||||
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 == 6) {
|
||||
|
||||
cell.getData = function(data,noAlert) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
data.component = cn[0].value;
|
||||
data.component_quantity = cn[1].value;
|
||||
data.product_id = cn[2].value;
|
||||
data.guid = cn[3].value;
|
||||
}
|
||||
cell.setData = function(data) {
|
||||
if(data.component) this.getElementsByTagName('input')[0].value = data.component;
|
||||
if(data.component_quantity) this.getElementsByTagName('input')[1].value = data.component_quantity;
|
||||
if(data.product_id) this.getElementsByTagName('input')[2].value = data.product_id;
|
||||
if(data.guid) this.getElementsByTagName('input')[3].value = data.guid;
|
||||
}
|
||||
cell.onDeselect = function() {
|
||||
ERROR = false;
|
||||
var data = new Object();
|
||||
this.getData(data);
|
||||
if(!ERROR) {
|
||||
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=document.createElement('input');
|
||||
inp.setAttribute('type','hidden');
|
||||
cell.appendChild(inp);
|
||||
|
||||
var inp=document.createElement('input');
|
||||
inp.setAttribute('type','hidden');
|
||||
cell.appendChild(inp);
|
||||
}
|
||||
|
||||
|
||||
if(i == 7) {
|
||||
|
||||
//cell.select = function() { };
|
||||
|
||||
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*data.quantity;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
var discount;
|
||||
if((discount = CheckDiscount(true)) == -1) discount = 0;
|
||||
|
||||
var discount2 = subtotal*discount/100;
|
||||
|
||||
total = total2-discount2;
|
||||
|
||||
discount2 = NumberToUserFormatNumber(discount2).toString();
|
||||
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('total').value = total;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
calculateTotal();
|
||||
|
||||
|
||||
|
||||
setPREVIEW = function() {
|
||||
if(SHOW_PDF_IN_DIV==1){
|
||||
//HideLoadingView();
|
||||
//SetTab('preview_PREVIEW');
|
||||
EcmPreviewPDF('index.php?module=EcmInsideOrders&action=previewPDF&to_pdf=1&method=I&record='+document.forms.DetailView.record.value,{zoom:75});
|
||||
}
|
||||
else{
|
||||
SetTab('panel_PREVIEW');
|
||||
document.getElementById('previewPDF').innerHTML = '<iframe style="border:none;width:100%;height:1200px;" frameborder="no" src="index.php?module=EcmInsideOrders&action=previewPDF&to_pdf=1&method=I&record='+document.forms.DetailView.record.value+'#zoom=75">Yours browser not accept iframes!</iframe>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!OPT.user.access.send_email)
|
||||
setEMAIL = function() { alert(MOD['LBL_ACCESS_UNAVAIBLE_DELETE_EMAIL']); };
|
||||
else
|
||||
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=EcmInsideOrders&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+'"e_id='+document.forms.DetailView.record.value+'&record='+document.forms.DetailView.email_id.value+'">Yours browser not accept iframes!</iframe>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
setInterval(function() {
|
||||
doRequest('index.php',"module=EcmInsideOrders&action=subpanels&to_pdf=1&record="+document.forms.DetailView.record.value,
|
||||
function(result) {
|
||||
if(result != '') document.getElementById('subpanels_div').innerHTML = result;
|
||||
}
|
||||
);
|
||||
},
|
||||
10000
|
||||
);
|
||||
|
||||
setInterval("updateStyles();",100);
|
||||
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
1018
modules/EcmInsideOrders.cp/Email.js
Executable file
1018
modules/EcmInsideOrders.cp/Email.js
Executable file
File diff suppressed because it is too large
Load Diff
78
modules/EcmInsideOrders.cp/ListView.js
Executable file
78
modules/EcmInsideOrders.cp/ListView.js
Executable file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
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 list_setQuoteStatus(record, status) {
|
||||
if(typeof(record) == "string") {
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'index.php',
|
||||
{
|
||||
success: function(results) {
|
||||
results = results.responseText;
|
||||
//alert(results);
|
||||
var obj = eval(results);
|
||||
if(obj[0]) obj = obj[0];
|
||||
if(typeof(obj) == "object") {
|
||||
alert(obj['message']);
|
||||
if(typeof(obj['record']) == "string" && obj['record'].length == 36) {
|
||||
var status = document.getElementById('statusListEcmInsideOrder_'+obj['record']);
|
||||
if(status) status.innerHTML = obj['status']['image'];
|
||||
if(obj['list_images']) {
|
||||
var list_images = document.getElementById('optionsListEcmInsideOrder_'+obj['record']);
|
||||
if(list_images && list_images.parentNode) list_images.parentNode.innerHTML = obj['list_images'];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
failure: function() {}
|
||||
},
|
||||
'module=EcmInsideOrders&action=SetStatus&to_pdf=1&status='+status+'&record='+record+'&ListQuotesModule='+ListQuotesModule+'&ListQuotesAction='+ListQuotesAction
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var UserAccessToListItems = new Object();
|
||||
|
||||
|
||||
function list_showStatusMenu(record) {
|
||||
var div = document.getElementById('list_statusMenu');
|
||||
if(!div) {
|
||||
div = document.createElement('div');
|
||||
div.className = 'list_statusMenu';
|
||||
div.id = 'list_statusMenu';
|
||||
document.body.appendChild(div);
|
||||
}
|
||||
if(div) {
|
||||
var statusSpan = document.getElementById('statusListEcmInsideOrder_'+record);
|
||||
if(statusSpan) {
|
||||
var XY = YAHOO.util.Dom.getXY(statusSpan);
|
||||
div.style.left = XY[0]+statusSpan.offsetWidth;
|
||||
div.style.top = XY[1];
|
||||
if(typeof(EcmInsideOrdersStatusMenu) == "object") {
|
||||
var html = '';
|
||||
for(x in EcmInsideOrdersStatusMenu) {
|
||||
html += EcmInsideOrdersStatusMenu[x]['enabled'];
|
||||
}
|
||||
div.innerHTML = html;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function list_hideStatusMenu(record) {
|
||||
alert('hide');
|
||||
}
|
||||
|
||||
|
||||
YAHOO.util.Event.addListener(
|
||||
window,
|
||||
"load",
|
||||
function() {
|
||||
//alert(EcmInsideOrdersStatusMenu);
|
||||
}
|
||||
);
|
||||
2297
modules/EcmInsideOrders.cp/MyTable.js
Executable file
2297
modules/EcmInsideOrders.cp/MyTable.js
Executable file
File diff suppressed because it is too large
Load Diff
361
modules/EcmInsideOrders.cp/PDFLanguages.js
Executable file
361
modules/EcmInsideOrders.cp/PDFLanguages.js
Executable file
@@ -0,0 +1,361 @@
|
||||
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=EcmInsideOrders&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'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
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/EcmInsideOrders.cp/PDFLanguagesMT.js
Executable file
371
modules/EcmInsideOrders.cp/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); }
|
||||
}
|
||||
164
modules/EcmInsideOrders.cp/formloader.js
Executable file
164
modules/EcmInsideOrders.cp/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, 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 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