Add JS files
This commit is contained in:
501
modules/EcmProducts/javascript/DetailViewDocumentReady.js
Executable file
501
modules/EcmProducts/javascript/DetailViewDocumentReady.js
Executable file
@@ -0,0 +1,501 @@
|
||||
$(document).ready(function () {
|
||||
InitializeTableCost();
|
||||
InitializeTableComponents();
|
||||
});
|
||||
|
||||
function trigerDocumentsPZ($this){
|
||||
$this = $($this);
|
||||
$this.closest('tr').next().find('div').toggle(400);
|
||||
}
|
||||
function trigerStockOperations($this){
|
||||
$this = $($this);
|
||||
$this.closest('tr').next().next().find('div').toggle(400);
|
||||
}
|
||||
function InitializeTableCost() {
|
||||
// Initialize appendGrid
|
||||
$('#tableTimeEdit').appendGrid({
|
||||
hideRowNumColumn: false,
|
||||
initRows: 1,
|
||||
initData: $.parseJSON($("input[name='action_list']").val()),
|
||||
columns: [
|
||||
{
|
||||
name: 'indeks',
|
||||
display: 'Indeks',
|
||||
type: 'text',
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {
|
||||
'width': '80px',
|
||||
'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: 'name',
|
||||
display: 'Nazwa',
|
||||
type: 'text',
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {
|
||||
'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: 'category',
|
||||
display: 'Kategoria',
|
||||
type: 'text',
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {
|
||||
'width': '20%',
|
||||
'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: 'unit_id',
|
||||
display: SUGAR.language.get("app_strings", "LBL_JM"),
|
||||
type: 'custom',
|
||||
displayCss: {
|
||||
'width': '5%',
|
||||
'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'
|
||||
},
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
var ctrl = document.createElement('span');
|
||||
$(ctrl).attr({id: ctrlId, name: ctrlId}).appendTo(parent);
|
||||
$(parent).css({'text-align': 'right'});
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
var tmp = SUGAR.language.get("app_list_strings", "ecmproducts_unit_dom");
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
$('#' + ctrlId).html(tmp[value]);
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
return '';
|
||||
},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
}, {
|
||||
name: 'quantity',
|
||||
display: 'Ilość',
|
||||
type: 'text',
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {
|
||||
'width': '10%',
|
||||
'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: 'price',
|
||||
display: 'Koszt',
|
||||
type: 'custom',
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {
|
||||
'width': '10%',
|
||||
'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',
|
||||
},
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
// Tworzenie Id dla inputow
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
//kontener
|
||||
var ctrl = document.createElement('span');
|
||||
//dodajemy kontener do komorki w tabeli
|
||||
$(ctrl).attr({id: ctrlId, name: ctrlId}).appendTo(parent);
|
||||
//Tworzymy pierwszy input dla ceny jednostkowej
|
||||
var Single = $('<input/>', {type: 'text', id: ctrlId + '_Single', name: ctrlId + '_Single', class: 'inputs', readonly: 'readonly'}).css({'width': '100%', 'text-align': 'right'});
|
||||
//Ustawiamy wartosc domyslna
|
||||
$(Single).val('0,00');
|
||||
//dodajemy do kontenera
|
||||
$(Single).appendTo(ctrl);
|
||||
//oddzielamy widoczna linia
|
||||
var hr = document.createElement('hr');
|
||||
$(hr).css('margin', '0em').appendTo(ctrl);
|
||||
//Tworzymy drugi input dla sumy
|
||||
var Summary = $('<input/>', {type: 'text', id: ctrlId + '_Summary', name: ctrlId + '_Summary', class: 'inputs', readonly: 'readonly'}).css({'width': '100%', 'text-align': 'right'});
|
||||
//Ustawiamy wartosc domyslna
|
||||
$(Summary).val('0,00');
|
||||
$(Summary).appendTo(ctrl);
|
||||
return ctrl;
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
var Single = $('#' + ctrlId + '_Single').val();
|
||||
var Summary = $('#' + ctrlId + '_Summary').val();
|
||||
return {Single: Single, Summary: Summary};
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
if (value != null) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
$('#' + ctrlId + '_Single').val(value['Single'] == null ? '0,00' : FormatNumber(value['Single']));
|
||||
$('#' + ctrlId + '_Summary').val(value['Summary'] == null ? '0,00' : FormatNumber(value['Summary'],6));
|
||||
}
|
||||
},
|
||||
}, ],
|
||||
i18n: {
|
||||
rowEmpty: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWEMPTY"),
|
||||
},
|
||||
hideButtons: {
|
||||
removeLast: true,
|
||||
append: true,
|
||||
insert: true,
|
||||
remove: true,
|
||||
moveUp: true,
|
||||
moveDown: true
|
||||
}
|
||||
});
|
||||
$('#tableTimeEdit_price_td_head').html('Cena<br>Wartość');
|
||||
var count = $('#tableTimeEdit').appendGrid('getRowCount');
|
||||
for (var i = 0; i < count; i++) {
|
||||
var value = $('#tableTimeEdit').appendGrid('getCtrlValue', 'quantity', i);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'quantity', i, FormatNumber(value,6));
|
||||
}
|
||||
//Podsumowanie
|
||||
var data = $('#tableTimeEdit').appendGrid('getAllValue');
|
||||
var sumPriceSingle = 0;
|
||||
var sumPriceTotal = 0;
|
||||
$.each(data, function (index, value) {
|
||||
sumPriceTotal += parseFloat(UnformatNumber(value.price.Summary,6));
|
||||
});
|
||||
$('#tableTimeEdit').find('tfoot tr:last').after('<tr><td colspan="6" style="vertical-align: middle;border-top: 1px solid black">Suma:</td><td style="text-align: right;border-top: 1px solid black">' + FormatNumber(sumPriceTotal,6) + '</td></tr>');
|
||||
}
|
||||
|
||||
function InitializeTableComponents() {
|
||||
// Initialize appendGrid
|
||||
$('#tableComponents').appendGrid({
|
||||
hideRowNumColumn: false,
|
||||
initRows: 1,
|
||||
initData: $.parseJSON($("input[name='component_list']").val()),
|
||||
columns: [
|
||||
{
|
||||
name: 'code',
|
||||
display: SUGAR.language.get("app_strings", "LBL_INDEX"),
|
||||
type: 'text',
|
||||
displayCss: {
|
||||
'width': '150px',
|
||||
'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'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left',
|
||||
'vertical-align': 'middle',
|
||||
},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
ctrlClass: 'inputs'
|
||||
}, {
|
||||
name: 'name',
|
||||
display: SUGAR.language.get("app_strings", "LBL_NAME"),
|
||||
type: 'text',
|
||||
displayCss: {
|
||||
'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'
|
||||
},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
ctrlClass: 'inputs',
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
}, {
|
||||
name: 'product_category_name',
|
||||
display: SUGAR.language.get("app_strings", "LBL_CATEGORY"),
|
||||
type: 'text',
|
||||
displayCss: {
|
||||
'width': '10%',
|
||||
'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'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
ctrlAttr: {
|
||||
readonly: 'readonly'
|
||||
},
|
||||
}, {
|
||||
name: 'unit_id',
|
||||
display: SUGAR.language.get("app_strings", "LBL_JM"),
|
||||
type: 'custom',
|
||||
displayCss: {
|
||||
'width': '3%',
|
||||
'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'
|
||||
},
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
var ctrl = document.createElement('span');
|
||||
$(ctrl).attr({id: ctrlId, name: ctrlId}).appendTo(parent);
|
||||
$(parent).css({'text-align': 'right'});
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
var tmp = SUGAR.language.get("app_list_strings", "ecmproducts_unit_dom");
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
$('#' + ctrlId).html(tmp[value]);
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
return '';
|
||||
},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
}, {
|
||||
name: 'quantity_recipe',
|
||||
display: SUGAR.language.get("app_strings", "LBL_QUANTITY_RECIPE"),
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0.00000000',
|
||||
displayCss: {
|
||||
'width': '7%',
|
||||
'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'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'right'
|
||||
},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
}, {
|
||||
name: 'divider',
|
||||
display: SUGAR.language.get("app_strings", "LBL_DIVIDER"),
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0,00',
|
||||
displayCss: {
|
||||
'width': '7%',
|
||||
'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'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'right'
|
||||
},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
}, {
|
||||
name: 'quantity',
|
||||
display: SUGAR.language.get("app_strings", "LBL_QUANTITY"),
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0.000000',
|
||||
displayCss: {
|
||||
'width': '7%',
|
||||
'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'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'right'
|
||||
},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
}, {
|
||||
name: 'price',
|
||||
display: 'Cena / Wartość',
|
||||
type: 'custom',
|
||||
displayCss: {
|
||||
'width': '7%',
|
||||
'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'
|
||||
},
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
// Tworzenie Id dla inputow
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
//kontener
|
||||
var ctrl = document.createElement('span');
|
||||
//dodajemy kontener do komorki w tabeli
|
||||
$(ctrl).attr({id: ctrlId, name: ctrlId}).appendTo(parent);
|
||||
//Tworzymy pierwszy input dla ceny jednostkowej
|
||||
var Single = $('<input/>', {type: 'text', id: ctrlId + '_Single', name: ctrlId + '_Single', class: 'inputs', readonly: 'readonly'}).css({'width': '100%', 'text-align': 'right'});
|
||||
//Ustawiamy wartosc domyslna
|
||||
$(Single).val('0,00');
|
||||
|
||||
//dodajemy do kontenera
|
||||
$(Single).appendTo(ctrl);
|
||||
//oddzielamy widoczna linia
|
||||
var hr = document.createElement('hr');
|
||||
$(hr).css('margin', '0em').appendTo(ctrl);
|
||||
//Tworzymy drugi input dla sumy
|
||||
var Summary = $('<input/>', {type: 'text', id: ctrlId + '_Summary', name: ctrlId + '_Summary', class: 'inputs', readonly: 'readonly'}).css({'width': '100%', 'text-align': 'right'});
|
||||
//Ustawiamy wartosc domyslna
|
||||
$(Summary).val('0,00');
|
||||
$(Summary).appendTo(ctrl);
|
||||
return ctrl;
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
var Single = $('#' + ctrlId + '_Single').val();
|
||||
var Summary = $('#' + ctrlId + '_Summary').val();
|
||||
return {Single: Single, Summary: Summary};
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
if (value != null) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
$('#' + ctrlId + '_Single').val(value['Single'] == null ? '0,00' : FormatNumber(value['Single']));
|
||||
$('#' + ctrlId + '_Summary').val(value['Summary'] == null ? '0,00' : FormatNumber(value['Summary'],6));
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: 'ecmcomponent_id',
|
||||
display: 'ecmcomponent_id',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
}, {
|
||||
name: 'product_category_id',
|
||||
display: 'product_category_id',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
},
|
||||
],
|
||||
i18n: {
|
||||
append: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_APPEND"),
|
||||
remove: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVE"),
|
||||
insert: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_INSERT"),
|
||||
moveUp: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEUP"),
|
||||
moveDown: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEDOWN"),
|
||||
removeLast: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVELAST"),
|
||||
rowEmpty: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWEMPTY"),
|
||||
rowDrag: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWDRAG"),
|
||||
},
|
||||
customGridButtons: {
|
||||
insert: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/add_position.gif';
|
||||
return button;
|
||||
},
|
||||
remove: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/deleterow.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;
|
||||
},
|
||||
},
|
||||
afterRowRemoved: function (caller, rowIndex) {
|
||||
var quantity = $('#tableComponents').appendGrid(
|
||||
'getRowCount');
|
||||
if (quantity == 0) {
|
||||
$('#tableComponents').appendGrid('appendRow', 1);
|
||||
}
|
||||
},
|
||||
hideButtons: {
|
||||
removeLast: true,
|
||||
append: true,
|
||||
insert: true,
|
||||
remove: true,
|
||||
moveUp: true,
|
||||
moveDown: true
|
||||
}
|
||||
});
|
||||
$('#tableComponents_price_td_head').html('Cena<br>Wartość');
|
||||
var count = $('#tableComponents').appendGrid('getRowCount');
|
||||
for (var i = 0; i < count; i++) {
|
||||
var value = $('#tableComponents').appendGrid('getCtrlValue', 'quantity', i);
|
||||
var divider = $('#tableComponents').appendGrid('getCtrlValue', 'divider', i);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'quantity', i, QuantityFormat(value,6));
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'divider', i, FormatNumber(divider,2));
|
||||
}
|
||||
//Podsumowanie
|
||||
var html = '<tr><td colspan="8" style="vertical-align: middle;border-top: 1px solid black">Suma:</td><td style="text-align: right;border-top: 1px solid black"><span id="sumComponentsPriceTotal">0,00</span></td></tr>';
|
||||
$('#tableComponents').find('tfoot tr:last').after(html);
|
||||
updateSumComponents();
|
||||
}
|
||||
function updateSumComponents() {
|
||||
var data = $('#tableComponents').appendGrid('getAllValue');
|
||||
var sumPriceSingle = 0;
|
||||
var sumPriceTotal = 0;
|
||||
$.each(data, function (index, value) {
|
||||
|
||||
sumPriceTotal += parseFloat(UnformatNumber(value.price.Summary,6));
|
||||
});
|
||||
$('#sumComponentsPriceTotal').html(FormatNumber(sumPriceTotal,6));
|
||||
}
|
||||
1438
modules/EcmProducts/javascript/EcmProduct.js
Executable file
1438
modules/EcmProducts/javascript/EcmProduct.js
Executable file
File diff suppressed because it is too large
Load Diff
1478
modules/EcmProducts/javascript/EcmProductDetailView.js
Executable file
1478
modules/EcmProducts/javascript/EcmProductDetailView.js
Executable file
File diff suppressed because it is too large
Load Diff
1429
modules/EcmProducts/javascript/EcmProductQuickCreate.js
Executable file
1429
modules/EcmProducts/javascript/EcmProductQuickCreate.js
Executable file
File diff suppressed because it is too large
Load Diff
888
modules/EcmProducts/javascript/EditViewDocumentReady44.js
Executable file
888
modules/EcmProducts/javascript/EditViewDocumentReady44.js
Executable file
@@ -0,0 +1,888 @@
|
||||
$(document).ready(function () {
|
||||
InitializeTableCost();
|
||||
if ($('#tableTimeEdit').appendGrid('getRowCount') === 0) {
|
||||
$('#tableTimeEdit').appendGrid('appendRow', 1);
|
||||
}
|
||||
InitializeTableComponents();
|
||||
if ($('#tableComponents').appendGrid('getRowCount') === 0) {
|
||||
$('#tableComponents').appendGrid('appendRow', 1);
|
||||
}
|
||||
var tmp = $("select[name=select_ecmaction_category]");
|
||||
tmp.append($('<option>', {value: ""})
|
||||
.text(""));
|
||||
tmp.val('');
|
||||
|
||||
$('#srp_price').on('click',function(){
|
||||
$('#srp_price').select();
|
||||
});
|
||||
|
||||
$('#srp_price').on('change',function(){
|
||||
$('#srp_price').val(FormatNumber($('#srp_price').val(),2));
|
||||
|
||||
srp_price_replace
|
||||
|
||||
var r = confirm("Czy podmienić cenę w komponentach?");
|
||||
if (r == true) {
|
||||
$('#srp_price_replace').val(1);
|
||||
} else {
|
||||
$('#srp_price_replace').val(0);
|
||||
}
|
||||
});
|
||||
|
||||
$('#price_msh').on('click',function(){
|
||||
$('#price_msh').select();
|
||||
});
|
||||
|
||||
$('#price_msh').on('change',function(){
|
||||
$('#price_msh').val(FormatNumber($('#price_msh').val(),2));
|
||||
});
|
||||
|
||||
|
||||
$('#cena_produkcyjna').on('click',function(){
|
||||
$('#cena_produkcyjna').select();
|
||||
});
|
||||
|
||||
$('#cena_produkcyjna').on('change',function(){
|
||||
$('#cena_produkcyjna').val(FormatNumber($('#cena_produkcyjna').val(),2));
|
||||
});
|
||||
// rozszerzenie kolumn do maksa
|
||||
var trki = $("#LBL_TIME_TABLE").children('table').children('tbody').children('tr');
|
||||
$.each(trki, function (index, value) {
|
||||
if (index == 1) {
|
||||
var tmp = $(value).children('td').attr('colspan');
|
||||
$(value).children('td').attr('colspan', (tmp + 1));
|
||||
}
|
||||
});
|
||||
var trki = $("#LBL_COMPONENTS").children('table').children('tbody').children('tr');
|
||||
$.each(trki, function (index, value) {
|
||||
if (index == 1) {
|
||||
var tmp = $(value).children('td').attr('colspan');
|
||||
$(value).children('td').attr('colspan', (tmp + 1));
|
||||
}
|
||||
});
|
||||
});
|
||||
$["ui"]["autocomplete"].prototype["_renderItem"] = function (ul, item) {
|
||||
return $("<li></li>").data("item.autocomplete", item).append(
|
||||
$("<a></a>").html(item.label)).appendTo(ul);
|
||||
};
|
||||
|
||||
function InitializeTableCost() {
|
||||
// Initialize appendGrid
|
||||
$('#tableTimeEdit').appendGrid({
|
||||
hideRowNumColumn: false,
|
||||
initRows: 1,
|
||||
initData: $.parseJSON($("input[name='action_list']").val()),
|
||||
columns: [
|
||||
{
|
||||
name: 'indeks',
|
||||
display: SUGAR.language.get("app_strings", "LBL_INDEX"),
|
||||
type: 'ui-autocomplete',
|
||||
displayCss: {
|
||||
'width': '80px',
|
||||
'vertical-align': 'middle',
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left',
|
||||
'vertical-align': 'middle',
|
||||
},
|
||||
uiOption: {
|
||||
source: function (request, response) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmProducts&action=javahelper&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "searchEcmActionsAutocomplite",
|
||||
term: request.term,
|
||||
source: 'indeks',
|
||||
},
|
||||
success: function (data) {
|
||||
response(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
minLength: 3,
|
||||
select: function (event, ui) {
|
||||
var uniqueid = $(event.target).attr('id');
|
||||
uniqueid = uniqueid.substring('tableTimeEdit_indeks_'.length);
|
||||
var rowIndex = $('#tableTimeEdit').appendGrid('getRowIndex', uniqueid);
|
||||
if (ui.item.id != '') {
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'name', rowIndex, ui.item.name);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'quantity', rowIndex, '1,00');
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'ecmactionid', rowIndex, ui.item.id);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'category', rowIndex, ui.item.category);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'price', rowIndex, ui.item.price);
|
||||
}
|
||||
},
|
||||
},
|
||||
ctrlClass: 'inputs'
|
||||
}, {
|
||||
name: 'name',
|
||||
display: SUGAR.language.get("app_strings", "LBL_NAME"),
|
||||
type: 'ui-autocomplete',
|
||||
displayCss: {
|
||||
// 'width': '40%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
uiOption: {
|
||||
source: function (request, response) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmProducts&action=javahelper&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "searchEcmActionsAutocomplite",
|
||||
term: request.term,
|
||||
source: 'name',
|
||||
},
|
||||
success: function (data) {
|
||||
response(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
minLength: 3,
|
||||
select: function (event, ui) {
|
||||
var uniqueid = $(event.target).attr('id');
|
||||
uniqueid = uniqueid.substring('tableTimeEdit_name_'.length);
|
||||
var rowIndex = $('#tableTimeEdit').appendGrid('getRowIndex', uniqueid);
|
||||
if (ui.item.id != '') {
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'indeks', rowIndex, ui.item.indeks);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'quantity', rowIndex, '1,00');
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'ecmactionid', rowIndex, ui.item.id);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'category', rowIndex, ui.item.category);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'price', rowIndex, ui.item.price);
|
||||
}
|
||||
},
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
}, {
|
||||
name: 'category',
|
||||
display: SUGAR.language.get("app_strings", "LBL_CATEGORY"),
|
||||
type: 'text',
|
||||
displayCss: {
|
||||
'width': '15%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
ctrlAttr: {
|
||||
disabled: 'disabled',
|
||||
readonly: 'readonly'
|
||||
},
|
||||
}, {
|
||||
name: 'unit_id',
|
||||
display: SUGAR.language.get("app_strings", "LBL_JM"),
|
||||
type: 'select',
|
||||
ctrlOptions: SUGAR.language.get("app_list_strings", "ecmproducts_unit_dom"),
|
||||
displayCss: {
|
||||
'width': '5%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
}, {
|
||||
name: 'quantity',
|
||||
display: SUGAR.language.get("app_strings", "LBL_QUANTITY"),
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0,00',
|
||||
displayCss: {
|
||||
'width': '10%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'right'
|
||||
},
|
||||
onChange: function (evt, rowIndex) {
|
||||
var row = $('#tableTimeEdit').appendGrid('getRowValue', rowIndex);
|
||||
var formatedQuantity = FormatNumber(row.quantity);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'quantity', rowIndex, formatedQuantity);
|
||||
var Quantity = UnformatNumber(formatedQuantity);
|
||||
var PriceSingle = UnformatNumber(row.price.Single);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'price', rowIndex, {Single: row.price.Single, Summary: Quantity * PriceSingle});
|
||||
updateSumEcmAction();
|
||||
}
|
||||
}, {
|
||||
name: 'price',
|
||||
display: 'Cena / Wartość',
|
||||
type: 'custom',
|
||||
displayCss: {
|
||||
'width': '10%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
// Tworzenie Id dla inputow
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
//kontener
|
||||
var ctrl = document.createElement('span');
|
||||
//dodajemy kontener do komorki w tabeli
|
||||
$(ctrl).attr({id: ctrlId, name: ctrlId}).appendTo(parent);
|
||||
//Tworzymy pierwszy input dla ceny jednostkowej
|
||||
var Single = $('<input/>', {type: 'text', id: ctrlId + '_Single', name: ctrlId + '_Single', class: 'inputs'}).css({'width': '100%', 'text-align': 'right'});
|
||||
//Ustawiamy wartosc domyslna
|
||||
$(Single).val('0,00');
|
||||
//Akacja wywolywana podczas zmiany wartosci oraz formatuje
|
||||
// oblicza (ilosc*cena jednostkowa) i wstawia
|
||||
$(Single).change(function () {
|
||||
var SingleFormated = FormatNumber($(this).val());
|
||||
$(this).val(SingleFormated);
|
||||
var qunatity = UnformatNumber($('#' + idPrefix + '_quantity_' + uniqueIndex).val());
|
||||
$('#' + ctrlId + '_Summary').val(FormatNumber(qunatity * UnformatNumber(SingleFormated)));
|
||||
updateSumEcmAction();
|
||||
});
|
||||
//dodajemy do kontenera
|
||||
$(Single).appendTo(ctrl);
|
||||
//oddzielamy widoczna linia
|
||||
var hr = document.createElement('hr');
|
||||
$(hr).css('margin', '0em').appendTo(ctrl);
|
||||
//Tworzymy drugi input dla sumy
|
||||
var Summary = $('<input/>', {type: 'text', id: ctrlId + '_Summary', name: ctrlId + '_Summary', class: 'inputs'}).css({'width': '100%', 'text-align': 'right'});
|
||||
//Ustawiamy wartosc domyslna
|
||||
$(Summary).val('0,00');
|
||||
//Akacja wywolywana podczas zmiany wartosci oraz formatuje
|
||||
// oblicza (suma / ilosc) i wstawia
|
||||
$(Summary).change(function () {
|
||||
var SummaryFormated = FormatNumber($(this).val());
|
||||
$(this).val(SummaryFormated);
|
||||
var qunatity = UnformatNumber($('#' + idPrefix + '_quantity_' + uniqueIndex).val());
|
||||
$('#' + ctrlId + '_Single').val(FormatNumber(UnformatNumber(SummaryFormated) / qunatity));
|
||||
updateSumEcmAction();
|
||||
});
|
||||
$(Summary).appendTo(ctrl);
|
||||
return ctrl;
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
var Single = $('#' + ctrlId + '_Single').val();
|
||||
var Summary = $('#' + ctrlId + '_Summary').val();
|
||||
return {Single: Single, Summary: Summary};
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
if (value != null) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
$('#' + ctrlId + '_Single').val(value['Single'] == null ? '0,00' : FormatNumber(value['Single']));
|
||||
$('#' + ctrlId + '_Summary').val(value['Summary'] == null ? '0,00' : FormatNumber(value['Summary']));
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: 'ecmactionid',
|
||||
display: 'ecmactionid',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
},
|
||||
],
|
||||
i18n: {
|
||||
append: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_APPEND"),
|
||||
remove: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVE"),
|
||||
insert: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_INSERT"),
|
||||
moveUp: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEUP"),
|
||||
moveDown: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEDOWN"),
|
||||
removeLast: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVELAST"),
|
||||
rowEmpty: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWEMPTY"),
|
||||
rowDrag: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWDRAG"),
|
||||
},
|
||||
customGridButtons: {
|
||||
insert: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/add_position.gif';
|
||||
return button;
|
||||
},
|
||||
remove: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/deleterow.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;
|
||||
},
|
||||
},
|
||||
afterRowRemoved: function (caller, rowIndex) {
|
||||
var quantity = $('#tableTimeEdit').appendGrid(
|
||||
'getRowCount');
|
||||
if (quantity == 0) {
|
||||
$('#tableTimeEdit').appendGrid('appendRow', 1);
|
||||
}
|
||||
},
|
||||
hideButtons: {
|
||||
removeLast: true,
|
||||
append: true,
|
||||
moveUp: true,
|
||||
moveDown: true
|
||||
}
|
||||
});
|
||||
$('#tableTimeEdit_price_td_head').html('Cena<br>Wartość');
|
||||
var count = $('#tableTimeEdit').appendGrid('getRowCount');
|
||||
for (var i = 0; i < count; i++) {
|
||||
var value = $('#tableTimeEdit').appendGrid('getCtrlValue', 'quantity', i);
|
||||
$('#tableTimeEdit').appendGrid('setCtrlValue', 'quantity', i, FormatNumber(value));
|
||||
}
|
||||
//Podsumowanie
|
||||
var html = '<tr><td colspan="6" style="vertical-align: middle;border-top: 1px solid black">Suma:</td><td style="text-align: right;border-top: 1px solid black"><span id="sumEcmActionPriceTotal">0,00</span></td></tr>';
|
||||
$('#tableTimeEdit').find('tfoot tr:last').after(html);
|
||||
updateSumEcmAction();
|
||||
}
|
||||
|
||||
function updateSumEcmAction() {
|
||||
var data = $('#tableTimeEdit').appendGrid('getAllValue');
|
||||
var sumPriceSingle = 0;
|
||||
var sumPriceTotal = 0;
|
||||
$.each(data, function (index, value) {
|
||||
sumPriceTotal += parseFloat(UnformatNumber(value.price.Summary));
|
||||
});
|
||||
$('#sumEcmActionPriceTotal').html(FormatNumber(sumPriceTotal));
|
||||
}
|
||||
|
||||
|
||||
function searchActions() {
|
||||
var nazwa = $('#searchEcmActionInput').val();
|
||||
var kategoria = $('select[name=select_ecmaction_category]').find(":selected").val();
|
||||
var wynik = '';
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmProducts&action=javahelper&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "searchActionsList",
|
||||
term: nazwa,
|
||||
category: kategoria,
|
||||
},
|
||||
success: function (data) {
|
||||
wynik = data;
|
||||
}
|
||||
});
|
||||
if (wynik != '') {
|
||||
InitializeSearchtableTable(wynik);
|
||||
$('#ttabble').show();
|
||||
} else {
|
||||
console.log("nie znaleziono wyników");
|
||||
}
|
||||
}
|
||||
|
||||
function InitializeSearchtableTable(data) {
|
||||
// Initialize appendGrid
|
||||
$('#wyszukiwanie').appendGrid({
|
||||
hideRowNumColumn: true,
|
||||
initRows: 0,
|
||||
columns: [
|
||||
{
|
||||
name: 'indeks',
|
||||
display: 'Indeks',
|
||||
type: 'text',
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {'width': '90px', 'vertical-align': 'middle'},
|
||||
onClick: function (evt, rowIndex) {
|
||||
dodajDoListy(evt, rowIndex);
|
||||
}
|
||||
}, {
|
||||
name: 'name',
|
||||
display: 'Nazwa',
|
||||
//type: 'text',
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {'vertical-align': 'middle'},
|
||||
onClick: function (evt, rowIndex) {
|
||||
dodajDoListy(evt, rowIndex);
|
||||
}
|
||||
}, {
|
||||
name: 'category',
|
||||
display: 'Kategoria',
|
||||
type: 'text',
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {'width': '130px', 'vertical-align': 'middle'},
|
||||
onClick: function (evt, rowIndex) {
|
||||
dodajDoListy(evt, rowIndex);
|
||||
}
|
||||
}, {
|
||||
name: 'price1',
|
||||
display: 'Koszt',
|
||||
type: 'text',
|
||||
ctrlCss: {'text-align': 'right'},
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {'width': '70px', 'vertical-align': 'middle'},
|
||||
onClick: function (evt, rowIndex) {
|
||||
dodajDoListy(evt, rowIndex);
|
||||
}
|
||||
}, {
|
||||
name: 'displaytime',
|
||||
display: 'Czas',
|
||||
type: 'text',
|
||||
ctrlAttr: {readonly: 'readonly'},
|
||||
displayCss: {'width': '70px', 'vertical-align': 'middle'},
|
||||
onClick: function (evt, rowIndex) {
|
||||
dodajDoListy(evt, rowIndex);
|
||||
}
|
||||
}, {
|
||||
name: 'ecmactionid',
|
||||
display: 'ecmactionid',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
}, {
|
||||
name: 'time',
|
||||
display: 'time',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
}, {
|
||||
name: 'cost_action',
|
||||
display: 'cost_action',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
}, {
|
||||
name: 'cost_hour',
|
||||
display: 'cost_hour',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
}, ],
|
||||
i18n: {
|
||||
rowEmpty: 'Brak wyników'
|
||||
},
|
||||
hideButtons: {
|
||||
removeLast: true,
|
||||
append: true,
|
||||
insert: true,
|
||||
remove: true,
|
||||
moveUp: true,
|
||||
moveDown: true
|
||||
},
|
||||
initData: data,
|
||||
});
|
||||
$('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 dodajDoListy(evt, rowIndex) {
|
||||
var tmp = $('#wyszukiwanie').appendGrid('getRowValue', rowIndex);
|
||||
tmp['price1'] = '0,00';
|
||||
tmp['displaytime'] = '00.00:00';
|
||||
tmp['quantity'] = '0';
|
||||
$('#tableTimeEdit').appendGrid(
|
||||
'insertRow',
|
||||
[{
|
||||
indeks: tmp['indeks'],
|
||||
name: tmp['name'],
|
||||
quantity: '0,00',
|
||||
ecmactionid: tmp['ecmactionid'],
|
||||
category: tmp['category'],
|
||||
cost_action: tmp['cost_action'],
|
||||
cost_hour: tmp['cost_hour'],
|
||||
displaytime: tmp['displaytime'],
|
||||
time: tmp['time'],
|
||||
price1: '0,00'
|
||||
}], 0);
|
||||
$('#ttabble').hide();
|
||||
}
|
||||
|
||||
|
||||
function InitializeTableComponents() {
|
||||
// Initialize appendGrid
|
||||
$('#tableComponents').appendGrid({
|
||||
hideRowNumColumn: false,
|
||||
initRows: 1,
|
||||
initData: $.parseJSON($("input[name='component_list']").val()),
|
||||
columns: [
|
||||
{
|
||||
name: 'code',
|
||||
display: SUGAR.language.get("app_strings", "LBL_INDEX"),
|
||||
type: 'ui-autocomplete',
|
||||
displayCss: {
|
||||
'width': '150px',
|
||||
'vertical-align': 'middle',
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left',
|
||||
'vertical-align': 'middle',
|
||||
},
|
||||
uiOption: {
|
||||
source: function (request, response) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmProducts&action=javahelper&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "searchComponentsAutocomplite",
|
||||
term: request.term,
|
||||
source: 'code',
|
||||
},
|
||||
success: function (data) {
|
||||
response(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
minLength: 3,
|
||||
select: function (event, ui) {
|
||||
var uniqueid = $(event.target).attr('id');
|
||||
uniqueid = uniqueid.substring('tableComponents_code_'.length);
|
||||
var rowIndex = $('#tableComponents').appendGrid('getRowIndex', uniqueid);
|
||||
|
||||
if (ui.item.id != '') {
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'name', rowIndex, ui.item.name);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'quantity', rowIndex, '0.000000');
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'ecmcomponent_id', rowIndex, ui.item.ecmcomponent_id);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'unit_id', rowIndex, ui.item.unit_id);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'product_category_id', rowIndex, ui.item.product_category_id);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'product_category_name', rowIndex, ui.item.product_category_name);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'price', rowIndex, {Single: ui.item.srp_price, Summary: 0.000000});
|
||||
|
||||
}
|
||||
},
|
||||
},
|
||||
ctrlClass: 'inputs'
|
||||
}, {
|
||||
name: 'name',
|
||||
display: SUGAR.language.get("app_strings", "LBL_NAME"),
|
||||
type: 'ui-autocomplete',
|
||||
displayCss: {
|
||||
// 'width': '40%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
uiOption: {
|
||||
source: function (request, response) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmProducts&action=javahelper&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "searchComponentsAutocomplite",
|
||||
term: request.term,
|
||||
source: 'name',
|
||||
},
|
||||
success: function (data) {
|
||||
|
||||
console.log(data);
|
||||
response(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
minLength: 3,
|
||||
select: function (event, ui) {
|
||||
var uniqueid = $(event.target).attr('id');
|
||||
uniqueid = uniqueid.substring('tableComponents_name_'.length);
|
||||
var rowIndex = $('#tableComponents').appendGrid('getRowIndex', uniqueid);
|
||||
if (ui.item.id != '') {
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'code', rowIndex, ui.item.code);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'quantity', rowIndex, '0.000000');
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'ecmcomponent_id', rowIndex, ui.item.ecmcomponent_id);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'unit_id', rowIndex, ui.item.unit_id);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'product_category_id', rowIndex, ui.item.product_category_id);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'product_category_name', rowIndex, ui.item.product_category_name);
|
||||
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'price', rowIndex, {Single: ui.item.srp_price, Summary: 0.000000});
|
||||
}
|
||||
},
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
}, {
|
||||
name: 'product_category_name',
|
||||
display: SUGAR.language.get("app_strings", "LBL_CATEGORY"),
|
||||
type: 'text',
|
||||
displayCss: {
|
||||
'width': '10%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
ctrlAttr: {
|
||||
disabled: 'disabled',
|
||||
readonly: 'readonly'
|
||||
},
|
||||
}, {
|
||||
name: 'unit_id',
|
||||
display: SUGAR.language.get("app_strings", "LBL_JM"),
|
||||
type: 'select',
|
||||
ctrlOptions: SUGAR.language.get("app_list_strings", "ecmproducts_unit_dom"),
|
||||
displayCss: {
|
||||
'width': '3%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'left'
|
||||
},
|
||||
ctrlClass: 'inputs',
|
||||
}, {
|
||||
name: 'quantity_recipe',
|
||||
display: SUGAR.language.get("app_strings", "LBL_QUANTITY_RECIPE"),
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0.00000000',
|
||||
displayCss: {
|
||||
'width': '7%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'right'
|
||||
},
|
||||
onClick: function (evt, rowIndex) {
|
||||
|
||||
|
||||
$('#tableComponents_quantity_recipe_'+(rowIndex+1)).select();
|
||||
},
|
||||
onChange: function (evt, rowIndex) {
|
||||
var row = $('#tableComponents').appendGrid('getRowValue', rowIndex);
|
||||
var formatedQuantity = QuantityFormat(row.quantity_recipe,8);
|
||||
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'quantity_recipe', rowIndex, formatedQuantity);
|
||||
var Quantity=formatedQuantity;
|
||||
var PriceSingle = (row.price.Single);
|
||||
|
||||
var Divider = UnformatNumber(row.divider);
|
||||
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'quantity', rowIndex,QuantityFormat(Quantity/Divider,8));
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'price', rowIndex, {Single: row.price.Single, Summary: (Quantity/Divider) * PriceSingle});
|
||||
|
||||
updateSumComponents();
|
||||
}
|
||||
}, {
|
||||
name: 'divider',
|
||||
display: SUGAR.language.get("app_strings", "LBL_DIVIDER"),
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '1,0',
|
||||
displayCss: {
|
||||
'width': '7%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'right'
|
||||
},
|
||||
onClick: function (evt, rowIndex) {
|
||||
|
||||
|
||||
$('#tableComponents_divider_'+(rowIndex+1)).select();
|
||||
},
|
||||
onChange: function (evt, rowIndex) {
|
||||
var row = $('#tableComponents').appendGrid('getRowValue', rowIndex);
|
||||
var formatedQuantity = FormatNumber(row.divider,2);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'divider', rowIndex, formatedQuantity);
|
||||
var Quantity = UnformatNumber(formatedQuantity);
|
||||
var PriceSingle = (row.price.Single);
|
||||
var Divider = row.quantity_recipe;
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'quantity', rowIndex,QuantityFormat(Divider/Quantity,6));
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'price', rowIndex, {Single: row.price.Single, Summary: (Divider/Quantity) * PriceSingle});
|
||||
|
||||
updateSumComponents();
|
||||
}
|
||||
}, {
|
||||
name: 'quantity',
|
||||
display: SUGAR.language.get("app_strings", "LBL_QUANTITY"),
|
||||
type: 'text',
|
||||
ctrlClass: 'inputs',
|
||||
value: '0.000000',
|
||||
displayCss: {
|
||||
'width': '7%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
ctrlCss: {
|
||||
'text-align': 'right'
|
||||
},
|
||||
onClick: function (evt, rowIndex) {
|
||||
|
||||
|
||||
$('#tableComponents_quantity_'+(rowIndex+1)).select();
|
||||
},
|
||||
ctrlAttr: { 'readonly': 'readonly' },
|
||||
onChange: function (evt, rowIndex) {
|
||||
var row = $('#tableComponents').appendGrid('getRowValue', rowIndex);
|
||||
var formatedQuantity = QuantityFormat(row.quantity,6);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'quantity', rowIndex, formatedQuantity);
|
||||
var Quantity = formatedQuantity;
|
||||
var PriceSingle = (row.price.Single);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'price', rowIndex, {Single: row.price.Single, Summary: Quantity * PriceSingle});
|
||||
|
||||
updateSumComponents();
|
||||
}
|
||||
}, {
|
||||
name: 'price',
|
||||
display: 'Cena / Wartość',
|
||||
type: 'custom',
|
||||
displayCss: {
|
||||
'width': '7%',
|
||||
'vertical-align': 'middle'
|
||||
},
|
||||
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
|
||||
// Tworzenie Id dla inputow
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
//kontener
|
||||
var ctrl = document.createElement('span');
|
||||
//dodajemy kontener do komorki w tabeli
|
||||
$(ctrl).attr({id: ctrlId, name: ctrlId}).appendTo(parent);
|
||||
//Tworzymy pierwszy input dla ceny jednostkowej
|
||||
var Single = $('<input/>', {type: 'text', id: ctrlId + '_Single', name: ctrlId + '_Single', class: 'inputs'}).css({'width': '100%', 'text-align': 'right'});
|
||||
//Ustawiamy wartosc domyslna
|
||||
$(Single).val('0,00');
|
||||
//Akacja wywolywana podczas zmiany wartosci oraz formatuje
|
||||
// oblicza (ilosc*cena jednostkowa) i wstawia
|
||||
$(Single).change(function () {
|
||||
var SingleFormated = FormatNumber($(this).val());
|
||||
$(this).val(SingleFormated);
|
||||
var qunatity = ($('#' + idPrefix + '_quantity_' + uniqueIndex).val());
|
||||
$('#' + ctrlId + '_Summary').val(FormatNumber(qunatity * UnformatNumber(SingleFormated),6));
|
||||
updateSumComponents();
|
||||
});
|
||||
$(Single).on('click',function () {
|
||||
$('#tableComponents_price_'+(uniqueIndex)+"_Single").select();
|
||||
});
|
||||
//dodajemy do kontenera
|
||||
$(Single).appendTo(ctrl);
|
||||
//oddzielamy widoczna linia
|
||||
var hr = document.createElement('hr');
|
||||
$(hr).css('margin', '0em').appendTo(ctrl);
|
||||
//Tworzymy drugi input dla sumy
|
||||
var Summary = $('<input/>', {type: 'text', id: ctrlId + '_Summary', name: ctrlId + '_Summary', class: 'inputs'}).css({'width': '100%', 'text-align': 'right'});
|
||||
//Ustawiamy wartosc domyslna
|
||||
$(Summary).val('0,000000');
|
||||
//Akacja wywolywana podczas zmiany wartosci oraz formatuje
|
||||
// oblicza (suma / ilosc) i wstawia
|
||||
$(Summary).change(function () {
|
||||
var SummaryFormated = FormatNumber($(this).val(),6);
|
||||
$(this).val(SummaryFormated);
|
||||
var qunatity = ($('#' + idPrefix + '_quantity_' + uniqueIndex).val());
|
||||
$('#' + ctrlId + '_Single').val(FormatNumber(UnformatNumber(SummaryFormated) / qunatity));
|
||||
updateSumComponents();
|
||||
});
|
||||
$(Summary).appendTo(ctrl);
|
||||
return ctrl;
|
||||
},
|
||||
customGetter: function (idPrefix, name, uniqueIndex) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
var Single = UnformatNumber($('#' + ctrlId + '_Single').val());
|
||||
var Summary = UnformatNumber($('#' + ctrlId + '_Summary').val());
|
||||
return {Single: Single, Summary: Summary};
|
||||
},
|
||||
customSetter: function (idPrefix, name, uniqueIndex, value) {
|
||||
console.log(value);
|
||||
if (value != null) {
|
||||
var ctrlId = idPrefix + '_' + name + '_' + uniqueIndex;
|
||||
$('#' + ctrlId + '_Single').val(value['Single'] == null ? '0,00' : FormatNumber(value['Single']));
|
||||
$('#' + ctrlId + '_Summary').val(value['Summary'] == null ? '0,000000' : FormatNumber(value['Summary'],6));
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: 'ecmcomponent_id',
|
||||
display: 'ecmcomponent_id',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
}, {
|
||||
name: 'product_category_id',
|
||||
display: 'product_category_id',
|
||||
type: 'text',
|
||||
invisible: true,
|
||||
},
|
||||
],
|
||||
i18n: {
|
||||
append: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_APPEND"),
|
||||
remove: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVE"),
|
||||
insert: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_INSERT"),
|
||||
moveUp: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEUP"),
|
||||
moveDown: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEDOWN"),
|
||||
removeLast: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVELAST"),
|
||||
rowEmpty: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWEMPTY"),
|
||||
rowDrag: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWDRAG"),
|
||||
},
|
||||
customGridButtons: {
|
||||
insert: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/add_position.gif';
|
||||
return button;
|
||||
},
|
||||
remove: function () {
|
||||
var button = document.createElement('img');
|
||||
button.src = 'modules/EcmQuotes/images/deleterow.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;
|
||||
},
|
||||
},
|
||||
afterRowRemoved: function (caller, rowIndex) {
|
||||
var quantity = $('#tableComponents').appendGrid(
|
||||
'getRowCount');
|
||||
if (quantity == 0) {
|
||||
$('#tableComponents').appendGrid('appendRow', 1);
|
||||
}
|
||||
},
|
||||
afterRowAppended: function(caller, parentRowIndex, addedRowIndex){
|
||||
|
||||
$('#tableComponents_name_'+(addedRowIndex+1)).focus();
|
||||
},
|
||||
hideButtons: {
|
||||
removeLast: true,
|
||||
append: false,
|
||||
insert: false,
|
||||
moveUp: true,
|
||||
moveDown: true
|
||||
}
|
||||
});
|
||||
var buttonSelect = document.createElement('img');
|
||||
buttonSelect.src = 'modules/EcmQuotes/images/search.gif';
|
||||
$(buttonSelect).addClass('selectComponent');
|
||||
$(buttonSelect).on('click', selectComponent);
|
||||
//$("#tableComponents").find("tbody").find(".last").append(buttonSelect);
|
||||
$('#tableComponents_price_td_head').html('Cena<br>Wartość');
|
||||
var count = $('#tableComponents').appendGrid('getRowCount');
|
||||
for (var i = 0; i < count; i++) {
|
||||
var value = $('#tableComponents').appendGrid('getCtrlValue', 'quantity', i);
|
||||
var divider = $('#tableComponents').appendGrid('getCtrlValue', 'divider', i);
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'quantity', i, QuantityFormat(value,6));
|
||||
$('#tableComponents').appendGrid('setCtrlValue', 'divider', i, FormatNumber(divider,2));
|
||||
}
|
||||
//Podsumowanie
|
||||
var html = '<tr><td colspan="8" style="vertical-align: middle;border-top: 1px solid black">Suma:</td><td style="text-align: right;border-top: 1px solid black"><span id="sumComponentsPriceTotal">0,000000</span></td></tr>';
|
||||
$('#tableComponents').find('tfoot tr:last').after(html);
|
||||
updateSumComponents();
|
||||
}
|
||||
|
||||
function selectComponent(){
|
||||
var id = $(this).closest('tr').find("input[name^='tableComponents_ecmcomponent_id_']").attr('id');
|
||||
var name = $(this).closest('tr').find("input[name^='tableComponents_name_']").attr('id');
|
||||
var code = $(this).closest('tr').find("input[name^='tableComponents_code_']").attr('id');
|
||||
var unit_id = $(this).closest('tr').find("select[name^='tableComponents_unit_id']").attr('id');
|
||||
|
||||
var window = open_popup('EcmProducts', 600, 400, '', true, false,{'call_back_function': 'testms', 'form_name': 'EditView', 'field_to_name_array':{'id': id, 'name': name ,'code' : code ,'unit_id' : unit_id}}, 'single', true);
|
||||
}
|
||||
function testms(dane1,dane2){
|
||||
console.log(dane1);
|
||||
console.log(dane2);
|
||||
}
|
||||
function updateSumComponents() {
|
||||
var data = $('#tableComponents').appendGrid('getAllValue');
|
||||
var sumPriceSingle = 0;
|
||||
var sumPriceTotal = 0;
|
||||
$.each(data, function (index, value) {
|
||||
console.log(value.price.Single);
|
||||
console.log(parseFloat(value.price.Single));
|
||||
sumPriceTotal += parseFloat(value.price.Summary);
|
||||
});
|
||||
$('#sumComponentsPriceTotal').html(FormatNumber(sumPriceTotal,6));
|
||||
}
|
||||
910
modules/EcmProducts/javascript/MyTable.js
Executable file
910
modules/EcmProducts/javascript/MyTable.js
Executable file
@@ -0,0 +1,910 @@
|
||||
var reg = /[\s]/g;
|
||||
|
||||
function findPos(obj) {
|
||||
var curleft = curtop = 0;
|
||||
if (obj.offsetParent)
|
||||
do {
|
||||
curleft += obj.offsetLeft;
|
||||
curtop += obj.offsetTop;
|
||||
} while (obj = obj.offsetParent);
|
||||
return [curleft, curtop];
|
||||
}
|
||||
|
||||
function generateSelectOptions(arr, selected) {
|
||||
var tmp = '';
|
||||
for (x in arr) {
|
||||
tmp += '<option value="' + x + '" ' + ((arr[x] === selected) ? 'selected' : '') + '>' + arr[x] + '</option>';
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
function NumberToUserFormatNumber(number, add, len, zeros) {
|
||||
if (!number)
|
||||
number = 0;
|
||||
if (!len) {
|
||||
len = 2;
|
||||
zeros = 2;
|
||||
}
|
||||
number = parseFloat(number);
|
||||
//var tmp = number.toFixed(OPT['dec_len']);
|
||||
var tmp = number.toFixed(len);
|
||||
//var s1 = tmp.substring(0,tmp.length-1-OPT['dec_len']);
|
||||
var s1 = tmp.substring(0, tmp.length - 1 - len);
|
||||
if (zeros == true)
|
||||
return s1;
|
||||
//var s2 = tmp.substring(tmp.length-OPT['dec_len'],tmp.length);
|
||||
var s2 = tmp.substring(tmp.length - len, tmp.length);
|
||||
var tmp = '';
|
||||
for (var i = s1.length; i > 0; i -= 3) {
|
||||
// tmp = ((i<=3)?"":OPT['sep_1000'])+s1.substring(i-3,i)+tmp;
|
||||
tmp = s1.substring(i - 3, i) + tmp;
|
||||
if (i > 3)
|
||||
tmp = '.' + tmp;
|
||||
}
|
||||
s1 = tmp;
|
||||
if (s2.length > zeros) {
|
||||
var cut = s2.length;
|
||||
for (var i = s2.length - 1; i > zeros - 1; i--) {
|
||||
if (s2[i] == '0')
|
||||
cut--;
|
||||
else
|
||||
break;
|
||||
}
|
||||
s2 = s2.substring(0, cut);
|
||||
}
|
||||
//console.log(s2);
|
||||
//return (s1+OPT['dec_sep']+s2).toString()+((add)?add:'');
|
||||
return (s1 + ',' + s2).toString() + ((add) ? add : '');
|
||||
}
|
||||
|
||||
function UserFormatNumberToNumber(ufn, add) {
|
||||
if (add) {
|
||||
var match = /add/g;
|
||||
ufn = ufn.replace(match, '');
|
||||
}
|
||||
var match = /Err/g;
|
||||
ufn = ufn.replace(match, '');
|
||||
if (!ufn)
|
||||
return parseFloat(0);
|
||||
var pos = ufn.indexOf(OPT['dec_sep']);
|
||||
var s1 = '',
|
||||
s2 = '';
|
||||
if (pos == -1) {
|
||||
s1 = ufn;
|
||||
s2 = '';
|
||||
} else {
|
||||
s1 = ufn.substring(0, pos);
|
||||
s2 = ufn.substring(pos + 1, ufn.length);
|
||||
}
|
||||
/*
|
||||
if(OPT['sep_1000'] != "")
|
||||
for(var i=s1.length-4;i>=0;i-=4)
|
||||
if(s1.charAt(i) != OPT['sep_1000']) { return -1; }
|
||||
if(s1.charAt(0) == OPT['sep_1000']) return -1;
|
||||
*/
|
||||
var pos = -1;
|
||||
while ((pos = s1.indexOf(OPT['sep_1000'])) != - 1)
|
||||
s1 = s1.substring(0, pos) + s1.substring(pos + 1, s1.length);
|
||||
//alert(s1);
|
||||
return parseFloat(s1 + "." + s2);
|
||||
}
|
||||
|
||||
function keyPressedNumber(e) {
|
||||
var keynum;
|
||||
if (window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
return keynum;
|
||||
}
|
||||
|
||||
function isEnterOrTabPressed(e) {
|
||||
var keynum = keyPressedNumber(e);
|
||||
if (keynum == 9 || keynum == 13)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function setSelectionRange(obj) {
|
||||
if (obj && typeof (obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
|
||||
if (obj.createTextRange) {
|
||||
var range = obj.createTextRange();
|
||||
range.moveStart("character", 0);
|
||||
range.moveEnd("character", obj.value.lengh - 1);
|
||||
range.select();
|
||||
} else {
|
||||
if (obj.setSelectionRange) {
|
||||
obj.setSelectionRange(0, obj.value.length);
|
||||
}
|
||||
}
|
||||
obj.focus();
|
||||
}
|
||||
if (obj && typeof (obj) == "object" && obj.options) {
|
||||
obj.focus();
|
||||
}
|
||||
}
|
||||
/*
|
||||
function keyPressed = function(e, method) {
|
||||
var keynumkey = PressedNumber(e);
|
||||
if((keynum == 9) || (keynum == 13)) {
|
||||
//this.calculateTotal();
|
||||
//if(this.selectedCell.lp == 1) setTimeout( function() { N.selectNextCell(); } , 100);
|
||||
//this.selectNextCell();
|
||||
return false;
|
||||
}
|
||||
//if(keynum == 40) this.selectNextRow();
|
||||
//if(keynum == 38) this.selectPreviousRow();
|
||||
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
|
||||
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
|
||||
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
|
||||
return true;
|
||||
}
|
||||
this.OnlyNumbers = function(e, noQuote) {
|
||||
var keynum = e, keychar, numcheck;
|
||||
keychar = String.fromCharCode(keynum);
|
||||
numcheck = /\d/;
|
||||
return numcheck.test(keychar)
|
||||
|| ((!noQuote)?(keynum == 190):false)
|
||||
|| (keynum == 8) //backspace
|
||||
|| (keynum == 13) //enter
|
||||
|| (keynum == 0) //special keys with FF
|
||||
|| (keynum == 37) //left arrow
|
||||
|| (keynum == 39) //right arrow
|
||||
|| (keynum == 188) //,
|
||||
|| (keynum >= 95 && keynum <= 105) //numeric keyboard
|
||||
|| (keynum == 110);
|
||||
}
|
||||
*/
|
||||
function MyTable(name) {
|
||||
this.myTableName = name;
|
||||
this.table = document.getElementById(this.myTableName);
|
||||
this.thead = this.table.tHead;
|
||||
this.tbody = this.table.tBodies.item(0);
|
||||
this.cellSelectedClass = 'selectedCell';
|
||||
this.rowSelectedClass = 'selectedRow';
|
||||
this.selectedRow;
|
||||
this.selectedCell;
|
||||
this.divParent;
|
||||
this.rowCount = function () {
|
||||
return this.tbody.rows.length;
|
||||
}
|
||||
this.colCount = function () {
|
||||
return this.thead.rows.item(0).cells.length;
|
||||
};
|
||||
this.colWidth = function (i) {
|
||||
return this.thead.rows.item(0).cells.item(i).width;
|
||||
};
|
||||
this.moveUpRow = function () {
|
||||
if (this.selectedRow)
|
||||
this.selectedRow.moveUp();
|
||||
};
|
||||
this.moveDownRow = function () {
|
||||
if (this.selectedRow)
|
||||
this.selectedRow.moveDown();
|
||||
};
|
||||
this.insertRow = function (row, newRow) {
|
||||
if (!row)
|
||||
if (this.rowCount())
|
||||
if (typeof (row) == "number")
|
||||
row = this.tbody.rows.item(row);
|
||||
else
|
||||
row = this.tbody.rows.item(this.tbody.rows.length - 1);
|
||||
var row_tmp;
|
||||
if ((newRow) && (row))
|
||||
row_tmp = newRow;
|
||||
else {
|
||||
row_tmp = this.createRow();
|
||||
this.fillWithDefaultData(row_tmp);
|
||||
}
|
||||
if (this.rowCount() > 0 && row.nextSibling)
|
||||
this.tbody.insertBefore(row_tmp, row.nextSibling);
|
||||
else
|
||||
this.tbody.appendChild(row_tmp);
|
||||
return row_tmp;
|
||||
};
|
||||
/*
|
||||
this.deleteRow = function(row) {
|
||||
if(!row)
|
||||
if(this.rowCount())
|
||||
if(typeof(row) == "number")
|
||||
row = this.tbody.rows.item(row);
|
||||
else
|
||||
row = this.tbody.rows.item(this.tbody.rows.length-1);
|
||||
if(!row) return;
|
||||
if(row.nextSibling) this.selectNextRow();
|
||||
else if(row.previousSibling) this.selectPreviousRow();
|
||||
this.tbody.removeChild(row);
|
||||
this.deselectRow();
|
||||
this.deselectCell();
|
||||
if(this.rowCount() == 0)
|
||||
setTimeout( function() { N.insertRow(); } , 1000);
|
||||
}
|
||||
this.changeRowMode = function(row) {
|
||||
row.isnew = !row.isnew;
|
||||
this.setEditNames(row,!row.isnew);
|
||||
var img = row.firstChild.nextSibling.lastChild.previousSibling.previousSibling;
|
||||
if(row.isnew)
|
||||
img.setAttribute('src','modules/EcmInvoiceOuts/images/newproductset.gif');
|
||||
else
|
||||
img.setAttribute('src','modules/EcmInvoiceOuts/images/newproduct.gif');
|
||||
}
|
||||
*/
|
||||
this.refreshRowIndex = function () {
|
||||
for (var i = 0; i < this.rowCount(); i++) {
|
||||
this.tbody.rows.item(i).index = i;
|
||||
if (this.onRefreshRowIndex)
|
||||
this.onRefreshRowIndex(this.tbody.rows.item(i));
|
||||
}
|
||||
}
|
||||
this.onRefreshRowIndex;
|
||||
this.addRow = function (i, data) {
|
||||
if (this.rowCount() > 0) {
|
||||
try {
|
||||
if (typeof (i) != "undefined") {
|
||||
var r = i;
|
||||
if (typeof (i) == "object") {
|
||||
} else if (typeof (i) == "number")
|
||||
r = this.tbody.rows.item(i - 1);
|
||||
if (this.isProductLoaded(r.cells.item(0)) == false) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
var row = this.createRow();
|
||||
if (this.selectedRow)
|
||||
this.selectedRow.deselect();
|
||||
if (this.selectedCell)
|
||||
this.selectedCell.deselect();
|
||||
row.myTable = this;
|
||||
if (typeof (i) == "number")
|
||||
this.tbody.insertBefore(row, this.tbody.rows.item(i));
|
||||
else
|
||||
this.tbody.appendChild(row);
|
||||
this.refreshRowIndex();
|
||||
this.setRowData(row, data);
|
||||
for (var i = 0; i < this.colCount(); i++)
|
||||
row.cells.item(i).afterCreate();
|
||||
return row;
|
||||
}
|
||||
this.createRow = function (row) {
|
||||
var row = document.createElement('tr');
|
||||
row.myTable = this;
|
||||
row.isnew = false;
|
||||
row.onclick = function () {
|
||||
this.select();
|
||||
}
|
||||
row.select = function () {
|
||||
if (!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
|
||||
if (this.myTable.selectedRow)
|
||||
this.myTable.selectedRow.deselect();
|
||||
this.myTable.selectedRow = this;
|
||||
this.className = this.myTable.rowSelectedClass;
|
||||
if (row.onSelect)
|
||||
row.onSelect();
|
||||
if (this.myTable.divParent)
|
||||
if (((this.offsetTop + this.offsetHeight - this.myTable.divParent.scrollTop) > (this.myTable.divParent.offsetHeight + 5)) || ((this.offsetTop - this.myTable.divParent.scrollTop) < (-10)))
|
||||
this.myTable.divParent.scrollTop = this.offsetTop;
|
||||
}
|
||||
}
|
||||
row.deselect = function () {
|
||||
if (this.myTable.selectedRow === this) {
|
||||
this.className = '';
|
||||
this.myTable.selectedRow = '';
|
||||
if (row.onDeselect)
|
||||
row.onDeselect();
|
||||
}
|
||||
};
|
||||
row.calculateTotal = function () {
|
||||
};
|
||||
row.selectNext = function () {
|
||||
if (this.index < this.myTable.rowCount() - 1) {
|
||||
this.deselect();
|
||||
this.nextSibling.select();
|
||||
return this.nextSibling;
|
||||
} else {
|
||||
if (this.noAddNew)
|
||||
return this;
|
||||
this.deselect();
|
||||
var row = this.myTable.addRow();
|
||||
return row;
|
||||
}
|
||||
}
|
||||
row.selectPrevious = function () {
|
||||
this.deselect();
|
||||
if (this.previousSibling) {
|
||||
this.previousSibling.select();
|
||||
return this.previousSibling;
|
||||
} else
|
||||
return this;
|
||||
}
|
||||
row.deleteRow = function (noNew) {
|
||||
if (this.myTable.selectedCell)
|
||||
this.myTable.selectedCell.deselect();
|
||||
if (this.myTable.selectedRow)
|
||||
this.myTable.selectedRow.deselect();
|
||||
if (this.myTable.rowCount() == 1 && !noNew) {
|
||||
var MyTaBlE = this.myTable;
|
||||
setTimeout(function () {
|
||||
MyTaBlE.addRow();
|
||||
}, 1000);
|
||||
}
|
||||
this.myTable.tbody.removeChild(this);
|
||||
this.myTable.refreshRowIndex();
|
||||
calculateTotal();
|
||||
}
|
||||
row.moveUp = function () {
|
||||
if (!this.previousSibling)
|
||||
return;
|
||||
this.myTable.tbody.insertBefore(this, this.previousSibling);
|
||||
this.myTable.refreshRowIndex();
|
||||
}
|
||||
row.moveDown = function () {
|
||||
if (!this.nextSibling)
|
||||
this.myTable.addRow(row);
|
||||
this.myTable.tbody.insertBefore(this.nextSibling, this);
|
||||
this.myTable.refreshRowIndex();
|
||||
}
|
||||
row.setData = function (data) {
|
||||
if (!data || typeof (data) != "object") {
|
||||
return;
|
||||
}
|
||||
;
|
||||
for (var i = 0; i < this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).setData(data);
|
||||
}
|
||||
//this.calculateTotal();
|
||||
}
|
||||
row.getData = function () {
|
||||
var data = new Object();
|
||||
for (var i = 0; i < this.myTable.colCount(); i++) {
|
||||
if (this.cells.item(i).getData)
|
||||
this.cells.item(i).getData(data, true);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
for (var i = 0; i < this.colCount(); i++) {
|
||||
var cell = this.createCell(i);
|
||||
row.appendChild(cell);
|
||||
}
|
||||
if (this.onCreateRow)
|
||||
this.onCreateRow(row);
|
||||
return row;
|
||||
};
|
||||
this.onCreateRow; //function(row) {}
|
||||
this.cellCodeIndex = 1;
|
||||
this.isProductLoaded = function (cell) {
|
||||
if (this.selectedRow && typeof (this.selectedRow) != "undefined" && this.selectedRow === cell.parentNode) {
|
||||
var data = this.selectedRow.getData();
|
||||
if (data.id && data.id != "" && data.code && data.code != "") {
|
||||
} else {
|
||||
if (this.selectedCell !== cell && cell === this.selectedRow.cells.item(1)) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
if (cell.parentNode.cells.item(1).firstChild.focus && !cell.parentNode.cells.item(1).noSelect)
|
||||
setSelectionRange(cell.parentNode.cells.item(1).firstChild);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (typeof (cell) != "undefined" && cell.index != this.cellCodeIndex) {
|
||||
cell.parentNode.select();
|
||||
cell.parentNode.cells.item(1).select();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
this.createCell = function (i) {
|
||||
var cell = document.createElement('td');
|
||||
cell.index = i;
|
||||
cell.myTable = this;
|
||||
cell.onclick = function () {
|
||||
this.select();
|
||||
}
|
||||
cell.select = function () {
|
||||
if (this.myTable.isProductLoaded(this) == false)
|
||||
return;
|
||||
if (!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
|
||||
if (this.myTable.selectedCell)
|
||||
this.myTable.selectedCell.deselect();
|
||||
this.myTable.selectedCell = this;
|
||||
if (this.firstChild.focus && !this.noSelect)
|
||||
setSelectionRange(this.firstChild);
|
||||
if (this.onSelect)
|
||||
this.onSelect();
|
||||
this.className = this.myTable.cellSelectedClass;
|
||||
}
|
||||
}
|
||||
cell.deselect = function () {
|
||||
if (this.myTable.selectedCell === this) {
|
||||
if (this.onDeselect)
|
||||
cell.onDeselect();
|
||||
if (this.onDeselect2)
|
||||
cell.onDeselect2();
|
||||
this.className = '';
|
||||
this.selected = false;
|
||||
this.myTable.selectedCell = '';
|
||||
this.parentNode.calculateTotal();
|
||||
}
|
||||
};
|
||||
cell.selectNext = function () {
|
||||
this.deselect();
|
||||
if (this.nextSibling)
|
||||
this.nextSibling.select();
|
||||
else {
|
||||
if (!this.parentNode.nextSibling)
|
||||
this.myTable.addRow();
|
||||
this.parentNode.nextSibling.select();
|
||||
this.parentNode.nextSibling.firstChild.select();
|
||||
}
|
||||
}
|
||||
cell.afterCreate = function () {
|
||||
}
|
||||
cell.setData = function (data) {
|
||||
}
|
||||
cell.getData = function (data) {
|
||||
}
|
||||
if (this.onCreateCell)
|
||||
this.onCreateCell(cell);
|
||||
return cell;
|
||||
};
|
||||
this.onCreateCell; //function(cell) {}
|
||||
this.setRowData = function (row, data) {
|
||||
for (var i = 0; i < this.colCount(); i++) {
|
||||
this.setCellData(row, row.cells.item(i), data);
|
||||
}
|
||||
}
|
||||
this.setCellData = function (row, cell, data) {
|
||||
if (typeof (row) == "number")
|
||||
if (this.tbody.rows.item(row))
|
||||
row = this.tbody.rows.item(row);
|
||||
if (typeof (cell) != "object")
|
||||
if (typeof (cell) == "number" && typeof (row) == "object") {
|
||||
if (row.cells.item(cell))
|
||||
cell = row.cells.item(cell);
|
||||
else
|
||||
return;
|
||||
} else
|
||||
return;
|
||||
if (this.onSetCellData)
|
||||
this.onSetCellData(row, cell, data);
|
||||
}
|
||||
this.onSetCellData; //function(row,cell,data) {}
|
||||
this.setEditNames = function (row, isset) {
|
||||
if (isset)
|
||||
for (var i = 0; i < row.cells.length; i++) {
|
||||
if (i != 0 && i != 6 && i != 7) {
|
||||
var c = row.cells.item(i).firstChild;
|
||||
if (c.parentNode.lp == 1) {
|
||||
c.name = 'parent_wi';
|
||||
c.id = 'parent_wi';
|
||||
c = c.nextSibling.nextSibling.nextSibling.nextSibling;
|
||||
c.name = 'parent_name_wi';
|
||||
c.id = 'parent_name_wi';
|
||||
c.className = 'sqsEnabled';
|
||||
//alert(c);
|
||||
c = c.nextSibling;
|
||||
c.name = 'parent_id_wi';
|
||||
c.id = 'parent_id_wi';
|
||||
/*
|
||||
c=c.nextSibling;
|
||||
c.name = 'vat_id_p'; c.id = 'vat_id_p';
|
||||
c=c.nextSibling;
|
||||
c.name = 'category_id_p'; c.id = 'category_id_p';
|
||||
*/
|
||||
}
|
||||
/*
|
||||
if(c.parentNode.lp == 2) { c.name = 'name_p'; c.id = 'name_p'; c.className = 'sqsEnabled'; }
|
||||
if(c.parentNode.lp == 3) { c.name = 'quantity_p'; c.id = 'quantity_p'; }
|
||||
if(c.parentNode.lp == 4) { c.name = 'price_p'; c.id = 'price_p'; }
|
||||
if(c.parentNode.lp == 5) { c.name = 'discount_p'; c.id = 'discount_p'; }
|
||||
*/
|
||||
}
|
||||
}
|
||||
else
|
||||
for (var i = 0; i < row.cells.length; i++) {
|
||||
if (i != 0 && i != 5) {
|
||||
var c = row.cells.item(i).firstChild;
|
||||
c.name = '';
|
||||
c.id = '';
|
||||
if (i == 1) {
|
||||
c = c.nextSibling.nextSibling.nextSibling.nextSibling;
|
||||
c.name = '';
|
||||
c.id = '';
|
||||
c = c.nextSibling;
|
||||
c.name = '';
|
||||
c.id = '';
|
||||
/*
|
||||
c=c.nextSibling;
|
||||
c.name = ''; c.id = '';
|
||||
c=c.nextSibling;
|
||||
c.name = ''; c.id = ''; */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.deselectRow = function () {
|
||||
if (!this.selectedRow)
|
||||
return;
|
||||
this.setEditNames(this.selectedRow, false);
|
||||
this.selectedRow.className = '';
|
||||
this.deselectCell();
|
||||
this.selectedRow = null;
|
||||
}
|
||||
this.selectRow = function (row) {
|
||||
if (this.selectedRow === row)
|
||||
return;
|
||||
if (this.selectedRow)
|
||||
this.deselectRow();
|
||||
this.selectedRow = row;
|
||||
this.selectedRow.className = this.rowSelectedClass;
|
||||
this.setEditNames(this.selectedRow, !this.selectedRow.isnew);
|
||||
}
|
||||
this.selectNextRow = function () {
|
||||
if (!this.selectedRow)
|
||||
return;
|
||||
if (!this.selectedRow.nextSibling)
|
||||
this.insertRow();
|
||||
var cell_id = this.selectedCell.lp;
|
||||
this.selectRow(this.selectedRow.nextSibling);
|
||||
this.selectCell(this.selectedRow.cells.item(cell_id));
|
||||
}
|
||||
this.selectPreviousRow = function () {
|
||||
if (!this.selectedRow)
|
||||
return;
|
||||
if (!this.selectedRow.previousSibling)
|
||||
return;
|
||||
if (this.selectedRow === this.tbody.rows.item(0))
|
||||
return;
|
||||
var cell_id = this.selectedCell.lp;
|
||||
this.selectRow(this.selectedRow.previousSibling);
|
||||
this.selectCell(this.selectedRow.cells.item(cell_id));
|
||||
}
|
||||
this.calculateSubtotal = function (row, sub) {
|
||||
if (!row)
|
||||
if (this.selectedRow)
|
||||
row = this.selectedRow;
|
||||
else
|
||||
return 0;
|
||||
if (row.cells.item(4).err || row.cells.item(5).err) {
|
||||
row.cells.item(6).firstChild.value = NumberToUserFormatNumber(0);
|
||||
row.cells.item(6).firstChild.style.color = 'red';
|
||||
row.title = 'Bad number format';
|
||||
} else if (row.cells.item(2).firstChild.value == '' && UserFormatNumberToNumber(row.cells.item(4).firstChild.value) != 0 && !row.cells.item(4).err) {
|
||||
row.cells.item(6).firstChild.style.color = 'red';
|
||||
row.title = 'Position have price, but didin\'t have a description';
|
||||
} else {
|
||||
var quantity = parseInt(row.cells.item(3).firstChild.value);
|
||||
if (row.cells.item(1).firstChild.nextSibling.nextSibling.value == 3)
|
||||
quantity = 1;
|
||||
var price = UserFormatNumberToNumber(tmp = row.cells.item(4).firstChild.value);
|
||||
var discount = UserFormatNumberToNumber(row.cells.item(5).firstChild.value, "%");
|
||||
var total = NumberToUserFormatNumber(quantity * price - quantity * price * (discount / 100));
|
||||
row.cells.item(6).firstChild.value = total;
|
||||
row.cells.item(6).firstChild.style.color = 'black';
|
||||
row.title = '';
|
||||
}
|
||||
//if(!sub) this.calculateTotal();
|
||||
}
|
||||
this.calculateTotal = function () {
|
||||
var vats = new Object();
|
||||
var subtotal = 0;
|
||||
var total = 0;
|
||||
for (var i = 0; i < this.rowCount(); i++) {
|
||||
if (!OPT['to_is_vat_free']) {
|
||||
var v_tmp = this.tbody.rows.item(i).cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.value;
|
||||
if (v_tmp && this.tbody.rows.item(i).cells.item(2).firstChild.value != '') {
|
||||
if (typeof (vats[v_tmp]) != "object") {
|
||||
vats[v_tmp] = new Object();
|
||||
vats[v_tmp]['vat'] = 0;
|
||||
}
|
||||
vats[v_tmp]['vat'] += UserFormatNumberToNumber(this.tbody.rows.item(i).cells.item(6).firstChild.value);
|
||||
}
|
||||
} else if (typeof (vats['0.00']) != "object") {
|
||||
vats['0.00'] = new Object();
|
||||
vats['0.00']['vat'] = 0;
|
||||
}
|
||||
subtotal += UserFormatNumberToNumber(this.tbody.rows.item(i).cells.item(6).firstChild.value);
|
||||
}
|
||||
total = subtotal;
|
||||
var rt = document.getElementById('result_table');
|
||||
for (var i = 1; i < rt.rows.length - 1; i++) {
|
||||
if (!vats[rt.rows.item(i).id]) {
|
||||
rt.deleteRow(i);
|
||||
--i;
|
||||
} else
|
||||
vats[rt.rows.item(i).id]['node'] = rt.rows.item(i);
|
||||
}
|
||||
for (x in vats) {
|
||||
vats[x]['vat'] = vats[x]['vat'] * (parseFloat(x) / 100);
|
||||
total += vats[x]['vat'];
|
||||
var txL = 'VAT' + ' (' + NumberToUserFormatNumber(parseFloat(x), '%') + ')';
|
||||
var txF = NumberToUserFormatNumber(vats[x]['vat']);
|
||||
if (vats[x]['node']) {
|
||||
vats[x]['node'].id = x;
|
||||
vats[x]['node'].cells.item(0).innerHTML = txL;
|
||||
vats[x]['node'].cells.item(1).innerHTML = txF;
|
||||
} else {
|
||||
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 = txF;
|
||||
}
|
||||
}
|
||||
document.getElementById('subtotal_span').innerHTML = NumberToUserFormatNumber(subtotal);
|
||||
document.getElementById('subtotal').value = NumberToUserFormatNumber(subtotal);
|
||||
total = ((iType == "correct") ? '-' : '') + NumberToUserFormatNumber(total).toString();
|
||||
document.getElementById('total_span').innerHTML = total;
|
||||
document.getElementById('total').value = total;
|
||||
}
|
||||
this.deselectCell = function () {
|
||||
if (!this.selectedCell)
|
||||
return;
|
||||
var tmp = 0;
|
||||
var c = this.selectedCell;
|
||||
/*
|
||||
if(c.lp == 4)
|
||||
if(c.firstChild.value != "") {
|
||||
tmp = UserFormatNumberToNumber(this.selectedCell.firstChild.value);
|
||||
if(tmp == -1) {
|
||||
alert('Error with format number: '+c.firstChild.value);
|
||||
c.err = true;
|
||||
c.firstChild.style.color = 'red';
|
||||
}
|
||||
else {
|
||||
c.firstChild.value = NumberToUserFormatNumber(tmp);
|
||||
c.firstChild.style.color = 'black';
|
||||
c.err = false;
|
||||
}
|
||||
}
|
||||
if(c.lp == 5)
|
||||
if(c.firstChild.value != "") {
|
||||
tmp = UserFormatNumberToNumber(this.selectedCell.firstChild.value,"%");
|
||||
if(tmp == -1) {
|
||||
alert('Error with format number: '+c.firstChild.value);
|
||||
c.err = true;
|
||||
c.firstChild.style.color = 'red';
|
||||
}
|
||||
else {
|
||||
c.firstChild.value = NumberToUserFormatNumber(tmp,"%");
|
||||
c.firstChild.style.color = 'black';
|
||||
c.err = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//this.calculateSubtotal(c.parentNode);
|
||||
this.selectedCell.className = '';
|
||||
this.selectedCell = null;
|
||||
}
|
||||
this.selectCell = function (cell) {
|
||||
if (this.selectedCell === cell)
|
||||
return;
|
||||
if (this.selectedCell)
|
||||
this.deselectCell();
|
||||
this.selectedCell = cell;
|
||||
if (!cell.noSelect) {
|
||||
this.selectedCell.className = this.cellSelectedClass;
|
||||
this.setCellFocus(this.selectedCell);
|
||||
}
|
||||
}
|
||||
this.selectNextCell = function () {
|
||||
if (!this.selectedCell)
|
||||
return;
|
||||
if (this.selectedCell.lp == 4) {
|
||||
this.selectNextRow();
|
||||
this.selectCell(this.selectedRow.firstChild.nextSibling);
|
||||
} else
|
||||
this.selectCell(this.selectedCell.nextSibling);
|
||||
}
|
||||
this.setCellFocus = function (cell, input) {
|
||||
if (typeof (cell) == 'number') {
|
||||
cell = this.selectedRow.cells.item(cell);
|
||||
}
|
||||
var edit = ((input) ? input : cell.firstChild);
|
||||
if (edit && typeof (edit) == "object" && (edit.type == "text" || edit.type == "textarea")) {
|
||||
if (edit.createTextRange) {
|
||||
var range = edit.createTextRange();
|
||||
range.moveStart("character", 0);
|
||||
range.moveEnd("character", edit.value.lengh - 1);
|
||||
range.select();
|
||||
} else {
|
||||
if (edit.setSelectionRange) {
|
||||
edit.setSelectionRange(0, edit.value.length);
|
||||
}
|
||||
}
|
||||
edit.focus();
|
||||
}
|
||||
if (edit && typeof (edit) == "object" && edit.options) {
|
||||
edit.focus();
|
||||
}
|
||||
}
|
||||
this.fillWithDefaultData = function (row) {
|
||||
//this.setCellData(3,1,row);
|
||||
//this.setCellData(5,0,row);
|
||||
//this.setCellData(6,0,row);
|
||||
}
|
||||
this.refreshNumeration = function () {
|
||||
for (var i = 0; i < this.tbody.rows.length; i++)
|
||||
this.tbody.rows.item(i).cells.item(0).firstChild.value = i + 1;
|
||||
}
|
||||
/*
|
||||
this.setCellData = function(i,data,row) {
|
||||
if(!row) if(this.selectedRow) row = this.selectedRow; else return null;
|
||||
//if(i == 3) { row.firstChild.nextSibling.nextSibling.nextSibling.firstChild.value = data; }
|
||||
//if(i == 5) { row.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.value = NumberToUserFormatNumber(data,"%"); }
|
||||
//if(i == 6) { row.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.value = NumberToUserFormatNumber(data); }
|
||||
}
|
||||
*/
|
||||
this.insertRowFromArray = function (arr) {
|
||||
var row = this.insertRow();
|
||||
row.cells.item(1).firstChild.value = arr['code'];
|
||||
row.cells.item(1).firstChild.nextSibling.value = arr['id'];
|
||||
row.cells.item(1).firstChild.nextSibling.nextSibling.value = arr['unit_id'];
|
||||
row.cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.value = arr['vat_id'];
|
||||
row.cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.nextSibling.value = arr['category_id'];
|
||||
row.cells.item(2).firstChild.value = arr['name'];
|
||||
row.cells.item(3).firstChild.value = arr['quantity'];
|
||||
row.cells.item(4).firstChild.value = NumberToUserFormatNumber(arr['price']);
|
||||
row.cells.item(5).firstChild.value = NumberToUserFormatNumber(arr['discount'], '%');
|
||||
row.cells.item(6).firstChild.value = NumberToUserFormatNumber(arr['total']);
|
||||
}
|
||||
this.getRowData = function (row) {
|
||||
if (typeof (row) == "number")
|
||||
row = this.tbody.rows.item(row);
|
||||
var rData = new Object();
|
||||
rData['id'] = row.cells.item(1).firstChild.nextSibling.value;
|
||||
rData['unit_id'] = row.cells.item(1).firstChild.nextSibling.nextSibling.value;
|
||||
if (!rData['unit_id'])
|
||||
rData['unit_id'] = OPT['default_unit']; //szt
|
||||
rData['vat_id'] = row.cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.value;
|
||||
if (!rData['vat_id'])
|
||||
rData['vat_id'] = OPT['default_vat']; //standard
|
||||
rData['category_id'] = row.cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.nextSibling.value;
|
||||
if (!rData['category_id'])
|
||||
rData['category_id'] = OPT['default_category']; //no category
|
||||
rData['code'] = row.cells.item(1).firstChild.value;
|
||||
rData['name'] = row.cells.item(2).firstChild.value;
|
||||
rData['quantity'] = row.cells.item(3).firstChild.value;
|
||||
rData['price'] = UserFormatNumberToNumber(row.cells.item(4).firstChild.value);
|
||||
rData['discount'] = UserFormatNumberToNumber(row.cells.item(5).firstChild.value, '%');
|
||||
rData['total'] = UserFormatNumberToNumber(row.cells.item(6).firstChild.value);
|
||||
if (rData['code'] == '' && rData['name'] == '')
|
||||
return '';
|
||||
else
|
||||
return rData;
|
||||
}
|
||||
this.prepareToSend = function (json) {
|
||||
var rData = new Object();
|
||||
var l = 0,
|
||||
tmp;
|
||||
for (var i = 0; i < this.rowCount(); i++) {
|
||||
//this.calculateSubtotal(this.tbody.rows.item(i),true);
|
||||
tmp = this.getRowData(i);
|
||||
if (tmp != '') {
|
||||
rData[l.toString()] = tmp;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
//this.calculateTotal();
|
||||
if (!json)
|
||||
return JSON.stringifyNoSecurity(rData);
|
||||
else
|
||||
return rData;
|
||||
}
|
||||
this.KeyPressedNumber = function (e) {
|
||||
var keynum;
|
||||
if (window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
return keynum;
|
||||
}
|
||||
this.KeyPressed = function (e, cell, method, noArrow) {
|
||||
var keynum;
|
||||
if (window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
if ((keynum == 9) || (keynum == 13 && cell.index != 2)) {
|
||||
//this.calculateTotal();
|
||||
//if(this.selectedCell.lp == 1) setTimeout( function() { N.selectNextCell(); } , 100);
|
||||
//this.selectNextCell();
|
||||
if (cell.index == 1 || cell.index == 2)
|
||||
cell.parentNode.calculateTotal();
|
||||
cell.selectNext();
|
||||
return false;
|
||||
}
|
||||
if (!noArrow) {
|
||||
if (keynum == 40) {
|
||||
var id = cell.index;
|
||||
var row = cell.parentNode.selectNext();
|
||||
if (row) {
|
||||
row.select();
|
||||
row.cells.item(id).select();
|
||||
}
|
||||
}
|
||||
if (keynum == 38) {
|
||||
var id = cell.index;
|
||||
var row = cell.parentNode.selectPrevious();
|
||||
if (row) {
|
||||
row.select();
|
||||
row.cells.item(id).select();
|
||||
}
|
||||
}
|
||||
} else
|
||||
return true;
|
||||
if (e.shiftKey && (method == "decimalNumber" || method == "onlyNumber"))
|
||||
return false;
|
||||
if (method == "decimalNumber")
|
||||
return this.OnlyNumbers(keynum);
|
||||
if (method == "onlyNumber")
|
||||
return this.OnlyNumbers(keynum, true);
|
||||
return true;
|
||||
}
|
||||
this.OnlyNumbers = function (e, noQuote) {
|
||||
var keynum = e,
|
||||
keychar, numcheck;
|
||||
keychar = String.fromCharCode(keynum);
|
||||
numcheck = /\d/;
|
||||
return numcheck.test(keychar) || ((!noQuote) ? (keynum == 190) : false) || (keynum == 8) //backspace
|
||||
|| (keynum == 46) //delete
|
||||
|| (keynum == 13) //enter
|
||||
|| (keynum == 0) //special keys with FF
|
||||
|| (keynum == 37) //left arrow
|
||||
|| (keynum == 39) //right arrow
|
||||
|| (keynum == 188) //,
|
||||
|| (keynum >= 95 && keynum <= 105) //numeric keyboard
|
||||
|| (keynum == 110);
|
||||
}
|
||||
this.row = function (i) {
|
||||
if (this.tbody.rows.item(i))
|
||||
return this.tbody.rows.item(i);
|
||||
}
|
||||
this.cells = function (i, j) {
|
||||
if (this.tbody.rows.item(i).cells.item(i))
|
||||
return this.tbody.rows.item(i).cells.item(i);
|
||||
}
|
||||
}
|
||||
// var N;
|
||||
var parent_options;
|
||||
/*
|
||||
function ItemListSave(json) {
|
||||
if(N.selectedCell) N.selectedCell.deselect();
|
||||
if(N.selectedRow) N.selectedRow.deselect();
|
||||
var data = new Object();
|
||||
for(var i=0; i<N.rowCount(); i++) {
|
||||
data[i.toString()] = N.row(i).getData();
|
||||
}
|
||||
return json ? JSON.stringifyNoSecurity(data) : data;
|
||||
}
|
||||
function ItemListClear() {
|
||||
while(N.rowCount()>0) N.row(0).deleteRow();
|
||||
}
|
||||
*/
|
||||
function ItemListFill(list) {
|
||||
/*
|
||||
var start_list_count = 6;
|
||||
var count = 0;
|
||||
var arr = '';
|
||||
if(list)
|
||||
arr = list;
|
||||
else
|
||||
if(document.getElementById('position_list').value!="")
|
||||
arr = eval(document.getElementById('position_list').value);
|
||||
if(arr != '')
|
||||
for(x in arr) {
|
||||
N.insertRowFromArray(arr[x]);
|
||||
count++;
|
||||
}
|
||||
for(var i=count; i<start_list_count; i++) N.insertRow();
|
||||
N.calculateTotal();
|
||||
*/
|
||||
}
|
||||
25
modules/EcmProducts/javascript/autoIndeks.js
Executable file
25
modules/EcmProducts/javascript/autoIndeks.js
Executable file
@@ -0,0 +1,25 @@
|
||||
var startCode;
|
||||
|
||||
$(document).ready(function () {
|
||||
startCode = $('#code').val();
|
||||
if ($('#code').val() == '') {
|
||||
$('#code').val(genereteCode());
|
||||
}
|
||||
});
|
||||
|
||||
function genereteCode() {
|
||||
var code;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmProducts&action=indeksIncrement&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "generateCode",
|
||||
},
|
||||
success: function (data) {
|
||||
code = data;
|
||||
}
|
||||
});
|
||||
return code;
|
||||
}
|
||||
90
modules/EcmProducts/javascript/formloader.js
Executable file
90
modules/EcmProducts/javascript/formloader.js
Executable file
@@ -0,0 +1,90 @@
|
||||
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 changeValidateRequired(formname, name, required) {
|
||||
for (var i = 0; i < validate[formname].length; i++)
|
||||
if (validate[formname][i][0] == name) {
|
||||
validate[formname][i][2] = required;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function my_popup(module, field_array, call_back_function, form_name) {
|
||||
if (!call_back_function) call_back_function = "set_return";
|
||||
if (!form_name) form_name = "EditView";
|
||||
return open_popup(module, 900, 700, "", true, false, {
|
||||
"call_back_function": call_back_function,
|
||||
"form_name": form_name,
|
||||
"field_to_name_array": field_array
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function FormLoader() {
|
||||
this.module;
|
||||
this.createModule;
|
||||
this.fieldName;
|
||||
this.buttonName = 'FormLoaderButton';
|
||||
this.load = function(module, createModule, fieldName) {
|
||||
this.module = module;
|
||||
this.createModule = createModule;
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
this.createButton = function() {
|
||||
var b = document.createElement('input');
|
||||
b.type = 'button';
|
||||
b.className = 'button';
|
||||
b.name = this.buttonName;
|
||||
b.value = 'Create';
|
||||
b.FL = this;
|
||||
b.onclick = function() {
|
||||
if (this.FL.createModule == '') return;
|
||||
if (this.FL.onButtonClick) var data = this.FL.onButtonClick();
|
||||
window.open("index.php?module=" + this.FL.module + "&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName=" + this.FL.fieldName + "&createModule=" + this.FL.createModule + (data ? data : ''), "Create10" + this.FL.module, "resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
this.setEditDblClick = function(edit) {
|
||||
edit.FL = this;
|
||||
edit.ondblclick = this.editDblClick;
|
||||
}
|
||||
this.editDblClick = function() {
|
||||
if (this.FL.createModule == '') return;
|
||||
if (this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
|
||||
window.open("index.php?module=" + this.FL.module + "&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName=" + this.FL.fieldName + "&createModule=" + this.FL.createModule + (data ? data : ''), "Create10" + this.FL.module, "resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
}
|
||||
this.responseData = function(data) {
|
||||
if (this.onResponseData) this.onResponseData(data);
|
||||
}
|
||||
this.onResponseData;
|
||||
this.addPostData = function() {
|
||||
if (this.onAddPostData)
|
||||
return this.onAddPostData();
|
||||
else
|
||||
return '';
|
||||
}
|
||||
this.onAddPostData;
|
||||
this.onButtonClick;
|
||||
}
|
||||
Reference in New Issue
Block a user