Compare commits

..

No commits in common. '63bf4c30de5c00aed8fed73a7bae773ace7789ab' and 'f0caa489c833663977f8226e47acf1209d7ccae0' have entirely different histories.

  1. 9
      edit-mode/function/activityLocation.js
  2. 38
      edit-mode/function/expenseResource.js
  3. 18
      edit-mode/function/function.js
  4. 5
      edit-mode/function/ganttActivityComments.js
  5. 38
      edit-mode/function/ganttActivityUploadDoc.js
  6. 17
      edit-mode/function/ganttConfig.js
  7. 25
      edit-mode/function/ganttSettings.js
  8. 2
      edit-mode/function/holiday.js
  9. 2
      edit-mode/function/humanResource.js
  10. 4
      edit-mode/function/materialResource.js
  11. 4
      edit-mode/function/milestone.js
  12. 19
      edit-mode/function/modalHumanResourceFunction.js
  13. 2
      edit-mode/function/reportActivity.js
  14. 2
      edit-mode/function/restActivityLink.js
  15. 2
      edit-mode/function/toolsResource.js
  16. 2
      edit-mode/index.html
  17. 10
      view-mode/function/activityLocation.js
  18. 8
      view-mode/function/function.js
  19. 6
      view-mode/function/ganttActivityComments.js
  20. 45
      view-mode/function/ganttActivityUploadDoc.js
  21. 1
      view-mode/function/ganttConfig.js
  22. 4
      view-mode/function/ganttEvent.js
  23. 36
      view-mode/function/ganttSettings.js
  24. 2
      view-mode/function/holiday.js
  25. 4
      view-mode/function/milestone.js
  26. 108
      view-mode/function/modalHumanResourceFunction.js
  27. 1
      view-mode/function/overlaySCurve.js
  28. 3
      view-mode/function/reportActivity.js
  29. 33
      view-mode/function/restActivityLink.js
  30. 2
      view-mode/function/toolsResource.js

9
edit-mode/function/activityLocation.js

