Add functionality to order insufficient supplies for plan templates.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD
2024-11-02 19:13:02 -06:00
parent feaf631b47
commit 0b9ca77281
8 changed files with 115 additions and 9 deletions

View File

@@ -150,6 +150,9 @@ function usePlannerRecordTemplate(planRecordTemplateId) {
saveScrollPosition();
getVehiclePlanRecords(vehicleId);
} else {
if (data.message == "Insufficient Supplies") {
data.message += `<br /><br /><a class='text-link' style='cursor:pointer;' onclick='orderPlanSupplies(${planRecordTemplateId}, true)'>Order Required Supplies</a>`
}
errorToast(data.message);
}
});
@@ -325,4 +328,24 @@ function updatePlanRecordProgress(newProgress) {
draggedId = 0;
}
}
}
function orderPlanSupplies(planRecordTemplateId, closeSwal) {
if (closeSwal) {
Swal.close();
}
$.get(`/Vehicle/OrderPlanSupplies?planRecordTemplateId=${planRecordTemplateId}`, function (data) {
if (data.success != undefined && !data.success) {
//success is provided.
errorToast(data.message);
} else {
//hide plan record template modal.
hidePlanRecordTemplatesModal();
$("#planRecordTemplateSupplyOrderModalContent").html(data);
$("#planRecordTemplateSupplyOrderModal").modal('show');
}
})
}
function hideOrderSupplyModal() {
$("#planRecordTemplateSupplyOrderModal").modal('hide');
showPlanRecordTemplatesModal();
}