From cb2a2c1dd270e59e2cc876f7c1afcc327375069f Mon Sep 17 00:00:00 2001 From: wahyun Date: Mon, 19 Feb 2024 17:06:41 +0700 Subject: [PATCH 1/5] add endpoint --- src/const/ApiConst.js | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js index f8ef23b..8d48366 100644 --- a/src/const/ApiConst.js +++ b/src/const/ApiConst.js @@ -122,6 +122,9 @@ export let BASE_OSPRO = "http://localhost:8444/generic-ospro-backend"; export let BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; export let BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; export let BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; +export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file, company_name)=>{ + return `${BASE_OSPRO}/assets/${company_name}/file/project/${file}`; +} // switch (APP_MODE) { // case 'KIT': @@ -281,6 +284,10 @@ export const USER_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/human-resource/delete/${id}`; }; +export const HUMAN_RESOURCE_LIST = `${BASE_SIMPRO_LUMEN}/human-resource` +export const USER_TO_ACTIVITY_ADD = `${BASE_SIMPRO_LUMEN}/user-to-activity/add` +export const USER_TO_ACTIVITY_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-activity/delete/${id}` } + export const ABSENSI_ADD = `${BASE_SIMPRO_LUMEN}/permit/add`; export const ABSENSI_SEARCH = `${BASE_SIMPRO_LUMEN}/permit/search`; export const ABSENSI_EDIT = (id) => { @@ -307,11 +314,11 @@ export const DOCUMENT_SEARCH = `${BASE_SIMPRO_LUMEN}/document-project/search`; export const DOCUMENT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/document-project/update/${id}`; }; -export const DOCUMENT_DELETE = (id) => { - return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}`; +export const DOCUMENT_DELETE = (id, company_id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}/${company_id}`; }; -export const DOCUMENT_DOWNLOAD = (id) => { - return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}`; +export const DOCUMENT_DOWNLOAD = (id, company_id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}/${company_id}`; }; export const ROLE_ADD = `${BASE_SIMPRO_LUMEN}/role/add`; @@ -423,8 +430,8 @@ export const PROYEK_GET_ID = (id) => { export const PROYEK_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project/update/${id}`; }; -export const PROYEK_DELETE = (id) => { - return `${BASE_SIMPRO_LUMEN}/project/delete/${id}`; +export const PROYEK_DELETE = (id, company_id) => { + return `${BASE_SIMPRO_LUMEN}/project/delete/${id}/${company_id}`; }; export const PROJECT_ROLE_ADD = `${BASE_SIMPRO_LUMEN}/project-role/add`; @@ -576,6 +583,15 @@ export const DIVISI_DELETE = (id) => { }; export const DIVISI_LIST = `${BASE_SIMPRO_LUMEN}/divisi/list`; +export const KANBAN_BOARD_LIST = `${BASE_SIMPRO_LUMEN}/kanban-board/list` +export const KANBAN_BOARD_ADD = `${BASE_SIMPRO_LUMEN}/kanban-board/add` +export const KANBAN_BOARD_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/kanban-board/update/${id}` } +export const KANBAN_BOARD_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/kanban-board/delete/${id}` } + +export const KANBAN_CARD_LIST = `${BASE_SIMPRO_LUMEN}/kanban-card/get-data` +export const KANBAN_CARD_ADD = `${BASE_SIMPRO_LUMEN}/task` +export const KANBAN_CARD_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/kanban-card/update/${id}` } + export const SHIFT_ADD = `${BASE_SIMPRO_LUMEN}/shift/add`; export const SHIFT_SEARCH = `${BASE_SIMPRO_LUMEN}/shift/search`; export const SHIFT_EDIT = (id) => { @@ -700,8 +716,8 @@ export const ASSIGN_HR_PROJECT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-proyek/sea export const ASSIGN_HR_PROJECT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-proyek/update/${id}`; }; -export const ASSIGN_HR_PROJECT_DELETE = (id) => { - return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}`; +export const ASSIGN_HR_PROJECT_DELETE = (id, company_id) => { + return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}/${company_id}`; }; export const ASSIGN_HR_PROJECT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-proyek/list`; @@ -772,11 +788,11 @@ export const WAYPOINT_SEARCH = `${BASE_SIMPRO_LUMEN}/waypoint/search`; export const IMAGE_UPLOAD = `${BASE_SIMPRO_LUMEN}/image/upload`; export const IMAGE_MULTIPLE_UPLOAD = `${BASE_SIMPRO_LUMEN}/image/multiple-upload`; -export const IMAGE_MULTIPLE_DELETE = (id, category) => { - return `${BASE_SIMPRO_LUMEN}/image/multiple-delete/${id}/${category}`; +export const IMAGE_MULTIPLE_DELETE = (id, category, company_id) => { + return `${BASE_SIMPRO_LUMEN}/image/multiple-delete/${id}/${category}/${company_id}`; } -export const IMAGE_DELETE = (id, category) => { - return `${BASE_SIMPRO_LUMEN}/image/delete/${id}/${category}`; +export const IMAGE_DELETE = (id, category, company_id) => { + return `${BASE_SIMPRO_LUMEN}/image/delete/${id}/${category}/${company_id}`; } From 778490e790acf7e3327039e6d4dc12e74fb69041 Mon Sep 17 00:00:00 2001 From: wahyun Date: Mon, 19 Feb 2024 17:09:13 +0700 Subject: [PATCH 2/5] add company_id and company_name --- src/views/Master/MasterCompany/index.js | 14 +- src/views/Master/Proyek/index.js | 959 +++++++++--------- src/views/SimproV2/Closing/index.js | 767 +++++++------- .../CreatedProyek/AsignCustProject.js | 2 +- .../SimproV2/CreatedProyek/DialogDocument.js | 22 +- .../SimproV2/CreatedProyek/FormDocument.js | 195 ++-- src/views/SimproV2/CreatedProyek/index.js | 6 +- .../SimproV2/ResourceWorker/DialogForm.js | 4 +- 8 files changed, 985 insertions(+), 984 deletions(-) diff --git a/src/views/Master/MasterCompany/index.js b/src/views/Master/MasterCompany/index.js index d629c83..9a06900 100644 --- a/src/views/Master/MasterCompany/index.js +++ b/src/views/Master/MasterCompany/index.js @@ -53,7 +53,7 @@ const MasterCompany = ({ params }) => { const [loading, setLoading] = useState(true); const pageName = params.name; const { t } = useTranslation(); - + const configApp = JSON.parse(window.localStorage.getItem('configApp')); useEffect(() => { setLoading(true) getDataCompany() @@ -354,6 +354,7 @@ const MasterCompany = ({ params }) => { formData.append('ref_id', id); formData.append('category', 'company_logo_header'); formData.append('files', data); + formData.append('company_name',configApp.company_name); await axios .post(IMAGE_UPLOAD, formData, HEADER_MULTIPART) @@ -367,6 +368,7 @@ const MasterCompany = ({ params }) => { formData.append('ref_id', id); formData.append('category', 'company_logo_login'); formData.append('files', data); + formData.append('company_name',configApp.company_name); await axios .post(IMAGE_UPLOAD, formData, HEADER_MULTIPART) @@ -380,6 +382,7 @@ const MasterCompany = ({ params }) => { formData.append('ref_id', id); formData.append('category', 'company_favicon'); formData.append('files', data); + formData.append('company_name',configApp.company_name); await axios .post(IMAGE_UPLOAD, formData, HEADER_MULTIPART) @@ -389,6 +392,7 @@ const MasterCompany = ({ params }) => { }; const saveSliderLogin = async (data) => { + data.company_name = configApp.company_name; await axios .post(IMAGE_MULTIPLE_UPLOAD, data, HEADER_MULTIPART) .then(res => res) @@ -398,7 +402,7 @@ const MasterCompany = ({ params }) => { // Delete Image Function const deleteImageHeader = async (id) => { - const URL = IMAGE_DELETE(id, 'company_logo_header'); + const URL = IMAGE_DELETE(id, 'company_logo_header', company_id); await axios .delete(URL, HEADER) .then(res => res) @@ -407,7 +411,7 @@ const MasterCompany = ({ params }) => { }; const deleteImageLogin = async (id) => { - const URL = IMAGE_DELETE(id, 'company_logo_login'); + const URL = IMAGE_DELETE(id, 'company_logo_login', company_id); await axios .delete(URL, HEADER) .then(res => res) @@ -416,7 +420,7 @@ const MasterCompany = ({ params }) => { }; const deleteImageFavicon = async (id) => { - const URL = IMAGE_DELETE(id, 'company_favicon'); + const URL = IMAGE_DELETE(id, 'company_favicon', company_id); await axios .delete(URL, HEADER) .then(res => res) @@ -425,7 +429,7 @@ const MasterCompany = ({ params }) => { }; const deleteImageSlider = async (id) => { - const URL = IMAGE_MULTIPLE_DELETE(id, 'company_slider_login'); + const URL = IMAGE_MULTIPLE_DELETE(id, 'company_slider_login', company_id); await axios .delete(URL, HEADER) .then(res => res) diff --git a/src/views/Master/Proyek/index.js b/src/views/Master/Proyek/index.js index 085b5e7..3a63728 100644 --- a/src/views/Master/Proyek/index.js +++ b/src/views/Master/Proyek/index.js @@ -1,479 +1,480 @@ -import React, { useState, useEffect, useMemo } from 'react'; -import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; -import { DownloadOutlined } from '@ant-design/icons'; -import axios from 'axios'; -import * as XLSX from 'xlsx'; -import SweetAlert from 'react-bootstrap-sweetalert'; -import DialogForm from './DialogForm'; -import DialogFormSub from './DialogFormSub'; -import SubProyekComp from './SubProyekComp'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { Pagination, Table, Button, Tooltip } from 'antd'; -import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE } from '../../../const/ApiConst'; -import { formatRupiah } from '../../../const/CustomFunc' -import moment from 'moment' - -const format = "DD-MM-YYYY"; -const data = [ - { - key: 1, - name: 'John Brown', - age: 32, - address: 'New York No. 1 Lake Park', - description: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.', - }, - { - key: 2, - name: 'Jim Green', - age: 42, - address: 'London No. 1 Lake Park', - description: 'My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park.', - }, - { - key: 3, - name: 'Not Expandable', - age: 29, - address: 'Jiangsu No. 1 Lake Park', - description: 'This not expandable', - }, - { - key: 4, - name: 'Joe Black', - age: 32, - address: 'Sidney No. 1 Lake Park', - description: 'My name is Joe Black, I am 32 years old, living in Sidney No. 1 Lake Park.', - }, -]; - -const url = ""; -const proyek_id = localStorage.getItem('proyek_id'); -const role_id = localStorage.getItem('role_id'); - -const IndexRole = ({ params }) => { - const token = localStorage.getItem("token") - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - const [idTask, setidTask] = useState(0); - const [dataTable, setDatatable] = useState([]) - const [search, setSearch] = useState('') - const [currentPage, setCurrentPage] = useState(1) - const [totalPage, setTotalPage] = useState(0) - const [openDialog, setOpenDialog] = useState(false) - const [openDialogSub, setOpenDialogSub] = useState(false) - const [openDialogMap, setOpenDialogMap] = useState(false) - const [typeDialog, setTypeDialog] = useState('Save'); - const [typeDialogSub, setTypeDialogSub] = useState('Save') - const [idDelete, setIdDelete] = useState(0) - const [alertDelete, setAlertDelete] = useState(false) - const [dataEdit, setDataEdit] = useState([]) - const [dataEditSub, setDataEditSub] = useState([]) - const [rowsPerPage, setRowsPerPage] = useState(10) - const [clickOpenModal, setClickOpenModal] = useState(false) - const [dataExport, setDataExport] = useState([]) - const [allDataMenu, setAllDataMenu] = useState([]) - const pageName = params.name; - useEffect(() => { - getDataProyek(); - }, []) - - useEffect(() => { - getDataProyek(); - }, [search, rowsPerPage, currentPage]) - - useEffect(() => { - const cekData = dataExport || [] - if (cekData.length > 0) { - exportExcel() - } - }, [dataExport]) - - const handleSearch = e => { - const value = e.target.value - setSearch(value); - setCurrentPage(1) - }; - - const getDataProyek = async () => { - - - let start = 0; - - if (currentPage !== 1 && currentPage > 1) { - start = (currentPage * rowsPerPage) - rowsPerPage - } - - const payload = { - "columns": [ - { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } - ], - "joins": [ - { "name": "subproyeks.m_proyek", "column_join": "proyek_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }, - { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] } - ], - "orders": { "columns": ["id"], "ascending": true }, - "paging": { "start": 0, "length": 25 } - } - - - if (parseInt(role_id) !== 1) { - payload["columns"] = [ - { "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } - ] - } - - - const URL = `${BASE_SIMPRO}/proyek/search-detail` - const result = await axios - .post(URL, payload, HEADER) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - let dataRes = result.data.data || [] - let dataWithKey = getChildrenTree(dataRes) - setDatatable(dataWithKey); - setTotalPage(result.data.totalRecord); - } else { - NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); - } - } - - const getChildrenTree = (data) => ( - data.map((item, index) => { - let arrSubProyek = item.subproyeks - if (item.subproyeks && item.subproyeks.length > 0) { - return { - "key": Math.random(), - "subproyeks2": getChildrenTree(item.subproyeks), - ...item - } - } - else if (item.plannings && item.plannings.length > 0) { - return { - "key": Math.random(), - "plannings2": getChildrenTree(item.plannings), - ...item - } - } else { - return { - "key": Math.random(), - ...item - } - } - }) - ) - - const handleOpenDialog = (type) => { - setOpenDialog(true) - setTypeDialog(type) - } - - const handleOpenDialogSub = (type, param) => { - setidTask(param.id) - setOpenDialogSub(true) - setTypeDialogSub(type) - } - - const handleCloseDialog = (type, data) => { - if (type === "save") { - saveProyek(data); - } else if (type === "edit") { - editProyek(data); - } - setDataEdit([]) - setOpenDialog(false) - } - - const handleCloseDialogSub = (type, data) => { - setDataEditSub([]) - setOpenDialogSub(false) - if (type !== "cancel") { - getDataProyek() - } - } - - const handleCloseDialogMap = () => { - setOpenDialogMap(false) - } - - const toggleAddDialog = () => { - setOpenDialog(!openDialog) - } - - const toggleAddDialogSub = () => { - setOpenDialogSub(!openDialogSub) - } - - const toggleMapDialog = () => { - setOpenDialogMap(!openDialogMap) - } - - const onConfirmDelete = async () => { - let urlDel = PROYEK_DELETE(idDelete) - const result = await axios.delete(urlDel, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - getDataProyek() - setIdDelete(0) - setAlertDelete(false) - NotificationManager.success(`Data proyek berhasil dihapus`, 'Success!!'); - } else { - setIdDelete(0) - setAlertDelete(false) - NotificationManager.error(`Data proyek gagal dihapus`, 'Failed!!'); - } - } - - const saveProyek = async (data) => { - const formData = data - - const result = await axios.post(PROYEK_ADD, formData, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - getDataProyek(); - NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!'); - } else { - NotificationManager.error(`${result.data.message}`, 'Failed!!'); - } - - } - - const editProyek = async (data) => { - - let urlEdit = PROYEK_EDIT(data.id) - const formData = data - - const result = await axios.put(urlEdit, formData, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - getDataProyek(); - NotificationManager.success(`Data proyek berhasil diedit`, 'Success!!'); - } else { - NotificationManager.error(`Data proyek gagal di edit`, `Failed!!`); - } - - - - } - - - const handleEdit = (data) => { - setDataEdit(data) - handleOpenDialog('Edit'); - } - - const handleDelete = async (id) => { - await setAlertDelete(true) - await setIdDelete(id) - } - - const onShowSizeChange = (current, pageSize) => { - setRowsPerPage(pageSize) - } - - const onPagination = (current, pageSize) => { - setCurrentPage(current) - } - - const handleExportExcel = async () => { - - const payload = { - "paging": { "start": 0, "length": -1 }, - "joins": [], - "orders": { "columns": ["id"], "ascending": false } - } - - if (parseInt(role_id) !== 1) { - payload["columns"] = [ - { "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } - ] - } - - - - const result = await axios - .post(PROYEK_SEARCH, payload, HEADER) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - let resData = result.data.data; - const excelData = []; - resData.map((n, index) => { - let dataRow = { - "Nama Proyek": n.nama, - "Biaya": n.biaya, - "Color Progress": n.color_progress, - "Jumlah Pekerja": n.jumlah_pekerja, - "Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-", - "Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-", - } - excelData.push(dataRow) - }) - await setDataExport(excelData); - } else { - NotificationManager.error('Gagal Export Data!!', 'Failed'); - } - } - - const exportExcel = () => { - const dataExcel = dataExport || []; - const fileName = `Data ${pageName}.xlsx`; - const ws = XLSX.utils.json_to_sheet(dataExcel); - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); - - XLSX.writeFile(wb, fileName); - setDataExport([]) - } - - const cancelDelete = () => { - setAlertDelete(false) - setIdDelete(0) - } - - const renderProggress = (color) => { - if (color === "green") { - return "Aman" - } else if (color === "orange") { - return "Alert" - } else { - return "Critical" - } - } - - const renderFormatRupiah = (text, prefix) => { - if (text) { - return formatRupiah(text, prefix) - } else { - return "-" - } - } - - const RenderTable = useMemo(() => { - const columns = [ - { title: 'Nama Proyek', dataIndex: 'nama', key: 'nama' }, - { - title: 'Biaya', - dataIndex: 'biaya', - key: 'biaya', - render: (text, record) => { return renderFormatRupiah(text, "Rp") } - }, - { title: 'SDM', dataIndex: 'jumlah_pekerja', key: 'jumlah_pekerja' }, - { title: 'PM', dataIndex: 'pic', key: 'pic' }, - { - title: 'Aktifitas Mulai', - dataIndex: 'mulai_proyek', - key: 'mulai_proyek', - render: (text, record) => <>{moment(text).format(format)}, - }, - { - title: 'Aktifitas Selesai', - dataIndex: 'akhir_proyek', - key: 'akhir_proyek', - render: (text, record) => <>{moment(text).format(format)}, - }, - { - title: 'Action', - dataIndex: '', - key: 'x', - render: (text, record) => <> - - - - - - - - - - , - }, - ]; - - return ( - , - rowExpandable: record => record.subproyeks2, - }} - dataSource={dataTable} - /> - ) - }, [dataTable]) - - return ( -
- - cancelDelete()} - focusCancelBtn - > - Data akan terhapus - - toggleAddDialog} - typeDialog={typeDialog} - dataEdit={dataEdit} - clickOpenModal={clickOpenModal} - dataParent={allDataMenu} - /> - toggleAddDialogSub} - typeDialog={typeDialogSub} - dataEdit={dataEditSub} - idTask={idTask} - idSubtask={0} - /> - - -