@ -61,10 +61,12 @@ function openActivityMap(id) {
type: "get", type: "get",
success: function (data) { success: function (data) {
let dataRes = data.data let dataRes = data.data
// console.log("cek data", data);
drawnItems.clearLayers(); drawnItems.clearLayers();
if (dataRes.geom) { if (dataRes.geom) {
let datageojson = JSON.parse(dataRes.geom); let datageojson = JSON.parse(dataRes.geom);
currentGeoJson = datageojson currentGeoJson = datageojson
// console.log("cek data geojson", datageojson);
if (datageojson.type === 'FeatureCollection') { if (datageojson.type === 'FeatureCollection') {
datageojson.features.forEach(feature => { datageojson.features.forEach(feature => {
let lGeoJson = L.geoJSON(feature); let lGeoJson = L.geoJSON(feature);
@ -89,6 +91,7 @@ function openActivityMap(id) {
let latlon = layers[0].getLatLng(); let latlon = layers[0].getLatLng();
let newCircle = L.circle([latlon.lat, latlon.lng], { radius: radius }); let newCircle = L.circle([latlon.lat, latlon.lng], { radius: radius });
addDrawnLayer(newCircle) addDrawnLayer(newCircle)
// console.log("cek layers", layers[0]);
} else { } else {
let lGeoJson = L.geoJson(datageojson); let lGeoJson = L.geoJson(datageojson);
let layers = lGeoJson.getLayers(); let layers = lGeoJson.getLayers();
@ -135,16 +138,19 @@ $(document).ready(function () {
layer = e.layer; layer = e.layer;
if (type === 'marker') { if (type === 'marker') {
let latlong = layer.getLatLng(); let latlong = layer.getLatLng();
// console.log("cek latlong", latlong);
circLat = latlong.lat circLat = latlong.lat
circLong = latlong.lng circLong = latlong.lng
$("#modal_radius").modal("show"); $("#modal_radius").modal("show");
// Do marker specific actions // Do marker specific actions
// let attri = layer.getAttribution(); // let attri = layer.getAttribution();
// console.log("cek attribute", attri);
return false; return false;
} }
let geJson = layer.toGeoJSON(); let geJson = layer.toGeoJSON();
currentGeoJson = geJson; currentGeoJson = geJson;
// let lgeojson = L.geoJson(geJson) // let lgeojson = L.geoJson(geJson)
// console.log("cek layer", layer.toGeoJSON());
// layer.bindTooltip("cek"); // layer.bindTooltip("cek");
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
addDrawnLayer(layer); addDrawnLayer(layer);
@ -160,6 +166,7 @@ $(document).ready(function () {
drawnItems.removeLayer(layer); drawnItems.removeLayer(layer);
}); });
updateCurrentGeoJson() updateCurrentGeoJson()
// console.log("cek layer", layer.toGeoJSON());
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
// map.addLayer(layer); // map.addLayer(layer);
@ -176,6 +183,8 @@ $(document).ready(function () {
} }
updateCurrentGeoJson(); updateCurrentGeoJson();
}); });
// console.log("cek layer", layers[0].toGeoJSON());
// console.log("cek layer", layer.toGeoJSON());
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
// drawnControlEdit.remove(); // drawnControlEdit.remove();
// map.addControl(drawControl); // map.addControl(drawControl);

38
edit-mode/function/expenseResource.js

@ -1,11 +1,10 @@
var expenseModal = $('#modal-expense > .modal-dialog > .modal-content'); var expenseModal = $('#modal-expense > .modal-dialog > .modal-content');
function resetFormAssignexpense() { function resetFormAssignexpense() {
// $('#select-expense').val(null).trigger("change"); $('#select-expense').val(null).trigger("change");
// $('#select-expense').find('option').remove(); $('#select-expense').find('option').remove();
// $('#select-expense').val(""); $('#select-expense').val("");
$("#desc-expense").val(""); $('#uom-req-expense').val(null).trigger('change');
$('#uom-req-expense').val("").trigger('change');
$('#form-assign-expense').trigger("reset"); $('#form-assign-expense').trigger("reset");
$('#btn-assign-expense').html('Assign'); $('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false); $('#btn-assign-expense').prop("disabled", false);
@ -89,18 +88,20 @@ $(document).ready(function () {
}); });
$('#modal-expense').on('show.bs.modal', function (event) { $('#modal-expense').on('show.bs.modal', function (event) {
resetFormAssignexpense(); $("#desc-expense").val(activityName);
$('#modal-expense-title').html("Overhead " + activityName); $('#modal-expense-title').html("Overhead " + activityName);
$('#modal-expense-sub-title').html(`<p style="font-size: 12px; color: #747474">Plan Date: ${moment(activityEarlyStart).format('DD MMMM YYYY')} - ${moment(activityEarlyFinish).format('DD MMMM YYYY')}</p>`); $('#modal-expense-sub-title').html(`<p style="font-size: 12px; color: #747474">Plan Date: ${moment(activityEarlyStart).format('DD MMMM YYYY')} - ${moment(activityEarlyFinish).format('DD MMMM YYYY')}</p>`);
tableexpense.draw(); tableexpense.draw();
}); });
$('#modal-expense').on('hide.bs.modal', function (event) { $('#modal-expense').on('hide.bs.modal', function (event) {
resetFormAssignexpense();
$("#show-form-expense").show(); $("#show-form-expense").show();
console.log("there's before action change ", actionHappen);
if (actionHappen) { if (actionHappen) {
console.log("there's action change ", actionHappen);
updateActivity(activityId); updateActivity(activityId);
} }
resetFormAssignexpense();
}); });
$('#select-expense').select2({ $('#select-expense').select2({
@ -122,6 +123,7 @@ $(document).ready(function () {
processResults: function (result) { processResults: function (result) {
return { return {
results: $.map(result, function (item) { results: $.map(result, function (item) {
// console.log("cek item", item)
return { return {
text: item.description, text: item.description,
id: item.id id: item.id
@ -161,7 +163,7 @@ $(document).ready(function () {
type: "expense", type: "expense",
fom_date: required_date, fom_date: required_date,
required_date: required_date, required_date: required_date,
proyek_id: parseInt(proyekId), proyek_id: proyekId,
uom: uom, uom: uom,
qty: formatReplaceTitikRibuan(qty_planning), qty: formatReplaceTitikRibuan(qty_planning),
price: formatReplaceTitikRibuan(price) price: formatReplaceTitikRibuan(price)
@ -176,6 +178,7 @@ $(document).ready(function () {
if (data && data.code === 200) { if (data && data.code === 200) {
material_id = data.data.id; material_id = data.data.id;
resetFormAssignexpense(); resetFormAssignexpense();
let payloadAssign = { let payloadAssign = {
proyek_id: proyekId, proyek_id: proyekId,
activity_id: activityId, activity_id: activityId,
@ -192,34 +195,35 @@ $(document).ready(function () {
contentType: false, contentType: false,
success: function (data) { success: function (data) {
if (data && data.code === 200) { if (data && data.code === 200) {
resetFormAssignexpense();
actionHappen = true; actionHappen = true;
gantt.alert("Data added!"); gantt.alert("Data added!");
tableexpense.draw(); tableexpense.draw();
} else { resetFormAssignexpense();
}
else {
gantt.alert({ type: "error", text: data.message });
$('#btn-assign-expense').html('Assign'); $('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false); $('#btn-assign-expense').prop("disabled", false);
gantt.alert({ type: "error", text: data.message });
} }
}, },
error: function (data) { error: function (data) {
$('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false);
gantt.alert("Assign Failed, try again later!"); gantt.alert("Assign Failed, try again later!");
resetFormAssignexpense();
} }
}); });
} else { }
else {
gantt.alert({ type: "error", text: data.message });
$('#btn-assign-expense').html('Assign'); $('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false); $('#btn-assign-expense').prop("disabled", false);
gantt.alert({ type: "error", text: data.message });
} }
}, },
error: function (data) { error: function (data) {
$('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false);
gantt.alert("Overhead request Failed, try again later!"); gantt.alert("Overhead request Failed, try again later!");
resetFormAssignexpense();
} }
}); });
}); });
// delete from row // delete from row

18
edit-mode/function/function.js

@ -189,14 +189,11 @@ function initializationProject() {
function getSatuan() { function getSatuan() {
const payload = { const payload = {
"orders": { "columns": [],
"ascending": true,
"columns": [
'id'
]
}
} }
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
$.ajax({ $.ajax({
data: JSON.stringify(payload), data: JSON.stringify(payload),
url: `${base_url}satuan/search`, url: `${base_url}satuan/search`,
@ -224,7 +221,7 @@ function getSatuan() {
let newOption = new Option(option.label, option.label); let newOption = new Option(option.label, option.label);
$('#uom-req-material').append(newOption); $('#uom-req-material').append(newOption);
}); });
$('#uom-req-expense').append(new Option('', '', true, true));
satuanList.forEach((option) => { satuanList.forEach((option) => {
let newOption = new Option(option.label, option.label); let newOption = new Option(option.label, option.label);
$('#uom-req-expense').append(newOption); $('#uom-req-expense').append(newOption);
@ -650,8 +647,10 @@ function updateShowHideColumn(data) {
processData: false, processData: false,
contentType: false, contentType: false,
success: function (data) { success: function (data) {
// console.log(data);
}, },
error: function (data) { error: function (data) {
// console.log(data);
} }
}); });
} }
@ -662,6 +661,8 @@ function colAjaxReq(type) {
type: "GET", type: "GET",
success: function (data) { success: function (data) {
let ganttColumnsByType = data.data; let ganttColumnsByType = data.data;
// console.log("ini gantt field ", ganttColumnsByType);
// console.log("ini column ", gantt.config.columns);
let isFound = false; let isFound = false;
x = gantt.config.columns.filter((val) => { x = gantt.config.columns.filter((val) => {
isFound = ganttColumnsByType.find(obj => { isFound = ganttColumnsByType.find(obj => {
@ -670,6 +671,7 @@ function colAjaxReq(type) {
if (isFound) if (isFound)
return val; return val;
if (isFound == false){ if (isFound == false){
// console.log("ini gantt field !isFound ", val);
} }
}); });

5
edit-mode/function/ganttActivityComments.js

@ -4,6 +4,7 @@ const COMMENT_SEARCH_URL = `${base_url}comment-activity/search`;
$(document).ready(function() { $(document).ready(function() {
$(".modal_add_btn_comment").on('click', function() { $(".modal_add_btn_comment").on('click', function() {
console.log('onclick add comments');
addComments(); addComments();
}); });
$("#btn_comment_submit").on('click', function() { $("#btn_comment_submit").on('click', function() {
@ -14,6 +15,7 @@ $(document).ready(function() {
// show comments modal // show comments modal
function showComments(id) { function showComments(id) {
var task = gantt.getTaskBy('id', id); var task = gantt.getTaskBy('id', id);
console.log('showComments', task);
var activity = task && task.length > 0 ? task[0].text : ''; var activity = task && task.length > 0 ? task[0].text : '';
$("#activity_id").val(id); $("#activity_id").val(id);
$("#comments_title").text(activity); $("#comments_title").text(activity);
@ -56,6 +58,7 @@ function submitComments() {
data: JSON.stringify(payload) data: JSON.stringify(payload)
}) })
.done(function( msg ) { .done(function( msg ) {
console.log('done submit comment', msg)
// gantt.message("Comment posted"); // gantt.message("Comment posted");
gantt.alert("Comment posted"); gantt.alert("Comment posted");
$("#add_comment_form").trigger("reset"); $("#add_comment_form").trigger("reset");
@ -103,6 +106,7 @@ function searchComments(activity_id) {
} }
} }
console.log('searchComments payload', payload);
$.ajax({ $.ajax({
method: "POST", method: "POST",
@ -111,6 +115,7 @@ function searchComments(activity_id) {
data: JSON.stringify(payload) data: JSON.stringify(payload)
}) })
.done(function( msg ) { .done(function( msg ) {
console.log('done search comment', msg)
var comments = msg && msg.data; var comments = msg && msg.data;
var contents = ''; var contents = '';
if (comments.length > 0) { if (comments.length > 0) {

38
edit-mode/function/ganttActivityUploadDoc.js

@ -1,13 +1,14 @@
// Upload Document Activity // Upload Document Activity
const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`; const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`;
const DOCUMENT_DOWNLOAD_URL = (id) => `${base_url}document-activity/download/${id}`; const DOCUMENT_DOWNLOAD_URL = (id, company_id) => `${base_url}document-activity/download/${id}/${company_id}`;
const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`; const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`;
const DOCUMENT_DELETE_URL = (id) => `${base_url}document-activity/delete/${id}`; const DOCUMENT_DELETE_URL = (id, company_id) => `${base_url}document-activity/delete/${id}/${company_id}`;
var fileToUpload = null; var fileToUpload = null;
$(document).ready(function() { $(document).ready(function() {
$(".modal_add_btn_doc").on('click', function() { $(".modal_add_btn_doc").on('click', function() {
console.log('onclick add document');
addDocuments(); addDocuments();
}); });
@ -22,7 +23,9 @@ $(document).ready(function() {
// $("#add_doc_form").on('submit', function(e) { // $("#add_doc_form").on('submit', function(e) {
// // submitDocuments(); // // submitDocuments();
// e.preventDefault(); // e.preventDefault();
// console.log(this);
// var formData = new FormData(this); // var formData = new FormData(this);
// console.log('formData', formData);
// $.ajax({ // $.ajax({
// method: "POST", // method: "POST",
// url: DOCUMENT_UPLOAD_URL, // url: DOCUMENT_UPLOAD_URL,
@ -31,11 +34,13 @@ $(document).ready(function() {
// contentType: false, // contentType: false,
// cache: false, // cache: false,
// success: function(msg) { // success: function(msg) {
// console.log('done submit comment', msg)
// $("#add_doc_form").trigger("reset"); // $("#add_doc_form").trigger("reset");
// searchDocuments(activity_id); // reload the contents // searchDocuments(activity_id); // reload the contents
// }, // },
// error: function(xhr, status, error) { // error: function(xhr, status, error) {
// // error handling // // error handling
// console.log('error document upload', xhr, status, error);
// } // }
// }); // });
// }); // });
@ -52,6 +57,7 @@ $(document).ready(function() {
// show comments modal // show comments modal
function showDocuments(id) { function showDocuments(id) {
var task = gantt.getTaskBy('id', id); var task = gantt.getTaskBy('id', id);
console.log('showComments', task);
var activity = task && task.length > 0 ? task[0].text : ''; var activity = task && task.length > 0 ? task[0].text : '';
$("#activity_id").val(id); $("#activity_id").val(id);
$("#upload_doc_title").text(activity); $("#upload_doc_title").text(activity);
@ -90,21 +96,25 @@ async function submitDocuments() {
return; return;
} }
console.log('fileToUpload', fileToUpload);
var formData = new FormData; var formData = new FormData;
formData.append('activity_id', activity_id); formData.append('activity_id', activity_id);
formData.append('dokumen', files); formData.append('dokumen', files);
formData.append('company_id',company_id);
if (activity_id !== '' && dokumen !== '') { if (activity_id !== '' && dokumen !== '') {
const result = await axiosInstance const result = await axiosInstance
.post(DOCUMENT_UPLOAD_URL, formData) .post(DOCUMENT_UPLOAD_URL, formData)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.status==200){ if(result && result.status==200){
console.log('done upload doc', result)
gantt.alert("Upload Success"); gantt.alert("Upload Success");
$("#add_doc_form").trigger("reset"); $("#add_doc_form").trigger("reset");
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
$('#btn_doc_submit').prop("disabled",false); $('#btn_doc_submit').prop("disabled",false);
searchDocuments(activity_id); // reload the contents searchDocuments(activity_id); // reload the contents
}else{ }else{
console.log('failed upload');
gantt.alert({type: "error", text: "Upload Failed"}); gantt.alert({type: "error", text: "Upload Failed"});
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
$('#btn_doc_submit').prop("disabled",false); $('#btn_doc_submit').prop("disabled",false);
@ -132,6 +142,7 @@ function searchDocuments(activity_id) {
"operator": "AND" "operator": "AND"
} }
], ],
// "joins": [{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }],
"orders": { "orders": {
"columns": [ "columns": [
"id" "id"
@ -147,7 +158,20 @@ function searchDocuments(activity_id) {
data: JSON.stringify(payload) data: JSON.stringify(payload)
}) })
.done(function( msg ) { .done(function( msg ) {
console.log('done search documents', msg)
var documents = msg && msg.data; var documents = msg && msg.data;
// var contents = '';
// if (documents.length > 0) {
// contents += '<div>';
// for (var i=0; i < documents.length; i++) {
// // contents += '<div class="comment-section">';
// // contents += '<div class="comment-detail">'+comments[i].created_by+' &bull; '+moment(comments[i].created_at).format('DD-MM-YYYY HH:mm:ss')+'</div>';
// // contents += '<div class="comment-text">'+comments[i].comment+'</div>';
// // contents += '</div>';
// }
// contents += '</div>';
// }
$("#documents_table").DataTable().destroy(); $("#documents_table").DataTable().destroy();
$('#documents_table').DataTable({ $('#documents_table').DataTable({
data: documents, data: documents,
@ -167,12 +191,17 @@ function searchDocuments(activity_id) {
}, },
] ]
}); });
// $("#documents_list").html(contents);
})
.fail(function(xhr, status, error) {
// error handling
console.log('error document search', status);
}); });
} }
async function downloadDocument(id, name) { async function downloadDocument(id, name) {
let result; let result;
await fetch(DOCUMENT_DOWNLOAD_URL(id), { await fetch(DOCUMENT_DOWNLOAD_URL(id, company_id), {
headers: new Headers({ headers: new Headers({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': `Bearer ${token}` 'Authorization': `Bearer ${token}`
@ -214,8 +243,9 @@ async function deleteDocument(id, activity_id) {
callback: async function(result){ callback: async function(result){
// result is true / false; // result is true / false;
if (result) { if (result) {
console.log('download document', id);
const result = await axiosInstance const result = await axiosInstance
.delete(DOCUMENT_DELETE_URL(id)) .delete(DOCUMENT_DELETE_URL(id, company_id))
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

17
edit-mode/function/ganttConfig.js

@ -4,6 +4,7 @@ const proyekId = getUrlParameter("proyek_id");
const timestamp = getUrlParameter("timestamp"); 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_name = getUrlParameter("company_name"); const company_name = getUrlParameter("company_name");
const base_url_image = `https://project-api.ospro.id/assets/${company_name}/`; const base_url_image = `https://project-api.ospro.id/assets/${company_name}/`;
const ganttName = getUrlParameter("gantt_name"); const ganttName = getUrlParameter("gantt_name");
@ -294,14 +295,14 @@ var allColumns = [
editor: editor.text, editor: editor.text,
resize: true, resize: true,
template: function (text) { template: function (text) {
// function truncateText(text, maxLength) { function truncateText(text, maxLength) {
// if (text.length > maxLength) { if (text.length > maxLength) {
// return text.substring(0, maxLength) + '...'; return text.substring(0, maxLength) + '...';
// } }
// return text; return text;
// } }
// const truncatedText = truncateText(text.text, 30); const truncatedText = truncateText(text.text, 30);
return `<span title="${text.text}">${text.text}</span>`; return `<span title="${text.text}">${truncatedText}</span>`;
} }
}, },
{ {

25
edit-mode/function/ganttSettings.js

@ -65,7 +65,6 @@ $(document).ready(function () {
if (result && result.status == 200) { if (result && result.status == 200) {
if (result.data && result.data.data) { if (result.data && result.data.data) {
var config_dayoff = null; var config_dayoff = null;
if (result.data.data.config_dayoff !== null) { if (result.data.data.config_dayoff !== null) {
config_dayoff = result.data.data.config_dayoff; config_dayoff = result.data.data.config_dayoff;
@ -126,13 +125,14 @@ $(document).ready(function () {
gantt.render(); gantt.render();
}); });
$("#gantt_toggle_task_btn").on('click', function (event) { $("#gantt_toggle_task_btn").on('click', function (event) {
toggleCollapseTasks(); toggleCollapseTasks();
}); });
$("#dashboard-project").on('click', function (event) { $("#dashboard-project").on('click', function (event) {
window.location.href = `https://si.ospro.id/#/dashboard-project/${projectId}/${ganttId}?dashboardGantt=${true}`; window.location.href = `https://si.ospro.id/#/dashboard-project/${projectId}/${ganttId}false-header`;
// window.location.href = `http://localhost:3000/#/dashboard-project/${projectId}/${ganttId}?dashboardGantt=${true}`; // window.location.href = `http://localhost:3000/#/dashboard-project/${projectId}/${ganttId}/false-header`;
}); });
$("#gantt-baseline").on('click', function (event) { $("#gantt-baseline").on('click', function (event) {
@ -181,6 +181,7 @@ async function initHolidays() {
var b = moment(a).add(val.duration, 'days'); var b = moment(a).add(val.duration, 'days');
for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) { for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) {
let holiday = new Date(m.format('YYYY-MM-DD')); let holiday = new Date(m.format('YYYY-MM-DD'));
console.log("holiday", holiday);
gantt.setWorkTime({ gantt.setWorkTime({
date: holiday, date: holiday,
hours: false hours: false
@ -204,9 +205,6 @@ async function initGanttSettings() {
if (result && result.status == 200) { if (result && result.status == 200) {
var config_dayoff = result.data.data.config_dayoff; var config_dayoff = result.data.data.config_dayoff;
var type_gantt = result.data.data.calculation_type; var type_gantt = result.data.data.calculation_type;
const ganttName = result.data.data.name_version;
document.getElementById("project-name-header").textContent = ganttName;
reRenderColumns(type_gantt); reRenderColumns(type_gantt);
var dayoff = []; var dayoff = [];
if (config_dayoff && config_dayoff.length > 0) { if (config_dayoff && config_dayoff.length > 0) {
@ -223,10 +221,19 @@ async function initGanttSettings() {
gantt.setWorkTime({ day: dayoff[i], hours: false }); gantt.setWorkTime({ day: dayoff[i], hours: false });
} }
} }
// for (let index = 1; index <= 7; index++) {
// const dateToCheck = new Date(2023, 4, index); // Note: Month is 0-based, so 5 represents June
// if (gantt.isWorkTime({ date: dateToCheck, hours: false })) {
// console.log(dateToCheck.toString() + ' is work time.');
// } else {
// console.log(dateToCheck.toString() + ' is not work time.');
// }
// }
} }
} }
function expandTask() { function expandTask() {
console.log("check expandTask")
gantt.eachTask(function (task) { gantt.eachTask(function (task) {
task.$open = true; task.$open = true;
}); });
@ -240,16 +247,19 @@ function expandTask() {
function toggleCollapseTasks() { function toggleCollapseTasks() {
// collapse task / activity // collapse task / activity
console.log('toggleCollapseTasks');
gantt.eachTask(function (task) { gantt.eachTask(function (task) {
task.$open = toggleTasks == "Expand"; task.$open = toggleTasks == "Expand";
}); });
if (toggleTasks == "Expand") { if (toggleTasks == "Expand") {
updateProperty({ task_open: true }) updateProperty({ task_open: true })
// console.log('to collapse');
toggleTasks = "Collapse"; toggleTasks = "Collapse";
$("#gantt_toggle_task_btn").prop('title', 'Collapse Activities'); $("#gantt_toggle_task_btn").prop('title', 'Collapse Activities');
$("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt'); $("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt');
$("#gantt_toggle_task_btn").children().addClass('fa-compress-alt'); // change icon to collapse $("#gantt_toggle_task_btn").children().addClass('fa-compress-alt'); // change icon to collapse
} else { } else {
// console.log('to expand');
updateProperty({ task_open: false }) updateProperty({ task_open: false })
toggleTasks = "Expand"; toggleTasks = "Expand";
$("#gantt_toggle_task_btn").prop('title', 'Expand Activities'); $("#gantt_toggle_task_btn").prop('title', 'Expand Activities');
@ -266,6 +276,7 @@ function getColumnsSelection(node) {
var selectedColumns = node.querySelectorAll(":checked"); var selectedColumns = node.querySelectorAll(":checked");
var unselectedColumn = node.querySelectorAll('input[type="checkbox"]:not(:checked)'); var unselectedColumn = node.querySelectorAll('input[type="checkbox"]:not(:checked)');
// var allSelected = node.querySelector("#check-all").prop('checked'); // var allSelected = node.querySelector("#check-all").prop('checked');
// console.log("unselectedColumn", unselectedColumn)
var checkedColumns = {}; var checkedColumns = {};
selectedColumns.forEach(function (node) { selectedColumns.forEach(function (node) {
checkedColumns[node.name] = true; checkedColumns[node.name] = true;
@ -420,6 +431,7 @@ async function setBaselineAPI() {
.get(ACTIVITY_SET_BASELINE_URL, HEADER) .get(ACTIVITY_SET_BASELINE_URL, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('set baseline res', res);
if (res && res.status === 200) { if (res && res.status === 200) {
// $('#modal_gantt_setting').modal('hide'); // $('#modal_gantt_setting').modal('hide');
// gantt.alert("Settings updated"); // gantt.alert("Settings updated");
@ -497,6 +509,7 @@ async function setSynchronizeAPI() {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('synchronize res', res);
if (res && res.status === 200) { if (res && res.status === 200) {
// $('#modal_gantt_setting').modal('hide'); // $('#modal_gantt_setting').modal('hide');
// gantt.alert("Settings updated"); // gantt.alert("Settings updated");

2
edit-mode/function/holiday.js

@ -82,6 +82,7 @@ $(document).ready(function () {
var b = moment(a).add(data.duration, 'days'); var b = moment(a).add(data.duration, 'days');
for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) { for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) {
let holiday = new Date(m.format('YYYY-MM-DD')); let holiday = new Date(m.format('YYYY-MM-DD'));
// console.log("cek holiday", holiday)
gantt.unsetWorkTime({ gantt.unsetWorkTime({
date: holiday, date: holiday,
hours:false hours:false
@ -96,6 +97,7 @@ $(document).ready(function () {
url: `${base_url}holiday/delete/${id}`, url: `${base_url}holiday/delete/${id}`,
type:"DELETE", type:"DELETE",
success: function (data) { success: function (data) {
// console.log("cek data", data.data);
gantt.alert("Delete Holiday Success!"); gantt.alert("Delete Holiday Success!");
tableHoliday.draw(); tableHoliday.draw();
if(data.data){ if(data.data){

2
edit-mode/function/humanResource.js

@ -113,6 +113,7 @@ $(document).ready(function () {
processResults: function (result) { processResults: function (result) {
return { return {
results: $.map(result, function (item) { results: $.map(result, function (item) {
// console.log("cek item", item)
return { return {
text: item.name, text: item.name,
id: item.id id: item.id
@ -142,6 +143,7 @@ $(document).ready(function () {
processResults: function (result) { processResults: function (result) {
return { return {
results: $.map(result, function (item) { results: $.map(result, function (item) {
// console.log("cek item", item)
return { return {
text: item.name, text: item.name,
id: item.id + "|" + item.proyek_role, id: item.id + "|" + item.proyek_role,

4
edit-mode/function/materialResource.js

@ -97,7 +97,9 @@ $(document).ready(function () {
$('#modal-material').on('hide.bs.modal', function (event) { $('#modal-material').on('hide.bs.modal', function (event) {
// $("#hide-form-material").hide(); // $("#hide-form-material").hide();
$("#show-form-material").show(); $("#show-form-material").show();
console.log("there's before action change ", actionHappen);
if (actionHappen) { if (actionHappen) {
console.log("there's action change ", actionHappen);
updateActivity(activityId); updateActivity(activityId);
} }
resetFormAssignMaterial(); resetFormAssignMaterial();
@ -122,6 +124,7 @@ $(document).ready(function () {
processResults: function (result) { processResults: function (result) {
return { return {
results: $.map(result, function (item) { results: $.map(result, function (item) {
// console.log("cek item", item)
return { return {
text: item.description, text: item.description,
id: item.id id: item.id
@ -165,6 +168,7 @@ $(document).ready(function () {
results: dataIntegrasiMaterial results: dataIntegrasiMaterial
}; };
}, error: function (jqXHR, textStatus, errorThrown) { }, error: function (jqXHR, textStatus, errorThrown) {
// console.log("textStatus ", textStatus);
if (textStatus != "abort") { if (textStatus != "abort") {
// gantt.alert(`Status: ${textStatus}`); // gantt.alert(`Status: ${textStatus}`);
gantt.alert(`Data Not Found`); gantt.alert(`Data Not Found`);

4
edit-mode/function/milestone.js

@ -1,5 +1,6 @@
var milestoneModal = $('#modal-add-milestone > .modal-dialog > .modal-content'); var milestoneModal = $('#modal-add-milestone > .modal-dialog > .modal-content');
function addMilestone(id){ function addMilestone(id){
console.log("cek cek id milestone", id);
if(id && id > 0){ if(id && id > 0){
$("#milestone_parent").val(id); $("#milestone_parent").val(id);
} }
@ -40,6 +41,7 @@ $(document).ready(function () {
processResults: function (result) { processResults: function (result) {
return { return {
results: $.map(result, function (item) { results: $.map(result, function (item) {
// console.log("cek item", item)
return { return {
due_date:item.due_date, due_date:item.due_date,
deadline:item.deadline, deadline:item.deadline,
@ -92,12 +94,14 @@ $(document).ready(function () {
$('#submit-milestone').html('Add..'); $('#submit-milestone').html('Add..');
$('#submit-milestone').prop("disabled",true); $('#submit-milestone').prop("disabled",true);
var data = Object.fromEntries(new FormData(this)); var data = Object.fromEntries(new FormData(this));
console.log("cek data form", data);
let parent = data.milestone_parent; let parent = data.milestone_parent;
var taskId = 0; var taskId = 0;
var start = moment(data.due_date, "DD-MM-YYYY"); var start = moment(data.due_date, "DD-MM-YYYY");
var end = moment(data.deadline, "DD-MM-YYYY"); var end = moment(data.deadline, "DD-MM-YYYY");
let duration = moment.duration(start.diff(end)).asDays(); let duration = moment.duration(start.diff(end)).asDays();
let nameMilestone = data.status!="" ? data.status : data.id_milestone let nameMilestone = data.status!="" ? data.status : data.id_milestone
// console.log("cek duration", Math.abs(duration));
if(parent && parseInt(parent) > 0){ if(parent && parseInt(parent) > 0){
taskId = gantt.addTask({ taskId = gantt.addTask({
id: Math.floor(Math.random() * 1000) + 5000, id: Math.floor(Math.random() * 1000) + 5000,

19
edit-mode/function/modalHumanResourceFunction.js

@ -30,7 +30,9 @@ $(document).ready(function () {
"ascending": false "ascending": false
} }
} }
// console.log("qry", qry)
axiosInstance.post(url, payload, HEADER).then(res => { axiosInstance.post(url, payload, HEADER).then(res => {
console.log('getDataHumanResource', res)
DATA_HUMAN_RESOURCE = res.data.data DATA_HUMAN_RESOURCE = res.data.data
// arr.forEach(function (element, key) { // arr.forEach(function (element, key) {
// $('#choices-multiple-remove-button1').append(`<option value="${element.id}">${element.name}</option>`) // $('#choices-multiple-remove-button1').append(`<option value="${element.id}">${element.name}</option>`)
@ -54,7 +56,9 @@ $(document).ready(function () {
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
// console.log("qry", qry)
axiosInstance.post(url, payload, HEADER).then(res => { axiosInstance.post(url, payload, HEADER).then(res => {
console.log(res)
DATA_ROLE_HUMAN_RESOURCE = res.data.data DATA_ROLE_HUMAN_RESOURCE = res.data.data
}); });
} }
@ -89,6 +93,7 @@ $(document).ready(function () {
// } // }
// } // }
// axiosInstance.post(url, payload, HEADER).then(res => { // axiosInstance.post(url, payload, HEADER).then(res => {
// console.log(res)
// DATA_MATERIAL_RESOURCE = res.data.data // DATA_MATERIAL_RESOURCE = res.data.data
// }); // });
// } // }
@ -116,6 +121,7 @@ $(document).ready(function () {
// } // }
// } // }
// axiosInstance.post(url, payload, HEADER).then(res => { // axiosInstance.post(url, payload, HEADER).then(res => {
// console.log(res)
// const arr = res.data.data // const arr = res.data.data
// DATA_TOOL_RESOURCE = res.data.data // DATA_TOOL_RESOURCE = res.data.data
// arr.forEach(function (element, key) { // arr.forEach(function (element, key) {
@ -128,6 +134,7 @@ $(document).ready(function () {
// } // }
$('#human-resource').on('show.bs.modal', function (event) { $('#human-resource').on('show.bs.modal', function (event) {
// console.log("open modal human resource")
getDataHumanResource() getDataHumanResource()
getDataRole() getDataRole()
// getDataMaterials() // getDataMaterials()
@ -142,6 +149,7 @@ $(document).ready(function () {
$("#add-human-resource").on('click', function () { $("#add-human-resource").on('click', function () {
const num = $('#table-human-resource tr').length const num = $('#table-human-resource tr').length
console.log(num)
const idx = num + 1 const idx = num + 1
$('#table-human-resource').append(` $('#table-human-resource').append(`
<tr id="row-human-resource-${idx}"> <tr id="row-human-resource-${idx}">
@ -174,11 +182,13 @@ $(document).ready(function () {
$('#table-human-resource').on('click', '.human-resource-delete', function (event) { $('#table-human-resource').on('click', '.human-resource-delete', function (event) {
const idx = $(this).attr("index") const idx = $(this).attr("index")
console.log(idx)
$(`#row-human-resource-${idx}`).remove() $(`#row-human-resource-${idx}`).remove()
}) })
// $("#add-material-resource").on('click', function () { // $("#add-material-resource").on('click', function () {
// const num = $('#table-material-resource tr').length // const num = $('#table-material-resource tr').length
// console.log(num)
// const idx = num + 1 // const idx = num + 1
// $('#table-material-resource').append(` // $('#table-material-resource').append(`
// <tr id="row-material-resource-${idx}"> // <tr id="row-material-resource-${idx}">
@ -206,11 +216,13 @@ $(document).ready(function () {
// $('#table-material-resource').on('click', '#material-resource-delete', function (event) { // $('#table-material-resource').on('click', '#material-resource-delete', function (event) {
// const idx = $(this).attr("index") // const idx = $(this).attr("index")
// console.log(idx)
// $(`#row-material-resource-${idx}`).remove() // $(`#row-material-resource-${idx}`).remove()
// }) // })
// $("#add-tool-resource").on('click', function () { // $("#add-tool-resource").on('click', function () {
// const num = $('#table-tool-resource tr').length // const num = $('#table-tool-resource tr').length
// console.log(num)
// const idx = num + 1 // const idx = num + 1
// $('#table-tool-resource').append(` // $('#table-tool-resource').append(`
// <tr id="row-tool-resource-${idx}"> // <tr id="row-tool-resource-${idx}">
@ -238,11 +250,13 @@ $(document).ready(function () {
// $('#table-tool-resource').on('click', '#tool-resource-delete', function (event) { // $('#table-tool-resource').on('click', '#tool-resource-delete', function (event) {
// const idx = $(this).attr("index") // const idx = $(this).attr("index")
// console.log(idx)
// $(`#row-tool-resource-${idx}`).remove() // $(`#row-tool-resource-${idx}`).remove()
// }) // })
$(".submit-human-resource").on('click', function () { $(".submit-human-resource").on('click', function () {
console.log('onclick submit human resource');
// addComments(); // addComments();
let valueHumanResource = [] let valueHumanResource = []
const num = $('#table-human-resource tr').length const num = $('#table-human-resource tr').length
@ -255,6 +269,8 @@ $(document).ready(function () {
} }
valueHumanResource.push(obj) valueHumanResource.push(obj)
} }
console.log("cek value", valueHumanResource)
// let valueMaterialResource = [] // let valueMaterialResource = []
// const numMaterial = $('#table-material-resource tr').length // const numMaterial = $('#table-material-resource tr').length
// for (let i = 0; i < numMaterial; i++) { // for (let i = 0; i < numMaterial; i++) {
@ -266,6 +282,7 @@ $(document).ready(function () {
// } // }
// valueMaterialResource.push(obj) // valueMaterialResource.push(obj)
// } // }
// console.log(valueMaterialResource)
// let valueToolResource = [] // let valueToolResource = []
// const numTool = $('#table-tool-resource tr').length // const numTool = $('#table-tool-resource tr').length
@ -278,9 +295,11 @@ $(document).ready(function () {
// } // }
// valueToolResource.push(obj) // valueToolResource.push(obj)
// } // }
// console.log(valueToolResource)
// const cost = $(`#cost-human-resource`).val() // const cost = $(`#cost-human-resource`).val()
// const duration = $(`#duration-human-resource`).val() // const duration = $(`#duration-human-resource`).val()
// const dateStart = $(`#date-started-human-started`).val() // const dateStart = $(`#date-started-human-started`).val()
// console.log({ cost, duration, dateStart })
// $("#exampleModal").modal('hide'); // $("#exampleModal").modal('hide');
}); });

2
edit-mode/function/reportActivity.js

@ -654,7 +654,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;

2
edit-mode/function/restActivityLink.js

@ -59,6 +59,8 @@ gantt.ajax.get({
}); });
function refresData(id) { function refresData(id) {
console.log("refres triggered!!");
// Store the current scroll position // Store the current scroll position
var scrollState = { var scrollState = {
x: gantt.getScrollState().x, x: gantt.getScrollState().x,

2
edit-mode/function/toolsResource.js

@ -94,6 +94,7 @@ $(document).ready(function () {
processResults: function (result) { processResults: function (result) {
return { return {
results: $.map(result, function (item) { results: $.map(result, function (item) {
// console.log("cek item", item)
return { return {
text: item.name, text: item.name,
id: item.id id: item.id
@ -142,6 +143,7 @@ $(document).ready(function () {
processData: false, processData: false,
contentType: false, contentType: false,
success: function (data) { success: function (data) {
console.log('response data', data);
if (data && data.code === 200) { if (data && data.code === 200) {
actionHappen = true; actionHappen = true;
gantt.alert("Tools Assign Success!"); gantt.alert("Tools Assign Success!");

2
edit-mode/index.html

@ -67,7 +67,7 @@
<div class="loading-overlay"></div> <div class="loading-overlay"></div>
<div class="container-header"> <div class="container-header">
<div class="container-project"> <div class="container-project">
<h6 id="project-name-header" style="margin-left: 10px;"></h6> <h6 id="project-name-header"></h6>
</div> </div>
<div class="container-action"> <div class="container-action">
<div class="btn-icon-toolbar btn-sm"><span class="icon-toolbar-separator">Zoom: </span></div> <div class="btn-icon-toolbar btn-sm"><span class="icon-toolbar-separator">Zoom: </span></div>

10
view-mode/function/activityLocation.js

@ -49,10 +49,12 @@ function openActivityMap(id)
type:"get", type:"get",
success: function (data) { success: function (data) {
let dataRes = data.data let dataRes = data.data
// console.log("cek data", data);
drawnItem.clearLayers(); drawnItem.clearLayers();
if(dataRes.geom){ if(dataRes.geom){
let datageojson = JSON.parse(dataRes.geom); let datageojson = JSON.parse(dataRes.geom);
currentGeoJson = datageojson currentGeoJson = datageojson
// console.log("cek data geojson", datageojson);
if(datageojson.properties.radius){ if(datageojson.properties.radius){
let radius = datageojson.properties.radius let radius = datageojson.properties.radius
let lGeoJson = L.geoJson(datageojson); let lGeoJson = L.geoJson(datageojson);
@ -60,6 +62,7 @@ function openActivityMap(id)
let latlon = layers[0].getLatLng(); let latlon = layers[0].getLatLng();
let newCircle = L.circle([latlon.lat,latlon.lng], {radius: radius}); let newCircle = L.circle([latlon.lat,latlon.lng], {radius: radius});
drawnItem.addLayer(newCircle); drawnItem.addLayer(newCircle);
// console.log("cek layers", layers[0]);
}else{ }else{
let lGeoJson = L.geoJson(datageojson); let lGeoJson = L.geoJson(datageojson);
let layers = lGeoJson.getLayers(); let layers = lGeoJson.getLayers();
@ -106,16 +109,19 @@ $(document).ready(function () {
layer = e.layer; layer = e.layer;
if (type === 'marker') { if (type === 'marker') {
let latlong = layer.getLatLng(); let latlong = layer.getLatLng();
// console.log("cek latlong", latlong);
circLat = latlong.lat circLat = latlong.lat
circLong = latlong.lng circLong = latlong.lng
$("#modal_radius").modal("show"); $("#modal_radius").modal("show");
// Do marker specific actions // Do marker specific actions
// let attri = layer.getAttribution(); // let attri = layer.getAttribution();
// console.log("cek attribute", attri);
return false; return false;
} }
let geJson = layer.toGeoJSON(); let geJson = layer.toGeoJSON();
currentGeoJson = geJson; currentGeoJson = geJson;
// let lgeojson = L.geoJson(geJson) // let lgeojson = L.geoJson(geJson)
// console.log("cek layer", layer.toGeoJSON());
// layer.bindTooltip("cek"); // layer.bindTooltip("cek");
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
drawnItem.addLayer(layer); drawnItem.addLayer(layer);
@ -128,6 +134,7 @@ $(document).ready(function () {
var type = e.layerType, var type = e.layerType,
layer = e.layer; layer = e.layer;
// console.log("cek layer", layer.toGeoJSON());
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
currentGeoJson = ""; currentGeoJson = "";
drawnItem.removeLayer(layer); drawnItem.removeLayer(layer);
@ -148,6 +155,8 @@ $(document).ready(function () {
}else{ }else{
currentGeoJson = geoJson currentGeoJson = geoJson
} }
// console.log("cek layer", layers[0].toGeoJSON());
// console.log("cek layer", layer.toGeoJSON());
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
// drawnItem.removeLayer(layer); // drawnItem.removeLayer(layer);
// drawnControlEdit.remove(); // drawnControlEdit.remove();
@ -225,6 +234,7 @@ function submitCircle(radius)
let geojsoncircle = circle.toGeoJSON(); let geojsoncircle = circle.toGeoJSON();
geojsoncircle.properties.radius = radius geojsoncircle.properties.radius = radius
currentGeoJson = geojsoncircle currentGeoJson = geojsoncircle
// console.log("geojsoncircle", geojsoncircle);
drawnItem.addLayer(circle); drawnItem.addLayer(circle);
drawControl.remove(); drawControl.remove();
map.addControl(drawnControlEdit); map.addControl(drawnControlEdit);

8
view-mode/function/function.js

@ -485,7 +485,13 @@ function updateShowHideColumn(data)
url: `${base_url}gantt-show-hide/update/${ganttId}`, url: `${base_url}gantt-show-hide/update/${ganttId}`,
type: "POST", type: "POST",
processData: false, processData: false,
contentType: false contentType: false,
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
}); });
} }

6
view-mode/function/ganttActivityComments.js

@ -4,6 +4,7 @@ const COMMENT_SEARCH_URL = `${base_url}comment-activity/search`;
$(document).ready(function() { $(document).ready(function() {
$(".modal_add_btn_comment").on('click', function() { $(".modal_add_btn_comment").on('click', function() {
console.log('onclick add comments');
addComments(); addComments();
}); });
$("#btn_comment_submit").on('click', function() { $("#btn_comment_submit").on('click', function() {
@ -14,6 +15,7 @@ $(document).ready(function() {
// show comments modal // show comments modal
function showComments(id) { function showComments(id) {
var task = gantt.getTaskBy('id', id); var task = gantt.getTaskBy('id', id);
console.log('showComments', task);
var activity = task && task.length > 0 ? task[0].text : ''; var activity = task && task.length > 0 ? task[0].text : '';
$("#activity_id").val(id); $("#activity_id").val(id);
$("#comments_title").text(activity); $("#comments_title").text(activity);
@ -56,6 +58,7 @@ function submitComments() {
data: JSON.stringify(payload) data: JSON.stringify(payload)
}) })
.done(function( msg ) { .done(function( msg ) {
console.log('done submit comment', msg)
// gantt.message("Comment posted"); // gantt.message("Comment posted");
gantt.alert("Comment posted"); gantt.alert("Comment posted");
$("#add_comment_form").trigger("reset"); $("#add_comment_form").trigger("reset");
@ -103,6 +106,8 @@ function searchComments(activity_id) {
} }
} }
console.log('searchComments payload', payload);
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: COMMENT_SEARCH_URL, url: COMMENT_SEARCH_URL,
@ -110,6 +115,7 @@ function searchComments(activity_id) {
data: JSON.stringify(payload) data: JSON.stringify(payload)
}) })
.done(function( msg ) { .done(function( msg ) {
console.log('done search comment', msg)
var comments = msg && msg.data; var comments = msg && msg.data;
var contents = ''; var contents = '';
if (comments.length > 0) { if (comments.length > 0) {

45
view-mode/function/ganttActivityUploadDoc.js

@ -1,13 +1,14 @@
// Upload Document Activity // Upload Document Activity
const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`; const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`;
const DOCUMENT_DOWNLOAD_URL = (id) => `${base_url}document-activity/download/${id}`; const DOCUMENT_DOWNLOAD_URL = (id, company_id) => `${base_url}document-activity/download/${id}/${company_id}`;
const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`; const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`;
const DOCUMENT_DELETE_URL = (id) => `${base_url}document-activity/delete/${id}`; const DOCUMENT_DELETE_URL = (id, company_id) => `${base_url}document-activity/delete/${id}/${company_id}`;
var fileToUpload = null; var fileToUpload = null;
$(document).ready(function() { $(document).ready(function() {
$(".modal_add_btn_doc").on('click', function() { $(".modal_add_btn_doc").on('click', function() {
console.log('onclick add document');
addDocuments(); addDocuments();
}); });
@ -19,6 +20,31 @@ $(document).ready(function() {
fileToUpload = e.target.files[0]; fileToUpload = e.target.files[0];
}); });
// $("#add_doc_form").on('submit', function(e) {
// // submitDocuments();
// e.preventDefault();
// console.log(this);
// var formData = new FormData(this);
// console.log('formData', formData);
// $.ajax({
// method: "POST",
// url: DOCUMENT_UPLOAD_URL,
// data: formData,
// processData: false,
// contentType: false,
// cache: false,
// success: function(msg) {
// console.log('done submit comment', msg)
// $("#add_doc_form").trigger("reset");
// searchDocuments(activity_id); // reload the contents
// },
// error: function(xhr, status, error) {
// // error handling
// console.log('error document upload', xhr, status, error);
// }
// });
// });
$("#btn_doc_reset").on('click', function() { $("#btn_doc_reset").on('click', function() {
// $("#add_doc_form").trigger("reset"); // $("#add_doc_form").trigger("reset");
}) })
@ -31,6 +57,7 @@ $(document).ready(function() {
// show comments modal // show comments modal
function showDocuments(id) { function showDocuments(id) {
var task = gantt.getTaskBy('id', id); var task = gantt.getTaskBy('id', id);
console.log('showComments', task);
var activity = task && task.length > 0 ? task[0].text : ''; var activity = task && task.length > 0 ? task[0].text : '';
$("#activity_id").val(id); $("#activity_id").val(id);
$("#upload_doc_title").text(activity); $("#upload_doc_title").text(activity);
@ -69,15 +96,18 @@ async function submitDocuments() {
return; return;
} }
console.log('fileToUpload', fileToUpload);
var formData = new FormData; var formData = new FormData;
formData.append('activity_id', activity_id); formData.append('activity_id', activity_id);
formData.append('dokumen', files); formData.append('dokumen', files);
formData.append('company_id',company_id);
if (activity_id !== '' && dokumen !== '') { if (activity_id !== '' && dokumen !== '') {
const result = await axiosInstance const result = await axiosInstance
.post(DOCUMENT_UPLOAD_URL, formData) .post(DOCUMENT_UPLOAD_URL, formData)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.status==200){ if(result && result.status==200){
console.log('done upload doc', result)
gantt.alert("Upload Success"); gantt.alert("Upload Success");
$("#add_doc_form").trigger("reset"); $("#add_doc_form").trigger("reset");
$('#btn_doc_submit').html('Upload'); $('#btn_doc_submit').html('Upload');
@ -127,6 +157,7 @@ function searchDocuments(activity_id) {
data: JSON.stringify(payload) data: JSON.stringify(payload)
}) })
.done(function( msg ) { .done(function( msg ) {
console.log('done search documents', msg)
var documents = msg && msg.data; var documents = msg && msg.data;
// var contents = ''; // var contents = '';
// if (documents.length > 0) { // if (documents.length > 0) {
@ -159,12 +190,17 @@ function searchDocuments(activity_id) {
}, },
] ]
}); });
// $("#documents_list").html(contents);
})
.fail(function(xhr, status, error) {
// error handling
console.log('error document search', status);
}); });
} }
async function downloadDocument(id, name) { async function downloadDocument(id, name) {
let result; let result;
await fetch(DOCUMENT_DOWNLOAD_URL(id), { await fetch(DOCUMENT_DOWNLOAD_URL(id, company_id), {
headers: new Headers({ headers: new Headers({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': `Bearer ${token}` 'Authorization': `Bearer ${token}`
@ -206,8 +242,9 @@ async function deleteDocument(id, activity_id) {
callback: async function(result){ callback: async function(result){
// result is true / false; // result is true / false;
if (result) { if (result) {
console.log('download document', id);
const result = await axiosInstance const result = await axiosInstance
.delete(DOCUMENT_DELETE_URL(id)) .delete(DOCUMENT_DELETE_URL(id, company_id))
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

1
view-mode/function/ganttConfig.js

@ -3,6 +3,7 @@ const readOnly = getUrlParameter("ro");
const proyekId = getUrlParameter("proyek_id"); const proyekId = getUrlParameter("proyek_id");
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 adwIntegrationUrl = "https://adw-api.ospro.id/api"; const adwIntegrationUrl = "https://adw-api.ospro.id/api";
let userToVersionGanttId = 0 let userToVersionGanttId = 0

4
view-mode/function/ganttEvent.js

@ -19,6 +19,7 @@ gantt.attachEvent("onTaskRowClick", function(id,row){
gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function(state){ gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function(state){
let id = parseInt(state.id) let id = parseInt(state.id)
let ganttData = gantt.getTask(id); let ganttData = gantt.getTask(id);
// console.log("cek ganttData", ganttData);
if(ganttData.type_activity && ganttData.type_activity=="header"){ if(ganttData.type_activity && ganttData.type_activity=="header"){
return false return false
} }
@ -31,11 +32,13 @@ gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function(state){
} }
if(column=="cost_actual"){ if(column=="cost_actual"){
// let ganttData = gantt.getTask(id);
let progress = ganttData.progress ? ganttData.progress : 0 let progress = ganttData.progress ? ganttData.progress : 0
if(progress <= 0){ if(progress <= 0){
return false return false
} }
} }
// console.log("cek state", state);
return true return true
}); });
@ -61,6 +64,7 @@ gantt.attachEvent("onBeforeTaskUpdate", function(id,new_item){
gantt.attachEvent("onBeforeLinkAdd", function(id,link){ gantt.attachEvent("onBeforeLinkAdd", function(id,link){
//any custom logic here //any custom logic here
// console.log("cek link", link);
let source = link.source; let source = link.source;
let target = link.target; let target = link.target;
let parents = gantt.getParent(source); let parents = gantt.getParent(source);

36
view-mode/function/ganttSettings.js

@ -47,6 +47,9 @@ $(document).ready(function() {
selectDayOffChoices = new Choices('#select_dayoff', { selectDayOffChoices = new Choices('#select_dayoff', {
removeItemButton: true, removeItemButton: true,
shouldSort: false shouldSort: false
// maxItemCount: 5,
// searchResultLimit: 5,
// renderChoiceLimit: 5
}); });
$('#gantt_setting_btn').on('click', async function() { $('#gantt_setting_btn').on('click', async function() {
@ -54,9 +57,13 @@ $(document).ready(function() {
.get(VERSION_GANTT_EDIT_URL, HEADER) .get(VERSION_GANTT_EDIT_URL, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
// console.log("get version gantt result", result)
if(result && result.status==200){ if(result && result.status==200){
if (result.data && result.data.data) { if (result.data && result.data.data) {
var config_dayoff = null; var config_dayoff = null;
// console.log('result.data.data.config_dayoff', result.data.data.config_dayoff)
if (result.data.data.config_dayoff !== null) { if (result.data.data.config_dayoff !== null) {
config_dayoff = result.data.data.config_dayoff; config_dayoff = result.data.data.config_dayoff;
@ -65,13 +72,17 @@ $(document).ready(function() {
for (var i=0; i < config_dayoff_arr.length; i++) { for (var i=0; i < config_dayoff_arr.length; i++) {
var day = daysObj.find(o => parseInt(o.value) === parseInt(config_dayoff_arr[i])); var day = daysObj.find(o => parseInt(o.value) === parseInt(config_dayoff_arr[i]));
// $('#select_dayoff option[value='+day.value+']').prop("selected", true); // $('#select_dayoff option[value='+day.value+']').prop("selected", true);
// console.log('day', day);
selectDayOffChoices.setChoiceByValue(day.value); selectDayOffChoices.setChoiceByValue(day.value);
} }
} }
} }
} }
}else{ }else{
// closeDialog('failed upload')
console.log('failed get version gantt');
gantt.alert({type: "error", text: "Failed to get settings. Please check your internet connection."}); gantt.alert({type: "error", text: "Failed to get settings. Please check your internet connection."});
// alert('Upload failed');
} }
$('#modal_gantt_setting').modal('show'); $('#modal_gantt_setting').modal('show');
}); });
@ -92,7 +103,16 @@ $(document).ready(function() {
// } // }
var holidays = []; var holidays = [];
var dayoff = $('#select_dayoff').val(); var dayoff = $('#select_dayoff').val();
// console.log('dayoff', dayoff);
// if (dayoff.length < 1) return alert('Please add a day off');
dayoff = dayoff.map(item => parseInt(item)); dayoff = dayoff.map(item => parseInt(item));
// console.log('dayoff after', dayoff);
var workdays = _.difference(days, dayoff);
// console.log('workdays', workdays);
// getCurrentWorkdays();
// reset the dayoff first // reset the dayoff first
for (var i=0; i < days.length; i++) { for (var i=0; i < days.length; i++) {
gantt.unsetWorkTime({day: days[i], hours: false}); gantt.unsetWorkTime({day: days[i], hours: false});
@ -114,6 +134,8 @@ $(document).ready(function() {
// } // }
// } // }
// console.log('dayoff.length', dayoff.length);
if (dayoff.length > 0) { if (dayoff.length > 0) {
for (var i=0; i < dayoff.length; i++) { for (var i=0; i < dayoff.length; i++) {
gantt.setWorkTime({ day:dayoff[i], hours:false }); gantt.setWorkTime({ day:dayoff[i], hours:false });
@ -130,10 +152,13 @@ $(document).ready(function() {
let payload = { let payload = {
"config_dayoff": dayoff.join(',') "config_dayoff": dayoff.join(',')
} }
// console.log('payload', payload);
// console.log('HEADER', HEADER);
const result = await axiosInstance const result = await axiosInstance
.put(VERSION_GANTT_UPDATE_URL, payload, HEADER) .put(VERSION_GANTT_UPDATE_URL, payload, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
// console.log("update settings result", result)
if (result && result.status === 200) { if (result && result.status === 200) {
$('#modal_gantt_setting').modal('hide'); $('#modal_gantt_setting').modal('hide');
// gantt.alert("Settings updated"); // gantt.alert("Settings updated");
@ -183,6 +208,7 @@ async function initHolidays(){
url: `${base_url}holiday/search`, url: `${base_url}holiday/search`,
type: "POST", type: "POST",
success: function (result) { success: function (result) {
// console.log("cek data", result.data);
let dataHolidays = result.data || [] let dataHolidays = result.data || []
dataHolidays.map((val, index) => { dataHolidays.map((val, index) => {
// let day = moment(val.date).format("YYYY-MM-DD"); // let day = moment(val.date).format("YYYY-MM-DD");
@ -190,6 +216,7 @@ async function initHolidays(){
var b = moment(a).add(val.duration, 'days'); var b = moment(a).add(val.duration, 'days');
for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) { for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) {
let holiday = new Date(m.format('YYYY-MM-DD')); let holiday = new Date(m.format('YYYY-MM-DD'));
// console.log("cek holiday", holiday)
gantt.setWorkTime({ gantt.setWorkTime({
date: holiday, date: holiday,
hours: false hours: false
@ -210,6 +237,7 @@ async function initHolidays(){
} }
async function initGanttSettings() { async function initGanttSettings() {
console.log('initGanttSettings');
// if zoom is day // if zoom is day
$("#scale3").attr('checked', true); $("#scale3").attr('checked', true);
// toggleCollapseTasks(); // toggleCollapseTasks();
@ -242,6 +270,7 @@ async function initGanttSettings() {
} }
function expandTask(){ function expandTask(){
console.log("check expandTask")
gantt.eachTask(function(task){ gantt.eachTask(function(task){
task.$open = true; task.$open = true;
}); });
@ -255,16 +284,19 @@ function expandTask(){
function toggleCollapseTasks() { function toggleCollapseTasks() {
// collapse task / activity // collapse task / activity
console.log('toggleCollapseTasks');
gantt.eachTask(function(task){ gantt.eachTask(function(task){
task.$open = toggleTasks == "Expand"; task.$open = toggleTasks == "Expand";
}); });
if (toggleTasks == "Expand") { if (toggleTasks == "Expand") {
updateProperty({task_open:true}) updateProperty({task_open:true})
// console.log('to collapse');
toggleTasks = "Collapse"; toggleTasks = "Collapse";
$("#gantt_toggle_task_btn").prop('title', 'Collapse Activities'); $("#gantt_toggle_task_btn").prop('title', 'Collapse Activities');
$("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt'); $("#gantt_toggle_task_btn").children().removeClass('fa-expand-alt');
$("#gantt_toggle_task_btn").children().addClass('fa-compress-alt'); // change icon to collapse $("#gantt_toggle_task_btn").children().addClass('fa-compress-alt'); // change icon to collapse
} else { } else {
// console.log('to expand');
updateProperty({task_open:false}) updateProperty({task_open:false})
toggleTasks = "Expand"; toggleTasks = "Expand";
$("#gantt_toggle_task_btn").prop('title', 'Expand Activities'); $("#gantt_toggle_task_btn").prop('title', 'Expand Activities');
@ -280,6 +312,7 @@ function getColumnsSelection(node){
var selectedColumns = node.querySelectorAll(":checked"); var selectedColumns = node.querySelectorAll(":checked");
var unselectedColumn = node.querySelectorAll('input[type="checkbox"]:not(:checked)'); var unselectedColumn = node.querySelectorAll('input[type="checkbox"]:not(:checked)');
// var allSelected = node.querySelector("#check-all").prop('checked'); // var allSelected = node.querySelector("#check-all").prop('checked');
// console.log("unselectedColumn", unselectedColumn)
var checkedColumns = {}; var checkedColumns = {};
selectedColumns.forEach(function(node){ selectedColumns.forEach(function(node){
checkedColumns[node.name] = true; checkedColumns[node.name] = true;
@ -287,6 +320,7 @@ function getColumnsSelection(node){
unselectedColumn.forEach(function(node){ unselectedColumn.forEach(function(node){
checkedColumns[node.name] = false; checkedColumns[node.name] = false;
}); });
// console.log("checkedColumns", checkedColumns)
return checkedColumns; return checkedColumns;
} }
@ -370,6 +404,7 @@ async function setBaselineAPI() {
.get(ACTIVITY_SET_BASELINE_URL, HEADER) .get(ACTIVITY_SET_BASELINE_URL, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('set baseline res', res);
if (res && res.status === 200) { if (res && res.status === 200) {
// $('#modal_gantt_setting').modal('hide'); // $('#modal_gantt_setting').modal('hide');
// gantt.alert("Settings updated"); // gantt.alert("Settings updated");
@ -425,6 +460,7 @@ async function setSynchronizeAPI() {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('synchronize res', res);
if (res && res.status === 200) { if (res && res.status === 200) {
// $('#modal_gantt_setting').modal('hide'); // $('#modal_gantt_setting').modal('hide');
// gantt.alert("Settings updated"); // gantt.alert("Settings updated");

2
view-mode/function/holiday.js

@ -76,6 +76,7 @@ $(document).ready(function () {
var b = moment(a).add(data.duration, 'days'); var b = moment(a).add(data.duration, 'days');
for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) { for (var m = moment(a); m.isBefore(b); m.add(1, 'days')) {
let holiday = new Date(m.format('YYYY-MM-DD')); let holiday = new Date(m.format('YYYY-MM-DD'));
// console.log("cek holiday", holiday)
gantt.unsetWorkTime({ gantt.unsetWorkTime({
date: holiday, date: holiday,
hours:false hours:false
@ -90,6 +91,7 @@ $(document).ready(function () {
url: `${base_url}holiday/delete/${id}`, url: `${base_url}holiday/delete/${id}`,
type:"DELETE", type:"DELETE",
success: function (data) { success: function (data) {
// console.log("cek data", data.data);
gantt.alert("Delete Holiday Success!"); gantt.alert("Delete Holiday Success!");
tableHoliday.draw(); tableHoliday.draw();
if(data.data){ if(data.data){

4
view-mode/function/milestone.js

@ -1,5 +1,6 @@
var milestoneModal = $('#modal-add-milestone > .modal-dialog > .modal-content'); var milestoneModal = $('#modal-add-milestone > .modal-dialog > .modal-content');
function addMilestone(id){ function addMilestone(id){
console.log("cek cek id milestone", id);
if(id && id > 0){ if(id && id > 0){
$("#milestone_parent").val(id); $("#milestone_parent").val(id);
} }
@ -40,6 +41,7 @@ $(document).ready(function () {
processResults: function (result) { processResults: function (result) {
return { return {
results: $.map(result, function (item) { results: $.map(result, function (item) {
// console.log("cek item", item)
return { return {
due_date:item.due_date, due_date:item.due_date,
deadline:item.deadline, deadline:item.deadline,
@ -83,12 +85,14 @@ $(document).ready(function () {
$('#submit-milestone').html('Add..'); $('#submit-milestone').html('Add..');
$('#submit-milestone').prop("disabled",true); $('#submit-milestone').prop("disabled",true);
var data = Object.fromEntries(new FormData(this)); var data = Object.fromEntries(new FormData(this));
console.log("cek data form", data);
let parent = data.milestone_parent; let parent = data.milestone_parent;
var taskId = 0; var taskId = 0;
var start = moment(data.due_date, "YYYY-MM-DD"); var start = moment(data.due_date, "YYYY-MM-DD");
var end = moment(data.deadline, "YYYY-MM-DD"); var end = moment(data.deadline, "YYYY-MM-DD");
let duration = moment.duration(start.diff(end)).asDays(); let duration = moment.duration(start.diff(end)).asDays();
let nameMilestone = data.status!="" ? data.status : data.id_milestone let nameMilestone = data.status!="" ? data.status : data.id_milestone
// console.log("cek duration", Math.abs(duration));
if(parent && parseInt(parent) > 0){ if(parent && parseInt(parent) > 0){
taskId = gantt.addTask({ taskId = gantt.addTask({
id: Math.floor(Math.random() * 1000) + 5000, id: Math.floor(Math.random() * 1000) + 5000,

108
view-mode/function/modalHumanResourceFunction.js

@ -5,6 +5,9 @@ $(document).ready(function () {
let DATA_ROLE_HUMAN_RESOURCE = [] let DATA_ROLE_HUMAN_RESOURCE = []
let DATA_HUMAN_RESOURCE = [] let DATA_HUMAN_RESOURCE = []
let forbiddenHuman = []
// let DATA_MATERIAL_RESOURCE = []
// let DATA_TOOL_RESOURCE = []
function getDataHumanResource() { function getDataHumanResource() {
const url = `${base_url}human-resource/search` const url = `${base_url}human-resource/search`
const payload = { const payload = {
@ -12,6 +15,14 @@ $(document).ready(function () {
"start": 1, "start": 1,
"length": -1 "length": -1
}, },
"columns": [
// {
// "name": "proyek_id",
// "logic_operator": "like",
// "value": search,
// "operator": "AND"
// },
],
"orders": { "orders": {
"columns": [ "columns": [
"id" "id"
@ -19,8 +30,19 @@ $(document).ready(function () {
"ascending": false "ascending": false
} }
} }
// console.log("qry", qry)
axiosInstance.post(url, payload, HEADER).then(res => { axiosInstance.post(url, payload, HEADER).then(res => {
console.log('getDataHumanResource', res)
DATA_HUMAN_RESOURCE = res.data.data DATA_HUMAN_RESOURCE = res.data.data
// arr.forEach(function (element, key) {
// $('#choices-multiple-remove-button1').append(`<option value="${element.id}">${element.name}</option>`)
// });
// var multipleCancelButton = new Choices('#choices-multiple-remove-button1', {
// removeItemButton: true,
// // maxItemCount: 5,
// // searchResultLimit: 5,
// // renderChoiceLimit: 5
// });
}); });
} }
@ -34,14 +56,89 @@ $(document).ready(function () {
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
// console.log("qry", qry)
axiosInstance.post(url, payload, HEADER).then(res => { axiosInstance.post(url, payload, HEADER).then(res => {
console.log(res)
DATA_ROLE_HUMAN_RESOURCE = res.data.data DATA_ROLE_HUMAN_RESOURCE = res.data.data
}); });
} }
// getDataHumanResource()
// function getDataMaterials() {
// const url = `${base_url}request-material/search`
// const payload = {
// "paging": {
// "start": 0,
// "length": -1
// },
// "columns": [
// {
// "name": "proyek_id",
// "logic_operator": "=",
// "value": "6",
// "operator": "AND"
// },
// {
// "name": "status",
// "logic_operator": "=",
// "value": "receipt to site",
// "operator": "AND"
// }
// ],
// "orders": {
// "columns": [
// "id"
// ],
// "ascending": false
// }
// }
// axiosInstance.post(url, payload, HEADER).then(res => {
// console.log(res)
// DATA_MATERIAL_RESOURCE = res.data.data
// });
// }
// function getDataTools() {
// const url = `${base_url}req-tools/search`
// const payload = {
// "paging": {
// "start": 0,
// "length": -1
// },
// "columns": [
// {
// "name": "status",
// "logic_operator": "=",
// "value": "receipt to site",
// "operator": "AND"
// }
// ],
// "orders": {
// "columns": [
// "id"
// ],
// "ascending": false
// }
// }
// axiosInstance.post(url, payload, HEADER).then(res => {
// console.log(res)
// const arr = res.data.data
// DATA_TOOL_RESOURCE = res.data.data
// arr.forEach(function (element, key) {
// $('#choices-multiple-remove-button3').append(`<option value="${element.id}">${element.name}</option>`)
// });
// var multipleCancelButton = new Choices('#choices-multiple-remove-button3', {
// removeItemButton: true
// });
// });
// }
$('#human-resource').on('show.bs.modal', function (event) { $('#human-resource').on('show.bs.modal', function (event) {
// console.log("open modal human resource")
getDataHumanResource() getDataHumanResource()
getDataRole() getDataRole()
// getDataMaterials()
// getDataTools()
}); });
$('#human-resource').on('hide.bs.modal', function (event) { $('#human-resource').on('hide.bs.modal', function (event) {
@ -52,6 +149,7 @@ $(document).ready(function () {
$("#add-human-resource").on('click', function () { $("#add-human-resource").on('click', function () {
const num = $('#table-human-resource tr').length const num = $('#table-human-resource tr').length
console.log(num)
const idx = num + 1 const idx = num + 1
$('#table-human-resource').append(` $('#table-human-resource').append(`
<tr id="row-human-resource-${idx}"> <tr id="row-human-resource-${idx}">
@ -84,11 +182,13 @@ $(document).ready(function () {
$('#table-human-resource').on('click', '.human-resource-delete', function (event) { $('#table-human-resource').on('click', '.human-resource-delete', function (event) {
const idx = $(this).attr("index") const idx = $(this).attr("index")
console.log(idx)
$(`#row-human-resource-${idx}`).remove() $(`#row-human-resource-${idx}`).remove()
}) })
// $("#add-material-resource").on('click', function () { // $("#add-material-resource").on('click', function () {
// const num = $('#table-material-resource tr').length // const num = $('#table-material-resource tr').length
// console.log(num)
// const idx = num + 1 // const idx = num + 1
// $('#table-material-resource').append(` // $('#table-material-resource').append(`
// <tr id="row-material-resource-${idx}"> // <tr id="row-material-resource-${idx}">
@ -116,11 +216,13 @@ $(document).ready(function () {
// $('#table-material-resource').on('click', '#material-resource-delete', function (event) { // $('#table-material-resource').on('click', '#material-resource-delete', function (event) {
// const idx = $(this).attr("index") // const idx = $(this).attr("index")
// console.log(idx)
// $(`#row-material-resource-${idx}`).remove() // $(`#row-material-resource-${idx}`).remove()
// }) // })
// $("#add-tool-resource").on('click', function () { // $("#add-tool-resource").on('click', function () {
// const num = $('#table-tool-resource tr').length // const num = $('#table-tool-resource tr').length
// console.log(num)
// const idx = num + 1 // const idx = num + 1
// $('#table-tool-resource').append(` // $('#table-tool-resource').append(`
// <tr id="row-tool-resource-${idx}"> // <tr id="row-tool-resource-${idx}">
@ -148,11 +250,13 @@ $(document).ready(function () {
// $('#table-tool-resource').on('click', '#tool-resource-delete', function (event) { // $('#table-tool-resource').on('click', '#tool-resource-delete', function (event) {
// const idx = $(this).attr("index") // const idx = $(this).attr("index")
// console.log(idx)
// $(`#row-tool-resource-${idx}`).remove() // $(`#row-tool-resource-${idx}`).remove()
// }) // })
$(".submit-human-resource").on('click', function () { $(".submit-human-resource").on('click', function () {
console.log('onclick submit human resource');
// addComments(); // addComments();
let valueHumanResource = [] let valueHumanResource = []
const num = $('#table-human-resource tr').length const num = $('#table-human-resource tr').length
@ -165,6 +269,7 @@ $(document).ready(function () {
} }
valueHumanResource.push(obj) valueHumanResource.push(obj)
} }
console.log("cek value", valueHumanResource)
// let valueMaterialResource = [] // let valueMaterialResource = []
// const numMaterial = $('#table-material-resource tr').length // const numMaterial = $('#table-material-resource tr').length
@ -177,6 +282,7 @@ $(document).ready(function () {
// } // }
// valueMaterialResource.push(obj) // valueMaterialResource.push(obj)
// } // }
// console.log(valueMaterialResource)
// let valueToolResource = [] // let valueToolResource = []
// const numTool = $('#table-tool-resource tr').length // const numTool = $('#table-tool-resource tr').length
@ -189,9 +295,11 @@ $(document).ready(function () {
// } // }
// valueToolResource.push(obj) // valueToolResource.push(obj)
// } // }
// console.log(valueToolResource)
// const cost = $(`#cost-human-resource`).val() // const cost = $(`#cost-human-resource`).val()
// const duration = $(`#duration-human-resource`).val() // const duration = $(`#duration-human-resource`).val()
// const dateStart = $(`#date-started-human-started`).val() // const dateStart = $(`#date-started-human-started`).val()
// console.log({ cost, duration, dateStart })
// $("#exampleModal").modal('hide'); // $("#exampleModal").modal('hide');
}); });

1
view-mode/function/overlaySCurve.js

@ -98,6 +98,7 @@ function getChartScaleRange() {
function getProgressLine() { function getProgressLine() {
// As long as the progress data length is same with chart scale range (period) then it's fine. // As long as the progress data length is same with chart scale range (period) then it's fine.
getSCurveData(); getSCurveData();
// console.log("apa ", return_first);
var cumulativePlannedDurations = return_first.data[0].data.percentagePlan; var cumulativePlannedDurations = return_first.data[0].data.percentagePlan;
var cumulativeRealDurations = return_first.data[0].data.percentageReal; var cumulativeRealDurations = return_first.data[0].data.percentageReal;
cumulativeRealDurations[cumulativeRealDurations.length - 1] = Math.ceil(cumulativeRealDurations[cumulativeRealDurations.length - 1]); cumulativeRealDurations[cumulativeRealDurations.length - 1] = Math.ceil(cumulativeRealDurations[cumulativeRealDurations.length - 1]);

3
view-mode/function/reportActivity.js

@ -50,16 +50,19 @@ $(document).ready(function () {
{ data: 'uom', name: 'uom' }, { data: 'uom', name: 'uom' },
{ {
data: 'start_activity', render: function (data, type) { data: 'start_activity', render: function (data, type) {
console.log("start", data)
return data ? formatDate(data) : '-' return data ? formatDate(data) : '-'
} }
}, },
{ {
data: 'finish_activity', render: function (data, type) { data: 'finish_activity', render: function (data, type) {
console.log("finish", data)
return data ? formatDate(data) : '-' return data ? formatDate(data) : '-'
} }
}, },
{ {
data: 'status_activity', render: function (data, type) { data: 'status_activity', render: function (data, type) {
console.log("status", data)
const val = !data ? '-' : const val = !data ? '-' :
data == "done" ? `<span class="badge badge-success">${data}</span>` : data == "done" ? `<span class="badge badge-success">${data}</span>` :
data == "open" ? `<span class="badge badge-primary">${data}</span>` : data == "open" ? `<span class="badge badge-primary">${data}</span>` :

33
view-mode/function/restActivityLink.js

@ -5,6 +5,7 @@ window.parent.postMessage({ action: 'getUrl' }, '*');
window.addEventListener('message', function(event) { window.addEventListener('message', function(event) {
if (event.data && event.data.action === 'sendUrl') { if (event.data && event.data.action === 'sendUrl') {
const parentUrl = event.data.url; const parentUrl = event.data.url;
// Split the remaining path by "/" // Split the remaining path by "/"
parts = parentUrl.split("/"); parts = parentUrl.split("/");
} }
@ -23,10 +24,13 @@ gantt.ajax.get({
data['links'] = obj.data.links; data['links'] = obj.data.links;
// check if baseline has been set // check if baseline has been set
if (data.data && data.data.length > 0) { if (data.data && data.data.length > 0) {
console.log('baseline', data.data[0].planned_start);
if (data.data[0].planned_start !== null && data.data[0].planned_end !== null) { if (data.data[0].planned_start !== null && data.data[0].planned_end !== null) {
console.log('baseline set');
isBaselineSet = true; isBaselineSet = true;
} }
else { else {
console.log('baseline has not been set');
isBaselineSet = false; isBaselineSet = false;
} }
} }
@ -54,6 +58,7 @@ function refresData(id){
let obj = JSON.parse(response); let obj = JSON.parse(response);
data['data'] = obj.data.data; data['data'] = obj.data.data;
data['links'] = obj.data.links; data['links'] = obj.data.links;
// console.log("data parse wrong", data);
if(!parts[7]){ if(!parts[7]){
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
@ -99,17 +104,21 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
}).then(function(response){ }).then(function(response){
let res = response.responseText let res = response.responseText
res = JSON.parse(res) res = JSON.parse(res)
// console.log("cek response", res)
if(entity=="link"){ if(entity=="link"){
gantt.changeLinkId(id, res.tid); gantt.changeLinkId(id, res.tid);
}else if(entity=="task"){ }else if(entity=="task"){
gantt.changeTaskId(id, res.tid); gantt.changeTaskId(id, res.tid);
} }
// refresData();
}); });
break; break;
case "update": case "update":
if(entity=="task"){ if(entity=="task"){
data['start_date'] = moment(data.start_date).format("YYYY-MM-DD HH:mm:ss+07"); data['start_date'] = moment(data.start_date).format("YYYY-MM-DD HH:mm:ss+07");
data['end_date'] = moment(data.end_date).format("YYYY-MM-DD HH:mm:ss+07"); data['end_date'] = moment(data.end_date).format("YYYY-MM-DD HH:mm:ss+07");
// data['planned_start'] = moment(data.planned_start).format("YYYY-MM-DD HH:mm:ss+07");
// data['planned_end'] = moment(data.planned_end).format("YYYY-MM-DD HH:mm:ss+07");
if(data && data.parent){ if(data && data.parent){
data['parent_id'] = data.parent; data['parent_id'] = data.parent;
@ -121,6 +130,9 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
} }
}); });
} }
// console.log("cek data update", data)
// let dataProgress = parseInt(data.progress)
// dataProgress = dataProgress/100
return gantt.ajax.put({ return gantt.ajax.put({
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -133,6 +145,7 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
let parent = data.parent; let parent = data.parent;
let responseText = JSON.parse(response.responseText) let responseText = JSON.parse(response.responseText)
let resData = responseText let resData = responseText
// console.log("dataRes", resData);
let updateBobot = resData.update_bobot || false let updateBobot = resData.update_bobot || false
if(updateBobot){ if(updateBobot){
refresData(id); refresData(id);
@ -141,11 +154,25 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
updateActivity(parent); updateActivity(parent);
} }
} }
// console.log("data", data);
// refresData();
// if(resData && resData.rencana_biaya){
// if(data.rencana_biaya != resData.rencana_biaya){
// // gantt.getTask(id).bobot_planning = resData.bobot_planning;
// // gantt.updateTask(id);
// }else{
// if(parent && parent > 0){
// updateActivity(parent);
// }
// }
// }
} }
}); });
break; break;
case "delete": case "delete":
// console.log("cek data", data)
return gantt.ajax.del({ return gantt.ajax.del({
headers: { headers: {
"Authorization": `Bearer ${token}` "Authorization": `Bearer ${token}`
@ -166,7 +193,13 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
} }
} }
} }
// console.log("cek data delete", data)
} }
// let res = response.responseText
// res = JSON.parse(res)
// console.log("cek response", res)
// refresData();
}); });
break; break;
} }

2
view-mode/function/toolsResource.js

@ -88,6 +88,7 @@ $(document).ready(function () {
processResults: function (result) { processResults: function (result) {
return { return {
results: $.map(result, function (item) { results: $.map(result, function (item) {
// console.log("cek item", item)
return { return {
text: item.name, text: item.name,
id: item.id id: item.id
@ -136,6 +137,7 @@ $(document).ready(function () {
processData: false, processData: false,
contentType: false, contentType: false,
success: function (data) { success: function (data) {
console.log('response data', data);
if (data && data.code === 200) { if (data && data.code === 200) {
actionHappen = true; actionHappen = true;
gantt.alert("Tools Assign Success!"); gantt.alert("Tools Assign Success!");

Loading…
Cancel
Save