|
|
|
@ -425,21 +425,27 @@ $(document).ready(function () {
|
|
|
|
|
.post(`${base_url}report-activity-material/add`, formData); |
|
|
|
|
|
|
|
|
|
const reportId = result.data.data.report_id; |
|
|
|
|
try { |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
if (image.name && image.size) { |
|
|
|
|
const resultImage = await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result.status === 200 && resultImage.status === 200) { |
|
|
|
|
if (result.status === 200) { |
|
|
|
|
gantt.alert("Add report activity material Success!"); |
|
|
|
|
resetFormAddRaMaterial(); |
|
|
|
|
tableRaMaterialActual.draw(); |
|
|
|
|
} else { |
|
|
|
|
throw new Error("Add report activity material failed."); |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
throw new Error("Image upload failed."); |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
resetFormAddRaMaterial(); |
|
|
|
|
$("body").removeClass("loading"); |
|
|
|
@ -512,7 +518,7 @@ $(document).ready(function () {
|
|
|
|
|
// kalo gambarnya banyak belum di handle...
|
|
|
|
|
}, |
|
|
|
|
error: function (data) { |
|
|
|
|
gantt.alert({ type: "error", text: "Failed to get report image" }); |
|
|
|
|
gantt.alert({ type: "error", text: "Image not found !" }); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|