154 lines
4.8 KiB
JavaScript
Executable File
154 lines
4.8 KiB
JavaScript
Executable File
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
addEvent(
|
|
|
|
window,
|
|
|
|
'load',
|
|
|
|
function () {
|
|
|
|
//initialize table
|
|
N = new MyTable('itemsTable');
|
|
|
|
N.divParent = document.getElementById('itemsTableDIV');
|
|
|
|
|
|
N.onCreateRow = function(row) {
|
|
row.newPos = false;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
var itd = document.getElementById('itemsTableDIV');
|
|
|
|
N.onCreateCell = function(cell) {
|
|
|
|
var i = cell.index;
|
|
cell.change = function(select) {};
|
|
cell.style.height = OPT['row_item_height'];
|
|
|
|
|
|
if(i == 0) {
|
|
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[2]; c.name = 'iid_p'; c.id = 'iid_p';
|
|
}
|
|
else {
|
|
c = cn[0]; c.name = ''; c.id = ''; c.className = 'inputs';
|
|
c = cn[1]; c.name = ''; c.id = '';
|
|
c = cn[2]; c.name = ''; c.id = '';
|
|
}
|
|
}
|
|
|
|
cell.getData = function(data) {
|
|
var cn = this.getElementsByTagName('input');
|
|
data.code = cn[0].value;
|
|
data.id = cn[1].value;
|
|
data.iid = cn[2].value;
|
|
}
|
|
cell.setData = function(data) {
|
|
var cn = this.getElementsByTagName('input');
|
|
cn[0].value = ((data.code)?data.code:'');
|
|
cn[1].value = ((data.id)?data.id:'');
|
|
cn[2].value = ((data.iid)?data.iid:'');
|
|
}
|
|
var edit = '<input type="text" onFocus="this.parentNode.select();" tabindex="1" class="inputs" style="height:16px;" autocomplete="off" readonly="readonly"><br>';
|
|
cell.innerHTML = edit;
|
|
cell.align = 'right';
|
|
var id = document.createElement('input');
|
|
id.setAttribute('type','hidden');
|
|
cell.appendChild(id);
|
|
|
|
var iid = document.createElement('input');
|
|
iid.setAttribute('type','hidden');
|
|
cell.appendChild(iid);
|
|
}
|
|
//nazwa
|
|
if(i == 1) {
|
|
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 = '<textarea tabindex="1" onFocus="this.parentNode.select();" style="width:100%;height:100%;" readonly="readonly" class="inputs" onKeyDown="return this.parentNode.myTable.KeyPressed(event,this.parentNode,null,true);"></textarea>';
|
|
cell.innerHTML = textarea;
|
|
}
|
|
}
|
|
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();
|
|
|
|
ItemsList = function(json) {
|
|
var data = '';
|
|
for(var i=0; i<N.rowCount(); i++) {
|
|
data = data + '||||' + JSON.stringifyNoSecurity(N.row(i).getData());
|
|
}
|
|
|
|
return data;
|
|
}
|
|
function HideLoadingView() {
|
|
var slv = document.getElementById('ShowLoadingView');
|
|
if(slv) slv.style.display = 'none';
|
|
}
|
|
setPREVIEW = function() {
|
|
SetTab('panel_PREVIEW');
|
|
document.getElementById('previewPDF').innerHTML = '<iframe style="border:none;width:100%;height:1200px;" frameborder="no" src="index.php?module=EcmPrepaymentInvoices&action=previewPDF&to_pdf=1&method=I&record='+document.forms.DetailView.record.value+'#zoom=75">Yours browser not accept iframes!</iframe>';
|
|
}
|
|
}
|
|
); |