|
|
|
@ -24,6 +24,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
const [dataTable, setDatatable] = useState([]); |
|
|
|
|
const [dataTableActivityToHr, setDataTableActivityToHr] = useState([]); |
|
|
|
|
const [hrList, setHrList] = useState([]); |
|
|
|
|
const [groupedActivity, setGroupedActivity] = useState([]); |
|
|
|
|
const [selectedHr, setSelectedHr] = useState(null); |
|
|
|
|
|
|
|
|
|
const toggle = (tab) => { |
|
|
|
@ -102,6 +103,23 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
getDataHr() |
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (projectId) { |
|
|
|
|
getGroupedActivity() |
|
|
|
|
getDataHr() |
|
|
|
|
} |
|
|
|
|
}, [projectId]); |
|
|
|
|
|
|
|
|
|
const handleClose = () => { |
|
|
|
|
setAvgActivityHr(0); |
|
|
|
|
setSelectedHr(null); |
|
|
|
|
setDataTableActivityToHr([]); |
|
|
|
|
setAvgActivity(0); |
|
|
|
|
setSearch(''); |
|
|
|
|
setDatatable([]) |
|
|
|
|
closeDialog() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleSearch = (e) => { |
|
|
|
|
const value = e.target.value; |
|
|
|
|
setSearch(value); |
|
|
|
@ -131,8 +149,27 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const getDataHr = async () => { |
|
|
|
|
const payload = { |
|
|
|
|
columns: [ |
|
|
|
|
{ |
|
|
|
|
name: "proyek_id", |
|
|
|
|
logic_operator: "=", |
|
|
|
|
value: projectId, |
|
|
|
|
operator: "AND", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
joins: [ |
|
|
|
|
{ |
|
|
|
|
name: "m_users", |
|
|
|
|
column_join: "user_id", |
|
|
|
|
column_results: ["id", "name"] |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
orders: { columns: ["id"], ascending: false }, |
|
|
|
|
paging: { start: 0, length: -1 }, |
|
|
|
|
}; |
|
|
|
|
const result = await axios |
|
|
|
|
.get(`${BASE_SIMPRO_LUMEN}/human-resource/list`, HEADER) |
|
|
|
|
.post(`${BASE_SIMPRO_LUMEN}/user-to-proyek/search`, payload, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
@ -209,6 +246,33 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const getGroupedActivity = async () => { |
|
|
|
|
const payload = { |
|
|
|
|
columns: [ |
|
|
|
|
{ |
|
|
|
|
name: "proyek_id", |
|
|
|
|
logic_operator: "=", |
|
|
|
|
value: projectId, |
|
|
|
|
operator: "AND", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
orders: { columns: ["id"], ascending: false }, |
|
|
|
|
paging: { start: 0, length: -1 }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
.post(`${BASE_SIMPRO_LUMEN}/activity/search-analysis-prep`, payload, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
let dataRes = result.data.data || []; |
|
|
|
|
setGroupedActivity(dataRes); |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const getDataActivity = async () => { |
|
|
|
|
setAvgActivity(0); |
|
|
|
|
let sum = 0; |
|
|
|
@ -216,7 +280,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
columns: [ |
|
|
|
|
{ |
|
|
|
|
name: "name", |
|
|
|
|
logic_operator: "ilike", |
|
|
|
|
logic_operator: "=", |
|
|
|
|
value: search, |
|
|
|
|
operator: "AND", |
|
|
|
|
}, |
|
|
|
@ -251,7 +315,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
<Modal size="xl" isOpen={openDialog} toggle={toggleDialog}> |
|
|
|
|
<ModalHeader className="capitalize" toggle={closeDialog}>Report Analysis</ModalHeader> |
|
|
|
|
<ModalHeader className="capitalize" toggle={handleClose}>Report Analysis</ModalHeader> |
|
|
|
|
<ModalBody> |
|
|
|
|
<div> |
|
|
|
|
<Nav tabs> |
|
|
|
@ -282,15 +346,13 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
<CardHeader> |
|
|
|
|
<Row> |
|
|
|
|
<Col> |
|
|
|
|
<Input |
|
|
|
|
onChange={handleSearch} |
|
|
|
|
value={search} |
|
|
|
|
type="text" |
|
|
|
|
name="search" |
|
|
|
|
id="search" |
|
|
|
|
placeholder={`Search Activity Name`} |
|
|
|
|
style={{ width: 200 }} |
|
|
|
|
/> |
|
|
|
|
<Select showSearch value={search} onChange={(val) => setSearch(val)} placeholder="Select Activity" filterOption={(input, option) => |
|
|
|
|
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 |
|
|
|
|
} style={{ width: 200 }}> |
|
|
|
|
{groupedActivity && groupedActivity.map((res, index) => ( |
|
|
|
|
<Option key={index} value={res.name}>{`${res.name}`}</Option> |
|
|
|
|
))} |
|
|
|
|
</Select> |
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
|
</CardHeader> |
|
|
|
@ -321,7 +383,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 |
|
|
|
|
} style={{ width: 200 }}> |
|
|
|
|
{hrList && hrList.map(res => ( |
|
|
|
|
<Option key={res.id} value={res.id}>{`${res.name}`}</Option> |
|
|
|
|
<Option key={res.join_first_id} value={res.join_first_id}>{`${res.join_first_name}`}</Option> |
|
|
|
|
))} |
|
|
|
|
</Select> |
|
|
|
|
</Col> |
|
|
|
@ -342,7 +404,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
|
|
|
|
|
</div> |
|
|
|
|
</ModalBody> |
|
|
|
|
<ModalFooter> |
|
|
|
|
<Button color="primary" onClick={closeDialog}>Close</Button> |
|
|
|
|
<Button color="primary" onClick={handleClose}>Close</Button> |
|
|
|
|
</ModalFooter> |
|
|
|
|
</Modal> |
|
|
|
|
<DialogFormAnalysis |
|
|
|
|