{pageName}

- -
- - - - - - - - - - - - - - - {RenderTable} - - - - ) -} - -export default IndexRole; \ No newline at end of file +import React, { useState, useEffect, useMemo } from 'react'; +import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; +import { DownloadOutlined } from '@ant-design/icons'; +import axios from 'axios'; +import * as XLSX from 'xlsx'; +import SweetAlert from 'react-bootstrap-sweetalert'; +import DialogForm from './DialogForm'; +import DialogFormSub from './DialogFormSub'; +import SubProyekComp from './SubProyekComp'; +import { NotificationContainer, NotificationManager } from 'react-notifications'; +import { Pagination, Table, Button, Tooltip } from 'antd'; +import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE } from '../../../const/ApiConst'; +import { formatRupiah } from '../../../const/CustomFunc' +import moment from 'moment' + +const format = "DD-MM-YYYY"; +const data = [ + { + key: 1, + name: 'John Brown', + age: 32, + address: 'New York No. 1 Lake Park', + description: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.', + }, + { + key: 2, + name: 'Jim Green', + age: 42, + address: 'London No. 1 Lake Park', + description: 'My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park.', + }, + { + key: 3, + name: 'Not Expandable', + age: 29, + address: 'Jiangsu No. 1 Lake Park', + description: 'This not expandable', + }, + { + key: 4, + name: 'Joe Black', + age: 32, + address: 'Sidney No. 1 Lake Park', + description: 'My name is Joe Black, I am 32 years old, living in Sidney No. 1 Lake Park.', + }, +]; + +const url = ""; +const proyek_id = localStorage.getItem('proyek_id'); +const role_id = localStorage.getItem('role_id'); +const company_id = window.localStorage.getItem('company_id'); + +const IndexRole = ({ params }) => { + const token = localStorage.getItem("token") + const HEADER = { + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + } + } + const [idTask, setidTask] = useState(0); + const [dataTable, setDatatable] = useState([]) + const [search, setSearch] = useState('') + const [currentPage, setCurrentPage] = useState(1) + const [totalPage, setTotalPage] = useState(0) + const [openDialog, setOpenDialog] = useState(false) + const [openDialogSub, setOpenDialogSub] = useState(false) + const [openDialogMap, setOpenDialogMap] = useState(false) + const [typeDialog, setTypeDialog] = useState('Save'); + const [typeDialogSub, setTypeDialogSub] = useState('Save') + const [idDelete, setIdDelete] = useState(0) + const [alertDelete, setAlertDelete] = useState(false) + const [dataEdit, setDataEdit] = useState([]) + const [dataEditSub, setDataEditSub] = useState([]) + const [rowsPerPage, setRowsPerPage] = useState(10) + const [clickOpenModal, setClickOpenModal] = useState(false) + const [dataExport, setDataExport] = useState([]) + const [allDataMenu, setAllDataMenu] = useState([]) + const pageName = params.name; + useEffect(() => { + getDataProyek(); + }, []) + + useEffect(() => { + getDataProyek(); + }, [search, rowsPerPage, currentPage]) + + useEffect(() => { + const cekData = dataExport || [] + if (cekData.length > 0) { + exportExcel() + } + }, [dataExport]) + + const handleSearch = e => { + const value = e.target.value + setSearch(value); + setCurrentPage(1) + }; + + const getDataProyek = async () => { + + + let start = 0; + + if (currentPage !== 1 && currentPage > 1) { + start = (currentPage * rowsPerPage) - rowsPerPage + } + + const payload = { + "columns": [ + { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } + ], + "joins": [ + { "name": "subproyeks.m_proyek", "column_join": "proyek_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }, + { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] } + ], + "orders": { "columns": ["id"], "ascending": true }, + "paging": { "start": 0, "length": 25 } + } + + + if (parseInt(role_id) !== 1) { + payload["columns"] = [ + { "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } + ] + } + + + const URL = `${BASE_SIMPRO}/proyek/search-detail` + const result = await axios + .post(URL, payload, HEADER) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + let dataRes = result.data.data || [] + let dataWithKey = getChildrenTree(dataRes) + setDatatable(dataWithKey); + setTotalPage(result.data.totalRecord); + } else { + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } + } + + const getChildrenTree = (data) => ( + data.map((item, index) => { + let arrSubProyek = item.subproyeks + if (item.subproyeks && item.subproyeks.length > 0) { + return { + "key": Math.random(), + "subproyeks2": getChildrenTree(item.subproyeks), + ...item + } + } + else if (item.plannings && item.plannings.length > 0) { + return { + "key": Math.random(), + "plannings2": getChildrenTree(item.plannings), + ...item + } + } else { + return { + "key": Math.random(), + ...item + } + } + }) + ) + + const handleOpenDialog = (type) => { + setOpenDialog(true) + setTypeDialog(type) + } + + const handleOpenDialogSub = (type, param) => { + setidTask(param.id) + setOpenDialogSub(true) + setTypeDialogSub(type) + } + + const handleCloseDialog = (type, data) => { + if (type === "save") { + saveProyek(data); + } else if (type === "edit") { + editProyek(data); + } + setDataEdit([]) + setOpenDialog(false) + } + + const handleCloseDialogSub = (type, data) => { + setDataEditSub([]) + setOpenDialogSub(false) + if (type !== "cancel") { + getDataProyek() + } + } + + const handleCloseDialogMap = () => { + setOpenDialogMap(false) + } + + const toggleAddDialog = () => { + setOpenDialog(!openDialog) + } + + const toggleAddDialogSub = () => { + setOpenDialogSub(!openDialogSub) + } + + const toggleMapDialog = () => { + setOpenDialogMap(!openDialogMap) + } + + const onConfirmDelete = async () => { + let urlDel = PROYEK_DELETE(idDelete, company_id); + const result = await axios.delete(urlDel, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getDataProyek() + setIdDelete(0) + setAlertDelete(false) + NotificationManager.success(`Data proyek berhasil dihapus`, 'Success!!'); + } else { + setIdDelete(0) + setAlertDelete(false) + NotificationManager.error(`Data proyek gagal dihapus`, 'Failed!!'); + } + } + + const saveProyek = async (data) => { + const formData = data + + const result = await axios.post(PROYEK_ADD, formData, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getDataProyek(); + NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!'); + } else { + NotificationManager.error(`${result.data.message}`, 'Failed!!'); + } + + } + + const editProyek = async (data) => { + + let urlEdit = PROYEK_EDIT(data.id) + const formData = data + + const result = await axios.put(urlEdit, formData, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getDataProyek(); + NotificationManager.success(`Data proyek berhasil diedit`, 'Success!!'); + } else { + NotificationManager.error(`Data proyek gagal di edit`, `Failed!!`); + } + + + + } + + + const handleEdit = (data) => { + setDataEdit(data) + handleOpenDialog('Edit'); + } + + const handleDelete = async (id) => { + await setAlertDelete(true) + await setIdDelete(id) + } + + const onShowSizeChange = (current, pageSize) => { + setRowsPerPage(pageSize) + } + + const onPagination = (current, pageSize) => { + setCurrentPage(current) + } + + const handleExportExcel = async () => { + + const payload = { + "paging": { "start": 0, "length": -1 }, + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + + if (parseInt(role_id) !== 1) { + payload["columns"] = [ + { "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } + ] + } + + + + const result = await axios + .post(PROYEK_SEARCH, payload, HEADER) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + let resData = result.data.data; + const excelData = []; + resData.map((n, index) => { + let dataRow = { + "Nama Proyek": n.nama, + "Biaya": n.biaya, + "Color Progress": n.color_progress, + "Jumlah Pekerja": n.jumlah_pekerja, + "Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-", + "Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-", + } + excelData.push(dataRow) + }) + await setDataExport(excelData); + } else { + NotificationManager.error('Gagal Export Data!!', 'Failed'); + } + } + + const exportExcel = () => { + const dataExcel = dataExport || []; + const fileName = `Data ${pageName}.xlsx`; + const ws = XLSX.utils.json_to_sheet(dataExcel); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); + + XLSX.writeFile(wb, fileName); + setDataExport([]) + } + + const cancelDelete = () => { + setAlertDelete(false) + setIdDelete(0) + } + + const renderProggress = (color) => { + if (color === "green") { + return "Aman" + } else if (color === "orange") { + return "Alert" + } else { + return "Critical" + } + } + + const renderFormatRupiah = (text, prefix) => { + if (text) { + return formatRupiah(text, prefix) + } else { + return "-" + } + } + + const RenderTable = useMemo(() => { + const columns = [ + { title: 'Nama Proyek', dataIndex: 'nama', key: 'nama' }, + { + title: 'Biaya', + dataIndex: 'biaya', + key: 'biaya', + render: (text, record) => { return renderFormatRupiah(text, "Rp") } + }, + { title: 'SDM', dataIndex: 'jumlah_pekerja', key: 'jumlah_pekerja' }, + { title: 'PM', dataIndex: 'pic', key: 'pic' }, + { + title: 'Aktifitas Mulai', + dataIndex: 'mulai_proyek', + key: 'mulai_proyek', + render: (text, record) => <>{moment(text).format(format)}, + }, + { + title: 'Aktifitas Selesai', + dataIndex: 'akhir_proyek', + key: 'akhir_proyek', + render: (text, record) => <>{moment(text).format(format)}, + }, + { + title: 'Action', + dataIndex: '', + key: 'x', + render: (text, record) => <> + + + + + + + + + + , + }, + ]; + + return ( +
, + rowExpandable: record => record.subproyeks2, + }} + dataSource={dataTable} + /> + ) + }, [dataTable]) + + return ( +
+ + cancelDelete()} + focusCancelBtn + > + Data akan terhapus + + toggleAddDialog} + typeDialog={typeDialog} + dataEdit={dataEdit} + clickOpenModal={clickOpenModal} + dataParent={allDataMenu} + /> + toggleAddDialogSub} + typeDialog={typeDialogSub} + dataEdit={dataEditSub} + idTask={idTask} + idSubtask={0} + /> + + +

