Browse Source

update

pull/1/head
root 11 months ago
parent
commit
59b2f3bf79
  1. BIN
      public/OSPRO.ico
  2. 4
      public/index.html
  3. 16
      src/App.js
  4. 1
      src/const/en.json
  5. 1
      src/const/id.json
  6. 19
      src/containers/DefaultLayout/DefaultHeader.js
  7. 51
      src/containers/DefaultLayout/DefaultLayout.js
  8. 10
      src/routes.js
  9. 94
      src/views/Dashboard/DashboardBOD.js
  10. 25
      src/views/Dashboard/DashboardCustomer.js
  11. 232
      src/views/Dashboard/DashboardProject.js
  12. 29
      src/views/Dashboard/DashboardProjectCarousell.js
  13. 27
      src/views/MapMonitoring/index.js
  14. 26
      src/views/Master/MasterAbsensi/index.js
  15. 110
      src/views/Master/MasterBroadcast/DialogForm.js
  16. 83
      src/views/Master/MasterBroadcast/index.js
  17. 91
      src/views/Master/MasterRoles/DialogForm.js
  18. 61
      src/views/Master/MasterRoles/DialogMenuRoles.js
  19. 140
      src/views/Master/MasterRoles/index.js
  20. 48
      src/views/Master/MenuCompany/DialogForm.js
  21. 418
      src/views/Master/MenuCompany/DialogMasterMenu.js
  22. 89
      src/views/Master/MenuCompany/index.js
  23. 27
      src/views/Master/ProjectExpenditure/index.js
  24. 27
      src/views/Master/ProjectFinancialHealth/index.js
  25. 27
      src/views/Master/ProjectInvoice/index.js
  26. 48
      src/views/Master/ProjectPhase/DialogForm.js
  27. 141
      src/views/Master/ProjectPhase/index.js
  28. 27
      src/views/Master/ProjectScheduleHealth/index.js
  29. 114
      src/views/Master/RoleProject/DialogForm.js
  30. 152
      src/views/Master/RoleProject/index.js
  31. 62
      src/views/Pages/Login/Login.js
  32. 59
      src/views/Report/k3/index.js
  33. 56
      src/views/SimproV2/ChecklistK3/DialogForm.js
  34. 116
      src/views/SimproV2/ChecklistK3/index.js
  35. 68
      src/views/SimproV2/CreatedProyek/DialogFormProyek.js
  36. 347
      src/views/SimproV2/CreatedProyek/index.js
  37. 47
      src/views/SimproV2/Divisi/DialogForm.js
  38. 161
      src/views/SimproV2/Divisi/index.js
  39. 19
      src/views/SimproV2/Gantt/GanttFrame.js
  40. 29
      src/views/SimproV2/Gantt/index.js
  41. 16
      src/views/SimproV2/PanicButton/index.js
  42. 39
      src/views/SimproV2/Presence/index.js
  43. 58
      src/views/SimproV2/ProjectType/DialogForm.js
  44. 137
      src/views/SimproV2/ProjectType/index.js
  45. 63
      src/views/SimproV2/ResourceWorker/DialogForm.js
  46. 97
      src/views/SimproV2/ResourceWorker/index.js
  47. 60
      src/views/SimproV2/Satuan/DialogForm.js
  48. 128
      src/views/SimproV2/Satuan/index.js

BIN
public/OSPRO.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

4
public/index.html

@ -8,13 +8,13 @@
<meta name="description" content="OSPRO"> <meta name="description" content="OSPRO">
<meta name="author" content="Integrasia Utama"> <meta name="author" content="Integrasia Utama">
<meta name="keyword" content="OSPRO,Integrasia,OSLOG,Asset,WebGIS,Aplikasi,Tracking System"> <meta name="keyword" content="OSPRO,Integrasia,OSLOG,Asset,WebGIS,Aplikasi,Tracking System">
<title>OSPRO</title> <title id="title">OSPRO</title>
<!-- <!--
manifest.json provides metadata used when your web app is added to the manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
--> -->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/simpro-icon.ico"> <link rel="shortcut icon" href="%PUBLIC_URL%/OSPRO.ico">
<!-- <link rel="shortcut icon" href="%PUBLIC_URL%/favicon_bmd_denpasar.ico"> --> <!-- <link rel="shortcut icon" href="%PUBLIC_URL%/favicon_bmd_denpasar.ico"> -->
<link rel="stylesheet" href="https://unpkg.com/@coreui/icons@1.0.0/css/all.min.css"> <link rel="stylesheet" href="https://unpkg.com/@coreui/icons@1.0.0/css/all.min.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"

16
src/App.js

@ -18,6 +18,22 @@ const Page500 = React.lazy(() => import('./views/Pages/Page500'));
const SiopasMap = React.lazy(() => import('./views/Map')); const SiopasMap = React.lazy(() => import('./views/Map'));
class App extends Component { 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 {
document.title = 'OSPRO';
}
} catch (error) {
document.title = 'OSPRO';
}
}
render() { render() {
return ( return (

1
src/const/en.json

@ -12,6 +12,7 @@
"birthPlace": "Birth Place", "birthPlace": "Birth Place",
"birthDate": "Birth Date", "birthDate": "Birth Date",
"ChecklistK3Add": "Add Checklist K3", "ChecklistK3Add": "Add Checklist K3",
"company": "Company Name",
"cancel": "Cancel", "cancel": "Cancel",
"close": "Close", "close": "Close",
"color": "Color", "color": "Color",

1
src/const/id.json

@ -12,6 +12,7 @@
"birthPlace": "Tempat Lahir", "birthPlace": "Tempat Lahir",
"birthDate": "Tanggal Lahir", "birthDate": "Tanggal Lahir",
"ChecklistK3Add": "Tambah Ceklis K3", "ChecklistK3Add": "Tambah Ceklis K3",
"company": "Nama Perusahaan",
"cancel": "Batal", "cancel": "Batal",
"close": "Tutup", "close": "Tutup",
"color": "Warna", "color": "Warna",

19
src/containers/DefaultLayout/DefaultHeader.js

@ -4,7 +4,8 @@ import { Badge, Nav, NavItem } from 'reactstrap';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Menu, Dropdown } from 'antd' import { Menu, Dropdown } from 'antd'
import { ALERTUSER_SEARCH, ALERT_SEARCH, ALERTUSER_STATUSVIEW, ALERT_STATUSVIEW, APP_MODE } from '../../const/ApiConst'; 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 axios from 'axios';
import './Default.css' import './Default.css'
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
@ -194,6 +195,15 @@ class DefaultHeader extends Component {
}); });
} }
getLogo = () => {
return (
<div style={{ width: '10%', display: 'flex', justifyContent: 'center' }}>
<img style={{ width: '100%', height: '100%' }} src={logo_ospro} />
</div>
)
}
getHeaderMenu = () => { getHeaderMenu = () => {
const { fullname, u_group } = this.state; const { fullname, u_group } = this.state;
if (u_group == 'kominfo') { if (u_group == 'kominfo') {
@ -244,12 +254,15 @@ class DefaultHeader extends Component {
return ( return (
<React.Fragment> <React.Fragment>
<AppSidebarToggler className="d-lg-none" display="md" mobile />
{this.getLogo()}
<AppSidebarToggler className="d-md-down-none" display="lg" />
<Nav className="ml-auto" navbar> <Nav className="ml-auto" navbar>
<Dropdown onVisibleChange={(visible) => this.onReadNotif(visible)} overlay={this.dropDownMenu} trigger={['click']}> {/* <Dropdown onVisibleChange={(visible) => this.onReadNotif(visible)} overlay={this.dropDownMenu} trigger={['click']}>
<NavItem className="d-md-down-none"> <NavItem className="d-md-down-none">
<NavLink to="#" className="nav-link"><i className="icon-bell"></i><Badge pill color={this.state.totalAlert > 0 ? "danger" : "default"}>{this.state.totalAlert > 0 ? this.state.totalAlert : null}</Badge></NavLink> <NavLink to="#" className="nav-link"><i className="icon-bell"></i><Badge pill color={this.state.totalAlert > 0 ? "danger" : "default"}>{this.state.totalAlert > 0 ? this.state.totalAlert : null}</Badge></NavLink>
</NavItem> </NavItem>
</Dropdown> </Dropdown> */}
</Nav> </Nav>
</React.Fragment> </React.Fragment>
); );

51
src/containers/DefaultLayout/DefaultLayout.js

@ -38,17 +38,33 @@ class DefaultLayout extends Component {
constructor(props) { constructor(props) {
super(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 = { this.state = {
role_id: localStorage.getItem('role_id'), role_id: role_id,
token: localStorage.getItem('token'), token: token,
menu: { items: [] }, menu: { items: [] },
routes2: routes, routes2: routes,
finalRoutes: [], finalRoutes: [],
breadrCrumbReady: false, breadrCrumbReady: false,
minimized: true minimized: true,
} company_id: company_id
};
} }
async componentDidMount() { async componentDidMount() {
const menu = localStorage.getItem("menu_login") const menu = localStorage.getItem("menu_login")
if (menu) this.setMenu(JSON.parse(menu)) if (menu) this.setMenu(JSON.parse(menu))
@ -102,6 +118,8 @@ class DefaultLayout extends Component {
e.preventDefault() e.preventDefault()
} }
await localStorage.removeItem("role_id"); await localStorage.removeItem("role_id");
await localStorage.removeItem("company_id");
document.getElementById('title').innerText = 'OSPRO';
await window.localStorage.clear(); await window.localStorage.clear();
this.props.history.replace('/login') this.props.history.replace('/login')
} }
@ -251,15 +269,13 @@ class DefaultLayout extends Component {
return ( return (
<div className="app"> <div className="app">
<AppHeader fixed>
<DefaultHeader />
</AppHeader>
<div className="app-body"> <div className="app-body">
{!window.location.href.includes("dashboard-project") || renderSidebar ? ( {!window.location.href.includes("dashboard-project") || renderSidebar ? (
<AppSidebar minimized={this.state.minimized} fixed display="lg"> <AppSidebar minimized={this.state.minimized} fixed display="lg">
{/* <div class="sidebar-header">
<Suspense fallback={this.loading()}>
<DefaultHeader history={this.props.history} onLogout={e => this.signOut(e)} />
</Suspense>
</div> */}
<hr />
<AppSidebarHeader /> <AppSidebarHeader />
<AppSidebarForm /> <AppSidebarForm />
<Suspense> <Suspense>
@ -295,7 +311,20 @@ class DefaultLayout extends Component {
exact={route.exact} exact={route.exact}
name={route.name} name={route.name}
render={props => ( render={props => (
<route.component params={{ name: route.name }} {...props} /> <route.component
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); ) : (null);
})} })}

10
src/routes.js

@ -22,7 +22,7 @@ const Layer = React.lazy(() => import('./views/Layers/Layer'));
const Layers = React.lazy(() => import('./views/Layers/Layers')); const Layers = React.lazy(() => import('./views/Layers/Layers'));
const Lembur = React.lazy(() => import('./views/Master/MasterLembur')); const Lembur = React.lazy(() => import('./views/Master/MasterLembur'));
const MapConfig = React.lazy(() => import('./views/MapConfig')); 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 OfficeHours = React.lazy(() => import('./views/Master/MasterOfficeHours'));
const Organization = React.lazy(() => import('./views/Master/MasterOrganization')); const Organization = React.lazy(() => import('./views/Master/MasterOrganization'));
const PanicButton = React.lazy(() => import('./views/SimproV2/PanicButton')); const PanicButton = React.lazy(() => import('./views/SimproV2/PanicButton'));
@ -31,6 +31,10 @@ const Presensi = React.lazy(() => import('./views/SimproV2/Presence'));
const ProjectRole = React.lazy(() => import('./views/Master/RoleProject')); const ProjectRole = React.lazy(() => import('./views/Master/RoleProject'));
const ProjectType = React.lazy(() => import('./views/SimproV2/ProjectType')); const ProjectType = React.lazy(() => import('./views/SimproV2/ProjectType'));
const ProjectPhase = React.lazy(() => import('./views/Master/ProjectPhase')); 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 Proyek = React.lazy(() => import('./views/Master/Proyek'));
const RateCost = React.lazy(() => import('./views/SimproV2/RateCost')); const RateCost = React.lazy(() => import('./views/SimproV2/RateCost'));
const ResourceMaterial = React.lazy(() => import('./views/SimproV2/ResourceMaterial')); 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-role', exact: true, name: 'Project Role', component: ProjectRole },
{ path: '/project-type', exact: true, name: 'Project Type', component: ProjectType }, { path: '/project-type', exact: true, name: 'Project Type', component: ProjectType },
{ path: '/project-phase', exact: true, name: 'Project Phase', component: ProjectPhase }, { 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: '/divisi', exact: true, name: 'Divisi', component: Divisi },
{ path: '/satuan', exact: true, name: 'Satuan', component: Satuan }, { path: '/satuan', exact: true, name: 'Satuan', component: Satuan },
{ path: '/config-alert', exact: true, name: 'Config Alert', component: ConfigAlert }, { path: '/config-alert', exact: true, name: 'Config Alert', component: ConfigAlert },

94
src/views/Dashboard/DashboardBOD.js

@ -15,24 +15,19 @@ import { HealthByBudget, HealthBySchedule } from './Components';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Card, CardBody, CardHeader, Input } from "reactstrap"; import { Card, CardBody, CardHeader, Input } from "reactstrap";
const DashboardBOD = (props) => { const DashboardBOD = (props) => {
let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
company_id = props.location.state.company_id; company_id = props.company_id;
all_project = props.location.state.all_project; all_project = props.all_project;
} else { role_name = props.role_name;
role_id = localStorage.getItem("role_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
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")));
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -66,13 +61,6 @@ const DashboardBOD = (props) => {
const [READY_TABLE_DETAIL_EXPENDITURE, SET_READY_TABLE_DETAIL_EXPENDITURE] = useState(false); const [READY_TABLE_DETAIL_EXPENDITURE, SET_READY_TABLE_DETAIL_EXPENDITURE] = useState(false);
const [DATA_DETAIL_EXPENDITURE, SET_DATA_DETAIL_EXPENDITURE] = useState([]); 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(() => { useEffect(() => {
getCompanyCashFlow(); // expenditure getCompanyCashFlow(); // expenditure
getCompanyExpenditureColor(); // expenditure Color getCompanyExpenditureColor(); // expenditure Color
@ -87,14 +75,13 @@ const DashboardBOD = (props) => {
getProjectScheduleHealthPerDivision(); // project by schedule health per division getProjectScheduleHealthPerDivision(); // project by schedule health per division
getTotalProjectPerDivision(); // project by division getTotalProjectPerDivision(); // project by division
getTotalProjectValuePerDivision(); // project value by division getTotalProjectValuePerDivision(); // project value by division
localStorage.setItem('selectedYear', searchColumn); }, [])
}, [searchColumn])
// project expenditure // project expenditure
const getCompanyCashFlow = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Expenditure."; const content = "Get Project Expenditure.";
@ -120,31 +107,31 @@ const DashboardBOD = (props) => {
// Project Expenditure Color // Project Expenditure Color
const getCompanyExpenditureColor = async () => { 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) const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_EXPENDITURE_COLOR(result.data.data) SET_PROJECT_EXPENDITURE_COLOR(result.data.data)
} }
const getCompanyFinancialHealthColor = async () => { 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) const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_FINANCIAL_HEALTH_COLOR(result.data.data) SET_PROJECT_FINANCIAL_HEALTH_COLOR(result.data.data)
} }
const getCompanyScheduleHealthColor = async () => { 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) const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_SCHEDULE_HEALTH_COLOR(result.data.data) SET_PROJECT_SCHEDULE_HEALTH_COLOR(result.data.data)
} }
const getCompanyInvoiceColor = async () => { 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) const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_INVOICE_COLOR(result.data.data) SET_PROJECT_INVOICE_COLOR(result.data.data)
} }
const getInvoiceOutstanding = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Invoice vs Cash In."; const content = "Get Project Invoice vs Cash In.";
@ -167,7 +154,7 @@ const DashboardBOD = (props) => {
} }
const getProjectPerScheduleHealth = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health."; const content = "Get Project by Schedule Health.";
@ -191,7 +178,7 @@ const DashboardBOD = (props) => {
} }
const getProjectPerBudgetHealth = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Budget Health."; const content = "Get Project by Budget Health.";
@ -214,7 +201,7 @@ const DashboardBOD = (props) => {
} }
const getProjectBudgetHealthPerDivision = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health per Division."; const content = "Get Project by Schedule Health per Division.";
@ -238,7 +225,7 @@ const DashboardBOD = (props) => {
} }
const getProjectScheduleHealthPerDivision = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health."; const content = "Get Project by Schedule Health.";
@ -261,7 +248,7 @@ const DashboardBOD = (props) => {
} }
const getProjectPerPhase = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Phase."; const content = "Get Project by Phase.";
@ -286,7 +273,7 @@ const DashboardBOD = (props) => {
} }
const getTotalProjectPerDivision = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Division."; const content = "Get Project by Division.";
@ -311,7 +298,7 @@ const DashboardBOD = (props) => {
} }
const getTotalProjectValuePerDivision = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Value by Division"; const content = "Get Project Value by Division";
@ -340,7 +327,7 @@ const DashboardBOD = (props) => {
return; return;
} }
setOpenDetailedView(true); 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Detail Expenditure"; const content = "Get Detail Expenditure";
@ -459,33 +446,6 @@ const DashboardBOD = (props) => {
<div style={{ marginLeft: -25, marginRight: -25 }}> <div style={{ marginLeft: -25, marginRight: -25 }}>
{/* <FloatingFilter /> */} {/* <FloatingFilter /> */}
<NotificationContainer /> <NotificationContainer />
<Row>
<Col span={24} style={{ backgroundColor: '#fff', height: '8vh', display: 'flex', justifyContent: 'space-between' }}>
<div style={{ marginTop: '7px', marginLeft: '10px' }}>
<h4>Dashboard</h4>
</div>
<div style={{ display: 'flex', marginRight: '15px' }}>
<div style={{ marginTop: '11px', marginRight: '5px' }}>
<p>Search by Years</p>
</div>
<div>
<Input
type="select"
value={searchColumn}
style={{ width: '100px', marginTop: '7px', cursor: 'pointer' }}
onChange={(e) => setSearchColumn(e.target.value)}
name="select"
>
{years.map((year) => (
<option key={year} value={year.toString()}>
{year}
</option>
))}
</Input>
</div>
</div>
</Col>
</Row>
<Row> <Row>
<Col span={12}> <Col span={12}>
<Row> <Row>

25
src/views/Dashboard/DashboardCustomer.js

@ -26,18 +26,19 @@ const center = {
} }
const DashboardCustomer = (props) => { const DashboardCustomer = (props) => {
let role_id = '', user_id = '', isLogin = '', token = ''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
} else { company_id = props.company_id;
role_id = localStorage.getItem("role_id"); all_project = props.all_project;
user_id = localStorage.getItem("user_id"); role_name = props.role_name;
token = localStorage.getItem("token"); isLogin = props.isLogin;
isLogin = localStorage.getItem("isLogin"); hierarchy = props.hierarchy;
} user_name = props.user_name;
}
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",

