From 6eba2eb1a6e8c75d9b4425edd5dbc077592309f2 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Sun, 24 Dec 2023 21:04:16 +0700 Subject: [PATCH 01/17] add routing --- src/routes.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/routes.js b/src/routes.js index 2719201..b9920f1 100644 --- a/src/routes.js +++ b/src/routes.js @@ -31,6 +31,10 @@ const Presensi = React.lazy(() => import('./views/SimproV2/Presence')); const ProjectRole = React.lazy(() => import('./views/Master/RoleProject')); const ProjectType = React.lazy(() => import('./views/SimproV2/ProjectType')); const ProjectPhase = React.lazy(() => import('./views/Master/ProjectPhase')); +const ProjectExpenditure = React.lazy(() => import('./views/Master/ProjectExpenditure')); +const ProjectFinancialHealth = React.lazy(() => import('./views/Master/ProjectFinancialHealth')); +const ProjectScheduleHealth = React.lazy(() => import('./views/Master/ProjectScheduleHealth')); +const ProjectInvoice = React.lazy(() => import('./views/Master/ProjectInvoice')); const Proyek = React.lazy(() => import('./views/Master/Proyek')); const RateCost = React.lazy(() => import('./views/SimproV2/RateCost')); const ResourceMaterial = React.lazy(() => import('./views/SimproV2/ResourceMaterial')); @@ -82,6 +86,10 @@ const routes = [ { path: '/project-role', exact: true, name: 'Project Role', component: ProjectRole }, { path: '/project-type', exact: true, name: 'Project Type', component: ProjectType }, { path: '/project-phase', exact: true, name: 'Project Phase', component: ProjectPhase }, + { path: '/project-expenditure', exact: true, name: 'Project Expenditure', component: ProjectExpenditure }, + { path: '/project-financial-health', exact: true, name: 'Project Financial Health', component: ProjectFinancialHealth }, + { path: '/project-schedule-health', exact: true, name: 'Project Schedule Health', component: ProjectScheduleHealth }, + { path: '/project-invoice', exact: true, name: 'Project Invoice vs Cash In', component: ProjectInvoice }, { path: '/divisi', exact: true, name: 'Divisi', component: Divisi }, { path: '/satuan', exact: true, name: 'Satuan', component: Satuan }, { path: '/config-alert', exact: true, name: 'Config Alert', component: ConfigAlert }, From 5d854478f53ce925a2e6d0f5dea68fb0de614591 Mon Sep 17 00:00:00 2001 From: wahyun Date: Thu, 4 Jan 2024 08:39:46 +0700 Subject: [PATCH 02/17] update props --- src/containers/DefaultLayout/DefaultLayout.js | 55 +- src/views/Dashboard/DashboardBOD.js | 31 +- src/views/Dashboard/DashboardCustomer.js | 27 +- src/views/Dashboard/DashboardProject.js | 20 +- .../Dashboard/DashboardProjectCarousell.js | 31 +- src/views/MapMonitoring/index.js | 31 +- src/views/Master/MasterRoles/index.js | 28 +- src/views/Master/ProjectExpenditure/index.js | 27 +- .../Master/ProjectFinancialHealth/index.js | 27 +- src/views/Master/ProjectInvoice/index.js | 27 +- src/views/Master/ProjectPhase/index.js | 791 +++++------ .../Master/ProjectScheduleHealth/index.js | 27 +- src/views/Master/RoleProject/index.js | 26 +- src/views/Pages/Login/Login.js | 43 +- src/views/Report/k3/index.js | 1263 ++++++++--------- src/views/SimproV2/CreatedProyek/index.js | 44 +- src/views/SimproV2/Divisi/index.js | 29 +- src/views/SimproV2/Gantt/GanttFrame.js | 17 +- src/views/SimproV2/Gantt/index.js | 27 +- src/views/SimproV2/ProjectType/index.js | 27 +- src/views/SimproV2/ResourceWorker/index.js | 27 +- src/views/SimproV2/Satuan/index.js | 30 +- 22 files changed, 1338 insertions(+), 1317 deletions(-) diff --git a/src/containers/DefaultLayout/DefaultLayout.js b/src/containers/DefaultLayout/DefaultLayout.js index 4cdd3cb..abb5cf9 100644 --- a/src/containers/DefaultLayout/DefaultLayout.js +++ b/src/containers/DefaultLayout/DefaultLayout.js @@ -36,18 +36,34 @@ const config = { }; class DefaultLayout extends Component { - constructor(props) { - super(props); - this.state = { - role_id: localStorage.getItem('role_id'), - token: localStorage.getItem('token'), - menu: { items: [] }, - routes2: routes, - finalRoutes: [], - breadrCrumbReady: false, - minimized: true - } - } + constructor(props) { + super(props); + + let role_id = '', token = '', company_id = 0, menu='' + if (props.location.state && props.location.state.role_id) { + role_id = props.location.state.role_id; + token = props.location.state.token; + company_id = props.location.state.company_id; + menu = props.location.state.menu_login; + } else { + role_id = localStorage.getItem("role_id"); + token = localStorage.getItem("token"); + company_id = localStorage.getItem('company_id'); + menu = localStorage.getItem("menu_login"); + } + + this.state = { + role_id: role_id, + token: token, + menu: { items: [] }, + routes2: routes, + finalRoutes: [], + breadrCrumbReady: false, + minimized: true, + company_id: company_id + }; + } + async componentDidMount() { const menu = localStorage.getItem("menu_login") @@ -295,7 +311,20 @@ class DefaultLayout extends Component { exact={route.exact} name={route.name} render={props => ( - + )} /> ) : (null); })} diff --git a/src/views/Dashboard/DashboardBOD.js b/src/views/Dashboard/DashboardBOD.js index 46175ac..1341c88 100644 --- a/src/views/Dashboard/DashboardBOD.js +++ b/src/views/Dashboard/DashboardBOD.js @@ -15,24 +15,19 @@ import { HealthByBudget, HealthBySchedule } from './Components'; import { Link } from 'react-router-dom'; const DashboardBOD = (props) => { - let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, all_project = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - company_id = props.location.state.company_id; - all_project = props.location.state.all_project; - } else { - role_id = localStorage.getItem("role_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - all_project = localStorage.getItem('all_project'); - } - let hierarchy = []; - hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } const HEADER = { headers: { "Content-Type": "application/json", diff --git a/src/views/Dashboard/DashboardCustomer.js b/src/views/Dashboard/DashboardCustomer.js index 93b8f86..8f0f5f6 100644 --- a/src/views/Dashboard/DashboardCustomer.js +++ b/src/views/Dashboard/DashboardCustomer.js @@ -26,18 +26,19 @@ const center = { } const DashboardCustomer = (props) => { - let role_id = '', user_id = '', isLogin = '', token = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - } else { - role_id = localStorage.getItem("role_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - } + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } const HEADER = { headers: { "Content-Type": "application/json", @@ -45,7 +46,7 @@ const DashboardCustomer = (props) => { } } const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); - const URL_GANTT = `https://konstruksi-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; + const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; const mapRef = useRef() const [projectName, setProjectName] = useState(""); const [projectManagerName, setProjectManagerName] = useState(''); diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index be177a7..b70c658 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -63,8 +63,22 @@ const center = { lng: 106.816666, }; -const DashboardProject = () => { - const token = localStorage.getItem("token"); +const DashboardProject = (props) => { + + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } + const HEADER = { headers: { "Content-Type": "application/json", @@ -72,7 +86,7 @@ const DashboardProject = () => { }, }; const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); - const URL_GANTT = `https://konstruksi-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; + const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; const mapRef = useRef(); const [projectName, setProjectName] = useState(""); const [projectManagerName, setProjectManagerName] = useState(""); diff --git a/src/views/Dashboard/DashboardProjectCarousell.js b/src/views/Dashboard/DashboardProjectCarousell.js index 774fd2d..57f35e7 100644 --- a/src/views/Dashboard/DashboardProjectCarousell.js +++ b/src/views/Dashboard/DashboardProjectCarousell.js @@ -69,16 +69,21 @@ const center = { lng: 106.816666, }; -const DashboardProject = (args) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, all_project = '', hierarchy = []; - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - all_project = localStorage.getItem('all_project'); - hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); +const DashboardProject = ({args,...props}) => { + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } + const HEADER = { headers: { "Content-Type": "application/json", @@ -231,7 +236,7 @@ const DashboardProject = (args) => { let URL_GANTT = ""; let version_gantt = ""; if (item.gantt !== null) { - URL_GANTT = `http://localhost:8444/adw-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${item.gantt.id}&proyek_id=${item.gantt.proyek_id}&token=${token}&ro=1`; + URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${item.gantt.id}&proyek_id=${item.gantt.proyek_id}&token=${token}&ro=1`; version_gantt = item.gantt.name_version } else { URL_GANTT = ""; @@ -803,10 +808,10 @@ const DashboardProject = (args) => { > {slides}
- +
- +
diff --git a/src/views/MapMonitoring/index.js b/src/views/MapMonitoring/index.js index 8df8828..aaa61b5 100644 --- a/src/views/MapMonitoring/index.js +++ b/src/views/MapMonitoring/index.js @@ -28,20 +28,19 @@ import 'leaflet-control-geocoder/dist/Control.Geocoder.js' import moment from 'moment'; import axios from "../../const/interceptorApi"; const MapMonitoring = ({ ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - } + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } const HEADER = { headers: { "Content-Type": "application/json", @@ -67,7 +66,7 @@ const MapMonitoring = ({ ...props }) => { let markerCluster = L.markerClusterGroup({ name: "userPointLayer", - // disableClusteringAtZoom: 17, + // disableClusteringAtZoom: 17, showCoverageOnHover: false, // spiderfyOnMaxZoom: false }); @@ -333,4 +332,4 @@ const MapMonitoring = ({ ...props }) => { return MapContent } -export default MapMonitoring; \ No newline at end of file +export default MapMonitoring; diff --git a/src/views/Master/MasterRoles/index.js b/src/views/Master/MasterRoles/index.js index ddd84da..c6fec9d 100644 --- a/src/views/Master/MasterRoles/index.js +++ b/src/views/Master/MasterRoles/index.js @@ -16,21 +16,19 @@ const LENGTH_DATA = 10 class index extends Component { constructor(props) { - let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - company_id = props.location.state.company_id; - role_name = props.location.state.role_name; - - - } else { - token = window.localStorage.getItem('token'); - role_name = window.localStorage.getItem('role_name'); - company_id = window.localStorage.getItem('company_id'); - } + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } super(props) this.config = { headers: { diff --git a/src/views/Master/ProjectExpenditure/index.js b/src/views/Master/ProjectExpenditure/index.js index 4dde162..c9b227d 100644 --- a/src/views/Master/ProjectExpenditure/index.js +++ b/src/views/Master/ProjectExpenditure/index.js @@ -12,21 +12,18 @@ import { useTranslation } from 'react-i18next'; const ProjectExpenditure = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } const HEADER = { diff --git a/src/views/Master/ProjectFinancialHealth/index.js b/src/views/Master/ProjectFinancialHealth/index.js index bc6b0a3..28f9fcd 100644 --- a/src/views/Master/ProjectFinancialHealth/index.js +++ b/src/views/Master/ProjectFinancialHealth/index.js @@ -12,21 +12,18 @@ import { useTranslation } from 'react-i18next'; const ProjectFinancialHealth = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } const HEADER = { diff --git a/src/views/Master/ProjectInvoice/index.js b/src/views/Master/ProjectInvoice/index.js index da213a1..c030d1d 100644 --- a/src/views/Master/ProjectInvoice/index.js +++ b/src/views/Master/ProjectInvoice/index.js @@ -12,21 +12,18 @@ import { useTranslation } from 'react-i18next'; const ProjectInvoice = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } const HEADER = { diff --git a/src/views/Master/ProjectPhase/index.js b/src/views/Master/ProjectPhase/index.js index d9bbd17..78b914a 100644 --- a/src/views/Master/ProjectPhase/index.js +++ b/src/views/Master/ProjectPhase/index.js @@ -1,397 +1,394 @@ -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 { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, PROJECT_PHASE_LIST, BASE_OSPRO } from '../../../const/ApiConst'; -import { Pagination, Button, Tooltip, Table } from 'antd'; -import { useTranslation } from 'react-i18next'; - - -const ProjectPhase = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); - } - - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - const pageName = params.name; - - const [alertDelete, setAlertDelete] = useState(false) - const [allDataMenu, setAllDataMenu] = useState([]) - const [clickOpenModal, setClickOpenModal] = useState(false) - const [currentPage, setCurrentPage] = useState(1) - const [dataEdit, setDataEdit] = useState([]) - const [dataExport, setDataExport] = useState([]) - const [dataTable, setDatatable] = useState([]) - const [idDelete, setIdDelete] = useState(0) - const [idPhaseProject, setIdPhaseProject] = useState(0) - const [openDialog, setOpenDialog] = useState(false) - const [openDialogIG, setOpenDialogIG] = useState(false) - const [rowsPerPage, setRowsPerPage] = useState(10) - const [search, setSearch] = useState('') - const [totalPage, setTotalPage] = useState(0) - const [typeDialog, setTypeDialog] = useState('Save') - const { t } = useTranslation() - useEffect(() => { - getDataProjectPhase() - }, [currentPage, rowsPerPage, search]) - - useEffect(() => { - const cekData = dataExport || [] - if (cekData.length > 0) { - exportExcel() - } - }, [dataExport]) - - const getDataProjectPhase = async () => { - let start = 0; - if (currentPage !== 1 && currentPage > 1) { - start = (currentPage * rowsPerPage) - rowsPerPage - } - const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "ilike", - "value": search, - "operator": "AND" - } - ], - "orders": { - "ascending": true, - "columns": [ - 'id' - ] - }, - "paging": { - "length": rowsPerPage, - "start": start - } - } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - } - const result = await axios - .post(PROJECT_PHASE_SEARCH, payload, HEADER) - .then((res) => res) - .catch((err) => err.response); - - if (result && result.data && result.data.code == 200) { - result.data.data.map((res) => { - res.key = res.id.toString() - }); - setDatatable(result.data.data); - setTotalPage(result.data.totalRecord); - } else { - NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); - } - } - - const handleSearch = e => { - const value = e.target.value - setSearch(value); - setCurrentPage(1) - }; - const handleOpenDialog = (type) => { - setOpenDialog(true) - setTypeDialog(type) - } - - const handleExportExcel = async () => { - let start = 0; - - if (currentPage !== 1 && currentPage > 1) { - start = (currentPage * rowsPerPage) - rowsPerPage - } - - const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "like", - "value": search, - "operator": "AND" - } - ], - "orders": { - "ascending": true, - "columns": [ - 'id' - ] - }, - "paging": { - "length": rowsPerPage, - "start": start - } - } - - const result = await axios - .post(PROJECT_PHASE_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((val, index) => { - let dataRow = { - "Nama": val.name, - "Color": val.color, - } - 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 handleEdit = (data) => { - setDataEdit(data) - handleOpenDialog('Edit'); - } - - const handleDelete = async (id) => { - await setAlertDelete(true) - await setIdDelete(id) - } - - const handleCloseDialog = (type, data) => { - if (type === "save") { - saveProjectPhase(data); - } else if (type === "edit") { - editMaterialR(data); - } - setDataEdit([]) - setOpenDialog(false) - } - - const saveProjectPhase = async (data) => { - const formData = data - const result = await axios.post(PROJECT_PHASE_ADD, formData, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - getDataProjectPhase() - NotificationManager.success(`Data project type berhasil ditambah`, 'Success!!'); - } else { - NotificationManager.error(`${result.data.message}`, 'Failed!!'); - } - } - - const editMaterialR = async (data) => { - let urlEdit = PROJECT_PHASE_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) { - getDataProjectPhase(); - NotificationManager.success(`Data project phase berhasil diedit`, 'Success!!'); - } else { - NotificationManager.error(`Data project phase gagal di edit`, `Failed!!`); - } - } - - const toggleAddDialog = () => { - setOpenDialog(!openDialog) - } - - const handleDialogIg = (id) => { - setIdPhaseProject(id) - setOpenDialogIG(true) - } - - const closeDialogIG = () => { - setIdPhaseProject(0) - setOpenDialogIG(false) - } - - const toggleDialogIG = () => { - if (openDialogIG) { - setIdPhaseProject(0) - } - setOpenDialogIG(!openDialogIG); - } - - const onConfirmDelete = async () => { - let url = PROJECT_PHASE_DELETE(idDelete); - - const result = await axios.delete(url, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - getDataProjectPhase() - setIdDelete(0) - setAlertDelete(false) - NotificationManager.success(`Data project phase berhasil dihapus!`, 'Success!!'); - } else { - setIdDelete(0) - setAlertDelete(false) - NotificationManager.error(`Data project phase gagal dihapus!}`, 'Failed!!'); - } - } - - const cancelDelete = () => { - setAlertDelete(false) - setIdDelete(0) - } - - const onShowSizeChange = (current, pageSize) => { - setRowsPerPage(pageSize) - } - - const onPagination = (current, pageSize) => { - setCurrentPage(current) - } - - const dataNotAvailable = () => { - if (dataTable.length === 0) { - return ( - - {t('noData')} - - ) - } - } - - const renderTable = useMemo(() => { - const columns = [ - { - title: t('action'), - dataIndex: '', - key: 'x', - className: 'nowrap', - render: (text, record) => <> - - handleDelete(text.id)}> - - - handleEdit(text)}> - {" "} - , - }, - { title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" }, - { - title: t('color'), - dataIndex: 'color', - key: 'color', - render: (text) => <> - - - - , - }, - ]; - return ( - - ) - }, [dataTable]) - - return ( -
- - - {t('deleteMsg')} - - toggleAddDialog} - typeDialog={typeDialog} - dataEdit={dataEdit} - clickOpenModal={clickOpenModal} - dataParent={allDataMenu} - /> - - -

{pageName}

- -
- - - - - - - - - - - - - - {renderTable} - - - - - ) -} - -export default ProjectPhase; +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 { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; +import { NotificationContainer, NotificationManager } from 'react-notifications'; +import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, PROJECT_PHASE_LIST, BASE_OSPRO } from '../../../const/ApiConst'; +import { Pagination, Button, Tooltip, Table } from 'antd'; +import { useTranslation } from 'react-i18next'; + + +const ProjectPhase = ({ params, ...props }) => { + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } + + const HEADER = { + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + } + } + const pageName = params.name; + + const [alertDelete, setAlertDelete] = useState(false) + const [allDataMenu, setAllDataMenu] = useState([]) + const [clickOpenModal, setClickOpenModal] = useState(false) + const [currentPage, setCurrentPage] = useState(1) + const [dataEdit, setDataEdit] = useState([]) + const [dataExport, setDataExport] = useState([]) + const [dataTable, setDatatable] = useState([]) + const [idDelete, setIdDelete] = useState(0) + const [idPhaseProject, setIdPhaseProject] = useState(0) + const [openDialog, setOpenDialog] = useState(false) + const [openDialogIG, setOpenDialogIG] = useState(false) + const [rowsPerPage, setRowsPerPage] = useState(10) + const [search, setSearch] = useState('') + const [totalPage, setTotalPage] = useState(0) + const [typeDialog, setTypeDialog] = useState('Save') + const { t } = useTranslation() + useEffect(() => { + getDataProjectPhase() + }, [currentPage, rowsPerPage, search]) + + useEffect(() => { + const cekData = dataExport || [] + if (cekData.length > 0) { + exportExcel() + } + }, [dataExport]) + + const getDataProjectPhase = async () => { + let start = 0; + if (currentPage !== 1 && currentPage > 1) { + start = (currentPage * rowsPerPage) - rowsPerPage + } + const payload = { + "columns": [ + { + "name": "name", + "logic_operator": "ilike", + "value": search, + "operator": "AND" + } + ], + "orders": { + "ascending": true, + "columns": [ + 'id' + ] + }, + "paging": { + "length": rowsPerPage, + "start": start + } + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + } + const result = await axios + .post(PROJECT_PHASE_SEARCH, payload, HEADER) + .then((res) => res) + .catch((err) => err.response); + + if (result && result.data && result.data.code == 200) { + result.data.data.map((res) => { + res.key = res.id.toString() + }); + setDatatable(result.data.data); + setTotalPage(result.data.totalRecord); + } else { + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } + } + + const handleSearch = e => { + const value = e.target.value + setSearch(value); + setCurrentPage(1) + }; + const handleOpenDialog = (type) => { + setOpenDialog(true) + setTypeDialog(type) + } + + const handleExportExcel = async () => { + let start = 0; + + if (currentPage !== 1 && currentPage > 1) { + start = (currentPage * rowsPerPage) - rowsPerPage + } + + const payload = { + "columns": [ + { + "name": "name", + "logic_operator": "like", + "value": search, + "operator": "AND" + } + ], + "orders": { + "ascending": true, + "columns": [ + 'id' + ] + }, + "paging": { + "length": rowsPerPage, + "start": start + } + } + + const result = await axios + .post(PROJECT_PHASE_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((val, index) => { + let dataRow = { + "Nama": val.name, + "Color": val.color, + } + 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 handleEdit = (data) => { + setDataEdit(data) + handleOpenDialog('Edit'); + } + + const handleDelete = async (id) => { + await setAlertDelete(true) + await setIdDelete(id) + } + + const handleCloseDialog = (type, data) => { + if (type === "save") { + saveProjectPhase(data); + } else if (type === "edit") { + editProjectPhase(data); + } + setDataEdit([]) + setOpenDialog(false) + } + + const saveProjectPhase = async (data) => { + const formData = data + const result = await axios.post(PROJECT_PHASE_ADD, formData, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getDataProjectPhase() + NotificationManager.success(`Data project type berhasil ditambah`, 'Success!!'); + } else { + NotificationManager.error(`${result.data.message}`, 'Failed!!'); + } + } + + const editProjectPhase = async (data) => { + let urlEdit = PROJECT_PHASE_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) { + getDataProjectPhase(); + NotificationManager.success(`Data project phase berhasil diedit`, 'Success!!'); + } else { + NotificationManager.error(`Data project phase gagal di edit`, `Failed!!`); + } + } + + const toggleAddDialog = () => { + setOpenDialog(!openDialog) + } + + const handleDialogIg = (id) => { + setIdPhaseProject(id) + setOpenDialogIG(true) + } + + const closeDialogIG = () => { + setIdPhaseProject(0) + setOpenDialogIG(false) + } + + const toggleDialogIG = () => { + if (openDialogIG) { + setIdPhaseProject(0) + } + setOpenDialogIG(!openDialogIG); + } + + const onConfirmDelete = async () => { + let url = PROJECT_PHASE_DELETE(idDelete); + + const result = await axios.delete(url, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getDataProjectPhase() + setIdDelete(0) + setAlertDelete(false) + NotificationManager.success(`Data project phase berhasil dihapus!`, 'Success!!'); + } else { + setIdDelete(0) + setAlertDelete(false) + NotificationManager.error(`Data project phase gagal dihapus!}`, 'Failed!!'); + } + } + + const cancelDelete = () => { + setAlertDelete(false) + setIdDelete(0) + } + + const onShowSizeChange = (current, pageSize) => { + setRowsPerPage(pageSize) + } + + const onPagination = (current, pageSize) => { + setCurrentPage(current) + } + + const dataNotAvailable = () => { + if (dataTable.length === 0) { + return ( + + + + ) + } + } + + const renderTable = useMemo(() => { + const columns = [ + { + title: t('action'), + dataIndex: '', + key: 'x', + className: 'nowrap', + render: (text, record) => <> + + handleDelete(text.id)}> + + + handleEdit(text)}> + {" "} + , + }, + { title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" }, + { + title: t('color'), + dataIndex: 'color', + key: 'color', + render: (text) => <> + + + + , + }, + ]; + return ( +
{t('noData')}
+ ) + }, [dataTable]) + + return ( +
+ + + {t('deleteMsg')} + + toggleAddDialog} + typeDialog={typeDialog} + dataEdit={dataEdit} + clickOpenModal={clickOpenModal} + dataParent={allDataMenu} + /> + + +

{pageName}

+ +
+ + + + + + + + + + + + + + {renderTable} + + + + + ) +} + +export default ProjectPhase; diff --git a/src/views/Master/ProjectScheduleHealth/index.js b/src/views/Master/ProjectScheduleHealth/index.js index ed90090..36bc06f 100644 --- a/src/views/Master/ProjectScheduleHealth/index.js +++ b/src/views/Master/ProjectScheduleHealth/index.js @@ -12,21 +12,18 @@ import { useTranslation } from 'react-i18next'; const ProjectScheduleHealth = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } const HEADER = { diff --git a/src/views/Master/RoleProject/index.js b/src/views/Master/RoleProject/index.js index a9e22ae..89d7312 100644 --- a/src/views/Master/RoleProject/index.js +++ b/src/views/Master/RoleProject/index.js @@ -35,18 +35,18 @@ const LENGTH_DATA = 10 class index extends Component { constructor(props) { - let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - company_id = props.location.state.company_id; - role_name = props.location.state.role_name; - } else { - token = window.localStorage.getItem('token'); - role_name = window.localStorage.getItem('role_name'); - company_id = window.localStorage.getItem('company_id'); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } super(props) this.state = { @@ -408,4 +408,4 @@ class index extends Component { ) } } -export default withTranslation()(index); \ No newline at end of file +export default withTranslation()(index); diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js index 1104ecc..17eb331 100644 --- a/src/views/Pages/Login/Login.js +++ b/src/views/Pages/Login/Login.js @@ -120,7 +120,7 @@ class Login extends Component { } } - getDataMenu = async (token, role_id, user_id, company_id, role_name, all_project) => { + getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name) => { const config = { headers: { @@ -146,14 +146,36 @@ class Login extends Component { else { this.props.history.push({ pathname: "/dashboard", - state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name, all_project: all_project } + state: { + menu_login: JSON.stringify(resData), + hierarchy, + role_id, + user_id, + token, + isLogin: true, + company_id, + role_name, + all_project, + user_name + } }); } if (this.state.defaultPage) { if (role_id === 44) { this.props.history.push({ pathname: this.state.defaultPage, - state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name, all_project: all_project } + state: { + menu_login: JSON.stringify(resData), + hierarchy, + role_id, + user_id, + token, + isLogin: true, + company_id, + role_name, + all_project, + user_name + } }); } else { this.props.history.push(this.state.defaultPage); @@ -164,7 +186,18 @@ class Login extends Component { else { this.props.history.push({ pathname: "/dashboard", - state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name } + state: { + menu_login: JSON.stringify(resData), + hierarchy, + role_id, + user_id, + token, + isLogin: true, + company_id, + role_name, + all_project, + user_name + } }); } } else { @@ -209,7 +242,7 @@ class Login extends Component { if (doLogin && doLogin.data && doLogin.data.code === 200) { const { access_token, data_user } = doLogin.data.data this.getDataRole(access_token, data_user.role_id) - this.getDataMenu(access_token, data_user.role_id, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project) + this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name) window.localStorage.setItem('isLogin', true); window.localStorage.setItem('token', access_token); window.localStorage.setItem('user_id', data_user.id); diff --git a/src/views/Report/k3/index.js b/src/views/Report/k3/index.js index 36f415a..d967fd9 100644 --- a/src/views/Report/k3/index.js +++ b/src/views/Report/k3/index.js @@ -1,634 +1,629 @@ -import React, { Component } from 'react'; -import { Card, CardBody, CardHeader, Col, Row, Table, Input, InputGroup } from 'reactstrap'; -import { Button } from 'reactstrap'; -import axios from 'axios'; -import moment from 'moment'; -import SweetAlert from 'react-bootstrap-sweetalert'; -import DialogForm from './DialogForm'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { Pagination, Tooltip } from 'antd'; -import { DatePicker, Select } from 'antd'; -import * as XLSX from 'xlsx'; -import { PRESENSI_SEARCH, PROYEK_SEARCH, USERPROYEK_SEARCH, K3_SEARCH, SIMPRO_BASE_IMAGE } from '../../../const/ApiConst.js'; -import { withTranslation } from 'react-i18next'; -const { RangePicker } = DatePicker; -const { Option } = Select - - -const BASE_URL = "" - -const momentFormat = 'DD-MM-YY'; - - - -const LENGTH_DATA = 10 - -class index extends Component { - - constructor(props) { - - let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = '', hierarchy = []; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - company_id = props.location.state.company_id; - role_name = props.location.state.role_name; - hierarchy = props.location.state.hierarchy; - - - } else { - token = window.localStorage.getItem('token'); - role_name = window.localStorage.getItem('role_name'); - company_id = window.localStorage.getItem('company_id'); - hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); - } - super(props) - this.config = { - headers: { - Authorization: `Bearer ${token}`, - "Content-type": "application/json" - } - }; - this.state = { - dataTable: [], - dataExport: [], - openDialog: false, - dataImage: {}, - typeDialog: 'Save', - dataEdit: null, - alertDelete: false, - idDelete: 0, - dataGs: [], - dataIdHo: [], - search: "", - page: 0, - rowsPerPage: LENGTH_DATA, - currentPage: 1, - totalPage: 0, - tooltipEdit: false, - tooltipDelete: false, - typeClock: "All", - startDate: moment(moment().format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentDay: 'today', - tooltipExport: false, - disableProyek: false, - currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null, - allUserToProyek: [], - proyekIds: [], - allDataProyek: [], - finishSetupOption: false, - company_id: company_id, - role_name: role_name, - role_id: role_id, - hierarchy: hierarchy - } - } - - async componentDidMount() { - this.getAllProyek(); - this.setUpFirstProyek(); - } - - async componentDidUpdate(prevProps, prevState) { - const { search, startDate, dataExport, proyekIds, currentProyek } = this.state - if (search !== prevState.search) this.getDataLaporanK3() - if (startDate !== prevState.startDate) this.getDataLaporanK3() - if (dataExport !== prevState.dataExport) { - if (dataExport.length > 0) { - this.exportExcel() - } - } - if (proyekIds !== prevState.proyekIds) { - this.getDataLaporanK3(); - } - - if (currentProyek !== prevState.currentProyek) { - this.getDataLaporanK3(); - } - } - - setUpFirstProyek = () => { - if (parseInt(localStorage.getItem('role_id')) === 2) { - this.setState({ disableProyek: true }); - } else { - this.setState({ currentProyek: null }) - } - } - handleSearch = e => { - const value = e.target.value - this.setState({ search: value, currentPage: 1 }) - }; - - getAllProyek = async () => { - const payload = { - "select": ["id", "nama"], - "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } - ], - "joins": [], - "orders": { "columns": ["id"], "ascending": false } - } - if (this.state.role_id !== "Super Admin") { - payload.columns.push( - { name: "created_by_id", logic_operator: "IN", value: this.state.hierarchy, operator: "AND" } - ) - } - - const result = await axios - .post(PROYEK_SEARCH, payload, this.config) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - let resData = result.data.data - - let proyekIds = [] - resData.map((val, index) => { - proyekIds.push(val.id); - }); - this.setState({ allDataProyek: resData, proyekIds: proyekIds }) - } else { - } - } - - getDataLaporanK3 = async () => { - - let start = 0; - if (this.state.currentPage !== 1 && this.state.currentPage > 1) { - start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage - } - - let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00"); - let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59"); - let currentProyek = this.state.currentProyek - const payload = { - "paging": { - "start": start, - "length": this.state.rowsPerPage - }, - "filter_columns": [ - { - "name": "name", - "value": "", - "table_name": "m_users" - } - ], - "columns": [ - { "name": "report_date", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" }, - { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" } - ], - "joins": [ - { - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "name", - ] - }, - { - "name": "m_proyek", - "column_join": "proyek_id", - "column_results": [ - "nama" - ] - } - ], - "orders": { - "columns": [ - "id" - ], - "ascending": false - }, - "child_data": { - "table_name": "t_report_k3_detail", - "column_table": "report_k3_id", - "column_name": "id" - } - } - - if (currentProyek) { - let proyekPayload = { "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek }; - payload.columns.push(proyekPayload) - } else { - let proyekPayload = { "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds }; - payload.columns.push(proyekPayload) - } - - const result = await axios - .post(K3_SEARCH, payload, this.config) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - let resData = result.data.data || [] - this.setState({ dataTable: resData, totalPage: result.data.totalRecord }); - } else { - NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); - } - } - - handleOpenDialog = (type) => { - this.setState({ openDialog: true, typeDialog: type }) - this.showChildDialog(); - } - - handleCloseDialog = (type, data) => { - if (type === "save") { - this.saveDivision(data); - } else if (type === "edit") { - this.editDataDivision(data); - } - - this.setState({ openDialog: false }) - } - - toggleAddDialog = () => { - this.setState({ openDialog: !this.state.openDialog }) - } - - onConfirmDelete = async () => { - const { idDelete } = this.state - let url = BASE_URL + `employee_devision.php?act=delete&id=${idDelete}`; - const result = await axios.post(url) - .then(res => res) - .catch((error) => error.response); - - if (result.message !== undefined) { - if (result.message === "Data Has Been Deleted") { - this.getDataLaporanK3() - this.setState({ idDelete: 0, alertDelete: false }) - NotificationManager.success('Data division berhasil dihapus!!', 'Success!!'); - } else { - this.setState({ idDelete: 0, alertDelete: false }) - NotificationManager.error('Data division gagal dihapus!!', 'Failed!!'); - } - } else { - if (result.data.message === "Data Has Been Deleted") { - this.getDataLaporanK3() - this.setState({ idDelete: 0, alertDelete: false }) - NotificationManager.success('Data division berhasil dihapus!!', 'Success!!'); - } else { - this.setState({ idDelete: 0, alertDelete: false }) - NotificationManager.error('Data division gagal dihapus!!', 'Failed!!'); - } - } - } - - saveDivision = async (data) => { - let url = BASE_URL + "employee_devision.php?act=input"; - - const formData = new FormData() - formData.append('name', data.name); - formData.append('description', data.description); - const result = await axios.post(url, formData) - .then(res => res) - .catch((error) => error.response); - - if (result.message !== undefined) { - if (result.message === "Data Has Been Saved") { - this.getDataLaporanK3(); - NotificationManager.success('Data division berhasil ditambahkan!!', 'Success!!'); - } else { - NotificationManager.error(`${result.data.message}`, 'Failed!!'); - } - } else { - if (result.data.message === "Data Has Been Saved") { - this.getDataLaporanK3(); - NotificationManager.success('Data division berhasil ditambahkan!!', 'Success!!'); - } else { - NotificationManager.error(`${result.data.message}`, 'Failed!!'); - } - } - - } - - editDataDivision = async (data) => { - let url = ""; - - const formData = new FormData(); - formData.append('name', data.name); - formData.append('description', data.description); - - const result = await axios.post(url, formData) - .then(res => res) - .catch((error) => error.response); - - if (result.data !== undefined) { - if (result.data.message === "Data Has Been Edited") { - this.getDataLaporanK3(); - NotificationManager.success('Data division berhasil diedit!!', 'Success!!'); - } else { - NotificationManager.error('Data division gagal diedit!!', 'Failed!!'); - } - } - } - - - handleEdit = (data) => { - this.setState({ dataEdit: data }); - this.handleOpenDialog('Edit'); - } - - handleDelete = (id) => { - this.setState({ alertDelete: true, idDelete: id }); - } - - onShowSizeChange = (current, pageSize) => { - this.setState({ rowsPerPage: pageSize }, () => { - this.getDataLaporanK3(); - }) - } - - onPagination = (current, pageSize) => { - this.setState({ currentPage: current, page: (current - 1) * pageSize }, () => { - this.getDataLaporanK3(); - }) - } - - toggle = (param) => { - if (param === "edit") { - this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit })) - } else if (param === "delete") { - this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete })) - } else if (param === "export") { - this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport })) - } - } - - handleDatePicker = (date, dateString) => { - this.setState({ startDate: date[0], endDate: date[1] }, () => { - this.getDataLaporanK3(); - }) - } - - handleTipe = (e) => { - this.setState({ typeClock: e.target.value }, () => { - this.getDataLaporanK3(); - }); - } - - handleExportExcel = async () => { - let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00"); - let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59"); - let currentProyek = this.state.currentProyek - const payload = { - "paging": { - "start": 0, - "length": -1 - }, - "columns": [ - { "name": "report_date", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" }, - { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" } - ], - "joins": [ - { - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "name", - ] - } - ], - "orders": { - "columns": [ - "id" - ], - "ascending": false - }, - "child_data": { - "table_name": "t_report_k3_detail", - "column_table": "report_k3_id", - "column_name": "id" - } - } - - if (currentProyek) { - let proyekPayload = { "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek }; - payload.columns.push(proyekPayload) - } else { - let proyekPayload = { "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds }; - payload.columns.push(proyekPayload) - } - - - - const result = await axios - .post(K3_SEARCH, payload, this.config) - .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 Human Resource": n.join_first_name ? n.join_first_name : "-", - "Tanggal Lapor": n.report_date ? moment(n.report_date).format("DD-MM-YYYY HH:mm:ss") : "-", - "Perlengkapan Dikenakan": n.k3_checked.length ? n.k3_checked.join() : "-", - "Perlengkapan Tidak Dikenakan": n.k3_not_checked.length ? n.k3_not_checked.join() : "-", - "Description": n.description ? n.description : "-" - } - excelData.push(dataRow) - }) - this.setState({ dataExport: excelData }) - } else { - NotificationManager.error('Gagal Export Data!!', 'Failed'); - } - } - - exportExcel = () => { - const dataExcel = this.state.dataExport || []; - const fileName = `Data Laporan K3.xlsx`; - const ws = XLSX.utils.json_to_sheet(dataExcel); - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, `Data Laporan K3`); - - XLSX.writeFile(wb, fileName); - this.setState({ dataExport: [] }) - } - - lihatFoto = (data) => { - this.showChildDialog(); - this.setState({ dataImage: data }, () => { - this.setState({ openDialog: true }); - }); - } - - renderTable = () => { - const { t } = this.props; - const dataTable2 = this.state.dataTable || []; - return ( - - {dataTable2.length !== 0 ? dataTable2.map((n) => { - return ( - - - - - - - - - - ) - }) : - - - } - - ) - } - - handleChangeDay = (e) => { - const val = e.target.value; - this.setState({ currentDay: val }); - if (val === "today") { - this.setState({ - startDate: moment(moment().format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentPage: 1 - }) - } else if (val === "3 day") { - this.setState({ - startDate: moment(moment().subtract(3, "days").format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentPage: 1 - }) - } else if (val === "7 day") { - this.setState({ - startDate: moment(moment().subtract(7, "days").format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentPage: 1 - }) - } else { - this.setState({ - startDate: moment(moment().format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentPage: 1 - }) - } - } - - setupSelectProyek = () => { - let allDataProyek = this.state.allDataProyek - return ( - <> - {allDataProyek.map((val, index) => { - return ( - - ) - }) - } - - ) - } - - onChangeProyek = (val) => { - this.setState({ currentProyek: val }); - } - - delay = (ms) => new Promise(res => setTimeout(res, ms)); - - render() { - const column = [ - { name: this.props.t('nameHR') }, - { name: this.props.t('projectName') }, - { name: this.props.t('dateReport') }, - { name: this.props.t('gearUse') }, - { name: this.props.t('gearNotUse') }, - { name: this.props.t('description') }, - { name: this.props.t('action') }, - ] - const t = this.props; - const { tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state - return ( -
- - this.setState({ alertDelete: false, idDelete: 0 })} - focusCancelBtn - > - {this.props.t('deleteMsg')} - - this.toggleAddDialog} - dataImage={this.state.dataImage} - showDialog={showDialog => this.showChildDialog = showDialog} - /> - - -

{this.props.params.name}

-
- - - -
-
- -
-
-
- -
-
- this.handleChangeDay(e)} defaultValue={this.state.currentDay}> - - - - -
-
- {' '} - -
-
- -
-
{n.join_first_name ? n.join_first_name : "-"}{n.join_second_nama ? n.join_second_nama : "-"}{n.report_date ? moment(n.report_date).format("DD-MM-YYYY") : "-"}{n.k3_checked.length ? n.k3_checked.join() : "-"}{n.k3_not_checked.length ? n.k3_not_checked.join() : "-"}{n.description ? n.description : "-"} {n.image ? this.lihatFoto(n.image)} className='fa fa-image'> : ""}
{this.props.t('noData')}
- - - {/* */} - {column.map((i, index) => { - return ( - - ) - })} - - - {this.renderTable()} -
Actions{i.name}
- - - - - ) - } -} -export default withTranslation()(index); +import React, { Component } from 'react'; +import { Card, CardBody, CardHeader, Col, Row, Table, Input, InputGroup } from 'reactstrap'; +import { Button } from 'reactstrap'; +import axios from 'axios'; +import moment from 'moment'; +import SweetAlert from 'react-bootstrap-sweetalert'; +import DialogForm from './DialogForm'; +import { NotificationContainer, NotificationManager } from 'react-notifications'; +import { Pagination, Tooltip } from 'antd'; +import { DatePicker, Select } from 'antd'; +import * as XLSX from 'xlsx'; +import { PRESENSI_SEARCH, PROYEK_SEARCH, USERPROYEK_SEARCH, K3_SEARCH, SIMPRO_BASE_IMAGE } from '../../../const/ApiConst.js'; +import { withTranslation } from 'react-i18next'; +const { RangePicker } = DatePicker; +const { Option } = Select + + +const BASE_URL = "" + +const momentFormat = 'DD-MM-YY'; + + + +const LENGTH_DATA = 10 + +class index extends Component { + + constructor(props) { + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } + super(props) + this.config = { + headers: { + Authorization: `Bearer ${token}`, + "Content-type": "application/json" + } + }; + this.state = { + dataTable: [], + dataExport: [], + openDialog: false, + dataImage: {}, + typeDialog: 'Save', + dataEdit: null, + alertDelete: false, + idDelete: 0, + dataGs: [], + dataIdHo: [], + search: "", + page: 0, + rowsPerPage: LENGTH_DATA, + currentPage: 1, + totalPage: 0, + tooltipEdit: false, + tooltipDelete: false, + typeClock: "All", + startDate: moment(moment().format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentDay: 'today', + tooltipExport: false, + disableProyek: false, + currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null, + allUserToProyek: [], + proyekIds: [], + allDataProyek: [], + finishSetupOption: false, + company_id: company_id, + role_name: role_name, + role_id: role_id, + hierarchy: hierarchy + } + } + + async componentDidMount() { + this.getAllProyek(); + this.setUpFirstProyek(); + } + + async componentDidUpdate(prevProps, prevState) { + const { search, startDate, dataExport, proyekIds, currentProyek } = this.state + if (search !== prevState.search) this.getDataLaporanK3() + if (startDate !== prevState.startDate) this.getDataLaporanK3() + if (dataExport !== prevState.dataExport) { + if (dataExport.length > 0) { + this.exportExcel() + } + } + if (proyekIds !== prevState.proyekIds) { + this.getDataLaporanK3(); + } + + if (currentProyek !== prevState.currentProyek) { + this.getDataLaporanK3(); + } + } + + setUpFirstProyek = () => { + if (parseInt(localStorage.getItem('role_id')) === 2) { + this.setState({ disableProyek: true }); + } else { + this.setState({ currentProyek: null }) + } + } + handleSearch = e => { + const value = e.target.value + this.setState({ search: value, currentPage: 1 }) + }; + + getAllProyek = async () => { + const payload = { + "select": ["id", "nama"], + "paging": { "start": 0, "length": -1 }, + "columns": [ + { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } + ], + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + if (this.state.role_id !== "Super Admin") { + payload.columns.push( + { name: "created_by_id", logic_operator: "IN", value: this.state.hierarchy, operator: "AND" } + ) + } + + const result = await axios + .post(PROYEK_SEARCH, payload, this.config) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + let resData = result.data.data + + let proyekIds = [] + resData.map((val, index) => { + proyekIds.push(val.id); + }); + this.setState({ allDataProyek: resData, proyekIds: proyekIds }) + } else { + } + } + + getDataLaporanK3 = async () => { + + let start = 0; + if (this.state.currentPage !== 1 && this.state.currentPage > 1) { + start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage + } + + let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00"); + let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59"); + let currentProyek = this.state.currentProyek + const payload = { + "paging": { + "start": start, + "length": this.state.rowsPerPage + }, + "filter_columns": [ + { + "name": "name", + "value": "", + "table_name": "m_users" + } + ], + "columns": [ + { "name": "report_date", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" }, + { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" } + ], + "joins": [ + { + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name", + ] + }, + { + "name": "m_proyek", + "column_join": "proyek_id", + "column_results": [ + "nama" + ] + } + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + }, + "child_data": { + "table_name": "t_report_k3_detail", + "column_table": "report_k3_id", + "column_name": "id" + } + } + + if (currentProyek) { + let proyekPayload = { "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek }; + payload.columns.push(proyekPayload) + } else { + let proyekPayload = { "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds }; + payload.columns.push(proyekPayload) + } + + const result = await axios + .post(K3_SEARCH, payload, this.config) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + let resData = result.data.data || [] + this.setState({ dataTable: resData, totalPage: result.data.totalRecord }); + } else { + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } + } + + handleOpenDialog = (type) => { + this.setState({ openDialog: true, typeDialog: type }) + this.showChildDialog(); + } + + handleCloseDialog = (type, data) => { + if (type === "save") { + this.saveDivision(data); + } else if (type === "edit") { + this.editDataDivision(data); + } + + this.setState({ openDialog: false }) + } + + toggleAddDialog = () => { + this.setState({ openDialog: !this.state.openDialog }) + } + + onConfirmDelete = async () => { + const { idDelete } = this.state + let url = BASE_URL + `employee_devision.php?act=delete&id=${idDelete}`; + const result = await axios.post(url) + .then(res => res) + .catch((error) => error.response); + + if (result.message !== undefined) { + if (result.message === "Data Has Been Deleted") { + this.getDataLaporanK3() + this.setState({ idDelete: 0, alertDelete: false }) + NotificationManager.success('Data division berhasil dihapus!!', 'Success!!'); + } else { + this.setState({ idDelete: 0, alertDelete: false }) + NotificationManager.error('Data division gagal dihapus!!', 'Failed!!'); + } + } else { + if (result.data.message === "Data Has Been Deleted") { + this.getDataLaporanK3() + this.setState({ idDelete: 0, alertDelete: false }) + NotificationManager.success('Data division berhasil dihapus!!', 'Success!!'); + } else { + this.setState({ idDelete: 0, alertDelete: false }) + NotificationManager.error('Data division gagal dihapus!!', 'Failed!!'); + } + } + } + + saveDivision = async (data) => { + let url = BASE_URL + "employee_devision.php?act=input"; + + const formData = new FormData() + formData.append('name', data.name); + formData.append('description', data.description); + const result = await axios.post(url, formData) + .then(res => res) + .catch((error) => error.response); + + if (result.message !== undefined) { + if (result.message === "Data Has Been Saved") { + this.getDataLaporanK3(); + NotificationManager.success('Data division berhasil ditambahkan!!', 'Success!!'); + } else { + NotificationManager.error(`${result.data.message}`, 'Failed!!'); + } + } else { + if (result.data.message === "Data Has Been Saved") { + this.getDataLaporanK3(); + NotificationManager.success('Data division berhasil ditambahkan!!', 'Success!!'); + } else { + NotificationManager.error(`${result.data.message}`, 'Failed!!'); + } + } + + } + + editDataDivision = async (data) => { + let url = ""; + + const formData = new FormData(); + formData.append('name', data.name); + formData.append('description', data.description); + + const result = await axios.post(url, formData) + .then(res => res) + .catch((error) => error.response); + + if (result.data !== undefined) { + if (result.data.message === "Data Has Been Edited") { + this.getDataLaporanK3(); + NotificationManager.success('Data division berhasil diedit!!', 'Success!!'); + } else { + NotificationManager.error('Data division gagal diedit!!', 'Failed!!'); + } + } + } + + + handleEdit = (data) => { + this.setState({ dataEdit: data }); + this.handleOpenDialog('Edit'); + } + + handleDelete = (id) => { + this.setState({ alertDelete: true, idDelete: id }); + } + + onShowSizeChange = (current, pageSize) => { + this.setState({ rowsPerPage: pageSize }, () => { + this.getDataLaporanK3(); + }) + } + + onPagination = (current, pageSize) => { + this.setState({ currentPage: current, page: (current - 1) * pageSize }, () => { + this.getDataLaporanK3(); + }) + } + + toggle = (param) => { + if (param === "edit") { + this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit })) + } else if (param === "delete") { + this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete })) + } else if (param === "export") { + this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport })) + } + } + + handleDatePicker = (date, dateString) => { + this.setState({ startDate: date[0], endDate: date[1] }, () => { + this.getDataLaporanK3(); + }) + } + + handleTipe = (e) => { + this.setState({ typeClock: e.target.value }, () => { + this.getDataLaporanK3(); + }); + } + + handleExportExcel = async () => { + let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00"); + let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59"); + let currentProyek = this.state.currentProyek + const payload = { + "paging": { + "start": 0, + "length": -1 + }, + "columns": [ + { "name": "report_date", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" }, + { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" } + ], + "joins": [ + { + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name", + ] + } + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + }, + "child_data": { + "table_name": "t_report_k3_detail", + "column_table": "report_k3_id", + "column_name": "id" + } + } + + if (currentProyek) { + let proyekPayload = { "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek }; + payload.columns.push(proyekPayload) + } else { + let proyekPayload = { "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds }; + payload.columns.push(proyekPayload) + } + + + + const result = await axios + .post(K3_SEARCH, payload, this.config) + .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 Human Resource": n.join_first_name ? n.join_first_name : "-", + "Tanggal Lapor": n.report_date ? moment(n.report_date).format("DD-MM-YYYY HH:mm:ss") : "-", + "Perlengkapan Dikenakan": n.k3_checked.length ? n.k3_checked.join() : "-", + "Perlengkapan Tidak Dikenakan": n.k3_not_checked.length ? n.k3_not_checked.join() : "-", + "Description": n.description ? n.description : "-" + } + excelData.push(dataRow) + }) + this.setState({ dataExport: excelData }) + } else { + NotificationManager.error('Gagal Export Data!!', 'Failed'); + } + } + + exportExcel = () => { + const dataExcel = this.state.dataExport || []; + const fileName = `Data Laporan K3.xlsx`; + const ws = XLSX.utils.json_to_sheet(dataExcel); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, `Data Laporan K3`); + + XLSX.writeFile(wb, fileName); + this.setState({ dataExport: [] }) + } + + lihatFoto = (data) => { + this.showChildDialog(); + this.setState({ dataImage: data }, () => { + this.setState({ openDialog: true }); + }); + } + + renderTable = () => { + const { t } = this.props; + const dataTable2 = this.state.dataTable || []; + return ( + + {dataTable2.length !== 0 ? dataTable2.map((n) => { + return ( + + {n.join_first_name ? n.join_first_name : "-"} + {n.join_second_nama ? n.join_second_nama : "-"} + {n.report_date ? moment(n.report_date).format("DD-MM-YYYY") : "-"} + {n.k3_checked.length ? n.k3_checked.join() : "-"} + {n.k3_not_checked.length ? n.k3_not_checked.join() : "-"} + {n.description ? n.description : "-"} + {n.image ? this.lihatFoto(n.image)} className='fa fa-image'> : ""} + + ) + }) : + {this.props.t('noData')} + + } + + ) + } + + handleChangeDay = (e) => { + const val = e.target.value; + this.setState({ currentDay: val }); + if (val === "today") { + this.setState({ + startDate: moment(moment().format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentPage: 1 + }) + } else if (val === "3 day") { + this.setState({ + startDate: moment(moment().subtract(3, "days").format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentPage: 1 + }) + } else if (val === "7 day") { + this.setState({ + startDate: moment(moment().subtract(7, "days").format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentPage: 1 + }) + } else { + this.setState({ + startDate: moment(moment().format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentPage: 1 + }) + } + } + + setupSelectProyek = () => { + let allDataProyek = this.state.allDataProyek + return ( + <> + {allDataProyek.map((val, index) => { + return ( + + ) + }) + } + + ) + } + + onChangeProyek = (val) => { + this.setState({ currentProyek: val }); + } + + delay = (ms) => new Promise(res => setTimeout(res, ms)); + + render() { + const column = [ + { name: this.props.t('nameHR') }, + { name: this.props.t('projectName') }, + { name: this.props.t('dateReport') }, + { name: this.props.t('gearUse') }, + { name: this.props.t('gearNotUse') }, + { name: this.props.t('description') }, + { name: this.props.t('action') }, + ] + const t = this.props; + const { tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state + return ( +
+ + this.setState({ alertDelete: false, idDelete: 0 })} + focusCancelBtn + > + {this.props.t('deleteMsg')} + + this.toggleAddDialog} + dataImage={this.state.dataImage} + showDialog={showDialog => this.showChildDialog = showDialog} + /> + + +