{pageName}

+ +
+ + + + + + + + + + + + + + + {RenderTable} + + + + ) +} + +export default IndexRole; diff --git a/src/views/SimproV2/Closing/index.js b/src/views/SimproV2/Closing/index.js index 3e9c93d..23f6b50 100644 --- a/src/views/SimproV2/Closing/index.js +++ b/src/views/SimproV2/Closing/index.js @@ -1,383 +1,384 @@ -import * as XLSX from 'xlsx'; -import DialogForm from './DialogForm'; -import React, { useState, useEffect, useMemo } from 'react'; -import SweetAlert from 'react-bootstrap-sweetalert'; -import axios from "../../../const/interceptorApi"; -import moment from 'moment' -import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE } from '../../../const/ApiConst'; -import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; -import { DownloadOutlined } from '@ant-design/icons'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { Pagination, Table, Button, Tooltip } from 'antd'; -import { formatRupiah } from '../../../const/CustomFunc' - -const url = ""; -const proyek_id = localStorage.getItem('proyek_id'); -const role_id = localStorage.getItem('role_id'); -const format = "DD-MM-YYYY"; - -const Closing = ({ params, ...props }) => { - const token = localStorage.getItem("token") - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - - const [alertClose, setAlertClose] = useState(false) - const [alertDelete, setAlertDelete] = useState(false) - const [allDataMenu, setAllDataMenu] = useState([]) - const [clickOpenModal, setClickOpenModal] = useState(false) - const [currentPage, setCurrentPage] = useState(1) - const [dataCharter, setDataCharter] = useState(null) - const [dataEdit, setDataEdit] = useState([]) - const [dataEditSub, setDataEditSub] = useState([]) - const [dataExport, setDataExport] = useState([]) - const [dataTable, setDatatable] = useState([]) - const [dataView, setDataView] = useState([]) - const [idDelete, setIdDelete] = useState(0) - const [idTask, setidTask] = useState(0); - const [openDialog, setOpenDialog] = useState(false) - const [openDialogMap, setOpenDialogMap] = useState(false) - const [openDialogResource, setOpenDialogResource] = useState(false) - const [openDialogViewDetail, setOpenDialogViewDetail] = useState(false) - const [rowsPerPage, setRowsPerPage] = useState(10) - const [search, setSearch] = useState('') - const [totalPage, setTotalPage] = useState(0) - const [typeDialog, setTypeDialog] = useState('Save'); - const [typeDialogSub, setTypeDialogSub] = useState('Save') - const [userProyek, setUserProyek] = useState([]); - const pageName = params.name; - - useEffect(() => { - getDataProyek() - }, []) - - const handleSearch = e => { - const value = e.target.value - setSearch(value); - setCurrentPage(1) - }; - - const getDataProyek = async () => { - - let start = 0; - - if (currentPage !== 1 && currentPage > 1) { - start = (currentPage * rowsPerPage) - rowsPerPage - } - - const payload = { - "columns": [ - { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } - ], - "joins": [ - { "name": "m_users", "column_join": "pm_id", "column_results": ["name", "username"] }, - { "name": "m_type_proyek", "column_join": "type_proyek_id", "column_results": ["name", "description"] }, - ], - "orders": { "columns": ["id"], "ascending": true }, - "paging": { "start": 0, "length": 25 } - } - - - if (parseInt(role_id) !== 1) { - payload["columns"] = [ - { "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } - ] - } - - const URL = `${BASE_SIMPRO}/proyek/search-detail` - const result = await axios - .post(URL, payload, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - let dataRes = result.data.data || [] - - setDatatable(dataRes); - setTotalPage(result.data.totalRecord); - } else { - NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); - } - } - - const handleOpenDialog = (id) => { - setOpenDialog(true) - setidTask(id) - } - - const handleOpenDialogResource = (data) => { - setOpenDialogResource(true) - setidTask(data.id) - setUserProyek(data.user_proyeks) - } - - const handleOpenDialogViewDetail = (data) => { - setOpenDialogViewDetail(true) - setidTask(data.id) - setDataView(data) - setDataCharter(data.project_charter ? data.project_charter : null) - } - - const handleCloseDialog = (type, payload) => { - if (type === "add") saveProyek(payload); - - if (type === "edit") editProyek(payload); - - setOpenDialog(false) - } - - const handleCloseDialogResource = (type, payload) => { - setOpenDialogResource(false) - } - - const handleCloseDialogView = (type, payload) => { - setOpenDialogViewDetail(false) - } - - - const toggleAddDialog = () => setOpenDialog(!openDialog) - - const toggleAddDialogResource = () => setOpenDialogResource(!openDialog) - const toggleAddDialogView = () => setOpenDialogViewDetail(!openDialogViewDetail) - - const onConfirmDelete = async () => { - let urlDel = PROYEK_DELETE(idDelete) - const result = await axios.delete(urlDel, HEADER) - .then(res => res) - .catch((error) => error.response); - if (result && result.data && result.data.code === 200) { - getDataProyek() - setIdDelete(0) - setAlertDelete(false) - NotificationManager.success(`Data proyek berhasil dihapus`, 'Success!!'); - } else { - setIdDelete(0) - setAlertDelete(false) - NotificationManager.error(`Data proyek gagal dihapus`, 'Failed!!'); - } - } - - const onConfirmClose = async () => { - setIdDelete(0) - setAlertClose(false) - NotificationManager.success(`Data proyek berhasil diclose`, 'Success!!'); - } - - const saveProyek = async (data) => { - const formData = data - - const result = await axios.post(PROYEK_ADD, formData, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - getDataProyek(); - NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!'); - } else { - NotificationManager.error(`${result.data.message}`, 'Failed!!'); - } - - } - - const editProyek = async (data) => { - let urlEdit = PROYEK_EDIT(data.id) - const formData = data - - const result = await axios.put(urlEdit, formData, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - getDataProyek(); - NotificationManager.success(`Data proyek berhasil diedit`, 'Success!!'); - } else { - NotificationManager.error(`Data proyek gagal di edit`, `Failed!!`); - } - } - - const handleDelete = async (id) => { - await setAlertDelete(true) - await setIdDelete(id) - } - - const handleCloseProject = async (id) => { - await setAlertClose(true) - await setIdDelete(id) - } - - const onShowSizeChange = (current, pageSize) => { - setRowsPerPage(pageSize) - } - - const onPagination = (current, pageSize) => { - setCurrentPage(current) - } - - const handleExportExcel = async () => { - - const payload = { - "paging": { "start": 0, "length": -1 }, - "joins": [], - "orders": { "columns": ["id"], "ascending": false } - } - - if (parseInt(role_id) !== 1) { - payload["columns"] = [ - { "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } - ] - } - - const result = await axios - .post(PROYEK_SEARCH, payload, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - let resData = result.data.data; - const excelData = []; - resData.map((n, index) => { - let dataRow = { - "Nama Proyek": n.nama, - "Biaya": n.biaya, - "Color Progress": n.color_progress, - "Jumlah Pekerja": n.jumlah_pekerja, - "Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-", - "Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-", - } - excelData.push(dataRow) - }) - await setDataExport(excelData); - } else { - NotificationManager.error('Gagal Export Data!!', 'Failed'); - } - } - - const exportExcel = () => { - const dataExcel = dataExport || []; - const fileName = `Data ${pageName}.xlsx`; - const ws = XLSX.utils.json_to_sheet(dataExcel); - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); - - XLSX.writeFile(wb, fileName); - setDataExport([]) - } - - const cancelDelete = () => { - setAlertDelete(false) - setIdDelete(0) - } - - const cancelClose = () => { - setAlertClose(false) - setIdDelete(0) - } - - const renderFormatRupiah = (text, prefix) => { - if (text) { - return formatRupiah(text, prefix) - } else { - return "-" - } - } - - const handleClickGantt = (id) => { - props.history.push({ - pathname: '/gantt', - state: { proyek_id: id } - }) - } - - const RenderTable = useMemo(() => { - const columns = [ - { - title: 'Action', - dataIndex: '', - key: 'x', - render: (text, record) => <> - - - - , - }, - { title: 'Nama Proyek', dataIndex: 'nama', key: 'nama' }, - { - title: 'Planning Cost', - dataIndex: 'rencana_biaya', - key: 'rencana_biaya', - render: (text, record) => { return renderFormatRupiah(text, "Rp") } - }, - { - title: 'Project Type', - dataIndex: 'color_progress', - key: 'color_progress', - render: (text, record) => <>{record.join.m_type_proyek_name} - }, - { - title: 'PM', dataIndex: 'pic', key: 'pic', - render: (text, record) => <>{record.join.m_users_name} - }, - { - title: 'Time Project', - dataIndex: 'akhir_proyek', - key: 'akhir_proyek', - render: (text, record) => <>{moment(record.mulai_proyek).format(format)} - {moment(record.akhir_proyek).format(format)}, - }, - ]; - - return ( -
- ) - }, [dataTable]) - - const RenderDialogForm = useMemo(() => ( - toggleAddDialog} - idTask={idTask} - /> - ), [openDialog]) - - return ( -
- - cancelClose()} - focusCancelBtn - > - Close this project - - {RenderDialogForm} - - -