232
src/views/Dashboard/DashboardProject.js

@ -30,7 +30,9 @@ import {
} from "./Components"; } from "./Components";
import { Fab, Action } from "react-tiny-fab"; import { Fab, Action } from "react-tiny-fab";
import "react-tiny-fab/dist/styles.css"; 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; const { TextArea } = Input;
@ -63,8 +65,20 @@ const center = {
lng: 106.816666, lng: 106.816666,
}; };
const DashboardProject = () => { const DashboardProject = (props) => {
const token = localStorage.getItem("token"); 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 = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -72,7 +86,9 @@ const DashboardProject = () => {
}, },
}; };
const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); 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 mapRef = useRef();
const [projectName, setProjectName] = useState(""); const [projectName, setProjectName] = useState("");
const [projectManagerName, setProjectManagerName] = useState(""); const [projectManagerName, setProjectManagerName] = useState("");
@ -125,6 +141,8 @@ const DashboardProject = () => {
const [isReadyGanttParents, setIsReadyGanttParents] = useState(false); const [isReadyGanttParents, setIsReadyGanttParents] = useState(false);
const [calculationStatus, setCalculationStatus] = useState(false); const [calculationStatus, setCalculationStatus] = useState(false);
const [isHierarchy, setIsHierarchy] = useState(null); const [isHierarchy, setIsHierarchy] = useState(null);
const [dataOverdue, setDataOverdue] = useState(null);
const [projectType, setProjectType] = useState(null);
let history = useHistory(); let history = useHistory();
useEffect(() => { useEffect(() => {
@ -135,6 +153,7 @@ const DashboardProject = () => {
getGantt(); getGantt();
getGanttParents(); getGanttParents();
return () => { return () => {
console.log("unmount RenderMap");
}; };
}, []); }, []);
@ -143,9 +162,10 @@ const DashboardProject = () => {
getSCurve(); getSCurve();
} }
window.addEventListener("message", handleIframeMessage); window.addEventListener("message", handleIframeMessage);
window.addEventListener('message', handleGetOverdue);
return () => { return () => {
window.removeEventListener("message", handleIframeMessage); window.removeEventListener("message", handleIframeMessage);
window.removeEventListener("message", handleGetOverdue);
}; };
}, [isHierarchy]); }, [isHierarchy]);
@ -168,8 +188,13 @@ const DashboardProject = () => {
useEffect(() => { useEffect(() => {
let deviation = 0; let deviation = 0;
if (plannedCost && totalCost) { // Convert plannedCost and totalCost to numbers
deviation = plannedCost - totalCost; const plannedCostNumber = parseFloat(plannedCost);
const totalCostNumber = parseFloat(totalCost);
// Check if conversion is successful
if (!isNaN(plannedCostNumber) && !isNaN(totalCostNumber)) {
deviation = plannedCostNumber - totalCostNumber;
} }
setRemToComplete(deviation.toString()); setRemToComplete(deviation.toString());
}, [plannedCost, totalCost]); }, [plannedCost, totalCost]);
@ -184,6 +209,7 @@ const DashboardProject = () => {
const response = await axios.get(url, HEADER); const response = await axios.get(url, HEADER);
setManPower(response.data.totalRecord); setManPower(response.data.totalRecord);
} catch (error) { } catch (error) {
console.error("Failed to get manpower:", error);
} }
}; };
@ -200,6 +226,7 @@ const DashboardProject = () => {
} }
setIsReadyGantt(true); setIsReadyGantt(true);
} catch (error) { } catch (error) {
console.error("Failed to get gantt data:", error);
setIsReadyGantt(true); setIsReadyGantt(true);
} }
}; };
@ -212,6 +239,7 @@ const DashboardProject = () => {
setDataGanttParents(response); setDataGanttParents(response);
setIsReadyGanttParents(true); setIsReadyGanttParents(true);
} catch (error) { } catch (error) {
console.error("Failed to get gantt data:", error);
setIsReadyGanttParents(true); setIsReadyGanttParents(true);
} }
}; };
@ -229,6 +257,7 @@ const DashboardProject = () => {
setAssignedHrCount(assignedList.length); setAssignedHrCount(assignedList.length);
setAssignedHr(assignedList); setAssignedHr(assignedList);
} catch (error) { } catch (error) {
console.error("Failed to get assigned HR:", error);
} }
}; };
@ -285,6 +314,7 @@ const DashboardProject = () => {
.get(URL, HEADER) .get(URL, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log("getProjectDetail", result);
if (!result) { if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed"); NotificationManager.error(`Could not connect to internet.`, "Failed");
setIsReadyProjectDetail(true); setIsReadyProjectDetail(true);
@ -299,6 +329,8 @@ const DashboardProject = () => {
setIsReadyProjectDetail(true); setIsReadyProjectDetail(true);
return; return;
} else if (result.status == 200 && result.data.data) { } 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 : "-"); setProjectName(result.data.data.nama ? result.data.data.nama : "-");
setProjectManagerName( setProjectManagerName(
result.data.data.projectManager ? result.data.data.projectManager : "-" result.data.data.projectManager ? result.data.data.projectManager : "-"
@ -326,6 +358,7 @@ const DashboardProject = () => {
? result.data.data.header?.planned_end ? result.data.data.header?.planned_end
: null : null
); );
setProjectType(result.data.data.type_proyek_id);
setActualStart( setActualStart(
result.data.data.header?.start_date result.data.data.header?.start_date
? result.data.data.header.start_date ? result.data.data.header.start_date
@ -393,6 +426,7 @@ const DashboardProject = () => {
let selisihProgress = 0; let selisihProgress = 0;
let planningProgress = 0; let planningProgress = 0;
let actualProgress = 0; let actualProgress = 0;
console.log("test flow ", result.data.data);
let statusHealthBySchedule = "on-schedule"; let statusHealthBySchedule = "on-schedule";
if ( if (
result.data.data.length > 0 && result.data.data.length > 0 &&
@ -416,21 +450,13 @@ const DashboardProject = () => {
result.data.data[0].data.budget_control.cost_deviation?.toString() 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 ( if (
result.data.data.length > 0 && result.data.data.length > 0 &&
result.data.data[0].data?.percentagePlan && result.data.data[0].data?.percentagePlan &&
result.data.data[0].data?.percentagePlan.length > 0 result.data.data[0].data?.percentagePlan.length > 0
) { ) {
planningProgress = result.data.data[0].data?.percentagePlan[n]; planningProgress = result.data.data[0].data?.percentagePlan[result.data.data[0].data?.percentagePlan.length - 1];
setPlanningProgress(planningProgress); setPlanningProgress(Math.ceil(planningProgress));
} }
if ( if (
result.data.data.length > 0 && result.data.data.length > 0 &&
@ -469,6 +495,7 @@ const DashboardProject = () => {
.post(URL, payload, HEADER) .post(URL, payload, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log("getOverdueActivities", result);
if (!result) { if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed"); NotificationManager.error(`Could not connect to internet.`, "Failed");
setIsReadyOverdueActivities(true); setIsReadyOverdueActivities(true);
@ -505,6 +532,7 @@ const DashboardProject = () => {
.post(URL, payload, HEADER) .post(URL, payload, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log("getIntegrationInvoice", result);
if (!result) { if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed"); NotificationManager.error(`Could not connect to internet.`, "Failed");
setIsReadyIntegrationInvoice(true); setIsReadyIntegrationInvoice(true);
@ -551,6 +579,7 @@ const DashboardProject = () => {
.post(URL, payload, HEADER) .post(URL, payload, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log("getReportDistribution", result);
if (!result) { if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed"); NotificationManager.error(`Could not connect to internet.`, "Failed");
setIsReadyReportDistribution(true); setIsReadyReportDistribution(true);
@ -603,6 +632,7 @@ const DashboardProject = () => {
.post(URL, payload, HEADER) .post(URL, payload, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
console.log("getComments", result);
if (!result) { if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed"); NotificationManager.error(`Could not connect to internet.`, "Failed");
setIsReadyComments(true); setIsReadyComments(true);
@ -623,6 +653,7 @@ const DashboardProject = () => {
}; };
const handleSendComment = async () => { const handleSendComment = async () => {
// console.log('handleSendComment', comment);
setIsSendingComment(true); setIsSendingComment(true);
if (comment === "") { if (comment === "") {
NotificationManager.error( NotificationManager.error(
@ -669,6 +700,10 @@ const DashboardProject = () => {
setIsSendingComment(false); setIsSendingComment(false);
}; };
const handleBack = async () => {
window.parent.location.reload();
};
const initMap = () => { const initMap = () => {
let mymap = L.map("map-area", { let mymap = L.map("map-area", {
center: center, center: center,
@ -716,6 +751,12 @@ const DashboardProject = () => {
} }
}; };
const handleGetOverdue = (event) => {
if (event.data.type === 'dataOverdueUpdate') {
setDataOverdue(event.data.dataOverdue);
}
}
const RenderGantt = useMemo( const RenderGantt = useMemo(
() => ( () => (
<iframe <iframe
@ -789,53 +830,82 @@ const DashboardProject = () => {
}, [comment, comments, isSendingComment, isReadyComments]); }, [comment, comments, isSendingComment, isReadyComments]);
const RenderBehindTasks = useMemo(() => { const RenderBehindTasks = useMemo(() => {
return ( return SCURVE ?
<div> (
{!isReadyOverdueActivities && <ListLoader />} <div>
{isReadyOverdueActivities && {!isReadyOverdueActivities && <ListLoader />}
overdueActivities && {isReadyOverdueActivities &&
overdueActivities.length < 1 && ( overdueActivities &&
<div overdueActivities.length < 1 && (
style={{ <div
flex: 1, style={{
textAlign: "center", flex: 1,
color: "#E80053", textAlign: "center",
marginTop: 50, color: "#E80053",
marginBottom: 50, marginTop: 50,
}} marginBottom: 50,
> }}
No overdue activity found. >
</div> No overdue activity found.
)} </div>
{isReadyOverdueActivities && )}
overdueActivities && {isReadyOverdueActivities &&
overdueActivities.length > 0 && overdueActivities &&
overdueActivities.map((item, idx) => { overdueActivities.length > 0 &&
let end_date; overdueActivities.map((item, idx) => {
let planned_end; let end_date;
let diffDays = 0; let planned_end;
let message = ""; let diffDays = 0;
if (item.end_date && item.end_date !== null) { let message = "";
end_date = moment(item.end_date); if (item.end_date && item.end_date !== null) {
planned_end = moment(item.planned_end); end_date = moment(item.end_date);
diffDays = end_date.diff(planned_end, "days"); planned_end = moment(item.planned_end);
if (isNaN(diffDays)) { diffDays = end_date.diff(planned_end, "days");
return null; if (isNaN(diffDays)) {
} else {
if (diffDays > 0) {
message = `Overdue by ${diffDays + 1} days`;
} else {
return null; return null;
} else {
if (diffDays > 0) {
message = `Overdue by ${diffDays + 1} days`;
} else {
return null;
}
} }
} }
} return (
return ( <BehindTaskItem key={idx} name={item.name + ' - ' + item.name_version} message={message} scurve={SCURVE} proyek_id={PROJECT_ID} gantt_id={item.version_gantt_id} />
<BehindTaskItem key={idx} name={item.name} message={message} /> );
); })}
})} </div>
</div> )
); :
}, [overdueActivities, isReadyOverdueActivities]); (
<div>
{!dataOverdue && <ListLoader />}
{dataOverdue &&
dataOverdue.length < 1 && (
<div
style={{
flex: 1,
textAlign: "center",
color: "#E80053",
marginTop: 50,
marginBottom: 50,
}}
>
No overdue activity found.
</div>
)}
{dataOverdue &&
dataOverdue.length > 0 &&
dataOverdue.map((item, idx) => {
let message = `Overdue by ${item.overdue} days`;
return (
<BehindTaskItem key={idx} name={item.text} message={message} />
);
})}
</div>
);
}, [dataOverdue, isReadyOverdueActivities, overdueActivities]);
return ( return (
<div style={{ marginLeft: -25, marginRight: -25 }}> <div style={{ marginLeft: -25, marginRight: -25 }}>
@ -843,7 +913,23 @@ const DashboardProject = () => {
<Row> <Row>
<Col span={18}> <Col span={18}>
<Row> <Row>
<Col span={8}> {
!SCURVE ?
<Col span={2}>
<Button
style={{
height: "100%",
width: "100%",
fontSize: "18px"
}}
onClick={handleBack}
type="primary"
>
<Icon icon={arrowLeft} style={{ fontSize: "20px" }} /> Back
</Button>
</Col> : null
}
<Col span={!SCURVE ? 6 : 8}>
<div <div
style={{ style={{
border: "solid", border: "solid",
@ -1011,7 +1097,7 @@ const DashboardProject = () => {
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col span={SCURVE ? 8 : 10}> <Col span={SCURVE ? 8 : projectType != 9 ? 8 : 10}>
<div <div
style={{ style={{
border: "solid", border: "solid",
@ -1136,7 +1222,7 @@ const DashboardProject = () => {
</div> </div>
</div> </div>
</Col> </Col>
{SCURVE ? ( {SCURVE || projectType != 9 ? (
<Col span={16}> <Col span={16}>
<div <div
style={{ style={{
@ -1275,15 +1361,17 @@ const DashboardProject = () => {
BCWP (cost vs perform) BCWP (cost vs perform)
</Col> </Col>
<Col span={5} style={{ fontSize: 11 }}> <Col span={5} style={{ fontSize: 11 }}>
{isReadySCurve ? ( {isReadySCurve ?
bcwp ? ( (
renderFormatRupiah(bcwp, "Rp.") planningProgress > 100 || actualProgress > 100
) : ( ?
"-" renderFormatRupiah(((parseInt(plannedCost) * parseFloat((actualProgress / planningProgress) * 100).toFixed(0)) / 100).toString(), "Rp.")
:
renderFormatRupiah(((parseInt(plannedCost) * parseInt(actualProgress)) / 100).toString(), "Rp.")
) )
) : ( : (
<SingleTextLoader width={100} height={10} /> "-"
)} )}
</Col> </Col>
<Col <Col
span={7} span={7}

29
src/views/Dashboard/DashboardProjectCarousell.js

@ -69,16 +69,21 @@ const center = {
lng: 106.816666, lng: 106.816666,
}; };
const DashboardProject = (args) => { const DashboardProject = ({args,...props}) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, all_project = '', hierarchy = []; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
role_id = localStorage.getItem("role_id"); if (props && props.role_id && props.user_id) {
proyek_id = localStorage.getItem("proyek_id"); role_id = props.role_id;
user_id = localStorage.getItem("user_id"); user_id = props.user_id;
token = localStorage.getItem("token"); token = props.token;
isLogin = localStorage.getItem("isLogin"); isLogin = props.isLogin;
company_id = localStorage.getItem('company_id'); company_id = props.company_id;
all_project = localStorage.getItem('all_project'); all_project = props.all_project;
hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -804,10 +809,10 @@ const DashboardProject = (args) => {
> >
{slides} {slides}
<div style={{ position: 'absolute', top: '95%', left: 0, zIndex: 1000 }}> <div style={{ position: 'absolute', top: '95%', left: 0, zIndex: 1000 }}>
<Button onClick={previous}><i class="fa fa-chevron-left"></i></Button> <Button onClick={previous}><i className="fa fa-chevron-left"></i></Button>
</div> </div>
<div style={{ position: 'absolute', top: '95%', right: 0, zIndex: 1000 }}> <div style={{ position: 'absolute', top: '95%', right: 0, zIndex: 1000 }}>
<Button onClick={next}><i class="fa fa-chevron-right"></i></Button> <Button onClick={next}><i className="fa fa-chevron-right"></i></Button>
</div> </div>
</Carousel > </Carousel >
</Spin> </Spin>

27
src/views/MapMonitoring/index.js

@ -28,20 +28,19 @@ import 'leaflet-control-geocoder/dist/Control.Geocoder.js'
import moment from 'moment'; import moment from 'moment';
import axios from "../../const/interceptorApi"; import axios from "../../const/interceptorApi";
const MapMonitoring = ({ ...props }) => { const MapMonitoring = ({ ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = ''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin"); }
}
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",

26
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, currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null,
allUserToProyek: [], allUserToProyek: [],
allDataProyek: [], 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 "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 const result = await axios
@ -448,6 +463,9 @@ class index extends Component {
Edit Edit
</Tooltip> </Tooltip>
</td> */} </td> */}
{this.state.role_name === 'Super Admin' &&
<td>{n.join_second_company_name ? n.join_second_company_name : ""}</td>
}
<td>{n.join_first_name ? n.join_first_name : ""}</td> <td>{n.join_first_name ? n.join_first_name : ""}</td>
<td>{n.description ? n.description : "-"}</td> <td>{n.description ? n.description : "-"}</td>
<td>{n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"}</td> <td>{n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"}</td>
@ -494,10 +512,12 @@ class index extends Component {
render() { render() {
const t = this.props; const t = this.props;
const column = [ const column = [
this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null,
{ name: this.props.t('nameHR') }, { name: this.props.t('nameHR') },
{ name: this.props.t('description') }, { name: this.props.t('description') },
{ name: this.props.t('dateAbsent') }, { name: this.props.t('dateAbsent') },
] ].filter(column => column && column.name);
const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state
return ( return (
<div> <div>

110
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 { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import Select from 'react-select'; import Select from 'react-select';
import axios from 'axios'; 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 { Transfer } from 'antd';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
@ -51,13 +51,18 @@ class DialogForm extends Component {
allEmployeeId: [], allEmployeeId: [],
idEmployeeDivision: [], idEmployeeDivision: [],
idOrganization: [], idOrganization: [],
disableTransfer: true disableTransfer: true,
listCompany: [],
company_id: this.props.company_id,
role_name: ''
} }
} }
async componentDidMount() { async componentDidMount() {
this.getDataUsers(); if (this.props.company_id !== null) {
this.getDataRole(); this.getDataRole();
this.getDataUsers();
}
this.props.showDialog(this.showDialog); this.props.showDialog(this.showDialog);
} }
@ -69,14 +74,16 @@ class DialogForm extends Component {
id: dataEdit.id, id: dataEdit.id,
title: dataEdit.title_notif, title: dataEdit.title_notif,
description: dataEdit.description, description: dataEdit.description,
message: dataEdit.message_notif message: dataEdit.message_notif,
company_id: dataEdit.company_id
}) })
} else { } else {
this.setState({ this.setState({
id: 0, id: 0,
title: "", title: "",
description: "", description: "",
message: "" message: "",
company_id: 0
}) })
} }
this.setState({ isParentClick: false }); this.setState({ isParentClick: false });
@ -128,9 +135,12 @@ class DialogForm extends Component {
title, title,
description, description,
message, message,
penerima penerima,
} = this.state
} = this.state
let {
company_id
} = this.state
let idSend = []; let idSend = [];
let send_to_type = "all"; let send_to_type = "all";
if (penerima === "all") { if (penerima === "all") {
@ -151,15 +161,17 @@ class DialogForm extends Component {
} else { } else {
idSend = idSend; idSend = idSend;
} }
if (this.props.role_name !== 'Super Admin') {
company_id = parseInt(this.props.company_id)
}
const data = { const data = {
title, title,
description, description,
message, message,
send_to_type, send_to_type,
id: idSend id: idSend,
company_id: company_id
} }
if (param === 'registered' || param === 'send') { if (param === 'registered' || param === 'send') {
this.props.handleSaveBroadcast(param, data) this.props.handleSaveBroadcast(param, data)
} }
@ -201,7 +213,18 @@ class DialogForm extends Component {
getDataRole = async () => { getDataRole = async () => {
const payload = { 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 } "orders": { "columns": ["id"], "ascending": false }
} }
@ -231,20 +254,11 @@ class DialogForm extends Component {
} }
getDataUsers = async () => { getDataUsers = async () => {
const payload = { const payload = {
"paging": { "paging": {
"start": 0, "start": 0,
"length": 10 "length": -1
}, },
"filter_columns": [
{
"name": "name",
"value": "",
"table_name": "m_users"
}
],
"columns": [ "columns": [
{ {
"name": "name", "name": "name",
@ -254,34 +268,10 @@ class DialogForm extends Component {
"table_name": "m_users" "table_name": "m_users"
}, },
{ {
"name": "id", "name": "company_id",
"logic_operator": "=", "logic_operator": "=",
"value": "3", "value": this.state.company_id,
"operator": "AND", "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"
]
} }
], ],
"orders": { "orders": {
@ -293,7 +283,7 @@ class DialogForm extends Component {
} }
//TODO should use search instead //TODO should use search instead
const result = await axios const result = await axios
.get(USER_LIST, config) .post(USER_SEARCH, payload, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .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 = () => { renderForm = () => {
const t = this.props const t = this.props
const { errorTitle, errorMessage } = this.state const { errorTitle, errorMessage } = this.state
return ( return (
<Form> <Form>
{this.props.role_name === 'Super Admin' && (
<FormGroup>
<Label>{this.props.t('company')}</Label>
<Select
options={this.props.listCompany.map(company => ({ value: company.id, label: company.company_name }))}
onChange={this.handleSelectCompany}
value={this.state.company_id}
/>
</FormGroup>
)}
<FormGroup> <FormGroup>
<Label>{this.props.t('receiver')}</Label> <Label>{this.props.t('receiver')}</Label>
<Input type="select" value={this.state.penerima} onChange={(e) => this.handleChangePenerima(e.target.value)}> <Input type="select" value={this.state.penerima} onChange={(e) => this.handleChangePenerima(e.target.value)}>
@ -395,7 +403,7 @@ class DialogForm extends Component {
<Label>{this.props.t('broadcastDescription')}</Label> <Label>{this.props.t('broadcastDescription')}</Label>
<Input style={{ minHeight: "100px" }} type="textarea" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> <Input style={{ minHeight: "100px" }} type="textarea" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} />
</FormGroup> </FormGroup>
</Form> </Form >
) )
} }
handleCloseDialog = () => { handleCloseDialog = () => {

83
src/views/Master/MasterBroadcast/index.js

@ -5,7 +5,7 @@ import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios'; import axios from 'axios';
import moment from 'moment'; 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 { Button, Card, CardBody, CardHeader, DropdownItem, DropdownMenu, DropdownToggle, Input, InputGroup, InputGroupButtonDropdown, Table, Row, Col } from 'reactstrap';
import { DatePicker, Pagination } from 'antd'; import { DatePicker, Pagination } from 'antd';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
@ -66,6 +66,9 @@ class index extends Component {
totalPage: 0, totalPage: 0,
typeClock: "All", typeClock: "All",
typeDialog: 'Save', 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() 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 const result = await axios
.get(ROLE_LIST, config) .get(COMPANY_MANAGEMENT_LIST, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.status == 200) { if (result && result.data && result.data.code == 200) {
this.setState({ dataRoles: result.data.data }); this.setState({ listCompany: result.data.data })
} }
} }
handleSearch = e => {
const value = e.target.value
this.setState({ search: value, currentPage: 1 })
};
getDataBroadcast = async () => { getDataBroadcast = async () => {
let url = BASE_SIMPRO_LUMEN + `/broadcast/search`; let url = BASE_SIMPRO_LUMEN + `/broadcast/search`;
@ -141,8 +124,9 @@ class index extends Component {
"name": searchDetailField, "name": searchDetailField,
"operator": "AND", "operator": "AND",
"value": search "value": search
} },
], ],
"joins": [],
"orders": { "orders": {
"ascending": false, "ascending": false,
"columns": [ "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 const result = await axios
@ -165,8 +164,7 @@ class index extends Component {
if (result && result.data) { if (result && result.data) {
if (result.data.code === 200) { if (result.data.code === 200) {
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord }); this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord });
this.getDataUsers() this.getDataCompany()
this.getDataRoles()
} else { } else {
NotificationManager.error('Failed retreiving data!!', 'Failed'); NotificationManager.error('Failed retreiving data!!', 'Failed');
} }
@ -214,13 +212,13 @@ class index extends Component {
saveBroadcast = async (type, data) => { saveBroadcast = async (type, data) => {
let url = BASE_SIMPRO_LUMEN + `/broadcast/add`; let url = BASE_SIMPRO_LUMEN + `/broadcast/add`;
const param = { const param = {
"title_notif": data.title, "title_notif": data.title,
"status_send": type, "status_send": type,
"send_to_type": "all", "send_to_type": "all",
"message_notif": data.message, "message_notif": data.message,
"description": data.description, "description": data.description,
"company_id": data.company_id
} }
const paramRoles = { const paramRoles = {
@ -229,7 +227,8 @@ class index extends Component {
"send_to_type": "roles", "send_to_type": "roles",
"message_notif": data.message, "message_notif": data.message,
"description": data.description, "description": data.description,
"send_to_id": data.id "send_to_id": data.id,
"company_id": data.company_id
} }
const paramUsers = { const paramUsers = {
@ -238,7 +237,8 @@ class index extends Component {
"send_to_type": "users", "send_to_type": "users",
"message_notif": data.message, "message_notif": data.message,
"description": data.description, "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") { if (data.send_to_type === "all") {
@ -491,6 +491,9 @@ class index extends Component {
</Col> </Col>
</Row> </Row>
</td> </td>
{this.state.role_name === 'Super Admin' &&
<td>{n.join_first_company_name ? n.join_first_company_name : "-"}</td>
}
<td>{n.title_notif}</td> <td>{n.title_notif}</td>
<td>{n.message_notif !== "" ? n.message_notif : "-"}</td> <td>{n.message_notif !== "" ? n.message_notif : "-"}</td>
<td>{n.description !== "" ? n.description : "-"}</td> <td>{n.description !== "" ? n.description : "-"}</td>
@ -557,13 +560,14 @@ class index extends Component {
render() { render() {
const column = [ const column = [
{ name: this.props.t('action') }, { 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('title') },
{ name: this.props.t('message') }, { name: this.props.t('message') },
{ name: this.props.t('description') }, { name: this.props.t('description') },
{ name: this.props.t('receiver') }, { name: this.props.t('receiver') },
{ name: "Status" }, { name: "Status" },
{ name: this.props.t('date') }, { name: this.props.t('date') },
] ].filter(column => column && column.name);
const t = this.props; const t = this.props;
const { tooltipTambah, tooltipExport, dataTable, splitButtonOpen, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, statusSend } = this.state const { tooltipTambah, tooltipExport, dataTable, splitButtonOpen, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, statusSend } = this.state
return ( return (
@ -591,6 +595,9 @@ class index extends Component {
dataEdit={this.state.dataEdit} dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog} showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo} dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
listCompany={this.state.listCompany}
/> />
<DialogDetail <DialogDetail
openDialog={this.state.openDialogDetail} openDialog={this.state.openDialogDetail}

91
src/views/Master/MasterRoles/DialogForm.js

@ -1,22 +1,13 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col } from 'reactstrap'; import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import axios from 'axios'; import axios from 'axios';
import { NotificationManager } from 'react-notifications';
import { Select } from 'antd'; 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 { 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 { class DialogForm extends Component {
constructor(props) { constructor(props) {
@ -27,16 +18,26 @@ class DialogForm extends Component {
description: "", description: "",
openDialog: false, openDialog: false,
isParentClick: false, isParentClick: false,
companyList: [],
scompany_id:null,
menu: [], menu: [],
selectedMenu: null, selectedMenu: null,
all_project: false, 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() { async componentDidMount() {
this.props.showDialog(this.showDialog); this.getDataProyekCompany();
this.getAllMenu(); this.getAllMenu();
this.props.showDialog(this.showDialog);
} }
async componentDidUpdate() { async componentDidUpdate() {
if (this.state.isParentClick === true) { if (this.state.isParentClick === true) {
@ -47,7 +48,7 @@ class DialogForm extends Component {
name: dataEdit.name, name: dataEdit.name,
description: dataEdit.description, description: dataEdit.description,
selectedMenu: dataEdit.default_page, selectedMenu: dataEdit.default_page,
company_id scompany_id : dataEdit.company_id
}) })
} else { } else {
this.setState({ this.setState({
@ -55,13 +56,27 @@ class DialogForm extends Component {
name: "", name: "",
description: "", description: "",
selectedMenu: null, selectedMenu: null,
company_id scompany_id : null
}) })
} }
this.setState({ isParentClick: false }); 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 () => { getAllMenu = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
@ -72,7 +87,7 @@ class DialogForm extends Component {
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
.post(MENU_SEARCH, payload, config) .post(MENU_SEARCH, payload, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
@ -85,6 +100,10 @@ class DialogForm extends Component {
} }
validation = () => { 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 === "") { if (!this.state.name || this.state.name === "") {
alert("Role Name cannot be empty!"); alert("Role Name cannot be empty!");
return true; return true;
@ -101,7 +120,9 @@ class DialogForm extends Component {
name, name,
description, description,
selectedMenu, selectedMenu,
role_name,
company_id, company_id,
scompany_id,
all_project all_project
} = this.state } = this.state
@ -114,7 +135,7 @@ class DialogForm extends Component {
name, name,
description, description,
selectedMenu, selectedMenu,
company_id, company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project all_project
} }
@ -125,21 +146,22 @@ class DialogForm extends Component {
name, name,
description, description,
selectedMenu, selectedMenu,
company_id, company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project all_project
} }
this.props.closeDialog('edit', data); this.props.closeDialog('edit', data);
} }
this.setState({ id: 0 }); this.setState({ id: 0 });
} }
} }
handleCancel = () => { handleCancel = () => {
this.props.closeDialog('cancel', 'none') this.props.closeDialog('cancel', 'none')
} }
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => { renderForm = () => {
const { t } = this.props; const { t } = this.props;
return ( return (
@ -150,6 +172,31 @@ class DialogForm extends Component {
</Col> </Col>
</Row> </Row>
<Row> <Row>
{
this.state.role_name === 'Super Admin' && (
<Col md={12}>
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={this.state.scompany_id}
defaultValue={this.state.scompany_id}
onChange={this.onChangeCompanyProject}
style={{ width: "100%" }}
>
{this.state.companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
<Col md={12}> <Col md={12}>
<FormGroup> <FormGroup>
<Label>{this.props.t('nameRole')}<span style={{ color: "red" }}>*</span></Label> <Label>{this.props.t('nameRole')}<span style={{ color: "red" }}>*</span></Label>

61
src/views/Master/MasterRoles/DialogMenuRoles.js

@ -7,17 +7,6 @@ import { MENU_SEARCH } from '../../../const/ApiConst.js';
import { withTranslation, WithTranslation } from 'react-i18next'; import { withTranslation, WithTranslation } from 'react-i18next';
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/"; 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 { class DialogMenuRoles extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
@ -27,28 +16,24 @@ class DialogMenuRoles extends Component {
description: "", description: "",
openDialog: false, openDialog: false,
isParentClick: false, isParentClick: false,
menu: [],
stateMenu: [], stateMenu: [],
menu:[],
allChecked: true, 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() { async componentDidMount() {
this.getAllMenu()
this.props.showDialog(this.showDialog); 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 () => { getAllMenu = async () => {
@ -60,22 +45,26 @@ class DialogMenuRoles extends Component {
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
.post(MENU_SEARCH, payload, config) .post(MENU_SEARCH, payload, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
this.setState({ menu: result.data.data }, () => { this.setState({ menu: result.data.data });
this.setStateMenu(false); }
}); }
} else {
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 => { setStateMenu = edit => {

140
src/views/Master/MasterRoles/index.js

@ -16,28 +16,7 @@ const LENGTH_DATA = 10
class index extends Component { class index extends Component {
constructor(props) { 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');
}
super(props) super(props)
this.config = {
headers: {
Authorization: `Bearer ${token}`,
"Content-type": "application/json"
}
};
this.state = { this.state = {
alertDelete: false, alertDelete: false,
alertNotDelete: false, alertNotDelete: false,
@ -63,8 +42,21 @@ class index extends Component {
tooltipTambah: false, tooltipTambah: false,
totalPage: 0, totalPage: 0,
typeDialog: 'Save', typeDialog: 'Save',
company_id: company_id, company_id: props.company_id || 0,
role_name: role_name 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 = [ this.columns = [
{ {
@ -86,6 +78,18 @@ class index extends Component {
</Tooltip> </Tooltip>
</>, </>,
}, },
...(this.state.role_name === 'Super Admin'
? [
{
title: this.props.t('company'),
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => (
<span>{record.join_first_company_name}</span>
),
}
]
: []),
{ title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' },
] ]
@ -116,9 +120,18 @@ class index extends Component {
const formData = { const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage }, "paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }, group_column: {
], "operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
@ -130,9 +143,15 @@ class index extends Component {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "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 const result = await axios
.post(ROLE_SEARCH, formData, this.config) .post(ROLE_SEARCH, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -177,7 +196,7 @@ class index extends Component {
const { idDelete } = this.state const { idDelete } = this.state
const url = ROLE_DELETE(idDelete) 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) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -202,7 +221,7 @@ class index extends Component {
all_project: data.all_project 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) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -224,7 +243,7 @@ class index extends Component {
all_project: data.all_project all_project: data.all_project
} }
const url = ROLE_EDIT(data.id) 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) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -293,7 +312,7 @@ class index extends Component {
} }
const result = await axios const result = await axios
.post(ROLEMENU_SEARCH, formData, this.config) .post(ROLEMENU_SEARCH, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
@ -317,7 +336,7 @@ class index extends Component {
menu_id: val.menu_id, menu_id: val.menu_id,
role_id: val.roles_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))) .then(res => result.push(res)))
} }
}) })
@ -337,7 +356,7 @@ class index extends Component {
deleteCurrentRoleMenu = async (id) => { deleteCurrentRoleMenu = async (id) => {
let urlDel = ROLEMENU_DELETE_ROLE(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) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
@ -349,18 +368,42 @@ class index extends Component {
handleExportExcel = async () => { handleExportExcel = async () => {
let start = 0; let start = 0;
let end = "ALL";
const formData = { const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage }, "paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } "group_column": {
], "operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(ROLE_SEARCH, formData, this.config) .post(ROLE_SEARCH, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -368,10 +411,12 @@ class index extends Component {
const dataRes = result.data.data || []; const dataRes = result.data.data || [];
const dataExport = []; const dataExport = [];
dataRes.map((val, index) => { dataRes.map((val, index) => {
let row = { let row = {};
Nama: val.name, if (this.state.role_name === 'Super Admin') {
Deskripsi: val.description row.Company = val.join_first_company_name;
} }
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row); dataExport.push(row);
}) })
this.setState({ dataExport: dataExport }, () => { this.setState({ dataExport: dataExport }, () => {
@ -429,9 +474,9 @@ class index extends Component {
dataEdit={this.state.dataEdit} dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog} showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo} dataHs={this.state.dataIdHo}
companyID={this.state.company_id} company_id={this.state.company_id}
roleName={this.state.role_name} role_name={this.state.role_name}
token={this.state.token}
/> />
<DialogMenuRoles <DialogMenuRoles
openDialog={dialogMenuForm} openDialog={dialogMenuForm}
@ -439,15 +484,16 @@ class index extends Component {
idRoles={this.state.idRoles} idRoles={this.state.idRoles}
showDialog={showDialog => this.showMenuRolesDialog = showDialog} showDialog={showDialog => this.showMenuRolesDialog = showDialog}
menuRoles={this.state.menuRoles} menuRoles={this.state.menuRoles}
companyID={this.state.company_id} company_id={this.state.company_id}
roleName={this.state.role_name} role_name={this.state.role_name}
token={this.state.token}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4> <h4>{this.props.params.name}</h4>
<Row> <Row>
<Col> <Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('searchRoles')} /> <Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('search')} />
</Col> </Col>
<Col> <Col>
<Tooltip title={this.props.t('rolesAdd')}> <Tooltip title={this.props.t('rolesAdd')}>

48
src/views/Master/MasterMenu/DialogForm.js → src/views/Master/MenuCompany/DialogForm.js

@ -7,7 +7,7 @@ import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { Option } = Select const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataMenu }) => { const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataMenu, listCompany, role_name, company_id }) => {
const [id, setId] = useState(0) const [id, setId] = useState(0)
const [name, setName] = useState('') const [name, setName] = useState('')
const [url, setUrl] = useState('') const [url, setUrl] = useState('')
@ -15,17 +15,19 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [icon, setIcon] = useState('') const [icon, setIcon] = useState('')
const [sequence, setSequence] = useState(0) const [sequence, setSequence] = useState(0)
const [parentId, setParentId] = useState(null) const [parentId, setParentId] = useState(null)
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation() const { t } = useTranslation()
useEffect(() => { useEffect(() => {
if (typeDialog === "Edit") { if (typeDialog === "Edit") {
setId(dataEdit.id) setId(dataEdit.id)
setName(dataEdit.name) setName(dataEdit.join_first_name)
setUrl(dataEdit.url) setUrl(dataEdit.url)
setIcon(dataEdit.icon) setIcon(dataEdit.icon)
setParentId(dataEdit.parent_id) setParentId(dataEdit.parent_menu_id)
setSequence(dataEdit.sequence) setSequence(dataEdit.sequence)
setAliasName(dataEdit.alias_name) setAliasName(dataEdit.alias_name)
setSelectedCompany(dataEdit.company_id)
} else { } else {
setId(0) setId(0)
setName('') setName('')
@ -61,12 +63,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const err = validation(); const err = validation();
if (!err) { if (!err) {
if (typeDialog === "Save") { if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
name, name,
url, url,
sequence: parseInt(sequence), sequence: parseInt(sequence),
icon, icon,
alias_name: aliasName, alias_name: aliasName,
company_id: company_id
} }
if (parentId && parentId > 0) { if (parentId && parentId > 0) {
@ -75,6 +81,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
closeDialog('save', data); closeDialog('save', data);
} else { } else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
id, id,
name, name,
@ -82,12 +91,12 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
sequence: parseInt(sequence), sequence: parseInt(sequence),
icon, icon,
alias_name: aliasName, alias_name: aliasName,
company_id: company_id
} }
if (parentId && parentId > 0) { if (parentId && parentId > 0) {
data['parent_id'] = parentId data['parent_id'] = parentId
} }
closeDialog('edit', data); closeDialog('edit', data);
} }
setId(0) setId(0)
@ -127,6 +136,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
) )
} }
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => { const renderForm = () => {
return ( return (
<Form> <Form>
@ -135,6 +148,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<span style={{ color: "red" }}>*</span> Wajib diisi. <span style={{ color: "red" }}>*</span> Wajib diisi.
</Col> </Col>
</Row> </Row>
{role_name === 'Super Admin' &&
<Row>
<Col md={12}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
}
<Row> <Row>
<Col> <Col>
<FormGroup> <FormGroup>

418
src/views/Master/MenuCompany/DialogMasterMenu.js

@ -0,0 +1,418 @@
import * as XLSX from 'xlsx';
import DialogForm from './DialogForm.js';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { MENU_ADD, MENU_SEARCH, MENU_EDIT, MENU_DELETE, MENU_LIST } from '../../../const/ApiConst.js';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip, Table, Spin } from 'antd';
import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const column = [
{ name: "Nama" },
{ name: "Url" },
{ name: "Ikon" },
{ name: "Alias" },
{ name: "Urutan" },
{ name: "Parent" },
]
const Index = ({ params, openDialog, toggleDialog, closeDialog }) => {
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 [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [tooltipDelete, setTooltipDelete] = useState(false)
const [tooltipEdit, setTooltipEdit] = useState(false)
const [tooltipExport, setTooltipExport] = useState(false)
const [tooltipTambah, setTooltipTambah] = useState(false)
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [loading, SetLoading] = useState(false)
const { t } = useTranslation()
// const pageName = params.name;
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
useEffect(() => {
getDataMenu();
}, [search, currentPage, rowsPerPage])
useEffect(() => {
const cekData = dataExport || []
if (cekData.length > 0) {
exportExcel()
}
}, [dataExport])
const handleSearch = e => {
const value = e.target.value
setSearch(value);
setCurrentPage(1)
};
const getDataAllMenu = async () => {
const result = await axios
.get(MENU_LIST, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let arr = []
let dataRes = result.data.data;
for (const v in dataRes) {
arr.push(dataRes[v])
}
setAllDataMenu(arr);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const getDataMenu = async () => {
SetLoading(true)
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
"paging": { "start": start, "length": rowsPerPage },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" }
],
"joins": [{
"name": "m_menu",
"column_join": "parent_id",
"column_results": [
"name"
]
}],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_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);
SetLoading(false)
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
SetLoading(false)
}
}
const handleOpenDialog = async (type) => {
await setTypeDialog(type)
getDataAllMenu();
// setOpenDialog(true)
}
const handleCloseDialog = (type, data) => {
if (type === "save") {
saveMenu(data);
} else if (type === "edit") {
editMenu(data);
}
setDataEdit([])
// setOpenDialog(false)
}
const toggleAddDialog = () => {
// setOpenDialog(!openDialog)
}
const handleCancel = () => {
closeDialog('cancel', 'none')
// setDatatable([]);
// setBaseUrl([]);
// setAvailableBaseUrl(false);
// setLoading(false);
}
const onConfirmDelete = async () => {
const url = MENU_DELETE(idDelete)
const result = await axios.delete(url, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataMenu()
setIdDelete(0)
setAlertDelete(false)
NotificationManager.success(`Data menu berhasil dihapus`, 'Success!!');
} else {
setIdDelete(0)
setAlertDelete(false)
NotificationManager.error(`Data menu gagal dihapus`, 'Failed!!');
}
}
const saveMenu = async (data) => {
const formData = data
const result = await axios.post(MENU_ADD, formData, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataMenu();
getDataAllMenu();
NotificationManager.success(`Data menu berhasil ditambahkan`, 'Success!!');
} else {
NotificationManager.error(`Data menu gagal ditambahkan`, 'Failed!!');
}
}
const editMenu = async (data) => {
const formData = data
const url = MENU_EDIT(data.id)
const result = await axios.put(url, formData, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataMenu();
NotificationManager.success(`Data menu berhasil diubah`, 'Success!!');
} else {
NotificationManager.error(`Data menu gagal diubah`, `Failed!!`);
}
}
const handleEdit = (data) => {
setDataEdit(data)
handleOpenDialog('Edit');
}
const handleDelete = async (id) => {
await setAlertDelete(true)
await setIdDelete(id)
}
const onShowSizeChange = (current, pageSize) => {
setRowsPerPage(pageSize)
}
const onPagination = (current, pageSize) => {
setCurrentPage(current)
}
const toggle = (param) => {
if (param === "edit") {
setTooltipEdit(!tooltipEdit)
} else if (param === "delete") {
setTooltipDelete(!tooltipDelete)
} else if (param === "tambah") {
setTooltipTambah(!tooltipTambah)
} else if (param === "export") {
setTooltipExport(!tooltipExport)
}
}
const handleExportExcel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" }
],
"joins": [{
"name": "m_menu",
"column_join": "parent_id",
"column_results": [
"name"
]
}],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_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 = {
"Nama": val.name,
"Url": val.url,
"Icon": val.icon,
"Alias Name": val.alias_name,
"Urutan": val.sequence,
"Parent Name": val.join_first_name ? val.join_first_name : "-"
}
excelData.push(dataRow)
})
await setDataExport(excelData);
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
const exportExcel = () => {
const dataExcel = dataExport || [];
const fileName = `Data Master Menu.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data Master Menu`);
XLSX.writeFile(wb, fileName);
setDataExport([])
}
const cancelDelete = () => {
setAlertDelete(false)
setIdDelete(0)
}
const renderTable = useMemo(() => {
const columns = [
{
title: t('action'),
dataIndex: '',
key: 'x',
render: (text, record) => <>
<Tooltip title={t('delete')}>
<i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title={t('edit')}>
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(text)}></i>
</Tooltip>
</>,
},
{ title: t('name'), dataIndex: 'name', key: 'name' },
{ title: 'Url', dataIndex: 'url', key: 'url' },
{ title: t('icon'), dataIndex: 'icon', key: 'icon' },
{ title: 'Alias', dataIndex: 'alias_name', key: 'alias_name' },
{ title: t('order'), dataIndex: 'sequence', key: 'sequence' },
{ title: t('parentMenu'), dataIndex: 'join_first_name', key: 'join_first_name', render: (text, record) => (text ? text : "-") }
];
return (
<Table
rowKey="id"
size="small"
columns={columns}
dataSource={dataTable}
pagination={false}
/>
)
}, [dataTable])
return (
<div>
<NotificationContainer />
<SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
{t('deleteMsg')}
</SweetAlert>
{/* <DialogForm
openDialog={openDialog}
closeDialog={handleCloseDialog}
toggleDialog={() => toggleAddDialog}
typeDialog={typeDialog}
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataMenu={allDataMenu}
/> */}
<Modal size="xl" fullscreen="xl" scrollable={true} isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}>
MASTER MENU
<div style={{ display: 'flex' }}>
<Tooltip title={t('menuAdd')}>
<Button style={{ marginLeft: "5px" }} id="TooltipTambah" color="success" onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</div>
</ModalHeader>
<ModalBody>
<>
<Spin tip="Loading..." spinning={loading}>
{renderTable}
<Pagination
style={{ marginTop: "25px" }}
showSizeChanger
onShowSizeChange={onShowSizeChange}
onChange={onPagination}
pageSizeOptions={["10", "25", "50"]}
total={totalPage}
pageSize={rowsPerPage}
current={currentPage}
/>
</Spin>
</>
</ModalBody>
<ModalFooter>
{/* {typeDialog !== "Set" && typeDialog !== "Set-Menu" && (
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>
)} */}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>cancel</Button>
</ModalFooter>
</Modal>
{/* <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchMenu')} />
</Col>
<Col>
<Tooltip title={t('menuAdd')}>
<Button id="TooltipTambah" color="success" onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
</CardHeader>
<CardBody>
{renderTable}
<Pagination
style={{ marginTop: "25px" }}
showSizeChanger
onShowSizeChange={onShowSizeChange}
onChange={onPagination}
current={currentPage}
pageSize={rowsPerPage}
total={totalPage}
pageSizeOptions={["10", "15", "20", "25", "30", "35", "40"]}
/>
</CardBody>
</Card> */}
</div>
)
}
export default Index;

89
src/views/Master/MasterMenu/index.js → src/views/Master/MenuCompany/index.js

@ -1,11 +1,12 @@
import * as XLSX from 'xlsx'; import * as XLSX from 'xlsx';
import DialogForm from './DialogForm'; import DialogForm from './DialogForm';
import DialogMasterMenu from './DialogMasterMenu.js'
import React, { useState, useEffect, useMemo } from 'react'; import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios'; import axios from 'axios';
import { Button } from 'reactstrap'; import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { MENU_ADD, MENU_SEARCH, MENU_EDIT, MENU_DELETE, MENU_LIST } from '../../../const/ApiConst.js'; import { MENU_ADD, MENU_SEARCH, MENU_EDIT, MENU_DELETE, MENU_LIST, MENU_COMPANY_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst.js';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip, Table } from 'antd'; import { Pagination, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -19,7 +20,20 @@ const column = [
{ name: "Parent" }, { name: "Parent" },
] ]
const Index = ({ params }) => { 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 [alertDelete, setAlertDelete] = useState(false) const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([]) const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false) const [clickOpenModal, setClickOpenModal] = useState(false)
@ -29,6 +43,7 @@ const Index = ({ params }) => {
const [dataTable, setDatatable] = useState([]) const [dataTable, setDatatable] = useState([])
const [idDelete, setIdDelete] = useState(0) const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false) const [openDialog, setOpenDialog] = useState(false)
const [openDialogMasterMenu, setOpenDialogMasterMenu] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10) const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [tooltipDelete, setTooltipDelete] = useState(false) const [tooltipDelete, setTooltipDelete] = useState(false)
@ -37,6 +52,7 @@ const Index = ({ params }) => {
const [tooltipTambah, setTooltipTambah] = useState(false) const [tooltipTambah, setTooltipTambah] = useState(false)
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
const pageName = params.name; const pageName = params.name;
@ -59,6 +75,21 @@ const Index = ({ params }) => {
} }
}, [dataExport]) }, [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 handleSearch = e => { const handleSearch = e => {
const value = e.target.value const value = e.target.value
setSearch(value); setSearch(value);
@ -93,11 +124,11 @@ const Index = ({ params }) => {
const payload = { const payload = {
"paging": { "start": start, "length": rowsPerPage }, "paging": { "start": start, "length": rowsPerPage },
"columns": [ "columns": [
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" } { "name": "alias_name", "logic_operator": "ilike", "value": search, "operator": "AND" }
], ],
"joins": [{ "joins": [{
"name": "m_menu", "name": "m_menu",
"column_join": "parent_id", "column_join": "menu_id",
"column_results": [ "column_results": [
"name" "name"
] ]
@ -105,8 +136,24 @@ const Index = ({ params }) => {
"orders": { "columns": ["id"], "ascending": false } "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.columns.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios const result = await axios
.post(MENU_SEARCH, payload, config) .post(MENU_COMPANY_SEARCH, payload, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -123,6 +170,18 @@ const Index = ({ params }) => {
getDataAllMenu(); getDataAllMenu();
setOpenDialog(true) setOpenDialog(true)
} }
const handleOpenDialogMasterMenu = async () => {
setOpenDialogMasterMenu(true)
}
const handleCloseDialogMasterMenu = () => {
setOpenDialogMasterMenu(false)
}
const toggleDialogMasterMenu = () => {
setOpenDialogMasterMenu(!openDialog)
}
const handleCloseDialog = (type, data) => { const handleCloseDialog = (type, data) => {
if (type === "save") { if (type === "save") {
@ -288,7 +347,10 @@ const Index = ({ params }) => {
</Tooltip> </Tooltip>
</>, </>,
}, },
{ title: t('name'), dataIndex: 'name', key: 'name' }, ...(role_name === 'Super Admin' ?
[{ title: t('company'), dataIndex: 'join_second_company_name', key: 'join_second_company_name' }]
: []),
{ title: t('name'), dataIndex: 'join_first_name', key: 'join_first_name' },
{ title: 'Url', dataIndex: 'url', key: 'url' }, { title: 'Url', dataIndex: 'url', key: 'url' },
{ title: t('icon'), dataIndex: 'icon', key: 'icon' }, { title: t('icon'), dataIndex: 'icon', key: 'icon' },
{ title: 'Alias', dataIndex: 'alias_name', key: 'alias_name' }, { title: 'Alias', dataIndex: 'alias_name', key: 'alias_name' },
@ -330,6 +392,14 @@ const Index = ({ params }) => {
dataEdit={dataEdit} dataEdit={dataEdit}
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataMenu={allDataMenu} dataMenu={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/>
<DialogMasterMenu
openDialog={openDialogMasterMenu}
closeDialog={handleCloseDialogMasterMenu}
toggleDialog={() => toggleDialogMasterMenu}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -339,8 +409,13 @@ const Index = ({ params }) => {
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchMenu')} /> <Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchMenu')} />
</Col> </Col>
<Col> <Col>
{role_name === 'Super Admin' &&
<Tooltip title="Master Menu">
<Button id="TooltipMasterMenu" color="warning" onClick={() => handleOpenDialogMasterMenu()}><i className="fa fa-table"></i></Button>
</Tooltip>
}
<Tooltip title={t('menuAdd')}> <Tooltip title={t('menuAdd')}>
<Button id="TooltipTambah" color="success" onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> <Button style={{ marginLeft: "5px" }} id="TooltipTambah" color="success" onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title={t('exportExcel')}> <Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> <Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>

27
src/views/Master/ProjectExpenditure/index.js

@ -12,21 +12,18 @@ import { useTranslation } from 'react-i18next';
const ProjectExpenditure = ({ params, ...props }) => { const ProjectExpenditure = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {

27
src/views/Master/ProjectFinancialHealth/index.js

@ -12,21 +12,18 @@ import { useTranslation } from 'react-i18next';
const ProjectFinancialHealth = ({ params, ...props }) => { const ProjectFinancialHealth = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {

27
src/views/Master/ProjectInvoice/index.js

@ -12,21 +12,18 @@ import { useTranslation } from 'react-i18next';
const ProjectInvoice = ({ params, ...props }) => { const ProjectInvoice = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {

48
src/views/Master/ProjectPhase/DialogForm.js

@ -8,17 +8,20 @@ import InputColor from "./InputColor";
import "./styles.css"; import "./styles.css";
import "rc-color-picker/assets/index.css"; import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id") import { Select } from 'antd';
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const [id, setId] = useState(0) const [id, setId] = useState(0)
const [projectType, setProjectType] = useState('') const [projectType, setProjectType] = useState('')
const [color, setColor] = useState('') const [color, setColor] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation(); const { t } = useTranslation();
useEffect(() => { useEffect(() => {
if (typeDialog === "Edit") { if (typeDialog === "Edit") {
setId(dataEdit.id) setId(dataEdit.id)
setProjectType(dataEdit.name) setProjectType(dataEdit.name)
setColor(dataEdit.color) setColor(dataEdit.color)
setSelectedCompany(dataEdit.company_id)
} else { } else {
setId(0) setId(0)
setColor('') setColor('')
@ -29,18 +32,24 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => { const handleSave = () => {
let data = ''; let data = '';
if (typeDialog === "Save") { if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
name: projectType, name: projectType,
color, color,
company_id company_id: company_id
} }
closeDialog('save', data); closeDialog('save', data);
} else { } else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
id, id,
name: projectType, name: projectType,
color, color,
company_id company_id: company_id
} }
closeDialog('edit', data); closeDialog('edit', data);
} }
@ -52,6 +61,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setId(0) setId(0)
} }
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => { const renderForm = () => {
return ( return (
<Form> <Form>
@ -69,6 +82,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
{role_name === 'Super Admin' &&
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
}
</Form> </Form>
) )
} }

141
src/views/Master/ProjectPhase/index.js

@ -6,27 +6,24 @@ import axios from "../../../const/interceptorApi"
import moment from 'moment' import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; 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 { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const ProjectPhase = ({ params, ...props }) => { const ProjectPhase = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {
@ -52,6 +49,7 @@ const ProjectPhase = ({ params, ...props }) => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getDataProjectPhase() getDataProjectPhase()
@ -64,20 +62,39 @@ const ProjectPhase = ({ params, ...props }) => {
} }
}, [dataExport]) }, [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 () => { const getDataProjectPhase = async () => {
let start = 0; let start = 0;
if (currentPage !== 1 && currentPage > 1) { if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage start = (currentPage * rowsPerPage) - rowsPerPage
} }
const payload = { const payload = {
"columns": [ group_column: {
{ "operator": "AND",
"name": "name", "group_operator": "OR",
"logic_operator": "ilike", "where": [
"value": search, {
"operator": "AND" "name": "name",
} "logic_operator": "~*",
], "value": search,
}
]
},
"columns": [],
"orders": { "orders": {
"ascending": true, "ascending": true,
"columns": [ "columns": [
@ -87,7 +104,8 @@ const ProjectPhase = ({ params, ...props }) => {
"paging": { "paging": {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "start": start
} },
'joins': []
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.columns.push( payload.columns.push(
@ -97,6 +115,12 @@ const ProjectPhase = ({ params, ...props }) => {
payload.columns.push( 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"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
.post(PROJECT_PHASE_SEARCH, payload, HEADER) .post(PROJECT_PHASE_SEARCH, payload, HEADER)
@ -132,14 +156,18 @@ const ProjectPhase = ({ params, ...props }) => {
} }
const payload = { const payload = {
"columns": [ group_column: {
{ "operator": "AND",
"name": "name", "group_operator": "OR",
"logic_operator": "like", "where": [
"value": search, {
"operator": "AND" "name": "name",
} "logic_operator": "~*",
], "value": search,
}
]
},
"columns": [],
"orders": { "orders": {
"ascending": true, "ascending": true,
"columns": [ "columns": [
@ -149,7 +177,23 @@ const ProjectPhase = ({ params, ...props }) => {
"paging": { "paging": {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "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 const result = await axios
@ -160,10 +204,12 @@ const ProjectPhase = ({ params, ...props }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((val, index) => { resData.map((val, index) => {
let dataRow = { let dataRow = {};
"Nama": val.name, if (role_name === 'Super Admin') {
"Color": val.color, dataRow.Company = val.join_first_company_name;
} }
dataRow.Nama = val.name;
dataRow.Color = val.color;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData) await setDataExport(excelData)
@ -196,7 +242,7 @@ const ProjectPhase = ({ params, ...props }) => {
if (type === "save") { if (type === "save") {
saveProjectPhase(data); saveProjectPhase(data);
} else if (type === "edit") { } else if (type === "edit") {
editMaterialR(data); editProjectPhase(data);
} }
setDataEdit([]) setDataEdit([])
setOpenDialog(false) setOpenDialog(false)
@ -216,7 +262,7 @@ const ProjectPhase = ({ params, ...props }) => {
} }
} }
const editMaterialR = async (data) => { const editProjectPhase = async (data) => {
let urlEdit = PROJECT_PHASE_EDIT(data.id) let urlEdit = PROJECT_PHASE_EDIT(data.id)
const formData = data const formData = data
@ -311,7 +357,19 @@ const ProjectPhase = ({ params, ...props }) => {
</Tooltip>{" "} </Tooltip>{" "}
</>, </>,
}, },
{ title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" }, ...(role_name === 'Super Admin' ?
[{
title: t('companyName'),
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => (
<span>{record.join_first_company_name}</span>
)
}]
: []),
{
title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap"
},
{ {
title: t('color'), title: t('color'),
dataIndex: 'color', dataIndex: 'color',
@ -358,6 +416,9 @@ const ProjectPhase = ({ params, ...props }) => {
dataEdit={dataEdit} dataEdit={dataEdit}
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataParent={allDataMenu} dataParent={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>

27
src/views/Master/ProjectScheduleHealth/index.js

@ -12,21 +12,18 @@ import { useTranslation } from 'react-i18next';
const ProjectScheduleHealth = ({ params, ...props }) => { const ProjectScheduleHealth = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {

114
src/views/Master/RoleProject/DialogForm.js

@ -1,9 +1,12 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import axios from 'axios';
import { COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id") import { NotificationManager } from 'react-notifications';
import { Select } from 'antd';
const { Option } = Select
class DialogForm extends Component { class DialogForm extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
@ -12,13 +15,24 @@ class DialogForm extends Component {
name: "", name: "",
description: "", description: "",
openDialog: false, openDialog: false,
companyList: [],
scompany_id:null,
isParentClick: false, isParentClick: 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() { async componentDidMount() {
this.props.showDialog(this.showDialog); this.props.showDialog(this.showDialog);
this.getDataProyekCompany();
} }
async componentDidUpdate() { async componentDidUpdate() {
@ -29,13 +43,14 @@ class DialogForm extends Component {
id: dataEdit.id, id: dataEdit.id,
name: dataEdit.name, name: dataEdit.name,
description: dataEdit.description, description: dataEdit.description,
company_id scompany_id : dataEdit.company_id
}) })
} else { } else {
this.setState({ this.setState({
id: 0, id: 0,
name: "", name: "",
description: "" description: "",
scompany_id:null
}) })
} }
this.setState({ isParentClick: false }); this.setState({ isParentClick: false });
@ -47,45 +62,96 @@ class DialogForm extends Component {
this.setState({ isParentClick: true }); 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 = () => { handleSave = () => {
const { const {
id, id,
name, name,
description description,
role_name,
company_id,
scompany_id
} = this.state } = this.state
let data = ''; let data = '';
if (this.props.typeDialog === "Save") { const err = this.validation();
data = { if(!err) {
id, if (this.props.typeDialog === "Save") {
name, data = {
description, id,
company_id name,
} description,
this.props.closeDialog('save', data); company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
} else { }
data = { this.props.closeDialog('save', data);
id, } else {
name, data = {
description, id,
company_id name,
description,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
}
this.props.closeDialog('edit', data);
} }
this.props.closeDialog('edit', data);
} }
this.setState({ id: 0 }); this.setState({ id: 0 });
} }
handleCancel = () => { handleCancel = () => {
this.props.closeDialog('cancel', 'none') this.props.closeDialog('cancel', 'none')
} }
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => { renderForm = () => {
const { t } = this.props; const { t } = this.props;
return ( return (
<Form> <Form>
{
this.state.role_name === 'Super Admin' && (
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={this.state.scompany_id}
defaultValue={this.state.scompany_id}
onChange={this.onChangeCompanyProject}
style={{ width: "100%" }}
>
{this.state.companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
)
}
<FormGroup> <FormGroup>
<Label>{this.props.t('name')}</Label> <Label>{this.props.t('name')}</Label>
<Input type="text" value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} /> <Input type="text" value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} />

152
src/views/Master/RoleProject/index.js

@ -6,49 +6,13 @@ import axios from 'axios';
import { Button } from 'reactstrap'; import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; 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 { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next'; 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 const LENGTH_DATA = 10
class index extends Component { class index extends Component {
constructor(props) { constructor(props) {
let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = ''; super(props);
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');
}
super(props)
this.state = { this.state = {
alertDelete: false, alertDelete: false,
alertNotDelete: false, alertNotDelete: false,
@ -74,9 +38,23 @@ class index extends Component {
tooltipTambah: false, tooltipTambah: false,
totalPage: 0, totalPage: 0,
typeDialog: 'Save', typeDialog: 'Save',
company_id: company_id, company_id: props.company_id || 0,
role_name: role_name 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 = [ this.columns = [
{ {
title: this.props.t('action'), title: this.props.t('action'),
@ -86,21 +64,27 @@ class index extends Component {
render: (text, record) => <> render: (text, record) => <>
<Tooltip title={this.props.t('delete')}> <Tooltip title={this.props.t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i> <i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
</Tooltip> </Tooltip>
<Tooltip title={this.props.t('edit')}> <Tooltip title={this.props.t('edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i> <i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
</Tooltip> </Tooltip>
</>, </>,
}, },
{
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' ? (
<span>{record.join_first_company_name}</span>
) : null;
}
},
{ title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' },
]; ];
} }
async componentDidMount() { async componentDidMount() {
this.getDataRoles(); this.getDataRoles();
} }
@ -123,9 +107,18 @@ class index extends Component {
const formData = { const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage }, "paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }, group_column: {
], "operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
@ -137,9 +130,15 @@ class index extends Component {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "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 const result = await axios
.post(PROJECT_ROLE_SEARCH, formData, config) .post(PROJECT_ROLE_SEARCH, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -184,7 +183,7 @@ class index extends Component {
const { idDelete } = this.state const { idDelete } = this.state
const url = PROJECT_ROLE_DELETE(idDelete) 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) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -203,10 +202,10 @@ class index extends Component {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description, description: data.description,
company_id company_id: data.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) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -224,10 +223,10 @@ class index extends Component {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description, description: data.description,
company_id company_id : data.company_id
} }
const url = PROJECT_ROLE_EDIT(data.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) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -290,24 +289,50 @@ class index extends Component {
handleExportExcel = async () => { handleExportExcel = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } "group_column": {
], "operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(PROJECT_ROLE_SEARCH, payload, config) .post(PROJECT_ROLE_SEARCH, payload, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.statusText == "OK") { if (result && result.data && result.statusText == "OK") {
const dataRes = result.data.data || []; const dataRes = result.data.data || [];
const dataExport = []; const dataExport = [];
dataRes.map((val, index) => { dataRes.map((val, index) => {
let row = { let row = {};
Nama: val.name, if (this.state.role_name === 'Super Admin') {
Deskripsi: val.description row.Company = val.join_first_company_name;
} }
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row); dataExport.push(row);
}) })
this.setState({ dataExport: dataExport }, () => { this.setState({ dataExport: dataExport }, () => {
@ -365,13 +390,16 @@ class index extends Component {
dataEdit={this.state.dataEdit} dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog} showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo} dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4> <h4>{this.props.params.name}</h4>
<Row> <Row>
<Col> <Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('searchProjectRoles')} /> <Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('search')} />
</Col> </Col>
<Col> <Col>
<Tooltip title={this.props.t('rolesAdd')}> <Tooltip title={this.props.t('rolesAdd')}>

62
src/views/Pages/Login/Login.js

@ -58,6 +58,21 @@ class Login extends Component {
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
this.showHide = this.showHide.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) { showHide(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -120,7 +135,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, configApp) => {
const config = { const config = {
headers: headers:
{ {
@ -146,14 +161,38 @@ class Login extends Component {
else { else {
this.props.history.push({ this.props.history.push({
pathname: "/dashboard", 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,
configApp
}
}); });
} }
if (this.state.defaultPage) { if (this.state.defaultPage) {
if (role_id === 44) { if (role_id === 44) {
this.props.history.push({ this.props.history.push({
pathname: this.state.defaultPage, 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,
configApp
}
}); });
} else { } else {
this.props.history.push(this.state.defaultPage); this.props.history.push(this.state.defaultPage);
@ -164,7 +203,18 @@ class Login extends Component {
else { else {
this.props.history.push({ this.props.history.push({
pathname: "/dashboard", 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 { } else {
@ -209,7 +259,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) { if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id) 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, data_user.configApp)
window.localStorage.setItem('isLogin', true); window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token); window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id); window.localStorage.setItem('user_id', data_user.id);
@ -219,6 +269,8 @@ class Login extends Component {
window.localStorage.setItem('role_name', data_user.role.name); window.localStorage.setItem('role_name', data_user.role.name);
window.localStorage.setItem('all_project', data_user.role.all_project); window.localStorage.setItem('all_project', data_user.role.all_project);
window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy)); window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy));
window.localStorage.setItem('configApp', JSON.stringify(data_user.configApp));
this.updatePageTitle();
} else { } else {
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!'); // NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
NotificationManager.error(doLogin.data.message, 'Login Failed!'); NotificationManager.error(doLogin.data.message, 'Login Failed!');

59
src/views/Report/k3/index.js

@ -26,23 +26,18 @@ const LENGTH_DATA = 10
class index extends Component { class index extends Component {
constructor(props) { 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 = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = '', hierarchy = []; if (props && props.role_id && props.user_id) {
if (props.location.state && props.location.state.role_id && props.location.state.user_id) { role_id = props.role_id;
role_id = props.location.state.role_id; user_id = props.user_id;
user_id = props.location.state.user_id; token = props.token;
token = props.location.state.token; isLogin = props.isLogin;
isLogin = props.location.state.isLogin; company_id = props.company_id;
company_id = props.location.state.company_id; all_project = props.all_project;
role_name = props.location.state.role_name; role_name = props.role_name;
hierarchy = props.location.state.hierarchy; isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
} 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) super(props)
this.config = { this.config = {
@ -132,7 +127,7 @@ class index extends Component {
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (this.state.role_id !== "Super Admin") { if (this.state.role_name !== "Super Admin") {
payload.columns.push( payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: this.state.hierarchy, operator: "AND" } { name: "created_by_id", logic_operator: "IN", value: this.state.hierarchy, operator: "AND" }
) )
@ -212,11 +207,25 @@ class index extends Component {
} }
if (currentProyek) { if (currentProyek) {
let proyekPayload = { "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek }; payload.columns.push({ "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek })
payload.columns.push(proyekPayload) 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 { } else {
let proyekPayload = { "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds }; payload.columns.push({ "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds })
payload.columns.push(proyekPayload) 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 const result = await axios
@ -470,6 +479,9 @@ class index extends Component {
{dataTable2.length !== 0 ? dataTable2.map((n) => { {dataTable2.length !== 0 ? dataTable2.map((n) => {
return ( return (
<tr key={n.id}> <tr key={n.id}>
{this.state.role_name === 'Super Admin' &&
<td>{n.join_third_company_name ? n.join_third_company_name : "-"}</td>
}
<td>{n.join_first_name ? n.join_first_name : "-"}</td> <td>{n.join_first_name ? n.join_first_name : "-"}</td>
<td>{n.join_second_nama ? n.join_second_nama : "-"}</td> <td>{n.join_second_nama ? n.join_second_nama : "-"}</td>
<td>{n.report_date ? moment(n.report_date).format("DD-MM-YYYY") : "-"}</td> <td>{n.report_date ? moment(n.report_date).format("DD-MM-YYYY") : "-"}</td>
@ -539,6 +551,7 @@ class index extends Component {
render() { render() {
const column = [ const column = [
this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null,
{ name: this.props.t('nameHR') }, { name: this.props.t('nameHR') },
{ name: this.props.t('projectName') }, { name: this.props.t('projectName') },
{ name: this.props.t('dateReport') }, { name: this.props.t('dateReport') },
@ -546,7 +559,7 @@ class index extends Component {
{ name: this.props.t('gearNotUse') }, { name: this.props.t('gearNotUse') },
{ name: this.props.t('description') }, { name: this.props.t('description') },
{ name: this.props.t('action') }, { name: this.props.t('action') },
] ].filter(column => column && column.name);
const t = this.props; const t = this.props;
const { tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state const { tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state
return ( return (

56
src/views/SimproV2/ChecklistK3/DialogForm.js

@ -5,20 +5,22 @@ import {
} from 'reactstrap'; } from 'reactstrap';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Select } from 'antd';
const { Option } = Select;
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id }) => {
const [id, setId] = useState(0) const [id, setId] = useState(0)
const [name, setName] = useState('') const [name, setName] = useState('')
const [description, setDescription] = useState('') const [description, setDescription] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation() const { t } = useTranslation()
useEffect(() => { useEffect(() => {
if (typeDialog === "Edit") { if (typeDialog === "Edit") {
setId(dataEdit.id) setId(dataEdit.id)
setDescription(dataEdit.description) setDescription(dataEdit.description)
setName(dataEdit.name) setName(dataEdit.name)
setSelectedCompany(dataEdit.company_id);
} else { } else {
handleClearData() handleClearData()
@ -27,20 +29,26 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => { const handleSave = () => {
let data = ''; let data = '';
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
if (typeDialog === "Save") { if (typeDialog === "Save") {
data = { data = {
name: name, name: name,
description, description: description,
company_id company_id: parseInt(company_id),
} }
closeDialog('save', data); closeDialog('save', data);
} else { } else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
id, id,
name: name, name: name,
description, description: description,
company_id company_id: company_id,
} }
closeDialog('edit', data); closeDialog('edit', data);
} }
@ -56,8 +64,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setId(0) setId(0)
setName('') setName('')
setDescription('') setDescription('')
setSelectedCompany(null)
} }
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => { const renderForm = () => {
return ( return (
<Form> <Form>
@ -75,6 +88,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
{role_name === 'Super Admin' &&
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
}
</Form> </Form>
) )
} }

116
src/views/SimproV2/ChecklistK3/index.js

@ -5,15 +5,13 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip, } from 'antd';
import { 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'; } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
const role_name = window.localStorage.getItem('role_name');
const company_id = window.localStorage.getItem('company_id');
const config = { const config = {
headers: headers:
{ {
@ -22,8 +20,20 @@ const config = {
} }
}; };
const ChecklistK3 = ({ params }) => { const ChecklistK3 = ({ params, ...props }) => {
const token = localStorage.getItem("token") 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 = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -45,11 +55,13 @@ const ChecklistK3 = ({ params }) => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
const column = [ const column = [
role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('name') }, { name: t('name') },
{ name: t('description') }, { name: t('description') },
] ].filter(column => column && column.name)
useEffect(() => { useEffect(() => {
getDataChecklistK3() getDataChecklistK3()
}, [currentPage, rowsPerPage, search]) }, [currentPage, rowsPerPage, search])
@ -61,6 +73,22 @@ const ChecklistK3 = ({ params }) => {
} }
}, [dataExport]) }, [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 () => { const getDataChecklistK3 = async () => {
let start = 0; let start = 0;
@ -70,14 +98,18 @@ const ChecklistK3 = ({ params }) => {
} }
const payload = { const payload = {
"columns": [ group_column: {
{ "operator": "AND",
"name": "name", "group_operator": "OR",
"logic_operator": "ilike", "where": [
"value": search, {
"operator": "AND" "name": "name",
} "logic_operator": "~*",
], "value": search,
}
]
},
"columns": [],
"orders": { "orders": {
"ascending": true, "ascending": true,
"columns": [ "columns": [
@ -87,7 +119,8 @@ const ChecklistK3 = ({ params }) => {
"paging": { "paging": {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "start": start
} },
'joins': []
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
@ -98,6 +131,12 @@ const ChecklistK3 = ({ params }) => {
payload.columns.push( 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"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
@ -126,13 +165,37 @@ const ChecklistK3 = ({ params }) => {
const handleExportExcel = async () => { const handleExportExcel = async () => {
const payload = { const payload = {
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" }
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(CHECKLIST_K3_SEARCH, payload, config) .post(CHECKLIST_K3_SEARCH, payload, config)
@ -143,10 +206,12 @@ const ChecklistK3 = ({ params }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((val, index) => { resData.map((val, index) => {
let dataRow = { let dataRow = {};
"Nama": val.name, if (role_name === 'Super Admin') {
"Deskripsi": val.description, dataRow.Company = val.join_first_company_name;
} }
dataRow.Nama = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
@ -286,6 +351,8 @@ const ChecklistK3 = ({ params }) => {
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataParent={allDataMenu} dataParent={allDataMenu}
company_id={company_id} company_id={company_id}
listCompany={listCompany}
role_name={role_name}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -329,6 +396,11 @@ const ChecklistK3 = ({ params }) => {
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
{role_name === 'Super Admin' &&
(
<td>{n.join_first_company_name}</td>
)
}
<td>{n.name}</td> <td>{n.name}</td>
<td>{n.description}</td> <td>{n.description}</td>
</tr> </tr>

68
src/views/SimproV2/CreatedProyek/DialogFormProyek.js

@ -35,7 +35,9 @@ const DialogFormProyek = ({
dataDivisions, dataDivisions,
dataPM, dataPM,
projectImage, projectImage,
company_id company_id,
role_name,
companyList
}) => { }) => {
const token = localStorage.getItem("token"); const token = localStorage.getItem("token");
const HEADER = { const HEADER = {
@ -65,6 +67,7 @@ const DialogFormProyek = ({
const [finance, setFinance] = useState(""); const [finance, setFinance] = useState("");
const [investor, setInvestor] = useState(""); const [investor, setInvestor] = useState("");
const [company, setCompany] = useState(""); const [company, setCompany] = useState("");
const [scompany_id, setCompanyId] = useState(null);
const [step, setStep] = useState(1); const [step, setStep] = useState(1);
const [currencyList, setCurrencyList] = useState(null); const [currencyList, setCurrencyList] = useState(null);
const [currency, setCurrency] = useState(""); // merge of code | symbol | name const [currency, setCurrency] = useState(""); // merge of code | symbol | name
@ -115,6 +118,7 @@ const DialogFormProyek = ({
setProjectDuration(val.durasi_proyek); setProjectDuration(val.durasi_proyek);
setInvestor(val.investor); setInvestor(val.investor);
setCompany(val.company); setCompany(val.company);
setCompanyId(val.company_id)
setFinance(val.finance); setFinance(val.finance);
setObjectives(val.project_objectives ? val.project_objectives : ""); setObjectives(val.project_objectives ? val.project_objectives : "");
setTestingEnv(val.testing_environment); setTestingEnv(val.testing_environment);
@ -206,6 +210,7 @@ const DialogFormProyek = ({
setDivisiProject(null); setDivisiProject(null);
setProjectStructureOrg(null); setProjectStructureOrg(null);
setCompany(""); setCompany("");
setCompanyId(null)
setCurrency(""); setCurrency("");
setCurrencyCode(""); setCurrencyCode("");
setCurrencySymbol(null); setCurrencySymbol(null);
@ -276,7 +281,7 @@ const DialogFormProyek = ({
currency_symbol: currencySymbol, currency_symbol: currencySymbol,
currency_code: currencyCode, currency_code: currencyCode,
currency_name: currencyName, 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.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval };
data.imageStructureOrg = organization ? organization : null; data.imageStructureOrg = organization ? organization : null;
@ -307,7 +312,7 @@ const DialogFormProyek = ({
currency_symbol: currencySymbol, currency_symbol: currencySymbol,
currency_code: currencyCode, currency_code: currencyCode,
currency_name: currencyName, 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.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval };
data.imageStructureOrg = organization ? organization : null; data.imageStructureOrg = organization ? organization : null;
@ -326,6 +331,10 @@ const DialogFormProyek = ({
setTypeproject(val); setTypeproject(val);
}; };
const onChangeCompanyProject = (val) => {
setCompanyId(val);
};
const onChangePhaseProject = (val) => { const onChangePhaseProject = (val) => {
setPhaseProject(val); setPhaseProject(val);
}; };
@ -404,6 +413,10 @@ const DialogFormProyek = ({
alert("End Date cannot be empty!"); alert("End Date cannot be empty!");
return false; return false;
} }
if (role_name === 'Super Admin' && !scompany_id || scompany_id === "") {
alert("Company data cannot be empty!");
return false;
}
if (!biaya || biaya === "") { if (!biaya || biaya === "") {
alert("Budget cannot be empty!"); alert("Budget cannot be empty!");
return false; return false;
@ -754,16 +767,31 @@ const DialogFormProyek = ({
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col md={6}> {
<FormGroup> role_name === 'Super Admin' && (
<Label className="capitalize" style={{ fontWeight: "bold" }}>Work Area</Label> <Col md={6}>
<Input <FormGroup>
type="text" <Label className="capitalize" style={{ fontWeight: "bold" }}>Assign Company Project<span style={{ color: "red" }}>*</span></Label>
value={workArea} <Select
onChange={(e) => setWorkArea(e.target.value)} showSearch
/> filterOption={(inputValue, option) =>
</FormGroup> option.children.toLowerCase().includes(inputValue.toLowerCase())
</Col> }
value={scompany_id}
defaultValue={scompany_id}
onChange={onChangeCompanyProject}
style={{ width: "100%" }}
>
{companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
<Col md={6}> <Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Company</Label> <Label className="capitalize" style={{ fontWeight: "bold" }}>Company</Label>
@ -774,9 +802,7 @@ const DialogFormProyek = ({
/> />
</FormGroup> </FormGroup>
</Col> </Col>
</Row> <Col md={6}>
<Row>
<Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}> <Label className="capitalize" style={{ fontWeight: "bold" }}>
Budget<span style={{ color: "red" }}>*</span> Budget<span style={{ color: "red" }}>*</span>
@ -804,6 +830,16 @@ const DialogFormProyek = ({
</Row> </Row>
</FormGroup> </FormGroup>
</Col> </Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Work Area</Label>
<Input
type="text"
value={workArea}
onChange={(e) => setWorkArea(e.target.value)}
/>
</FormGroup>
</Col>
</Row> </Row>
<Row> <Row>
<Col md={6}> <Col md={6}>

347
src/views/SimproV2/CreatedProyek/index.js

@ -36,6 +36,7 @@ import {
PROJECT_TYPE_SEARCH, PROJECT_TYPE_SEARCH,
PROYEK_ADD, PROYEK_ADD,
PROYEK_SEARCH, PROYEK_SEARCH,
COMPANY_MANAGEMENT_LIST,
PROYEK_EDIT, PROYEK_EDIT,
ASSIGN_HR_PROJECT_SEARCH, ASSIGN_HR_PROJECT_SEARCH,
PROJECT_CHECKLIST_SEARCH, PROJECT_CHECKLIST_SEARCH,
@ -80,28 +81,24 @@ import ReportAnalysis from "./ReportAnalysis";
import { Icon } from "@iconify/react"; import { Icon } from "@iconify/react";
// import SubProyekComp from './SubProyekComp'; // import SubProyekComp from './SubProyekComp';
import { Link, useHistory, withRouter } from "react-router-dom"; import { Link, useHistory, withRouter } from "react-router-dom";
import { t } from "i18next";
const url = ""; const url = "";
const format = "DD-MM-YYYY"; const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => { const CreatedProyek = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
company_id = props.location.state.company_id; company_id = props.company_id;
all_project = props.location.state.all_project; all_project = props.all_project;
role_name = props.role_name;
} else { isLogin = props.isLogin;
role_id = localStorage.getItem("role_id"); hierarchy = props.hierarchy;
proyek_id = localStorage.getItem("proyek_id"); user_name = props.user_name;
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');
} }
const history = useHistory(); const history = useHistory();
const HEADER = { const HEADER = {
@ -121,6 +118,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [idTask, setidTask] = useState(0); const [idTask, setidTask] = useState(0);
const [projectId, setProjectId] = useState(0); const [projectId, setProjectId] = useState(0);
const [dataTable, setDatatable] = useState([]); const [dataTable, setDatatable] = useState([]);
const [companyList, setDataCompany] = useState([]);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const [totalPage, setTotalPage] = useState(0); const [totalPage, setTotalPage] = useState(0);
@ -198,6 +196,9 @@ const CreatedProyek = ({ params, ...props }) => {
handleGetPhaseProject(); handleGetPhaseProject();
handleGetDivisions(); handleGetDivisions();
handleGetDataPm(); handleGetDataPm();
if(role_name === 'Super Admin') {
getDataProyekCompany();
}
} }
}, [openDialogProyek]); }, [openDialogProyek]);
@ -229,33 +230,36 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetTipeProject = async () => { const handleGetTipeProject = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER) .post(PROJECT_TYPE_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
setDataTypeProyek(result.data.data); setDataTypeProyek(result.data.data);
} else {
} }
}; };
const handleGetPhaseProject = async () => { const handleGetPhaseProject = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(PROJECT_PHASE_SEARCH, payload, HEADER) .post(PROJECT_PHASE_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -268,13 +272,15 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetDivisions = async () => { const handleGetDivisions = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(DIVISI_SEARCH, payload, HEADER) .post(DIVISI_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -289,13 +295,15 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetDataPm = async () => { const handleGetDataPm = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(USER_SEARCH, payload, HEADER) .post(USER_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -307,6 +315,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 handleDashboard = async (id) => {
const URL = `${BASE_OSPRO}/api/project/detail/${id}`; const URL = `${BASE_OSPRO}/api/project/detail/${id}`;
const result = await axios const result = await axios
@ -335,21 +359,35 @@ const CreatedProyek = ({ params, ...props }) => {
const getDataProyek = async () => { const getDataProyek = async () => {
setLoading(true); setLoading(true);
let start = 0; let start = 0;
let hierarchy = [];
hierarchy.push(JSON.parse(localStorage.getItem("hierarchy")));
if (currentPage !== 1 && currentPage > 1) { if (currentPage !== 1 && currentPage > 1) {
start = currentPage * rowsPerPage - rowsPerPage; start = currentPage * rowsPerPage - rowsPerPage;
} }
const payload = { const payload = {
columns: [ columns: [],
{ group_column: {
name: "nama", "operator": "AND",
logic_operator: "ilike", "group_operator": "OR",
value: search, "where": [
operator: "AND", {
}, "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: [ select: [
"id", "id",
"nama", "nama",
@ -369,21 +407,28 @@ const CreatedProyek = ({ params, ...props }) => {
name: "m_type_proyek", name: "m_type_proyek",
column_join: "type_proyek_id", column_join: "type_proyek_id",
column_results: ["name", "description"], 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 }, orders: { columns: ["nama"], ascending: true },
paging: { start: start, length: rowsPerPage }, paging: { start: start, length: rowsPerPage },
}; };
if (all_project !== null && all_project === true) { if (all_project !== null && all_project === true) {
payload["columns"] = [ payload.columns.push(
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
]; );
}
if (role_name !== 'Super Admin') {
payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
);
} else { } else {
payload["columns"] = [ payload.joins.push(
{ name: "created_by_id", logic_operator: "IN", value: hierarchy, operator: "AND" } { 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 const result = await axios
@ -512,7 +557,6 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
const handleOpenDialogGantt = (data) => { const handleOpenDialogGantt = (data) => {
console.log('data.mulai_proyek', data.mulai_proyek);
setDataViewStartDate(data.mulai_proyek) setDataViewStartDate(data.mulai_proyek)
setidTask(data.id); setidTask(data.id);
setProyekName(data.nama); setProyekName(data.nama);
@ -569,7 +613,6 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenDialogViewDetail = async (data) => { const handleOpenDialogViewDetail = async (data) => {
setLoading(true); setLoading(true);
setidTask(data.id); setidTask(data.id);
// setDataView(data)
await getDataProject(data.id); await getDataProject(data.id);
await getProjectMilestone(data.id); await getProjectMilestone(data.id);
await getProjectParticipant(data.id); await getProjectParticipant(data.id);
@ -580,7 +623,6 @@ const CreatedProyek = ({ params, ...props }) => {
await getK3toProject(data.id); await getK3toProject(data.id);
await getProjectAssignHR(data.id); await getProjectAssignHR(data.id);
await getProjectImage(data.id); await getProjectImage(data.id);
// await handleGetDataPm(data.id);
setPM(data.join_first_name); setPM(data.join_first_name);
setOpenDialogViewDetail(true); setOpenDialogViewDetail(true);
}; };
@ -679,7 +721,6 @@ const CreatedProyek = ({ params, ...props }) => {
orders: { columns: ["id"], ascending: true }, orders: { columns: ["id"], ascending: true },
paging: { start: 0, length: -1 }, paging: { start: 0, length: -1 },
}; };
// const url = PROJECT_MI(proyek_id)
const result = await axios const result = await axios
.post(PROJECT_MILESTONE_SEARCH, payload, HEADER) .post(PROJECT_MILESTONE_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -718,7 +759,6 @@ const CreatedProyek = ({ params, ...props }) => {
orders: { columns: ["id"], ascending: true }, orders: { columns: ["id"], ascending: true },
paging: { start: 0, length: -1 }, paging: { start: 0, length: -1 },
}; };
// const url = PROJECT_MI(proyek_id)
const result = await axios const result = await axios
.post(ASSIGN_HR_PROJECT_SEARCH, payload, HEADER) .post(ASSIGN_HR_PROJECT_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -1313,13 +1353,6 @@ const CreatedProyek = ({ params, ...props }) => {
const arr = await Promise.all(request) const arr = await Promise.all(request)
.then((values) => values) .then((values) => values)
.catch((err) => err.response); .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) => { const handleDelete = async (id) => {
@ -1337,15 +1370,40 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportExcel = async () => { const handleExportExcel = async () => {
const payload = { const payload = {
columns: [],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "nama",
"logic_operator": "~*",
"value": search,
}
]
},
paging: { start: 0, length: -1 }, paging: { start: 0, length: -1 },
joins: [], joins: [],
orders: { columns: ["id"], ascending: false }, orders: { columns: ["id"], ascending: false },
}; };
if (parseInt(role_id) !== 1) { if (all_project !== null && all_project === true) {
payload["columns"] = [ payload.columns.push(
{ name: "id", logic_operator: "=", value: proyek_id, operator: "AND" }, { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
]; );
}
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 const result = await axios
@ -1357,30 +1415,33 @@ const CreatedProyek = ({ params, ...props }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((n, index) => { resData.map((n, index) => {
let dataRow = { let dataRow = {};
Sortname: n.kode_sortname ? n.kode_sortname : "", if (role_name === 'Super Admin') {
"Nama Project": n.nama ? n.nama : "", dataRow.Company = n.join_first_company_name;
"Tanggal Mulai": n.mulai_proyek }
? moment(n.mulai_proyek).format(format) dataRow.Sortname = n.kode_sortname ? n.kode_sortname : "";
: "-", dataRow["Nama Project"] = n.nama ? n.nama : "";
"Tanggal Selesai": n.akhir_proyek dataRow["Tanggal Mulai"] = n.mulai_proyek
? moment(n.akhir_proyek).format(format) ? moment(n.mulai_proyek).format(format)
: "-", : "-";
"Area Kerja": n.area_kerja ? n.area_kerja : "", dataRow["Tanggal Selesai"] = n.akhir_proyek
Perusahaan: n.company ? n.company : "", ? moment(n.akhir_proyek).format(format)
Keterangan: n.keterangan ? n.keterangan : "", : "-";
"Dianggap sukses ketika": n.considered_success_when dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : "";
? n.considered_success_when dataRow["Perusahaan"] = n.company ? n.company : "";
: "", dataRow["Keterangan"] = n.keterangan ? n.keterangan : "";
"Tujuan Proyek": n.project_objectives ? n.project_objectives : "", dataRow["Dianggap sukses ketika"] = n.considered_success_when
"Resiko potensial": n.potential_risk ? n.potential_risk : "", ? n.considered_success_when
"Rencana Biaya": n.rencana_biaya : "";
? formatThousand(n.rencana_biaya) dataRow["Tujuan Proyek"] = n.project_objectives ? n.project_objectives : "";
: "-", dataRow["Resiko potensial"] = n.potential_risk ? n.potential_risk : "";
"Testing Environment": n.testing_environment dataRow["Rencana Biaya"] = n.rencana_biaya
? n.testing_environment ? formatThousand(n.rencana_biaya)
: "-", : "-";
}; dataRow["Testing Environment"] = n.testing_environment
? n.testing_environment
: "-";
excelData.push(dataRow); excelData.push(dataRow);
}); });
await setDataExport(excelData); await setDataExport(excelData);
@ -1391,19 +1452,35 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportPdf = async () => { const handleExportPdf = async () => {
const doc = new jsPDF(); const doc = new jsPDF();
let headers = [
const headers = [ [role_name === 'Super Admin' ? "Company" : null, "Project Name", "Budget", "Project Type", "PM", "Time Project"],
["Project Name", "Budget", "Project Type", "PM", "Time Project"],
]; ];
const payload = { const payload = {
columns: [ columns: [],
{ group_column: {
name: "nama", "operator": "AND",
logic_operator: "ilike", "group_operator": "OR",
value: search, "where": [
operator: "AND", {
}, "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: [ joins: [
{ {
name: "m_users", name: "m_users",
@ -1415,11 +1492,28 @@ const CreatedProyek = ({ params, ...props }) => {
column_join: "type_proyek_id", column_join: "type_proyek_id",
column_results: ["name", "description"], 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 }, 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" }
);
}
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 const result = await axios
.post(PROYEK_SEARCH, payload, HEADER) .post(PROYEK_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -1427,6 +1521,7 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
let resData = result.data.data; let resData = result.data.data;
const data = resData.map((elt) => [ const data = resData.map((elt) => [
role_name === 'Super Admin' ? elt.join_third_company_name : null,
elt.nama, elt.nama,
`Rp. ${formatThousand(elt.rencana_biaya)}`, `Rp. ${formatThousand(elt.rencana_biaya)}`,
elt.join_second_name, elt.join_second_name,
@ -1447,34 +1542,6 @@ const CreatedProyek = ({ params, ...props }) => {
}); });
} }
doc.save("Project.pdf"); 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 = () => { const exportExcel = () => {
@ -1688,12 +1755,20 @@ const CreatedProyek = ({ params, ...props }) => {
</> </>
), ),
}, },
...(role_name === 'Super Admin' ? [
{
title: t('company'),
dataIndex: "join_third_company_name",
key: "join_third_company_name",
render: (text, record) => (
<span>{record.join_third_company_name}</span>
)
}] : []),
{ title: "Project Name", dataIndex: "nama", key: "nama" }, { title: "Project Name", dataIndex: "nama", key: "nama" },
{ {
title: "Budget", title: "Budget",
dataIndex: "rencana_biaya", dataIndex: "rencana_biaya",
key: "rencana_biaya", key: "rencana_biaya",
// render: (text, record) => { return renderFormatRupiah(text, "Rp") }
render: (text, record) => { render: (text, record) => {
return record.currency_symbol return record.currency_symbol
? `${record.currency_symbol} ${formatThousand(text)}` ? `${record.currency_symbol} ${formatThousand(text)}`
@ -1799,6 +1874,8 @@ const CreatedProyek = ({ params, ...props }) => {
dataPM={dataPm} dataPM={dataPm}
projectImage={image} projectImage={image}
company_id={company_id} company_id={company_id}
role_name={role_name}
companyList={companyList}
/> />
), ),
[ [
@ -2022,7 +2099,7 @@ const CreatedProyek = ({ params, ...props }) => {
type="text" type="text"
name="search" name="search"
id="search" id="search"
placeholder={`Search Project Name`} placeholder={`Search...`}
style={{ width: 200 }} style={{ width: 200 }}
/> />
</Col> </Col>
@ -2039,7 +2116,6 @@ const CreatedProyek = ({ params, ...props }) => {
)} )}
<Tooltip title="Export"> <Tooltip title="Export">
<Popover <Popover
// content={<a onClick={hide}>Close</a>}
title="Export" title="Export"
trigger="click" trigger="click"
placement="leftBottom" placement="leftBottom"
@ -2064,12 +2140,9 @@ const CreatedProyek = ({ params, ...props }) => {
</Button> </Button>
</> </>
} }
// visible={visible}
// onVisibleChange={handleVisibleChange}
> >
<Button <Button
style={{ marginLeft: "5px" }} style={{ marginLeft: "5px" }}
// onClick={() => handleExportExcel()}
> >
<i className="fa fa-print"></i> <i className="fa fa-print"></i>
</Button> </Button>

47
src/views/SimproV2/Divisi/DialogForm.js

@ -10,12 +10,13 @@ import InputColor from "./InputColor";
import "./styles.css"; import "./styles.css";
import "rc-color-picker/assets/index.css"; import "rc-color-picker/assets/index.css";
const { Option } = Select 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 [id, setId] = useState(0)
const [name, setName] = useState('') const [name, setName] = useState('')
const [parent, setParent] = useState(null) const [parent, setParent] = useState(null)
const [description, setDescription] = useState('') const [description, setDescription] = useState('')
const [color, setColor] = useState('') const [color, setColor] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation() const { t } = useTranslation()
const onChangeParent = (val) => { const onChangeParent = (val) => {
@ -29,6 +30,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setName(dataEdit.name) setName(dataEdit.name)
setParent(dataEdit.parent) setParent(dataEdit.parent)
setColor(dataEdit.color) setColor(dataEdit.color)
setSelectedCompany(dataEdit.company_id);
} else { } else {
setId(0) setId(0)
setColor('') setColor('')
@ -47,22 +49,28 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
if (!err) { if (!err) {
if (typeDialog === "Save") { if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
name, name,
description, description,
parent, parent,
color, color,
company_id company_id: company_id
} }
closeDialog('save', data); closeDialog('save', data);
} else { } else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
id, id,
name, name,
description, description,
parent, parent,
color, color,
company_id company_id: company_id
} }
closeDialog('edit', data); closeDialog('edit', data);
} }
@ -71,6 +79,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setName('') setName('')
setParent(null) setParent(null)
setColor('') setColor('')
setSelectedCompany(null)
} }
} }
const handleCancel = () => { const handleCancel = () => {
@ -79,8 +88,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setDescription('') setDescription('')
setName('') setName('')
setParent(null) setParent(null)
setSelectedCompany(null)
} }
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => { const renderForm = () => {
return ( return (
<Form> <Form>
@ -133,6 +147,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
{role_name === 'Super Admin' &&
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
}
</Form> </Form>
) )
} }

161
src/views/SimproV2/Divisi/index.js

@ -4,35 +4,27 @@ import React, { useState, useEffect } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; 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 { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
{ name: "Color" },
]
const ProjectType = ({ params, ...props }) => { const ProjectType = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -55,8 +47,14 @@ const ProjectType = ({ params, ...props }) => {
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [dataDivisions, setDataDivisions] = useState([]) const [dataDivisions, setDataDivisions] = useState([])
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() 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(() => { useEffect(() => {
getDataProjectType(); getDataProjectType();
}, [currentPage, rowsPerPage, search]) }, [currentPage, rowsPerPage, search])
@ -67,9 +65,34 @@ const ProjectType = ({ params, ...props }) => {
exportExcel() exportExcel()
} }
}, [dataExport]) }, [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 getListDivision = async () => {
const payload = { const payload = {
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
columns: [], columns: [],
"orders": { "orders": {
"ascending": true, "ascending": true,
@ -80,7 +103,8 @@ const ProjectType = ({ params, ...props }) => {
"paging": { "paging": {
"length": 0, "length": 0,
"start": -1 "start": -1
} },
'joins': []
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
@ -91,6 +115,12 @@ const ProjectType = ({ params, ...props }) => {
payload.columns.push( 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"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
const listDivions = await axios const listDivions = await axios
.post(DIVISI_SEARCH, payload, HEADER) .post(DIVISI_SEARCH, payload, HEADER)
@ -115,14 +145,18 @@ const ProjectType = ({ params, ...props }) => {
start = currentPage * rowsPerPage - rowsPerPage; start = currentPage * rowsPerPage - rowsPerPage;
} }
const payload = { const payload = {
columns: [ group_column: {
{ "operator": "AND",
name: "name", "group_operator": "OR",
logic_operator: "ilike", "where": [
value: search, {
operator: "AND" "name": "name",
}, "logic_operator": "~*",
], "value": search,
}
]
},
columns: [],
"orders": { "orders": {
"ascending": true, "ascending": true,
"columns": [ "columns": [
@ -132,7 +166,8 @@ const ProjectType = ({ params, ...props }) => {
"paging": { "paging": {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "start": start
} },
'joins': []
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
@ -143,6 +178,12 @@ const ProjectType = ({ params, ...props }) => {
payload.columns.push( 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"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
.post(DIVISI_SEARCH, payload, HEADER) .post(DIVISI_SEARCH, payload, HEADER)
@ -165,14 +206,18 @@ const ProjectType = ({ params, ...props }) => {
} }
const payload = { const payload = {
"columns": [ group_column: {
{ "operator": "AND",
"name": "name", "group_operator": "OR",
"logic_operator": "like", "where": [
"value": search, {
"operator": "AND" "name": "name",
} "logic_operator": "~*",
], "value": search,
}
]
},
"columns": [],
"orders": { "orders": {
"ascending": true, "ascending": true,
"columns": [ "columns": [
@ -182,9 +227,24 @@ const ProjectType = ({ params, ...props }) => {
"paging": { "paging": {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "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 const result = await axios
.post(DIVISI_SEARCH, payload, HEADER) .post(DIVISI_SEARCH, payload, HEADER)
.then(res => res) .then(res => res)
@ -193,10 +253,12 @@ const ProjectType = ({ params, ...props }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((val, index) => { resData.map((val, index) => {
let dataRow = { let dataRow = {};
"Nama Divisi": val.name, if (role_name === 'Super Admin') {
"Deskripsi": val.description, dataRow.Company = val.join_first_company_name;
} }
dataRow["Nama Divisi"] = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData) await setDataExport(excelData)
@ -345,6 +407,8 @@ const ProjectType = ({ params, ...props }) => {
dataParent={allDataMenu} dataParent={allDataMenu}
dataDivisions={dataDivisions} dataDivisions={dataDivisions}
company_id={company_id} company_id={company_id}
listCompany={listCompany}
role_name={role_name}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -388,6 +452,11 @@ const ProjectType = ({ params, ...props }) => {
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
{role_name === 'Super Admin' &&
(
<td>{n.join_first_company_name}</td>
)
}
<td>{n.name}</td> <td>{n.name}</td>
<td>{n.description ?? '-'}</td> <td>{n.description ?? '-'}</td>
{n.color != null ? ( {n.color != null ? (

19
src/views/SimproV2/Gantt/GanttFrame.js

@ -3,23 +3,10 @@ import { useHistory, withRouter } from 'react-router-dom';
import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
const GanttFrame = React.memo((props) => { 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 history = useHistory();
const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, company_id, role_name } = props;
const { versionGanttId, idProject, ro, timestamp } = 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}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`;
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}&timestamp=${timestamp}`; // 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}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`;
const [batchEntityData, setBatchEntityData] = useState(null); const [batchEntityData, setBatchEntityData] = useState(null);

29
src/views/SimproV2/Gantt/index.js

@ -15,18 +15,18 @@ import GanttFrame from "./GanttFrame";
let roCount = 0; let roCount = 0;
const Gantt = (props) => { const Gantt = (props) => {
let role_id = '', userId = '', isLogin = '', token = ''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
userId = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
} else { company_id = props.company_id;
role_id = localStorage.getItem("role_id"); all_project = props.all_project;
userId = localStorage.getItem("user_id"); role_name = props.role_name;
token = localStorage.getItem("token"); isLogin = props.isLogin;
isLogin = localStorage.getItem("isLogin"); hierarchy = props.hierarchy;
user_name = props.user_name;
} }
const HEADER = { const HEADER = {
headers: { headers: {
@ -39,7 +39,6 @@ const Gantt = (props) => {
const timestamp = props.match.params.timestamp const timestamp = props.match.params.timestamp
? props.match.params.timestamp ? props.match.params.timestamp
: 0; : 0;
const [ro, setRo] = useState(1); const [ro, setRo] = useState(1);
const [listUserGant, setListUserGantt] = useState([]); const [listUserGant, setListUserGantt] = useState([]);
const [ready, setReady] = useState(false); const [ready, setReady] = useState(false);
@ -93,7 +92,7 @@ const Gantt = (props) => {
}; };
const cekPermission = () => { const cekPermission = () => {
let check = listUserGant.includes(parseInt(userId)); let check = listUserGant.includes(parseInt(user_id));
if (check) { if (check) {
setRo(0); setRo(0);
} else { } else {
@ -114,6 +113,8 @@ const Gantt = (props) => {
idProject={idProject} idProject={idProject}
token={token} token={token}
ro={ro} ro={ro}
role_name={role_name}
company_id={company_id}
timestamp={timestamp} timestamp={timestamp}
/> />
)} )}

16
src/views/SimproV2/PanicButton/index.js

@ -60,6 +60,7 @@ class index extends Component {
totalPage: 0, totalPage: 0,
typeClock: "All", typeClock: "All",
typeDialog: 'Save', 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 const result = await axios
.post(PANIC_BUTTON_SEARCH, payload, config) .post(PANIC_BUTTON_SEARCH, payload, config)
.then(res => res) .then(res => res)
@ -275,6 +285,9 @@ class index extends Component {
<i id="tooltipMap" className="fa fa-map" style={{ color: 'black', cursor: "pointer" }} onClick={() => this.handleMap(n)}></i> <i id="tooltipMap" className="fa fa-map" style={{ color: 'black', cursor: "pointer" }} onClick={() => this.handleMap(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
{this.state.role_name === 'Super Admin' &&
<td>{n.join_second_company_name ? n.join_second_company_name : "-"}</td>
}
<td>{n.created_at !== null ? moment(n.created_at).format("DD-MM-YYYY HH:mm:ss") : "-"}</td> <td>{n.created_at !== null ? moment(n.created_at).format("DD-MM-YYYY HH:mm:ss") : "-"}</td>
<td>{n.join_first_name !== null ? n.join_first_name : "-"}</td> <td>{n.join_first_name !== null ? n.join_first_name : "-"}</td>
<td>{n.status_response !== null ? n.status_response : "-"}</td> <td>{n.status_response !== null ? n.status_response : "-"}</td>
@ -321,10 +334,11 @@ class index extends Component {
render() { render() {
const column = [ const column = [
{ name: this.props.t('action') }, { 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('date') },
{ name: this.props.t('nameHR') }, { name: this.props.t('nameHR') },
{ name: this.props.t('statusResponse') }, { name: this.props.t('statusResponse') },
] ].filter(column => column && column.name);
const t = this.props; const t = this.props;
const { tooltipExport, dataTable, openDialogEdit, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipMap, tooltipDelete } = this.state const { tooltipExport, dataTable, openDialogEdit, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipMap, tooltipDelete } = this.state
return ( return (

39
src/views/SimproV2/Presence/index.js

@ -10,10 +10,22 @@ import { PRESENCE_SEARCH, IMAGE_GET_BY_ID } from '../../../const/ApiConst.js';
import DialogFoto from './DialogFoto'; import DialogFoto from './DialogFoto';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const token = window.localStorage.getItem('token');
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 Index = ({ params }) => {
const [dataTable, setDatatable] = useState([]) const [dataTable, setDatatable] = useState([])
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1) const [currentPage, setCurrentPage] = useState(1)
@ -54,8 +66,6 @@ const Index = ({ params }) => {
}; };
const getDataPresence = async () => { const getDataPresence = async () => {
let start = 0; let start = 0;
if (currentPage !== 1 && currentPage > 1) { if (currentPage !== 1 && currentPage > 1) {
@ -82,6 +92,15 @@ const Index = ({ params }) => {
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
@ -234,6 +253,18 @@ const Index = ({ params }) => {
</Tooltip> </Tooltip>
</>, </>,
}, },
...(role_name === 'Super Admin'
? [
{
title: t('company'),
dataIndex: "join_second_company_name",
key: "join_second_company_name",
render: (text, record) => (
<span>{record.join_second_company_name}</span>
)
},
]
: []),
{ title: t('nik'), dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' }, { 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('nameHR'), dataIndex: 'join_first_name', key: 'join_first_name' },
{ title: t('presenceIn'), dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) }, { title: t('presenceIn'), dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) },

58
src/views/SimproV2/ProjectType/DialogForm.js

@ -3,20 +3,19 @@ import {
Modal, ModalHeader, ModalBody, ModalFooter, Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap'; } from 'reactstrap';
import { DatePicker, Tooltip, Select } from 'antd'; import { Select } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import moment from 'moment'; import moment from 'moment';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { Option } = Select 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 [id, setId] = useState(0)
const [projectType, setProjectType] = useState('') const [projectType, setProjectType] = useState('')
const [uom, setUom] = useState('') const [uom, setUom] = useState('')
const [description, setDescription] = useState('') const [description, setDescription] = useState('')
const [unitPrice, setUnitPrice] = useState() const [unitPrice, setUnitPrice] = useState()
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation(); const { t } = useTranslation();
@ -28,7 +27,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setUnitPrice(dataEdit.unit_price) setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom) setUom(dataEdit.uom)
setProjectType(dataEdit.name) setProjectType(dataEdit.name)
setSelectedCompany(dataEdit.company_id)
} else { } else {
setId(0) setId(0)
} }
@ -37,39 +36,43 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => { const handleSave = () => {
let data = ''; let data = '';
if (typeDialog === "Save") { if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
name: projectType, name: projectType,
description, description,
company_id company_id: company_id
} }
closeDialog('save', data); closeDialog('save', data);
} else { } else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
id, id,
name: projectType, name: projectType,
description, description,
company_id company_id: company_id
} }
closeDialog('edit', data); closeDialog('edit', data);
} }
setId(0) setId(0)
setDescription('') setDescription('')
setSelectedCompany(null)
} }
const handleCancel = () => { const handleCancel = () => {
closeDialog('cancel', 'none') closeDialog('cancel', 'none')
setId(0) setId(0)
setDescription('') setDescription('')
setSelectedCompany(null)
} }
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => { const renderForm = () => {
return ( return (
@ -88,6 +91,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
{role_name === 'Super Admin' &&
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
}
</Form> </Form>
) )
} }

137
src/views/SimproV2/ProjectType/index.js

@ -8,26 +8,24 @@ import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons'; import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications'; 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 { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const ProjectType = ({ params, ...props }) => { const ProjectType = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {
headers: { headers: {
@ -52,6 +50,7 @@ const ProjectType = ({ params, ...props }) => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation(); const { t } = useTranslation();
useEffect(() => { useEffect(() => {
getDataProjectType() getDataProjectType()
@ -64,6 +63,21 @@ const ProjectType = ({ params, ...props }) => {
} }
}, [dataExport]) }, [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 () => { const getDataProjectType = async () => {
let start = 0; let start = 0;
@ -73,14 +87,18 @@ const ProjectType = ({ params, ...props }) => {
} }
const payload = { const payload = {
"columns": [ group_column: {
{ "operator": "AND",
"name": "name", "group_operator": "OR",
"logic_operator": "like", "where": [
"value": search, {
"operator": "AND" "name": "name",
} "logic_operator": "~*",
], "value": search,
}
]
},
"columns": [],
"orders": { "orders": {
"ascending": false, "ascending": false,
"columns": [ "columns": [
@ -90,7 +108,8 @@ const ProjectType = ({ params, ...props }) => {
"paging": { "paging": {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "start": start
} },
'joins': []
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.columns.push( payload.columns.push(
@ -100,6 +119,12 @@ const ProjectType = ({ params, ...props }) => {
payload.columns.push( 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"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER) .post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER)
@ -133,14 +158,18 @@ const ProjectType = ({ params, ...props }) => {
} }
const payload = { const payload = {
"columns": [ group_column: {
{ "operator": "AND",
"name": "name", "group_operator": "OR",
"logic_operator": "like", "where": [
"value": search, {
"operator": "AND" "name": "name",
} "logic_operator": "~*",
], "value": search,
}
]
},
"columns": [],
"orders": { "orders": {
"ascending": true, "ascending": true,
"columns": [ "columns": [
@ -150,9 +179,24 @@ const ProjectType = ({ params, ...props }) => {
"paging": { "paging": {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "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 const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER) .post(PROJECT_TYPE_SEARCH, payload, HEADER)
@ -163,10 +207,12 @@ const ProjectType = ({ params, ...props }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((val, index) => { resData.map((val, index) => {
let dataRow = { let dataRow = {};
"Nama": val.name, if (role_name === 'Super Admin') {
"Deskripsi": val.description, dataRow.Company = val.join_first_company_name;
} }
dataRow.Nama = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
@ -317,6 +363,16 @@ const ProjectType = ({ params, ...props }) => {
</Tooltip> </Tooltip>
</>, </>,
}, },
...(role_name === 'Super Admin' ? [
{
title: t('company'),
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => (
<span>{record.join_first_company_name}</span>
)
}] : []),
{ title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: t('description'), dataIndex: 'description', key: 'description' }, { title: t('description'), dataIndex: 'description', key: 'description' },
]; ];
@ -355,6 +411,9 @@ const ProjectType = ({ params, ...props }) => {
dataEdit={dataEdit} dataEdit={dataEdit}
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataParent={allDataMenu} dataParent={allDataMenu}
listCompany={listCompany}
company_id={company_id}
role_name={role_name}
/> />
<DialogInitialGantt <DialogInitialGantt
openDialog={openDialogIG} openDialog={openDialogIG}
@ -367,7 +426,7 @@ const ProjectType = ({ params, ...props }) => {
<h4 className="capitalize">{pageName}</h4> <h4 className="capitalize">{pageName}</h4>
<Row> <Row>
<Col> <Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchType')} /> <Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('search')} />
</Col> </Col>
<Col> <Col>
<Tooltip title={t('projectType')}> <Tooltip title={t('projectType')}>

63
src/views/SimproV2/ResourceWorker/DialogForm.js

@ -7,21 +7,10 @@ import { DatePicker, Tooltip, Select, Input as InputAntd } from 'antd';
import moment from 'moment'; import moment from 'moment';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc' import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import { ROLE_SEARCH } from '../../../const/ApiConst'
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { Option } = Select const { Option } = Select
const token = window.localStorage.getItem('token'); const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => {
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 [openDialogMap, setOpenDialogMap] = useState(false) const [openDialogMap, setOpenDialogMap] = useState(false)
const [id, setId] = useState(0) const [id, setId] = useState(0)
@ -39,6 +28,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [ktpNumber, setKtpNumber] = useState('') const [ktpNumber, setKtpNumber] = useState('')
const [biayaPerJam, setBiayaPerJam] = useState('') const [biayaPerJam, setBiayaPerJam] = useState('')
const [roleId, setRoleId] = useState('') const [roleId, setRoleId] = useState('')
const [scompany_id, setCompanyId] = useState(null);
const [address, setAddress] = useState('') const [address, setAddress] = useState('')
const [divisionId, setDivisionId] = useState('') const [divisionId, setDivisionId] = useState('')
const [statusResource, setStatusResource] = useState('active') const [statusResource, setStatusResource] = useState('active')
@ -55,6 +45,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setPhoneNo(dataEdit.phone_number) setPhoneNo(dataEdit.phone_number)
setEmail(dataEdit.email) setEmail(dataEdit.email)
setGender(dataEdit.gender) setGender(dataEdit.gender)
setCompanyId(dataEdit.company_id)
setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "") setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "")
setBirthPlace(dataEdit.birth_place) setBirthPlace(dataEdit.birth_place)
setBloodType(dataEdit.blood_type) setBloodType(dataEdit.blood_type)
@ -82,6 +73,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setRoleId('') setRoleId('')
setDivisionId('') setDivisionId('')
setAddress('') setAddress('')
setCompanyId(null)
setStatusResource('active') setStatusResource('active')
setStatusRestriction(false) setStatusRestriction(false)
} }
@ -117,7 +109,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
address, address,
status_resource: statusResource, status_resource: statusResource,
status_boundary: statusRestriction, status_boundary: statusRestriction,
company_id: company_id company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
} }
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
@ -165,7 +157,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
address, address,
status_resource: statusResource, status_resource: statusResource,
status_boundary: statusRestriction, status_boundary: statusRestriction,
company_id: company_id company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
} }
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
@ -176,6 +168,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
} }
} }
const onChangeCompanyProject = (val) => {
setCompanyId(val);
};
const handleCancel = () => { const handleCancel = () => {
closeDialog('cancel', 'none') closeDialog('cancel', 'none')
} }
@ -307,13 +303,31 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</Row> </Row>
<Row> <Row>
<Col md={6}> {
<Label className="capitalize">Status</Label> role_name === 'Super Admin' && (
<Select style={{ width: "100%" }} defaultValue={statusResource} onChange={(e) => setStatusResource(e)}> <Col md={6}>
<Option value={'active'}>Active</Option> <FormGroup>
<Option value={'inactive'}>Inactive</Option> <Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
</Select> <Select
</Col> showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={scompany_id}
defaultValue={scompany_id}
onChange={onChangeCompanyProject}
style={{ width: "100%" }}
>
{companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
<Col md={6}> <Col md={6}>
<Label className="capitalize">{t('restrictions')}</Label> <Label className="capitalize">{t('restrictions')}</Label>
<Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}> <Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}>
@ -321,6 +335,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Option value={false}>Tidak</Option> <Option value={false}>Tidak</Option>
</Select> </Select>
</Col> </Col>
<Col md={6}>
<Label className="capitalize">Status</Label>
<Select style={{ width: "100%" }} defaultValue={statusResource} onChange={(e) => setStatusResource(e)}>
<Option value={'active'}>Active</Option>
<Option value={'inactive'}>Inactive</Option>
</Select>
</Col>
<Col md={6}> <Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('address')}</Label> <Label className="capitalize">{t('address')}</Label>

97
src/views/SimproV2/ResourceWorker/index.js

@ -10,26 +10,23 @@ import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip, Spin } from 'antd'; import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
import { 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'; } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const ResourceWorker = ({ params, ...props }) => { const ResourceWorker = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {
@ -46,6 +43,7 @@ const ResourceWorker = ({ params, ...props }) => {
const [dataExport, setDataExport] = useState([]) const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([]) const [dataTable, setDatatable] = useState([])
const [divisiList, setDivisiList] = useState([]) const [divisiList, setDivisiList] = useState([])
const [companyList, setDataCompany] = useState([]);
const [idDelete, setIdDelete] = useState(0) const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false) const [openDialog, setOpenDialog] = useState(false)
const [openDialogShift, setOpenDialogShift] = useState(false) const [openDialogShift, setOpenDialogShift] = useState(false)
@ -62,6 +60,9 @@ const ResourceWorker = ({ params, ...props }) => {
useEffect(() => { useEffect(() => {
getRoleList() getRoleList()
getDivisiList() getDivisiList()
if(role_name === 'Super Admin') {
getDataProyekCompany();
}
}, []) }, [])
useEffect(() => { useEffect(() => {
@ -99,7 +100,6 @@ const ResourceWorker = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
} }
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, HEADER) .post(ROLE_SEARCH, formData, HEADER)
.then(res => res) .then(res => res)
@ -233,7 +233,10 @@ const ResourceWorker = ({ params, ...props }) => {
} else { } else {
payload.group_column.where.push( payload.group_column.where.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"] }
);
} }
const result = await axios const result = await axios
@ -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 handleSearch = e => {
const value = e.target.value const value = e.target.value
setSearch(value); setSearch(value);
@ -355,6 +374,19 @@ const ResourceWorker = ({ params, ...props }) => {
"ascending": false "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 const result = await axios
.post(USER_SEARCH, payload, HEADER) .post(USER_SEARCH, payload, HEADER)
.then(res => res) .then(res => res)
@ -364,14 +396,16 @@ const ResourceWorker = ({ params, ...props }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((n, index) => { resData.map((n, index) => {
let dataRow = { let dataRow = {};
"NIK (Nomor Induk Karyawan)": n.ktp_number, if (role_name === 'Super Admin') {
"Employee Name": n.name, dataRow.Company = n.join_third_company_name;
"Divisi": n.join_second_name,
"Employee Type": n.employee_type,
"Role": n.join_first_name,
"Phone No": n.phone_number,
} }
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) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
@ -524,7 +558,15 @@ const ResourceWorker = ({ params, ...props }) => {
</Tooltip> </Tooltip>
</>, </>,
}, },
...(role_name === 'Super Admin' ? [
{
title: t('company'),
dataIndex: "join_third_company_name",
key: "join_third_company_name",
render: (text, record) => (
<span>{record.join_third_company_name}</span>
)
}] : []),
{ title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' }, { title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' },
{ title: t('nameHR'), dataIndex: 'name', key: 'name' }, { title: t('nameHR'), dataIndex: 'name', key: 'name' },
{ title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' }, { title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' },
@ -575,6 +617,9 @@ const ResourceWorker = ({ params, ...props }) => {
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
roleList={roleList} roleList={roleList}
divisiList={divisiList} divisiList={divisiList}
role_name={role_name}
companyList={companyList}
company_id={company_id}
/> />
<DialogFormUserShift <DialogFormUserShift
openDialog={openDialogShift} openDialog={openDialogShift}

60
src/views/SimproV2/Satuan/DialogForm.js

@ -3,15 +3,16 @@ import {
Modal, ModalHeader, ModalBody, ModalFooter, Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap'; } from 'reactstrap';
import { Select } from 'antd';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { Option } = Select;
const company_id = localStorage.getItem("company_id") const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0) const [id, setId] = useState(0)
const [name, setName] = useState('') const [name, setName] = useState('')
const [description, setDescription] = useState('') const [description, setDescription] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation() const { t } = useTranslation()
@ -20,7 +21,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setId(dataEdit.id) setId(dataEdit.id)
setDescription(dataEdit.description) setDescription(dataEdit.description)
setName(dataEdit.name) setName(dataEdit.name)
setSelectedCompany(dataEdit.company_id);
} else { } else {
setId(0) setId(0)
} }
@ -29,34 +30,46 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => { const handleSave = () => {
let data = ''; let data = '';
if (typeDialog === "Save") { if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
name: name, name: name,
description, description: description,
company_id company_id: company_id
} }
closeDialog('save', data); closeDialog('save', data);
} else { } else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = { data = {
id, id,
name: name, name: name,
description, description: description,
company_id company_id: company_id
} }
closeDialog('edit', data); closeDialog('edit', data);
} }
setId(0) setId(0)
setDescription('') setDescription('')
setSelectedCompany(null)
} }
const handleCancel = () => { const handleCancel = () => {
closeDialog('cancel', 'none') closeDialog('cancel', 'none')
setId(0) setId(0)
setDescription('') setDescription('')
setSelectedCompany(null)
} }
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => { const renderForm = () => {
return ( return (
<Form> <Form>
@ -74,6 +87,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
{role_name === 'Super Admin' &&
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
}
</Form> </Form>
) )
} }

128
src/views/SimproV2/Satuan/index.js

@ -6,27 +6,25 @@ import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; 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'; import { useTranslation } from 'react-i18next';
const Satuan = ({ params, ...props }) => { const Satuan = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, 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.location.state && props.location.state.role_id && props.location.state.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.location.state.role_id; role_id = props.role_id;
user_id = props.location.state.user_id; user_id = props.user_id;
token = props.location.state.token; token = props.token;
isLogin = props.location.state.isLogin; isLogin = props.isLogin;
role_name = props.location.state.role_name; company_id = props.company_id;
} else { all_project = props.all_project;
role_id = localStorage.getItem("role_id"); role_name = props.role_name;
proyek_id = localStorage.getItem("proyek_id"); isLogin = props.isLogin;
user_id = localStorage.getItem("user_id"); hierarchy = props.hierarchy;
token = localStorage.getItem("token"); user_name = props.user_name;
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
} }
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -48,6 +46,7 @@ const Satuan = ({ params, ...props }) => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getDataSatuan() getDataSatuan()
@ -60,10 +59,27 @@ const Satuan = ({ params, ...props }) => {
} }
}, [dataExport]) }, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const column = [ const column = [
role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('name') }, { name: t('name') },
{ name: t('description') }, { 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 () => { const getDataSatuan = async () => {
let start = 0; let start = 0;
@ -73,14 +89,18 @@ const Satuan = ({ params, ...props }) => {
} }
const payload = { const payload = {
"columns": [ group_column: {
{ "operator": "AND",
"name": "name", "group_operator": "OR",
"logic_operator": "ilike", "where": [
"value": search, {
"operator": "AND" "name": "name",
} "logic_operator": "~*",
], "value": search,
}
]
},
"columns": [],
"orders": { "orders": {
"ascending": true, "ascending": true,
"columns": [ "columns": [
@ -90,7 +110,8 @@ const Satuan = ({ params, ...props }) => {
"paging": { "paging": {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "start": start
} },
'joins': []
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
@ -101,6 +122,12 @@ const Satuan = ({ params, ...props }) => {
payload.columns.push( 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"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
@ -129,11 +156,36 @@ const Satuan = ({ params, ...props }) => {
const handleExportExcel = async () => { const handleExportExcel = async () => {
const payload = { const payload = {
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" } "orders": { "columns": ["id"], "ascending": false },
], '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 const result = await axios
.post(SATUAN_SEARCH, payload, HEADER) .post(SATUAN_SEARCH, payload, HEADER)
@ -143,10 +195,12 @@ const Satuan = ({ params, ...props }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((val, index) => { resData.map((val, index) => {
let dataRow = { let dataRow = {};
"Nama": val.name, if (role_name === 'Super Admin') {
"Deskripsi": val.description, dataRow.Company = val.join_first_company_name;
} }
dataRow.Nama = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
@ -285,6 +339,9 @@ const Satuan = ({ params, ...props }) => {
dataEdit={dataEdit} dataEdit={dataEdit}
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataParent={allDataMenu} dataParent={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -330,6 +387,11 @@ const Satuan = ({ params, ...props }) => {
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
{role_name === 'Super Admin' &&
(
<td>{n.join_first_company_name}</td>
)
}
<td>{n.name}</td> <td>{n.name}</td>
<td>{n.description}</td> <td>{n.description}</td>
</tr> </tr>

Loading…
Cancel
Save