production: update sorting
This commit is contained in:
@@ -8,7 +8,10 @@ $(document).ready(function () {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
format: function (s, table, cell) {
|
format: function (s, table, cell) {
|
||||||
return $(cell).find("input[id^=production-date]").val() + " " + $(cell).find("input[id^=production-time]").val() || "2222-01-01";
|
if ($(cell).find("input[id^=production-date]").val() === '') {
|
||||||
|
return "2222-01-01";
|
||||||
|
}
|
||||||
|
return $(cell).find("input[id^=production-date]").val() + " " + $(cell).find("input[id^=production-time]").val();
|
||||||
},
|
},
|
||||||
parsed: false,
|
parsed: false,
|
||||||
type: "text"
|
type: "text"
|
||||||
@@ -73,7 +76,8 @@ $(document).ready(function () {
|
|||||||
try {
|
try {
|
||||||
localStorage.setItem('productionSchedule_sort',
|
localStorage.setItem('productionSchedule_sort',
|
||||||
$("#allTable")[0].config.sortList[0][0] + "|" + $("#allTable")[0].config.sortList[0][1]);
|
$("#allTable")[0].config.sortList[0][0] + "|" + $("#allTable")[0].config.sortList[0][1]);
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
}
|
||||||
updateTimeSummary();
|
updateTimeSummary();
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -87,7 +91,8 @@ $(document).ready(function () {
|
|||||||
var tmp = sort.split("|");
|
var tmp = sort.split("|");
|
||||||
$("#allTable")[0].config.sortList = [[parseInt(tmp[0]), parseInt(tmp[1])]];
|
$("#allTable")[0].config.sortList = [[parseInt(tmp[0]), parseInt(tmp[1])]];
|
||||||
$.tablesorter.sortOn($("#allTable")[0].config, [[parseInt(tmp[0]), parseInt(tmp[1])]]);
|
$.tablesorter.sortOn($("#allTable")[0].config, [[parseInt(tmp[0]), parseInt(tmp[1])]]);
|
||||||
} catch (e) { }
|
} catch (e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
$("#selectAll").click(function () {
|
$("#selectAll").click(function () {
|
||||||
@@ -103,20 +108,35 @@ $(document).ready(function () {
|
|||||||
updateTimeSummary();
|
updateTimeSummary();
|
||||||
});
|
});
|
||||||
$("#duplicateBtn").click(() => duplicatePositions());
|
$("#duplicateBtn").click(() => duplicatePositions());
|
||||||
$("#deleteBtn").click(() => { removePositions(); });
|
$("#deleteBtn").click(() => {
|
||||||
$("#excelBtn").click(() => { exportExcel(); });
|
removePositions();
|
||||||
$("#pdfBtn").click(() => { exportPDF(); });
|
});
|
||||||
$("#changeDateBtn").click(() => { changeDate(); });
|
$("#excelBtn").click(() => {
|
||||||
$("#rawMaterialsExcelBtn").click(() => { exportRawMaterialsExcel(); });
|
exportExcel();
|
||||||
$("#productionBtn").click(() => { window.alert("In progress."); });
|
});
|
||||||
|
$("#pdfBtn").click(() => {
|
||||||
|
exportPDF();
|
||||||
|
});
|
||||||
|
$("#changeDateBtn").click(() => {
|
||||||
|
changeDate();
|
||||||
|
});
|
||||||
|
$("#rawMaterialsExcelBtn").click(() => {
|
||||||
|
exportRawMaterialsExcel();
|
||||||
|
});
|
||||||
|
$("#productionBtn").click(() => {
|
||||||
|
window.alert("In progress.");
|
||||||
|
});
|
||||||
$("#createInsideOrder").click(createInsideOrder);
|
$("#createInsideOrder").click(createInsideOrder);
|
||||||
$(document).on('change', '.allCheck', function () {
|
$(document).on('change', '.allCheck', function () {
|
||||||
updateTimeSummary();
|
updateTimeSummary();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function SetTab(tab_name) {
|
function SetTab(tab_name) {
|
||||||
if (TabsMainBlock) { return; }
|
if (TabsMainBlock) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var TabMenu = document.getElementById("groupTabsPanels");
|
var TabMenu = document.getElementById("groupTabsPanels");
|
||||||
var tabs = TabMenu.getElementsByTagName("li");
|
var tabs = TabMenu.getElementsByTagName("li");
|
||||||
for (var i = 0; i < tabs.length; i++) {
|
for (var i = 0; i < tabs.length; i++) {
|
||||||
@@ -142,6 +162,7 @@ function SetTab(tab_name) {
|
|||||||
if (SelectedTab === "1") {
|
if (SelectedTab === "1") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRawMaterials() {
|
function getRawMaterials() {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
$("input.allCheck:checkbox:checked").each(function () {
|
$("input.allCheck:checkbox:checked").each(function () {
|
||||||
@@ -177,6 +198,7 @@ function getRawMaterials() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawRawMaterials(data) {
|
function drawRawMaterials(data) {
|
||||||
$("#rawMaterialsTableContainer").html(rawMaterialsTablePrototype());
|
$("#rawMaterialsTableContainer").html(rawMaterialsTablePrototype());
|
||||||
// TODO: tutraj czasami się wiesza
|
// TODO: tutraj czasami się wiesza
|
||||||
@@ -229,9 +251,11 @@ function drawRawMaterials(data) {
|
|||||||
});
|
});
|
||||||
updateRawMaterialsPositions();
|
updateRawMaterialsPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
function rawMaterialsTablePrototype() {
|
function rawMaterialsTablePrototype() {
|
||||||
return '<table id="rawMaterialsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllRawMaterials" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Adres magazynowy</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody></table>';
|
return '<table id="rawMaterialsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllRawMaterials" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Adres magazynowy</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody></table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRawMaterialsPositions() {
|
function updateRawMaterialsPositions() {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
$("#rawMaterialsTable").find("tr").each(function (index) {
|
$("#rawMaterialsTable").find("tr").each(function (index) {
|
||||||
@@ -241,6 +265,7 @@ function updateRawMaterialsPositions() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function editQty(id) {
|
function editQty(id) {
|
||||||
$("#edit-" + id).css("display", "none");
|
$("#edit-" + id).css("display", "none");
|
||||||
$("#qty-" + id).css("display", "none");
|
$("#qty-" + id).css("display", "none");
|
||||||
@@ -248,6 +273,7 @@ function editQty(id) {
|
|||||||
$("#qtyInput-" + id).select();
|
$("#qtyInput-" + id).select();
|
||||||
$("#save-" + id).css("display", "inline-block");
|
$("#save-" + id).css("display", "inline-block");
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveQty(id) {
|
function saveQty(id) {
|
||||||
showLoader("Trwa aktualizacja...");
|
showLoader("Trwa aktualizacja...");
|
||||||
$("#edit-" + id).css("display", "inline-block");
|
$("#edit-" + id).css("display", "inline-block");
|
||||||
@@ -263,6 +289,7 @@ function saveQty(id) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function duplicatePositions() {
|
function duplicatePositions() {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
$("input.allCheck:checkbox:checked").each(function () {
|
$("input.allCheck:checkbox:checked").each(function () {
|
||||||
@@ -273,7 +300,9 @@ function duplicatePositions() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var userResponse = window.confirm("Zduplikować pozycje?");
|
var userResponse = window.confirm("Zduplikować pozycje?");
|
||||||
if (!userResponse) { return; }
|
if (!userResponse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
showLoader("Duplikowanie...");
|
showLoader("Duplikowanie...");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "get",
|
method: "get",
|
||||||
@@ -283,6 +312,7 @@ function duplicatePositions() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removePositions() {
|
function removePositions() {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
$("input.allCheck:checkbox:checked").each(function () {
|
$("input.allCheck:checkbox:checked").each(function () {
|
||||||
@@ -293,17 +323,19 @@ function removePositions() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var userResponse = window.confirm("Usunąć pozycje?");
|
var userResponse = window.confirm("Usunąć pozycje?");
|
||||||
if (!userResponse) { return; }
|
if (!userResponse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
showLoader("Usuwanie...");
|
showLoader("Usuwanie...");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=removePositions&ids=" + ids.join("|"),
|
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=removePositions&ids=" + ids.join("|"),
|
||||||
success: function ()
|
success: function () {
|
||||||
{
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveProductionDate(id) {
|
function saveProductionDate(id) {
|
||||||
let date = $("#production-date-" + id).val();
|
let date = $("#production-date-" + id).val();
|
||||||
let time = $("#production-time-" + id).val();
|
let time = $("#production-time-" + id).val();
|
||||||
@@ -352,6 +384,7 @@ function saveProductionDate(id) {
|
|||||||
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + encodeURIComponent(date) + "&time=" + encodeURIComponent(time),
|
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=saveProductionDate&id=" + id + "&date=" + encodeURIComponent(date) + "&time=" + encodeURIComponent(time),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function editDescription(id) {
|
function editDescription(id) {
|
||||||
$("#edit-description-" + id).css("display", "none");
|
$("#edit-description-" + id).css("display", "none");
|
||||||
$("#description-" + id).css("display", "none");
|
$("#description-" + id).css("display", "none");
|
||||||
@@ -359,6 +392,7 @@ function editDescription(id) {
|
|||||||
$("#descriptionInput-" + id).select();
|
$("#descriptionInput-" + id).select();
|
||||||
$("#save-description-" + id).css("display", "inline-block");
|
$("#save-description-" + id).css("display", "inline-block");
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveDescription(id) {
|
function saveDescription(id) {
|
||||||
$("#edit-description-" + id).css("display", "inline-block");
|
$("#edit-description-" + id).css("display", "inline-block");
|
||||||
$("#description-" + id).css("display", "inline");
|
$("#description-" + id).css("display", "inline");
|
||||||
@@ -372,6 +406,7 @@ function saveDescription(id) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showLoader(msg = "Pobieranie danych") {
|
function showLoader(msg = "Pobieranie danych") {
|
||||||
$.blockUI({
|
$.blockUI({
|
||||||
css: {
|
css: {
|
||||||
@@ -388,9 +423,11 @@ function showLoader(msg = "Pobieranie danych") {
|
|||||||
message: msg
|
message: msg
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideLoader() {
|
function hideLoader() {
|
||||||
$.unblockUI();
|
$.unblockUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportExcel() {
|
function exportExcel() {
|
||||||
// Check if any rows are selected
|
// Check if any rows are selected
|
||||||
var checkedRows = $("input.allCheck:checkbox:checked").closest('tr:visible');
|
var checkedRows = $("input.allCheck:checkbox:checked").closest('tr:visible');
|
||||||
@@ -462,6 +499,7 @@ function exportExcel() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportPDF() {
|
function exportPDF() {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
$("input.allCheck:checkbox:checked").each(function () {
|
$("input.allCheck:checkbox:checked").each(function () {
|
||||||
@@ -476,13 +514,13 @@ function exportPDF() {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportPDF&ids=" + ids.join("|"),
|
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportPDF&ids=" + ids.join("|"),
|
||||||
success: function (response)
|
success: function (response) {
|
||||||
{
|
|
||||||
downloadFile(response.fileContent, response.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
downloadFile(response.fileContent, response.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||||
hideLoader();
|
hideLoader();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportRawMaterialsExcel() {
|
function exportRawMaterialsExcel() {
|
||||||
// Check if raw materials table exists
|
// Check if raw materials table exists
|
||||||
if ($("#rawMaterialsTable").length === 0) {
|
if ($("#rawMaterialsTable").length === 0) {
|
||||||
@@ -558,6 +596,7 @@ function exportRawMaterialsExcel() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createInsideOrder() {
|
function createInsideOrder() {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
$('input.allCheck:checkbox:checked').each(function () {
|
$('input.allCheck:checkbox:checked').each(function () {
|
||||||
@@ -576,6 +615,7 @@ function createInsideOrder() {
|
|||||||
$("#insideOrderProducts").val(products.join('*'));
|
$("#insideOrderProducts").val(products.join('*'));
|
||||||
$("#createInsideOrderForm").submit();
|
$("#createInsideOrderForm").submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadFile(base64Data, fileName, mimeType) {
|
function downloadFile(base64Data, fileName, mimeType) {
|
||||||
// Stwórz blob z danych base64
|
// Stwórz blob z danych base64
|
||||||
const byteCharacters = atob(base64Data);
|
const byteCharacters = atob(base64Data);
|
||||||
@@ -610,6 +650,7 @@ function downloadFile(base64Data, fileName, mimeType) {
|
|||||||
window.URL.revokeObjectURL(link.href);
|
window.URL.revokeObjectURL(link.href);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTimeSummary() {
|
function updateTimeSummary() {
|
||||||
var totalMinutes = 0;
|
var totalMinutes = 0;
|
||||||
var rows;
|
var rows;
|
||||||
@@ -645,6 +686,7 @@ function updateTimeSummary() {
|
|||||||
|
|
||||||
return formattedTime;
|
return formattedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeDate() {
|
function changeDate() {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
$('input.allCheck:checkbox:checked').each(function () {
|
$('input.allCheck:checkbox:checked').each(function () {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ WHERE ps.deleted = 0 ";
|
|||||||
if ($dateFrom != null && $dateTo != null) {
|
if ($dateFrom != null && $dateTo != null) {
|
||||||
$query .= " AND (
|
$query .= " AND (
|
||||||
(DATE(ps.production_date) >= '$dateFrom' AND DATE(ps.production_date) <= '$dateTo')
|
(DATE(ps.production_date) >= '$dateFrom' AND DATE(ps.production_date) <= '$dateTo')
|
||||||
OR ps.production_date IS NULL OR DATE(ps.production_date) = '0000-00-00')";
|
OR ps.production_date IS NULL OR DATE(ps.production_date) = '0000-00-00 06:00:00')";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ids != null) {
|
if ($ids != null) {
|
||||||
@@ -115,7 +115,6 @@ WHERE ps.deleted = 0 ";
|
|||||||
|
|
||||||
$query .= "GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id ";
|
$query .= "GROUP BY ps.id, s.id, si.id, p.id, ps_main.id, p_main.id ";
|
||||||
|
|
||||||
|
|
||||||
$rows = $db->query($query);
|
$rows = $db->query($query);
|
||||||
$data = array();
|
$data = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user