{pageName}

- -
- - - - - - {RenderTable} - - - - ) -} - -export default Closing; +import * as XLSX from 'xlsx'; +import DialogForm from './DialogForm'; +import React, { useState, useEffect, useMemo } from 'react'; +import SweetAlert from 'react-bootstrap-sweetalert'; +import axios from "../../../const/interceptorApi"; +import moment from 'moment' +import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE } from '../../../const/ApiConst'; +import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; +import { DownloadOutlined } from '@ant-design/icons'; +import { NotificationContainer, NotificationManager } from 'react-notifications'; +import { Pagination, Table, Button, Tooltip } from 'antd'; +import { formatRupiah } from '../../../const/CustomFunc' + +const url = ""; +const proyek_id = localStorage.getItem('proyek_id'); +const role_id = localStorage.getItem('role_id'); +const company_id = window.localStorage.getItem('company_id'); +const format = "DD-MM-YYYY"; + +const Closing = ({ params, ...props }) => { + const token = localStorage.getItem("token") + const HEADER = { + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + } + } + + const [alertClose, setAlertClose] = useState(false) + const [alertDelete, setAlertDelete] = useState(false) + const [allDataMenu, setAllDataMenu] = useState([]) + const [clickOpenModal, setClickOpenModal] = useState(false) + const [currentPage, setCurrentPage] = useState(1) + const [dataCharter, setDataCharter] = useState(null) + const [dataEdit, setDataEdit] = useState([]) + const [dataEditSub, setDataEditSub] = useState([]) + const [dataExport, setDataExport] = useState([]) + const [dataTable, setDatatable] = useState([]) + const [dataView, setDataView] = useState([]) + const [idDelete, setIdDelete] = useState(0) + const [idTask, setidTask] = useState(0); + const [openDialog, setOpenDialog] = useState(false) + const [openDialogMap, setOpenDialogMap] = useState(false) + const [openDialogResource, setOpenDialogResource] = useState(false) + const [openDialogViewDetail, setOpenDialogViewDetail] = useState(false) + const [rowsPerPage, setRowsPerPage] = useState(10) + const [search, setSearch] = useState('') + const [totalPage, setTotalPage] = useState(0) + const [typeDialog, setTypeDialog] = useState('Save'); + const [typeDialogSub, setTypeDialogSub] = useState('Save') + const [userProyek, setUserProyek] = useState([]); + const pageName = params.name; + + useEffect(() => { + getDataProyek() + }, []) + + const handleSearch = e => { + const value = e.target.value + setSearch(value); + setCurrentPage(1) + }; + + const getDataProyek = async () => { + + let start = 0; + + if (currentPage !== 1 && currentPage > 1) { + start = (currentPage * rowsPerPage) - rowsPerPage + } + + const payload = { + "columns": [ + { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } + ], + "joins": [ + { "name": "m_users", "column_join": "pm_id", "column_results": ["name", "username"] }, + { "name": "m_type_proyek", "column_join": "type_proyek_id", "column_results": ["name", "description"] }, + ], + "orders": { "columns": ["id"], "ascending": true }, + "paging": { "start": 0, "length": 25 } + } + + + if (parseInt(role_id) !== 1) { + payload["columns"] = [ + { "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } + ] + } + + const URL = `${BASE_SIMPRO}/proyek/search-detail` + const result = await axios + .post(URL, payload, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + let dataRes = result.data.data || [] + + setDatatable(dataRes); + setTotalPage(result.data.totalRecord); + } else { + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } + } + + const handleOpenDialog = (id) => { + setOpenDialog(true) + setidTask(id) + } + + const handleOpenDialogResource = (data) => { + setOpenDialogResource(true) + setidTask(data.id) + setUserProyek(data.user_proyeks) + } + + const handleOpenDialogViewDetail = (data) => { + setOpenDialogViewDetail(true) + setidTask(data.id) + setDataView(data) + setDataCharter(data.project_charter ? data.project_charter : null) + } + + const handleCloseDialog = (type, payload) => { + if (type === "add") saveProyek(payload); + + if (type === "edit") editProyek(payload); + + setOpenDialog(false) + } + + const handleCloseDialogResource = (type, payload) => { + setOpenDialogResource(false) + } + + const handleCloseDialogView = (type, payload) => { + setOpenDialogViewDetail(false) + } + + + const toggleAddDialog = () => setOpenDialog(!openDialog) + + const toggleAddDialogResource = () => setOpenDialogResource(!openDialog) + const toggleAddDialogView = () => setOpenDialogViewDetail(!openDialogViewDetail) + + const onConfirmDelete = async () => { + let urlDel = PROYEK_DELETE(idDelete, company_id) + const result = await axios.delete(urlDel, HEADER) + .then(res => res) + .catch((error) => error.response); + if (result && result.data && result.data.code === 200) { + getDataProyek() + setIdDelete(0) + setAlertDelete(false) + NotificationManager.success(`Data proyek berhasil dihapus`, 'Success!!'); + } else { + setIdDelete(0) + setAlertDelete(false) + NotificationManager.error(`Data proyek gagal dihapus`, 'Failed!!'); + } + } + + const onConfirmClose = async () => { + setIdDelete(0) + setAlertClose(false) + NotificationManager.success(`Data proyek berhasil diclose`, 'Success!!'); + } + + const saveProyek = async (data) => { + const formData = data + + const result = await axios.post(PROYEK_ADD, formData, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getDataProyek(); + NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!'); + } else { + NotificationManager.error(`${result.data.message}`, 'Failed!!'); + } + + } + + const editProyek = async (data) => { + let urlEdit = PROYEK_EDIT(data.id) + const formData = data + + const result = await axios.put(urlEdit, formData, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getDataProyek(); + NotificationManager.success(`Data proyek berhasil diedit`, 'Success!!'); + } else { + NotificationManager.error(`Data proyek gagal di edit`, `Failed!!`); + } + } + + const handleDelete = async (id) => { + await setAlertDelete(true) + await setIdDelete(id) + } + + const handleCloseProject = async (id) => { + await setAlertClose(true) + await setIdDelete(id) + } + + const onShowSizeChange = (current, pageSize) => { + setRowsPerPage(pageSize) + } + + const onPagination = (current, pageSize) => { + setCurrentPage(current) + } + + const handleExportExcel = async () => { + + const payload = { + "paging": { "start": 0, "length": -1 }, + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + + if (parseInt(role_id) !== 1) { + payload["columns"] = [ + { "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } + ] + } + + const result = await axios + .post(PROYEK_SEARCH, payload, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + let resData = result.data.data; + const excelData = []; + resData.map((n, index) => { + let dataRow = { + "Nama Proyek": n.nama, + "Biaya": n.biaya, + "Color Progress": n.color_progress, + "Jumlah Pekerja": n.jumlah_pekerja, + "Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-", + "Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-", + } + excelData.push(dataRow) + }) + await setDataExport(excelData); + } else { + NotificationManager.error('Gagal Export Data!!', 'Failed'); + } + } + + const exportExcel = () => { + const dataExcel = dataExport || []; + const fileName = `Data ${pageName}.xlsx`; + const ws = XLSX.utils.json_to_sheet(dataExcel); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); + + XLSX.writeFile(wb, fileName); + setDataExport([]) + } + + const cancelDelete = () => { + setAlertDelete(false) + setIdDelete(0) + } + + const cancelClose = () => { + setAlertClose(false) + setIdDelete(0) + } + + const renderFormatRupiah = (text, prefix) => { + if (text) { + return formatRupiah(text, prefix) + } else { + return "-" + } + } + + const handleClickGantt = (id) => { + props.history.push({ + pathname: '/gantt', + state: { proyek_id: id } + }) + } + + const RenderTable = useMemo(() => { + const columns = [ + { + title: 'Action', + dataIndex: '', + key: 'x', + render: (text, record) => <> + + + + , + }, + { title: 'Nama Proyek', dataIndex: 'nama', key: 'nama' }, + { + title: 'Planning Cost', + dataIndex: 'rencana_biaya', + key: 'rencana_biaya', + render: (text, record) => { return renderFormatRupiah(text, "Rp") } + }, + { + title: 'Project Type', + dataIndex: 'color_progress', + key: 'color_progress', + render: (text, record) => <>{record.join.m_type_proyek_name} + }, + { + title: 'PM', dataIndex: 'pic', key: 'pic', + render: (text, record) => <>{record.join.m_users_name} + }, + { + title: 'Time Project', + dataIndex: 'akhir_proyek', + key: 'akhir_proyek', + render: (text, record) => <>{moment(record.mulai_proyek).format(format)} - {moment(record.akhir_proyek).format(format)}, + }, + ]; + + return ( +
+ ) + }, [dataTable]) + + const RenderDialogForm = useMemo(() => ( + toggleAddDialog} + idTask={idTask} + /> + ), [openDialog]) + + return ( +
+ + cancelClose()} + focusCancelBtn + > + Close this project + + {RenderDialogForm} + + +

