update
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
var SelectedTab = "";
|
||||
var TabsMainBlock = false;
|
||||
var Components;
|
||||
$(document).ready(function () {
|
||||
$.tablesorter.addParser({
|
||||
id: "production_date",
|
||||
@@ -85,14 +86,134 @@ $(document).ready(function () {
|
||||
} catch (e) { }
|
||||
}
|
||||
}, 500);
|
||||
$("#selectAll").click(function () {
|
||||
if (this.checked) {
|
||||
$(".allCheck").prop("checked", true);
|
||||
} else {
|
||||
$(".allCheck").prop("checked", false);
|
||||
}
|
||||
});
|
||||
$("#duplicateBtn").click(() => duplicatePositions());
|
||||
$("#deleteBtn").click(() => { removePositions(); });
|
||||
$("#excelBtn").click(() => { exportExcel(); });
|
||||
$("#pdfBtn").click(() => { window.alert("In progress."); });
|
||||
$("#productionBtn").click(() => { window.alert("In progress."); });
|
||||
$("#createInsideOrder").click(createInsideOrder);
|
||||
});
|
||||
|
||||
});
|
||||
function SetTab(tab_name) {
|
||||
if (TabsMainBlock) { return; }
|
||||
var TabMenu = document.getElementById("groupTabsPanels");
|
||||
var tabs = TabMenu.getElementsByTagName("li");
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
if ((tab_name + "_menu") === tabs[i].id) {
|
||||
tabs[i].className = "active";
|
||||
tabs[i].getElementsByTagName("a")[0].className = "current";
|
||||
} else {
|
||||
tabs[i].className = "";
|
||||
tabs[i].getElementsByTagName("a")[0].className = "";
|
||||
}
|
||||
}
|
||||
var prev = document.getElementById(SelectedTab);
|
||||
var curr = document.getElementById(tab_name);
|
||||
prev.style.display = "none";
|
||||
curr.style.display = "";
|
||||
SelectedTab = tab_name;
|
||||
if (SelectedTab === "3") {
|
||||
|
||||
}
|
||||
if (SelectedTab === "2") {
|
||||
getRawMaterials();
|
||||
}
|
||||
if (SelectedTab === "1") {
|
||||
}
|
||||
}
|
||||
function getRawMaterials() {
|
||||
var ids = [];
|
||||
$("input.allCheck:checkbox:checked").each(function () {
|
||||
// check if this element is visible on site
|
||||
if ($(this).parent().parent().css("display") === "table-row") {
|
||||
ids.push($(this).val());
|
||||
}
|
||||
});
|
||||
if (ids.length === 0) {
|
||||
window.alert("Wybierz pozycje zamówień");
|
||||
SetTab("1");
|
||||
return;
|
||||
}
|
||||
showLoader();
|
||||
var url = $(location).attr("href") + "&to_pdf=1&ajaxAction=getRawMaterials";
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: url,
|
||||
data: {
|
||||
ids
|
||||
},
|
||||
success: function (data) {
|
||||
var result = JSON.parse(data);
|
||||
Components = result;
|
||||
drawRawMaterials(result);
|
||||
//drawComponents(result);
|
||||
//updateComponentsPositions();
|
||||
hideLoader();
|
||||
},
|
||||
error: function () {
|
||||
window.alert("Błąd ładowania surowców");
|
||||
hideLoader();
|
||||
}
|
||||
});
|
||||
}
|
||||
function drawRawMaterials(data) {
|
||||
$("#rawMaterialsTableContainer").html(rawMaterialsTablePrototype());
|
||||
data.forEach((el, index) => {
|
||||
var tr = $("<tr></tr>");
|
||||
tr.append("<td><input type=\"checkbox\" value=" + el.id + " class=\"rawMaterialCheck\" /></td>");
|
||||
tr.append("<td>" + (index + 1) + "</td>");
|
||||
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.id + "\">" + el.code + "</a></td>");
|
||||
tr.append("<td title=\""+ el.fullName +"\">" + el.name + "</td>");
|
||||
tr.append("<td id=\"qty-" + el.id + "\">" + el.quantity + "</td>");
|
||||
tr.append("<td>" + el.unit + "</td>");
|
||||
tr.append("<td id=\"state-" + el.id + "\">" + el.stockState + "</td>");
|
||||
tr.append("<td id=\"ordered-" + el.id + "\">" + el.stockAddress + "</td>");
|
||||
$("#rawMaterialsTable > tbody").append(tr);
|
||||
});
|
||||
|
||||
$("#rawMaterialsTable").tablesorter({
|
||||
theme: "blue",
|
||||
widthFixed: true,
|
||||
widgets: ["filter", "stickyHeaders"],
|
||||
sortList: [[2, 0]],
|
||||
});
|
||||
$("#rawMaterialsTable").bind("filterEnd", function (event, config) {
|
||||
updateRawMaterialsPositions();
|
||||
});
|
||||
$("#rawMaterialsTable").bind("sortEnd", function (event, config) {
|
||||
updateRawMaterialsPositions();
|
||||
$("#rawMaterialsTable tfoot").find("td").each(function () {
|
||||
$(this).css("background-color", "white");
|
||||
});
|
||||
});
|
||||
$("#selectAllRawMaterials").attr('checked', false);
|
||||
$("#selectAllRawMaterials").click(function () {
|
||||
if (this.checked) {
|
||||
$(".rawMaterialCheck").prop('checked', true);
|
||||
} else {
|
||||
$(".rawMaterialCheck").prop('checked', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
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>';
|
||||
}
|
||||
function updateRawMaterialsPositions() {
|
||||
var i = 0;
|
||||
$("#rawMaterialsTable").find("tr").each(function (index) {
|
||||
if (index >= 2 && $(this).css('display') === 'table-row' && $(this).find("td").length > 3) {
|
||||
i++;
|
||||
$($(this).find("td")[1]).html(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
function editQty(id) {
|
||||
$("#edit-" + id).css("display", "none");
|
||||
$("#qty-" + id).css("display", "none");
|
||||
@@ -212,7 +333,6 @@ function exportExcel() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function createInsideOrder() {
|
||||
var ids = [];
|
||||
$('input.allCheck:checkbox:checked').each(function () {
|
||||
|
||||
Reference in New Issue
Block a user