Production changes
This commit is contained in:
@@ -96,7 +96,7 @@ $(document).ready(function () {
|
||||
$("#duplicateBtn").click(() => duplicatePositions());
|
||||
$("#deleteBtn").click(() => { removePositions(); });
|
||||
$("#excelBtn").click(() => { exportExcel(); });
|
||||
$("#pdfBtn").click(() => { window.alert("In progress."); });
|
||||
$("#pdfBtn").click(() => { exportPDF(); });
|
||||
$("#productionBtn").click(() => { window.alert("In progress."); });
|
||||
$("#createInsideOrder").click(createInsideOrder);
|
||||
|
||||
@@ -169,7 +169,12 @@ function drawRawMaterials(data) {
|
||||
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>");
|
||||
var code = "<td";
|
||||
if (el.isComponent) {
|
||||
code += " style='font-weight: bold;' ";
|
||||
}
|
||||
code += "><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.id + "\">" + el.code + "</a></td>";
|
||||
tr.append(code);
|
||||
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>");
|
||||
@@ -201,6 +206,7 @@ function drawRawMaterials(data) {
|
||||
$(".rawMaterialCheck").prop('checked', false);
|
||||
}
|
||||
});
|
||||
updateRawMaterialsPositions();
|
||||
}
|
||||
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>';
|
||||
@@ -323,13 +329,44 @@ function hideLoader() {
|
||||
$.unblockUI();
|
||||
}
|
||||
function exportExcel() {
|
||||
var ids = [];
|
||||
$("input.allCheck:checkbox:checked").each(function () {
|
||||
ids.push($(this).val());
|
||||
});
|
||||
if (ids.length === 0) {
|
||||
$("input.allCheck:checkbox").each(function () {
|
||||
ids.push($(this).val());
|
||||
});
|
||||
}
|
||||
showLoader("Generowanie pliku...");
|
||||
$.ajax({
|
||||
method: "get",
|
||||
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportExcel",
|
||||
success: function (data)
|
||||
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportExcel&ids=" + ids.join("|"),
|
||||
success: function (response)
|
||||
{
|
||||
window.console.log(data);
|
||||
downloadFile(response.fileContent, response.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
hideLoader();
|
||||
},
|
||||
});
|
||||
}
|
||||
function exportPDF() {
|
||||
var ids = [];
|
||||
$("input.allCheck:checkbox:checked").each(function () {
|
||||
ids.push($(this).val());
|
||||
});
|
||||
if (ids.length === 0) {
|
||||
$("input.allCheck:checkbox").each(function () {
|
||||
ids.push($(this).val());
|
||||
});
|
||||
}
|
||||
showLoader("Generowanie pliku...");
|
||||
$.ajax({
|
||||
method: "get",
|
||||
url: $(location).attr("href") + "&to_pdf=1&ajaxAction=exportPDF&ids=" + ids.join("|"),
|
||||
success: function (response)
|
||||
{
|
||||
downloadFile(response.fileContent, response.fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
hideLoader();
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -350,4 +387,39 @@ function createInsideOrder() {
|
||||
});
|
||||
$("#insideOrderProducts").val(products.join('*'));
|
||||
$("#createInsideOrderForm").submit();
|
||||
}
|
||||
}
|
||||
|
||||
function downloadFile(base64Data, fileName, mimeType) {
|
||||
// Stwórz blob z danych base64
|
||||
const byteCharacters = atob(base64Data);
|
||||
const byteArrays = [];
|
||||
|
||||
for (let offset = 0; offset < byteCharacters.length; offset += 512) {
|
||||
const slice = byteCharacters.slice(offset, offset + 512);
|
||||
|
||||
const byteNumbers = new Array(slice.length);
|
||||
for (let i = 0; i < slice.length; i++) {
|
||||
byteNumbers[i] = slice.charCodeAt(i);
|
||||
}
|
||||
|
||||
const byteArray = new Uint8Array(byteNumbers);
|
||||
byteArrays.push(byteArray);
|
||||
}
|
||||
|
||||
const blob = new Blob(byteArrays, {type: mimeType});
|
||||
|
||||
// Stwórz link do pobrania
|
||||
const link = document.createElement('a');
|
||||
link.href = window.URL.createObjectURL(blob);
|
||||
link.download = fileName;
|
||||
|
||||
// Dodaj link do dokumentu i kliknij go
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
// Usuń link z dokumentu
|
||||
setTimeout(function() {
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(link.href);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user