{pageName}

+ +
+ + + + + + {RenderTable} + + + + ) +} + +export default Closing; diff --git a/src/views/SimproV2/CreatedProyek/AsignCustProject.js b/src/views/SimproV2/CreatedProyek/AsignCustProject.js index 902c0f8..9bc6cb2 100644 --- a/src/views/SimproV2/CreatedProyek/AsignCustProject.js +++ b/src/views/SimproV2/CreatedProyek/AsignCustProject.js @@ -84,7 +84,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy } const onConfirmDelete = async () => { - let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete) + let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete, company_id) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/SimproV2/CreatedProyek/DialogDocument.js b/src/views/SimproV2/CreatedProyek/DialogDocument.js index a39529e..69830d0 100644 --- a/src/views/SimproV2/CreatedProyek/DialogDocument.js +++ b/src/views/SimproV2/CreatedProyek/DialogDocument.js @@ -5,7 +5,7 @@ import { Table, Tooltip, Popover, Spin } from 'antd'; import 'antd/dist/antd.css'; import moment from 'moment'; import SweetAlert from 'react-bootstrap-sweetalert'; -import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst'; +import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE_COMPANY, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst'; import axios from "../../../const/interceptorApi" import { NotificationContainer, NotificationManager } from 'react-notifications'; import DialogRequest from './FormDocument'; @@ -18,13 +18,6 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN "Authorization": `Bearer ${token}` } } - const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } - }; const [dataDocument, setDataDocument] = useState([]) const [openDialogReq, setOpenDialogReq] = useState(false) const [openDialogNewFolder, setOpenDialogNewFolder] = useState(false) @@ -34,6 +27,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN const [dataEdit, setDataEdit] = useState(null) const [parentIdNewFolder, setParentIdNewFolder] = useState(0) const [loading, setLoading] = useState(true); + const company_id = window.localStorage.getItem('company_id'); useEffect(() => { if (idTask > 0) { @@ -58,7 +52,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN const getDataDocument = async () => { const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask) const result = await axios - .get(url, config) + .get(url, HEADER) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { @@ -86,7 +80,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const handleDownload = (id, file) => { - fetch(DOCUMENT_DOWNLOAD(id), { + fetch(DOCUMENT_DOWNLOAD(id, company_id), { headers: new Headers({ 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` @@ -101,14 +95,12 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN a.click(); a.remove(); }); - //window.location.href = response.url; }); - // const urlDownload = DOCUMENT_DOWNLOAD(id); - // window.open(urlDownload); } const handleShow = (file) => { - const urlShow = `${BASE_SIMPRO_LUMEN_FILE}/${file}` + const configApp = JSON.parse(window.localStorage.getItem('configApp')); + const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, configApp.company_name)}` window.open(urlShow); } @@ -215,7 +207,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const onConfirmDelete = async () => { - let urlDel = DOCUMENT_DELETE(idDelete) + let urlDel = DOCUMENT_DELETE(idDelete, company_id) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/SimproV2/CreatedProyek/FormDocument.js b/src/views/SimproV2/CreatedProyek/FormDocument.js index 5bfe38d..71edd49 100644 --- a/src/views/SimproV2/CreatedProyek/FormDocument.js +++ b/src/views/SimproV2/CreatedProyek/FormDocument.js @@ -1,96 +1,99 @@ -import React, { useEffect, useState } from 'react' -import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; -import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; -import axios from "../../../const/interceptorApi"; -import { DOCUMENT_ADD } from '../../../const/ApiConst'; -import 'antd/dist/antd.css'; -import { NotificationManager } from 'react-notifications'; - -const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => { - const token = localStorage.getItem("token") - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - const [id, setId] = useState(0) - const [file, setFile] = useState(null) - - - const handleCLearData = () => { - setId(0) - setFile(null) - } - - useEffect(() => { - handleCLearData() - }, [openDialog]) - - const handleSave = () => { - uploadDokumen() - handleCLearData() - } - - const uploadDokumen = async () => { - const formData = new FormData; - formData.append('dokumen', file, file.name); - - if (parentIdNewFolder > 0) { - formData.append('ref_id', parentIdNewFolder); // folder_id - formData.append('type_dokumen', 'project-document-in-folder'); - } - else { - formData.append('ref_id', idTask); // proyek_id - formData.append('type_dokumen', 'project-document-out-folder') - } - - const result = await axios - .post(DOCUMENT_ADD, formData, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.status == 200) { - NotificationManager.success('Dokumen project berhasil diupload!!', 'Success'); - closeDialog('upload') - } else { - NotificationManager.error('Dokumen project gagal diupload!!', 'Failed'); - closeDialog('failed upload') - } - } - - const handleCancel = () => { - closeDialog('cancel') - handleCLearData() - } - - const renderForm = () => { - return ( - - - - setFile(e.target.files[0])} /> - - - ) - } - - - return ( - <> - - Upload Project Document - - {renderForm()} - - - {' '} - - - - - ) - -} - -export default DialogRequest; \ No newline at end of file +import React, { useEffect, useState } from 'react' +import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; +import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; +import axios from "../../../const/interceptorApi"; +import { DOCUMENT_ADD } from '../../../const/ApiConst'; +import 'antd/dist/antd.css'; +import { NotificationManager } from 'react-notifications'; + +const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => { + const token = localStorage.getItem("token") + const HEADER = { + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + } + } + const [id, setId] = useState(0) + const [file, setFile] = useState(null) + + + const handleCLearData = () => { + setId(0) + setFile(null) + } + + useEffect(() => { + handleCLearData() + }, [openDialog]) + + const handleSave = () => { + uploadDokumen() + handleCLearData() + } + + const uploadDokumen = async () => { + const configApp = JSON.parse(window.localStorage.getItem('configApp')); + + const formData = new FormData; + formData.append('dokumen', file, file.name); + formData.append('company_name',configApp.company_name); + + if (parentIdNewFolder > 0) { + formData.append('ref_id', parentIdNewFolder); // folder_id + formData.append('type_dokumen', 'project-document-in-folder'); + } + else { + formData.append('ref_id', idTask); // proyek_id + formData.append('type_dokumen', 'project-document-out-folder') + } + + const result = await axios + .post(DOCUMENT_ADD, formData, HEADER) + .then(res => res) + .catch((error) => error.response); + const notif = result.data.message; + if (result && result.status == 200) { + NotificationManager.success(notif, 'Success'); + closeDialog('upload') + } else { + NotificationManager.error(notif, 'Failed'); + closeDialog('failed upload') + } + } + + const handleCancel = () => { + closeDialog('cancel') + handleCLearData() + } + + const renderForm = () => { + return ( + + + + setFile(e.target.files[0])} /> + + + ) + } + + + return ( + <> + + Upload Project Document + + {renderForm()} + + + {' '} + + + + + ) + +} + +export default DialogRequest; diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 0dfde37..8a25b0e 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -968,7 +968,7 @@ const CreatedProyek = ({ params, ...props }) => { }; const onConfirmDelete = async () => { - let urlDel = PROYEK_DELETE(idDelete); + let urlDel = PROYEK_DELETE(idDelete, company_id); const result = await axios .delete(urlDel, HEADER) .then((res) => res) @@ -1189,8 +1189,8 @@ const CreatedProyek = ({ params, ...props }) => { }; const deleteImage = async (id) => { - const URL = IMAGE_DELETE(id, 'project_structure_organization'); - + const company_id = localStorage.getItem("company_id"); + const URL = IMAGE_DELETE(id, 'project_structure_organization', company_id); await axios .delete(URL, HEADER) .then(res => res) diff --git a/src/views/SimproV2/ResourceWorker/DialogForm.js b/src/views/SimproV2/ResourceWorker/DialogForm.js index 2c08421..86a53ec 100644 --- a/src/views/SimproV2/ResourceWorker/DialogForm.js +++ b/src/views/SimproV2/ResourceWorker/DialogForm.js @@ -135,6 +135,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi username, password, email, + company_id: parseInt(company_id) } closeDialog('edit', data); @@ -215,8 +216,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi - {/* setKtpNumber(e.target.value.replace(/[^0-9]/g, ''))} placeholder={`Input NIK (KTP)...`} maxLength="16" /> */} - setKtpNumber(e.target.value.replace(/[^0-9]/g, ''))} placeholder={t('inputNik')} maxLength="16" /> + setKtpNumber(e.target.value)} placeholder={'KTP/ID Card'} maxLength="16" /> From ed8a3ae6cdcde00de4c85170776fb253f89103da Mon Sep 17 00:00:00 2001 From: wahyun Date: Mon, 19 Feb 2024 17:09:35 +0700 Subject: [PATCH 3/5] add kanban route --- src/routes.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes.js b/src/routes.js index 6847782..eb71b0f 100644 --- a/src/routes.js +++ b/src/routes.js @@ -47,6 +47,7 @@ const Shift = React.lazy(() => import('./views/SimproV2/Shift')); const TestGantt = React.lazy(() => import('./views/testgantt')); const UserAdmin = React.lazy(() => import('./views/Master/UserAdmin')); const UserShift = React.lazy(() => import('./views/SimproV2/UserShift')); +const Kanban = React.lazy(() => import('./views/SimproV2/Kanban')); // const DashboardProject = React.lazy(() => import('./views/DashboardProject')); const DashboardBOD = React.lazy(() => import('./views/Dashboard/DashboardBOD')); const DashboardCustomer = React.lazy(() => import('./views/Dashboard/DashboardCustomer')); @@ -71,7 +72,6 @@ const routes = [ { path: '/human-resource', exact: true, name: 'Human Resource', component: ResourceWorker }, { path: '/material-resource', exact: true, name: 'Material Resource', component: ResourceMaterial }, { path: '/tools-resource', exact: true, name: 'Tools Resource', component: ResourceTools }, - { path: '/control-monitoring', exact: true, name: 'Control Monitoring', component: ControlMonitoring }, { path: '/control-monitoring-gantt', exact: true, name: 'Control Monitoring Gantt', component: ControlMonitoringGantt }, { path: '/presensi-resource', exact: true, name: 'Presensi Resource', component: Presensi }, @@ -79,9 +79,9 @@ const routes = [ { path: '/laporan-k3', exact: true, name: 'Laporan K3', component: K3 }, { path: '/broadcast', exact: true, name: 'Broadcast', component: Broadcast }, { path: '/panic-button', exact: true, name: 'Tombol Darurat', component: PanicButton }, - + { path: '/kanban', exact: true, name: 'Kanban', component: Kanban }, + { path: '/kanban/:proyek_id/:version_gantt_id', exact: true, name: 'Kanban', component: Kanban }, { path: '/closing', exact: true, name: 'Closing', component: Closing }, - { path: '/menu', exact: true, name: 'Menu', component: Menu }, { path: '/roles', exact: true, name: 'Roles', component: Roles }, { path: '/project-role', exact: true, name: 'Project Role', component: ProjectRole }, From fbdb1690ab4d076e08e6f7465da0be0bddabc51f Mon Sep 17 00:00:00 2001 From: wahyun Date: Mon, 19 Feb 2024 17:09:51 +0700 Subject: [PATCH 4/5] cleared --- src/views/ControlMonitoringGantt/index.js | 494 +++++++++++----------- 1 file changed, 247 insertions(+), 247 deletions(-) diff --git a/src/views/ControlMonitoringGantt/index.js b/src/views/ControlMonitoringGantt/index.js index 95a5376..fc3c1b4 100644 --- a/src/views/ControlMonitoringGantt/index.js +++ b/src/views/ControlMonitoringGantt/index.js @@ -1,247 +1,247 @@ -import React, { useEffect, useMemo, useState } from 'react'; -import Timeline from 'react-calendar-timeline' -import 'react-calendar-timeline/lib/Timeline.css' -import moment from 'moment'; -import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH_DETAIL, GANTT_CONTROL_MONITORING_SEARCH, PROYEK_EDIT, PROYEK_DELETE } from '../../const/ApiConst'; -import axios from 'axios'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { Button } from 'antd'; -import { - Container, Col, Row, UncontrolledTooltip, - Card, - CardBody, - CardHeader, - Table, - Modal, ModalHeader, ModalBody, ModalFooter -} from 'reactstrap'; -import GanttFull from './GanttDhtmlx2'; -import DialogForm from '../Master/Proyek/DialogForm'; -import DialogFormSub from '../Master/Proyek/DialogFormSub'; -import Iframe from "@nicholasadamou/react-iframe"; - -const getUrlParameter = (sParam) => { - var sPageURL = window.location.search.substring(1), - sURLVariables = sPageURL.split('&'), - sParameterName, - i; - - for (i = 0; i < sURLVariables.length; i++) { - sParameterName = sURLVariables[i].split('='); - - if (sParameterName[0] === sParam) { - return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); - } - } - return false; -}; - -const GanttTimeLine = () => { - const token = localStorage.getItem("token") - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - - const [proyekId, setProyekId] = useState(15); - const [dataGantt, setDataGantt] = useState([]); - const [prevProyekId, setPrevProyekId] = useState(0); - const [dataGroupGantt, setDataGroupGantt] = useState([]); - const [maxDateGantt, setMaxDateGantt] = useState(null); - const [minDateGantt, setMinDateGantt] = useState(null); - const [dataAllTimeLine, setDataAllTimeLine] = useState([]); - const [prevDataAllTimeLine, setPrevDataAllTimeLine] = useState(null); - - const [idTask, setidTask] = useState(0); - const [dataTable, setDatatable] = useState([]) - const [search, setSearch] = useState('') - const [currentPage, setCurrentPage] = useState(1) - const [totalPage, setTotalPage] = useState(0) - const [openDialog, setOpenDialog] = useState(false) - const [openDialogSub, setOpenDialogSub] = useState(false) - const [typeDialog, setTypeDialog] = useState('Save'); - const [typeDialogSub, setTypeDialogSub] = useState('Save') - const [idDelete, setIdDelete] = useState(0) - const [alertDelete, setAlertDelete] = useState(false) - const [dataEdit, setDataEdit] = useState([]) - const [dataEditSub, setDataEditSub] = useState([]) - const [rowsPerPage, setRowsPerPage] = useState(10) - const [clickOpenModal, setClickOpenModal] = useState(false) - const [dataExport, setDataExport] = useState([]) - const [allDataMenu, setAllDataMenu] = useState([]) - const [idSubtask, setIdSubtask] = useState(0); - - const handleMappingDataGantt = (data) => { - const minDates = data.map(res => moment(res.mulai_proyek)), - minDate = moment.min(minDates) - const maxDates = data.map(res => moment(res.akhir_proyek)), - maxDate = moment.max(maxDates) - - let groups = [] - let items = [] - data.map((res, idx) => { - let group = { - id: res.id, - title: res.nama, - stackItems: true, - height: 50 - } - let item = { - id: res.id, - group: res.id, - title: res.pic, - start_time: moment(res.mulai_proyek), - end_time: moment(res.akhir_proyek), - } - groups.push(group) - items.push(item) - }) - setDataGantt(items) - setDataGroupGantt(groups) - setMaxDateGantt(maxDate) - setMinDateGantt(minDate) - } - - const handleGetDataProyek = async () => { - - const payload = { - "columns": [ - { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } - ], - "joins": [ - { "name": "subproyeks.m_proyek", "column_join": "proyek_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }, - { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] } - ], - "orders": { "columns": ["id"], "ascending": true }, - "paging": { "start": 0, "length": 25 } - } - - const result = await axios - .post(GANTT_CONTROL_MONITORING_SEARCH, payload, HEADER) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - const { data } = result.data - setDataAllTimeLine(data) - setPrevDataAllTimeLine(data) - handleMappingDataGantt(data) - - } else { - NotificationManager.error('Gagal Export Data!!', 'Failed'); - } - } - - useEffect(() => { - let proyek_id = getUrlParameter('proyek_id'); - if (proyek_id) { - setProyekId(proyek_id); - } - handleGetDataProyek() - }, []); - - const handleClickGroupGantt = param => { - const row = prevDataAllTimeLine.filter(res => res.id === param) - if (row.length > 0) { - const { subproyeks, proyek_id, parent_id } = row[0] - setPrevProyekId(parent_id || proyek_id) - handleMappingDataGantt(subproyeks) - setDataAllTimeLine(subproyeks) - } - - } - - const handleOpenDialog = (type) => { - setOpenDialog(true) - setTypeDialog(type) - } - - const handleOpenDialogSub = (type, param) => { - const { id, parent_id, proyek_id, parent } = param - const idParent = parent == 0 ? 0 : parent == proyek_id ? id : parent_id - setidTask(proyek_id) - setIdSubtask(idParent) - setOpenDialogSub(true) - setTypeDialogSub(type) - } - - const handleCloseDialog = (type, data) => { - if (type === "save") { - saveProyek(data); - } - - setDataEdit([]) - setOpenDialog(false) - } - - const handleCloseDialogSub = (type, data) => { - setDataEditSub([]) - setOpenDialogSub(false) - if (type !== "cancel") { - handleGetDataProyek() - } - - } - - const toggleAddDialog = () => { - setOpenDialog(!openDialog) - } - - const toggleAddDialogSub = () => { - setOpenDialogSub(!openDialogSub) - } - - const saveProyek = async (data) => { - const formData = data - - const result = await axios.post(PROYEK_ADD, formData, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - handleGetDataProyek() - NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!'); - } else { - NotificationManager.error(`${result.data.message}`, 'Failed!!'); - } - - } - - const RenderGantt = useMemo(() => ( - - ), [dataAllTimeLine, maxDateGantt, minDateGantt]) - - return ( -
- {/* {RenderGantt} */} - {/* */} - */} +