init
This commit is contained in:
401
modules/EcmWorkCards/js/DetailViewDocumentReady.js
Normal file
401
modules/EcmWorkCards/js/DetailViewDocumentReady.js
Normal file
@@ -0,0 +1,401 @@
|
||||
$(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];
|
||||
if (typeof value[1] === "undefined") {
|
||||
nazwaUrl.textContent = value[1];
|
||||
}else{
|
||||
nazwaUrl.textContent = value[1].replace('"','"');
|
||||
}
|
||||
|
||||
$('#' + 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);
|
||||
}
|
||||
563
modules/EcmWorkCards/js/EditViewDocumentReady6.js
Normal file
563
modules/EcmWorkCards/js/EditViewDocumentReady6.js
Normal file
@@ -0,0 +1,563 @@
|
||||
var tabAction = $('#tableEcmActions');
|
||||
|
||||
$(document).ready(function () {
|
||||
//addToValidate('EditView','quantity','income_cycle_c',true,'');
|
||||
addToValidate('EditView','date_from','income_cycle_c',true,'');
|
||||
addToValidate('EditView','date_to','income_cycle_c',true,'');
|
||||
$('#time_from').timepicker({ 'timeFormat': 'H:i:s','step':15 });
|
||||
$('#time_to').timepicker({ 'timeFormat': 'H:i:s' ,'step':15});
|
||||
$('#worker_name').attr('tabindex',201);
|
||||
$('#date').attr('tabindex',202);
|
||||
$('#product_name').attr('tabindex',203);
|
||||
$('#action_name').attr('tabindex',204);
|
||||
$('#time_from').attr('tabindex',205);
|
||||
$('#time_to').attr('tabindex',206);
|
||||
$('#quantity').attr('tabindex',207);
|
||||
$('#description').attr('tabindex',208);
|
||||
$('#worker_name').focus();
|
||||
lockEnter();
|
||||
|
||||
$( "#product_name" ).autocomplete({
|
||||
source: function (request, response)
|
||||
{
|
||||
$.ajax(
|
||||
{
|
||||
url: 'index.php',
|
||||
dataType: "json",
|
||||
data:
|
||||
{
|
||||
query: request.term,
|
||||
to_pdf: 'true',
|
||||
type: 'EcmProducts',
|
||||
module: 'Home',
|
||||
action: 'customSearch',
|
||||
},
|
||||
success: function (data)
|
||||
{
|
||||
response($.map(data.fields, function (item) {
|
||||
return {
|
||||
label: item.code,
|
||||
value: item.code,
|
||||
id: item.id,
|
||||
};
|
||||
}));
|
||||
}
|
||||
});
|
||||
},
|
||||
minLength: 2,
|
||||
select: function( event, ui ) {
|
||||
$('#product_id').val(ui.item.id);
|
||||
}
|
||||
});
|
||||
|
||||
$( "#action_name" ).autocomplete({
|
||||
source: function (request, response)
|
||||
{
|
||||
$.ajax(
|
||||
{
|
||||
url: 'index.php',
|
||||
dataType: "json",
|
||||
data:
|
||||
{
|
||||
query: request.term,
|
||||
to_pdf: 'true',
|
||||
type: 'EcmActions',
|
||||
module: 'Home',
|
||||
action: 'customSearch',
|
||||
},
|
||||
success: function (data)
|
||||
{
|
||||
response($.map(data.fields, function (item) {
|
||||
return {
|
||||
label: item.name,
|
||||
value: item.name,
|
||||
id: item.id,
|
||||
};
|
||||
}));
|
||||
}
|
||||
});
|
||||
},
|
||||
minLength: 2,
|
||||
select: function( event, ui ) {
|
||||
$('#action_id').val(ui.item.id);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).keypress(function(event) {
|
||||
var keycode = (event.keyCode ? event.keyCode : event.which);
|
||||
if(keycode == '9') { //onEnter
|
||||
var tabindex= $(this.activeElement).attr("tabindex");
|
||||
if(tabindex==209){
|
||||
$('#worker_name').select();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$["ui"]["autocomplete"].prototype["_renderItem"] = function (ul, item) {
|
||||
return $("<li></li>").data("item.autocomplete", item).append(
|
||||
$("<a></a>").html(item.label)).appendTo(ul);
|
||||
};
|
||||
|
||||
function InitializeTableEcmActions() {
|
||||
tabAction.appendGrid({
|
||||
hideRowNumColumn: true,
|
||||
initRows: 1,
|
||||
columns: [
|
||||
{
|
||||
name: 'code',
|
||||
display: 'Indeks',
|
||||
type: 'ui-autocomplete',
|
||||
ctrlClass: 'inputs',
|
||||
displayCss: {'width': '10%', 'vertical-align': 'middle'},
|
||||
uiOption: {
|
||||
source: function (request, response) {
|
||||
getProductIndeks(request, response);
|
||||
},
|
||||
minLength: 1,
|
||||
delay: 1500,
|
||||
select: function (event, ui) {
|
||||
if (ui.item.id != '') {
|
||||
var rowIndex = event.target.id.split("_").pop();
|
||||
rowIndex = $('#tableEcmActions').appendGrid('getRowIndex', rowIndex)
|
||||
setProductActions(rowIndex, ui.item);
|
||||
}
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: 'ecmproductname',
|
||||
display: 'Nazwa produktu',
|
||||
type: 'ui-autocomplete',
|
||||
ctrlClass: 'inputs',
|
||||
displayCss: {'width': '32%', 'vertical-align': 'middle'},
|
||||
uiOption: {
|
||||
source: function (request, response) {
|
||||
getProductName(request, response);
|
||||
},
|
||||
delay: 1500,
|
||||
minLength: 1,
|
||||
select: function (event, ui) {
|
||||
if (ui.item.id != '') {
|
||||
var rowIndex = event.target.id.split("_").pop();
|
||||
rowIndex = $('#tableEcmActions').appendGrid('getRowIndex', rowIndex)
|
||||
setProductActions(rowIndex, ui.item);
|
||||
}
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: 'ecmaction',
|
||||
display: 'Indeks - Nazwa czynności',
|
||||
type: 'select',
|
||||
ctrlOptions: {0: 'Wyszukaj produkt'},
|
||||
ctrlAttr: {disabled: 'disabled'},
|
||||
ctrlClass: 'inputs',
|
||||
displayCss: {'width': '32%', 'vertical-align': 'middle'},
|
||||
emptyCriteria: function (value) {
|
||||
return (value <= 0);
|
||||
},
|
||||
onChange: function (evt, rowIndex) {
|
||||
selectChange(evt, rowIndex);
|
||||
},
|
||||
}, {
|
||||
name: 'quantity',
|
||||
display: 'Ilość',
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0',
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
onChange: function (evt, rowIndex) {
|
||||
var quantity = (isNaN(parseFloat(evt.target.value))) ? '0' : parseFloat(evt.target.value);
|
||||
var costvalue = $('#tableEcmActions').appendGrid('getCtrlValue', 'ecmactioncost', rowIndex);
|
||||
var bruttovalue = $('#tableEcmActions').appendGrid('getCtrlValue', 'costbrutto', rowIndex);
|
||||
$('#tableEcmActions').appendGrid('setCtrlValue', 'quantity', rowIndex, quantity);
|
||||
$('#tableEcmActions').appendGrid('setCtrlValue', 'ecmactioncost_display', rowIndex, FormatNumber(quantity * costvalue));
|
||||
$('#tableEcmActions').appendGrid('setCtrlValue', 'costbrutto_display', rowIndex, FormatNumber(quantity * bruttovalue));
|
||||
updateSum(evt, rowIndex);
|
||||
},
|
||||
displayCss: {'width': '50px', 'vertical-align': 'middle'},
|
||||
emptyCriteria: function (value) {
|
||||
// A value lesser than zero will consider as empty.
|
||||
return (value <= 0);
|
||||
}
|
||||
}, {
|
||||
name: 'ecmactioncost_single_netto',
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
display: 'Netto',
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
ctrlAttr: {readonly: 'readonly', 'disabled': 'disabled'},
|
||||
displayCss: {'width': '40px', 'vertical-align': 'middle'},
|
||||
invisible: true,
|
||||
},{
|
||||
name: 'ecmactioncost_single_brutto',
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
display: 'Brutto',
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
ctrlAttr: {readonly: 'readonly', 'disabled': 'disabled'},
|
||||
displayCss: {'width': '40px', 'vertical-align': 'middle'},
|
||||
invisible: true,
|
||||
}, {
|
||||
name: 'ecmactioncost_display',
|
||||
display: 'Wartość netto',
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0,00',
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
ctrlAttr: {readonly: 'readonly', 'disabled': 'disabled'},
|
||||
displayCss: {'width': '90px', 'vertical-align': 'middle'},
|
||||
}, {
|
||||
name: 'costbrutto_display',
|
||||
display: 'Wartość brutto',
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0,00',
|
||||
invisible: false,
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
ctrlAttr: {readonly: 'readonly', 'disabled': 'disabled'},
|
||||
displayCss: {'width': '90px', 'vertical-align': 'middle'},
|
||||
}, {
|
||||
name: 'ecmproductid',
|
||||
type: 'text',
|
||||
display: 'ecmproductid',
|
||||
invisible: true,
|
||||
}, {
|
||||
name: 'ecmactioncost',
|
||||
type: 'text',
|
||||
display: 'ecmactioncost',
|
||||
invisible: true,
|
||||
}, {
|
||||
name: 'costbrutto',
|
||||
type: 'text',
|
||||
display: 'costbrutto',
|
||||
invisible: true,
|
||||
}
|
||||
],
|
||||
i18n: {
|
||||
rowEmpty: 'Brak rekordów',
|
||||
append: 'Dodaj rekord',
|
||||
insert: 'Skopiuj rekord',
|
||||
remove: 'Usuń rekord',
|
||||
},
|
||||
customGridButtons: {
|
||||
insert: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/add_position.gif';
|
||||
return button;
|
||||
},
|
||||
moveUp: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/moverowup.gif';
|
||||
return button;
|
||||
},
|
||||
moveDown: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/moverowdown.gif';
|
||||
return button;
|
||||
},
|
||||
removeLast: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/deleterow.gif';
|
||||
return button;
|
||||
},
|
||||
append: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/insertrow.gif';
|
||||
return button;
|
||||
},
|
||||
remove: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/deleterow.gif';
|
||||
return button;
|
||||
},
|
||||
},
|
||||
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 getProductName(request, response) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmWorkCards&action=dbpost&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "ecmProductNameAutocomplite",
|
||||
name: request.term,
|
||||
},
|
||||
success: function (data) {
|
||||
response(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getProductIndeks(request, response) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmWorkCards&action=dbpost&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "ecmProductIndeksAutocomplite",
|
||||
indeks: request.term,
|
||||
},
|
||||
success: function (data) {
|
||||
response(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function selectChange(evt, rowIndex) {
|
||||
var jr = $('#' + evt.target.id + '').find(":selected").val();
|
||||
var cost = '';
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmWorkCards&action=dbpost&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "getEcmActionsCost",
|
||||
id: jr,
|
||||
},
|
||||
success: function (data) {
|
||||
cost = data;
|
||||
}
|
||||
});
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmactioncost', rowIndex, cost['cost_other']);
|
||||
tabAction.appendGrid('setCtrlValue', 'costbrutto', rowIndex, cost['cost_action']);
|
||||
var quantity = $('#tableEcmActions').appendGrid('getCtrlValue', 'quantity', rowIndex);
|
||||
quantity = parseFloat(quantity);
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmactioncost_display', rowIndex, FormatNumber(quantity * cost));
|
||||
}
|
||||
|
||||
function setProductActions(rowIndex, item) {
|
||||
var czynnosci = '';
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmWorkCards&action=dbpost&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "getProductActions",
|
||||
id: item.id,
|
||||
},
|
||||
success: function (data) {
|
||||
czynnosci = data;
|
||||
}
|
||||
});
|
||||
if (czynnosci.length > 0) {
|
||||
$.each(czynnosci, function (key, value) {
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmproductid', rowIndex, item.id);
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmproductname', rowIndex, item.ecmproductname);
|
||||
tabAction.appendGrid('setCtrlValue', 'code', rowIndex, item.code);
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmactioncost', rowIndex, value.ecmactioncost);
|
||||
tabAction.appendGrid('setCtrlValue', 'costbrutto', rowIndex, value.costbrutto);
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmactioncost_single_netto', rowIndex, FormatNumber(value.ecmactioncost));
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmactioncost_single_brutto', rowIndex, FormatNumber(value.costbrutto));
|
||||
var selekt = tabAction.appendGrid('getCellCtrl', 'ecmaction', rowIndex);
|
||||
selekt.options.length = 1;
|
||||
$.each(czynnosci, function (key2, value2) {
|
||||
if (value.id != value2.id) {
|
||||
selekt.options[key2] = new Option(value2.name, value2.id);
|
||||
} else {
|
||||
selekt.options[key2] = new Option(value2.name, value2.id, true, true);
|
||||
}
|
||||
});
|
||||
selekt.disabled = false;
|
||||
if (key != czynnosci.length - 1) {
|
||||
tabAction.appendGrid('insertRow', 1, rowIndex);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmproductid', rowIndex, item.id);
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmproductname', rowIndex, item.ecmproductname);
|
||||
tabAction.appendGrid('setCtrlValue', 'code', rowIndex, item.code);
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmactioncost', rowIndex, item.ecmactioncost);
|
||||
tabAction.appendGrid('setCtrlValue', 'costbrutto', rowIndex, item.costbrutto);
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmactioncost_single_netto', rowIndex, FormatNumber(item.ecmactioncost));
|
||||
tabAction.appendGrid('setCtrlValue', 'ecmactioncost_single_brutto', rowIndex, FormatNumber(item.costbrutto));
|
||||
var selekt = tabAction.appendGrid('getCellCtrl', 'ecmaction', rowIndex);
|
||||
if (selekt != null) {
|
||||
selekt.options.length = 1;
|
||||
selekt.options[0] = new Option('Brak przypisanych czynności', 0);
|
||||
selekt.disabled = true;
|
||||
}
|
||||
}
|
||||
tabAction.appendGrid('removeEmptyRows');
|
||||
tabAction.appendGrid('appendRow', 1);
|
||||
$("input[type='text']").on("focus", function () {
|
||||
$(this).select();
|
||||
});
|
||||
tabAction.appendGrid('getCellCtrl', 'quantity', rowIndex).focus();
|
||||
}
|
||||
|
||||
function loadData() {
|
||||
var action_list = $.parseJSON($("input[name='tableEcmActions_list']").val());
|
||||
if(action_list != '[]'){
|
||||
action_list = b64_to_utf8(action_list);
|
||||
action_list = $.parseJSON(action_list);
|
||||
}
|
||||
if (action_list.length > 0 && action_list != '[]') {
|
||||
$.each(action_list, function (idx2, obj2) {
|
||||
tabAction.appendGrid('insertRow', [{
|
||||
ecmproductid: obj2.ecmproductid,
|
||||
quantity: obj2.quantity,
|
||||
ecmproductname: obj2.ecmproductname,
|
||||
code: obj2.code,
|
||||
ecmactioncost: obj2.ecmactioncost,
|
||||
ecmactioncost_display: obj2.ecmactioncost_display,
|
||||
costbrutto: obj2.costbrutto,
|
||||
costbrutto_display: obj2.costbrutto_display,
|
||||
ecmactioncost_single_netto: obj2.ecmactioncost_single_netto,
|
||||
ecmactioncost_single_brutto: obj2.ecmactioncost_single_brutto,
|
||||
}], 0);
|
||||
setDisabled(0);
|
||||
var tmp;
|
||||
var elem2 = tabAction.appendGrid('getCellCtrl', 'ecmaction', 0);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmWorkCards&action=dbpost&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "getProductActionsLoad",
|
||||
id: obj2.ecmproductid,
|
||||
},
|
||||
success: function (data) {
|
||||
tmp = data;
|
||||
}
|
||||
});
|
||||
//wstawianie do selecta
|
||||
elem2.options.length = 1;
|
||||
elem2.options[0] = new Option('Brak przypisanych czynności', 0);
|
||||
if (0 < tmp.length) {
|
||||
// Generate options for elem2
|
||||
$.each(tmp, function (key, value) {
|
||||
if (value.id != obj2.ecmaction) {
|
||||
elem2.options[key] = new Option(value.name, value.id);
|
||||
} else {
|
||||
elem2.options[key] = new Option(value.name, value.id, true, true);
|
||||
}
|
||||
});
|
||||
elem2.disabled = true;
|
||||
} else {
|
||||
elem2.disabled = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateSum(evt, rowIndex) {
|
||||
var listanetto = $('input[name^=tableEcmActions_ecmactioncost_display_]');
|
||||
var listabrutto = $('input[name^=tableEcmActions_costbrutto_display_]');
|
||||
var sumanetto = 0;
|
||||
var sumabrutto = 0;
|
||||
$.each(listanetto, function (key, value) {
|
||||
var tmp = $('#' + value.id);
|
||||
sumanetto = sumanetto + UnformatNumber(tmp.val());
|
||||
});
|
||||
$.each(listabrutto, function (key, value) {
|
||||
var tmp = $('#' + value.id);
|
||||
sumabrutto = sumabrutto + UnformatNumber(tmp.val());
|
||||
});
|
||||
$('#sum_netto').text(FormatNumber(sumanetto));
|
||||
$('#sum_brutto').text(FormatNumber(sumabrutto));
|
||||
}
|
||||
|
||||
function setDisabled(id) {
|
||||
var rekord = tabAction.appendGrid('getCellCtrl', 'code', id);
|
||||
var jr = $('#' + rekord.id + '');
|
||||
jr.attr("disabled", "disabled");
|
||||
rekord = tabAction.appendGrid('getCellCtrl', 'ecmproductname', id);
|
||||
jr = $('#' + rekord.id + '');
|
||||
jr.attr("disabled", "disabled");
|
||||
}
|
||||
|
||||
function showHideSingleCost(){
|
||||
var txt = $('#showPrice').val();
|
||||
if(txt == "Pokaż jednostkowe ceny"){
|
||||
$('#showPrice').val("Schowaj jednostkowe ceny");
|
||||
tabAction.appendGrid('showColumn', 'ecmactioncost_single_netto');
|
||||
tabAction.appendGrid('showColumn', 'ecmactioncost_single_brutto');
|
||||
}else{
|
||||
$('#showPrice').val("Pokaż jednostkowe ceny");
|
||||
tabAction.appendGrid('hideColumn', 'ecmactioncost_single_netto');
|
||||
tabAction.appendGrid('hideColumn', 'ecmactioncost_single_brutto');
|
||||
}
|
||||
}
|
||||
|
||||
function utf8_to_b64(str) {
|
||||
return window.btoa(unescape(encodeURIComponent(str)));
|
||||
}
|
||||
|
||||
function b64_to_utf8(str) {
|
||||
return decodeURIComponent(escape(window.atob(str)));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function lockEnter() {
|
||||
// prevent default
|
||||
$(window).keydown(function (event) {
|
||||
if (event.keyCode == 13 && $(":focus").attr('id') != 'save_and_next') {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user