function updateUnitNames(){
var tab=document.getElementById("tbody");
var tr=tab.getElementsByTagName("tr");
var qtyinstock;
var qty;
var total;
for(var i=0;i
0) N.row(0).deleteRow();
}
function getFormPost(action) {
if(!action) action = 'previewPDF';
var pd = 'to_pdf=1'+'&module=EcmStockDocIns&action='+action+'&record='+document.forms.EditView.record.value;
pd += '&cache=fromJava'+ItemListSave(true);
var pd2 = new Object();
pd2['module'] = 'EcmStockDocIns';
pd2['action'] = action;
pd2['record'] = document.forms.EditView.record.value;
pd2['to_pdf'] = '1';
pd2['cache'] = 'fromJava';
document.forms.EditView.position_list.value = '';
document.forms["EditView"].action.value = action;
var tmp;
for(var i=0; iYours browser not accept iframes!";
}
}
);
}, 200);
}
function canConfirm() {
/*
if(document.forms.EditView.status.value == "accepted" && !OPT.user.confirm_quotes) {
alert('This option is disabled for You.');
document.forms.EditView.status.value = ((OPT.old_status)?OPT.old_status:'');
}
OPT.old_status = document.forms.EditView.status.value;*/
}
function CheckDiscount(noAlert) {
/*
var discount = 0;
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 true;
}
//document.getElementById('previewPDF').innerHTML = "";
//ProductListSave();
//YAHOO.util.Connect.asyncRequest('POST','index.php',{success:this.Display,failure:this.Fail},this.postData());
var AjaxSearchProducts;
var parentFL;
var productFL;
var contactFL;
addEvent(
window,
'load',
function () {
var CHANGER = new changer();
CHANGER.interval = 500;
set_focus();
//initialize table
N = new MyTable('itemsTable');
N.divParent = document.getElementById('itemsTableDIV');
var from_popup_return = false;
function returnedData(popup_reply_data) {
from_popup_return = true;
var form_name = popup_reply_data.form_name;
var name_to_value_array = popup_reply_data.name_to_value_array;
for (var the_key in name_to_value_array) {
if(the_key == 'toJSON'){}
else {
var displayValue=name_to_value_array[the_key].replace(/&/gi,'&').replace(/</gi,'<').replace(/>/gi,'>').replace(/'/gi,'\'').replace(/"/gi,'"');;
var e = document.getElementById(the_key);
if(e) { e.value = displayValue; }
}
}
//if(N.selectedRow) N.selectedRow.calculateTotal();
};
N.onRefreshRowIndex = function(row) {
var data = new Object();
data['index'] = (row.index+1).toString();
row.cells.item(0).setData(data);
}
N.onCreateRow = function(row) {
row.newPos = false;
//row.style.height = OPT['row_item_height'];
row.ondblclick = function() {
this.newPos = !this.newPos;
/*
var img = this.cells.item(1).getElementsByTagName('img');
//if(!this.newPos)
img[0].src = "modules/EcmStockDocIns/images/insertrow.gif";
//else img[0].src = "modules/EcmStockDocIns/images/editset.gif";
*/
for(var i=0; i (this.offsetHeight+5)) || ((N.selectedCell.offsetTop-this.scrollTop) < (-10)))
AjaxSearchProducts.div.style.display = 'none';
else
AjaxSearchProducts.div.style.display = '';
AjaxSearchProducts.div.style.top = top - this.scrollTop;
}
}
N.onCreateCell = function(cell) {
var i = cell.index;
cell.change = function(select) {};
cell.style.height = OPT['row_item_height'];
cell.onDeselect2 = function() {
var data = this.parentNode.getData();
if(!data.id || data.id == '') {
var data2 = new Object();
this.parentNode.setData(data2);
}
}
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) {
var cn = this.getElementsByTagName('input');
var c;
if(select) {
c = cn[0]; c.name = 'code_p'; c.id = 'code_p'; c.className = 'inputs';// sqsEnabled';
c = cn[1]; c.name = 'id_p'; c.id = 'id_p';
//c = cn[3]; c.name = 'vat_id_p'; c.id = 'vat_id_p';
c = cn[3]; c.name = 'category_id_p'; c.id = 'category_id_p';
c = cn[4]; c.name = 'currency_id_p'; c.id = 'currency_id_p';
c = cn[5]; c.name = 'currency_symbol_p'; c.id = 'currency_symbol_p';
}
else {
c = cn[0]; c.name = ''; c.id = ''; c.className = 'inputs';
c = cn[1]; c.name = ''; c.id = '';
//c = cn[3]; c.name = ''; c.id = '';
c = cn[3]; c.name = ''; c.id = '';
c = cn[4]; c.name = ''; c.id = '';
c = cn[5]; c.name = ''; c.id = '';
}
}
cell.onSelect = function() {
var xy = findPos(this);
this.TopPosition = xy[1];
this.LeftPosition = xy[0];
var top = xy[1]+this.offsetHeight;
var itd = document.getElementById('itemsTableDIV');
AjaxSearchProducts.setInputCode(this.getElementsByTagName('input')[0]);
if(!AjaxSearchProducts.AjaxSearchFrozen) {
AjaxSearchProducts.div.style.left = xy[0];
AjaxSearchProducts.div.TopPosition = top;
AjaxSearchProducts.div.style.top = top-itd.scrollTop;
}
this.ajax_search = false;
this.parentNode.noHideASP = false;
}
cell.onDeselect = function() {
if(!this.parentNode.noHideASP) AjaxSearchProducts.div.style.display = 'none';
this.ajax_search = false;
}
cell.getData = function(data) {
var cn = this.getElementsByTagName('input');
data.code = cn[0].value;
data.id = cn[1].value;
//data.vat_id = cn[3].value;
data.category_id = cn[3].value;
data.currency_id = cn[4].value;
data.currency_symbol = cn[5].value;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
cn[0].value = ((data.code)?data.code:'');
cn[1].value = ((data.id)?data.id:'');
//if(data.vat_id) cn[3].value = data.vat_id;
cn[3].value = ((data.category_id)?data.category_id:OPT['default_category']);
cn[4].value = ((data.currency_id)?data.currency_id:OPT['default_currency_id']);
cn[5].value = ((data.currency_symbol)?data.currency_symbol:OPT['default_category']);
}
cell.onKeyDownEvent = function(ev,input) {
var keynum; if(window.event) keynum = ev.keyCode; else keynum = ev.which;
if(keynum != 13 && keynum != 9) this.ajax_search = true;
if(this.ajax_search == true) {
AjaxSearchProducts.div.style.display = '';
setTimeout( function() {
AjaxSearchProducts.inputSearch.value=input.value;
AjaxSearchProducts.inputSearchOnKeyDown(keynum,"clear");
}, 50 );
}
if(input.value == '' && keynum == 40) { setSelectionRange(AjaxSearchProducts.inputSearch); return false; }
if(keynum == 13 || keynum == 9) {
if(input.value == '') return false;
if(this.parentNode.myTable.selectedCell && this.parentNode.myTable.selectedCell.index == 1) this.selectNext();
return false;
}
if(keynum == 27) { return false; }
return true;
//return input.parentNode.myTable.KeyPressed(ev,input.parentNode,null,true);
}
var edit = ' ';
cell.innerHTML = edit;
cell.align = 'right';
var id = document.createElement('input');
id.setAttribute('type','hidden');
cell.appendChild(id);
var unit_id = document.createElement('input');
unit_id.setAttribute('type','hidden');
unit_id.setAttribute('value',OPT['default_unit']);
cell.appendChild(unit_id);
/*
var vat_id = document.createElement('input');
vat_id.setAttribute('type','hidden');
vat_id.setAttribute('value',OPT['default_vat']);
cell.appendChild(vat_id);
*/
var category_id = document.createElement('input');
category_id.setAttribute('type','hidden');
category_id.setAttribute('value',OPT['default_category']);
cell.appendChild(category_id);
var currency_id = document.createElement('input');
currency_id.setAttribute('type','hidden');
currency_id.setAttribute('value',OPT['default_currency']);
cell.appendChild(currency_id);
var currency_symbol = document.createElement('input');
currency_symbol.setAttribute('type','hidden');
currency_symbol.setAttribute('value',OPT['default_category']);
cell.appendChild(currency_symbol);
var img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_IMG_SEARCH']);
img.setAttribute('src','modules/EcmStockDocIns/images/search.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.select(); my_popup('EcmProducts',{'id':'id_p','code':'code_p','name':'name_p','srp_price':'price_p','unit_id':'unit_id_p','vat_id':'vat_id_p','vat_value':'vat_value_p','vat_name':'vat_name_p','encoded_category_id':'category_id_p', 'currency_id':'currency_id_p', 'currency_symbol':'currency_symbol_p'}); }
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
var img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_IMG_EDIT']);
img.setAttribute('src','modules/EcmStockDocIns/images/edit_position.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
var data = new Object();
this.parentNode.getData(data);
window.open("index.php?module=EcmStockDocIns&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName=productFL&createModule=EcmProducts&fl_record="+data.id ,"New","resizable=yes,scrollbars=no,status=no,height=700,width=900").focus();
};
//cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
var img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_IMG_NEW']);
img.setAttribute('src','modules/EcmStockDocIns/images/add_position.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
window.open("index.php?module=EcmStockDocIns&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName=productFL&createModule=EcmProducts" ,"Create","resizable=yes,scrollbars=no,status=no,height=700,width=900").focus();
/*
this.parentNode.addToBase = !this.parentNode.addToBase;
if(!this.parentNode.addToBase) this.src = 'modules/EcmStockDocIns/images/new.gif';
else this.src = 'modules/EcmStockDocIns/images/newset.gif'
*/
};
//cell.appendChild(img);
}
if(i == 2) {
cell.change = function(select) {
var c;
if(select) {
c = this.childNodes[0]; c.name = 'name_p'; c.id = 'name_p'; //c.className = 'sqsEnabled';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = ''; c.className = '';
}
}
cell.getData = function(data) {
var cn = this.getElementsByTagName('textarea');
data.name = cn[0].value;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('textarea');
cn[0].value = ((data.name)?data.name:'');
}
var textarea = '';
cell.innerHTML = textarea;
}
if(i == 3) {
cell.change = function(select) {
var c;
if(select) {
c = this.childNodes[0]; c.name = 'quantity_p'; c.id = 'quantity_p';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = '';
}
}
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(1);
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.quantity = data.quantity;
this.setData(data);
}
}
var edit = ' ';
cell.innerHTML = edit;
}
if(i == 4) {
cell.change = function(select) {
// alert('test');
var c;
if(select) {
c = this.childNodes[0]; c.name = 'unit_id_p'; c.id = 'unit_id_p';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = '';
}
}
cell.getData = function(data,noAlert) {
var cn=this.getElementsByTagName('input');
data.unit_id = cn[0].value;
data.unit_name = cn[1].value;
}
cell.setData = function(data) {
var cn=this.getElementsByTagName('input');
if(data.unit_name){
cn[0].value = data.unit_id;
cn[1].value = data.unit_name;
}
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.unit_id = data.unit_id;
data.unit_name = data.unit_name;
this.setData(data);
}
}
var inp = document.createElement('input');
inp.setAttribute('type','hidden');
inp.setAttribute('value','1');
inp.className = 'inputs';
inp.cell = cell;
cell.appendChild(inp);
var inp = document.createElement('input');
inp.setAttribute('type','text');
inp.setAttribute('value','szt');
inp.setAttribute('readonly','readonly');
inp.className = 'inputs';
inp.cell = cell;
cell.appendChild(inp);
var img=document.createElement('img');
img.setAttribute('src','modules/EcmQuotes/images/edit_position.gif');
img.setAttribute('style','cursor:pointer;display:block;');
img.onclick=function(){
if(div.style.display=='none')div.style.display='block';
else div.style.display='none';
}
//cell.appendChild(img);
var div=document.createElement('div');
div.setAttribute('style','display:none;float:right;text-align:right;border: 1px #cccccc solid;padding:3px; background-color: #F0FFA0; z-index: 999;');
var key;
for(key in UNIT_LANG){
if(UNIT_LANG[key]){
var option=document.createElement('a');
option.setAttribute('id',UNIT_LANG[key].id);
option.setAttribute('name',UNIT_LANG[key].value);
option.onclick=function(){
cell.getElementsByTagName('input')[0].value=this.id;
cell.getElementsByTagName('input')[1].value=this.name;
div.style.display='none';
}
option.innerHTML=UNIT_LANG[key].value+' ';
option.setAttribute('style','cursor:pointer;');
div.appendChild(option);
}
}
//cell.appendChild(div);
// var edit = ' ';
//cell.innerHTML = edit;
}
if(i == 5) {
cell.change = function(select) {
var c;
if(select) {
c = this.childNodes[0]; c.name = 'price_last_p'; c.id = 'price_last_p';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = '';
}
}
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_last = 0;
this.firstChild.style.color = 'red';
} else {
data.price_last = tmp;
this.firstChild.style.color = 'black';
}
}
cell.setData = function(data) {
if(data.price_last) this.firstChild.value = NumberToUserFormatNumber(data.price_last); else this.firstChild.value = NumberToUserFormatNumber(1);
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.price_last = data.price_last;
this.setData(data);
}
}
var edit = ' ';
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.invoice_price = 0;
this.firstChild.style.color = 'red';
} else {
data.invoice_price = tmp;
this.firstChild.style.color = 'black';
}
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.invoice_price = data.invoice_price;
this.setData(data);
}
}
cell.setData = function(data) {
if(data.invoice_price) this.firstChild.value = NumberToUserFormatNumber(data.invoice_price); else this.firstChild.value = NumberToUserFormatNumber(0);
}
var edit = ' ';
cell.innerHTML = edit;
}
if(i == 7) {
cell.change = function(select) {
var c;
if(select) {
c = this.childNodes[0]; c.name = 'price_p'; c.id = 'price_p';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = '';
}
}
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);
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.price = data.price;
this.setData(data);
}
}
var edit = ' ';
cell.innerHTML = edit;
}
if(i == 8) {
cell.getData = function(data,noAlert) {
var cn = this.getElementsByTagName('input');
data.invoice_price = UserFormatNumberToNumber(cn[0].value);
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
if(data.invoice_price) cn[0].value = NumberToUserFormatNumber(data.invoice_price);
else this.firstChild.value = NumberToUserFormatNumber(0);
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.invoice_price = data.invoice_price;
this.setData(data);
}
}
var edit = ' ';
cell.innerHTML = edit;
}
if(i == 7) {
cell.getData = function(data,noAlert) {
var cn = this.getElementsByTagName('input');
data.price=UserFormatNumberToNumber(cn[0].value);
}
cell.setData = function(data) {
if(data.price) this.firstChild.value = NumberToUserFormatNumber(data.price);
/*
else if (document.getElementById('kind')=='country')
// get price from last pz - mz 2012-03-27
{
doRequest(
'index.php',
'to_pdf=1&generate=1&module=EcmStockDocIns&action=getLastPZPrice&product_id='+data.id,
function(result){
if (result)
cn[0].value = NumberToUserFormatNumber(result);
else cn[0].value = NumberToUserFormatNumber(0);
},
''
);
}
*/
else this.firstChild.value = NumberToUserFormatNumber(0);
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.price = data.price;
this.setData(data);
}
}
var edit = ' ';
cell.innerHTML = edit;
}
if(i == 8) {
cell.change = function(select) {
var c;
if(select) {
c = this.childNodes[0]; c.name = 'vat_name_p'; c.id = 'vat_name_p';
c = this.childNodes[1]; c.name = 'vat_value_p'; c.id = 'vat_value_p';
c = this.childNodes[2]; c.name = 'vat_id_p'; c.id = 'vat_id_p';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = '';
c = this.childNodes[1]; c.name = ''; c.id = '';
c = this.childNodes[2]; c.name = ''; c.id = '';
}
}
cell.getData = function(data,noAlert) {
var cn = this.getElementsByTagName('input');
data.vat_value = cn[1].value;
data.vat_id = cn[2].value;
//if(VAT[cn[2].value])data.vat_name = VAT[cn[2].value].name;
}
cell.setData = function(data) {
if(data.vat_value) this.getElementsByTagName('input')[1].value = data.vat_value; //0->1, 1->2, 2->0
if(data.vat_id) this.getElementsByTagName('input')[2].value = data.vat_id;
if(data.vat_name) this.getElementsByTagName('input')[0].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 div=document.createElement('div');
div.setAttribute('style','display:none;float:right;text-align:right;border: 1px #cccccc solid;padding:3px;');
var key;
for(key in VAT){
if(VAT[key]){
var option=document.createElement('a');
option.setAttribute('id',VAT[key].id);
option.setAttribute('name',VAT[key].name);
option.onclick=function(){
cell.getElementsByTagName('input')[0].value=this.name;
cell.getElementsByTagName('input')[1].value=VAT[this.id].value;
cell.getElementsByTagName('input')[2].value=this.id;
div.style.display='none';
}
option.innerHTML=VAT[key].name+' ';
option.setAttribute('style','cursor:pointer;');
div.appendChild(option);
}
}
var img=document.createElement('img');
img.setAttribute('src','modules/EcmInvoiceOuts/images/edit_position.gif');
img.setAttribute('style','cursor:pointer;display:inline;');
img.onclick=function(){
if(div.style.display=='none')div.style.display='block';
else div.style.display='none';
}
var edit = ' ';
cell.innerHTML = edit;
cell.appendChild(div);
cell.appendChild(img);
}
/*
if(i == 6) {
cell.change = function(select) {
var c;
if(select) {
c = this.childNodes[0]; c.name = 'discount_p'; c.id = 'discount_p';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = '';
}
}
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.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.discount = data.discount;
this.setData(data);
}
}
cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(0).select(); };
var edit = ' ';
cell.innerHTML = edit;
}
*/
if(i == 9) {
//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";
edit.onkeydown = function()
{
//this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
//var row = this.parentNode.selectNext(); row.select(); row.cells.item(0).select();
}
cell.appendChild(edit);
}
if(i ==10) {
cell.getData = function(data,noAlert) {
var tmp = UserFormatNumberToNumber(this.firstChild.value);
if(tmp == -1) {
ERROR = true;
data.weight_netto = 0;
} else {
data.weight_netto = tmp;
}
}
cell.setData = function(data) {
if(data.weight_netto) this.firstChild.value = NumberToUserFormatNumber(data.weight_netto); else this.firstChild.value = NumberToUserFormatNumber(1);
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.weight_netto = data.weight_netto;
this.setData(data);
}
}
var edit = ' ';
cell.innerHTML = edit;
}
if(i == 11) {
cell.getData = function(data,noAlert) {
var cn=this.getElementsByTagName('input');
var tmp = UserFormatNumberToNumber(cn[0].value);
data.duty = tmp;
}
cell.setData = function(data) {
var cn=this.getElementsByTagName('input');
if(data.duty) cn[0].value = NumberToUserFormatNumber(data.duty)+'%'; else cn[0].value = NumberToUserFormatNumber(0)+'%';
}
var obj = document.forms.EditView.kind;
var kind = obj.options[obj.selectedIndex].value;
var country_div=document.createElement('div');
country_div.style.display='none';
country_div.setAttribute('class','items_country_div');
if (kind=='other')
country_div.style.display='block';
country_div.appendChild(document.createTextNode(MOD['LBL_EDITTABLE_NO_ADD_FIELDS']));
cell.appendChild(country_div);
var import_div=document.createElement('div');
import_div.style.display='none';
import_div.setAttribute('class','items_import_div');
if (kind=='import')
import_div.style.display='block';
import_div.appendChild(document.createTextNode(MOD['LBL_EDITTABLE_DUTY']));
var inp = document.createElement('input');
inp.setAttribute('type','text');
inp.setAttribute('value',NumberToUserFormatNumber(0));
inp.className = 'inputs';
inp.cell = cell;
import_div.appendChild(inp);
cell.appendChild(import_div);
}
if(i == 12) {
cell.change = function(select) {
var c;
if(select) {
c = this.childNodes[0]; c.name = 'part_no'; c.id = 'part_no'; //c.className = 'sqsEnabled';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = ''; c.className = '';
}
}
cell.getData = function(data) {
var cn = this.getElementsByTagName('textarea');
data.part_no = cn[0].value;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('textarea');
cn[0].value = ((data.part_no)?data.part_no:'');
}
var textarea = '';
cell.innerHTML = textarea;
}
if(i == 13) {
cell.change = function(select) {
var c;
if(select) {
c = this.childNodes[0]; c.name = 'part_date'; c.id = 'part_date'; //c.className = 'sqsEnabled';
}
else {
c = this.childNodes[0]; c.name = ''; c.id = ''; c.className = '';
}
}
cell.getData = function(data) {
var cn = this.getElementsByTagName('input');
data.part_date = cn[0].value;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
cn[0].value = ((data.part_date)?data.part_date:'');
}
var edit = ' ';
cell.innerHTML = edit;
}
if(i == 14) {
var img;
//insert
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src','modules/EcmStockDocIns/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
img.setAttribute('src','modules/EcmStockDocIns/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.deleteRow(); };
cell.appendChild(img);
cell.appendChild(document.createElement('br'));
//move up
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src','modules/EcmStockDocIns/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveUp(); };
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src','modules/EcmStockDocIns/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveDown(); }
cell.appendChild(img);
}
}
N.onSetCellData = function(row,cell,data) {
if(cell.innerHTML == '') cell.innerHTML = ' ';
}
var pl = document.getElementById('position_list').value;
if(pl && pl != '') {
try {
pl = eval(pl);
for(x in pl) { var pl_row = pl[x]; if(!pl[x].code || pl[x].code == '') {} else N.addRow().setData(pl_row); }
} catch(err) { pl = null; };
}
if(N.rowCount() == 0) N.addRow();
//add mz 2012-03-20
function pf(i) {
return parseFloat(i);
}
function pf2(i) {
return UserFormatNumberToNumber(i);
}
function calculatePurchasePrices() {
kind = document.forms.EditView.kind.value;
if (kind == 'other') {
for(var i=0; i";
}
else
{
vats[x]['node']=1;
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 = " ";
}
}
var total2 = total;
var discount;
// if((discount = CheckDiscount(true)) == -1) discount = 0;
//var discount2 = total2*discount/100;
//total = total2-discount2;
total = total2;
//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;
//rt.rows.item(rt.rows.length-2).cells.item(0).innerHTML = MOD['LBL_DISCOUNT']+' ('+NumberToUserFormatNumber(discount,'%')+')';
//document.getElementById('discount_2').value = discount2;
//document.getElementById('total').value = total;
//document.getElementById('cbm_total').value = cbm_total;
}
sqs_objects["code_p"] = {
"method":"get_product_array",
"modules":["EcmProducts"],
"field_list":["date_entered", "code", "id", "encoded_unit_id", "vat_id", "encoded_category_id", "name", "selling_price", "currency_id",'price_last'],
"populate_list":["code_p", "code_p", "id_p", "unit_id_p", "vat_id_p", "category_id_p", "name_p", "price_p", "currency_id_p","price_last_p"],
"conditions":[{"name":"code","op":"like_custom","end":"%","value":""}],
"limit":"30",
"order":"code",
"no_match_text":"No Match"
};
sqs_objects["name_p"] = {
"method":"get_product_array",
"modules":["EcmProducts"],
"field_list":["date_entered", "name", "id", "encoded_unit_id", "vat_id", "encoded_category_id", "code", "selling_price", "currency_id",'price_last'],
"populate_list":["name_p", "name_p", "id_p", "unit_id_p", "vat_id_p", "category_id_p", "code_p", "price_p", "currency_id_p","price_last_p"],
"conditions":[{"name":"name","op":"like_custom","end":"%","value":""}],
"limit":"30",
"order":"name",
"no_match_text":"No Match"
};
function generateNumber() {
if(document.getElementById('template_id').value == '') { alert('There are no DocumentTemplates in data base!'); return;}
doRequest(
'index.php',
'to_pdf=1&generate=1&module=EcmStockDocIns&action=generateNumber&type=normal&template_id='+document.getElementById('template_id').value+'&record='+document.forms.EditView.record.value,
function(result){
var arr = eval(result)[0];
document.getElementById('number').value = arr.number;
document.getElementById('document_no').value = arr.document_no;
document.getElementById('status').value ='accepted';
},
''
);
};
calculateTotal();
if(OPT['new_number']) generateNumber();
if(document.getElementById('template_id').value != '') document.getElementById('template_id').onchange();
addEvent('template_id','change',generateNumber);
//addEvent(document.forms.EditView.status,'change',canConfirm);
setPREVIEW = function() {
//if(CheckDiscount() != -1) {
calculateTotal();
sendFormPostToPdf();
//}
}
setITEMS = function() {
//if(CheckDiscount() != -1) {
calculateTotal();
SetTab('ITEMS');
//}
}
if(!OPT.user.access.send_email)
setEMAIL = function() { alert(MOD['LBL_ACCESS_UNAVAIBLE_DELETE_EMAIL']); };
else
setEMAIL = function(noCheck) {
//if(CheckDiscount() != -1) {
calculateTotal();
OPT['setEmailTab'] = 0;
var view = true;
if(!noCheck) {
var record = document.forms.EditView.record.value;
if(record == '') {
alert('Quote is not saved!');
view = false;
}
else {
if(confirm('Save quote changes?')) {
OPT['setEmailTab'] = 1;
view = false;
SaveForm();
}
}
//}
if(view) {
SetTab('EMAIL');
document.getElementById('emailTAB').innerHTML = "";
}
}
}
CHANGER.add('kind', 'value', function(obj){
kind = document.forms.EditView.kind.value;
select_kind(kind);
}, true);
/*
CHANGER.add('to_is_vat_free', 'checked', function(obj){
obj.value = (obj.checked) ? 1 : 0;
OPT['to_is_vat_free'] = obj.value;
calculateTotal();
},
false
);
*/
//CHANGER.add('parent_id','value',function(){alert('zmiana parent');},true);
function setToAddrEmail(str) {
if(str && str != '') str = eval(str); else str = '';
if(typeof(str) == "object") str = str[0]; else str = '';
if(document.getElementById('parent_type').value == 'Accounts') {
//= document.getElementById('to_addrs_field'); if(tmp) tmp.value = (str=='')?'':(((str.name)?str.name:'')+' <'+((str.email1)?str.email1:'')+'>; ');
tmp = document.getElementById('parent_address_street'); if(tmp) tmp.value = (str.billing_address_street)?str.billing_address_street:'';
tmp = document.getElementById('parent_address_city'); if(tmp) tmp.value = (str.billing_address_city)?str.billing_address_city:'';
tmp = document.getElementById('parent_address_postalcode'); if(tmp) tmp.value = (str.billing_address_postalcode)?str.billing_address_postalcode:'';
tmp = document.getElementById('parent_address_country'); if(tmp) tmp.value = (str.billing_address_country)?str.billing_address_country:'';
// tmp = document.getElementById('to_nip'); if(tmp) tmp.value = (str.sic_code)?str.sic_code:'';
tmp = document.getElementById('to_vatid'); if(tmp) tmp.value = (str.vatid)?str.vatid:'';
tmp = document.getElementById('to_is_vat_free'); if(tmp) tmp.checked = (str.is_vat_free == 1)?true:false;
document.getElementById('parent_name_copy').value = document.getElementById('parent_name').value;
tmp = document.getElementById('ecmlanguage'); if(tmp && str.ecmlanguage) { if(tmp.value != str.ecmlanguage) { tmp.value = str.ecmlanguage; setTexts(); } }
tmp = document.getElementById('currency_id'); if(tmp) tmp.value = (str.currency_id)?str.currency_id:'';
}
}
function ChangeAccessFunction(obj,type) {
var objs = obj.getElementsByTagName('input');
for(var i=0; i