|
|
|
@ -418,34 +418,32 @@ $(document).ready(function () {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function submitRaMaterial(formData, id) { |
|
|
|
|
let qty_actual = $("#volume_pekerjaan_material").val(); |
|
|
|
|
try { |
|
|
|
|
const qty_actual = $("#volume_pekerjaan_material").val(); |
|
|
|
|
formData.set('qty', qty_actual); |
|
|
|
|
const result = await axiosInstance |
|
|
|
|
.post(`${base_url}report-activity-material/add`, formData) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
.post(`${base_url}report-activity-material/add`, formData); |
|
|
|
|
|
|
|
|
|
// console.log("cek result", result);
|
|
|
|
|
let reportId = result.data.data.report_id; |
|
|
|
|
let imageFormData = new FormData(); |
|
|
|
|
let image = formData.get("files"); |
|
|
|
|
imageFormData.append("ref_id",reportId); |
|
|
|
|
const reportId = result.data.data.report_id; |
|
|
|
|
const image = formData.get("files"); |
|
|
|
|
const imageFormData = new FormData(); |
|
|
|
|
imageFormData.append("ref_id", reportId); |
|
|
|
|
imageFormData.append("category", "report_activity"); |
|
|
|
|
imageFormData.append("files", image, image.name); |
|
|
|
|
|
|
|
|
|
const resultImage = await axiosInstanceMultipart |
|
|
|
|
.post(`${base_url}image/upload`, imageFormData) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
const resultImage = await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData); |
|
|
|
|
|
|
|
|
|
if (result && result.status == 200 && resultImage && resultImage.status == 200) { |
|
|
|
|
if (result.status === 200 && resultImage.status === 200) { |
|
|
|
|
gantt.alert("Add report activity material Success!"); |
|
|
|
|
resetFormAddRaMaterial(); |
|
|
|
|
tableRaMaterialActual.draw(); |
|
|
|
|
} else { |
|
|
|
|
throw new Error("Add report activity material failed."); |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
resetFormAddRaMaterial(); |
|
|
|
|
$("body").removeClass("loading"); |
|
|
|
|
gantt.alert("Add report activity material failed, try again later!"); |
|
|
|
|
gantt.alert("Add report activity material failed."); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|