Browse Source

Merge pull request 'dev-wahyun' (#8) from dev-wahyun into master

Reviewed-on: ibnu/generic-ospro-gantt#8
pull/1/head
farhantock 6 months ago
parent
commit
e16c1da205
  1. 4
      edit-mode/function/ganttConfig.js
  2. 1
      edit-mode/function/humanResource.js
  3. 32
      edit-mode/function/reportActivity.js

4
edit-mode/function/ganttConfig.js

@ -5,7 +5,9 @@ const timestamp = getUrlParameter("timestamp");
let base_url = getUrlParameter("base_url"); let base_url = getUrlParameter("base_url");
const role_name = getUrlParameter("role_name"); const role_name = getUrlParameter("role_name");
const company_id = getUrlParameter("company_id"); const company_id = getUrlParameter("company_id");
const base_url_image = "https://project-api.ospro.id/assets/image/"; const company_name = getUrlParameter("company_name");
const base_url_image = `https://project-api.ospro.id/assets/${company_name}/`;
// const base_url_image = `http://localhost:8444/generic-ospro-backend/assets/${company_name}/`;
const adwIntegrationUrl = "https://adw-api.ospro.id/api"; const adwIntegrationUrl = "https://adw-api.ospro.id/api";
let userToVersionGanttId = 0 let userToVersionGanttId = 0

1
edit-mode/function/humanResource.js

@ -225,6 +225,7 @@ $(document).ready(function () {
gantt.alert("Human Resource Assign Success!"); gantt.alert("Human Resource Assign Success!");
}, },
error: function (data) { error: function (data) {
$('#btn-assign-hr').html('Assign');
resetFormAssign(); resetFormAssign();
gantt.alert("Human Resource Assign Failed, try again later!"); gantt.alert("Human Resource Assign Failed, try again later!");
} }

32
edit-mode/function/reportActivity.js

@ -56,7 +56,6 @@ $(document).ready(function () {
}); });
$("#ra_select_status").on("change", function () { $("#ra_select_status").on("change", function () {
let val = $(this).val() let val = $(this).val()
console.log(val)
if (val == 'done') { if (val == 'done') {
$('#ra_date_end_activity').prop('disabled', false); $('#ra_date_end_activity').prop('disabled', false);
} else { } else {
@ -178,7 +177,6 @@ $(document).ready(function () {
d.type = 'actual'; d.type = 'actual';
}, },
"error": function (xhr, error, code) { "error": function (xhr, error, code) {
console.log(xhr, error, code);
} }
}, },
"columns": [ "columns": [
@ -397,8 +395,6 @@ $(document).ready(function () {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
// console.log("cek result", result);
if (result && result.data.code == 200) { if (result && result.data.code == 200) {
gantt.alert("Update Status report activity Success!"); gantt.alert("Update Status report activity Success!");
resetFormAddRa(); resetFormAddRa();
@ -417,8 +413,6 @@ $(document).ready(function () {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
// console.log("cek result", result);
if (result && result.status == 200) { if (result && result.status == 200) {
gantt.alert("Add report activity Success!"); gantt.alert("Add report activity Success!");
resetFormAddRa(); resetFormAddRa();
@ -435,8 +429,6 @@ $(document).ready(function () {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
// console.log("cek result", result);
if (result && result.status == 200) { if (result && result.status == 200) {
gantt.alert("Edit report activity Success!"); gantt.alert("Edit report activity Success!");
resetFormAddRa(); resetFormAddRa();
@ -464,9 +456,10 @@ $(document).ready(function () {
imageFormData.append("ref_id", reportId); imageFormData.append("ref_id", reportId);
imageFormData.append("category", "report_activity"); imageFormData.append("category", "report_activity");
imageFormData.append("files", image, image.name); imageFormData.append("files", image, image.name);
imageFormData.append("company_name",company_name);
if (image.name && image.size) { if (image.name && image.size) {
const resultImage = await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData); await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData);
} }
if (result.status === 200) { if (result.status === 200) {
@ -474,9 +467,11 @@ $(document).ready(function () {
resetFormAddRaMaterial(); resetFormAddRaMaterial();
tableRaMaterialActual.draw(); tableRaMaterialActual.draw();
} else { } else {
$('#btn_add_ra_material').html('Add');
throw new Error("Add report activity material failed."); throw new Error("Add report activity material failed.");
} }
} catch (error) { } catch (error) {
$('#btn_add_ra_material').html('Add');
throw new Error("Image upload failed."); throw new Error("Image upload failed.");
} }
} catch (error) { } catch (error) {
@ -505,14 +500,13 @@ $(document).ready(function () {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
// console.log("cek result", result);
if (result && result.status == 200) { if (result && result.status == 200) {
gantt.alert("Edit report activity Success!"); gantt.alert("Edit report activity Success!");
resetFormAddRaMaterial(); resetFormAddRaMaterial();
tableRaMaterialActual.draw(); tableRaMaterialActual.draw();
} else { } else {
resetFormAddRaMaterial(); resetFormAddRaMaterial();
$('#btn_add_ra_material').html('Add');
gantt.alert("Edit report activity failed, try again later!"); gantt.alert("Edit report activity failed, try again later!");
} }
} }
@ -533,7 +527,7 @@ $(document).ready(function () {
$("#table_activity_material_actual").on("click", ".btn-ram-delete", function () { $("#table_activity_material_actual").on("click", ".btn-ram-delete", function () {
let id = $(this).data('id'); let id = $(this).data('id');
var box = gantt.confirm({ gantt.confirm({
text: "Report activity material will be deleted from activity material, continue?", text: "Report activity material will be deleted from activity material, continue?",
ok: "Delete", ok: "Delete",
cancel: "Cancel", cancel: "Cancel",
@ -556,9 +550,8 @@ $(document).ready(function () {
gantt.alert({ type: "error", text: "Failed to get report image" }); gantt.alert({ type: "error", text: "Failed to get report image" });
return false; return false;
} }
if (data && data.image) { if (data && data.image) {
$("#report-image").html(`<img src="${base_url_image}${data.image}" class="img-responsive" style="height: 75vh;" />`); $("#report-image").html(`<img src="${base_url_image}${moment(data.created_at).format('YYYY-MM')}/image/${data.image}" class="img-responsive" style="height: 75vh;" />`);
$('#modal-report-image').modal('show'); $('#modal-report-image').modal('show');
} }
// kalo gambarnya banyak belum di handle... // kalo gambarnya banyak belum di handle...
@ -596,7 +589,6 @@ $(document).ready(function () {
if (attributeString.includes('"=""')) { if (attributeString.includes('"=""')) {
materialName = materialName + '"'; materialName = materialName + '"';
} }
// console.log(" okeee ",{ assignMaterialId, activityId, materialName });
$("#report_activity_material_title").html(`Report Activity Actual ${materialName}`) $("#report_activity_material_title").html(`Report Activity Actual ${materialName}`)
$("#modal_report_activity").hide(); $("#modal_report_activity").hide();
@ -632,7 +624,6 @@ $(document).ready(function () {
if (attributeString.includes('"=""')) { if (attributeString.includes('"=""')) {
materialName = materialName + '"'; materialName = materialName + '"';
} }
// console.log(" okeee ",{ assignMaterialId, activityId, materialName });
$("#report_activity_material_title").html(`Report Activity Plan ${materialName}`) $("#report_activity_material_title").html(`Report Activity Plan ${materialName}`)
$("#modal_report_activity").hide(); $("#modal_report_activity").hide();
// $("#show_form_ra_material").hide(); // $("#show_form_ra_material").hide();
@ -669,7 +660,7 @@ $(document).ready(function () {
function deleteRaMaterial(id) { function deleteRaMaterial(id) {
searchReport(assignMaterialId, false); searchReport(assignMaterialId, false);
$.ajax({ $.ajax({
url: `${base_url}report-activity-material/delete/${id}`, url: `${base_url}report-activity-material/delete/${id}/${company_id}`,
type: "DELETE", type: "DELETE",
success: function (data) { success: function (data) {
actionHappen = true; actionHappen = true;
@ -685,20 +676,16 @@ $(document).ready(function () {
$("#table_report").on("click", ".btn_report_edit", function () { $("#table_report").on("click", ".btn_report_edit", function () {
let id = $(this).data('id'); let id = $(this).data('id');
$("#id_ra").val(id); $("#id_ra").val(id);
// console.log("cek edit id", id);
$.ajax({ $.ajax({
url: `${base_url}report-activity/edit/${id}`, url: `${base_url}report-activity/edit/${id}`,
type: "get", type: "get",
success: function (data) { success: function (data) {
// console.log("data report-activity edit", data);
if (data && data.code == 200) { if (data && data.code == 200) {
let dataRes = data.data let dataRes = data.data
// console.log("dataRes", dataRes);
$('#btn_add_ra').html('Edit'); $('#btn_add_ra').html('Edit');
var newOption = new Option(dataRes.user_name, dataRes.user_id, true, true); var newOption = new Option(dataRes.user_name, dataRes.user_id, true, true);
$('#select_ra_hr').append(newOption).trigger('change'); $('#select_ra_hr').append(newOption).trigger('change');
let reportDate = moment(dataRes.report_date).format("YYYY-MM-DD"); let reportDate = moment(dataRes.report_date).format("YYYY-MM-DD");
// console.log("reportDate", reportDate);
$("#ra_date").val(reportDate); $("#ra_date").val(reportDate);
$("#volume_pekerjaan").val(dataRes.job_count_report); $("#volume_pekerjaan").val(dataRes.job_count_report);
$("#ra_description").val(dataRes.description); $("#ra_description").val(dataRes.description);
@ -709,9 +696,6 @@ $(document).ready(function () {
resetFormAddRa(); resetFormAddRa();
gantt.alert("Edit Report Activity Failed, try again later!"); gantt.alert("Edit Report Activity Failed, try again later!");
} }
// actionHappen = true;
// gantt.alert("Delete Report Activity Success!");
// tableRa.draw();
}, },
error: function (data) { error: function (data) {
resetFormAddRa(); resetFormAddRa();

Loading…
Cancel
Save