Add JS files
This commit is contained in:
224
modules/Accounts/Discounts.js
Normal file
224
modules/Accounts/Discounts.js
Normal file
@@ -0,0 +1,224 @@
|
||||
//addresses
|
||||
function saveItems2(){
|
||||
document.getElementById('position_list2').value = ItemsList2(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 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 ItemListSave2;
|
||||
var ItemListClear2;
|
||||
var ItemListFil2;
|
||||
var FillText;
|
||||
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
var paramsTable2 = new paramsMT('itemsTable2');
|
||||
paramsTable2.onCreateRow = function(row) {
|
||||
row.newPos = false;
|
||||
row.noAddNew = true;
|
||||
row.ondblclick = function() {}
|
||||
row.onSelect = function() {
|
||||
}
|
||||
row.onDeselect = function() {
|
||||
}
|
||||
}
|
||||
|
||||
paramsTable2.onCreateCell = function(cell) {
|
||||
|
||||
var i = cell.index;
|
||||
cell.change = function(select) {};
|
||||
if(i == 0) {
|
||||
|
||||
cell.setData = function(data) {
|
||||
console.log(data);
|
||||
if(data.ecmproductcategory_name) {
|
||||
cell.firstChild.value = data.ecmproductcategory_name;
|
||||
|
||||
cell.getElementsByTagName('input')[1].value = data.ecmproductcategory_id;
|
||||
if (data.id)
|
||||
cell.getElementsByTagName('input')[2].value = data.id;
|
||||
}
|
||||
};
|
||||
cell.getData = function(data) {
|
||||
data.ecmproductcategory_name = cell.firstChild.value;
|
||||
data.ecmproductcategory_id = cell.getElementsByTagName('input')[1].value;
|
||||
data.id = cell.getElementsByTagName('input')[2].value;
|
||||
}
|
||||
|
||||
cell.onSelect = function() {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
cn[0].name = 'name_p';
|
||||
cn[0].id = 'name_p';
|
||||
|
||||
cn[1].name = 'id_p';
|
||||
cn[1].id = 'id_p';
|
||||
}
|
||||
cell.onDeselect = function() {
|
||||
ERROR = false;
|
||||
var data = new Object();
|
||||
this.getData(data);
|
||||
if(!ERROR) {
|
||||
data.product_group = data.product_group;
|
||||
this.setData(data);
|
||||
}
|
||||
|
||||
var cn = this.getElementsByTagName('input');
|
||||
cn[0].name = '';
|
||||
cn[0].id = '';
|
||||
|
||||
cn[1].name = '';
|
||||
cn[1].id = '';
|
||||
}
|
||||
//cell.select = function() { this.selectNext(); }
|
||||
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','text');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','hidden');
|
||||
edit.setAttribute('readonly','readonly');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','hidden');
|
||||
edit.setAttribute('readonly','readonly');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
var img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_IMG_SEARCH']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/search.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() {
|
||||
var ecmpopup = open_popup( "EcmProductCategories", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"id_p","name":"name_p"}}, "single", true );
|
||||
setTimeout(function(){ecmpopup.focus();},200);
|
||||
}
|
||||
cell.appendChild(img);
|
||||
}
|
||||
if(i == 1) {
|
||||
cell.setData = function(data) {
|
||||
if (data.discount)
|
||||
cell.getElementsByTagName('input')[0].value = FormatNumber(data.discount);
|
||||
};
|
||||
cell.getData = function(data) {
|
||||
data.discount = UnformatNumber(cell.firstChild.value);
|
||||
}
|
||||
|
||||
cell.onDeselect = function() {
|
||||
ERROR = false;
|
||||
var data = new Object();
|
||||
this.getData(data);
|
||||
if(!ERROR) {
|
||||
data.discount = data.discount;
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
cell.onDeselect = function() {
|
||||
|
||||
|
||||
}
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','text');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.setAttribute('onChange','$(this).val(FormatNumber($(this).val(),2));');
|
||||
edit.className = 'inputs';
|
||||
edit.value = NumberToUserFormatNumber(0);
|
||||
cell.appendChild(edit);
|
||||
|
||||
}
|
||||
if(i == 2) {
|
||||
var img;
|
||||
|
||||
cell.style.padding="auto auto auto auto";
|
||||
//insert
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/insertrow.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() {
|
||||
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
|
||||
refreshPositionIndex();
|
||||
};
|
||||
|
||||
//delete
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/deleterow.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() { this.parentNode.parentNode.deleteRow(); refreshPositionIndex();};
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
|
||||
cell.appendChild(document.createElement('br'));
|
||||
//move up
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/moverowup.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() { this.parentNode.parentNode.moveUp(); refreshPositionIndex();};
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
//move down
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/moverowdown.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() { this.parentNode.parentNode.moveDown();refreshPositionIndex(); }
|
||||
cell.appendChild(img);
|
||||
}
|
||||
}
|
||||
ItemsList2 = function(json) {
|
||||
var data = '';
|
||||
for(var i=0; i<paramsTable2.rowCount(); i++) {
|
||||
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable2.row(i).getData());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
if(paramsTable2.rowCount() == 0) {paramsTable2.addRow();};
|
||||
paramsTable2.onSetCellData = function(row,cell,data) {
|
||||
if(cell.innerHTML == '') cell.innerHTML = ' ';
|
||||
}
|
||||
|
||||
ItemListFill2 = function() {
|
||||
var pl;
|
||||
pl = document.getElementById('position_list2').value;
|
||||
console.log(pl);
|
||||
if(pl && pl != '') {
|
||||
try {
|
||||
pl = eval(pl);
|
||||
for(x in pl) { var pl_row = pl[x]; if (pl_row.template=='') continue; paramsTable2.addRow().setData(pl_row); }
|
||||
} catch(err) { pl = null; };
|
||||
}
|
||||
}
|
||||
|
||||
ItemListClear2 = function(noNew,save) {
|
||||
if(typeof(save)=="string") ItemListSave(null,save);
|
||||
while(paramsTable2.rowCount()>0) paramsTable2.row(0).deleteRow(noNew);
|
||||
}
|
||||
|
||||
ItemListClear2();
|
||||
ItemListFill2();
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user