Add JS files
This commit is contained in:
396
modules/EcmWorkCards/js/DetailViewDocumentReady.js
Executable file
396
modules/EcmWorkCards/js/DetailViewDocumentReady.js
Executable file
@@ -0,0 +1,396 @@
|
||||
$(document).ready(function () {
|
||||
var tmp = $.parseJSON($("input[name='tableEcmActions_list']").val());
|
||||
tmp = b64_to_utf8(tmp);
|
||||
tmp = $.parseJSON(tmp);
|
||||
InitializeTableEcmActions(tmp);
|
||||
|
||||
var sumanetto = 0;
|
||||
var sumabrutto = 0;
|
||||
$.each(tmp, function (key, value) {
|
||||
sumanetto = sumanetto + UnformatNumber(value['ecmactioncost_display']);
|
||||
sumabrutto = sumabrutto + UnformatNumber(value['costbrutto_display']);
|
||||
});
|
||||
$('#sum_netto').text(FormatNumber(sumanetto));
|
||||
$('#sum_brutto').text(FormatNumber(sumabrutto));
|
||||
});
|
||||
|
||||
function InitializeTableEcmActions(tmp) {
|
||||
$('#tableEcmActions').appendGrid({
|
||||
hideRowNumColumn: true,
|
||||
initData: tmp,
|
||||
initRows: 0,
|
||||
columns: [
|
||||
{
|
||||
name: 'produkt',
|
||||
display: 'Produkt',
|
||||
type: 'custom',
|
||||
ctrlClass: 'inputs',
|
||||
ctrlAttr : {readonly : 'readonly'},
|
||||
displayCss: {
|
||||
// 'width': '30%',
|
||||
'vertical-align': 'middle',
|
||||
'text-align': 'center',
|
||||
'background-color': 'rgb(224,240,255)',
|
||||
'border': '1px solid rgb(48,192,255)',
|
||||
'height': '0px',
|
||||
'font-family': 'Arial',
|
||||
'font-size': '12px',
|
||||
'color': 'black',
|
||||
},
|
||||
value: ['', '', ''],
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
// Prepare the control ID/name by using idPrefix, column name and uniqueIndex
|
||||
var ctrlId = idPrefix + '_' + name + '_table_' + uniqueIndex;
|
||||
var upperRowId = idPrefix + '_' + name + '_upperRow_' + uniqueIndex;
|
||||
var lowerRowId = idPrefix + '_' + name + '_lowerRow_' + uniqueIndex;
|
||||
var upperCellId = idPrefix + '_' + name + '_upperCell_' + uniqueIndex;
|
||||
var lowerCellId = idPrefix + '_' + name + '_lowerCell_' + uniqueIndex;
|
||||
|
||||
var ctrl = document.createElement('table');
|
||||
$(ctrl).attr({ id: ctrlId, name: ctrlId }).appendTo(parent);
|
||||
$(ctrl).css('border', '0px solid white');
|
||||
$(ctrl).addClass('positions');
|
||||
|
||||
var upperRow = document.createElement('tr');
|
||||
$(upperRow).attr({ id: upperRowId, name: upperRowId }).appendTo(ctrl);
|
||||
$(upperRow).css('border', '0px solid white');
|
||||
|
||||
var lowerRow = document.createElement('tr');
|
||||
$(lowerRow).attr({ id: lowerRowId, name: lowerRowId }).appendTo(ctrl);
|
||||
$(lowerRow).css('border', '0px solid white');
|
||||
|
||||
var upperCell = document.createElement('td');
|
||||
$(upperCell).attr({ id: upperCellId, name: upperCellId }).appendTo(upperRow);
|
||||
$(upperCell).css('border', '0px solid white');
|
||||
upperCell.style.overflow = "hidden";
|
||||
|
||||
var lowerCell = document.createElement('td');
|
||||
$(lowerCell).attr({ id: lowerCellId, name: lowerCellId }).appendTo(lowerRow);
|
||||
$(lowerCell).css('border', '0px solid white');
|
||||
lowerCell.style.overflow = "hidden";
|
||||
// Create extra controls and add to container
|
||||
// Finally, return the container control
|
||||
return ctrl;
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
return '0';
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
var upperCellId = idPrefix + '_' + name + '_upperCell_' + uniqueIndex;
|
||||
var lowerCellId = idPrefix + '_' + name + '_lowerCell_' + uniqueIndex;
|
||||
|
||||
if( Object.prototype.toString.call( value ) === '[object Array]' ) {
|
||||
var indeksUrl = document.createElement('a');
|
||||
indeksUrl.href = 'index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value[2];
|
||||
indeksUrl.onclick = function (){
|
||||
window.open('index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value[2],'1426150651552','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0');
|
||||
return false;
|
||||
};
|
||||
indeksUrl.title = value[0];
|
||||
indeksUrl.textContent = value[0];
|
||||
|
||||
var nazwaUrl = document.createElement('a');
|
||||
nazwaUrl.href = 'index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value[2];
|
||||
nazwaUrl.onclick = function (){
|
||||
window.open('index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value[2],'1426150651552','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0');
|
||||
return false;
|
||||
};
|
||||
nazwaUrl.title = value[1];
|
||||
nazwaUrl.textContent = value[1];
|
||||
$('#' + upperCellId).html(indeksUrl);
|
||||
$('#' + lowerCellId).html(nazwaUrl);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'czynnosc',
|
||||
display: 'Czynność',
|
||||
type: 'custom',
|
||||
ctrlClass: 'inputs',
|
||||
ctrlAttr : {readonly : 'readonly'},
|
||||
displayCss: {
|
||||
// 'width': '30%',
|
||||
'vertical-align': 'middle',
|
||||
'text-align': 'center',
|
||||
'background-color': 'rgb(224,240,255)',
|
||||
'border': '1px solid rgb(48,192,255)',
|
||||
'height': '0px',
|
||||
'font-family': 'Arial',
|
||||
'font-size': '12px',
|
||||
'color': 'black',
|
||||
},
|
||||
value: ['', '', ''],
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
// Prepare the control ID/name by using idPrefix, column name and uniqueIndex
|
||||
var ctrlId = idPrefix + '_' + name + '_table_' + uniqueIndex;
|
||||
var upperRowId = idPrefix + '_' + name + '_upperRow_' + uniqueIndex;
|
||||
var lowerRowId = idPrefix + '_' + name + '_lowerRow_' + uniqueIndex;
|
||||
var upperCellId = idPrefix + '_' + name + '_upperCell_' + uniqueIndex;
|
||||
var lowerCellId = idPrefix + '_' + name + '_lowerCell_' + uniqueIndex;
|
||||
|
||||
var ctrl = document.createElement('table');
|
||||
$(ctrl).attr({ id: ctrlId, name: ctrlId }).appendTo(parent);
|
||||
$(ctrl).css('border', '0px solid white');
|
||||
$(ctrl).addClass('positions');
|
||||
|
||||
var upperRow = document.createElement('tr');
|
||||
$(upperRow).attr({ id: upperRowId, name: upperRowId }).appendTo(ctrl);
|
||||
$(upperRow).css('border', '0px solid white');
|
||||
|
||||
var lowerRow = document.createElement('tr');
|
||||
$(lowerRow).attr({ id: lowerRowId, name: lowerRowId }).appendTo(ctrl);
|
||||
$(lowerRow).css('border', '0px solid white');
|
||||
|
||||
var upperCell = document.createElement('td');
|
||||
$(upperCell).attr({ id: upperCellId, name: upperCellId }).appendTo(upperRow);
|
||||
$(upperCell).css('border', '0px solid white');
|
||||
upperCell.style.overflow = "hidden";
|
||||
|
||||
var lowerCell = document.createElement('td');
|
||||
$(lowerCell).attr({ id: lowerCellId, name: lowerCellId }).appendTo(lowerRow);
|
||||
$(lowerCell).css('border', '0px solid white');
|
||||
lowerCell.style.overflow = "hidden";
|
||||
// Create extra controls and add to container
|
||||
// Finally, return the container control
|
||||
return ctrl;
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
return '0';
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
var upperCellId = idPrefix + '_' + name + '_upperCell_' + uniqueIndex;
|
||||
var lowerCellId = idPrefix + '_' + name + '_lowerCell_' + uniqueIndex;
|
||||
|
||||
if( Object.prototype.toString.call( value ) === '[object Array]' ) {
|
||||
var indeksUrl = document.createElement('a');
|
||||
indeksUrl.href = 'index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value[2];
|
||||
indeksUrl.onclick = function (){
|
||||
window.open('index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value[2],'1426150651552','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0');
|
||||
return false;
|
||||
};
|
||||
indeksUrl.title = value[0];
|
||||
indeksUrl.textContent = value[0];
|
||||
|
||||
var nazwaUrl = document.createElement('a');
|
||||
nazwaUrl.href = 'index.php?module=EcmActions&return_module=EcmActions&action=DetailView&record=' + value[2];
|
||||
nazwaUrl.onclick = function (){
|
||||
window.open('index.php?module=EcmActions&return_module=EcmActions&action=DetailView&record=' + value[2],'1426150651552','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0');
|
||||
return false;
|
||||
};
|
||||
nazwaUrl.title = value[1];
|
||||
nazwaUrl.textContent = value[1];
|
||||
$('#' + upperCellId).html(indeksUrl);
|
||||
$('#' + lowerCellId).html(nazwaUrl);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'quantity',
|
||||
display: 'Ilość',
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
ctrlAttr : {readonly : 'readonly'},
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
displayCss: {
|
||||
'width': '50px',
|
||||
'vertical-align': 'middle',
|
||||
'text-align': 'center',
|
||||
'background-color': 'rgb(224,240,255)',
|
||||
'border': '1px solid rgb(48,192,255)',
|
||||
'height': '0px',
|
||||
'font-family': 'Arial',
|
||||
'font-size': '12px',
|
||||
'color': 'black',}
|
||||
},{
|
||||
name: 'netto',
|
||||
display: ' Cena / Wartość netto',
|
||||
type: 'custom',
|
||||
ctrlClass: 'inputs',
|
||||
ctrlAttr : {readonly : 'readonly'},
|
||||
displayCss: {
|
||||
'width': '130px',
|
||||
'vertical-align': 'middle',
|
||||
'text-align': 'center',
|
||||
'background-color': 'rgb(224,240,255)',
|
||||
'border': '1px solid rgb(48,192,255)',
|
||||
'height': '0px',
|
||||
'font-family': 'Arial',
|
||||
'font-size': '12px',
|
||||
'color': 'black',
|
||||
},
|
||||
value: ['', ''],
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
// Prepare the control ID/name by using idPrefix, column name and uniqueIndex
|
||||
var ctrlId = idPrefix + '_' + name + '_table_' + uniqueIndex;
|
||||
var upperRowId = idPrefix + '_' + name + '_upperRow_' + uniqueIndex;
|
||||
var lowerRowId = idPrefix + '_' + name + '_lowerRow_' + uniqueIndex;
|
||||
var upperCellId = idPrefix + '_' + name + '_upperCell_' + uniqueIndex;
|
||||
var lowerCellId = idPrefix + '_' + name + '_lowerCell_' + uniqueIndex;
|
||||
|
||||
var ctrl = document.createElement('table');
|
||||
$(ctrl).attr({ id: ctrlId, name: ctrlId }).appendTo(parent);
|
||||
$(ctrl).css('border', '0px solid white');
|
||||
$(ctrl).addClass('positions');
|
||||
|
||||
var upperRow = document.createElement('tr');
|
||||
$(upperRow).attr({ id: upperRowId, name: upperRowId }).appendTo(ctrl);
|
||||
$(upperRow).css('border', '0px solid white');
|
||||
|
||||
var lowerRow = document.createElement('tr');
|
||||
$(lowerRow).attr({ id: lowerRowId, name: lowerRowId }).appendTo(ctrl);
|
||||
$(lowerRow).css('border', '0px solid white');
|
||||
|
||||
var upperCell = document.createElement('td');
|
||||
$(upperCell).attr({ id: upperCellId, name: upperCellId }).appendTo(upperRow);
|
||||
$(upperCell).css('border', '0px solid white');
|
||||
$(upperCell).css('text-align', 'right');
|
||||
upperCell.style.overflow = "hidden";
|
||||
|
||||
var lowerCell = document.createElement('td');
|
||||
$(lowerCell).attr({ id: lowerCellId, name: lowerCellId }).appendTo(lowerRow);
|
||||
$(lowerCell).css('border', '0px solid white');
|
||||
$(lowerCell).css('text-align', 'right');
|
||||
lowerCell.style.overflow = "hidden";
|
||||
// Create extra controls and add to container
|
||||
// Finally, return the container control
|
||||
return ctrl;
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
return '0';
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
var upperCellId = idPrefix + '_' + name + '_upperCell_' + uniqueIndex;
|
||||
var lowerCellId = idPrefix + '_' + name + '_lowerCell_' + uniqueIndex;
|
||||
if( Object.prototype.toString.call( value ) === '[object Array]' ) {
|
||||
$('#' + upperCellId).html(value[0]);
|
||||
$('#' + lowerCellId).html(value[1]);
|
||||
}
|
||||
}
|
||||
},{
|
||||
name: 'brutto',
|
||||
display: ' Cena / Wartość brutto',
|
||||
type: 'custom',
|
||||
ctrlClass: 'inputs',
|
||||
ctrlAttr : {readonly : 'readonly'},
|
||||
displayCss: {
|
||||
'width': '130px',
|
||||
'vertical-align': 'middle',
|
||||
'text-align': 'center',
|
||||
'background-color': 'rgb(224,240,255)',
|
||||
'border': '1px solid rgb(48,192,255)',
|
||||
'height': '0px',
|
||||
'font-family': 'Arial',
|
||||
'font-size': '12px',
|
||||
'color': 'black',
|
||||
},
|
||||
value: ['', ''],
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
// Prepare the control ID/name by using idPrefix, column name and uniqueIndex
|
||||
var ctrlId = idPrefix + '_' + name + '_table_' + uniqueIndex;
|
||||
var upperRowId = idPrefix + '_' + name + '_upperRow_' + uniqueIndex;
|
||||
var lowerRowId = idPrefix + '_' + name + '_lowerRow_' + uniqueIndex;
|
||||
var upperCellId = idPrefix + '_' + name + '_upperCell_' + uniqueIndex;
|
||||
var lowerCellId = idPrefix + '_' + name + '_lowerCell_' + uniqueIndex;
|
||||
|
||||
var ctrl = document.createElement('table');
|
||||
$(ctrl).attr({ id: ctrlId, name: ctrlId }).appendTo(parent);
|
||||
$(ctrl).css('border', '0px solid white');
|
||||
$(ctrl).addClass('positions');
|
||||
|
||||
var upperRow = document.createElement('tr');
|
||||
$(upperRow).attr({ id: upperRowId, name: upperRowId }).appendTo(ctrl);
|
||||
$(upperRow).css('border', '0px solid white');
|
||||
|
||||
var lowerRow = document.createElement('tr');
|
||||
$(lowerRow).attr({ id: lowerRowId, name: lowerRowId }).appendTo(ctrl);
|
||||
$(lowerRow).css('border', '0px solid white');
|
||||
|
||||
var upperCell = document.createElement('td');
|
||||
$(upperCell).attr({ id: upperCellId, name: upperCellId }).appendTo(upperRow);
|
||||
$(upperCell).css('border', '0px solid white');
|
||||
$(upperCell).css('text-align', 'right');
|
||||
upperCell.style.overflow = "hidden";
|
||||
|
||||
var lowerCell = document.createElement('td');
|
||||
$(lowerCell).attr({ id: lowerCellId, name: lowerCellId }).appendTo(lowerRow);
|
||||
$(lowerCell).css('border', '0px solid white');
|
||||
$(lowerCell).css('text-align', 'right');
|
||||
lowerCell.style.overflow = "hidden";
|
||||
// Create extra controls and add to container
|
||||
// Finally, return the container control
|
||||
return ctrl;
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
return '0';
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
var upperCellId = idPrefix + '_' + name + '_upperCell_' + uniqueIndex;
|
||||
var lowerCellId = idPrefix + '_' + name + '_lowerCell_' + uniqueIndex;
|
||||
if( Object.prototype.toString.call( value ) === '[object Array]' ) {
|
||||
$('#' + upperCellId).html(value[0]);
|
||||
$('#' + lowerCellId).html(value[1]);
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
i18n: {
|
||||
rowEmpty: 'Brak rekordów'
|
||||
},
|
||||
hideButtons: {
|
||||
removeLast: true,
|
||||
append: true,
|
||||
insert: true,
|
||||
remove : true,
|
||||
moveUp: true,
|
||||
moveDown: true
|
||||
}
|
||||
});
|
||||
$('thead').removeClass('ui-widget-header');
|
||||
$('td').removeClass('ui-widget-header');
|
||||
$('tbody').removeClass('ui-widget-content');
|
||||
$('td').removeClass('ui-widget-content');
|
||||
$('tfoot').removeClass('ui-widget-header');
|
||||
}
|
||||
|
||||
function FormatNumber(number, precision) {
|
||||
var precision = precision || 2;
|
||||
// make string..
|
||||
number = number + '';
|
||||
number = number.replace(',', '.');
|
||||
// round
|
||||
number = toFixed(number, precision);
|
||||
// add 1000 sep
|
||||
var tmp = number.split(".");
|
||||
var c = '';
|
||||
for (var i = tmp[0].length; i != -1; i--) {
|
||||
c += tmp[0].charAt(i);
|
||||
if ((tmp[0].length - i) == 0 || i == 0)
|
||||
continue;
|
||||
if ((tmp[0].length - i) % 3 == 0)
|
||||
c += '.';
|
||||
}
|
||||
// reverse c
|
||||
c = c.split("").reverse().join("");
|
||||
return c + ',' + tmp[1];
|
||||
}
|
||||
|
||||
function toFixed(value, precision) {
|
||||
var precision = precision || 0,
|
||||
neg = value < 0, power = Math.pow(10, precision),
|
||||
value = Math.round(value * power),
|
||||
integral = String((neg ? Math.ceil : Math.floor)(value / power)),
|
||||
fraction = String((neg ? -value : value) % power),
|
||||
padding = new Array(Math.max(precision - fraction.length, 0) + 1).join('0');
|
||||
//fix problem with Math.floor and Math.ceil with result zero (lose sign)
|
||||
if (neg && integral=="0")
|
||||
integral='-'+integral;
|
||||
return precision ? integral + '.' + padding + fraction : integral;
|
||||
}
|
||||
|
||||
function UnformatNumber(number) {
|
||||
// make string..
|
||||
number = number + '';
|
||||
// remove 1000 sep
|
||||
number = number.replace(/\./g, '');
|
||||
// change ',' to '.'
|
||||
number = number.replace(',', '.');
|
||||
return parseFloat(number);
|
||||
}
|
||||
Reference in New Issue
Block a user