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="author" content="Integrasia Utama">
<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
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="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="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"

16
src/App.js

@ -18,6 +18,22 @@ const Page500 = React.lazy(() => import('./views/Pages/Page500'));
const SiopasMap = React.lazy(() => import('./views/Map'));
class App extends Component {
componentDidMount() {
try {
const storedData = localStorage.getItem('configApp');
if (storedData !== null) {
const data = JSON.parse(storedData);
const htmlTitle = data.html_title || 'OSPRO';
document.title = htmlTitle;
} else {
document.title = 'OSPRO';
}
} catch (error) {
document.title = 'OSPRO';
}
}
render() {
return (

1
src/const/en.json

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

1
src/const/id.json

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

19
src/containers/DefaultLayout/DefaultHeader.js

@ -4,7 +4,8 @@ import { Badge, Nav, NavItem } from 'reactstrap';
import PropTypes from 'prop-types';
import { Menu, Dropdown } from 'antd'
import { ALERTUSER_SEARCH, ALERT_SEARCH, ALERTUSER_STATUSVIEW, ALERT_STATUSVIEW, APP_MODE } from '../../const/ApiConst';
import { AppAsideToggler, AppNavbarBrand, AppSidebarToggler } from '@coreui/react';
import logo_ospro from '../../assets/img/OSPRO.png'
import axios from 'axios';
import './Default.css'
const token = window.localStorage.getItem('token');
@ -194,6 +195,15 @@ class DefaultHeader extends Component {
});
}
getLogo = () => {
return (
<div style={{ width: '10%', display: 'flex', justifyContent: 'center' }}>
<img style={{ width: '100%', height: '100%' }} src={logo_ospro} />
</div>
)
}
getHeaderMenu = () => {
const { fullname, u_group } = this.state;
if (u_group == 'kominfo') {
@ -244,12 +254,15 @@ class DefaultHeader extends Component {
return (
<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>
<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">
<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>
</Dropdown>
</Dropdown> */}
</Nav>
</React.Fragment>
);

51
src/containers/DefaultLayout/DefaultLayout.js

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

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 Lembur = React.lazy(() => import('./views/Master/MasterLembur'));
const MapConfig = React.lazy(() => import('./views/MapConfig'));
const Menu = React.lazy(() => import('./views/Master/MasterMenu'));
const Menu = React.lazy(() => import('./views/Master/MenuCompany'));
const OfficeHours = React.lazy(() => import('./views/Master/MasterOfficeHours'));
const Organization = React.lazy(() => import('./views/Master/MasterOrganization'));
const PanicButton = React.lazy(() => import('./views/SimproV2/PanicButton'));
@ -31,6 +31,10 @@ const Presensi = React.lazy(() => import('./views/SimproV2/Presence'));
const ProjectRole = React.lazy(() => import('./views/Master/RoleProject'));
const ProjectType = React.lazy(() => import('./views/SimproV2/ProjectType'));
const ProjectPhase = React.lazy(() => import('./views/Master/ProjectPhase'));
const ProjectExpenditure = React.lazy(() => import('./views/Master/ProjectExpenditure'));
const ProjectFinancialHealth = React.lazy(() => import('./views/Master/ProjectFinancialHealth'));
const ProjectScheduleHealth = React.lazy(() => import('./views/Master/ProjectScheduleHealth'));
const ProjectInvoice = React.lazy(() => import('./views/Master/ProjectInvoice'));
const Proyek = React.lazy(() => import('./views/Master/Proyek'));
const RateCost = React.lazy(() => import('./views/SimproV2/RateCost'));
const ResourceMaterial = React.lazy(() => import('./views/SimproV2/ResourceMaterial'));
@ -82,6 +86,10 @@ const routes = [
{ path: '/project-role', exact: true, name: 'Project Role', component: ProjectRole },
{ path: '/project-type', exact: true, name: 'Project Type', component: ProjectType },
{ path: '/project-phase', exact: true, name: 'Project Phase', component: ProjectPhase },
{ path: '/project-expenditure', exact: true, name: 'Project Expenditure', component: ProjectExpenditure },
{ path: '/project-financial-health', exact: true, name: 'Project Financial Health', component: ProjectFinancialHealth },
{ path: '/project-schedule-health', exact: true, name: 'Project Schedule Health', component: ProjectScheduleHealth },
{ path: '/project-invoice', exact: true, name: 'Project Invoice vs Cash In', component: ProjectInvoice },
{ path: '/divisi', exact: true, name: 'Divisi', component: Divisi },
{ path: '/satuan', exact: true, name: 'Satuan', component: Satuan },
{ path: '/config-alert', exact: true, name: 'Config Alert', component: ConfigAlert },

94
src/views/Dashboard/DashboardBOD.js

@ -15,24 +15,19 @@ import { HealthByBudget, HealthBySchedule } from './Components';
import { Link } from 'react-router-dom';
import { Card, CardBody, CardHeader, Input } from "reactstrap";
const DashboardBOD = (props) => {
let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, all_project = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
company_id = props.location.state.company_id;
all_project = props.location.state.all_project;
} else {
role_id = localStorage.getItem("role_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
all_project = localStorage.getItem('all_project');
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
let hierarchy = [];
hierarchy.push(JSON.parse(localStorage.getItem("hierarchy")));
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -66,13 +61,6 @@ const DashboardBOD = (props) => {
const [READY_TABLE_DETAIL_EXPENDITURE, SET_READY_TABLE_DETAIL_EXPENDITURE] = useState(false);
const [DATA_DETAIL_EXPENDITURE, SET_DATA_DETAIL_EXPENDITURE] = useState([]);
const currentYear = new Date().getFullYear();
const years = Array.from({ length: 6 }, (_, index) => currentYear - index);
const storedYear = localStorage.getItem('selectedYear');
const initialYear = storedYear ? storedYear : currentYear.toString();
const [searchColumn, setSearchColumn] = useState(initialYear);
useEffect(() => {
getCompanyCashFlow(); // expenditure
getCompanyExpenditureColor(); // expenditure Color
@ -87,14 +75,13 @@ const DashboardBOD = (props) => {
getProjectScheduleHealthPerDivision(); // project by schedule health per division
getTotalProjectPerDivision(); // project by division
getTotalProjectValuePerDivision(); // project value by division
localStorage.setItem('selectedYear', searchColumn);
}, [searchColumn])
}, [])
// project expenditure
const getCompanyCashFlow = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Expenditure.";
@ -120,31 +107,31 @@ const DashboardBOD = (props) => {
// Project Expenditure Color
const getCompanyExpenditureColor = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${company_id}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${company_id}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_EXPENDITURE_COLOR(result.data.data)
}
const getCompanyFinancialHealthColor = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${company_id}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${company_id}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_FINANCIAL_HEALTH_COLOR(result.data.data)
}
const getCompanyScheduleHealthColor = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${company_id}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${company_id}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_SCHEDULE_HEALTH_COLOR(result.data.data)
}
const getCompanyInvoiceColor = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${company_id}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${company_id}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_INVOICE_COLOR(result.data.data)
}
const getInvoiceOutstanding = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Invoice vs Cash In.";
@ -167,7 +154,7 @@ const DashboardBOD = (props) => {
}
const getProjectPerScheduleHealth = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health.";
@ -191,7 +178,7 @@ const DashboardBOD = (props) => {
}
const getProjectPerBudgetHealth = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Budget Health.";
@ -214,7 +201,7 @@ const DashboardBOD = (props) => {
}
const getProjectBudgetHealthPerDivision = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health per Division.";
@ -238,7 +225,7 @@ const DashboardBOD = (props) => {
}
const getProjectScheduleHealthPerDivision = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health.";
@ -261,7 +248,7 @@ const DashboardBOD = (props) => {
}
const getProjectPerPhase = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Phase.";
@ -286,7 +273,7 @@ const DashboardBOD = (props) => {
}
const getTotalProjectPerDivision = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Division.";
@ -311,7 +298,7 @@ const DashboardBOD = (props) => {
}
const getTotalProjectValuePerDivision = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Value by Division";
@ -340,7 +327,7 @@ const DashboardBOD = (props) => {
return;
}
setOpenDetailedView(true);
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${searchColumn}/${company_id}/${all_project}/${hierarchy}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${company_id}/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Detail Expenditure";
@ -459,33 +446,6 @@ const DashboardBOD = (props) => {
<div style={{ marginLeft: -25, marginRight: -25 }}>
{/* <FloatingFilter /> */}
<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>
<Col span={12}>
<Row>

25
src/views/Dashboard/DashboardCustomer.js

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

232
src/views/Dashboard/DashboardProject.js

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

29
src/views/Dashboard/DashboardProjectCarousell.js

@ -69,16 +69,21 @@ const center = {
lng: 106.816666,
};
const DashboardProject = (args) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, all_project = '', hierarchy = [];
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
all_project = localStorage.getItem('all_project');
hierarchy.push(JSON.parse(localStorage.getItem("hierarchy")));
const DashboardProject = ({args,...props}) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -804,10 +809,10 @@ const DashboardProject = (args) => {
>
{slides}
<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 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>
</Carousel >
</Spin>

27
src/views/MapMonitoring/index.js

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

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,
allUserToProyek: [],
allDataProyek: [],
finishSetupOption: false
finishSetupOption: false,
role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
}
}
@ -195,7 +203,14 @@ class index extends Component {
"ascending": false
}
}
if (this.state.role_name === 'Super Admin') {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.columns.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
@ -448,6 +463,9 @@ class index extends Component {
Edit
</Tooltip>
</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.description ? n.description : "-"}</td>
<td>{n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"}</td>
@ -494,10 +512,12 @@ class index extends Component {
render() {
const t = this.props;
const column = [
this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null,
{ name: this.props.t('nameHR') },
{ name: this.props.t('description') },
{ name: this.props.t('dateAbsent') },
]
].filter(column => column && column.name);
const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state
return (
<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 Select from 'react-select';
import axios from 'axios';
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST } from '../../../const/ApiConst';
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst';
import { Transfer } from 'antd';
import { withTranslation } from 'react-i18next';
@ -51,13 +51,18 @@ class DialogForm extends Component {
allEmployeeId: [],
idEmployeeDivision: [],
idOrganization: [],
disableTransfer: true
disableTransfer: true,
listCompany: [],
company_id: this.props.company_id,
role_name: ''
}
}
async componentDidMount() {
this.getDataUsers();
this.getDataRole();
if (this.props.company_id !== null) {
this.getDataRole();
this.getDataUsers();
}
this.props.showDialog(this.showDialog);
}
@ -69,14 +74,16 @@ class DialogForm extends Component {
id: dataEdit.id,
title: dataEdit.title_notif,
description: dataEdit.description,
message: dataEdit.message_notif
message: dataEdit.message_notif,
company_id: dataEdit.company_id
})
} else {
this.setState({
id: 0,
title: "",
description: "",
message: ""
message: "",
company_id: 0
})
}
this.setState({ isParentClick: false });
@ -128,9 +135,12 @@ class DialogForm extends Component {
title,
description,
message,
penerima
} = this.state
penerima,
} = this.state
let {
company_id
} = this.state
let idSend = [];
let send_to_type = "all";
if (penerima === "all") {
@ -151,15 +161,17 @@ class DialogForm extends Component {
} else {
idSend = idSend;
}
if (this.props.role_name !== 'Super Admin') {
company_id = parseInt(this.props.company_id)
}
const data = {
title,
description,
message,
send_to_type,
id: idSend
id: idSend,
company_id: company_id
}
if (param === 'registered' || param === 'send') {
this.props.handleSaveBroadcast(param, data)
}
@ -201,7 +213,18 @@ class DialogForm extends Component {
getDataRole = async () => {
const payload = {
"paging": {
"start": 0,
"length": -1
},
"columns": [
{
"name": "company_id",
"logic_operator": "=",
"value": this.state.company_id,
"operator": "AND"
}
],
"orders": { "columns": ["id"], "ascending": false }
}
@ -231,20 +254,11 @@ class DialogForm extends Component {
}
getDataUsers = async () => {
const payload = {
"paging": {
"start": 0,
"length": 10
"length": -1
},
"filter_columns": [
{
"name": "name",
"value": "",
"table_name": "m_users"
}
],
"columns": [
{
"name": "name",
@ -254,34 +268,10 @@ class DialogForm extends Component {
"table_name": "m_users"
},
{
"name": "id",
"name": "company_id",
"logic_operator": "=",
"value": "3",
"operator": "AND",
"table_name": "m_roles"
}
],
"joins": [
{
"name": "m_users",
"column_join": "user_id",
"column_results": [
"username",
"name",
"email",
"gender",
"phone_number",
"address",
"birth_place",
"birth_date"
]
},
{
"name": "m_roles",
"column_join": "role_id",
"column_results": [
"name"
]
"value": this.state.company_id,
"operator": "AND"
}
],
"orders": {
@ -293,7 +283,7 @@ class DialogForm extends Component {
}
//TODO should use search instead
const result = await axios
.get(USER_LIST, config)
.post(USER_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
@ -330,11 +320,29 @@ class DialogForm extends Component {
};
handleSelectCompany = (selectedOption) => {
const selectedCompanyId = selectedOption.value;
this.setState({ company_id: selectedCompanyId }, () => {
this.getDataRole();
this.getDataUsers();
});
}
renderForm = () => {
const t = this.props
const { errorTitle, errorMessage } = this.state
return (
<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>
<Label>{this.props.t('receiver')}</Label>
<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>
<Input style={{ minHeight: "100px" }} type="textarea" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} />
</FormGroup>
</Form>
</Form >
)
}
handleCloseDialog = () => {

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

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

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

@ -1,22 +1,13 @@
import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css';
import { withTranslation } from 'react-i18next';
import axios from 'axios';
import { NotificationManager } from 'react-notifications';
import { Select } from 'antd';
import { MENU_SEARCH } from '../../../const/ApiConst.js';
import { COMPANY_MANAGEMENT_LIST, MENU_SEARCH } from '../../../const/ApiConst.js';
const { Option } = Select
const token = window.localStorage.getItem('token');
const company_id = localStorage.getItem("company_id")
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
class DialogForm extends Component {
constructor(props) {
@ -27,16 +18,26 @@ class DialogForm extends Component {
description: "",
openDialog: false,
isParentClick: false,
companyList: [],
scompany_id:null,
menu: [],
selectedMenu: null,
all_project: false,
company_id
company_id: props.company_id || null,
role_name: props.role_name || '',
token: props.token || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
}
}
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getDataProyekCompany();
this.getAllMenu();
this.props.showDialog(this.showDialog);
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
@ -47,7 +48,7 @@ class DialogForm extends Component {
name: dataEdit.name,
description: dataEdit.description,
selectedMenu: dataEdit.default_page,
company_id
scompany_id : dataEdit.company_id
})
} else {
this.setState({
@ -55,13 +56,27 @@ class DialogForm extends Component {
name: "",
description: "",
selectedMenu: null,
company_id
scompany_id : null
})
}
this.setState({ isParentClick: false });
}
}
getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, this.state.config)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
this.setState({companyList: dataRes})
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
getAllMenu = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
@ -72,7 +87,7 @@ class DialogForm extends Component {
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.post(MENU_SEARCH, payload, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
@ -85,6 +100,10 @@ class DialogForm extends Component {
}
validation = () => {
if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") {
alert("Company data cannot be empty!");
return true;
}
if (!this.state.name || this.state.name === "") {
alert("Role Name cannot be empty!");
return true;
@ -101,7 +120,9 @@ class DialogForm extends Component {
name,
description,
selectedMenu,
role_name,
company_id,
scompany_id,
all_project
} = this.state
@ -114,7 +135,7 @@ class DialogForm extends Component {
name,
description,
selectedMenu,
company_id,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project
}
@ -125,21 +146,22 @@ class DialogForm extends Component {
name,
description,
selectedMenu,
company_id,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project
}
this.props.closeDialog('edit', data);
}
this.setState({ id: 0 });
}
}
handleCancel = () => {
this.props.closeDialog('cancel', 'none')
}
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => {
const { t } = this.props;
return (
@ -150,6 +172,31 @@ class DialogForm extends Component {
</Col>
</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}>
<FormGroup>
<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';
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
class DialogMenuRoles extends Component {
constructor(props) {
super(props)
@ -27,28 +16,24 @@ class DialogMenuRoles extends Component {
description: "",
openDialog: false,
isParentClick: false,
menu: [],
stateMenu: [],
menu:[],
allChecked: true,
company_id: props.company_id || null,
role_name: props.role_name || '',
token: props.token || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
}
}
async componentDidMount() {
this.getAllMenu()
this.props.showDialog(this.showDialog);
this.getAllMenu();
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
const { idRoles } = this.props
this.setStateMenu(true);
this.setState({ isParentClick: false, id: idRoles });
}
}
showDialog = () => {
this.setState({ isParentClick: true });
}
getAllMenu = async () => {
@ -60,22 +45,26 @@ class DialogMenuRoles extends Component {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.post(MENU_SEARCH, payload, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
this.setState({ menu: result.data.data }, () => {
this.setStateMenu(false);
});
} else {
this.setState({ menu: result.data.data });
}
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
const { idRoles } = this.props
this.setStateMenu(true);
this.setState({ isParentClick: false, id: idRoles });
}
}
showDialog = () => {
this.setState({ isParentClick: true });
}
setStateMenu = edit => {

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

@ -16,28 +16,7 @@ const LENGTH_DATA = 10
class index extends Component {
constructor(props) {
let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
company_id = props.location.state.company_id;
role_name = props.location.state.role_name;
} else {
token = window.localStorage.getItem('token');
role_name = window.localStorage.getItem('role_name');
company_id = window.localStorage.getItem('company_id');
}
super(props)
this.config = {
headers: {
Authorization: `Bearer ${token}`,
"Content-type": "application/json"
}
};
this.state = {
alertDelete: false,
alertNotDelete: false,
@ -63,8 +42,21 @@ class index extends Component {
tooltipTambah: false,
totalPage: 0,
typeDialog: 'Save',
company_id: company_id,
role_name: role_name
company_id: props.company_id || 0,
role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
}
this.columns = [
{
@ -86,6 +78,18 @@ class index extends Component {
</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('description'), dataIndex: 'description', key: 'description' },
]
@ -116,9 +120,18 @@ class index extends Component {
const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" },
],
"columns": [],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
@ -130,9 +143,15 @@ class index extends Component {
formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(ROLE_SEARCH, formData, this.config)
.post(ROLE_SEARCH, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -177,7 +196,7 @@ class index extends Component {
const { idDelete } = this.state
const url = ROLE_DELETE(idDelete)
const result = await axios.delete(url, this.config)
const result = await axios.delete(url, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -202,7 +221,7 @@ class index extends Component {
all_project: data.all_project
}
const result = await axios.post(ROLE_ADD, formData, this.config)
const result = await axios.post(ROLE_ADD, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -224,7 +243,7 @@ class index extends Component {
all_project: data.all_project
}
const url = ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.config)
const result = await axios.put(url, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -293,7 +312,7 @@ class index extends Component {
}
const result = await axios
.post(ROLEMENU_SEARCH, formData, this.config)
.post(ROLEMENU_SEARCH, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
@ -317,7 +336,7 @@ class index extends Component {
menu_id: val.menu_id,
role_id: val.roles_id
}
promises.push(axios.post(ROLEMENU_ADD, formData, this.config)
promises.push(axios.post(ROLEMENU_ADD, formData, this.state.config)
.then(res => result.push(res)))
}
})
@ -337,7 +356,7 @@ class index extends Component {
deleteCurrentRoleMenu = async (id) => {
let urlDel = ROLEMENU_DELETE_ROLE(id)
const result = await axios.delete(urlDel, this.config)
const result = await axios.delete(urlDel, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
@ -349,18 +368,42 @@ class index extends Component {
handleExportExcel = async () => {
let start = 0;
let end = "ALL";
const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }
],
"columns": [],
"group_column": {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
} else {
formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(ROLE_SEARCH, formData, this.config)
.post(ROLE_SEARCH, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -368,10 +411,12 @@ class index extends Component {
const dataRes = result.data.data || [];
const dataExport = [];
dataRes.map((val, index) => {
let row = {
Nama: val.name,
Deskripsi: val.description
let row = {};
if (this.state.role_name === 'Super Admin') {
row.Company = val.join_first_company_name;
}
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row);
})
this.setState({ dataExport: dataExport }, () => {
@ -429,9 +474,9 @@ class index extends Component {
dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
companyID={this.state.company_id}
roleName={this.state.role_name}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>
<DialogMenuRoles
openDialog={dialogMenuForm}
@ -439,15 +484,16 @@ class index extends Component {
idRoles={this.state.idRoles}
showDialog={showDialog => this.showMenuRolesDialog = showDialog}
menuRoles={this.state.menuRoles}
companyID={this.state.company_id}
roleName={this.state.role_name}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4>
<Row>
<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>
<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';
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 [name, setName] = useState('')
const [url, setUrl] = useState('')
@ -15,17 +15,19 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [icon, setIcon] = useState('')
const [sequence, setSequence] = useState(0)
const [parentId, setParentId] = useState(null)
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation()
useEffect(() => {
if (typeDialog === "Edit") {
setId(dataEdit.id)
setName(dataEdit.name)
setName(dataEdit.join_first_name)
setUrl(dataEdit.url)
setIcon(dataEdit.icon)
setParentId(dataEdit.parent_id)
setParentId(dataEdit.parent_menu_id)
setSequence(dataEdit.sequence)
setAliasName(dataEdit.alias_name)
setSelectedCompany(dataEdit.company_id)
} else {
setId(0)
setName('')
@ -61,12 +63,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const err = validation();
if (!err) {
if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
name,
url,
sequence: parseInt(sequence),
icon,
alias_name: aliasName,
company_id: company_id
}
if (parentId && parentId > 0) {
@ -75,6 +81,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
closeDialog('save', data);
} else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
id,
name,
@ -82,12 +91,12 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
sequence: parseInt(sequence),
icon,
alias_name: aliasName,
company_id: company_id
}
if (parentId && parentId > 0) {
data['parent_id'] = parentId
}
closeDialog('edit', data);
}
setId(0)
@ -127,6 +136,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
)
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
<Form>
@ -135,6 +148,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<span style={{ color: "red" }}>*</span> Wajib diisi.
</Col>
</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>
<Col>
<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 DialogForm from './DialogForm';
import DialogMasterMenu from './DialogMasterMenu.js'
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import { Button } 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 { Pagination, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
@ -19,7 +20,20 @@ const column = [
{ 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 [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
@ -29,6 +43,7 @@ const Index = ({ params }) => {
const [dataTable, setDatatable] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogMasterMenu, setOpenDialogMasterMenu] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [tooltipDelete, setTooltipDelete] = useState(false)
@ -37,6 +52,7 @@ const Index = ({ params }) => {
const [tooltipTambah, setTooltipTambah] = useState(false)
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation()
const pageName = params.name;
@ -59,6 +75,21 @@ const Index = ({ params }) => {
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const handleSearch = e => {
const value = e.target.value
setSearch(value);
@ -93,11 +124,11 @@ const Index = ({ params }) => {
const payload = {
"paging": { "start": start, "length": rowsPerPage },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" }
{ "name": "alias_name", "logic_operator": "ilike", "value": search, "operator": "AND" }
],
"joins": [{
"name": "m_menu",
"column_join": "parent_id",
"column_join": "menu_id",
"column_results": [
"name"
]
@ -105,8 +136,24 @@ const Index = ({ params }) => {
"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
.post(MENU_SEARCH, payload, config)
.post(MENU_COMPANY_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
@ -123,6 +170,18 @@ const Index = ({ params }) => {
getDataAllMenu();
setOpenDialog(true)
}
const handleOpenDialogMasterMenu = async () => {
setOpenDialogMasterMenu(true)
}
const handleCloseDialogMasterMenu = () => {
setOpenDialogMasterMenu(false)
}
const toggleDialogMasterMenu = () => {
setOpenDialogMasterMenu(!openDialog)
}
const handleCloseDialog = (type, data) => {
if (type === "save") {
@ -288,7 +347,10 @@ const Index = ({ params }) => {
</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: t('icon'), dataIndex: 'icon', key: 'icon' },
{ title: 'Alias', dataIndex: 'alias_name', key: 'alias_name' },
@ -330,6 +392,14 @@ const Index = ({ params }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataMenu={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/>
<DialogMasterMenu
openDialog={openDialogMasterMenu}
closeDialog={handleCloseDialogMasterMenu}
toggleDialog={() => toggleDialogMasterMenu}
/>
<Card>
<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')} />
</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')}>
<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 title={t('exportExcel')}>
<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 }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = {

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

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

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

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

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

@ -8,17 +8,20 @@ import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id")
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
import { Select } from 'antd';
const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const [id, setId] = useState(0)
const [projectType, setProjectType] = useState('')
const [color, setColor] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation();
useEffect(() => {
if (typeDialog === "Edit") {
setId(dataEdit.id)
setProjectType(dataEdit.name)
setColor(dataEdit.color)
setSelectedCompany(dataEdit.company_id)
} else {
setId(0)
setColor('')
@ -29,18 +32,24 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => {
let data = '';
if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
name: projectType,
color,
company_id
company_id: company_id
}
closeDialog('save', data);
} else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
id,
name: projectType,
color,
company_id
company_id: company_id
}
closeDialog('edit', data);
}
@ -52,6 +61,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setId(0)
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
<Form>
@ -69,6 +82,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup>
</Col>
</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>
)
}

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

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

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

@ -1,9 +1,12 @@
import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css';
import axios from 'axios';
import { COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id")
import { NotificationManager } from 'react-notifications';
import { Select } from 'antd';
const { Option } = Select
class DialogForm extends Component {
constructor(props) {
super(props)
@ -12,13 +15,24 @@ class DialogForm extends Component {
name: "",
description: "",
openDialog: false,
companyList: [],
scompany_id:null,
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() {
this.props.showDialog(this.showDialog);
this.getDataProyekCompany();
}
async componentDidUpdate() {
@ -29,13 +43,14 @@ class DialogForm extends Component {
id: dataEdit.id,
name: dataEdit.name,
description: dataEdit.description,
company_id
scompany_id : dataEdit.company_id
})
} else {
this.setState({
id: 0,
name: "",
description: ""
description: "",
scompany_id:null
})
}
this.setState({ isParentClick: false });
@ -47,45 +62,96 @@ class DialogForm extends Component {
this.setState({ isParentClick: true });
}
getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, this.state.config)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
this.setState({companyList: dataRes})
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
validation = () => {
if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") {
alert("Company data cannot be empty!");
return true;
}
}
handleSave = () => {
const {
id,
name,
description
description,
role_name,
company_id,
scompany_id
} = this.state
let data = '';
if (this.props.typeDialog === "Save") {
data = {
id,
name,
description,
company_id
}
this.props.closeDialog('save', data);
} else {
data = {
id,
name,
description,
company_id
const err = this.validation();
if(!err) {
if (this.props.typeDialog === "Save") {
data = {
id,
name,
description,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
}
this.props.closeDialog('save', data);
} else {
data = {
id,
name,
description,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
}
this.props.closeDialog('edit', data);
}
this.props.closeDialog('edit', data);
}
this.setState({ id: 0 });
}
handleCancel = () => {
this.props.closeDialog('cancel', 'none')
}
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => {
const { t } = this.props;
return (
<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>
<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')} />

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

@ -6,49 +6,13 @@ import axios from 'axios';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js';
import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE } from '../../../const/ApiConst.js';
import { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const company_id = localStorage.getItem("company_id")
const role_name = window.localStorage.getItem('role_name');
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const momentFormat = 'HH:mm';
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
]
const LENGTH_DATA = 10
class index extends Component {
constructor(props) {
let role_id = '', 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.state = {
alertDelete: false,
alertNotDelete: false,
@ -74,9 +38,23 @@ class index extends Component {
tooltipTambah: false,
totalPage: 0,
typeDialog: 'Save',
company_id: company_id,
role_name: role_name
}
company_id: props.company_id || 0,
role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
};
this.columns = [
{
title: this.props.t('action'),
@ -86,21 +64,27 @@ class index extends Component {
render: (text, record) => <>
<Tooltip title={this.props.t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title={this.props.t('edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
</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('description'), dataIndex: 'description', key: 'description' },
];
}
async componentDidMount() {
this.getDataRoles();
}
@ -123,9 +107,18 @@ class index extends Component {
const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" },
],
"columns": [],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
@ -137,9 +130,15 @@ class index extends Component {
formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_ROLE_SEARCH, formData, config)
.post(PROJECT_ROLE_SEARCH, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -184,7 +183,7 @@ class index extends Component {
const { idDelete } = this.state
const url = PROJECT_ROLE_DELETE(idDelete)
const result = await axios.delete(url, config)
const result = await axios.delete(url, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -203,10 +202,10 @@ class index extends Component {
const formData = {
name: data.name,
description: data.description,
company_id
company_id: 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)
.catch((error) => error.response);
@ -224,10 +223,10 @@ class index extends Component {
const formData = {
name: data.name,
description: data.description,
company_id
company_id : data.company_id
}
const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, config)
const result = await axios.put(url, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -290,24 +289,50 @@ class index extends Component {
handleExportExcel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }
],
"columns": [],
"group_column": {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_ROLE_SEARCH, payload, config)
.post(PROJECT_ROLE_SEARCH, payload, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.statusText == "OK") {
const dataRes = result.data.data || [];
const dataExport = [];
dataRes.map((val, index) => {
let row = {
Nama: val.name,
Deskripsi: val.description
let row = {};
if (this.state.role_name === 'Super Admin') {
row.Company = val.join_first_company_name;
}
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row);
})
this.setState({ dataExport: dataExport }, () => {
@ -365,13 +390,16 @@ class index extends Component {
dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4>
<Row>
<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>
<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.showHide = this.showHide.bind(this);
}
updatePageTitle = () => {
try {
const storedData = localStorage.getItem('configApp');
if (storedData !== null) {
const data = JSON.parse(storedData);
const htmlTitle = data.html_title || 'OSPRO';
console.log('htmlTitle', htmlTitle);
document.getElementById('title').innerText = htmlTitle;
} else {
document.title = 'OSPRO';
}
} catch (error) {
document.title = 'OSPRO';
}
}
showHide(e) {
e.preventDefault();
e.stopPropagation();
@ -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 = {
headers:
{
@ -146,14 +161,38 @@ class Login extends Component {
else {
this.props.history.push({
pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name, all_project: all_project }
state: {
menu_login: JSON.stringify(resData),
hierarchy,
role_id,
user_id,
token,
isLogin: true,
company_id,
role_name,
all_project,
user_name,
configApp
}
});
}
if (this.state.defaultPage) {
if (role_id === 44) {
this.props.history.push({
pathname: this.state.defaultPage,
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name, all_project: all_project }
state: {
menu_login: JSON.stringify(resData),
hierarchy,
role_id,
user_id,
token,
isLogin: true,
company_id,
role_name,
all_project,
user_name,
configApp
}
});
} else {
this.props.history.push(this.state.defaultPage);
@ -164,7 +203,18 @@ class Login extends Component {
else {
this.props.history.push({
pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name }
state: {
menu_login: JSON.stringify(resData),
hierarchy,
role_id,
user_id,
token,
isLogin: true,
company_id,
role_name,
all_project,
user_name
}
});
}
} else {
@ -209,7 +259,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project)
this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name, data_user.configApp)
window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token);
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('all_project', data_user.role.all_project);
window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy));
window.localStorage.setItem('configApp', JSON.stringify(data_user.configApp));
this.updatePageTitle();
} else {
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
NotificationManager.error(doLogin.data.message, 'Login Failed!');

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

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

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

@ -5,20 +5,22 @@ import {
} from 'reactstrap';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
import { Select } from 'antd';
const { Option } = Select;
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [description, setDescription] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation()
useEffect(() => {
if (typeDialog === "Edit") {
setId(dataEdit.id)
setDescription(dataEdit.description)
setName(dataEdit.name)
setSelectedCompany(dataEdit.company_id);
} else {
handleClearData()
@ -27,20 +29,26 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => {
let data = '';
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
if (typeDialog === "Save") {
data = {
name: name,
description,
company_id
description: description,
company_id: parseInt(company_id),
}
closeDialog('save', data);
} else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
id,
name: name,
description,
company_id
description: description,
company_id: company_id,
}
closeDialog('edit', data);
}
@ -56,8 +64,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setId(0)
setName('')
setDescription('')
setSelectedCompany(null)
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
<Form>
@ -75,6 +88,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup>
</Col>
</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>
)
}

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

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

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

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

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

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

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

@ -10,12 +10,13 @@ import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions, company_id }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions, company_id, role_name, listCompany }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [parent, setParent] = useState(null)
const [description, setDescription] = useState('')
const [color, setColor] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation()
const onChangeParent = (val) => {
@ -29,6 +30,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setName(dataEdit.name)
setParent(dataEdit.parent)
setColor(dataEdit.color)
setSelectedCompany(dataEdit.company_id);
} else {
setId(0)
setColor('')
@ -47,22 +49,28 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
if (!err) {
if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
name,
description,
parent,
color,
company_id
company_id: company_id
}
closeDialog('save', data);
} else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
id,
name,
description,
parent,
color,
company_id
company_id: company_id
}
closeDialog('edit', data);
}
@ -71,6 +79,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setName('')
setParent(null)
setColor('')
setSelectedCompany(null)
}
}
const handleCancel = () => {
@ -79,8 +88,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setDescription('')
setName('')
setParent(null)
setSelectedCompany(null)
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
<Form>
@ -133,6 +147,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup>
</Col>
</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>
)
}

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

@ -4,35 +4,27 @@ import React, { useState, useEffect } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH } from '../../../const/ApiConst';
import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd';
import { useTranslation } from 'react-i18next';
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
{ name: "Color" },
]
const ProjectType = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -55,8 +47,14 @@ const ProjectType = ({ params, ...props }) => {
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataDivisions, setDataDivisions] = useState([])
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation()
const column = [
role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('nameDivision') },
{ name: t('description') },
{ name: t('color') },
].filter(column => column && column.name);
useEffect(() => {
getDataProjectType();
}, [currentPage, rowsPerPage, search])
@ -67,9 +65,34 @@ const ProjectType = ({ params, ...props }) => {
exportExcel()
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getListDivision = async () => {
const payload = {
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
columns: [],
"orders": {
"ascending": true,
@ -80,7 +103,8 @@ const ProjectType = ({ params, ...props }) => {
"paging": {
"length": 0,
"start": -1
}
},
'joins': []
}
if (role_name !== "Super Admin") {
@ -91,6 +115,12 @@ const ProjectType = ({ params, ...props }) => {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const listDivions = await axios
.post(DIVISI_SEARCH, payload, HEADER)
@ -115,14 +145,18 @@ const ProjectType = ({ params, ...props }) => {
start = currentPage * rowsPerPage - rowsPerPage;
}
const payload = {
columns: [
{
name: "name",
logic_operator: "ilike",
value: search,
operator: "AND"
},
],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
columns: [],
"orders": {
"ascending": true,
"columns": [
@ -132,7 +166,8 @@ const ProjectType = ({ params, ...props }) => {
"paging": {
"length": rowsPerPage,
"start": start
}
},
'joins': []
}
if (role_name !== "Super Admin") {
@ -143,6 +178,12 @@ const ProjectType = ({ params, ...props }) => {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(DIVISI_SEARCH, payload, HEADER)
@ -165,14 +206,18 @@ const ProjectType = ({ params, ...props }) => {
}
const payload = {
"columns": [
{
"name": "name",
"logic_operator": "like",
"value": search,
"operator": "AND"
}
],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
"columns": [],
"orders": {
"ascending": true,
"columns": [
@ -182,9 +227,24 @@ const ProjectType = ({ params, ...props }) => {
"paging": {
"length": rowsPerPage,
"start": start
}
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(DIVISI_SEARCH, payload, HEADER)
.then(res => res)
@ -193,10 +253,12 @@ const ProjectType = ({ params, ...props }) => {
let resData = result.data.data;
const excelData = [];
resData.map((val, index) => {
let dataRow = {
"Nama Divisi": val.name,
"Deskripsi": val.description,
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name;
}
dataRow["Nama Divisi"] = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow)
})
await setDataExport(excelData)
@ -345,6 +407,8 @@ const ProjectType = ({ params, ...props }) => {
dataParent={allDataMenu}
dataDivisions={dataDivisions}
company_id={company_id}
listCompany={listCompany}
role_name={role_name}
/>
<Card>
<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>
</Tooltip>
</td>
{role_name === 'Super Admin' &&
(
<td>{n.join_first_company_name}</td>
)
}
<td>{n.name}</td>
<td>{n.description ?? '-'}</td>
{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';
const GanttFrame = React.memo((props) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
isLogin = props.location.state.isLogin;
token = props.location.state.token;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
isLogin = localStorage.getItem("isLogin");
token = localStorage.getItem("token");
}
const history = useHistory();
const { versionGanttId, idProject, ro, timestamp } = 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}`;
const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, company_id, role_name } = props;
const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`;
// const iframeSrc = `http://localhost:8444/generic-ospro-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`;
const [batchEntityData, setBatchEntityData] = useState(null);

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

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

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

@ -60,6 +60,7 @@ class index extends Component {
totalPage: 0,
typeClock: "All",
typeDialog: 'Save',
role_name: props.role_name || '',
}
}
@ -120,6 +121,15 @@ class index extends Component {
}
}
if (this.state.role_name === 'Super Admin') {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.columns.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(PANIC_BUTTON_SEARCH, payload, config)
.then(res => res)
@ -275,6 +285,9 @@ class index extends Component {
<i id="tooltipMap" className="fa fa-map" style={{ color: 'black', cursor: "pointer" }} onClick={() => this.handleMap(n)}></i>
</Tooltip>
</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.join_first_name !== null ? n.join_first_name : "-"}</td>
<td>{n.status_response !== null ? n.status_response : "-"}</td>
@ -321,10 +334,11 @@ class index extends Component {
render() {
const column = [
{ name: this.props.t('action') },
this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null,
{ name: this.props.t('date') },
{ name: this.props.t('nameHR') },
{ name: this.props.t('statusResponse') },
]
].filter(column => column && column.name);
const t = this.props;
const { tooltipExport, dataTable, openDialogEdit, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipMap, tooltipDelete } = this.state
return (

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 { useTranslation } from 'react-i18next';
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 [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1)
@ -54,8 +66,6 @@ const Index = ({ params }) => {
};
const getDataPresence = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
@ -82,6 +92,15 @@ const Index = ({ params }) => {
"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
@ -234,6 +253,18 @@ const Index = ({ params }) => {
</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('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>) },

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

@ -3,20 +3,19 @@ import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import { DatePicker, Tooltip, Select } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import { Select } from 'antd';
import moment from 'moment';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const { Option } = Select
const company_id = window.localStorage.getItem('company_id');
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const [id, setId] = useState(0)
const [projectType, setProjectType] = useState('')
const [uom, setUom] = useState('')
const [description, setDescription] = useState('')
const [unitPrice, setUnitPrice] = useState()
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation();
@ -28,7 +27,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setProjectType(dataEdit.name)
setSelectedCompany(dataEdit.company_id)
} else {
setId(0)
}
@ -37,39 +36,43 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => {
let data = '';
if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
name: projectType,
description,
company_id
company_id: company_id
}
closeDialog('save', data);
} else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
id,
name: projectType,
description,
company_id
company_id: company_id
}
closeDialog('edit', data);
}
setId(0)
setDescription('')
setSelectedCompany(null)
}
const handleCancel = () => {
closeDialog('cancel', 'none')
setId(0)
setDescription('')
setSelectedCompany(null)
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
@ -88,6 +91,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup>
</Col>
</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>
)
}

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 { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst';
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
const ProjectType = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = {
headers: {
@ -52,6 +50,7 @@ const ProjectType = ({ params, ...props }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation();
useEffect(() => {
getDataProjectType()
@ -64,6 +63,21 @@ const ProjectType = ({ params, ...props }) => {
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataProjectType = async () => {
let start = 0;
@ -73,14 +87,18 @@ const ProjectType = ({ params, ...props }) => {
}
const payload = {
"columns": [
{
"name": "name",
"logic_operator": "like",
"value": search,
"operator": "AND"
}
],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
"columns": [],
"orders": {
"ascending": false,
"columns": [
@ -90,7 +108,8 @@ const ProjectType = ({ params, ...props }) => {
"paging": {
"length": rowsPerPage,
"start": start
}
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
@ -100,6 +119,12 @@ const ProjectType = ({ params, ...props }) => {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER)
@ -133,14 +158,18 @@ const ProjectType = ({ params, ...props }) => {
}
const payload = {
"columns": [
{
"name": "name",
"logic_operator": "like",
"value": search,
"operator": "AND"
}
],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
"columns": [],
"orders": {
"ascending": true,
"columns": [
@ -150,9 +179,24 @@ const ProjectType = ({ params, ...props }) => {
"paging": {
"length": rowsPerPage,
"start": start
}
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER)
@ -163,10 +207,12 @@ const ProjectType = ({ params, ...props }) => {
let resData = result.data.data;
const excelData = [];
resData.map((val, index) => {
let dataRow = {
"Nama": val.name,
"Deskripsi": val.description,
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name;
}
dataRow.Nama = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow)
})
await setDataExport(excelData);
@ -317,6 +363,16 @@ const ProjectType = ({ params, ...props }) => {
</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('description'), dataIndex: 'description', key: 'description' },
];
@ -355,6 +411,9 @@ const ProjectType = ({ params, ...props }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
listCompany={listCompany}
company_id={company_id}
role_name={role_name}
/>
<DialogInitialGantt
openDialog={openDialogIG}
@ -367,7 +426,7 @@ const ProjectType = ({ params, ...props }) => {
<h4 className="capitalize">{pageName}</h4>
<Row>
<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>
<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 'antd/dist/antd.css';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import { ROLE_SEARCH } from '../../../const/ApiConst'
import { useTranslation } from 'react-i18next';
const { Option } = Select
const token = window.localStorage.getItem('token');
const company_id = localStorage.getItem("company_id")
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => {
const [openDialogMap, setOpenDialogMap] = useState(false)
const [id, setId] = useState(0)
@ -39,6 +28,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [ktpNumber, setKtpNumber] = useState('')
const [biayaPerJam, setBiayaPerJam] = useState('')
const [roleId, setRoleId] = useState('')
const [scompany_id, setCompanyId] = useState(null);
const [address, setAddress] = useState('')
const [divisionId, setDivisionId] = useState('')
const [statusResource, setStatusResource] = useState('active')
@ -55,6 +45,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setPhoneNo(dataEdit.phone_number)
setEmail(dataEdit.email)
setGender(dataEdit.gender)
setCompanyId(dataEdit.company_id)
setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "")
setBirthPlace(dataEdit.birth_place)
setBloodType(dataEdit.blood_type)
@ -82,6 +73,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setRoleId('')
setDivisionId('')
setAddress('')
setCompanyId(null)
setStatusResource('active')
setStatusRestriction(false)
}
@ -117,7 +109,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
address,
status_resource: statusResource,
status_boundary: statusRestriction,
company_id: company_id
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
}
if (birthDate && birthDate != "") {
@ -165,7 +157,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
address,
status_resource: statusResource,
status_boundary: statusRestriction,
company_id: company_id
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
}
if (birthDate && birthDate != "") {
@ -176,6 +168,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
}
}
const onChangeCompanyProject = (val) => {
setCompanyId(val);
};
const handleCancel = () => {
closeDialog('cancel', 'none')
}
@ -307,13 +303,31 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</Row>
<Row>
<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>
{
role_name === 'Super Admin' && (
<Col md={6}>
<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={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}>
<Label className="capitalize">{t('restrictions')}</Label>
<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>
</Select>
</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}>
<FormGroup>
<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 { Pagination, Table, Button, Tooltip, Spin } from 'antd';
import {
PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC
USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, COMPANY_MANAGEMENT_LIST
} from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
const ResourceWorker = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = {
@ -46,6 +43,7 @@ const ResourceWorker = ({ params, ...props }) => {
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [divisiList, setDivisiList] = useState([])
const [companyList, setDataCompany] = useState([]);
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogShift, setOpenDialogShift] = useState(false)
@ -62,6 +60,9 @@ const ResourceWorker = ({ params, ...props }) => {
useEffect(() => {
getRoleList()
getDivisiList()
if(role_name === 'Super Admin') {
getDataProyekCompany();
}
}, [])
useEffect(() => {
@ -99,7 +100,6 @@ const ResourceWorker = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
}
const result = await axios
.post(ROLE_SEARCH, formData, HEADER)
.then(res => res)
@ -233,7 +233,10 @@ const ResourceWorker = ({ params, ...props }) => {
} else {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
);
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
);
}
const result = await axios
@ -251,6 +254,22 @@ const ResourceWorker = ({ params, ...props }) => {
}
}
const getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
setDataCompany(dataRes);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
const handleSearch = e => {
const value = e.target.value
setSearch(value);
@ -355,6 +374,19 @@ const ResourceWorker = ({ params, ...props }) => {
"ascending": false
}
}
if (role_name !== "Super Admin") {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
);
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
);
}
const result = await axios
.post(USER_SEARCH, payload, HEADER)
.then(res => res)
@ -364,14 +396,16 @@ const ResourceWorker = ({ params, ...props }) => {
let resData = result.data.data;
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"NIK (Nomor Induk Karyawan)": n.ktp_number,
"Employee Name": n.name,
"Divisi": n.join_second_name,
"Employee Type": n.employee_type,
"Role": n.join_first_name,
"Phone No": n.phone_number,
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = n.join_third_company_name;
}
dataRow["NIK (Nomor Induk Karyawan)"] = n.ktp_number;
dataRow["Employee Name"] = n.name;
dataRow["Divisi"] = n.join_second_name;
dataRow["Employee Type"] = n.employee_type;
dataRow.Role = n.join_first_name;
dataRow["Phone No"] = n.phone_number;
excelData.push(dataRow)
})
await setDataExport(excelData);
@ -524,7 +558,15 @@ const ResourceWorker = ({ params, ...props }) => {
</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('nameHR'), dataIndex: 'name', key: 'name' },
{ title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' },
@ -575,6 +617,9 @@ const ResourceWorker = ({ params, ...props }) => {
clickOpenModal={clickOpenModal}
roleList={roleList}
divisiList={divisiList}
role_name={role_name}
companyList={companyList}
company_id={company_id}
/>
<DialogFormUserShift
openDialog={openDialogShift}

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

@ -3,15 +3,16 @@ import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import { Select } from 'antd';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const { Option } = Select;
const company_id = localStorage.getItem("company_id")
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [description, setDescription] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation()
@ -20,7 +21,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setId(dataEdit.id)
setDescription(dataEdit.description)
setName(dataEdit.name)
setSelectedCompany(dataEdit.company_id);
} else {
setId(0)
}
@ -29,34 +30,46 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => {
let data = '';
if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
name: name,
description,
company_id
description: description,
company_id: company_id
}
closeDialog('save', data);
} else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
id,
name: name,
description,
company_id
description: description,
company_id: company_id
}
closeDialog('edit', data);
}
setId(0)
setDescription('')
setSelectedCompany(null)
}
const handleCancel = () => {
closeDialog('cancel', 'none')
setId(0)
setDescription('')
setSelectedCompany(null)
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
<Form>
@ -74,6 +87,33 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup>
</Col>
</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>
)
}

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 { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
const Satuan = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -48,6 +46,7 @@ const Satuan = ({ params, ...props }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation()
useEffect(() => {
getDataSatuan()
@ -60,10 +59,27 @@ const Satuan = ({ params, ...props }) => {
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const column = [
role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('name') },
{ name: t('description') },
]
].filter(column => column && column.name);
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataSatuan = async () => {
let start = 0;
@ -73,14 +89,18 @@ const Satuan = ({ params, ...props }) => {
}
const payload = {
"columns": [
{
"name": "name",
"logic_operator": "ilike",
"value": search,
"operator": "AND"
}
],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
"columns": [],
"orders": {
"ascending": true,
"columns": [
@ -90,7 +110,8 @@ const Satuan = ({ params, ...props }) => {
"paging": {
"length": rowsPerPage,
"start": start
}
},
'joins': []
}
if (role_name !== "Super Admin") {
@ -101,6 +122,12 @@ const Satuan = ({ params, ...props }) => {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
@ -129,11 +156,36 @@ const Satuan = ({ params, ...props }) => {
const handleExportExcel = async () => {
const payload = {
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": search,
}
]
},
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" }
],
"orders": { "columns": ["id"], "ascending": false }
"columns": [],
"orders": { "columns": ["id"], "ascending": false },
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(SATUAN_SEARCH, payload, HEADER)
@ -143,10 +195,12 @@ const Satuan = ({ params, ...props }) => {
let resData = result.data.data;
const excelData = [];
resData.map((val, index) => {
let dataRow = {
"Nama": val.name,
"Deskripsi": val.description,
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name;
}
dataRow.Nama = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow)
})
await setDataExport(excelData);
@ -285,6 +339,9 @@ const Satuan = ({ params, ...props }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/>
<Card>
<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>
</Tooltip>
</td>
{role_name === 'Super Admin' &&
(
<td>{n.join_first_company_name}</td>
)
}
<td>{n.name}</td>
<td>{n.description}</td>
</tr>

Loading…
Cancel
Save