Browse Source

update report analysis

pull/1/head
farhantock 10 months ago
parent
commit
29c620d242
  1. 265
      src/views/SimproV2/CreatedProyek/ReportAnalysis.js

265
src/views/SimproV2/CreatedProyek/ReportAnalysis.js

@ -1,4 +1,4 @@
import React, {useState, useEffect} from 'react' import React, { useState, useEffect } from 'react'
import { import {
Modal, Modal,
ModalHeader, ModalHeader,
@ -73,67 +73,76 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
}; };
const columns = [ const columns = [
{title: "Gantt", dataIndex: "name_version", key: "name_version"}, { title: "Gantt", dataIndex: "name_version", key: "name_version" },
{title: "Baseline Start", dataIndex: "planned_start", key: "planned_start", {
title: "Baseline Start", dataIndex: "planned_start", key: "planned_start",
render: (text, record) => ( render: (text, record) => (
<> <>
{record.planned_start ? moment(record.planned_start).format("DD-MM-YY") : ''} {record.planned_start ? moment(record.planned_start).format("DD-MM-YY") : ''}
</> </>
), ),
}, },
{title: "Baseline Finish", dataIndex: "planned_end", key: "planned_end", {
title: "Baseline Finish", dataIndex: "planned_end", key: "planned_end",
render: (text, record) => ( render: (text, record) => (
<> <>
{record.planned_end ? moment(record.planned_end).format("DD-MM-YY") : ''} {record.planned_end ? moment(record.planned_end).format("DD-MM-YY") : ''}
</> </>
), ),
}, },
{title: "Early Start", dataIndex: "start_date", key: "start_date", {
title: "Early Start", dataIndex: "start_date", key: "start_date",
render: (text, record) => ( render: (text, record) => (
<> <>
{moment(record.start_date).format("DD-MM-YY")} {moment(record.start_date).format("DD-MM-YY")}
</> </>
), ),
}, },
{title: "Early Finish", dataIndex: "end_date", key: "end_date", {
title: "Early Finish", dataIndex: "end_date", key: "end_date",
render: (text, record) => ( render: (text, record) => (
<> <>
{moment(record.end_date).format("DD-MM-YY")} {moment(record.end_date).format("DD-MM-YY")}
</> </>
), ),
}, },
{title: "Actual Start", dataIndex: "actual_start", key: "actual_start", {
title: "Actual Start", dataIndex: "actual_start", key: "actual_start",
render: (text, record) => ( render: (text, record) => (
<> <>
{record.actual_start ? moment(record.actual_start).format("DD-MM-YY") : ""} {record.actual_start ? moment(record.actual_start).format("DD-MM-YY") : ""}
</> </>
), ),
}, },
{title: "Actual Finish", dataIndex: "actual_end", key: "actual_end", {
title: "Actual Finish", dataIndex: "actual_end", key: "actual_end",
render: (text, record) => ( render: (text, record) => (
<> <>
{record.actual_end ? moment(record.actual_end).format("DD-MM-YY") : ""} {record.actual_end ? moment(record.actual_end).format("DD-MM-YY") : ""}
</> </>
), ),
}, },
{title: "Assign HR", dataIndex: "user_name", key: "user_name", width: "8%", {
ellipsis:{ title: "Assign HR", dataIndex: "user_name", key: "user_name", width: "8%",
showTitle: true ellipsis: {
}, showTitle: true
render: (text) => },
<Tooltip placement="topLeft" title={text}> render: (text) =>
{text} <Tooltip placement="topLeft" title={text}>
</Tooltip> {text}
</Tooltip>
}, },
{title: "Volume Plan", dataIndex: "qty_planning", key: "qty_planning", {
render: (text, record) => title: "Volume Plan", dataIndex: "qty_planning", key: "qty_planning",
<> render: (text, record) =>
{text ? text : 0} <>
</> {text ? text : 0}
</>
}, },
{title: "Volume Actual", dataIndex: "qty", key: "qty"}, { title: "Volume Actual", dataIndex: "qty", key: "qty" },
{title: "Progress Plan (%)", dataIndex: "persentase_progress", key: "persentase_progress", {
render: (text, record) => { title: "Progress Plan (%)", dataIndex: "persentase_progress", key: "persentase_progress",
render: (text, record) => {
const startDate = moment(record.start_date); const startDate = moment(record.start_date);
const duration = record.duration; const duration = record.duration;
@ -148,7 +157,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
); );
}, },
}, },
{title: "Progress Actual (%)", dataIndex: "persentase_progress", key: "persentase_progress", width: "8%"}, { title: "Progress Actual (%)", dataIndex: "persentase_progress", key: "persentase_progress", width: "8%" },
{ {
title: 'Action', title: 'Action',
dataIndex: '', dataIndex: '',
@ -165,59 +174,67 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
] ]
const columnActivityToHr = [ const columnActivityToHr = [
{title: "Activity", dataIndex: "join_second_name", key: "join_second_name"}, { title: "Activity", dataIndex: "join_second_name", key: "join_second_name" },
{title: "Gantt", dataIndex: "join_fourth_name_version", key: "join_fourth_name_version"}, { title: "Gantt", dataIndex: "join_fourth_name_version", key: "join_fourth_name_version" },
{title: "Baseline Start", dataIndex: "join_second_planned_start", key: "join_second_planned_start", {
title: "Baseline Start", dataIndex: "join_second_planned_start", key: "join_second_planned_start",
render: (text, record) => ( render: (text, record) => (
<> <>
{moment(record.join_second_planned_start).format("DD-MM-YY")} {moment(record.join_second_planned_start).format("DD-MM-YY")}
</> </>
), ),
}, },
{title: "Baseline Finish", dataIndex: "join_second_planned_end", key: "join_second_planned_end", {
title: "Baseline Finish", dataIndex: "join_second_planned_end", key: "join_second_planned_end",
render: (text, record) => ( render: (text, record) => (
<> <>
{moment(record.join_second_planned_end).format("DD-MM-YY")} {moment(record.join_second_planned_end).format("DD-MM-YY")}
</> </>
), ),
}, },
{title: "Early Start", dataIndex: "join_second_start_date", key: "join_second_start_date", {
title: "Early Start", dataIndex: "join_second_start_date", key: "join_second_start_date",
render: (text, record) => ( render: (text, record) => (
<> <>
{moment(record.join_second_start_date).format("DD-MM-YY")} {moment(record.join_second_start_date).format("DD-MM-YY")}
</> </>
), ),
}, },
{title: "Early Finish", dataIndex: "join_second_end_date", key: "join_second_end_date", {
title: "Early Finish", dataIndex: "join_second_end_date", key: "join_second_end_date",
render: (text, record) => ( render: (text, record) => (
<> <>
{moment(record.join_second_end_date).format("DD-MM-YY")} {moment(record.join_second_end_date).format("DD-MM-YY")}
</> </>
), ),
}, },
{title: "Actual Start", dataIndex: "join_second_actual_start", key: "join_second_actual_start", {
title: "Actual Start", dataIndex: "join_second_actual_start", key: "join_second_actual_start",
render: (text, record) => ( render: (text, record) => (
<> <>
{record.join_second_actual_start ? moment(record.join_second_actual_start).format("DD-MM-YY") : ""} {record.join_second_actual_start ? moment(record.join_second_actual_start).format("DD-MM-YY") : ""}
</> </>
), ),
}, },
{title: "Actual Finish", dataIndex: "join_second_actual_end", key: "join_second_actual_end", {
title: "Actual Finish", dataIndex: "join_second_actual_end", key: "join_second_actual_end",
render: (text, record) => ( render: (text, record) => (
<> <>
{record.join_second_actual_end ? moment(record.join_second_actual_end).format("DD-MM-YY") : ""} {record.join_second_actual_end ? moment(record.join_second_actual_end).format("DD-MM-YY") : ""}
</> </>
), ),
}, },
{title: "Volume Plan", dataIndex: "join_third_qty_planning", key: "join_third_qty_planning", {
render: (text, record) => title: "Volume Plan", dataIndex: "join_third_qty_planning", key: "join_third_qty_planning",
<> render: (text, record) =>
{text ? text : 0} <>
</> {text ? text : 0}
</>
}, },
{title: "Volume Actual", dataIndex: "volume_actual", key: "volume_actual"}, { title: "Volume Actual", dataIndex: "volume_actual", key: "volume_actual" },
{title: "Progress Plan (%)", dataIndex: "join_second_persentase_progress", key: "persentase_progress", {
render: (text, record) => { title: "Progress Plan (%)", dataIndex: "join_second_persentase_progress", key: "persentase_progress",
render: (text, record) => {
const startDate = moment(record.join_second_start_date); const startDate = moment(record.join_second_start_date);
const duration = record.join_second_duration; const duration = record.join_second_duration;
@ -232,20 +249,20 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
); );
}, },
}, },
{title: "Progress Actual (%)", dataIndex: "join_second_persentase_progress", key: "persentase_progress"}, { title: "Progress Actual (%)", dataIndex: "join_second_persentase_progress", key: "persentase_progress" },
{ {
title: 'Action', title: 'Action',
dataIndex: '', dataIndex: '',
key: 'id', key: 'id',
className: "nowrap", className: "nowrap",
render: (text, record) => render: (text, record) =>
<> <>
<Tooltip title="Detail Activity"> <Tooltip title="Detail Activity">
<Button size={"sm"} color='primary' onClick={() => handleDetail(text)}><i className="fa fa-eye"></i></Button> <Button size={"sm"} color='primary' onClick={() => handleDetail(text)}><i className="fa fa-eye"></i></Button>
</Tooltip>{" "} </Tooltip>{" "}
</> </>
, ,
}, },
] ]
useEffect(() => { useEffect(() => {
@ -297,10 +314,10 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
if (status == "Save") { if (status == "Save") {
// getdataGantt() // getdataGantt()
NotificationManager.success(`Gantt berhasil dibuat!`, 'Success!!'); NotificationManager.success(`Gantt berhasil dibuat!`, 'Success!!');
}else if (status == "Edit") { } else if (status == "Edit") {
// getdataGantt() // getdataGantt()
NotificationManager.success(`Gantt berhasil dibubah!`, 'Failed!!'); NotificationManager.success(`Gantt berhasil dibubah!`, 'Failed!!');
}else if (status == "failed") { } else if (status == "failed") {
NotificationManager.error(`Gantt gagal dibuat!`, 'Failed!!'); NotificationManager.error(`Gantt gagal dibuat!`, 'Failed!!');
} }
setDataDetail(null) setDataDetail(null)
@ -338,7 +355,21 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || []; let dataRes = result.data.data || [];
setHrList(dataRes); let groupedData = {};
dataRes.forEach(data => {
if (groupedData[data.join_first_name]) {
groupedData[data.join_first_name].join_first_id = Math.min(groupedData[data.join_first_name].join_first_id, data.join_first_id);
} else {
groupedData[data.join_first_name] = {
join_first_id: data.join_first_id,
join_first_name: data.join_first_name
};
}
});
let dataFiltered = Object.values(groupedData);
setHrList(dataFiltered);
} else { } else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); NotificationManager.error("Gagal Mengambil Data!!", "Failed");
} }
@ -382,21 +413,21 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
name1: "m_activity", name1: "m_activity",
name: "assign_material_to_activity", name: "assign_material_to_activity",
column_join: "id", column_join: "id",
column_self:"activity_id", column_self: "activity_id",
column_results: ["id", "qty_planning"] column_results: ["qty_planning"]
}, },
{ {
name1: "m_activity", name1: "m_activity",
name: "m_version_gantt", name: "m_version_gantt",
column_join: "version_gantt_id", column_join: "version_gantt_id",
column_self:"id", column_self: "id",
column_results: ["name_version"] column_results: ["name_version"]
}, },
{ {
name1: "m_activity", name1: "m_activity",
name: "report_activity_material", name: "report_activity_material",
column_join: "id", column_join: "id",
column_self:"activity_id", column_self: "activity_id",
}, },
], ],
orders: { columns: ["id"], ascending: false }, orders: { columns: ["id"], ascending: false },
@ -411,7 +442,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || []; let dataRes = result.data.data || [];
dataRes.forEach(element => { dataRes.forEach(element => {
element.join_third_persentase_progress ? sum += parseInt(element.join_third_persentase_progress) : sum += 0; element.join_third_persentase_progress ? sum += parseInt(element.join_third_persentase_progress) : sum += 0;
}); });
setAvgActivityHr(sum / dataRes.length); setAvgActivityHr(sum / dataRes.length);
setDataTableActivityToHr(dataRes); setDataTableActivityToHr(dataRes);
@ -485,9 +516,9 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
let dataRes = result.data.data || []; let dataRes = result.data.data || [];
dataRes.forEach(element => { dataRes.forEach(element => {
element.persentase_progress ? sum += parseInt(element.persentase_progress) : sum += 0; element.persentase_progress ? sum += parseInt(element.persentase_progress) : sum += 0;
element.qty_planning ? sumPlan += parseInt(element.qty_planning) : sumPlan += 0; element.qty_planning ? sumPlan += parseInt(element.qty_planning) : sumPlan += 0;
element.qty ? sumAct += parseInt(element.qty) : sumAct += 0; element.qty ? sumAct += parseInt(element.qty) : sumAct += 0;
}); });
setAvgActivity(sum / dataRes.length); setAvgActivity(sum / dataRes.length);
setSumVolPlan(sumPlan); setSumVolPlan(sumPlan);
@ -536,9 +567,9 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
<Select showSearch value={search} onChange={(val) => setSearch(val)} placeholder="Select Activity" filterOption={(input, option) => <Select showSearch value={search} onChange={(val) => setSearch(val)} placeholder="Select Activity" filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
} style={{ width: 200 }}> } style={{ width: 200 }}>
{groupedActivity && groupedActivity.map((res, index) => ( {groupedActivity && groupedActivity.map((res, index) => (
<Option key={index} value={res.name}>{`${res.name}`}</Option> <Option key={index} value={res.name}>{`${res.name}`}</Option>
))} ))}
</Select> </Select>
</Col> </Col>
</Row> </Row>
@ -573,9 +604,9 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
<Select showSearch value={selectedHr} onChange={(val) => setSelectedHr(val)} placeholder="Select Human Resource" filterOption={(input, option) => <Select showSearch value={selectedHr} onChange={(val) => setSelectedHr(val)} placeholder="Select Human Resource" filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
} style={{ width: 200 }}> } style={{ width: 200 }}>
{hrList && hrList.map(res => ( {hrList && hrList.map(res => (
<Option key={res.join_first_id} value={res.join_first_id}>{`${res.join_first_name}`}</Option> <Option key={res.join_first_id} value={res.join_first_id}>{`${res.join_first_name}`}</Option>
))} ))}
</Select> </Select>
</Col> </Col>
</Row> </Row>

Loading…
Cancel
Save