This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,157 @@
$(document).ready(function() {
setTime();
var tmp = getProductList($('[name="record"]').val());
InitializeEcmProducts(tmp);
});
function setTime() {
var time = $("#mojtime").html();
var hours = 0;
var minutes = 0;
var seconds = 0;
time = parseInt(time);
minutes = Math.floor(time / 60);
hours = Math.floor(minutes / 60);
seconds = time - (minutes * 60);
minutes = minutes - (hours * 60);
if(hours<10){
hours = "0"+hours;
}
if(minutes<10){
minutes = "0"+minutes;
}
if(seconds<10){
seconds = "0"+seconds;
}
$("#mojtime").html("" + hours +"."+ minutes +":"+ seconds);
}
function getProductList(request) {
var tmp = null;
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=dbpost&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "getProductList",
id: request,
},
success: function (data) {
tmp = data;
}
});
return tmp;
}
function InitializeEcmProducts(tmp) {
$('#tableEcmProducts').appendGrid({
hideRowNumColumn: false,
initData: tmp,
initRows: 0,
columns: [
{
name: 'code',
display: 'Indeks',
type: 'custom',
ctrlClass: 'inputs',
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',
},
value: ['', '', ''],
customBuilder: function (parent, idPrefix, name, uniqueIndex) {
// Prepare the control ID/name by using idPrefix, column name and uniqueIndex
var ctrlId = idPrefix + '_' + name + '_span_' + uniqueIndex;
var ctrl = document.createElement('span');
$(ctrl).attr({ id: ctrlId, name: ctrlId }).appendTo(parent);
return ctrl;
},
customGetter: function (idPrefix, name, uniqueIndex) {
return '0';
},
customSetter: function (idPrefix, name, uniqueIndex, value) {
var spanId = idPrefix + '_' + name + '_span_' + uniqueIndex;
var spanUrl = document.createElement('a');
spanUrl.href = 'index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value['id'];
spanUrl.onclick = function (){
window.open('index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value['id'],'1426150651552','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0');
return false;
};
spanUrl.title = value['code'];
spanUrl.textContent = value['code'];
$('#' + spanId).html(spanUrl);
}
},{
name: 'name',
display: 'Nazwa',
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 + '_span_' + uniqueIndex;
var ctrl = document.createElement('span');
$(ctrl).attr({ id: ctrlId, name: ctrlId }).appendTo(parent);
return ctrl;
},
customGetter: function (idPrefix, name, uniqueIndex) {
return '0';
},
customSetter: function (idPrefix, name, uniqueIndex, value) {
var spanId = idPrefix + '_' + name + '_span_' + uniqueIndex;
var spanUrl = document.createElement('a');
spanUrl.href = 'index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value['id'];
spanUrl.onclick = function (){
window.open('index.php?module=EcmProducts&return_module=EcmProducts&action=DetailView&record=' + value['id'],'1426150651552','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0');
return false;
};
spanUrl.display = true;
if (typeof value['name'] === "undefined") {
spanUrl.textContent = '';
}else{
spanUrl.textContent = value['name'].replace('&quot;','"');
}
spanUrl.title = value['name'];
$('#' + spanId).html(spanUrl);
}
},
],
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');
}

View File

@@ -0,0 +1,375 @@
var startCat;
var startIndex;
var cost_netto = 764;
var cost_netto_s = cost_netto/3600; // koszt netto / 1h = koszt na sekunde
$(document).ready(function () {
initializeTime();
if($('#cost_hour').val()==''){
$('#cost_hour').val("15,20");
}
//$('#cost_hour').attr('disabled','disabled');
startCat = $('#category').find(":selected").val();
startIndex = $('#indeks').val();
if ($('#indeks').val() == '') {
categoryChange();
}
$("#cost_action").change(function () {
cost_actionChange();
});
$("#cost_hour").change(function () {
cost_hourChange();
});
$('#category').change(function () {
categoryChange();
});
$('#indeks').change(function () {
indeksChange();
});
$('#cost_other').change(function () {
cost_otherChange();
});
$("#EditView").submit(function (event) {
indeksChek();
});
});
function initializeTime() {
var time = parseInt($("#time").val());
if (isNaN(time)) {
time = 0;
$("#time").val(0);
}
var hours = 0;
var minutes = 0;
var seconds = 0;
minutes = Math.floor(time / 60);
hours = Math.floor(minutes / 60);
seconds = time - (minutes * 60);
minutes = minutes - (hours * 60);
$("#seconds").val(seconds);
$("#minutes").val(minutes);
$("#hours").val(hours);
}
function secondsChange() {
var tmp = parseInt($("#seconds").val());
if (isNaN(tmp)) {
tmp = 0;
}
if (tmp < 0) {
tmp = 0;
}
if (tmp > 59) {
tmp = 59;
}
$("#seconds").val(tmp);
updateTime();
}
function minutesChange() {
var tmp = parseInt($("#minutes").val());
if (isNaN(tmp)) {
tmp = 0;
}
if (tmp < 0) {
tmp = 0;
}
if (tmp > 59) {
tmp = 59;
}
$("#minutes").val(tmp);
updateTime();
}
function hoursChange() {
var tmp = parseInt($("#hours").val());
if (isNaN(tmp)) {
tmp = 0;
}
if (tmp < 0) {
tmp = 0;
}
$("#hours").val(tmp);
updateTime();
}
function cost_actionChange() {
var tmp = parseFloat($("#cost_action").val().replace(",", "."));
if (isNaN(tmp) || tmp == 'NaN,NaN') {
tmp = 0;
}
$("#cost_action").val(FormatNumber(tmp));
var cost_hour = UnformatNumber($("#cost_hour").val());
var proporcja = tmp/cost_hour;
var cost_other = (proporcja*cost_netto/100).toFixed(2);
$("#cost_other").val(FormatNumber(cost_other));
time = Math.round(3600*proporcja);
$('#time').val(time);
initializeTime();
}
function cost_hourChange() {
var tmp = parseFloat($("#cost_hour").val().replace(",", "."));
if (isNaN(tmp) || tmp == 'NaN,NaN') {
tmp = 0;
}
$("#cost_hour").val(FormatNumber(tmp));
}
function cost_otherChange() {
var tmp = parseFloat($("#cost_other").val().replace(",", "."));
if (isNaN(tmp) || tmp == 'NaN,NaN') {
tmp = 0;
}
$("#cost_other").val(FormatNumber(tmp));
//var time = $("#time").val();
var proporcja = tmp/cost_netto;
time = Math.round(3600*proporcja*100);
$('#time').val(time);
initializeTime();
var cost_hour = UnformatNumber($("#cost_hour").val())*100;
var cost_action = (cost_hour*proporcja).toFixed(2);
$("#cost_action").val(FormatNumber(cost_action));
}
function categoryChange() {
var category = $('#category').find(":selected").val();
console.log(category);
if (startIndex == '') {
var sufix;
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=indeksIncrement&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "getIndeks",
category: category,
},
success: function (data) {
sufix = data;
}
});
var text = $('#category').find(":selected").text();
var prefix = '';
if (text.indexOf(' ') === -1) {
prefix = text.substring(0, 5).toUpperCase();
} else {
prefix = text.substring(0, 2).toUpperCase();
prefix = prefix
+ text.substring(text.indexOf(' ') + 1, text.indexOf(' ') + 4)
.toUpperCase();
}
var indeks = prefix + sufix;
$("#indeks").val(indeks);
}else{
if(category==startCat){
$("#indeks").val(startIndex);
}else{
var sufix;
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=indeksIncrement&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "getIndeks",
category: category,
},
success: function (data) {
sufix = data;
}
});
var text = $('#category').find(":selected").text();
var prefix = '';
if (text.indexOf(' ') === -1) {
prefix = text.substring(0, 5).toUpperCase();
} else {
prefix = text.substring(0, 2).toUpperCase();
prefix = prefix
+ text.substring(text.indexOf(' ') + 1, text.indexOf(' ') + 4)
.toUpperCase();
}
var indeks = prefix + sufix;
$("#indeks").val(indeks);
}
}
}
function indeksChange() {
var checkindeks = $.trim($("#indeks").val()).toUpperCase();
if (checkindeks.length > 0) {
if (checkindeks.length > 10) {
checkindeks = checkindeks.substring(0, 10);
}
$("#indeks").val(checkindeks);
var condition = false;
var category = $('#category').find(":selected").val();
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=indeksIncrement&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "checkIndeks",
indeks: checkindeks,
category: category,
},
success: function (data) {
condition = data;
}
});
if (condition) {
alert("Podany indeks dla danej kategorii już istnieje");
$("#indeks").val('');
}
} else {
alert("Indeks nie może być pusty");
}
}
function indeksChek(){
var checkindeks = $.trim($("#indeks").val()).toUpperCase();
if (checkindeks.length > 0) {
if (checkindeks.length > 10) {
checkindeks = checkindeks.substring(0, 10);
}
$("#indeks").val(checkindeks);
var condition = false;
var category = $('#category').find(":selected").val();
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=indeksIncrement&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "checkIndeks",
indeks: checkindeks,
category: category,
},
success: function (data) {
condition = data;
}
});
if (condition) {
categoryChange();
}
} else {
alert("Indeks nie może być pusty");
}
}
function updateTime() {
var hours = parseInt($("#hours").val()) * 3600;
var minutes = parseInt($("#minutes").val()) * 60;
var seconds = parseInt($("#seconds").val());
var tmp = hours + minutes + seconds;
$("#time").val(tmp);
var time = tmp;
var cost_hour = UnformatNumber($("#cost_hour").val())*100;
if (isNaN(cost_hour) || cost_hour == 'NaN,NaN') {
cost_hour = 0;
}
var cost_hour_h = parseFloat(cost_hour / 3600); //*time + cost_netto_s*time
if (isNaN(cost_hour_h)) {
cost_hour_h = 0;
}
var tmp = ((cost_hour_h*time)/100).toFixed(2);
$("#cost_action").val(FormatNumber(tmp));
var tmp2 = (((cost_netto_s*time)/100)).toFixed(2);
$("#cost_other").val(FormatNumber(tmp2));
}
function setCost_Hour() {
var tmp = $("#time").val();
var cost_action = UnformatNumber($("#cost_action").val());
console.log($("#cost_action").val());
console.log(cost_action);
console.log(tmp);
if (isNaN(cost_action) || cost_action == 'NaN,NaN') {
cost_action = 0;
}
var value = parseFloat((3600 / tmp) * cost_action);
if (isNaN(value) || value == 'Infinity') {
value = 0;
$("#cost_hour").val("Nieprawidłowa wartość czasu");
} else {
$("#cost_hour").val(FormatNumber(value));
}
}
function setCost_Action() {
var time = $("#time").val();
var cost_hour = UnformatNumber($("#cost_hour").val())*100;
if (isNaN(cost_hour) || cost_hour == 'NaN,NaN') {
cost_hour = 0;
}
var cost_hour_h = parseFloat(cost_hour / 3600); //*time + cost_netto_s*time
if (isNaN(cost_hour_h)) {
cost_hour_h = 0;
}
var tmp = ((cost_hour_h*time)/100).toFixed(2);
$("#cost_action").val(FormatNumber(tmp));
}
function setCost_Other() {
var time = $("#time").val();
var cost_other = UnformatNumber($("#cost_other").val())*100;
var tmp2 = (((cost_netto_s*time)/100)).toFixed(2);
$("#cost_other").val(FormatNumber(tmp2));
}
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 UnformatNumber(number) {
// make string..
number = number + '';
// remove 1000 sep
number = number.replace(/\./g, '');
// change ',' to '.'
number = number.replace(',', '.');
return parseFloat(number);
}
// round with precision
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;
}