{this.props.params.name}

+
+ + + +
+
+ +
+
+
+ +
+
+ this.handleChangeDay(e)} defaultValue={this.state.currentDay}> + + + + +
+
+ {' '} + +
+
+ +
+ + + + {/* */} + {column.map((i, index) => { + return ( + + ) + })} + + + {this.renderTable()} +
Actions{i.name}
+ +
+
+
+ ) + } +} +export default withTranslation()(index); diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 30912f9..255e9c3 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -85,23 +85,18 @@ const url = ""; const format = "DD-MM-YYYY"; const CreatedProyek = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, all_project = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - company_id = props.location.state.company_id; - all_project = props.location.state.all_project; - - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - all_project = localStorage.getItem('all_project'); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } const history = useHistory(); const HEADER = { @@ -370,7 +365,6 @@ const CreatedProyek = ({ params, ...props }) => { column_join: "type_proyek_id", column_results: ["name", "description"], }, - // { "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: ["nama"], ascending: true }, paging: { start: start, length: rowsPerPage }, @@ -512,7 +506,6 @@ const CreatedProyek = ({ params, ...props }) => { }; const handleOpenDialogGantt = (data) => { - console.log('data.mulai_proyek', data.mulai_proyek); setDataViewStartDate(data.mulai_proyek) setidTask(data.id); setProyekName(data.nama); @@ -718,7 +711,6 @@ const CreatedProyek = ({ params, ...props }) => { orders: { columns: ["id"], ascending: true }, paging: { start: 0, length: -1 }, }; - // const url = PROJECT_MI(proyek_id) const result = await axios .post(ASSIGN_HR_PROJECT_SEARCH, payload, HEADER) .then((res) => res) @@ -1342,9 +1334,13 @@ const CreatedProyek = ({ params, ...props }) => { orders: { columns: ["id"], ascending: false }, }; - if (parseInt(role_id) !== 1) { + if (all_project !== null && all_project === true) { + payload["columns"] = [ + { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } + ]; + } else { payload["columns"] = [ - { name: "id", logic_operator: "=", value: proyek_id, operator: "AND" }, + { name: "created_by_id", logic_operator: "IN", value: hierarchy, operator: "AND" } ]; } @@ -2039,7 +2035,6 @@ const CreatedProyek = ({ params, ...props }) => { )} Close} title="Export" trigger="click" placement="leftBottom" @@ -2064,12 +2059,9 @@ const CreatedProyek = ({ params, ...props }) => { } - // visible={visible} - // onVisibleChange={handleVisibleChange} > diff --git a/src/views/SimproV2/Divisi/index.js b/src/views/SimproV2/Divisi/index.js index 9605901..386919d 100644 --- a/src/views/SimproV2/Divisi/index.js +++ b/src/views/SimproV2/Divisi/index.js @@ -17,22 +17,19 @@ const column = [ ] const ProjectType = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); - } + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } const HEADER = { headers: { "Content-Type": "application/json", diff --git a/src/views/SimproV2/Gantt/GanttFrame.js b/src/views/SimproV2/Gantt/GanttFrame.js index de840e7..e7c687f 100644 --- a/src/views/SimproV2/Gantt/GanttFrame.js +++ b/src/views/SimproV2/Gantt/GanttFrame.js @@ -3,22 +3,9 @@ import { useHistory, withRouter } from 'react-router-dom'; import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; const GanttFrame = React.memo((props) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - isLogin = props.location.state.isLogin; - token = props.location.state.token; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - isLogin = localStorage.getItem("isLogin"); - token = localStorage.getItem("token"); - } const history = useHistory(); - const { versionGanttId, idProject, ro, timestamp, dataViewStartDate } = props; - const iframeSrc = `http://localhost:8444/adw-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}`; + const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token } = props; + const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}`; const [batchEntityData, setBatchEntityData] = useState(null); useEffect(() => { diff --git a/src/views/SimproV2/Gantt/index.js b/src/views/SimproV2/Gantt/index.js index 3dcf7fa..cc7aba0 100644 --- a/src/views/SimproV2/Gantt/index.js +++ b/src/views/SimproV2/Gantt/index.js @@ -15,18 +15,18 @@ import GanttFrame from "./GanttFrame"; let roCount = 0; const Gantt = (props) => { - let role_id = '', userId = '', isLogin = '', token = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - userId = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - } else { - role_id = localStorage.getItem("role_id"); - userId = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } const HEADER = { headers: { @@ -39,7 +39,6 @@ const Gantt = (props) => { const timestamp = props.match.params.timestamp ? props.match.params.timestamp : 0; - const [ro, setRo] = useState(1); const [listUserGant, setListUserGantt] = useState([]); const [ready, setReady] = useState(false); @@ -93,7 +92,7 @@ const Gantt = (props) => { }; const cekPermission = () => { - let check = listUserGant.includes(parseInt(userId)); + let check = listUserGant.includes(parseInt(user_id)); if (check) { setRo(0); } else { diff --git a/src/views/SimproV2/ProjectType/index.js b/src/views/SimproV2/ProjectType/index.js index 9ca0621..ba95481 100644 --- a/src/views/SimproV2/ProjectType/index.js +++ b/src/views/SimproV2/ProjectType/index.js @@ -13,21 +13,18 @@ import { Pagination, Button, Tooltip, Table } from 'antd'; import { useTranslation } from 'react-i18next'; const ProjectType = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } const HEADER = { headers: { diff --git a/src/views/SimproV2/ResourceWorker/index.js b/src/views/SimproV2/ResourceWorker/index.js index ada1de8..cbc0185 100644 --- a/src/views/SimproV2/ResourceWorker/index.js +++ b/src/views/SimproV2/ResourceWorker/index.js @@ -15,21 +15,18 @@ import { import { useTranslation } from 'react-i18next'; const ResourceWorker = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; } const HEADER = { diff --git a/src/views/SimproV2/Satuan/index.js b/src/views/SimproV2/Satuan/index.js index f849360..3c694bc 100644 --- a/src/views/SimproV2/Satuan/index.js +++ b/src/views/SimproV2/Satuan/index.js @@ -11,22 +11,20 @@ import { useTranslation } from 'react-i18next'; const Satuan = ({ params, ...props }) => { - let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; - if (props.location.state && props.location.state.role_id && props.location.state.user_id) { - role_id = props.location.state.role_id; - user_id = props.location.state.user_id; - token = props.location.state.token; - isLogin = props.location.state.isLogin; - role_name = props.location.state.role_name; - } else { - role_id = localStorage.getItem("role_id"); - proyek_id = localStorage.getItem("proyek_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - company_id = localStorage.getItem('company_id'); - role_name = localStorage.getItem('role_name'); - } + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } + const HEADER = { headers: { "Content-Type": "application/json", From bf8c59a26480b4c417b2e7ea6885a8997cb1dd61 Mon Sep 17 00:00:00 2001 From: wahyun Date: Mon, 8 Jan 2024 10:04:23 +0700 Subject: [PATCH 03/17] update export & search project information --- src/views/SimproV2/CreatedProyek/index.js | 41 ++++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 255e9c3..55d9b59 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -330,8 +330,6 @@ const CreatedProyek = ({ params, ...props }) => { const getDataProyek = async () => { setLoading(true); let start = 0; - let hierarchy = []; - hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); if (currentPage !== 1 && currentPage > 1) { start = currentPage * rowsPerPage - rowsPerPage; } @@ -371,13 +369,13 @@ const CreatedProyek = ({ params, ...props }) => { }; if (all_project !== null && all_project === true) { - payload["columns"] = [ + payload.columns.push( { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } - ]; + ); } else { - payload["columns"] = [ - { name: "created_by_id", logic_operator: "IN", value: hierarchy, operator: "AND" } - ]; + payload.columns.push( + { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } + ); } const result = await axios @@ -1329,19 +1327,27 @@ const CreatedProyek = ({ params, ...props }) => { const handleExportExcel = async () => { const payload = { + columns: [ + { + name: "nama", + logic_operator: "ilike", + value: search, + operator: "AND", + }, + ], paging: { start: 0, length: -1 }, joins: [], orders: { columns: ["id"], ascending: false }, }; if (all_project !== null && all_project === true) { - payload["columns"] = [ + payload.columns.push( { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } - ]; + ); } else { - payload["columns"] = [ - { name: "created_by_id", logic_operator: "IN", value: hierarchy, operator: "AND" } - ]; + payload.columns.push( + { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } + ); } const result = await axios @@ -1411,11 +1417,20 @@ const CreatedProyek = ({ params, ...props }) => { column_join: "type_proyek_id", column_results: ["name", "description"], }, - // { "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: ["nama"], ascending: true }, }; + if (all_project !== null && all_project === true) { + payload.columns.push( + { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } + ); + } else { + payload.columns.push( + { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } + ); + } + const result = await axios .post(PROYEK_SEARCH, payload, HEADER) .then((res) => res) From d0dc93183cd5793bb06c0e7ca0cb8b7de6366efd Mon Sep 17 00:00:00 2001 From: wahyun Date: Thu, 11 Jan 2024 20:26:56 +0700 Subject: [PATCH 04/17] add company name --- src/views/SimproV2/CreatedProyek/index.js | 216 +++++++++++++--------- 1 file changed, 126 insertions(+), 90 deletions(-) diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 55d9b59..6840aa2 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -335,14 +335,30 @@ const CreatedProyek = ({ params, ...props }) => { } const payload = { - columns: [ - { - name: "nama", - logic_operator: "ilike", - value: search, - operator: "AND", - }, - ], + columns: [], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "nama", + "logic_operator": "~*", + "value": search, + }, + { + "name": "name", + "logic_operator": "~*", + "value": search, + "table_name": "m_type_proyek" + }, + { + "name": "name", + "logic_operator": "~*", + "value": search, + "table_name": "m_users" + } + ] + }, select: [ "id", "nama", @@ -362,7 +378,7 @@ const CreatedProyek = ({ params, ...props }) => { name: "m_type_proyek", column_join: "type_proyek_id", column_results: ["name", "description"], - }, + } ], orders: { columns: ["nama"], ascending: true }, paging: { start: start, length: rowsPerPage }, @@ -372,10 +388,18 @@ const CreatedProyek = ({ params, ...props }) => { payload.columns.push( { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } ); - } else { + } + if(role_name !== 'Super Admin') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); + } else { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios @@ -560,7 +584,6 @@ const CreatedProyek = ({ params, ...props }) => { const handleOpenDialogViewDetail = async (data) => { setLoading(true); setidTask(data.id); - // setDataView(data) await getDataProject(data.id); await getProjectMilestone(data.id); await getProjectParticipant(data.id); @@ -571,7 +594,6 @@ const CreatedProyek = ({ params, ...props }) => { await getK3toProject(data.id); await getProjectAssignHR(data.id); await getProjectImage(data.id); - // await handleGetDataPm(data.id); setPM(data.join_first_name); setOpenDialogViewDetail(true); }; @@ -670,7 +692,6 @@ const CreatedProyek = ({ params, ...props }) => { orders: { columns: ["id"], ascending: true }, paging: { start: 0, length: -1 }, }; - // const url = PROJECT_MI(proyek_id) const result = await axios .post(PROJECT_MILESTONE_SEARCH, payload, HEADER) .then((res) => res) @@ -1303,13 +1324,6 @@ const CreatedProyek = ({ params, ...props }) => { const arr = await Promise.all(request) .then((values) => values) .catch((err) => err.response); - // if(arr) - - // const result = arr.map(res => res.data.code !== 200) - // if (result.length > 0) { - // return "gagal" - // } - // return "berhasil" }; const handleDelete = async (id) => { @@ -1327,14 +1341,18 @@ const CreatedProyek = ({ params, ...props }) => { const handleExportExcel = async () => { const payload = { - columns: [ - { - name: "nama", - logic_operator: "ilike", - value: search, - operator: "AND", - }, - ], + columns:[], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "nama", + "logic_operator": "~*", + "value": search, + } + ] + }, paging: { start: 0, length: -1 }, joins: [], orders: { columns: ["id"], ascending: false }, @@ -1344,10 +1362,19 @@ const CreatedProyek = ({ params, ...props }) => { payload.columns.push( { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } ); - } else { + } + + if(role_name !== 'Super Admin') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); + } else { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios @@ -1359,30 +1386,33 @@ const CreatedProyek = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((n, index) => { - let dataRow = { - Sortname: n.kode_sortname ? n.kode_sortname : "", - "Nama Project": n.nama ? n.nama : "", - "Tanggal Mulai": n.mulai_proyek + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = n.join_first_company_name; + } + dataRow.Sortname = n.kode_sortname ? n.kode_sortname : ""; + dataRow["Nama Project"] = n.nama ? n.nama : ""; + dataRow["Tanggal Mulai"] = n.mulai_proyek ? moment(n.mulai_proyek).format(format) - : "-", - "Tanggal Selesai": n.akhir_proyek + : "-"; + dataRow["Tanggal Selesai"] = n.akhir_proyek ? moment(n.akhir_proyek).format(format) - : "-", - "Area Kerja": n.area_kerja ? n.area_kerja : "", - Perusahaan: n.company ? n.company : "", - Keterangan: n.keterangan ? n.keterangan : "", - "Dianggap sukses ketika": n.considered_success_when + : "-"; + dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : ""; + dataRow["Perusahaan"] = n.company ? n.company : ""; + dataRow["Keterangan"] = n.keterangan ? n.keterangan : ""; + dataRow["Dianggap sukses ketika"] = n.considered_success_when ? n.considered_success_when - : "", - "Tujuan Proyek": n.project_objectives ? n.project_objectives : "", - "Resiko potensial": n.potential_risk ? n.potential_risk : "", - "Rencana Biaya": n.rencana_biaya + : ""; + dataRow["Tujuan Proyek"] = n.project_objectives ? n.project_objectives : ""; + dataRow["Resiko potensial"] = n.potential_risk ? n.potential_risk : ""; + dataRow["Rencana Biaya"] = n.rencana_biaya ? formatThousand(n.rencana_biaya) - : "-", - "Testing Environment": n.testing_environment + : "-"; + dataRow["Testing Environment"] = n.testing_environment ? n.testing_environment - : "-", - }; + : "-"; + excelData.push(dataRow); }); await setDataExport(excelData); @@ -1393,19 +1423,35 @@ const CreatedProyek = ({ params, ...props }) => { const handleExportPdf = async () => { const doc = new jsPDF(); - - const headers = [ - ["Project Name", "Budget", "Project Type", "PM", "Time Project"], + let headers = [ + [role_name === 'Super Admin' ? "Company" : null,"Project Name", "Budget", "Project Type", "PM", "Time Project"], ]; + const payload = { - columns: [ - { - name: "nama", - logic_operator: "ilike", - value: search, - operator: "AND", - }, - ], + columns:[], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "nama", + "logic_operator": "~*", + "value": search, + }, + { + "name": "name", + "logic_operator": "~*", + "value": search, + "table_name": "m_type_proyek" + }, + { + "name": "name", + "logic_operator": "~*", + "value": search, + "table_name": "m_users" + } + ] + }, joins: [ { name: "m_users", @@ -1425,10 +1471,18 @@ const CreatedProyek = ({ params, ...props }) => { payload.columns.push( { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } ); - } else { + } + if(role_name !== 'Super Admin') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); + } else { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios @@ -1438,6 +1492,7 @@ const CreatedProyek = ({ params, ...props }) => { if (result && result.data && result.data.code == 200) { let resData = result.data.data; const data = resData.map((elt) => [ + role_name === 'Super Admin' ? elt.join_third_company_name : null, elt.nama, `Rp. ${formatThousand(elt.rencana_biaya)}`, elt.join_second_name, @@ -1458,34 +1513,6 @@ const CreatedProyek = ({ params, ...props }) => { }); } doc.save("Project.pdf"); - // const unit = "pt"; - // const size = "A4"; // Use A1, A2, A3 or A4 - // const orientation = "portrait"; // portrait or landscape - - // const marginLeft = 40; - // const doc = new jsPDF(orientation, unit, size); - - // doc.setFontSize(15); - // const dataPeople = [ - // { name: "Keanu Reeves", profession: "Actor" }, - // { name: "Lionel Messi", profession: "Football Player" }, - // { name: "Cristiano Ronaldo", profession: "Football Player" }, - // { name: "Jack Nicklaus", profession: "Golf Player" }, - // ]; - // const title = "My Awesome Report"; - // const headers = [["NAME", "PROFESSION"]]; - - // const data = dataPeople.map((elt) => [elt.name, elt.profession]); - - // let content = { - // startY: 50, - // head: headers, - // body: data, - // }; - - // doc.text(title, marginLeft, 40); - // doc.autoTable(content); - // doc.save("report.pdf"); }; const exportExcel = () => { @@ -1699,12 +1726,21 @@ const CreatedProyek = ({ params, ...props }) => { ), }, + { + title: role_name === 'Super Admin' ? "Company Name" : null, + dataIndex: "join_third_company_name", + key: "join_third_company_name", + render: (text, record) => { + return role_name === 'Super Admin' ? ( + {record.join_third_company_name} + ) : null; + } + }, { title: "Project Name", dataIndex: "nama", key: "nama" }, { title: "Budget", dataIndex: "rencana_biaya", key: "rencana_biaya", - // render: (text, record) => { return renderFormatRupiah(text, "Rp") } render: (text, record) => { return record.currency_symbol ? `${record.currency_symbol} ${formatThousand(text)}` @@ -2033,7 +2069,7 @@ const CreatedProyek = ({ params, ...props }) => { type="text" name="search" id="search" - placeholder={`Search Project Name`} + placeholder={`Search...`} style={{ width: 200 }} /> From 3f13eac471af7d21b890e6923652bbc85862e061 Mon Sep 17 00:00:00 2001 From: wahyun Date: Wed, 17 Jan 2024 13:10:37 +0700 Subject: [PATCH 05/17] add company in table --- src/views/Master/MasterRoles/index.js | 115 ++-- src/views/Master/RoleProject/index.js | 147 +++-- src/views/SimproV2/Presence/index.js | 688 +++++++++++---------- src/views/SimproV2/ResourceWorker/index.js | 45 +- 4 files changed, 551 insertions(+), 444 deletions(-) diff --git a/src/views/Master/MasterRoles/index.js b/src/views/Master/MasterRoles/index.js index c6fec9d..6ea08a6 100644 --- a/src/views/Master/MasterRoles/index.js +++ b/src/views/Master/MasterRoles/index.js @@ -16,26 +16,7 @@ const LENGTH_DATA = 10 class index extends Component { constructor(props) { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; - if (props && props.role_id && props.user_id) { - role_id = props.role_id; - user_id = props.user_id; - token = props.token; - isLogin = props.isLogin; - company_id = props.company_id; - all_project = props.all_project; - role_name = props.role_name; - isLogin = props.isLogin; - hierarchy = props.hierarchy; - user_name = props.user_name; - } super(props) - this.config = { - headers: { - Authorization: `Bearer ${token}`, - "Content-type": "application/json" - } - }; this.state = { alertDelete: false, alertNotDelete: false, @@ -61,8 +42,21 @@ class index extends Component { tooltipTambah: false, totalPage: 0, typeDialog: 'Save', - company_id: company_id, - role_name: role_name + company_id: props.company_id || 0, + role_name: props.role_name || '', + role_id: props.role_id || 0, + user_id: props.user_id || 0, + isLogin: props.isLogin || false, + token: props.token || '', + all_project: props.all_project || null, + hierarchy: props.hierarchy || [], + user_name: props.user_name || '', + config: { + headers: { + Authorization: `Bearer ${props.token || ''}`, + "Content-type": "application/json", + } + } } this.columns = [ { @@ -84,6 +78,16 @@ class index extends Component { , }, + { + title: this.state.role_name === 'Super Admin' ? "Company Name" : null, + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => { + return this.state.role_name === 'Super Admin' ? ( + {record.join_first_company_name} + ) : null; + } + }, { title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' }, ] @@ -114,9 +118,18 @@ class index extends Component { const formData = { "paging": { "start": start, "length": this.state.rowsPerPage }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }, - ], + "columns": [], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": this.state.search, + } + ] + }, "joins": [], "orders": { "columns": ["id"], "ascending": false } } @@ -128,9 +141,15 @@ class index extends Component { formData.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + formData.joins.push( + { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } + ) + formData.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) } const result = await axios - .post(ROLE_SEARCH, formData, this.config) + .post(ROLE_SEARCH, formData, this.state.config) .then(res => res) .catch((error) => error.response); @@ -347,18 +366,42 @@ class index extends Component { handleExportExcel = async () => { let start = 0; - let end = "ALL"; const formData = { "paging": { "start": start, "length": this.state.rowsPerPage }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } - ], + "columns": [], + "group_column": { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": this.state.search, + } + ] + }, "joins": [], "orders": { "columns": ["id"], "ascending": false } } + if (this.state.role_name !== "Super Admin") { + formData.columns.push( + { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, + ) + } else { + formData.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + formData.joins.push( + { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } + ) + formData.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) + } + const result = await axios - .post(ROLE_SEARCH, formData, this.config) + .post(ROLE_SEARCH, formData, this.state.config) .then(res => res) .catch((error) => error.response); @@ -366,10 +409,12 @@ class index extends Component { const dataRes = result.data.data || []; const dataExport = []; dataRes.map((val, index) => { - let row = { - Nama: val.name, - Deskripsi: val.description - } + let row = {}; + if (this.state.role_name === 'Super Admin') { + row.Company = val.join_first_company_name; + } + row.Nama = val.name; + row.Deskripsi = val.description; dataExport.push(row); }) this.setState({ dataExport: dataExport }, () => { @@ -445,7 +490,7 @@ class index extends Component {

{this.props.params.name}

- + diff --git a/src/views/Master/RoleProject/index.js b/src/views/Master/RoleProject/index.js index 89d7312..c7773e3 100644 --- a/src/views/Master/RoleProject/index.js +++ b/src/views/Master/RoleProject/index.js @@ -9,46 +9,10 @@ import { NotificationContainer, NotificationManager } from 'react-notifications' import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js'; import { Pagination, Tooltip, Table } from 'antd'; import { withTranslation } from 'react-i18next'; -const token = window.localStorage.getItem('token'); -const company_id = localStorage.getItem("company_id") -const role_name = window.localStorage.getItem('role_name'); -const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/"; - -const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } -}; - - - -const momentFormat = 'HH:mm'; - -const column = [ - { name: "Nama" }, - { name: "Deskripsi" }, -] - const LENGTH_DATA = 10 - class index extends Component { constructor(props) { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; - if (props && props.role_id && props.user_id) { - role_id = props.role_id; - user_id = props.user_id; - token = props.token; - isLogin = props.isLogin; - company_id = props.company_id; - all_project = props.all_project; - role_name = props.role_name; - isLogin = props.isLogin; - hierarchy = props.hierarchy; - user_name = props.user_name; - } - super(props) + super(props); this.state = { alertDelete: false, alertNotDelete: false, @@ -74,9 +38,23 @@ class index extends Component { tooltipTambah: false, totalPage: 0, typeDialog: 'Save', - company_id: company_id, - role_name: role_name - } + company_id: props.company_id || 0, + role_name: props.role_name || '', + role_id: props.role_id || 0, + user_id: props.user_id || 0, + isLogin: props.isLogin || false, + token: props.token || '', + all_project: props.all_project || null, + hierarchy: props.hierarchy || [], + user_name: props.user_name || '', + config: { + headers: { + Authorization: `Bearer ${props.token || ''}`, + "Content-type": "application/json", + } + } + }; + this.columns = [ { title: this.props.t('action'), @@ -86,21 +64,27 @@ class index extends Component { render: (text, record) => <> this.handleDelete(text.id)}> - - this.handleEdit(text)}> , }, + { + title: this.state.role_name === 'Super Admin' ? "Company Name" : null, + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => { + return this.state.role_name === 'Super Admin' ? ( + {record.join_first_company_name} + ) : null; + } + }, { title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' }, ]; } - - async componentDidMount() { this.getDataRoles(); } @@ -123,9 +107,18 @@ class index extends Component { const formData = { "paging": { "start": start, "length": this.state.rowsPerPage }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }, - ], + "columns": [], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": this.state.search, + } + ] + }, "joins": [], "orders": { "columns": ["id"], "ascending": false } } @@ -137,9 +130,15 @@ class index extends Component { formData.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + formData.joins.push( + { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } + ) + formData.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) } const result = await axios - .post(PROJECT_ROLE_SEARCH, formData, config) + .post(PROJECT_ROLE_SEARCH, formData, this.state.config) .then(res => res) .catch((error) => error.response); @@ -184,7 +183,7 @@ class index extends Component { const { idDelete } = this.state const url = PROJECT_ROLE_DELETE(idDelete) - const result = await axios.delete(url, config) + const result = await axios.delete(url, this.state.config) .then(res => res) .catch((error) => error.response); @@ -203,10 +202,10 @@ class index extends Component { const formData = { name: data.name, description: data.description, - company_id + company_id: this.state.company_id } - const result = await axios.post(PROJECT_ROLE_ADD, formData, config) + const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config) .then(res => res) .catch((error) => error.response); @@ -224,10 +223,10 @@ class index extends Component { const formData = { name: data.name, description: data.description, - company_id + company_id : this.state.company_id } const url = PROJECT_ROLE_EDIT(data.id) - const result = await axios.put(url, formData, config) + const result = await axios.put(url, formData, this.state.config) .then(res => res) .catch((error) => error.response); @@ -290,24 +289,50 @@ class index extends Component { handleExportExcel = async () => { const payload = { "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } - ], + "columns": [], + "group_column": { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": this.state.search, + } + ] + }, "joins": [], "orders": { "columns": ["id"], "ascending": false } } + if (this.state.role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) + } const result = await axios - .post(PROJECT_ROLE_SEARCH, payload, config) + .post(PROJECT_ROLE_SEARCH, payload, this.state.config) .then(res => res) .catch((error) => error.response); if (result && result.data && result.statusText == "OK") { const dataRes = result.data.data || []; const dataExport = []; dataRes.map((val, index) => { - let row = { - Nama: val.name, - Deskripsi: val.description + let row = {}; + if (this.state.role_name === 'Super Admin') { + row.Company = val.join_first_company_name; } + row.Nama = val.name; + row.Deskripsi = val.description; dataExport.push(row); }) this.setState({ dataExport: dataExport }, () => { @@ -371,7 +396,7 @@ class index extends Component {

{this.props.params.name}

- + diff --git a/src/views/SimproV2/Presence/index.js b/src/views/SimproV2/Presence/index.js index 2791d6f..3b4c1d4 100644 --- a/src/views/SimproV2/Presence/index.js +++ b/src/views/SimproV2/Presence/index.js @@ -1,339 +1,349 @@ -import React, { useState, useEffect, useMemo } from 'react'; -import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; -import { Button } from 'reactstrap'; -import axios from 'axios'; -import * as XLSX from 'xlsx'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { Pagination, Tooltip, Table, DatePicker } from 'antd'; -import moment from 'moment'; -import { PRESENCE_SEARCH, IMAGE_GET_BY_ID } from '../../../const/ApiConst.js'; -import DialogFoto from './DialogFoto'; -import { useTranslation } from 'react-i18next'; -const { RangePicker } = DatePicker; -const token = window.localStorage.getItem('token'); - - -const Index = ({ params }) => { - const [dataTable, setDatatable] = useState([]) - const [search, setSearch] = useState('') - const [currentPage, setCurrentPage] = useState(1) - const [totalPage, setTotalPage] = useState(0) - const [rowsPerPage, setRowsPerPage] = useState(10) - const [dataExport, setDataExport] = useState([]) - const [startDate, setStartDate] = useState(moment(moment().format("YYYY-M-D"))) - const [endDate, setEndDate] = useState(moment(moment().format("YYYY-M-D"))) - const [currentDay, setCurrentDay] = useState("today") - const [dataImage, setDataImage] = useState(null) - const [openImage, setOpenImage] = useState(false) - const { t } = useTranslation() - const pageName = params.name; - - const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } - }; - - useEffect(() => { - getDataPresence(); - }, [search, currentPage, rowsPerPage, startDate, endDate]) - - useEffect(() => { - const cekData = dataExport || [] - if (cekData.length > 0) { - exportExcel() - } - }, [dataExport]) - - const handleSearch = e => { - const value = e.target.value - setSearch(value); - setCurrentPage(1) - }; - - const getDataPresence = async () => { - - - let start = 0; - - if (currentPage !== 1 && currentPage > 1) { - start = (currentPage * rowsPerPage) - rowsPerPage - } - - let dateStart = moment(startDate).format("YYYY-MM-DD 00:00:00"); - let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59"); - - const payload = { - "paging": { "start": start, "length": rowsPerPage }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users" }, - { "name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd }, - ], - "joins": [{ - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "name", - "ktp_number" - ] - }], - "orders": { "columns": ["id"], "ascending": false } - } - - - - const result = await axios - .post(PRESENCE_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - setDatatable(result.data.data); - setTotalPage(result.data.totalRecord); - } else { - NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); - } - } - - const handleImage = async (id, name) => { - - let url = IMAGE_GET_BY_ID(id, "presensi"); - - const result = await axios - .get(url, config) - .then(res => res) - .catch((error) => error.response); - if (result && result.data.code == 200) { - let dataRes = result.data.data - let dataImage = { - name, - url: dataRes.image - } - await setDataImage(dataImage) - setOpenImage(true) - } else { - NotificationManager.error('Data image tidak ditemukan!', 'Failed'); - } - } - - const closeDialogImage = () => { - setOpenImage(false) - setDataImage(null) - } - - const toggleDialogImage = () => { - if (openImage) { - setDataImage(null) - } - setOpenImage(!openImage) - } - - const onShowSizeChange = (current, pageSize) => { - setRowsPerPage(pageSize) - } - - const onPagination = (current, pageSize) => { - setCurrentPage(current) - } - - const renderDurasiKerja = (jamMasuk, jamKeluar) => { - if (jamMasuk && jamKeluar) { - let start = moment(jamMasuk), - end = moment(jamKeluar); - - let diff = end.diff(start); - let result = moment.utc(diff).format('HH:mm:ss'); - - if (result) { - return result; - } else { - return "-" - } - - } else { - return "-" - } - } - - const handleExportExcel = async () => { - - let dateStart = moment(startDate).format("YYYY-MM-DD 00:00:00"); - let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59"); - - const payload = { - "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users" }, - { "name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd }, - ], - "joins": [{ - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "name", - "ktp_number" - ] - }], - "orders": { "columns": ["id"], "ascending": false } - } - - - - const result = await axios - .post(PRESENCE_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - let resData = result.data.data; - const excelData = []; - resData.map((val, index) => { - let dataRow = { - "NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-', - "Nama Human Resource": val.join_first_name ? val.join_first_name : '', - "Jam Masuk": val.clock_in ? moment(val.clock_in).format("D-M-YYYY HH:mm:ss") : '-', - "Jam Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-', - "Durasi Kerja": renderDurasiKerja(val.clock_in, val.clock_out), - "Lokasi Masuk": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_loc : '-', - "Lokasi Pulang": val.clock_out_loc && val.clock_out_loc !== '' ? val.clock_out_loc : '-', - "Area Kerja In": val.clock_in_boundary ? "Sesuai" : "Tidak Sesuai", - "Area Kerja Out": val.clock_out_boundary == null ? "-" : val.clock_out_boundary ? "Sesuai" : "Tidak Sesuai", - } - 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 renderTable = useMemo(() => { - const columns = [ - { - title: 'Action', - dataIndex: '', - key: 'x', - render: (text, record) => <> - - handleImage(text.id, text.join_first_name)}> - - , - }, - { title: t('nik'), dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' }, - { title: t('nameHR'), dataIndex: 'join_first_name', key: 'join_first_name' }, - { title: t('presenceIn'), dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}
) }, - { title: t('presenceOut'), dataIndex: 'clock_out', key: 'clock_out', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}
) }, - { title: t('workDuration'), render: (text, record) => (
{renderDurasiKerja(record.clock_in, record.clock_out)}
) }, - { title: t('locIn'), dataIndex: 'clock_in_loc', key: 'clock_in_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, - { title: t('locOut'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, - { title: t('workAreaIn'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => (
{record.clock_in_boundary ? : }
) }, - { title: t('workAreaOut'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => (
{record.clock_out_boundary == null ? : record.clock_out_boundary ? : }
) }, - ]; - return ( - - ) - }, [dataTable]) - - const handleDatePicker = (date, dateString) => { - setStartDate(date[0]) - setEndDate(date[1]) - } - - const handleChangeDay = (e) => { - const val = e.target.value; - setCurrentDay(val) - if (val === "today") { - setStartDate(moment(moment().format("YYYY-M-D"))) - setEndDate(moment(moment().format("YYYY-M-D"))) - setCurrentPage(1) - } else if (val === "3 day") { - setStartDate(moment(moment().subtract(3, "days").format("YYYY-M-D"))) - setEndDate(moment(moment().format("YYYY-M-D"))) - setCurrentPage(1) - } else if (val === "7 day") { - setStartDate(moment(moment().subtract(7, "days").format("YYYY-M-D"))) - setEndDate(moment(moment().format("YYYY-M-D"))) - setCurrentPage(1) - } else { - setStartDate(moment(moment().format("YYYY-M-D"))) - setEndDate(moment(moment().format("YYYY-M-D"))) - setCurrentPage(1) - } - } - - return ( -
- - - - -

{pageName}

- -
- - - - - - - -
-
-
- handleChangeDay(e)} defaultValue={currentDay}> - - - - -
-
- {' '} - -
-
- -
- {renderTable} - -
- - - ) -} - -export default Index; +import React, { useState, useEffect, useMemo } from 'react'; +import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; +import { Button } from 'reactstrap'; +import axios from 'axios'; +import * as XLSX from 'xlsx'; +import { NotificationContainer, NotificationManager } from 'react-notifications'; +import { Pagination, Tooltip, Table, DatePicker } from 'antd'; +import moment from 'moment'; +import { PRESENCE_SEARCH, IMAGE_GET_BY_ID } from '../../../const/ApiConst.js'; +import DialogFoto from './DialogFoto'; +import { useTranslation } from 'react-i18next'; +const { RangePicker } = DatePicker; + +const Index = ({ params,...props }) => { + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } + + const [dataTable, setDatatable] = useState([]) + const [search, setSearch] = useState('') + const [currentPage, setCurrentPage] = useState(1) + const [totalPage, setTotalPage] = useState(0) + const [rowsPerPage, setRowsPerPage] = useState(10) + const [dataExport, setDataExport] = useState([]) + const [startDate, setStartDate] = useState(moment(moment().format("YYYY-M-D"))) + const [endDate, setEndDate] = useState(moment(moment().format("YYYY-M-D"))) + const [currentDay, setCurrentDay] = useState("today") + const [dataImage, setDataImage] = useState(null) + const [openImage, setOpenImage] = useState(false) + const { t } = useTranslation() + const pageName = params.name; + + const config = { + headers: + { + Authorization: `Bearer ${token}`, + "Content-type": `application/json` + } + }; + + useEffect(() => { + getDataPresence(); + }, [search, currentPage, rowsPerPage, startDate, endDate]) + + useEffect(() => { + const cekData = dataExport || [] + if (cekData.length > 0) { + exportExcel() + } + }, [dataExport]) + + const handleSearch = e => { + const value = e.target.value + setSearch(value); + setCurrentPage(1) + }; + + const getDataPresence = async () => { + let start = 0; + + if (currentPage !== 1 && currentPage > 1) { + start = (currentPage * rowsPerPage) - rowsPerPage + } + + let dateStart = moment(startDate).format("YYYY-MM-DD 00:00:00"); + let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59"); + + const payload = { + "paging": { "start": start, "length": rowsPerPage }, + "columns": [ + { "name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users" }, + { "name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd }, + ], + "joins": [{ + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name", + "ktp_number" + ] + }], + "orders": { "columns": ["id"], "ascending": false } + } + + + + const result = await axios + .post(PRESENCE_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + setDatatable(result.data.data); + setTotalPage(result.data.totalRecord); + } else { + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } + } + + const handleImage = async (id, name) => { + + let url = IMAGE_GET_BY_ID(id, "presensi"); + + const result = await axios + .get(url, config) + .then(res => res) + .catch((error) => error.response); + if (result && result.data.code == 200) { + let dataRes = result.data.data + let dataImage = { + name, + url: dataRes.image + } + await setDataImage(dataImage) + setOpenImage(true) + } else { + NotificationManager.error('Data image tidak ditemukan!', 'Failed'); + } + } + + const closeDialogImage = () => { + setOpenImage(false) + setDataImage(null) + } + + const toggleDialogImage = () => { + if (openImage) { + setDataImage(null) + } + setOpenImage(!openImage) + } + + const onShowSizeChange = (current, pageSize) => { + setRowsPerPage(pageSize) + } + + const onPagination = (current, pageSize) => { + setCurrentPage(current) + } + + const renderDurasiKerja = (jamMasuk, jamKeluar) => { + if (jamMasuk && jamKeluar) { + let start = moment(jamMasuk), + end = moment(jamKeluar); + + let diff = end.diff(start); + let result = moment.utc(diff).format('HH:mm:ss'); + + if (result) { + return result; + } else { + return "-" + } + + } else { + return "-" + } + } + + const handleExportExcel = async () => { + + let dateStart = moment(startDate).format("YYYY-MM-DD 00:00:00"); + let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59"); + + const payload = { + "paging": { "start": 0, "length": -1 }, + "columns": [ + { "name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users" }, + { "name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd }, + ], + "joins": [{ + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name", + "ktp_number" + ] + }], + "orders": { "columns": ["id"], "ascending": false } + } + + + + const result = await axios + .post(PRESENCE_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + let resData = result.data.data; + const excelData = []; + resData.map((val, index) => { + let dataRow = { + "NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-', + "Nama Human Resource": val.join_first_name ? val.join_first_name : '', + "Jam Masuk": val.clock_in ? moment(val.clock_in).format("D-M-YYYY HH:mm:ss") : '-', + "Jam Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-', + "Durasi Kerja": renderDurasiKerja(val.clock_in, val.clock_out), + "Lokasi Masuk": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_loc : '-', + "Lokasi Pulang": val.clock_out_loc && val.clock_out_loc !== '' ? val.clock_out_loc : '-', + "Area Kerja In": val.clock_in_boundary ? "Sesuai" : "Tidak Sesuai", + "Area Kerja Out": val.clock_out_boundary == null ? "-" : val.clock_out_boundary ? "Sesuai" : "Tidak Sesuai", + } + 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 renderTable = useMemo(() => { + const columns = [ + { + title: 'Action', + dataIndex: '', + key: 'x', + render: (text, record) => <> + + handleImage(text.id, text.join_first_name)}> + + , + }, + { title: t('nik'), dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' }, + { title: t('nameHR'), dataIndex: 'join_first_name', key: 'join_first_name' }, + { title: t('presenceIn'), dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}
) }, + { title: t('presenceOut'), dataIndex: 'clock_out', key: 'clock_out', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}
) }, + { title: t('workDuration'), render: (text, record) => (
{renderDurasiKerja(record.clock_in, record.clock_out)}
) }, + { title: t('locIn'), dataIndex: 'clock_in_loc', key: 'clock_in_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, + { title: t('locOut'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'} }, + { title: t('workAreaIn'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => (
{record.clock_in_boundary ? : }
) }, + { title: t('workAreaOut'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => (
{record.clock_out_boundary == null ? : record.clock_out_boundary ? : }
) }, + ]; + return ( +
+ ) + }, [dataTable]) + + const handleDatePicker = (date, dateString) => { + setStartDate(date[0]) + setEndDate(date[1]) + } + + const handleChangeDay = (e) => { + const val = e.target.value; + setCurrentDay(val) + if (val === "today") { + setStartDate(moment(moment().format("YYYY-M-D"))) + setEndDate(moment(moment().format("YYYY-M-D"))) + setCurrentPage(1) + } else if (val === "3 day") { + setStartDate(moment(moment().subtract(3, "days").format("YYYY-M-D"))) + setEndDate(moment(moment().format("YYYY-M-D"))) + setCurrentPage(1) + } else if (val === "7 day") { + setStartDate(moment(moment().subtract(7, "days").format("YYYY-M-D"))) + setEndDate(moment(moment().format("YYYY-M-D"))) + setCurrentPage(1) + } else { + setStartDate(moment(moment().format("YYYY-M-D"))) + setEndDate(moment(moment().format("YYYY-M-D"))) + setCurrentPage(1) + } + } + + return ( +
+ + + + +

{pageName}

+ +
+ + + + + + + +
+
+
+ handleChangeDay(e)} defaultValue={currentDay}> + + + + +
+
+ {' '} + +
+
+ +
+ {renderTable} + +
+ + + ) +} + +export default Index; diff --git a/src/views/SimproV2/ResourceWorker/index.js b/src/views/SimproV2/ResourceWorker/index.js index cbc0185..fb07ef8 100644 --- a/src/views/SimproV2/ResourceWorker/index.js +++ b/src/views/SimproV2/ResourceWorker/index.js @@ -230,7 +230,10 @@ const ResourceWorker = ({ params, ...props }) => { } else { payload.group_column.where.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) + ); + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ); } const result = await axios @@ -352,6 +355,19 @@ const ResourceWorker = ({ params, ...props }) => { "ascending": false } } + + if (role_name !== "Super Admin") { + payload.group_column.where.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.group_column.where.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ); + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ); + } const result = await axios .post(USER_SEARCH, payload, HEADER) .then(res => res) @@ -361,14 +377,16 @@ const ResourceWorker = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((n, index) => { - let dataRow = { - "NIK (Nomor Induk Karyawan)": n.ktp_number, - "Employee Name": n.name, - "Divisi": n.join_second_name, - "Employee Type": n.employee_type, - "Role": n.join_first_name, - "Phone No": n.phone_number, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = n.join_third_company_name; } + dataRow["NIK (Nomor Induk Karyawan)"] = n.ktp_number; + dataRow["Employee Name"] = n.name; + dataRow["Divisi"] = n.join_second_name; + dataRow["Employee Type"] = n.employee_type; + dataRow.Role = n.join_first_name; + dataRow["Phone No"] = n.phone_number; excelData.push(dataRow) }) await setDataExport(excelData); @@ -521,7 +539,16 @@ const ResourceWorker = ({ params, ...props }) => { , }, - + { + title: role_name === 'Super Admin' ? "Company Name" : null, + dataIndex: "join_third_company_name", + key: "join_third_company_name", + render: (text, record) => { + return role_name === 'Super Admin' ? ( + {record.join_third_company_name} + ) : null; + } + }, { title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' }, { title: t('nameHR'), dataIndex: 'name', key: 'name' }, { title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' }, From 5b95b586519429e7cf325e49364d61dc383ca87e Mon Sep 17 00:00:00 2001 From: khaidralirahman Date: Wed, 17 Jan 2024 13:20:12 +0700 Subject: [PATCH 06/17] FN company name --- src/views/Master/ProjectPhase/index.js | 85 +++++++++++++++----- src/views/SimproV2/ChecklistK3/index.js | 73 +++++++++++++---- src/views/SimproV2/Divisi/index.js | 100 ++++++++++++++++++------ src/views/SimproV2/ProjectType/index.js | 88 +++++++++++++++------ src/views/SimproV2/Satuan/index.js | 72 +++++++++++++---- 5 files changed, 323 insertions(+), 95 deletions(-) diff --git a/src/views/Master/ProjectPhase/index.js b/src/views/Master/ProjectPhase/index.js index 78b914a..71239f3 100644 --- a/src/views/Master/ProjectPhase/index.js +++ b/src/views/Master/ProjectPhase/index.js @@ -67,14 +67,18 @@ const ProjectPhase = ({ params, ...props }) => { start = (currentPage * rowsPerPage) - rowsPerPage } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "ilike", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -84,7 +88,8 @@ const ProjectPhase = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { payload.columns.push( @@ -94,6 +99,12 @@ const ProjectPhase = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios .post(PROJECT_PHASE_SEARCH, payload, HEADER) @@ -129,14 +140,18 @@ const ProjectPhase = ({ params, ...props }) => { } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "like", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -146,7 +161,23 @@ const ProjectPhase = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios @@ -157,10 +188,12 @@ const ProjectPhase = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Color": val.color, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow.Nama=val.name; + dataRow.Color=val.color; excelData.push(dataRow) }) await setDataExport(excelData) @@ -308,6 +341,16 @@ const ProjectPhase = ({ params, ...props }) => { {" "} , }, + { + title: role_name === 'Super Admin' ? "Company Name" : null, + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => { + return role_name === 'Super Admin' ? ( + {record.join_first_company_name} + ) : null; + } + }, { title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: t('color'), diff --git a/src/views/SimproV2/ChecklistK3/index.js b/src/views/SimproV2/ChecklistK3/index.js index 0ba72c1..4d538ca 100644 --- a/src/views/SimproV2/ChecklistK3/index.js +++ b/src/views/SimproV2/ChecklistK3/index.js @@ -47,6 +47,7 @@ const ChecklistK3 = ({ params }) => { const [typeDialog, setTypeDialog] = useState('Save') const { t } = useTranslation() const column = [ + { name: "Company Name" }, { name: t('name') }, { name: t('description') }, ] @@ -70,14 +71,18 @@ const ChecklistK3 = ({ params }) => { } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "ilike", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -87,7 +92,8 @@ const ChecklistK3 = ({ params }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { @@ -98,6 +104,12 @@ const ChecklistK3 = ({ params }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios @@ -126,13 +138,37 @@ const ChecklistK3 = ({ params }) => { const handleExportExcel = async () => { const payload = { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" } - ], + "columns": [], "joins": [], "orders": { "columns": ["id"], "ascending": false } } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) + } const result = await axios .post(CHECKLIST_K3_SEARCH, payload, config) @@ -143,10 +179,12 @@ const ChecklistK3 = ({ params }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Deskripsi": val.description, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow.Nama=val.name; + dataRow.Deskripsi=val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -329,6 +367,11 @@ const ChecklistK3 = ({ params }) => { handleEdit(n)}> + {role_name === 'Super Admin'&& + ( + + ) + } diff --git a/src/views/SimproV2/Divisi/index.js b/src/views/SimproV2/Divisi/index.js index 386919d..a3b2866 100644 --- a/src/views/SimproV2/Divisi/index.js +++ b/src/views/SimproV2/Divisi/index.js @@ -11,7 +11,8 @@ import { useTranslation } from 'react-i18next'; const column = [ - { name: "Nama" }, + { name: "Company Name" }, + { name: "Nama Divisi" }, { name: "Deskripsi" }, { name: "Color" }, ] @@ -67,6 +68,17 @@ const ProjectType = ({ params, ...props }) => { const getListDivision = async () => { const payload = { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, columns: [], "orders": { "ascending": true, @@ -77,7 +89,8 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": 0, "start": -1 - } + }, + 'joins': [] } if (role_name !== "Super Admin") { @@ -88,6 +101,12 @@ const ProjectType = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const listDivions = await axios .post(DIVISI_SEARCH, payload, HEADER) @@ -112,14 +131,18 @@ const ProjectType = ({ params, ...props }) => { start = currentPage * rowsPerPage - rowsPerPage; } const payload = { - columns: [ - { - name: "name", - logic_operator: "ilike", - value: search, - operator: "AND" - }, - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + columns: [], "orders": { "ascending": true, "columns": [ @@ -129,7 +152,8 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { @@ -140,6 +164,12 @@ const ProjectType = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios .post(DIVISI_SEARCH, payload, HEADER) @@ -162,14 +192,18 @@ const ProjectType = ({ params, ...props }) => { } const payload = { - "columns": [ - { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { "name": "name", - "logic_operator": "like", + "logic_operator": "~*", "value": search, - "operator": "AND" - } - ], + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -179,9 +213,24 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } - const result = await axios .post(DIVISI_SEARCH, payload, HEADER) .then(res => res) @@ -190,10 +239,12 @@ const ProjectType = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama Divisi": val.name, - "Deskripsi": val.description, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow["Nama Divisi"]=val.name; + dataRow.Deskripsi=val.description; excelData.push(dataRow) }) await setDataExport(excelData) @@ -385,6 +436,11 @@ const ProjectType = ({ params, ...props }) => { handleEdit(n)}> + {role_name === 'Super Admin'&& + ( + + ) + } {n.color != null ? ( diff --git a/src/views/SimproV2/ProjectType/index.js b/src/views/SimproV2/ProjectType/index.js index ba95481..da49642 100644 --- a/src/views/SimproV2/ProjectType/index.js +++ b/src/views/SimproV2/ProjectType/index.js @@ -70,14 +70,18 @@ const ProjectType = ({ params, ...props }) => { } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "like", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": false, "columns": [ @@ -87,7 +91,8 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { payload.columns.push( @@ -97,6 +102,12 @@ const ProjectType = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios .post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER) @@ -130,14 +141,18 @@ const ProjectType = ({ params, ...props }) => { } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "like", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -147,9 +162,24 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } - const result = await axios .post(PROJECT_TYPE_SEARCH, payload, HEADER) @@ -160,10 +190,12 @@ const ProjectType = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Deskripsi": val.description, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow.Nama=val.name; + dataRow.Deskripsi=val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -314,6 +346,16 @@ const ProjectType = ({ params, ...props }) => { , }, + { + title: role_name === 'Super Admin' ? "Company Name" : null, + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => { + return role_name === 'Super Admin' ? ( + {record.join_first_company_name} + ) : null; + } + }, { title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: t('description'), dataIndex: 'description', key: 'description' }, ]; @@ -364,7 +406,7 @@ const ProjectType = ({ params, ...props }) => {

{pageName}

- + diff --git a/src/views/SimproV2/Satuan/index.js b/src/views/SimproV2/Satuan/index.js index 3c694bc..dfe0528 100644 --- a/src/views/SimproV2/Satuan/index.js +++ b/src/views/SimproV2/Satuan/index.js @@ -59,6 +59,7 @@ const Satuan = ({ params, ...props }) => { }, [dataExport]) const column = [ + { name: "Company Name" }, { name: t('name') }, { name: t('description') }, ] @@ -71,14 +72,18 @@ const Satuan = ({ params, ...props }) => { } const payload = { - "columns": [ - { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { "name": "name", - "logic_operator": "ilike", + "logic_operator": "~*", "value": search, - "operator": "AND" - } - ], + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -88,7 +93,8 @@ const Satuan = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { @@ -99,6 +105,12 @@ const Satuan = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } @@ -127,11 +139,36 @@ const Satuan = ({ params, ...props }) => { const handleExportExcel = async () => { const payload = { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" } - ], - "orders": { "columns": ["id"], "ascending": false } + "columns": [], + "orders": { "columns": ["id"], "ascending": false }, + 'joins': [] + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios .post(SATUAN_SEARCH, payload, HEADER) @@ -141,10 +178,12 @@ const Satuan = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Deskripsi": val.description, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow.Nama=val.name; + dataRow.Deskripsi=val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -328,6 +367,11 @@ const Satuan = ({ params, ...props }) => { handleEdit(n)}> + {role_name === 'Super Admin'&& + ( + + ) + } From f9ae1084861d3395bc71166643d10819485e40b5 Mon Sep 17 00:00:00 2001 From: farhantock Date: Fri, 19 Jan 2024 11:16:29 +0700 Subject: [PATCH 07/17] update vocab --- src/const/en.json | 1 + src/const/id.json | 1 + 2 files changed, 2 insertions(+) diff --git a/src/const/en.json b/src/const/en.json index c733e7c..07b20a3 100644 --- a/src/const/en.json +++ b/src/const/en.json @@ -12,6 +12,7 @@ "birthPlace": "Birth Place", "birthDate": "Birth Date", "ChecklistK3Add": "Add Checklist K3", + "company": "Company Name", "cancel": "Cancel", "close": "Close", "color": "Color", diff --git a/src/const/id.json b/src/const/id.json index 353a609..92b395a 100644 --- a/src/const/id.json +++ b/src/const/id.json @@ -12,6 +12,7 @@ "birthPlace": "Tempat Lahir", "birthDate": "Tanggal Lahir", "ChecklistK3Add": "Tambah Ceklis K3", + "company": "Nama Perusahaan", "cancel": "Batal", "close": "Tutup", "color": "Warna", From a829f1e89be4e28ae6f3397207b606f0f7870da8 Mon Sep 17 00:00:00 2001 From: farhantock Date: Fri, 19 Jan 2024 11:17:14 +0700 Subject: [PATCH 08/17] implement html title --- public/index.html | 4 +- src/App.js | 18 ++++ src/containers/DefaultLayout/DefaultHeader.js | 19 +++- src/containers/DefaultLayout/DefaultLayout.js | 90 +++++++++---------- src/views/Pages/Login/Login.js | 73 +++++++-------- 5 files changed, 118 insertions(+), 86 deletions(-) diff --git a/public/index.html b/public/index.html index 9b60c7b..ee2b6ef 100644 --- a/public/index.html +++ b/public/index.html @@ -8,7 +8,7 @@ - OSPRO + - + \ No newline at end of file diff --git a/src/App.js b/src/App.js index 5125e75..1329aa9 100644 --- a/src/App.js +++ b/src/App.js @@ -18,6 +18,24 @@ const Page500 = React.lazy(() => import('./views/Pages/Page500')); const SiopasMap = React.lazy(() => import('./views/Map')); class App extends Component { + componentDidMount() { + + try { + const storedData = localStorage.getItem('configApp'); + if (storedData !== null) { + const data = JSON.parse(storedData); + const htmlTitle = data.html_title || 'OSPRO'; + document.title = htmlTitle; + } else { + console.log('No data found in localStorage for key "configApp".'); + document.title = 'OSPRO'; + } + } catch (error) { + console.error('Error in componentDidMount:', error); + document.title = 'OSPRO'; + } + } + render() { return ( diff --git a/src/containers/DefaultLayout/DefaultHeader.js b/src/containers/DefaultLayout/DefaultHeader.js index c923679..697af47 100644 --- a/src/containers/DefaultLayout/DefaultHeader.js +++ b/src/containers/DefaultLayout/DefaultHeader.js @@ -4,7 +4,8 @@ import { Badge, Nav, NavItem } from 'reactstrap'; import PropTypes from 'prop-types'; import { Menu, Dropdown } from 'antd' import { ALERTUSER_SEARCH, ALERT_SEARCH, ALERTUSER_STATUSVIEW, ALERT_STATUSVIEW, APP_MODE } from '../../const/ApiConst'; - +import { AppAsideToggler, AppNavbarBrand, AppSidebarToggler } from '@coreui/react'; +import logo_ospro from '../../assets/img/OSPRO.png' import axios from 'axios'; import './Default.css' const token = window.localStorage.getItem('token'); @@ -194,6 +195,15 @@ class DefaultHeader extends Component { }); } + + getLogo = () => { + return ( +
+ +
+ ) + } + getHeaderMenu = () => { const { fullname, u_group } = this.state; if (u_group == 'kominfo') { @@ -244,12 +254,15 @@ class DefaultHeader extends Component { return ( + + {this.getLogo()} + ); diff --git a/src/containers/DefaultLayout/DefaultLayout.js b/src/containers/DefaultLayout/DefaultLayout.js index abb5cf9..6e9aab5 100644 --- a/src/containers/DefaultLayout/DefaultLayout.js +++ b/src/containers/DefaultLayout/DefaultLayout.js @@ -36,33 +36,33 @@ const config = { }; class DefaultLayout extends Component { - constructor(props) { - super(props); - - let role_id = '', token = '', company_id = 0, menu='' - if (props.location.state && props.location.state.role_id) { - role_id = props.location.state.role_id; - token = props.location.state.token; - company_id = props.location.state.company_id; - menu = props.location.state.menu_login; - } else { - role_id = localStorage.getItem("role_id"); - token = localStorage.getItem("token"); - company_id = localStorage.getItem('company_id'); - menu = localStorage.getItem("menu_login"); - } - - this.state = { - role_id: role_id, - token: token, - menu: { items: [] }, - routes2: routes, - finalRoutes: [], - breadrCrumbReady: false, - minimized: true, - company_id: company_id - }; - } + constructor(props) { + super(props); + + let role_id = '', token = '', company_id = 0, menu = '' + if (props.location.state && props.location.state.role_id) { + role_id = props.location.state.role_id; + token = props.location.state.token; + company_id = props.location.state.company_id; + menu = props.location.state.menu_login; + } else { + role_id = localStorage.getItem("role_id"); + token = localStorage.getItem("token"); + company_id = localStorage.getItem('company_id'); + menu = localStorage.getItem("menu_login"); + } + + this.state = { + role_id: role_id, + token: token, + menu: { items: [] }, + routes2: routes, + finalRoutes: [], + breadrCrumbReady: false, + minimized: true, + company_id: company_id + }; + } async componentDidMount() { @@ -267,15 +267,13 @@ class DefaultLayout extends Component { return (
+ + +
{!window.location.href.includes("dashboard-project") || renderSidebar ? ( - {/* */} -
+ @@ -312,19 +310,19 @@ class DefaultLayout extends Component { name={route.name} render={props => ( + params={{ name: route.name }} + hierarchy={props.location.state ? props.location.state.hierarchy : localStorage.getItem("hierarchy")} + user_id={props.location.state ? props.location.state.user_id : localStorage.getItem("user_id")} + role_id={props.location.state ? props.location.state.role_id : localStorage.getItem("role_id")} + isLogin={props.location.state ? props.location.state.isLogin : localStorage.getItem("isLogin")} + company_id={props.location.state ? props.location.state.company_id : localStorage.getItem("company_id")} + role_name={props.location.state ? props.location.state.role_name : localStorage.getItem("role_name")} + all_project={props.location.state ? props.location.state.all_project : localStorage.getItem("all_project")} + token={props.location.state ? props.location.state.token : localStorage.getItem("token")} + menu_login={props.location.state ? props.location.state.menu_login : localStorage.getItem("menu_login")} + user_name={props.location.state ? props.location.state.user_name : localStorage.getItem("user_name")} + {...props} + /> )} /> ) : (null); })} diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js index 17eb331..8cbdca8 100644 --- a/src/views/Pages/Login/Login.js +++ b/src/views/Pages/Login/Login.js @@ -120,7 +120,7 @@ class Login extends Component { } } - getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name) => { + getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name, configApp) => { const config = { headers: { @@ -147,17 +147,18 @@ class Login extends Component { this.props.history.push({ pathname: "/dashboard", state: { - menu_login: JSON.stringify(resData), - hierarchy, - role_id, - user_id, - token, - isLogin: true, - company_id, - role_name, - all_project, - user_name - } + menu_login: JSON.stringify(resData), + hierarchy, + role_id, + user_id, + token, + isLogin: true, + company_id, + role_name, + all_project, + user_name, + configApp + } }); } if (this.state.defaultPage) { @@ -165,17 +166,18 @@ class Login extends Component { this.props.history.push({ pathname: this.state.defaultPage, state: { - menu_login: JSON.stringify(resData), - hierarchy, - role_id, - user_id, - token, - isLogin: true, - company_id, - role_name, - all_project, - user_name - } + menu_login: JSON.stringify(resData), + hierarchy, + role_id, + user_id, + token, + isLogin: true, + company_id, + role_name, + all_project, + user_name, + configApp + } }); } else { this.props.history.push(this.state.defaultPage); @@ -187,17 +189,17 @@ class Login extends Component { this.props.history.push({ pathname: "/dashboard", state: { - menu_login: JSON.stringify(resData), - hierarchy, - role_id, - user_id, - token, - isLogin: true, - company_id, - role_name, - all_project, - user_name - } + menu_login: JSON.stringify(resData), + hierarchy, + role_id, + user_id, + token, + isLogin: true, + company_id, + role_name, + all_project, + user_name + } }); } } else { @@ -242,7 +244,7 @@ class Login extends Component { if (doLogin && doLogin.data && doLogin.data.code === 200) { const { access_token, data_user } = doLogin.data.data this.getDataRole(access_token, data_user.role_id) - this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name) + this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name, data_user.configApp) window.localStorage.setItem('isLogin', true); window.localStorage.setItem('token', access_token); window.localStorage.setItem('user_id', data_user.id); @@ -252,6 +254,7 @@ class Login extends Component { window.localStorage.setItem('role_name', data_user.role.name); window.localStorage.setItem('all_project', data_user.role.all_project); window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy)); + window.localStorage.setItem('configApp', JSON.stringify(data_user.configApp)); } else { // NotificationManager.error('Cek username atau password anda!', 'Gagal Login!'); NotificationManager.error(doLogin.data.message, 'Login Failed!'); From 21752ca924fd54800ba9e17cdeebd1e825155210 Mon Sep 17 00:00:00 2001 From: farhantock Date: Fri, 19 Jan 2024 11:17:41 +0700 Subject: [PATCH 09/17] update colomn company name --- src/views/Master/MasterAbsensi/index.js | 26 +++- src/views/Master/MasterBroadcast/index.js | 83 ++++++------ src/views/Master/MasterRoles/index.js | 146 +++++++++++---------- src/views/Master/ProjectPhase/index.js | 47 +++++-- src/views/Report/k3/index.js | 32 ++++- src/views/SimproV2/ChecklistK3/index.js | 135 +++++++++++-------- src/views/SimproV2/CreatedProyek/index.js | 54 ++++---- src/views/SimproV2/Divisi/index.js | 124 +++++++++-------- src/views/SimproV2/PanicButton/index.js | 16 ++- src/views/SimproV2/Presence/index.js | 25 +++- src/views/SimproV2/ProjectType/index.js | 46 +++++-- src/views/SimproV2/ResourceWorker/index.js | 19 ++- src/views/SimproV2/Satuan/index.js | 102 ++++++++------ 13 files changed, 521 insertions(+), 334 deletions(-) diff --git a/src/views/Master/MasterAbsensi/index.js b/src/views/Master/MasterAbsensi/index.js index 8d17489..b8e26f5 100644 --- a/src/views/Master/MasterAbsensi/index.js +++ b/src/views/Master/MasterAbsensi/index.js @@ -55,7 +55,15 @@ class index extends Component { currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null, allUserToProyek: [], allDataProyek: [], - finishSetupOption: false + finishSetupOption: false, + role_name: props.role_name || '', + role_id: props.role_id || 0, + user_id: props.user_id || 0, + isLogin: props.isLogin || false, + token: props.token || '', + all_project: props.all_project || null, + hierarchy: props.hierarchy || [], + user_name: props.user_name || '', } } @@ -195,7 +203,14 @@ class index extends Component { "ascending": false } } - + if (this.state.role_name === 'Super Admin') { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.columns.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) + } const result = await axios @@ -448,6 +463,9 @@ class index extends Component { Edit */} + {this.state.role_name === 'Super Admin' && +
+ } @@ -494,10 +512,12 @@ class index extends Component { render() { const t = this.props; const column = [ + this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null, { name: this.props.t('nameHR') }, { name: this.props.t('description') }, { name: this.props.t('dateAbsent') }, - ] + ].filter(column => column && column.name); + const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state return (
diff --git a/src/views/Master/MasterBroadcast/index.js b/src/views/Master/MasterBroadcast/index.js index e9d3efc..2622210 100644 --- a/src/views/Master/MasterBroadcast/index.js +++ b/src/views/Master/MasterBroadcast/index.js @@ -5,7 +5,7 @@ import React, { Component } from 'react'; import SweetAlert from 'react-bootstrap-sweetalert'; import axios from 'axios'; import moment from 'moment'; -import { USER_LIST, BASE_SIMPRO_LUMEN, ROLE_LIST } from '../../../const/ApiConst'; +import { USER_LIST, BASE_SIMPRO_LUMEN, ROLE_LIST, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; import { Button, Card, CardBody, CardHeader, DropdownItem, DropdownMenu, DropdownToggle, Input, InputGroup, InputGroupButtonDropdown, Table, Row, Col } from 'reactstrap'; import { DatePicker, Pagination } from 'antd'; import { NotificationContainer, NotificationManager } from 'react-notifications'; @@ -66,6 +66,9 @@ class index extends Component { totalPage: 0, typeClock: "All", typeDialog: 'Save', + role_name: props.role_name || '', + company_id: props.company_id, + listCompany: [] } } @@ -79,42 +82,22 @@ class index extends Component { if (startDate !== prevState.startDate) this.getDataBroadcast() } - handleSearch = e => { - const value = e.target.value - this.setState({ search: value, currentPage: 1 }) - }; - - getDataUsers = async () => { - const result = await axios - .get(USER_LIST, config) - .then(res => res) - .catch((error) => error.response); - if (result && result.data && result.status == 200) { - const dataRes = result.data.data; - const finalData = []; - if (dataRes.length > 0) { - dataRes.map((val, index) => { - let data = { - id: val.id, - name: val.name, - }; - finalData.push(data); - }); - } - this.setState({ dataUser: finalData }); - } - } - getDataRoles = async () => { + getDataCompany = async () => { const result = await axios - .get(ROLE_LIST, config) + .get(COMPANY_MANAGEMENT_LIST, config) .then(res => res) .catch((error) => error.response); - if (result && result.data && result.status == 200) { - this.setState({ dataRoles: result.data.data }); + if (result && result.data && result.data.code == 200) { + this.setState({ listCompany: result.data.data }) } } + handleSearch = e => { + const value = e.target.value + this.setState({ search: value, currentPage: 1 }) + }; + getDataBroadcast = async () => { let url = BASE_SIMPRO_LUMEN + `/broadcast/search`; @@ -141,8 +124,9 @@ class index extends Component { "name": searchDetailField, "operator": "AND", "value": search - } + }, ], + "joins": [], "orders": { "ascending": false, "columns": [ @@ -155,7 +139,22 @@ class index extends Component { } } - if (this.state.search !== "" && this.state.search !== null) { + if (this.state.role_name === 'Super Admin') { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.columns.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) + } else { + payload.columns.push( + { + "name": "company_id", + "logic_operator": "=", + "value": this.state.company_id, + "operator": "AND" + } + ) } const result = await axios @@ -165,8 +164,7 @@ class index extends Component { if (result && result.data) { if (result.data.code === 200) { this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord }); - this.getDataUsers() - this.getDataRoles() + this.getDataCompany() } else { NotificationManager.error('Failed retreiving data!!', 'Failed'); } @@ -214,13 +212,13 @@ class index extends Component { saveBroadcast = async (type, data) => { let url = BASE_SIMPRO_LUMEN + `/broadcast/add`; - const param = { "title_notif": data.title, "status_send": type, "send_to_type": "all", "message_notif": data.message, "description": data.description, + "company_id": data.company_id } const paramRoles = { @@ -229,7 +227,8 @@ class index extends Component { "send_to_type": "roles", "message_notif": data.message, "description": data.description, - "send_to_id": data.id + "send_to_id": data.id, + "company_id": data.company_id } const paramUsers = { @@ -238,7 +237,8 @@ class index extends Component { "send_to_type": "users", "message_notif": data.message, "description": data.description, - "send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null + "send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null, + "company_id": data.company_id } if (data.send_to_type === "all") { @@ -491,6 +491,9 @@ class index extends Component { + {this.state.role_name === 'Super Admin' && +
+ } @@ -557,13 +560,14 @@ class index extends Component { render() { const column = [ { name: this.props.t('action') }, + this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null, { name: this.props.t('title') }, { name: this.props.t('message') }, { name: this.props.t('description') }, { name: this.props.t('receiver') }, { name: "Status" }, { name: this.props.t('date') }, - ] + ].filter(column => column && column.name); const t = this.props; const { tooltipTambah, tooltipExport, dataTable, splitButtonOpen, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, statusSend } = this.state return ( @@ -591,6 +595,9 @@ class index extends Component { dataEdit={this.state.dataEdit} showDialog={showDialog => this.showChildDialog = showDialog} dataHs={this.state.dataIdHo} + company_id={this.state.company_id} + role_name={this.state.role_name} + listCompany={this.state.listCompany} /> , }, - { - title: this.state.role_name === 'Super Admin' ? "Company Name" : null, - dataIndex: "join_first_company_name", - key: "join_first_company_name", - render: (text, record) => { - return this.state.role_name === 'Super Admin' ? ( - {record.join_first_company_name} - ) : null; - } - }, + ...(this.state.role_name === 'Super Admin' + ? [ + { + title: this.props.t('company'), + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => ( + {record.join_first_company_name} + ), + } + ] + : []), { title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' }, ] @@ -119,17 +121,17 @@ class index extends Component { const formData = { "paging": { "start": start, "length": this.state.rowsPerPage }, "columns": [], - group_column: { - "operator": "AND", - "group_operator": "OR", - "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": this.state.search, - } - ] - }, + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": this.state.search, + } + ] + }, "joins": [], "orders": { "columns": ["id"], "ascending": false } } @@ -141,12 +143,12 @@ class index extends Component { formData.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) - formData.joins.push( - { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } - ) - formData.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) + formData.joins.push( + { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } + ) + formData.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) } const result = await axios .post(ROLE_SEARCH, formData, this.state.config) @@ -369,36 +371,36 @@ class index extends Component { const formData = { "paging": { "start": start, "length": this.state.rowsPerPage }, "columns": [], - "group_column": { - "operator": "AND", - "group_operator": "OR", - "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": this.state.search, - } - ] - }, + "group_column": { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": this.state.search, + } + ] + }, "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if (this.state.role_name !== "Super Admin") { - formData.columns.push( - { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, - ) - } else { - formData.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - formData.joins.push( - { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } - ) - formData.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } + if (this.state.role_name !== "Super Admin") { + formData.columns.push( + { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, + ) + } else { + formData.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + formData.joins.push( + { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } + ) + formData.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) + } const result = await axios .post(ROLE_SEARCH, formData, this.state.config) @@ -410,11 +412,11 @@ class index extends Component { const dataExport = []; dataRes.map((val, index) => { let row = {}; - if (this.state.role_name === 'Super Admin') { - row.Company = val.join_first_company_name; - } - row.Nama = val.name; - row.Deskripsi = val.description; + if (this.state.role_name === 'Super Admin') { + row.Company = val.join_first_company_name; + } + row.Nama = val.name; + row.Deskripsi = val.description; dataExport.push(row); }) this.setState({ dataExport: dataExport }, () => { diff --git a/src/views/Master/ProjectPhase/index.js b/src/views/Master/ProjectPhase/index.js index 71239f3..9effc9b 100644 --- a/src/views/Master/ProjectPhase/index.js +++ b/src/views/Master/ProjectPhase/index.js @@ -6,13 +6,13 @@ import axios from "../../../const/interceptorApi" import moment from 'moment' import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, PROJECT_PHASE_LIST, BASE_OSPRO } from '../../../const/ApiConst'; +import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, COMPANY_MANAGEMENT_LIST, BASE_OSPRO } from '../../../const/ApiConst'; import { Pagination, Button, Tooltip, Table } from 'antd'; import { useTranslation } from 'react-i18next'; const ProjectPhase = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; @@ -49,6 +49,7 @@ const ProjectPhase = ({ params, ...props }) => { const [search, setSearch] = useState('') const [totalPage, setTotalPage] = useState(0) const [typeDialog, setTypeDialog] = useState('Save') + const [listCompany, setListCompany] = useState([]) const { t } = useTranslation() useEffect(() => { getDataProjectPhase() @@ -61,6 +62,21 @@ const ProjectPhase = ({ params, ...props }) => { } }, [dataExport]) + useEffect(() => { + getDataCompany() + }, []) + + const getDataCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + setListCompany(result.data.data); + } + } + const getDataProjectPhase = async () => { let start = 0; if (currentPage !== 1 && currentPage > 1) { @@ -192,8 +208,8 @@ const ProjectPhase = ({ params, ...props }) => { if (role_name === 'Super Admin') { dataRow.Company = val.join_first_company_name; } - dataRow.Nama=val.name; - dataRow.Color=val.color; + dataRow.Nama = val.name; + dataRow.Color = val.color; excelData.push(dataRow) }) await setDataExport(excelData) @@ -341,17 +357,19 @@ const ProjectPhase = ({ params, ...props }) => { {" "} , }, - { - title: role_name === 'Super Admin' ? "Company Name" : null, - dataIndex: "join_first_company_name", - key: "join_first_company_name", - render: (text, record) => { - return role_name === 'Super Admin' ? ( + ...(role_name === 'Super Admin' ? + [{ + title: t('companyName'), + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => ( {record.join_first_company_name} - ) : null; - } + ) + }] + : []), + { + title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" }, - { title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: t('color'), dataIndex: 'color', @@ -398,6 +416,9 @@ const ProjectPhase = ({ params, ...props }) => { dataEdit={dataEdit} clickOpenModal={clickOpenModal} dataParent={allDataMenu} + listCompany={listCompany} + role_name={role_name} + company_id={company_id} /> diff --git a/src/views/Report/k3/index.js b/src/views/Report/k3/index.js index d967fd9..4fdc769 100644 --- a/src/views/Report/k3/index.js +++ b/src/views/Report/k3/index.js @@ -26,7 +26,7 @@ const LENGTH_DATA = 10 class index extends Component { constructor(props) { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; @@ -127,7 +127,7 @@ class index extends Component { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if (this.state.role_id !== "Super Admin") { + if (this.state.role_name !== "Super Admin") { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: this.state.hierarchy, operator: "AND" } ) @@ -207,11 +207,25 @@ class index extends Component { } if (currentProyek) { - let proyekPayload = { "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek }; - payload.columns.push(proyekPayload) + payload.columns.push({ "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek }) + if (this.state.role_name === "Super Admin") { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.columns.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) + } } else { - let proyekPayload = { "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds }; - payload.columns.push(proyekPayload) + payload.columns.push({ "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds }) + if (this.state.role_name === "Super Admin") { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.columns.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) + } } const result = await axios @@ -465,6 +479,9 @@ class index extends Component { {dataTable2.length !== 0 ? dataTable2.map((n) => { return ( + {this.state.role_name === 'Super Admin' && + + } @@ -534,6 +551,7 @@ class index extends Component { render() { const column = [ + this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null, { name: this.props.t('nameHR') }, { name: this.props.t('projectName') }, { name: this.props.t('dateReport') }, @@ -541,7 +559,7 @@ class index extends Component { { name: this.props.t('gearNotUse') }, { name: this.props.t('description') }, { name: this.props.t('action') }, - ] + ].filter(column => column && column.name); const t = this.props; const { tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state return ( diff --git a/src/views/SimproV2/ChecklistK3/index.js b/src/views/SimproV2/ChecklistK3/index.js index 4d538ca..e0632b6 100644 --- a/src/views/SimproV2/ChecklistK3/index.js +++ b/src/views/SimproV2/ChecklistK3/index.js @@ -5,15 +5,13 @@ import SweetAlert from 'react-bootstrap-sweetalert'; import axios from "../../../const/interceptorApi" import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { Pagination, Button, Tooltip } from 'antd'; +import { Pagination, Button, Tooltip, } from 'antd'; import { - CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH + CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; import { useTranslation } from 'react-i18next'; const token = window.localStorage.getItem('token'); -const role_name = window.localStorage.getItem('role_name'); -const company_id = window.localStorage.getItem('company_id'); const config = { headers: { @@ -22,8 +20,20 @@ const config = { } }; -const ChecklistK3 = ({ params }) => { - const token = localStorage.getItem("token") +const ChecklistK3 = ({ params, ...props }) => { + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } const HEADER = { headers: { "Content-Type": "application/json", @@ -45,12 +55,13 @@ const ChecklistK3 = ({ params }) => { const [search, setSearch] = useState('') const [totalPage, setTotalPage] = useState(0) const [typeDialog, setTypeDialog] = useState('Save') + const [listCompany, setListCompany] = useState([]) const { t } = useTranslation() const column = [ - { name: "Company Name" }, + role_name === 'Super Admin' ? { name: t('company') } : null, { name: t('name') }, { name: t('description') }, - ] + ].filter(column => column && column.name) useEffect(() => { getDataChecklistK3() }, [currentPage, rowsPerPage, search]) @@ -62,6 +73,22 @@ const ChecklistK3 = ({ params }) => { } }, [dataExport]) + useEffect(() => { + getDataCompany() + }, []) + + + const getDataCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, config) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + setListCompany(result.data.data); + } + } + const getDataChecklistK3 = async () => { let start = 0; @@ -72,16 +99,16 @@ const ChecklistK3 = ({ params }) => { const payload = { group_column: { - "operator": "AND", - "group_operator": "OR", - "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": search, - } - ] - }, + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, "columns": [], "orders": { "ascending": true, @@ -93,7 +120,7 @@ const ChecklistK3 = ({ params }) => { "length": rowsPerPage, "start": start }, - 'joins': [] + 'joins': [] } if (role_name !== "Super Admin") { @@ -106,10 +133,10 @@ const ChecklistK3 = ({ params }) => { ) payload.joins.push( { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.group_column.where.push( + ) + payload.group_column.where.push( { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } - ) + ) } const result = await axios @@ -139,36 +166,36 @@ const ChecklistK3 = ({ params }) => { const handleExportExcel = async () => { const payload = { group_column: { - "operator": "AND", - "group_operator": "OR", - "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": search, - } - ] - }, + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, "paging": { "start": 0, "length": -1 }, "columns": [], "joins": [], "orders": { "columns": ["id"], "ascending": false } } if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } - ) - } + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) + } const result = await axios .post(CHECKLIST_K3_SEARCH, payload, config) @@ -183,8 +210,8 @@ const ChecklistK3 = ({ params }) => { if (role_name === 'Super Admin') { dataRow.Company = val.join_first_company_name; } - dataRow.Nama=val.name; - dataRow.Deskripsi=val.description; + dataRow.Nama = val.name; + dataRow.Deskripsi = val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -324,6 +351,8 @@ const ChecklistK3 = ({ params }) => { clickOpenModal={clickOpenModal} dataParent={allDataMenu} company_id={company_id} + listCompany={listCompany} + role_name={role_name} /> @@ -367,11 +396,11 @@ const ChecklistK3 = ({ params }) => { handleEdit(n)}> - {role_name === 'Super Admin'&& - ( - - ) - } + {role_name === 'Super Admin' && + ( + + ) + } diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 6840aa2..8916117 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -80,12 +80,13 @@ import ReportAnalysis from "./ReportAnalysis"; import { Icon } from "@iconify/react"; // import SubProyekComp from './SubProyekComp'; import { Link, useHistory, withRouter } from "react-router-dom"; +import { t } from "i18next"; const url = ""; const format = "DD-MM-YYYY"; const CreatedProyek = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; @@ -389,7 +390,7 @@ const CreatedProyek = ({ params, ...props }) => { { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } ); } - if(role_name !== 'Super Admin') { + if (role_name !== 'Super Admin') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); @@ -1341,7 +1342,7 @@ const CreatedProyek = ({ params, ...props }) => { const handleExportExcel = async () => { const payload = { - columns:[], + columns: [], group_column: { "operator": "AND", "group_operator": "OR", @@ -1364,7 +1365,7 @@ const CreatedProyek = ({ params, ...props }) => { ); } - if(role_name !== 'Super Admin') { + if (role_name !== 'Super Admin') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); @@ -1393,25 +1394,25 @@ const CreatedProyek = ({ params, ...props }) => { dataRow.Sortname = n.kode_sortname ? n.kode_sortname : ""; dataRow["Nama Project"] = n.nama ? n.nama : ""; dataRow["Tanggal Mulai"] = n.mulai_proyek - ? moment(n.mulai_proyek).format(format) - : "-"; - dataRow["Tanggal Selesai"] = n.akhir_proyek - ? moment(n.akhir_proyek).format(format) - : "-"; + ? moment(n.mulai_proyek).format(format) + : "-"; + dataRow["Tanggal Selesai"] = n.akhir_proyek + ? moment(n.akhir_proyek).format(format) + : "-"; dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : ""; dataRow["Perusahaan"] = n.company ? n.company : ""; dataRow["Keterangan"] = n.keterangan ? n.keterangan : ""; dataRow["Dianggap sukses ketika"] = n.considered_success_when - ? n.considered_success_when - : ""; + ? n.considered_success_when + : ""; dataRow["Tujuan Proyek"] = n.project_objectives ? n.project_objectives : ""; dataRow["Resiko potensial"] = n.potential_risk ? n.potential_risk : ""; dataRow["Rencana Biaya"] = n.rencana_biaya - ? formatThousand(n.rencana_biaya) - : "-"; + ? formatThousand(n.rencana_biaya) + : "-"; dataRow["Testing Environment"] = n.testing_environment - ? n.testing_environment - : "-"; + ? n.testing_environment + : "-"; excelData.push(dataRow); }); @@ -1424,11 +1425,11 @@ const CreatedProyek = ({ params, ...props }) => { const handleExportPdf = async () => { const doc = new jsPDF(); let headers = [ - [role_name === 'Super Admin' ? "Company" : null,"Project Name", "Budget", "Project Type", "PM", "Time Project"], + [role_name === 'Super Admin' ? "Company" : null, "Project Name", "Budget", "Project Type", "PM", "Time Project"], ]; const payload = { - columns:[], + columns: [], group_column: { "operator": "AND", "group_operator": "OR", @@ -1472,7 +1473,7 @@ const CreatedProyek = ({ params, ...props }) => { { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } ); } - if(role_name !== 'Super Admin') { + if (role_name !== 'Super Admin') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); @@ -1726,16 +1727,15 @@ const CreatedProyek = ({ params, ...props }) => { ), }, - { - title: role_name === 'Super Admin' ? "Company Name" : null, - dataIndex: "join_third_company_name", - key: "join_third_company_name", - render: (text, record) => { - return role_name === 'Super Admin' ? ( + ...(role_name === 'Super Admin' ? [ + { + title: t('company'), + dataIndex: "join_third_company_name", + key: "join_third_company_name", + render: (text, record) => ( {record.join_third_company_name} - ) : null; - } - }, + ) + }] : []), { title: "Project Name", dataIndex: "nama", key: "nama" }, { title: "Budget", diff --git a/src/views/SimproV2/Divisi/index.js b/src/views/SimproV2/Divisi/index.js index a3b2866..382c1a3 100644 --- a/src/views/SimproV2/Divisi/index.js +++ b/src/views/SimproV2/Divisi/index.js @@ -4,33 +4,27 @@ import React, { useState, useEffect } from 'react'; import SweetAlert from 'react-bootstrap-sweetalert'; import axios from "../../../const/interceptorApi" import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; -import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH } from '../../../const/ApiConst'; +import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; import { NotificationContainer, NotificationManager } from 'react-notifications'; import { Pagination, Button, Tooltip } from 'antd'; import { useTranslation } from 'react-i18next'; -const column = [ - { name: "Company Name" }, - { name: "Nama Divisi" }, - { name: "Deskripsi" }, - { name: "Color" }, -] - const ProjectType = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; - if (props && props.role_id && props.user_id) { - role_id = props.role_id; - user_id = props.user_id; - token = props.token; - isLogin = props.isLogin; - company_id = props.company_id; - all_project = props.all_project; - role_name = props.role_name; - isLogin = props.isLogin; - hierarchy = props.hierarchy; - user_name = props.user_name; - } + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } + const HEADER = { headers: { "Content-Type": "application/json", @@ -53,8 +47,14 @@ const ProjectType = ({ params, ...props }) => { const [totalPage, setTotalPage] = useState(0) const [typeDialog, setTypeDialog] = useState('Save') const [dataDivisions, setDataDivisions] = useState([]) + const [listCompany, setListCompany] = useState([]) const { t } = useTranslation() - + const column = [ + role_name === 'Super Admin' ? { name: t('company') } : null, + { name: t('nameDivision') }, + { name: t('description') }, + { name: t('color') }, + ].filter(column => column && column.name); useEffect(() => { getDataProjectType(); }, [currentPage, rowsPerPage, search]) @@ -65,6 +65,20 @@ const ProjectType = ({ params, ...props }) => { exportExcel() } }, [dataExport]) + useEffect(() => { + getDataCompany() + }, []) + + const getDataCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + setListCompany(result.data.data); + } + } const getListDivision = async () => { const payload = { @@ -72,13 +86,13 @@ const ProjectType = ({ params, ...props }) => { "operator": "AND", "group_operator": "OR", "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": search, - } + { + "name": "name", + "logic_operator": "~*", + "value": search, + } ] - }, + }, columns: [], "orders": { "ascending": true, @@ -102,10 +116,10 @@ const ProjectType = ({ params, ...props }) => { { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } ) payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } ) } const listDivions = await axios @@ -135,13 +149,13 @@ const ProjectType = ({ params, ...props }) => { "operator": "AND", "group_operator": "OR", "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": search, - } + { + "name": "name", + "logic_operator": "~*", + "value": search, + } ] - }, + }, columns: [], "orders": { "ascending": true, @@ -196,13 +210,13 @@ const ProjectType = ({ params, ...props }) => { "operator": "AND", "group_operator": "OR", "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": search, - } + { + "name": "name", + "logic_operator": "~*", + "value": search, + } ] - }, + }, "columns": [], "orders": { "ascending": true, @@ -218,17 +232,17 @@ const ProjectType = ({ params, ...props }) => { } if (role_name !== "Super Admin") { payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, ) - } else { + } else { payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } ) payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } ) } const result = await axios @@ -241,10 +255,10 @@ const ProjectType = ({ params, ...props }) => { resData.map((val, index) => { let dataRow = {}; if (role_name === 'Super Admin') { - dataRow.Company = val.join_first_company_name; + dataRow.Company = val.join_first_company_name; } - dataRow["Nama Divisi"]=val.name; - dataRow.Deskripsi=val.description; + dataRow["Nama Divisi"] = val.name; + dataRow.Deskripsi = val.description; excelData.push(dataRow) }) await setDataExport(excelData) @@ -393,6 +407,8 @@ const ProjectType = ({ params, ...props }) => { dataParent={allDataMenu} dataDivisions={dataDivisions} company_id={company_id} + listCompany={listCompany} + role_name={role_name} /> @@ -436,10 +452,10 @@ const ProjectType = ({ params, ...props }) => { handleEdit(n)}> - {role_name === 'Super Admin'&& - ( - - ) + {role_name === 'Super Admin' && + ( + + ) } diff --git a/src/views/SimproV2/PanicButton/index.js b/src/views/SimproV2/PanicButton/index.js index 00d2dd8..7f59f31 100644 --- a/src/views/SimproV2/PanicButton/index.js +++ b/src/views/SimproV2/PanicButton/index.js @@ -60,6 +60,7 @@ class index extends Component { totalPage: 0, typeClock: "All", typeDialog: 'Save', + role_name: props.role_name || '', } } @@ -120,6 +121,15 @@ class index extends Component { } } + if (this.state.role_name === 'Super Admin') { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.columns.push( + { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } + ) + } + const result = await axios .post(PANIC_BUTTON_SEARCH, payload, config) .then(res => res) @@ -275,6 +285,9 @@ class index extends Component { this.handleMap(n)}> + {this.state.role_name === 'Super Admin' && + + } @@ -321,10 +334,11 @@ class index extends Component { render() { const column = [ { name: this.props.t('action') }, + this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null, { name: this.props.t('date') }, { name: this.props.t('nameHR') }, { name: this.props.t('statusResponse') }, - ] + ].filter(column => column && column.name); const t = this.props; const { tooltipExport, dataTable, openDialogEdit, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipMap, tooltipDelete } = this.state return ( diff --git a/src/views/SimproV2/Presence/index.js b/src/views/SimproV2/Presence/index.js index 3b4c1d4..5f1a592 100644 --- a/src/views/SimproV2/Presence/index.js +++ b/src/views/SimproV2/Presence/index.js @@ -11,8 +11,8 @@ import DialogFoto from './DialogFoto'; import { useTranslation } from 'react-i18next'; const { RangePicker } = DatePicker; -const Index = ({ params,...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; +const Index = ({ params, ...props }) => { + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; @@ -92,6 +92,15 @@ const Index = ({ params,...props }) => { "orders": { "columns": ["id"], "ascending": false } } + if (role_name === 'Super Admin') { + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.columns.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) + } + const result = await axios @@ -244,6 +253,18 @@ const Index = ({ params,...props }) => { , }, + ...(role_name === 'Super Admin' + ? [ + { + title: t('company'), + dataIndex: "join_second_company_name", + key: "join_second_company_name", + render: (text, record) => ( + {record.join_second_company_name} + ) + }, + ] + : []), { title: t('nik'), dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' }, { title: t('nameHR'), dataIndex: 'join_first_name', key: 'join_first_name' }, { title: t('presenceIn'), dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}
) }, diff --git a/src/views/SimproV2/ProjectType/index.js b/src/views/SimproV2/ProjectType/index.js index da49642..5d5b37c 100644 --- a/src/views/SimproV2/ProjectType/index.js +++ b/src/views/SimproV2/ProjectType/index.js @@ -8,12 +8,13 @@ import moment from 'moment' import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { DownloadOutlined } from '@ant-design/icons'; import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst'; +import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; import { Pagination, Button, Tooltip, Table } from 'antd'; import { useTranslation } from 'react-i18next'; + const ProjectType = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; @@ -49,6 +50,7 @@ const ProjectType = ({ params, ...props }) => { const [search, setSearch] = useState('') const [totalPage, setTotalPage] = useState(0) const [typeDialog, setTypeDialog] = useState('Save') + const [listCompany, setListCompany] = useState([]) const { t } = useTranslation(); useEffect(() => { getDataProjectType() @@ -61,6 +63,21 @@ const ProjectType = ({ params, ...props }) => { } }, [dataExport]) + useEffect(() => { + getDataCompany() + }, []) + + const getDataCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + setListCompany(result.data.data); + } + } + const getDataProjectType = async () => { let start = 0; @@ -194,8 +211,8 @@ const ProjectType = ({ params, ...props }) => { if (role_name === 'Super Admin') { dataRow.Company = val.join_first_company_name; } - dataRow.Nama=val.name; - dataRow.Deskripsi=val.description; + dataRow.Nama = val.name; + dataRow.Deskripsi = val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -346,16 +363,16 @@ const ProjectType = ({ params, ...props }) => { , }, - { - title: role_name === 'Super Admin' ? "Company Name" : null, - dataIndex: "join_first_company_name", - key: "join_first_company_name", - render: (text, record) => { - return role_name === 'Super Admin' ? ( + ...(role_name === 'Super Admin' ? [ + { + title: t('company'), + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => ( {record.join_first_company_name} - ) : null; - } - }, + ) + }] : []), + { title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: t('description'), dataIndex: 'description', key: 'description' }, ]; @@ -394,6 +411,9 @@ const ProjectType = ({ params, ...props }) => { dataEdit={dataEdit} clickOpenModal={clickOpenModal} dataParent={allDataMenu} + listCompany={listCompany} + company_id={company_id} + role_name={role_name} /> { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; @@ -539,16 +539,15 @@ const ResourceWorker = ({ params, ...props }) => { , }, - { - title: role_name === 'Super Admin' ? "Company Name" : null, - dataIndex: "join_third_company_name", - key: "join_third_company_name", - render: (text, record) => { - return role_name === 'Super Admin' ? ( + ...(role_name === 'Super Admin' ? [ + { + title: t('company'), + dataIndex: "join_third_company_name", + key: "join_third_company_name", + render: (text, record) => ( {record.join_third_company_name} - ) : null; - } - }, + ) + }] : []), { title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' }, { title: t('nameHR'), dataIndex: 'name', key: 'name' }, { title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' }, diff --git a/src/views/SimproV2/Satuan/index.js b/src/views/SimproV2/Satuan/index.js index dfe0528..fae6018 100644 --- a/src/views/SimproV2/Satuan/index.js +++ b/src/views/SimproV2/Satuan/index.js @@ -6,24 +6,24 @@ import axios from "../../../const/interceptorApi" import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { NotificationContainer, NotificationManager } from 'react-notifications'; import { Pagination, Button, Tooltip } from 'antd'; -import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst'; +import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; import { useTranslation } from 'react-i18next'; const Satuan = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; - if (props && props.role_id && props.user_id) { - role_id = props.role_id; - user_id = props.user_id; - token = props.token; - isLogin = props.isLogin; - company_id = props.company_id; - all_project = props.all_project; - role_name = props.role_name; - isLogin = props.isLogin; - hierarchy = props.hierarchy; - user_name = props.user_name; - } + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } const HEADER = { headers: { @@ -46,6 +46,7 @@ const Satuan = ({ params, ...props }) => { const [search, setSearch] = useState('') const [totalPage, setTotalPage] = useState(0) const [typeDialog, setTypeDialog] = useState('Save') + const [listCompany, setListCompany] = useState([]) const { t } = useTranslation() useEffect(() => { getDataSatuan() @@ -58,11 +59,27 @@ const Satuan = ({ params, ...props }) => { } }, [dataExport]) + useEffect(() => { + getDataCompany() + }, []) + const column = [ - { name: "Company Name" }, + role_name === 'Super Admin' ? { name: t('company') } : null, { name: t('name') }, { name: t('description') }, - ] + ].filter(column => column && column.name); + + const getDataCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + setListCompany(result.data.data); + } + } + const getDataSatuan = async () => { let start = 0; @@ -76,11 +93,11 @@ const Satuan = ({ params, ...props }) => { "operator": "AND", "group_operator": "OR", "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": search, - } + { + "name": "name", + "logic_operator": "~*", + "value": search, + } ] }, "columns": [], @@ -106,10 +123,10 @@ const Satuan = ({ params, ...props }) => { { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } ) payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } ) } @@ -143,13 +160,13 @@ const Satuan = ({ params, ...props }) => { "operator": "AND", "group_operator": "OR", "where": [ - { - "name": "name", - "logic_operator": "~*", - "value": search, - } + { + "name": "name", + "logic_operator": "~*", + "value": search, + } ] - }, + }, "paging": { "start": 0, "length": -1 }, "columns": [], "orders": { "columns": ["id"], "ascending": false }, @@ -157,17 +174,17 @@ const Satuan = ({ params, ...props }) => { } if (role_name !== "Super Admin") { payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, ) - } else { + } else { payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } ) payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } ) } const result = await axios @@ -179,11 +196,11 @@ const Satuan = ({ params, ...props }) => { const excelData = []; resData.map((val, index) => { let dataRow = {}; - if (role_name === 'Super Admin') { + if (role_name === 'Super Admin') { dataRow.Company = val.join_first_company_name; } - dataRow.Nama=val.name; - dataRow.Deskripsi=val.description; + dataRow.Nama = val.name; + dataRow.Deskripsi = val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -322,6 +339,9 @@ const Satuan = ({ params, ...props }) => { dataEdit={dataEdit} clickOpenModal={clickOpenModal} dataParent={allDataMenu} + listCompany={listCompany} + role_name={role_name} + company_id={company_id} /> @@ -367,10 +387,10 @@ const Satuan = ({ params, ...props }) => { handleEdit(n)}> - {role_name === 'Super Admin'&& - ( - - ) + {role_name === 'Super Admin' && + ( + + ) } From 0aecd61415d41e455bc34c339bf703d7eea70f5a Mon Sep 17 00:00:00 2001 From: farhantock Date: Fri, 19 Jan 2024 11:17:51 +0700 Subject: [PATCH 10/17] add select company by super admin --- .../Master/MasterBroadcast/DialogForm.js | 110 ++++++++++-------- src/views/Master/ProjectPhase/DialogForm.js | 48 +++++++- src/views/SimproV2/ChecklistK3/DialogForm.js | 56 +++++++-- src/views/SimproV2/Divisi/DialogForm.js | 47 +++++++- src/views/SimproV2/ProjectType/DialogForm.js | 58 ++++++--- src/views/SimproV2/Satuan/DialogForm.js | 60 ++++++++-- 6 files changed, 289 insertions(+), 90 deletions(-) diff --git a/src/views/Master/MasterBroadcast/DialogForm.js b/src/views/Master/MasterBroadcast/DialogForm.js index 7ce2d67..6f264dd 100644 --- a/src/views/Master/MasterBroadcast/DialogForm.js +++ b/src/views/Master/MasterBroadcast/DialogForm.js @@ -3,7 +3,7 @@ import React, { Component } from 'react'; import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; import Select from 'react-select'; import axios from 'axios'; -import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST } from '../../../const/ApiConst'; +import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst'; import { Transfer } from 'antd'; import { withTranslation } from 'react-i18next'; @@ -51,13 +51,18 @@ class DialogForm extends Component { allEmployeeId: [], idEmployeeDivision: [], idOrganization: [], - disableTransfer: true + disableTransfer: true, + listCompany: [], + company_id: this.props.company_id, + role_name: '' } } async componentDidMount() { - this.getDataUsers(); - this.getDataRole(); + if (this.props.company_id !== null) { + this.getDataRole(); + this.getDataUsers(); + } this.props.showDialog(this.showDialog); } @@ -69,14 +74,16 @@ class DialogForm extends Component { id: dataEdit.id, title: dataEdit.title_notif, description: dataEdit.description, - message: dataEdit.message_notif + message: dataEdit.message_notif, + company_id: dataEdit.company_id }) } else { this.setState({ id: 0, title: "", description: "", - message: "" + message: "", + company_id: 0 }) } this.setState({ isParentClick: false }); @@ -128,9 +135,12 @@ class DialogForm extends Component { title, description, message, - penerima - } = this.state + penerima, + } = this.state + let { + company_id + } = this.state let idSend = []; let send_to_type = "all"; if (penerima === "all") { @@ -151,15 +161,17 @@ class DialogForm extends Component { } else { idSend = idSend; } - + if (this.props.role_name !== 'Super Admin') { + company_id = parseInt(this.props.company_id) + } const data = { title, description, message, send_to_type, - id: idSend + id: idSend, + company_id: company_id } - if (param === 'registered' || param === 'send') { this.props.handleSaveBroadcast(param, data) } @@ -201,7 +213,18 @@ class DialogForm extends Component { getDataRole = async () => { const payload = { - + "paging": { + "start": 0, + "length": -1 + }, + "columns": [ + { + "name": "company_id", + "logic_operator": "=", + "value": this.state.company_id, + "operator": "AND" + } + ], "orders": { "columns": ["id"], "ascending": false } } @@ -231,20 +254,11 @@ class DialogForm extends Component { } getDataUsers = async () => { - - const payload = { "paging": { "start": 0, - "length": 10 + "length": -1 }, - "filter_columns": [ - { - "name": "name", - "value": "", - "table_name": "m_users" - } - ], "columns": [ { "name": "name", @@ -254,34 +268,10 @@ class DialogForm extends Component { "table_name": "m_users" }, { - "name": "id", + "name": "company_id", "logic_operator": "=", - "value": "3", - "operator": "AND", - "table_name": "m_roles" - } - ], - "joins": [ - { - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "username", - "name", - "email", - "gender", - "phone_number", - "address", - "birth_place", - "birth_date" - ] - }, - { - "name": "m_roles", - "column_join": "role_id", - "column_results": [ - "name" - ] + "value": this.state.company_id, + "operator": "AND" } ], "orders": { @@ -293,7 +283,7 @@ class DialogForm extends Component { } //TODO should use search instead const result = await axios - .get(USER_LIST, config) + .post(USER_SEARCH, payload, config) .then(res => res) .catch((error) => error.response); @@ -330,11 +320,29 @@ class DialogForm extends Component { }; + handleSelectCompany = (selectedOption) => { + const selectedCompanyId = selectedOption.value; + this.setState({ company_id: selectedCompanyId }, () => { + this.getDataRole(); + this.getDataUsers(); + }); + } + renderForm = () => { const t = this.props const { errorTitle, errorMessage } = this.state return (
+ {this.props.role_name === 'Super Admin' && ( + + + this.handleChangePenerima(e.target.value)}> @@ -395,7 +403,7 @@ class DialogForm extends Component { this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> - + ) } handleCloseDialog = () => { diff --git a/src/views/Master/ProjectPhase/DialogForm.js b/src/views/Master/ProjectPhase/DialogForm.js index db5b010..05d02be 100644 --- a/src/views/Master/ProjectPhase/DialogForm.js +++ b/src/views/Master/ProjectPhase/DialogForm.js @@ -8,17 +8,20 @@ import InputColor from "./InputColor"; import "./styles.css"; import "rc-color-picker/assets/index.css"; import { useTranslation } from 'react-i18next'; -const company_id = localStorage.getItem("company_id") -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { +import { Select } from 'antd'; +const { Option } = Select +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { const [id, setId] = useState(0) const [projectType, setProjectType] = useState('') const [color, setColor] = useState('') + const [selectedCompany, setSelectedCompany] = useState(null) const { t } = useTranslation(); useEffect(() => { if (typeDialog === "Edit") { setId(dataEdit.id) setProjectType(dataEdit.name) setColor(dataEdit.color) + setSelectedCompany(dataEdit.company_id) } else { setId(0) setColor('') @@ -29,18 +32,24 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi const handleSave = () => { let data = ''; if (typeDialog === "Save") { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { name: projectType, color, - company_id + company_id: company_id } closeDialog('save', data); } else { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { id, name: projectType, color, - company_id + company_id: company_id } closeDialog('edit', data); } @@ -52,6 +61,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setId(0) } + const onChangeCompany = (val) => { + setSelectedCompany(val); + }; + const renderForm = () => { return (
@@ -69,6 +82,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi + {role_name === 'Super Admin' && + +
+ + + + + + + } ) } diff --git a/src/views/SimproV2/ChecklistK3/DialogForm.js b/src/views/SimproV2/ChecklistK3/DialogForm.js index 459638c..07a4ab2 100644 --- a/src/views/SimproV2/ChecklistK3/DialogForm.js +++ b/src/views/SimproV2/ChecklistK3/DialogForm.js @@ -5,20 +5,22 @@ import { } from 'reactstrap'; import 'antd/dist/antd.css'; import { useTranslation } from 'react-i18next'; +import { Select } from 'antd'; +const { Option } = Select; - -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id }) => { +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { const [id, setId] = useState(0) const [name, setName] = useState('') const [description, setDescription] = useState('') + const [selectedCompany, setSelectedCompany] = useState(null) const { t } = useTranslation() - useEffect(() => { if (typeDialog === "Edit") { setId(dataEdit.id) setDescription(dataEdit.description) setName(dataEdit.name) + setSelectedCompany(dataEdit.company_id); } else { handleClearData() @@ -27,20 +29,26 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi const handleSave = () => { let data = ''; + if (role_name === 'Super Admin') { + company_id = selectedCompany + } + if (typeDialog === "Save") { data = { name: name, - description, - company_id + description: description, + company_id: parseInt(company_id), } - closeDialog('save', data); } else { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { id, name: name, - description, - company_id + description: description, + company_id: company_id, } closeDialog('edit', data); } @@ -56,8 +64,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setId(0) setName('') setDescription('') + setSelectedCompany(null) } + const onChangeCompany = (val) => { + setSelectedCompany(val); + }; + const renderForm = () => { return ( @@ -75,6 +88,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi + {role_name === 'Super Admin' && + + + + + + + + + } ) } diff --git a/src/views/SimproV2/Divisi/DialogForm.js b/src/views/SimproV2/Divisi/DialogForm.js index ee43a37..3c59e8a 100644 --- a/src/views/SimproV2/Divisi/DialogForm.js +++ b/src/views/SimproV2/Divisi/DialogForm.js @@ -10,12 +10,13 @@ import InputColor from "./InputColor"; import "./styles.css"; import "rc-color-picker/assets/index.css"; const { Option } = Select -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions, company_id }) => { +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions, company_id, role_name, listCompany }) => { const [id, setId] = useState(0) const [name, setName] = useState('') const [parent, setParent] = useState(null) const [description, setDescription] = useState('') const [color, setColor] = useState('') + const [selectedCompany, setSelectedCompany] = useState(null) const { t } = useTranslation() const onChangeParent = (val) => { @@ -29,6 +30,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setName(dataEdit.name) setParent(dataEdit.parent) setColor(dataEdit.color) + setSelectedCompany(dataEdit.company_id); } else { setId(0) setColor('') @@ -47,22 +49,28 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi if (!err) { if (typeDialog === "Save") { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { name, description, parent, color, - company_id + company_id: company_id } closeDialog('save', data); } else { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { id, name, description, parent, color, - company_id + company_id: company_id } closeDialog('edit', data); } @@ -71,6 +79,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setName('') setParent(null) setColor('') + setSelectedCompany(null) } } const handleCancel = () => { @@ -79,8 +88,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setDescription('') setName('') setParent(null) + setSelectedCompany(null) } + const onChangeCompany = (val) => { + setSelectedCompany(val); + }; + const renderForm = () => { return ( @@ -133,6 +147,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi + {role_name === 'Super Admin' && + + + + + + + + + } ) } diff --git a/src/views/SimproV2/ProjectType/DialogForm.js b/src/views/SimproV2/ProjectType/DialogForm.js index afe4058..6619f40 100644 --- a/src/views/SimproV2/ProjectType/DialogForm.js +++ b/src/views/SimproV2/ProjectType/DialogForm.js @@ -3,20 +3,19 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; -import { DatePicker, Tooltip, Select } from 'antd'; -import { formatRupiah, formatNumber } from '../../../const/CustomFunc' +import { Select } from 'antd'; import moment from 'moment'; import 'antd/dist/antd.css'; import { useTranslation } from 'react-i18next'; const { Option } = Select -const company_id = window.localStorage.getItem('company_id'); -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { const [id, setId] = useState(0) const [projectType, setProjectType] = useState('') const [uom, setUom] = useState('') const [description, setDescription] = useState('') const [unitPrice, setUnitPrice] = useState() + const [selectedCompany, setSelectedCompany] = useState(null) const { t } = useTranslation(); @@ -28,7 +27,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setUnitPrice(dataEdit.unit_price) setUom(dataEdit.uom) setProjectType(dataEdit.name) - + setSelectedCompany(dataEdit.company_id) } else { setId(0) } @@ -37,39 +36,43 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi const handleSave = () => { let data = ''; if (typeDialog === "Save") { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { name: projectType, description, - company_id + company_id: company_id } closeDialog('save', data); } else { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { id, name: projectType, description, - company_id + company_id: company_id } closeDialog('edit', data); } setId(0) setDescription('') - + setSelectedCompany(null) } const handleCancel = () => { closeDialog('cancel', 'none') setId(0) - setDescription('') - + setSelectedCompany(null) } - - - - + const onChangeCompany = (val) => { + setSelectedCompany(val); + }; const renderForm = () => { return ( @@ -88,6 +91,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi + {role_name === 'Super Admin' && + + + + + + + + + } ) } diff --git a/src/views/SimproV2/Satuan/DialogForm.js b/src/views/SimproV2/Satuan/DialogForm.js index 6291353..3ebbc50 100644 --- a/src/views/SimproV2/Satuan/DialogForm.js +++ b/src/views/SimproV2/Satuan/DialogForm.js @@ -3,15 +3,16 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; +import { Select } from 'antd'; import 'antd/dist/antd.css'; import { useTranslation } from 'react-i18next'; +const { Option } = Select; -const company_id = localStorage.getItem("company_id") - -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { const [id, setId] = useState(0) const [name, setName] = useState('') const [description, setDescription] = useState('') + const [selectedCompany, setSelectedCompany] = useState(null) const { t } = useTranslation() @@ -20,7 +21,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setId(dataEdit.id) setDescription(dataEdit.description) setName(dataEdit.name) - + setSelectedCompany(dataEdit.company_id); } else { setId(0) } @@ -29,34 +30,46 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi const handleSave = () => { let data = ''; if (typeDialog === "Save") { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { name: name, - description, - company_id + description: description, + company_id: company_id } closeDialog('save', data); } else { + + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { id, name: name, - description, - company_id + description: description, + company_id: company_id } closeDialog('edit', data); } setId(0) setDescription('') + setSelectedCompany(null) } const handleCancel = () => { closeDialog('cancel', 'none') setId(0) - setDescription('') - + setSelectedCompany(null) } + + const onChangeCompany = (val) => { + setSelectedCompany(val); + }; + const renderForm = () => { return ( @@ -74,6 +87,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi + {role_name === 'Super Admin' && + + + + + + + + + } ) } From c1ed033a7fb609360d6def3507efa844779d2ef1 Mon Sep 17 00:00:00 2001 From: wahyun Date: Fri, 19 Jan 2024 11:45:30 +0700 Subject: [PATCH 11/17] add form company_id --- src/views/Master/MasterRoles/DialogForm.js | 91 ++++-- .../Master/MasterRoles/DialogMenuRoles.js | 61 ++-- src/views/Master/MasterRoles/index.js | 23 +- src/views/Master/RoleProject/DialogForm.js | 298 +++++++++++------- src/views/Master/RoleProject/index.js | 9 +- .../CreatedProyek/DialogFormProyek.js | 68 +++- src/views/SimproV2/CreatedProyek/index.js | 64 +++- .../SimproV2/ResourceWorker/DialogForm.js | 63 ++-- src/views/SimproV2/ResourceWorker/index.js | 26 +- 9 files changed, 459 insertions(+), 244 deletions(-) diff --git a/src/views/Master/MasterRoles/DialogForm.js b/src/views/Master/MasterRoles/DialogForm.js index 53f6d4e..32ce293 100644 --- a/src/views/Master/MasterRoles/DialogForm.js +++ b/src/views/Master/MasterRoles/DialogForm.js @@ -1,22 +1,13 @@ import React, { Component } from 'react' -import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col } from 'reactstrap'; -import { Button, Form, FormGroup, Label, Input } from 'reactstrap'; +import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col, Button, Form, FormGroup, Label, Input } from 'reactstrap'; import 'antd/dist/antd.css'; import { withTranslation } from 'react-i18next'; import axios from 'axios'; +import { NotificationManager } from 'react-notifications'; import { Select } from 'antd'; -import { MENU_SEARCH } from '../../../const/ApiConst.js'; +import { COMPANY_MANAGEMENT_LIST, MENU_SEARCH } from '../../../const/ApiConst.js'; const { Option } = Select -const token = window.localStorage.getItem('token'); -const company_id = localStorage.getItem("company_id") -const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } -}; class DialogForm extends Component { constructor(props) { @@ -27,16 +18,26 @@ class DialogForm extends Component { description: "", openDialog: false, isParentClick: false, + companyList: [], + scompany_id:null, menu: [], selectedMenu: null, all_project: false, - company_id + company_id: props.company_id || null, + role_name: props.role_name || '', + token: props.token || '', + config: { + headers: { + Authorization: `Bearer ${props.token || ''}`, + "Content-type": "application/json", + } + } } } - async componentDidMount() { - this.props.showDialog(this.showDialog); + this.getDataProyekCompany(); this.getAllMenu(); + this.props.showDialog(this.showDialog); } async componentDidUpdate() { if (this.state.isParentClick === true) { @@ -47,7 +48,7 @@ class DialogForm extends Component { name: dataEdit.name, description: dataEdit.description, selectedMenu: dataEdit.default_page, - company_id + scompany_id : dataEdit.company_id }) } else { this.setState({ @@ -55,13 +56,27 @@ class DialogForm extends Component { name: "", description: "", selectedMenu: null, - company_id + scompany_id : null }) } this.setState({ isParentClick: false }); } } + getDataProyekCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, this.state.config) + .then((res) => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + let dataRes = result.data.data || []; + this.setState({companyList: dataRes}) + } else { + NotificationManager.error("Gagal Mengambil Data!!", "Failed"); + } + }; + getAllMenu = async () => { const payload = { "paging": { "start": 0, "length": -1 }, @@ -72,7 +87,7 @@ class DialogForm extends Component { "orders": { "columns": ["id"], "ascending": false } } const result = await axios - .post(MENU_SEARCH, payload, config) + .post(MENU_SEARCH, payload, this.state.config) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { @@ -85,6 +100,10 @@ class DialogForm extends Component { } validation = () => { + if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") { + alert("Company data cannot be empty!"); + return true; + } if (!this.state.name || this.state.name === "") { alert("Role Name cannot be empty!"); return true; @@ -101,7 +120,9 @@ class DialogForm extends Component { name, description, selectedMenu, + role_name, company_id, + scompany_id, all_project } = this.state @@ -114,7 +135,7 @@ class DialogForm extends Component { name, description, selectedMenu, - company_id, + company_id : role_name !== 'Super Admin' ? company_id : scompany_id, all_project } @@ -125,21 +146,22 @@ class DialogForm extends Component { name, description, selectedMenu, - company_id, + company_id : role_name !== 'Super Admin' ? company_id : scompany_id, all_project } this.props.closeDialog('edit', data); } this.setState({ id: 0 }); } - - } handleCancel = () => { this.props.closeDialog('cancel', 'none') } + onChangeCompanyProject = (val) => { + this.setState({scompany_id : val}); + }; renderForm = () => { const { t } = this.props; return ( @@ -150,6 +172,31 @@ class DialogForm extends Component { + { + this.state.role_name === 'Super Admin' && ( + + + + + + + ) + } diff --git a/src/views/Master/MasterRoles/DialogMenuRoles.js b/src/views/Master/MasterRoles/DialogMenuRoles.js index 1e6c5eb..fa0eda6 100644 --- a/src/views/Master/MasterRoles/DialogMenuRoles.js +++ b/src/views/Master/MasterRoles/DialogMenuRoles.js @@ -7,17 +7,6 @@ import { MENU_SEARCH } from '../../../const/ApiConst.js'; import { withTranslation, WithTranslation } from 'react-i18next'; const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/"; -const token = window.localStorage.getItem('token'); - - -const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } -}; - class DialogMenuRoles extends Component { constructor(props) { super(props) @@ -27,28 +16,24 @@ class DialogMenuRoles extends Component { description: "", openDialog: false, isParentClick: false, - menu: [], stateMenu: [], + menu:[], allChecked: true, + company_id: props.company_id || null, + role_name: props.role_name || '', + token: props.token || '', + config: { + headers: { + Authorization: `Bearer ${props.token || ''}`, + "Content-type": "application/json", + } + } } } async componentDidMount() { + this.getAllMenu() this.props.showDialog(this.showDialog); - this.getAllMenu(); - } - - async componentDidUpdate() { - if (this.state.isParentClick === true) { - const { idRoles } = this.props - this.setStateMenu(true); - this.setState({ isParentClick: false, id: idRoles }); - } - } - - - showDialog = () => { - this.setState({ isParentClick: true }); } getAllMenu = async () => { @@ -60,22 +45,26 @@ class DialogMenuRoles extends Component { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - - - const result = await axios - .post(MENU_SEARCH, payload, config) + .post(MENU_SEARCH, payload, this.state.config) .then(res => res) .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - this.setState({ menu: result.data.data }, () => { - this.setStateMenu(false); - }); - } else { + this.setState({ menu: result.data.data }); + } + } + + async componentDidUpdate() { + if (this.state.isParentClick === true) { + const { idRoles } = this.props + this.setStateMenu(true); + this.setState({ isParentClick: false, id: idRoles }); } + } + + showDialog = () => { + this.setState({ isParentClick: true }); } setStateMenu = edit => { diff --git a/src/views/Master/MasterRoles/index.js b/src/views/Master/MasterRoles/index.js index 6ea08a6..c19e1da 100644 --- a/src/views/Master/MasterRoles/index.js +++ b/src/views/Master/MasterRoles/index.js @@ -194,7 +194,7 @@ class index extends Component { const { idDelete } = this.state const url = ROLE_DELETE(idDelete) - const result = await axios.delete(url, this.config) + const result = await axios.delete(url, this.state.config) .then(res => res) .catch((error) => error.response); @@ -219,7 +219,7 @@ class index extends Component { all_project: data.all_project } - const result = await axios.post(ROLE_ADD, formData, this.config) + const result = await axios.post(ROLE_ADD, formData, this.state.config) .then(res => res) .catch((error) => error.response); @@ -241,7 +241,7 @@ class index extends Component { all_project: data.all_project } const url = ROLE_EDIT(data.id) - const result = await axios.put(url, formData, this.config) + const result = await axios.put(url, formData, this.state.config) .then(res => res) .catch((error) => error.response); @@ -310,7 +310,7 @@ class index extends Component { } const result = await axios - .post(ROLEMENU_SEARCH, formData, this.config) + .post(ROLEMENU_SEARCH, formData, this.state.config) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { @@ -334,7 +334,7 @@ class index extends Component { menu_id: val.menu_id, role_id: val.roles_id } - promises.push(axios.post(ROLEMENU_ADD, formData, this.config) + promises.push(axios.post(ROLEMENU_ADD, formData, this.state.config) .then(res => result.push(res))) } }) @@ -354,7 +354,7 @@ class index extends Component { deleteCurrentRoleMenu = async (id) => { let urlDel = ROLEMENU_DELETE_ROLE(id) - const result = await axios.delete(urlDel, this.config) + const result = await axios.delete(urlDel, this.state.config) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code === 200) { @@ -472,9 +472,9 @@ class index extends Component { dataEdit={this.state.dataEdit} showDialog={showDialog => this.showChildDialog = showDialog} dataHs={this.state.dataIdHo} - companyID={this.state.company_id} - roleName={this.state.role_name} - + company_id={this.state.company_id} + role_name={this.state.role_name} + token={this.state.token} /> this.showMenuRolesDialog = showDialog} menuRoles={this.state.menuRoles} - companyID={this.state.company_id} - roleName={this.state.role_name} + company_id={this.state.company_id} + role_name={this.state.role_name} + token={this.state.token} /> diff --git a/src/views/Master/RoleProject/DialogForm.js b/src/views/Master/RoleProject/DialogForm.js index c7a417e..d52f788 100644 --- a/src/views/Master/RoleProject/DialogForm.js +++ b/src/views/Master/RoleProject/DialogForm.js @@ -1,116 +1,182 @@ -import React, { Component } from 'react' -import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; -import { Button, Form, FormGroup, Label, Input } from 'reactstrap'; -import 'antd/dist/antd.css'; -import { withTranslation } from 'react-i18next'; -const company_id = localStorage.getItem("company_id") -class DialogForm extends Component { - constructor(props) { - super(props) - this.state = { - id: 0, - name: "", - description: "", - openDialog: false, - isParentClick: false, - company_id - } - } - - async componentDidMount() { - this.props.showDialog(this.showDialog); - } - - async componentDidUpdate() { - if (this.state.isParentClick === true) { - if (this.props.typeDialog === "Edit") { - const { dataEdit } = this.props - this.setState({ - id: dataEdit.id, - name: dataEdit.name, - description: dataEdit.description, - company_id - }) - } else { - this.setState({ - id: 0, - name: "", - description: "" - }) - } - this.setState({ isParentClick: false }); - } - } - - - showDialog = () => { - this.setState({ isParentClick: true }); - } - - - handleSave = () => { - const { - id, - name, - description - } = this.state - - let data = ''; - if (this.props.typeDialog === "Save") { - data = { - id, - name, - description, - company_id - } - this.props.closeDialog('save', data); - } else { - data = { - id, - name, - description, - company_id - } - this.props.closeDialog('edit', data); - } - - this.setState({ id: 0 }); - - } - - handleCancel = () => { - this.props.closeDialog('cancel', 'none') - } - - renderForm = () => { - const { t } = this.props; - return ( -
- - - this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} /> - - - - this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> - - - ) - } - - render() { - return ( - - {this.props.typeDialog == "Save" ? "Tambah" : "Edit"} {this.props.t('nameProjectRole')} - - {this.renderForm()} - - - {' '} - - - - ) - } -} -export default withTranslation()(DialogForm); +import React, { Component } from 'react' +import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input } from 'reactstrap'; +import 'antd/dist/antd.css'; +import axios from 'axios'; +import { COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst.js'; +import { withTranslation } from 'react-i18next'; +import { NotificationManager } from 'react-notifications'; +import { Select } from 'antd'; +const { Option } = Select +class DialogForm extends Component { + constructor(props) { + super(props) + this.state = { + id: 0, + name: "", + description: "", + openDialog: false, + companyList: [], + scompany_id:null, + isParentClick: false, + company_id: props.company_id || null, + role_name: props.role_name || '', + token: props.token || '', + config: { + headers: { + Authorization: `Bearer ${props.token || ''}`, + "Content-type": "application/json", + } + } + } + } + + async componentDidMount() { + this.props.showDialog(this.showDialog); + this.getDataProyekCompany(); + } + + async componentDidUpdate() { + if (this.state.isParentClick === true) { + if (this.props.typeDialog === "Edit") { + const { dataEdit } = this.props + this.setState({ + id: dataEdit.id, + name: dataEdit.name, + description: dataEdit.description, + scompany_id : dataEdit.company_id + }) + } else { + this.setState({ + id: 0, + name: "", + description: "", + scompany_id:null + }) + } + this.setState({ isParentClick: false }); + } + } + + + showDialog = () => { + this.setState({ isParentClick: true }); + } + + getDataProyekCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, this.state.config) + .then((res) => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + let dataRes = result.data.data || []; + this.setState({companyList: dataRes}) + } else { + NotificationManager.error("Gagal Mengambil Data!!", "Failed"); + } + }; + + validation = () => { + if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") { + alert("Company data cannot be empty!"); + return true; + } + } + + handleSave = () => { + const { + id, + name, + description, + role_name, + company_id, + scompany_id + } = this.state + + let data = ''; + const err = this.validation(); + if(!err) { + if (this.props.typeDialog === "Save") { + data = { + id, + name, + description, + company_id : role_name !== 'Super Admin' ? company_id : scompany_id, + } + this.props.closeDialog('save', data); + } else { + data = { + id, + name, + description, + company_id : role_name !== 'Super Admin' ? company_id : scompany_id, + } + this.props.closeDialog('edit', data); + } + } + this.setState({ id: 0 }); + } + + handleCancel = () => { + this.props.closeDialog('cancel', 'none') + } + + onChangeCompanyProject = (val) => { + this.setState({scompany_id : val}); + }; + + renderForm = () => { + const { t } = this.props; + return ( +
+ { + this.state.role_name === 'Super Admin' && ( + + + + + ) + } + + + this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} /> + + + + this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> + + + ) + } + + render() { + return ( + + {this.props.typeDialog == "Save" ? "Tambah" : "Edit"} {this.props.t('nameProjectRole')} + + {this.renderForm()} + + + {' '} + + + + ) + } +} +export default withTranslation()(DialogForm); diff --git a/src/views/Master/RoleProject/index.js b/src/views/Master/RoleProject/index.js index c7773e3..d5b095b 100644 --- a/src/views/Master/RoleProject/index.js +++ b/src/views/Master/RoleProject/index.js @@ -6,7 +6,7 @@ import axios from 'axios'; import { Button } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js'; +import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE } from '../../../const/ApiConst.js'; import { Pagination, Tooltip, Table } from 'antd'; import { withTranslation } from 'react-i18next'; const LENGTH_DATA = 10 @@ -202,7 +202,7 @@ class index extends Component { const formData = { name: data.name, description: data.description, - company_id: this.state.company_id + company_id: data.company_id } const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config) @@ -223,7 +223,7 @@ class index extends Component { const formData = { name: data.name, description: data.description, - company_id : this.state.company_id + company_id : data.company_id } const url = PROJECT_ROLE_EDIT(data.id) const result = await axios.put(url, formData, this.state.config) @@ -390,6 +390,9 @@ class index extends Component { dataEdit={this.state.dataEdit} showDialog={showDialog => this.showChildDialog = showDialog} dataHs={this.state.dataIdHo} + company_id={this.state.company_id} + role_name={this.state.role_name} + token={this.state.token} /> diff --git a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js index f871754..e53efc2 100644 --- a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js +++ b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js @@ -35,7 +35,9 @@ const DialogFormProyek = ({ dataDivisions, dataPM, projectImage, - company_id + company_id, + role_name, + companyList }) => { const token = localStorage.getItem("token"); const HEADER = { @@ -65,6 +67,7 @@ const DialogFormProyek = ({ const [finance, setFinance] = useState(""); const [investor, setInvestor] = useState(""); const [company, setCompany] = useState(""); + const [scompany_id, setCompanyId] = useState(null); const [step, setStep] = useState(1); const [currencyList, setCurrencyList] = useState(null); const [currency, setCurrency] = useState(""); // merge of code | symbol | name @@ -115,6 +118,7 @@ const DialogFormProyek = ({ setProjectDuration(val.durasi_proyek); setInvestor(val.investor); setCompany(val.company); + setCompanyId(val.company_id) setFinance(val.finance); setObjectives(val.project_objectives ? val.project_objectives : ""); setTestingEnv(val.testing_environment); @@ -206,6 +210,7 @@ const DialogFormProyek = ({ setDivisiProject(null); setProjectStructureOrg(null); setCompany(""); + setCompanyId(null) setCurrency(""); setCurrencyCode(""); setCurrencySymbol(null); @@ -276,7 +281,7 @@ const DialogFormProyek = ({ currency_symbol: currencySymbol, currency_code: currencyCode, currency_name: currencyName, - company_id: parseInt(company_id) + company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; data.imageStructureOrg = organization ? organization : null; @@ -307,7 +312,7 @@ const DialogFormProyek = ({ currency_symbol: currencySymbol, currency_code: currencyCode, currency_name: currencyName, - company_id: parseInt(company_id) + company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; data.imageStructureOrg = organization ? organization : null; @@ -326,6 +331,10 @@ const DialogFormProyek = ({ setTypeproject(val); }; + const onChangeCompanyProject = (val) => { + setCompanyId(val); + }; + const onChangePhaseProject = (val) => { setPhaseProject(val); }; @@ -404,6 +413,10 @@ const DialogFormProyek = ({ alert("End Date cannot be empty!"); return false; } + if (role_name === 'Super Admin' && !scompany_id || scompany_id === "") { + alert("Company data cannot be empty!"); + return false; + } if (!biaya || biaya === "") { alert("Budget cannot be empty!"); return false; @@ -754,16 +767,31 @@ const DialogFormProyek = ({ -
- - - setWorkArea(e.target.value)} - /> - - + { + role_name === 'Super Admin' && ( + + + + + + + ) + } @@ -774,9 +802,7 @@ const DialogFormProyek = ({ /> - - - + + + + + setWorkArea(e.target.value)} + /> + + diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 6840aa2..af1da88 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -36,6 +36,7 @@ import { PROJECT_TYPE_SEARCH, PROYEK_ADD, PROYEK_SEARCH, + COMPANY_MANAGEMENT_LIST, PROYEK_EDIT, ASSIGN_HR_PROJECT_SEARCH, PROJECT_CHECKLIST_SEARCH, @@ -116,6 +117,7 @@ const CreatedProyek = ({ params, ...props }) => { const [idTask, setidTask] = useState(0); const [projectId, setProjectId] = useState(0); const [dataTable, setDatatable] = useState([]); + const [companyList, setDataCompany] = useState([]); const [search, setSearch] = useState(""); const [currentPage, setCurrentPage] = useState(1); const [totalPage, setTotalPage] = useState(0); @@ -193,6 +195,9 @@ const CreatedProyek = ({ params, ...props }) => { handleGetPhaseProject(); handleGetDivisions(); handleGetDataPm(); + if(role_name === 'Super Admin') { + getDataProyekCompany(); + } } }, [openDialogProyek]); @@ -224,33 +229,36 @@ const CreatedProyek = ({ params, ...props }) => { const handleGetTipeProject = async () => { const payload = { "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ], + "columns": [], "joins": [], "orders": { "columns": ["id"], "ascending": false } } - + if(role_name !== 'Super Admin') { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" } + ) + } const result = await axios .post(PROJECT_TYPE_SEARCH, payload, HEADER) .then((res) => res) .catch((err) => err.response); if (result && result.data && result.data.code === 200) { setDataTypeProyek(result.data.data); - } else { } }; const handleGetPhaseProject = async () => { const payload = { "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ], + "columns": [], "joins": [], "orders": { "columns": ["id"], "ascending": false } } - + if(role_name !== 'Super Admin') { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" } + ) + } const result = await axios .post(PROJECT_PHASE_SEARCH, payload, HEADER) .then((res) => res) @@ -263,13 +271,15 @@ const CreatedProyek = ({ params, ...props }) => { const handleGetDivisions = async () => { const payload = { "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ], + "columns": [], "joins": [], "orders": { "columns": ["id"], "ascending": false } } - + if(role_name !== 'Super Admin') { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" } + ) + } const result = await axios .post(DIVISI_SEARCH, payload, HEADER) .then((res) => res) @@ -284,13 +294,15 @@ const CreatedProyek = ({ params, ...props }) => { const handleGetDataPm = async () => { const payload = { "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ], + "columns": [], "joins": [], "orders": { "columns": ["id"], "ascending": false } } - + if(role_name !== 'Super Admin') { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" } + ) + } const result = await axios .post(USER_SEARCH, payload, HEADER) .then((res) => res) @@ -302,6 +314,22 @@ const CreatedProyek = ({ params, ...props }) => { } }; + const getDataProyekCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, HEADER) + .then((res) => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + let dataRes = result.data.data || []; + setDataCompany(dataRes); + setLoading(false); + } else { + setLoading(false); + NotificationManager.error("Gagal Mengambil Data!!", "Failed"); + } + }; + const handleDashboard = async (id) => { const URL = `${BASE_OSPRO}/api/project/detail/${id}`; const result = await axios @@ -1846,6 +1874,8 @@ const CreatedProyek = ({ params, ...props }) => { dataPM={dataPm} projectImage={image} company_id={company_id} + role_name={role_name} + companyList={companyList} /> ), [ diff --git a/src/views/SimproV2/ResourceWorker/DialogForm.js b/src/views/SimproV2/ResourceWorker/DialogForm.js index 8bfaabb..2c08421 100644 --- a/src/views/SimproV2/ResourceWorker/DialogForm.js +++ b/src/views/SimproV2/ResourceWorker/DialogForm.js @@ -7,21 +7,10 @@ import { DatePicker, Tooltip, Select, Input as InputAntd } from 'antd'; import moment from 'moment'; import 'antd/dist/antd.css'; import { formatRupiah, formatNumber } from '../../../const/CustomFunc' -import { ROLE_SEARCH } from '../../../const/ApiConst' import { useTranslation } from 'react-i18next'; const { Option } = Select -const token = window.localStorage.getItem('token'); -const company_id = localStorage.getItem("company_id") -const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } -}; - -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList }) => { +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => { const [openDialogMap, setOpenDialogMap] = useState(false) const [id, setId] = useState(0) @@ -39,6 +28,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi const [ktpNumber, setKtpNumber] = useState('') const [biayaPerJam, setBiayaPerJam] = useState('') const [roleId, setRoleId] = useState('') + const [scompany_id, setCompanyId] = useState(null); const [address, setAddress] = useState('') const [divisionId, setDivisionId] = useState('') const [statusResource, setStatusResource] = useState('active') @@ -55,6 +45,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setPhoneNo(dataEdit.phone_number) setEmail(dataEdit.email) setGender(dataEdit.gender) + setCompanyId(dataEdit.company_id) setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "") setBirthPlace(dataEdit.birth_place) setBloodType(dataEdit.blood_type) @@ -82,6 +73,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi setRoleId('') setDivisionId('') setAddress('') + setCompanyId(null) setStatusResource('active') setStatusRestriction(false) } @@ -117,7 +109,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi address, status_resource: statusResource, status_boundary: statusRestriction, - company_id: company_id + company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) } if (birthDate && birthDate != "") { @@ -165,7 +157,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi address, status_resource: statusResource, status_boundary: statusRestriction, - company_id: company_id + company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) } if (birthDate && birthDate != "") { @@ -176,6 +168,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi } } + const onChangeCompanyProject = (val) => { + setCompanyId(val); + }; + const handleCancel = () => { closeDialog('cancel', 'none') } @@ -307,13 +303,31 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi - - - - + { + role_name === 'Super Admin' && ( + + + + + + + ) + } + + + + diff --git a/src/views/SimproV2/ResourceWorker/index.js b/src/views/SimproV2/ResourceWorker/index.js index fb07ef8..2cb1008 100644 --- a/src/views/SimproV2/ResourceWorker/index.js +++ b/src/views/SimproV2/ResourceWorker/index.js @@ -10,7 +10,7 @@ import { DownloadOutlined } from '@ant-design/icons'; import { NotificationContainer, NotificationManager } from 'react-notifications'; import { Pagination, Table, Button, Tooltip, Spin } from 'antd'; import { - PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC + USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; import { useTranslation } from 'react-i18next'; @@ -43,6 +43,7 @@ const ResourceWorker = ({ params, ...props }) => { const [dataExport, setDataExport] = useState([]) const [dataTable, setDatatable] = useState([]) const [divisiList, setDivisiList] = useState([]) + const [companyList, setDataCompany] = useState([]); const [idDelete, setIdDelete] = useState(0) const [openDialog, setOpenDialog] = useState(false) const [openDialogShift, setOpenDialogShift] = useState(false) @@ -59,6 +60,9 @@ const ResourceWorker = ({ params, ...props }) => { useEffect(() => { getRoleList() getDivisiList() + if(role_name === 'Super Admin') { + getDataProyekCompany(); + } }, []) useEffect(() => { @@ -96,7 +100,6 @@ const ResourceWorker = ({ params, ...props }) => { { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) } - const result = await axios .post(ROLE_SEARCH, formData, HEADER) .then(res => res) @@ -251,6 +254,22 @@ const ResourceWorker = ({ params, ...props }) => { } } + const getDataProyekCompany = async () => { + const result = await axios + .get(COMPANY_MANAGEMENT_LIST, HEADER) + .then((res) => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + let dataRes = result.data.data || []; + setDataCompany(dataRes); + setLoading(false); + } else { + setLoading(false); + NotificationManager.error("Gagal Mengambil Data!!", "Failed"); + } + }; + const handleSearch = e => { const value = e.target.value setSearch(value); @@ -599,6 +618,9 @@ const ResourceWorker = ({ params, ...props }) => { clickOpenModal={clickOpenModal} roleList={roleList} divisiList={divisiList} + role_name={role_name} + companyList={companyList} + company_id={company_id} /> Date: Fri, 19 Jan 2024 16:26:53 +0700 Subject: [PATCH 12/17] add param company_id & role_name --- src/views/Dashboard/DashboardProject.js | 3 ++- src/views/SimproV2/Gantt/GanttFrame.js | 5 +++-- src/views/SimproV2/Gantt/index.js | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index b70c658..376bada 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -86,7 +86,8 @@ const DashboardProject = (props) => { }, }; const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); - const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; + const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; + // const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; const mapRef = useRef(); const [projectName, setProjectName] = useState(""); const [projectManagerName, setProjectManagerName] = useState(""); diff --git a/src/views/SimproV2/Gantt/GanttFrame.js b/src/views/SimproV2/Gantt/GanttFrame.js index e7c687f..8c7c252 100644 --- a/src/views/SimproV2/Gantt/GanttFrame.js +++ b/src/views/SimproV2/Gantt/GanttFrame.js @@ -4,8 +4,9 @@ import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; const GanttFrame = React.memo((props) => { const history = useHistory(); - const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token } = props; - const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}`; + const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, company_id, role_name } = props; + const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`; + // const iframeSrc = `http://localhost:8444/generic-ospro-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`; const [batchEntityData, setBatchEntityData] = useState(null); useEffect(() => { diff --git a/src/views/SimproV2/Gantt/index.js b/src/views/SimproV2/Gantt/index.js index cc7aba0..817985c 100644 --- a/src/views/SimproV2/Gantt/index.js +++ b/src/views/SimproV2/Gantt/index.js @@ -113,6 +113,8 @@ const Gantt = (props) => { idProject={idProject} token={token} ro={ro} + role_name={role_name} + company_id={company_id} timestamp={timestamp} /> )} From 08d1994fae5f10fb6573adaa6bafde1296998e90 Mon Sep 17 00:00:00 2001 From: farhantock Date: Tue, 23 Jan 2024 17:29:54 +0700 Subject: [PATCH 13/17] update html title --- public/OSPRO.ico | Bin 0 -> 105726 bytes public/index.html | 4 ++-- src/App.js | 2 -- src/containers/DefaultLayout/DefaultLayout.js | 2 ++ src/routes.js | 2 +- src/views/Pages/Login/Login.js | 16 ++++++++++++++++ 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 public/OSPRO.ico diff --git a/public/OSPRO.ico b/public/OSPRO.ico new file mode 100644 index 0000000000000000000000000000000000000000..113520704ff10e10a1a985138d1e55e7f1e368c4 GIT binary patch literal 105726 zcmeI530zIv`~UYTDoSOZQX$jL5NSZltjN$sh793~3=N{eP!Y=9y+mamuFU0TN`^z> z8j>=V!ZDR0DJ4<#`#d?j@4m-52lx8Fe)s?Vt@HA>re{5CtGQhKMUdUbk-2bPtZxHxzLuCZE&0n{iy938-l(P3v-8Zm@{cMM(ap zRN}aG;UaG7;DLRsRc%leuB+ME_WGGh2@Ps`^vvC8v+i)aUfqZK-hFk?Z=>F%O&9YA z&2HX!r|QsUPQ8B}x~@S;$jqSQk{UmURMih$c)6MJ?v3p{<9eO1oie6dx9U&Q0vBGa z;Zga}_RRI_zf{RSyiH9dq@m%SR*h>fwA)p*I!Zk_^!f8SCr-@W{@~rqFq;lz1`X@l zbqM}Te*M0yVUz!oPaChx_qSySKVI-$++{(4%6*mToW0tdz^CFXVokAWw`$?*6G|6Y zHpnTe`^Vl^{+8DkaK1jLtlb+qZpjx{HB_x386>VL?kP^N(>paPE6yrwptIiN7GYy9 zZk(t4=IN>D#>N?MyISWC+|^_3hqyb*0nM~N9kCd*?%2!HD~?|KUW#6;+!sw3ova_O zvVUb<+i{hDc5a+kE6>v8UF{3)<_(Wr=dJ&HM{cu$o5s9K#kw(FVpg4Z8(Yb(vcGm_ zcw$Ow>eP|fYX!Kh4l=D-Y-v(6?fL|Z{()Tnfp4wiMjk$)F71xY35@LGI>TesC+!9s%Vyd)E!8tI2v^TkeV=JK=EU{^7iZj^ z=oaRgb)mSu-eIbbAyNdgF4PVenb7W*S?y1UQOSt#PqxrAD~if?co>d;<$3(FjdL> zhpWUE3*Lo|-Ztz2=U-`KL}E(pE344#;MZqI?>sfb%3fvO(v8MzKJCtXJav78z=v6? zQ9b;7hPG`p>(iL&+>$5ab_<3q>^OJ-J@uDf`yT5R*UB3vnK8pUbArT4+`D^Z8{?m2 z2BVd2nx*OEL`(`%W7*>$*GB-6PvvpG8B+4Uf-v z>N0xILw`-Zjfp7>J9wKQH2N#LA0=?PjAFzi7aks?oDcWX+%s{j~PjuGE-kpPdacSd{ye9nfa``q0R zr-an@iAv&v-BqHzS3Fg&YfLiG%BXPhuxMg zaT(d;Uw#Y?ID6D1>A*qNt0M1L-n|_sYD$VCof_pInV+b(^|#ess$2e^VK!x}`VEa7 z7l)!L&NtkKZ@nhEwz-2@>#i;L1zA4|O@3BncUZDN(&^srDcewW_4DhmW=$Sf-Cfn~ zpt}C4vr`*#$vTsr=agJLu~Zx|*FUZByw#+;_qFq)+vs^!@lf^9&U-Bm3(rq;%#m28 zb^K-GrS;kI6Q8y@6!SK4&9Yk0yjm=b>vMb268CA&j$69CuVxWp(W{A{|MBY0HKMLI zKGaOyL=qi7_+qv8b=~WmSN?RRU~=x7M6W)LHh90eJWG7c>b99Ue_v7NT&G3awTsSH znv}NcH$AP)A*ntcGQGr})vOJ4rdOICv~=*?HBUY7oBp}zc}!_ajpUEbBp)1(*4LT7 zaOwVnQI@wSPj!21oK(0`)pA9~>I)C1Ids|;RMJjt*gVp^=jC|qcRqiv7PZy?lyJw4 zdpW4ur6je6$9!YzF4&?{Jx?sDx_MCDUeWWPeb_dn{jc8fDkZ80JCBTC6Cu&7dUfiA zjCUjSA1|2~I;fh}`wQIW#L^s>WE~%s+zSU6q-Sh8Vc}X9?Nr>r@#Ry)q(1Q>-0rwr z`u0Xo0#tfGE@~v<>@_?`)=_iy_BCyITh+bjf>p$fiJtr4E(j30xjmXY%Ha6g+dZEf zoE_cb*wZ`@_sB{6Zo0NnKdMqxNxPEw)O_FUo0%^LbdT(6S{QU^n7ANee&lPz^?yxQ)upp>o#vhWnLFcZv zIONx{Y+$HM3v)ItNOdAR>=mg zE(vFAU&&RQ-eW)`=g3L-`q$o>-X=We+4iFc;?{JoJ)l!+T)Xp$_s>jmm{*cw4q3Sp z@uBXLX`QZJ>mGUUZq9j~>l<7uxfW&U-Phc>B;w?x$AOVf^AFs36on z2s_EixQrJ1J4dRFp5QR+#bdYGhi44@y?9OaaLu9{-6QAYEHA1hy#12Ur zyUPciS9$H}dAebi>(-E}9`!sv44$Nuc(8B5TAaVa##J%cKk4;XU%|04k zcU*p{N16A{*;=vhH`Fs8={LQ>!>8{xp6Z+ay2{+AOw01LMH`#d{pW9KF=2_$^3E~I z2RiqxCO%!KOUR{GuYPqI_V!_n>7kOKsY4AicIws)Oy6uU_WApVF0b~!8<8@3Nu?Q` z?VYaa53RAmHd)liH(I~%=~gkD&Re(BNzIA#9@fD&_I$YAjNb3HD}}ZCbai(7_qkPv z@6U;Qzi+Qje7e@2SLu@2j6-Mo4>OssHOSZB@=8I%t9wZa-u{)xJPyyheWcB@qh_A{ zMe!rn`fayJ>hmFIORG=4)=s<=G3w@|aKrfRMY}C6Ute(BHEzh+X3dJRQM`&OHXUBl zc6f5@Sw73N57+T%=@IaIuzFV;t3CQx@_e=>7cSc3>`>^Jv*ba)VFt^rE^mKk&|scR z&DRg=?i@KT{-x8Pt25(!r!+FYo;TmmC^@Usrpvc{_Vtc<+h}8-)zOo#d8O5{tm}KX zAR*q$#_D!K!lBffZs*(A-!gsI(ff5*%u|0A()Zp^l8vjzbd*HHuW2tgFNeE-#0|Xf zAlfym);te!lc-H$R;%0FnJvG&{j7CBmD24`OdADX3Yph9Z$)Ju&Rsq9o9m2oNFM)(u6WDv3s&kNvr!J(+Q`3`_w5eJGd`*=3;K$E|K}+BbMj}_ug!9O{ML?N6+?X&!3TS zV4T;!l`}gR<{i7#E#7%c@uVtG&(s-sFz!~$Olx~_qW*OCd7MX^)w9Qky6k&(WE z)1^B)w79y$rDx=daZ^(E8z!ax_U?W2tMf{{=hms`x$*wlh>$VCQ~LjUsP~g6$z3di zYT4g*+E%>3oymduEziU)n@cD)r&c6*PFOL zy3?yu-h1b;2;Y6-A@__OE*@NSf7bJvR~u+A9@^UY_H$>Q4O>_3dJ&eGvL@Vh-Ei;S zV;`G1EcWVZbNG2+qvfY-?M&YiKflJhwpT~`J#LwiHn8MX;q0G_eQUQKRV_z9c+~iU zwW+gC{bo6*)6yMH+dsU1W}E35OM~OsN)LtiKNzxa_~1hkoh<8&UY}5R?v0e@(OKpb za|Vx1-QdtQ*U@;yqE^FA>f0{6yLCwIX%BrDzeF$Q+v&YpS!KnEjYT%+28i6=lzQwl zH;5W@P<>V8=F?V==K_`=uVi`LXVI!N4`=#Tj&C>#16uaH;3uov@e9ZFJ)gB{Z+Q0W zYAcr%_Hnr~@cxyP&6+@3c^t$%jpbx|;rcc&_@(xZnYs zehM%BrT2q}7sguzUB3|A=CV}>-DKB{9j>Qtc5b?_F@@?`j)6P+Nr4lWXRJh*~bD4Gy=w7yB$$e@9fque0-W zvO|*-_us!!b;FrG`u30g+%}wvQjO7k79Zcjufw^5gihh{BdW&_f8!ZHUjNYDr_0l- z{obq2q*1>W_BCE$Y-Mw@;hI&KT?Q1-$ncn&tmb<3Lh{Jm0qY&S_C-zHtg-ylfQ{In zGmfT??-WunWpQbztAsn3hv#?1+sPn{TE#V&*TN)KAxHI3w%y{H(~6y+$}yb}g#qvhD8nIfs(BsCVlc z6rD8tjicmA(R|};p5aGSmz`*38#{b1H}g$Kqm7f>Yj&-3sA=y1|F7nJ7J4euM2EdHb&1V#jINTpKdiXaK;`17wOvkSIcDPuqNKx_5L_Q?$69S#xo?}br?cVa*c$O2 zFLRUU`1{(940}@=QPae(+w>)7Gq1iGy)tu2{SU3*xaZ;)G{x&sMAb-B@0l-F+I5et z=KQYj8T~c`mtFSEjq*$l{negx!*xrl%VwOq>x8#@W$q9cuyeDGbMe(}{bQ2D=Z0km zx0uuBpvTMi4{Le2CHgOVxXWl&AE&hmS=up&f`-hBYq!BHdwsQoBSubf2n!foH)vRo z$b=>BmN^XVS|#e$qfQ%C-rdaHJ7Di0clN~HdeweMlcTXC&NSMYZm3n#bikvQXHOrS zspp}uZ867xgzp%uy`NZRvsU?H9PoJxR2?E+6#3C zJ(_ac*1&tJ=XLKX7awg!o5syAY4X5;2YX`L7QB^?;s&F@N3I~DzNi$+F;`)|Dz zKJdMdbHK52w~ll&)~Rn@l3(rA!yx11zo#bnbv$-GYfAG8eX8z%5FZ&+!*YMb@&`BF z(`({5=H)t}@t?QCmqlDG8*+7rbG4cWj<(fx&i$Z1VbuHW>n0r2y==2zFWWkJp85Hv zEiKOO?{n{RUS_NCp%2YB-P(7Ti|y#wrE4|4_!l>`Ei&ids9fFenrqsm`mdIluCYAv zd-}?k%YDXPKbL=D;<}I%+P<}XYlN$p?)>DnVYz{%ubp1{{@`MrefL}W{N&v!fAzk& zTRr-())}so^S++hCc~9Kg8i_-o&fD zyEwK!e=@_ad-urmE36CSJJ$>>C>dQcGVSfe*M0qJp1V7~a^5Awq}*}$f}5TW&4nRqi=vx*{u1x9E&MpQAu4LV-W#2xGbN}y zDaTyJII!u$jt$!{JTzW?bdA34oY$o{n9;#5YQ6=IFlzRtr^2wSbJm02sk-|QxaK#; zI@oMfsLS%0LH*{qB^@|=*t=(_%Q0uSbu&h`yp#H~{ke4p=69#u)Gx;M?3&oRn?^pK z-tkJ{j>b0LTLT7OxzzGE%M*GxB5oY$VPc$f)W|lr#AMSw z^BYU96dA?L4Rx_tadiBUo*s4qg)bykSE*U|Q}@~w{iwThw$ZA#10Fd}_WqP4sd{?l z$g2BpRQL7CGTD)yqUnm8q)FoE>&_2?}t1 zm*e(ku1L&ucbL^kva!Rp#yDyQb?j0(ZNar`{pQyTuf8*VeD6Q>Yipmgd(_hI(KF5P zC6W$zExca!zS=rrkDcE97E5;=HMhh8`ihr#;**baPYei-t9c`IQ|gop+tZ$#Im~G> z@m)V3+oS`zj<@3~xth1La6RF2{qAptJ0jHeI)oJD8YWfMxp&O!9j*|n1qQW`809T) zVwP_bJ;CMW7}e2R5*>!`IzMMfLcZlZ4NI*8&FR0dc~;v#yx`r;<6eeGlZS1$6{oz7 zTjTj>z^dmF?WVe|iXGy9V&_fk2%p5l8keQ2pe!}cVHS>=c=e4!hD6s8R zdFItMR}9*Fe)Lf}wr*IIwa=^kf%&~HacAyg>bYyEnNMmZk7eFQPMhX-6<=)LUt8?g zJ@UwmXYt9Ko>*Esjo+;8&Fz}l#Qt9OWv$O&P4?3>UH$Z+p8gbNl+cFwN%z+MM?I4^98cpzn98J^bZKYv7A|JGbN(hL?b1(*U%0j2;`fGNNf zU08@Y|z!YE#Fa?+bOaZ008@Y|z!YE#Fa?+bOaZ008@Y|z!YE#Fa?+b zOaZ0rs-Xrt16L3L0;TvM91QRm#DC0(d`W$JBjnqmHm3ng zfWJ7d{8L5uj!08CZLk8GD6jqXQuuA9z;{1IwP9aXK^?xInu_Ym%ZD#b&=a_WKmjum zw*@-#>U~chv~CABgFH~CgpVjo1Y^Kg=SQ{=woR*xP;Ur03&@wUww|G!wufr6e)u%z zzY@k@rhw_Z-QNx2caZ|$If{J3ey)N#)X%e8*k%>gUfCVg=_d52EDqax;MCt}=OOBt%k%wjn}5tfUGN6T zo3B#jx05#xVIFLZzzGFDX!{Y)v$8lHFUHFH7N()4H7NWC^C8>@C?0Ct zq`I()iny&&`7!^@4`}Nye5hAAM&#c#|InPS6-t1-xp{^Bn!>)z#!)^7&@n<@{qN2D z1V7Vc+n_WwGy=IlU_NBG0e1!M_4`U&*(l!v)_~JM*>%AbVH^LJ`Nuh(&ewk^nLD|2 z!H)&?Yyh3dzjvOM*?)w;zg(w6TUGEUkexeWn&#tIFdEnby6*P{mw?btHeQVKpZGEH zA@b<@Le`c~pG4VTu7{EC4-{RGhbzOwP7-dF{7X&xh$)s-!S z{Td~{T%f7Hk~y=L^`|TiKeSFr*9rWb3&UH=>MAOOuSQ@MC{f^-+DH`E|H}UV5_)6` zpmS&{hy%+(FQ6jyCmTn(qV=BwlsSV4Aa9?ey!o>JWYe(uT|s?1Z+zGKCG6`1MfV>E zq1_<`y3(<{vTWbJmPVZo3jEQ&`YSbXyTenWFg@`cM@A6ZOY|it|;4V`&6sX+U266j|GENyFDU1^#FaEd>a*7VCW8w=(RDuGH(^Nk3V*o{`T_ILYrh)0eR2Ln-anat-uHF* zX(6j$)z8l^Xsw2~6NWov?Y|`rU%x5vNBfop2=(OSN593ltPOk(Q{a#MTFSAfd(YWG z+5H3GC)w~6>S@dR{DJdN+Aoy#kGvl-|K$4xXeRWJG+jFg=Uflt<5i+`(V=d*1gCo_|_l_VG@w1v;33aR~nSgi#&gn*PO53w`uvh z!EOa@%d1c4gaj}SXz+gIg{^e#YSW$g;fzB2!EpZ`LidVr3{yw<|-De^0tKwQ!MD|`NHhj~>Ci~pVZCx6gsr2^e)4r=giBL3a;FZCa#z(2OTJG^`9#|8y<)Q`3mhTjl@y%A8f z2DB3zw^A|>bZ_v@_kgesRN^a8*j?BuI`7c@dkSs8H~tUi-%W|`hI~I@^LOW8(e_32 zQ?cfNIK2}j-0y|)gY;bKTRzg~PrH@)8e!X{{5*VK$-J#Y*%$XfvhBl$p3f*+qoI65 zVI8CuJ@Co7ON ztpbX!{b)|UxUWZEWsn4fb0!<7`-B64?(b)Sxqy!Mik=F|Cj{L1|E8hlUKL+BscDVqQ9@yXlL+WZ&m zfYcuHn}J-w+y01aC7UHbuT`O5nK!SlaI z_IeBY{mA)WD%*cy8f|q3dEiIPeG&X9eWr)`Xb5NxUO1QE8_!4mp~7*NCiPFY0a}0R%==UpLeomX z3n;pmSF}CQ8r^nZXnFQ4uw=z8#rxhLO0VE*adhy_4R*jGM|{C_(C zIq)%6cumRsRusZs6D$XGukbzF0bO&30lC+TirS-m=&J+hT91wgbX_iQE-3E_SPQ;u zZGvwb^+aF@hzE3?si>XjC|eKYo-cWS()p)r-*18Lz3DwE35W%>22gRY$NLn9D5q=4 zZ}Ckw08@Y|z!YE#Fa?+bOaZ0< zQ-CSJ6krN41(*U%0j2;`fGNNfU08@Y|z!YE# zFa?+bOaZ0 z08@Y|z!YE#Fa`de0%h#O6krM{Rv^%(EKj{yy{uSAY)~pH`^2f21&X9;31?Hxsg`kE zc{Plrz5sRIoi|X0*cio^>nD0 z)E_<7GHIInXM_G?Jmuv`myZW&s&9qyl#iF355OIe1 zAD?a<*T3~=%G2yWrT|lbDZmt93NQtj0!#s>08@Y|z!YE#Fa?+bOaZ0M=yG>|={MmxCaKtOxAv;aoJ0PtK_!Y#1GvFZb05yfa_&EA%51xTC1)N8| zA#YD1(rRG80(2*n0DQp%7)81?3+RUjr;a3osm{0bYyuh|?H@1buytxW3RQ#gX@mz=m{aC(Wn* zo{kMf6TTkeivX_|ZC9dyI{)Y^?LXH9{g39`qY(KGfpEW=BP^HN(7y3l;9~>&c16(F zP}w?^rv3woz|Ke34rLmkKiCUC0e<|K$X3qy^U;r2;3c>YLO?CvFXF=epT>0>@N-9@ zE2uaoBR)=0UVwNN-j^^$J{>!GKeRvR2>R+Qv=zo-6CH)^M3M>w-z+w{mB{sALs||uXJ827W65G>L4u~e+klSrR+i|v|lQ<4?sRY z{%d@@vLS4G3+!n87X|$fleMQb%2mM=ft{B$|F|HJ#!l&2>L|F zrAk0J{)+P-`9+z#z&=}gzIPJj6(O!A+XrdgxdOWf=<8g-&s!nlEoAEGS8G^5u` zNS7Ca{0)3P}$<1F?cW zWmVNplimK`p}eJ(&Itb$*r)ORL0+gJpLC#or5~U=Q-Sc<{}yROs*Aq%1n&fW=Eo`< zropD-7>)Q+nL4DSte>&ehMe*9^CTOVpSRFA;rz?m2-DNZKYdWA3b+7-mA5vVu^ zQs0o)1RDYQlQ(wS2JD67;N$3PB`^Slf`ecWSO83T8`%(LwEgq~tHA+4=YP8XDZfVI z?J<7ZM;FK;0C|%@`FW4GN4kj|TdMC5#)F2ut-KKB&4C}FeIOdF10%o}$7Xr;Ssqh> zDZmt93NQtj0!#s>08@Y|z!YE#Fa?+bOaZ0_;2~C1c?E6 zw$u{8N21MjFE#N{4OByD=q%#YG(@F_5>9<#JyEIXtVAbB+)ax+o2Qe&b*sen%+oo? ziOa)(XS;qbMON@XA%4&^iY-9h{SrLQuY59-RMC+J=}8!6~7Z< z#C|6Na1_&y-!Ov9=*4&Bc=R3R^A_l=mWh+KM~vj^qnGl zN0#2Jr}v2Qd!_&RAUzV$cd6+6Gh`My;=Ph|yw_6yq1Xv`GScNB*LDkB^I`z3t;lhMvh z;0CCVMuG-uMj{1&IR1ZG+{+Dn6((mBVcbcfZi!%MkuN-q6@~GY^sZAV0nuDj(^ge_Y@A4zA0xn3) zlF*02fQ}#3FZwQ4SI{2Nv6JS9@e*keEK;JL9 z52*jKGW`!h9&Ia~03CbCru=&_2>qpL+K%WuS{(t|?E+*+j7Pg7upIDXp#BO;L|RkY z|DOeRwBLS^+EQpH(|^7VKBQxJADRC1Wqe5c0KXs692^FGnQXWjWh&Bs(HN+234pd0 z+Qx4IA5i{1ymGtG-w7X$JUUjsa)FsR6#k}W`G!A zO*Z@oX&S>cK*y*;@CIB4V?lY}d0Pt6526at1YeZ%wkV_VRt03sXP1ZYOJfiT_)EE# z?rqs}5pDmC-wA() zs{Hf6A3iMh%nQaZd<1$_&s#!wiiXwm$`|Dj(hr|#ak{!1c(F-e7fZ5OebJ}4oDgbp z)ww`KIs7KoXZz1#ptFgtHvBv+_VBQQ-+#+E`F^ydE`x5M;yo=4jr~0z2*N&00j2;` zfGJR}0M=^hxmQmx4p@Q;We~3phJjI_E)`&{m7cc^1r=-9(tI=I{Va{svlg;x@i|@o z8>6O3j{|){`7;&xtPQRL;oANmNUMV;fSyCpZ$#0$IIW@6bB91c>+XN~O&_GUfe+GW zpT`iV->jm3&~xS}AY7}ziF8Bw+X3i#&j?T#_yOt*g?50-EkF-I`EyWDY5OSeEp2PQ zRErtX^g@L7fCHdsSJCiC&sa{99eofd9)kpFx((vL0(v$>{j@EZ8Vlxw z`ZoyJ1G-ct{b>x{rO>l84QYNWLB1v8e|c8}Y1(&&fi9q8Tj1MbAya@Uz!YE#{NGXF z^LoLz{~x6Bq&vq+Adn=mJ(fpIG_XV>{RC?mKKyo1pDk&f0?QKRYZVpi6j*3s>lD1I z|BevX9&|0Z8_WUpjt5;2hSjMROV|A6?}8zu_z*zv=+yx9o)*2gLhl}>0zI%E(6ycm zxYVrPVt14$f{EZ~K-WcQ0bN6G0u8_o*rouwK8ysu;2Lm6`-4zU*IkFeG7tuifO%jG zFaXrH8K7% - + OSPRO - + import('./views/Layers/Layer')); const Layers = React.lazy(() => import('./views/Layers/Layers')); const Lembur = React.lazy(() => import('./views/Master/MasterLembur')); const MapConfig = React.lazy(() => import('./views/MapConfig')); -const Menu = React.lazy(() => import('./views/Master/MasterMenu')); +const Menu = React.lazy(() => import('./views/Master/MenuCompany')); const OfficeHours = React.lazy(() => import('./views/Master/MasterOfficeHours')); const Organization = React.lazy(() => import('./views/Master/MasterOrganization')); const PanicButton = React.lazy(() => import('./views/SimproV2/PanicButton')); diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js index 8cbdca8..47c8e9d 100644 --- a/src/views/Pages/Login/Login.js +++ b/src/views/Pages/Login/Login.js @@ -58,6 +58,21 @@ class Login extends Component { this.handleChange = this.handleChange.bind(this); this.showHide = this.showHide.bind(this); } + updatePageTitle = () => { + try { + const storedData = localStorage.getItem('configApp'); + if (storedData !== null) { + const data = JSON.parse(storedData); + const htmlTitle = data.html_title || 'OSPRO'; + console.log('htmlTitle', htmlTitle); + document.getElementById('title').innerText = htmlTitle; + } else { + document.title = 'OSPRO'; + } + } catch (error) { + document.title = 'OSPRO'; + } + } showHide(e) { e.preventDefault(); e.stopPropagation(); @@ -255,6 +270,7 @@ class Login extends Component { window.localStorage.setItem('all_project', data_user.role.all_project); window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy)); window.localStorage.setItem('configApp', JSON.stringify(data_user.configApp)); + this.updatePageTitle(); } else { // NotificationManager.error('Cek username atau password anda!', 'Gagal Login!'); NotificationManager.error(doLogin.data.message, 'Login Failed!'); From 4b22ba52c417b8acc1170ce8d7734b93687145c5 Mon Sep 17 00:00:00 2001 From: farhantock Date: Tue, 23 Jan 2024 17:30:18 +0700 Subject: [PATCH 14/17] update filter --- src/views/Dashboard/DashboardBOD.js | 91 +++++++++-------------------- 1 file changed, 28 insertions(+), 63 deletions(-) diff --git a/src/views/Dashboard/DashboardBOD.js b/src/views/Dashboard/DashboardBOD.js index 64084b4..a63d260 100644 --- a/src/views/Dashboard/DashboardBOD.js +++ b/src/views/Dashboard/DashboardBOD.js @@ -15,19 +15,19 @@ import { HealthByBudget, HealthBySchedule } from './Components'; import { Link } from 'react-router-dom'; import { Card, CardBody, CardHeader, Input } from "reactstrap"; const DashboardBOD = (props) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; - if (props && props.role_id && props.user_id) { - role_id = props.role_id; - user_id = props.user_id; - token = props.token; - isLogin = props.isLogin; - company_id = props.company_id; - all_project = props.all_project; - role_name = props.role_name; - isLogin = props.isLogin; - hierarchy = props.hierarchy; - user_name = props.user_name; - } + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + if (props && props.role_id && props.user_id) { + role_id = props.role_id; + user_id = props.user_id; + token = props.token; + isLogin = props.isLogin; + company_id = props.company_id; + all_project = props.all_project; + role_name = props.role_name; + isLogin = props.isLogin; + hierarchy = props.hierarchy; + user_name = props.user_name; + } const HEADER = { headers: { "Content-Type": "application/json", @@ -61,13 +61,6 @@ const DashboardBOD = (props) => { const [READY_TABLE_DETAIL_EXPENDITURE, SET_READY_TABLE_DETAIL_EXPENDITURE] = useState(false); const [DATA_DETAIL_EXPENDITURE, SET_DATA_DETAIL_EXPENDITURE] = useState([]); - const currentYear = new Date().getFullYear(); - const years = Array.from({ length: 6 }, (_, index) => currentYear - index); - const storedYear = localStorage.getItem('selectedYear'); - const initialYear = storedYear ? storedYear : currentYear.toString(); - - const [searchColumn, setSearchColumn] = useState(initialYear); - useEffect(() => { getCompanyCashFlow(); // expenditure getCompanyExpenditureColor(); // expenditure Color @@ -82,14 +75,13 @@ const DashboardBOD = (props) => { getProjectScheduleHealthPerDivision(); // project by schedule health per division getTotalProjectPerDivision(); // project by division getTotalProjectValuePerDivision(); // project value by division - localStorage.setItem('selectedYear', searchColumn); - }, [searchColumn]) + }, []) // project expenditure const getCompanyCashFlow = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Expenditure."; @@ -115,31 +107,31 @@ const DashboardBOD = (props) => { // Project Expenditure Color const getCompanyExpenditureColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${company_id}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${company_id}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_EXPENDITURE_COLOR(result.data.data) } const getCompanyFinancialHealthColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${company_id}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${company_id}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_FINANCIAL_HEALTH_COLOR(result.data.data) } const getCompanyScheduleHealthColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${company_id}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${company_id}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_SCHEDULE_HEALTH_COLOR(result.data.data) } const getCompanyInvoiceColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${company_id}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${company_id}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_INVOICE_COLOR(result.data.data) } const getInvoiceOutstanding = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Invoice vs Cash In."; @@ -162,7 +154,7 @@ const DashboardBOD = (props) => { } const getProjectPerScheduleHealth = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health."; @@ -186,7 +178,7 @@ const DashboardBOD = (props) => { } const getProjectPerBudgetHealth = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Budget Health."; @@ -209,7 +201,7 @@ const DashboardBOD = (props) => { } const getProjectBudgetHealthPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health per Division."; @@ -233,7 +225,7 @@ const DashboardBOD = (props) => { } const getProjectScheduleHealthPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health."; @@ -256,7 +248,7 @@ const DashboardBOD = (props) => { } const getProjectPerPhase = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Phase."; @@ -281,7 +273,7 @@ const DashboardBOD = (props) => { } const getTotalProjectPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Division."; @@ -306,7 +298,7 @@ const DashboardBOD = (props) => { } const getTotalProjectValuePerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Value by Division"; @@ -335,7 +327,7 @@ const DashboardBOD = (props) => { return; } setOpenDetailedView(true); - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${searchColumn}/${company_id}/${all_project}/${hierarchy}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${company_id}/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Detail Expenditure"; @@ -454,33 +446,6 @@ const DashboardBOD = (props) => {
{/* */} - -
-
-

Dashboard

-
-
-
-

Search by Years

-
-
- setSearchColumn(e.target.value)} - name="select" - > - {years.map((year) => ( - - ))} - -
-
- -
From 33e3e36706351ce297ce5f9afdfaeda078f12ff7 Mon Sep 17 00:00:00 2001 From: farhantock Date: Tue, 23 Jan 2024 17:30:29 +0700 Subject: [PATCH 15/17] update from adw --- src/views/Dashboard/DashboardProject.js | 218 ++++++++++++++++-------- 1 file changed, 145 insertions(+), 73 deletions(-) diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index 376bada..7ec0cbe 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -30,7 +30,9 @@ import { } from "./Components"; import { Fab, Action } from "react-tiny-fab"; import "react-tiny-fab/dist/styles.css"; -import { useHistory, useLocation, useParams } from "react-router-dom"; +import { useHistory, useParams } from "react-router-dom"; +import { Icon } from '@iconify/react'; +import arrowLeft from '@iconify/icons-ion/ios-arrow-back'; const { TextArea } = Input; @@ -64,8 +66,7 @@ const center = { }; const DashboardProject = (props) => { - - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; @@ -78,7 +79,6 @@ const DashboardProject = (props) => { hierarchy = props.hierarchy; user_name = props.user_name; } - const HEADER = { headers: { "Content-Type": "application/json", @@ -87,7 +87,7 @@ const DashboardProject = (props) => { }; const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; - // const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; + // const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; const mapRef = useRef(); const [projectName, setProjectName] = useState(""); const [projectManagerName, setProjectManagerName] = useState(""); @@ -140,6 +140,8 @@ const DashboardProject = (props) => { const [isReadyGanttParents, setIsReadyGanttParents] = useState(false); const [calculationStatus, setCalculationStatus] = useState(false); const [isHierarchy, setIsHierarchy] = useState(null); + const [dataOverdue, setDataOverdue] = useState(null); + const [projectType, setProjectType] = useState(null); let history = useHistory(); useEffect(() => { @@ -150,6 +152,7 @@ const DashboardProject = (props) => { getGantt(); getGanttParents(); return () => { + console.log("unmount RenderMap"); }; }, []); @@ -158,9 +161,10 @@ const DashboardProject = (props) => { getSCurve(); } window.addEventListener("message", handleIframeMessage); - + window.addEventListener('message', handleGetOverdue); return () => { window.removeEventListener("message", handleIframeMessage); + window.removeEventListener("message", handleGetOverdue); }; }, [isHierarchy]); @@ -183,8 +187,13 @@ const DashboardProject = (props) => { useEffect(() => { let deviation = 0; - if (plannedCost && totalCost) { - deviation = plannedCost - totalCost; + // Convert plannedCost and totalCost to numbers + const plannedCostNumber = parseFloat(plannedCost); + const totalCostNumber = parseFloat(totalCost); + + // Check if conversion is successful + if (!isNaN(plannedCostNumber) && !isNaN(totalCostNumber)) { + deviation = plannedCostNumber - totalCostNumber; } setRemToComplete(deviation.toString()); }, [plannedCost, totalCost]); @@ -199,6 +208,7 @@ const DashboardProject = (props) => { const response = await axios.get(url, HEADER); setManPower(response.data.totalRecord); } catch (error) { + console.error("Failed to get manpower:", error); } }; @@ -215,6 +225,7 @@ const DashboardProject = (props) => { } setIsReadyGantt(true); } catch (error) { + console.error("Failed to get gantt data:", error); setIsReadyGantt(true); } }; @@ -227,6 +238,7 @@ const DashboardProject = (props) => { setDataGanttParents(response); setIsReadyGanttParents(true); } catch (error) { + console.error("Failed to get gantt data:", error); setIsReadyGanttParents(true); } }; @@ -244,6 +256,7 @@ const DashboardProject = (props) => { setAssignedHrCount(assignedList.length); setAssignedHr(assignedList); } catch (error) { + console.error("Failed to get assigned HR:", error); } }; @@ -300,6 +313,7 @@ const DashboardProject = (props) => { .get(URL, HEADER) .then((res) => res) .catch((err) => err.response); + console.log("getProjectDetail", result); if (!result) { NotificationManager.error(`Could not connect to internet.`, "Failed"); setIsReadyProjectDetail(true); @@ -314,6 +328,8 @@ const DashboardProject = (props) => { setIsReadyProjectDetail(true); return; } else if (result.status == 200 && result.data.data) { + console.log(result.data.data); + // setComments(result.data.data); setProjectName(result.data.data.nama ? result.data.data.nama : "-"); setProjectManagerName( result.data.data.projectManager ? result.data.data.projectManager : "-" @@ -341,6 +357,7 @@ const DashboardProject = (props) => { ? result.data.data.header?.planned_end : null ); + setProjectType(result.data.data.type_proyek_id); setActualStart( result.data.data.header?.start_date ? result.data.data.header.start_date @@ -408,6 +425,7 @@ const DashboardProject = (props) => { let selisihProgress = 0; let planningProgress = 0; let actualProgress = 0; + console.log("test flow ", result.data.data); let statusHealthBySchedule = "on-schedule"; if ( result.data.data.length > 0 && @@ -431,21 +449,13 @@ const DashboardProject = (props) => { result.data.data[0].data.budget_control.cost_deviation?.toString() ); } - let now = new Date().toISOString().slice(0, 10); - let dates = result.data.data[0].data?.date; - let n = dates.findIndex( - (element) => new Date(now) < new Date(element[0]) - ); - if (n < 0) { - n = dates.length - 1; - } if ( result.data.data.length > 0 && result.data.data[0].data?.percentagePlan && result.data.data[0].data?.percentagePlan.length > 0 ) { - planningProgress = result.data.data[0].data?.percentagePlan[n]; - setPlanningProgress(planningProgress); + planningProgress = result.data.data[0].data?.percentagePlan[result.data.data[0].data?.percentagePlan.length - 1]; + setPlanningProgress(Math.ceil(planningProgress)); } if ( result.data.data.length > 0 && @@ -484,6 +494,7 @@ const DashboardProject = (props) => { .post(URL, payload, HEADER) .then((res) => res) .catch((err) => err.response); + console.log("getOverdueActivities", result); if (!result) { NotificationManager.error(`Could not connect to internet.`, "Failed"); setIsReadyOverdueActivities(true); @@ -520,6 +531,7 @@ const DashboardProject = (props) => { .post(URL, payload, HEADER) .then((res) => res) .catch((err) => err.response); + console.log("getIntegrationInvoice", result); if (!result) { NotificationManager.error(`Could not connect to internet.`, "Failed"); setIsReadyIntegrationInvoice(true); @@ -566,6 +578,7 @@ const DashboardProject = (props) => { .post(URL, payload, HEADER) .then((res) => res) .catch((err) => err.response); + console.log("getReportDistribution", result); if (!result) { NotificationManager.error(`Could not connect to internet.`, "Failed"); setIsReadyReportDistribution(true); @@ -618,6 +631,7 @@ const DashboardProject = (props) => { .post(URL, payload, HEADER) .then((res) => res) .catch((err) => err.response); + console.log("getComments", result); if (!result) { NotificationManager.error(`Could not connect to internet.`, "Failed"); setIsReadyComments(true); @@ -638,6 +652,7 @@ const DashboardProject = (props) => { }; const handleSendComment = async () => { + // console.log('handleSendComment', comment); setIsSendingComment(true); if (comment === "") { NotificationManager.error( @@ -684,6 +699,10 @@ const DashboardProject = (props) => { setIsSendingComment(false); }; + const handleBack = async () => { + window.parent.location.reload(); + }; + const initMap = () => { let mymap = L.map("map-area", { center: center, @@ -731,6 +750,12 @@ const DashboardProject = (props) => { } }; + const handleGetOverdue = (event) => { + if (event.data.type === 'dataOverdueUpdate') { + setDataOverdue(event.data.dataOverdue); + } + } + const RenderGantt = useMemo( () => (
{n.join_first_company_name}{n.name} {n.description}
{n.join_first_company_name}{n.name} {n.description ?? '-'}
{n.join_first_company_name}{n.name} {n.description}
{n.join_second_company_name ? n.join_second_company_name : ""}{n.join_first_name ? n.join_first_name : ""} {n.description ? n.description : "-"} {n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"}{n.join_first_company_name ? n.join_first_company_name : "-"}{n.title_notif} {n.message_notif !== "" ? n.message_notif : "-"} {n.description !== "" ? n.description : "-"}
{n.join_third_company_name ? n.join_third_company_name : "-"}{n.join_first_name ? n.join_first_name : "-"} {n.join_second_nama ? n.join_second_nama : "-"} {n.report_date ? moment(n.report_date).format("DD-MM-YYYY") : "-"}{n.join_first_company_name}{n.join_first_company_name}{n.name} {n.description}
{n.join_first_company_name}{n.join_first_company_name}{n.name} {n.description ?? '-'} {n.join_second_company_name ? n.join_second_company_name : "-"}{n.created_at !== null ? moment(n.created_at).format("DD-MM-YYYY HH:mm:ss") : "-"} {n.join_first_name !== null ? n.join_first_name : "-"} {n.status_response !== null ? n.status_response : "-"}{n.join_first_company_name}{n.join_first_company_name}{n.name} {n.description}