function renderItembtns(data, row) { var jsonData = JSON.stringify(row).replace(/"/g, """); var buttonsHtml = ''; // var statusNumber = parseInt(row.status, 10); buttonsHtml += ' '; return buttonsHtml; } function holdItem(isApprove) { $('#addRemarksUpdate').modal('show'); $('#addRemarksUpdate').css('z-index', 1060); // Ensure the event listener is added only once if (!confirmUpdateListener) { document.getElementById('btnAddRemarks').addEventListener('click', function () { var Remarks = document.getElementById('remarks').value; if (isApprove === 3 && !Remarks) { alert('Please put remarks!'); return; } // Show a confirmation dialog const confirmation = confirm('Are you sure you want to proceed?'); if (confirmation) { // If all validation is passed then proceed to confirmation to backend // confirmPRApproveReject(isApprove, Remarks); var loader = $('#overlay, #loader').css('z-index', 1060); var ItemNo = document.getElementById("itemNo").value; var Status = isApprove; $.ajax({ url: '/PRMgmt/PostPRApproveReject', type: 'POST', data: { ItemNo: ItemNo, Status: Status, PRDetailsId: PRDetailsId, Remarks: Remarks }, // Pass requestData array to the backend success: function (response) { if (response.success) { prTable.ajax.reload(); prDataTable.ajax.reload(); $('#viewPRItemDetails').modal('hide'); $('#addRemarksUpdate').modal('hide'); if (isApprove == 1) { alert('Item Hold!'); } } else { itemTable.ajax.reload(); alert('Failed: ' + response.response); } }, beforeSend: function () { // Show the loader before making the AJAX request loader.show(); }, complete: function () { // Hide the loader after the AJAX request is complete (success or error) loader.hide(); } }); } }); // Set the flag to true to indicate that the listener is attached confirmUpdateListener = true; } } function postPutLotBin(isSave) { var loader = $('#overlay, #loader').css('z-index', 1060); const lotIdInput = document.getElementById('lotId'); const lotNameInput = document.getElementById('lotNo'); const LotId = lotIdInput.value; const LotNo = lotNameInput.value; if (!LotId || LotId==0) { alert('Please fill the required fields !'); if (!LotId || LotId == 0) { lotNameInput.classList.add('error-input'); } return; } const confirmation = confirm('Are you sure you want to proceed?'); if (confirmation) { $.ajax({ url: '/InventoryMgmt/PostPutLotBin', type: 'POST', data: { InventoryId, LotId }, success: function (response) { if (response.success) { inventTable.ajax.reload(); $('#viewItemDetails').modal('hide'); if (isSave == 1) { alert('Lot Save Successfully'); } else { alert('Lot Updated Successfully'); } } else { itemTable.ajax.reload(); alert('Failed: ' + response.response); } }, beforeSend: function () { // Show the loader before making the AJAX request loader.show(); }, complete: function () { // Hide the loader after the AJAX request is complete (success or error) loader.hide(); } }); } } function populateLotNo() { $.ajax({ url: "/InventoryMgmt/GetLotNo", success: function (response) { if (response.success && Array.isArray(response.data)) { var lots = response.data; $('#lotNo').empty(); // Add the default option $('#lotNo').append($('