Browse Source

Merge branch 'staging' of https://git.oslog.id/ibnu/generic-ospro-frontend into dev-wahyun

pull/1/head
wahyun 11 months ago
parent
commit
f743d5412e
  1. 4
      public/index.html
  2. 18
      src/App.js
  3. 1
      src/const/en.json
  4. 1
      src/const/id.json
  5. 19
      src/containers/DefaultLayout/DefaultHeader.js
  6. 90
      src/containers/DefaultLayout/DefaultLayout.js
  7. 26
      src/views/Master/MasterAbsensi/index.js
  8. 110
      src/views/Master/MasterBroadcast/DialogForm.js
  9. 83
      src/views/Master/MasterBroadcast/index.js
  10. 146
      src/views/Master/MasterRoles/index.js
  11. 48
      src/views/Master/ProjectPhase/DialogForm.js
  12. 47
      src/views/Master/ProjectPhase/index.js
  13. 73
      src/views/Pages/Login/Login.js
  14. 32
      src/views/Report/k3/index.js
  15. 56
      src/views/SimproV2/ChecklistK3/DialogForm.js
  16. 135
      src/views/SimproV2/ChecklistK3/index.js
  17. 54
      src/views/SimproV2/CreatedProyek/index.js
  18. 47
      src/views/SimproV2/Divisi/DialogForm.js
  19. 124
      src/views/SimproV2/Divisi/index.js
  20. 16
      src/views/SimproV2/PanicButton/index.js
  21. 25
      src/views/SimproV2/Presence/index.js
  22. 58
      src/views/SimproV2/ProjectType/DialogForm.js
  23. 46
      src/views/SimproV2/ProjectType/index.js
  24. 19
      src/views/SimproV2/ResourceWorker/index.js
  25. 60
      src/views/SimproV2/Satuan/DialogForm.js
  26. 102
      src/views/SimproV2/Satuan/index.js

4
public/index.html

@ -8,7 +8,7 @@
<meta name="description" content="OSPRO"> <meta name="description" content="OSPRO">
<meta name="author" content="Integrasia Utama"> <meta name="author" content="Integrasia Utama">
<meta name="keyword" content="OSPRO,Integrasia,OSLOG,Asset,WebGIS,Aplikasi,Tracking System"> <meta name="keyword" content="OSPRO,Integrasia,OSLOG,Asset,WebGIS,Aplikasi,Tracking System">
<title>OSPRO</title> <title id="title"></title>
<!-- <!--
manifest.json provides metadata used when your web app is added to the manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
@ -98,4 +98,4 @@
--> -->
</body> </body>
</html> </html>

18
src/App.js

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

1
src/const/en.json

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

1
src/const/id.json

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

19
src/containers/DefaultLayout/DefaultHeader.js

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

90
src/containers/DefaultLayout/DefaultLayout.js

@ -36,33 +36,33 @@ const config = {
}; };
class DefaultLayout extends Component { class DefaultLayout extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
let role_id = '', token = '', company_id = 0, menu='' let role_id = '', token = '', company_id = 0, menu = ''
if (props.location.state && props.location.state.role_id) { if (props.location.state && props.location.state.role_id) {
role_id = props.location.state.role_id; role_id = props.location.state.role_id;
token = props.location.state.token; token = props.location.state.token;
company_id = props.location.state.company_id; company_id = props.location.state.company_id;
menu = props.location.state.menu_login; menu = props.location.state.menu_login;
} else { } else {
role_id = localStorage.getItem("role_id"); role_id = localStorage.getItem("role_id");
token = localStorage.getItem("token"); token = localStorage.getItem("token");
company_id = localStorage.getItem('company_id'); company_id = localStorage.getItem('company_id');
menu = localStorage.getItem("menu_login"); menu = localStorage.getItem("menu_login");
} }
this.state = { this.state = {
role_id: role_id, role_id: role_id,
token: token, token: token,
menu: { items: [] }, menu: { items: [] },
routes2: routes, routes2: routes,
finalRoutes: [], finalRoutes: [],
breadrCrumbReady: false, breadrCrumbReady: false,
minimized: true, minimized: true,
company_id: company_id company_id: company_id
}; };
} }
async componentDidMount() { async componentDidMount() {
@ -267,15 +267,13 @@ class DefaultLayout extends Component {
return ( return (
<div className="app"> <div className="app">
<AppHeader fixed>
<DefaultHeader />
</AppHeader>
<div className="app-body"> <div className="app-body">
{!window.location.href.includes("dashboard-project") || renderSidebar ? ( {!window.location.href.includes("dashboard-project") || renderSidebar ? (
<AppSidebar minimized={this.state.minimized} fixed display="lg"> <AppSidebar minimized={this.state.minimized} fixed display="lg">
{/* <div class="sidebar-header">
<Suspense fallback={this.loading()}>
<DefaultHeader history={this.props.history} onLogout={e => this.signOut(e)} />
</Suspense>
</div> */}
<hr />
<AppSidebarHeader /> <AppSidebarHeader />
<AppSidebarForm /> <AppSidebarForm />
<Suspense> <Suspense>
@ -312,19 +310,19 @@ class DefaultLayout extends Component {
name={route.name} name={route.name}
render={props => ( render={props => (
<route.component <route.component
params={{ name: route.name }} params={{ name: route.name }}
hierarchy={props.location.state ? props.location.state.hierarchy : localStorage.getItem("hierarchy")} 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")} 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")} 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")} 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")} 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")} 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")} 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")} 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")} 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")} user_name={props.location.state ? props.location.state.user_name : localStorage.getItem("user_name")}
{...props} {...props}
/> />
)} /> )} />
) : (null); ) : (null);
})} })}

26
src/views/Master/MasterAbsensi/index.js

@ -55,7 +55,15 @@ class index extends Component {
currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null, currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null,
allUserToProyek: [], allUserToProyek: [],
allDataProyek: [], allDataProyek: [],
finishSetupOption: false finishSetupOption: false,
role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
} }
} }
@ -195,7 +203,14 @@ class index extends Component {
"ascending": false "ascending": false
} }
} }
if (this.state.role_name === 'Super Admin') {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.columns.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios const result = await axios
@ -448,6 +463,9 @@ class index extends Component {
Edit Edit
</Tooltip> </Tooltip>
</td> */} </td> */}
{this.state.role_name === 'Super Admin' &&
<td>{n.join_second_company_name ? n.join_second_company_name : ""}</td>
}
<td>{n.join_first_name ? n.join_first_name : ""}</td> <td>{n.join_first_name ? n.join_first_name : ""}</td>
<td>{n.description ? n.description : "-"}</td> <td>{n.description ? n.description : "-"}</td>
<td>{n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"}</td> <td>{n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"}</td>
@ -494,10 +512,12 @@ class index extends Component {
render() { render() {
const t = this.props; const t = this.props;
const column = [ const column = [
this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null,
{ name: this.props.t('nameHR') }, { name: this.props.t('nameHR') },
{ name: this.props.t('description') }, { name: this.props.t('description') },
{ name: this.props.t('dateAbsent') }, { name: this.props.t('dateAbsent') },
] ].filter(column => column && column.name);
const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state
return ( return (
<div> <div>

110
src/views/Master/MasterBroadcast/DialogForm.js

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

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

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

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

@ -43,20 +43,20 @@ class index extends Component {
totalPage: 0, totalPage: 0,
typeDialog: 'Save', typeDialog: 'Save',
company_id: props.company_id || 0, company_id: props.company_id || 0,
role_name: props.role_name || '', role_name: props.role_name || '',
role_id: props.role_id || 0, role_id: props.role_id || 0,
user_id: props.user_id || 0, user_id: props.user_id || 0,
isLogin: props.isLogin || false, isLogin: props.isLogin || false,
token: props.token || '', token: props.token || '',
all_project: props.all_project || null, all_project: props.all_project || null,
hierarchy: props.hierarchy || [], hierarchy: props.hierarchy || [],
user_name: props.user_name || '', user_name: props.user_name || '',
config: { config: {
headers: { headers: {
Authorization: `Bearer ${props.token || ''}`, Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json", "Content-type": "application/json",
} }
} }
} }
this.columns = [ this.columns = [
{ {
@ -78,16 +78,18 @@ class index extends Component {
</Tooltip> </Tooltip>
</>, </>,
}, },
{ ...(this.state.role_name === 'Super Admin'
title: this.state.role_name === 'Super Admin' ? "Company Name" : null, ? [
dataIndex: "join_first_company_name", {
key: "join_first_company_name", title: this.props.t('company'),
render: (text, record) => { dataIndex: "join_first_company_name",
return this.state.role_name === 'Super Admin' ? ( key: "join_first_company_name",
<span>{record.join_first_company_name}</span> render: (text, record) => (
) : null; <span>{record.join_first_company_name}</span>
} ),
}, }
]
: []),
{ title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' },
] ]
@ -119,17 +121,17 @@ class index extends Component {
const formData = { const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage }, "paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [], "columns": [],
group_column: { group_column: {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": this.state.search, "value": this.state.search,
} }
] ]
}, },
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
@ -141,12 +143,12 @@ class index extends Component {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
formData.joins.push( formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
) )
formData.group_column.where.push( formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
) )
} }
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, this.state.config) .post(ROLE_SEARCH, formData, this.state.config)
@ -369,36 +371,36 @@ class index extends Component {
const formData = { const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage }, "paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [], "columns": [],
"group_column": { "group_column": {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": this.state.search, "value": this.state.search,
} }
] ]
}, },
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (this.state.role_name !== "Super Admin") { if (this.state.role_name !== "Super Admin") {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
) )
} else { } else {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
formData.joins.push( formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
) )
formData.group_column.where.push( formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
) )
} }
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, this.state.config) .post(ROLE_SEARCH, formData, this.state.config)
@ -410,11 +412,11 @@ class index extends Component {
const dataExport = []; const dataExport = [];
dataRes.map((val, index) => { dataRes.map((val, index) => {
let row = {}; let row = {};
if (this.state.role_name === 'Super Admin') { if (this.state.role_name === 'Super Admin') {
row.Company = val.join_first_company_name; row.Company = val.join_first_company_name;
} }
row.Nama = val.name; row.Nama = val.name;
row.Deskripsi = val.description; row.Deskripsi = val.description;
dataExport.push(row); dataExport.push(row);
}) })
this.setState({ dataExport: dataExport }, () => { this.setState({ dataExport: dataExport }, () => {

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

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

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

@ -6,13 +6,13 @@ import axios from "../../../const/interceptorApi"
import moment from 'moment' import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, PROJECT_PHASE_LIST, BASE_OSPRO } from '../../../const/ApiConst'; import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, COMPANY_MANAGEMENT_LIST, BASE_OSPRO } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd'; import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const ProjectPhase = ({ params, ...props }) => { const ProjectPhase = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
user_id = props.user_id; user_id = props.user_id;
@ -49,6 +49,7 @@ const ProjectPhase = ({ params, ...props }) => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getDataProjectPhase() getDataProjectPhase()
@ -61,6 +62,21 @@ const ProjectPhase = ({ params, ...props }) => {
} }
}, [dataExport]) }, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataProjectPhase = async () => { const getDataProjectPhase = async () => {
let start = 0; let start = 0;
if (currentPage !== 1 && currentPage > 1) { if (currentPage !== 1 && currentPage > 1) {
@ -192,8 +208,8 @@ const ProjectPhase = ({ params, ...props }) => {
if (role_name === 'Super Admin') { if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name; dataRow.Company = val.join_first_company_name;
} }
dataRow.Nama=val.name; dataRow.Nama = val.name;
dataRow.Color=val.color; dataRow.Color = val.color;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData) await setDataExport(excelData)
@ -341,17 +357,19 @@ const ProjectPhase = ({ params, ...props }) => {
</Tooltip>{" "} </Tooltip>{" "}
</>, </>,
}, },
{ ...(role_name === 'Super Admin' ?
title: role_name === 'Super Admin' ? "Company Name" : null, [{
dataIndex: "join_first_company_name", title: t('companyName'),
key: "join_first_company_name", dataIndex: "join_first_company_name",
render: (text, record) => { key: "join_first_company_name",
return role_name === 'Super Admin' ? ( render: (text, record) => (
<span>{record.join_first_company_name}</span> <span>{record.join_first_company_name}</span>
) : null; )
} }]
: []),
{
title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap"
}, },
{ title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ {
title: t('color'), title: t('color'),
dataIndex: 'color', dataIndex: 'color',
@ -398,6 +416,9 @@ const ProjectPhase = ({ params, ...props }) => {
dataEdit={dataEdit} dataEdit={dataEdit}
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataParent={allDataMenu} dataParent={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>

73
src/views/Pages/Login/Login.js

@ -120,7 +120,7 @@ class Login extends Component {
} }
} }
getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name) => { getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name, configApp) => {
const config = { const config = {
headers: headers:
{ {
@ -147,17 +147,18 @@ class Login extends Component {
this.props.history.push({ this.props.history.push({
pathname: "/dashboard", pathname: "/dashboard",
state: { state: {
menu_login: JSON.stringify(resData), menu_login: JSON.stringify(resData),
hierarchy, hierarchy,
role_id, role_id,
user_id, user_id,
token, token,
isLogin: true, isLogin: true,
company_id, company_id,
role_name, role_name,
all_project, all_project,
user_name user_name,
} configApp
}
}); });
} }
if (this.state.defaultPage) { if (this.state.defaultPage) {
@ -165,17 +166,18 @@ class Login extends Component {
this.props.history.push({ this.props.history.push({
pathname: this.state.defaultPage, pathname: this.state.defaultPage,
state: { state: {
menu_login: JSON.stringify(resData), menu_login: JSON.stringify(resData),
hierarchy, hierarchy,
role_id, role_id,
user_id, user_id,
token, token,
isLogin: true, isLogin: true,
company_id, company_id,
role_name, role_name,
all_project, all_project,
user_name user_name,
} configApp
}
}); });
} else { } else {
this.props.history.push(this.state.defaultPage); this.props.history.push(this.state.defaultPage);
@ -187,17 +189,17 @@ class Login extends Component {
this.props.history.push({ this.props.history.push({
pathname: "/dashboard", pathname: "/dashboard",
state: { state: {
menu_login: JSON.stringify(resData), menu_login: JSON.stringify(resData),
hierarchy, hierarchy,
role_id, role_id,
user_id, user_id,
token, token,
isLogin: true, isLogin: true,
company_id, company_id,
role_name, role_name,
all_project, all_project,
user_name user_name
} }
}); });
} }
} else { } else {
@ -242,7 +244,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) { if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id) this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name) this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name, data_user.configApp)
window.localStorage.setItem('isLogin', true); window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token); window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id); window.localStorage.setItem('user_id', data_user.id);
@ -252,6 +254,7 @@ class Login extends Component {
window.localStorage.setItem('role_name', data_user.role.name); window.localStorage.setItem('role_name', data_user.role.name);
window.localStorage.setItem('all_project', data_user.role.all_project); window.localStorage.setItem('all_project', data_user.role.all_project);
window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy)); window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy));
window.localStorage.setItem('configApp', JSON.stringify(data_user.configApp));
} else { } else {
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!'); // NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
NotificationManager.error(doLogin.data.message, 'Login Failed!'); NotificationManager.error(doLogin.data.message, 'Login Failed!');

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

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

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

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

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

@ -5,15 +5,13 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip, } from 'antd';
import { import {
CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH, COMPANY_MANAGEMENT_LIST
} from '../../../const/ApiConst'; } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
const role_name = window.localStorage.getItem('role_name');
const company_id = window.localStorage.getItem('company_id');
const config = { const config = {
headers: headers:
{ {
@ -22,8 +20,20 @@ const config = {
} }
}; };
const ChecklistK3 = ({ params }) => { const ChecklistK3 = ({ params, ...props }) => {
const token = localStorage.getItem("token") let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -45,12 +55,13 @@ const ChecklistK3 = ({ params }) => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
const column = [ const column = [
{ name: "Company Name" }, role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('name') }, { name: t('name') },
{ name: t('description') }, { name: t('description') },
] ].filter(column => column && column.name)
useEffect(() => { useEffect(() => {
getDataChecklistK3() getDataChecklistK3()
}, [currentPage, rowsPerPage, search]) }, [currentPage, rowsPerPage, search])
@ -62,6 +73,22 @@ const ChecklistK3 = ({ params }) => {
} }
}, [dataExport]) }, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataChecklistK3 = async () => { const getDataChecklistK3 = async () => {
let start = 0; let start = 0;
@ -72,16 +99,16 @@ const ChecklistK3 = ({ params }) => {
const payload = { const payload = {
group_column: { group_column: {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": search, "value": search,
} }
] ]
}, },
"columns": [], "columns": [],
"orders": { "orders": {
"ascending": true, "ascending": true,
@ -93,7 +120,7 @@ const ChecklistK3 = ({ params }) => {
"length": rowsPerPage, "length": rowsPerPage,
"start": start "start": start
}, },
'joins': [] 'joins': []
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
@ -106,10 +133,10 @@ const ChecklistK3 = ({ params }) => {
) )
payload.joins.push( payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } { name: "m_company", column_join: "company_id", column_results: ["company_name"] }
) )
payload.group_column.where.push( payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
) )
} }
const result = await axios const result = await axios
@ -139,36 +166,36 @@ const ChecklistK3 = ({ params }) => {
const handleExportExcel = async () => { const handleExportExcel = async () => {
const payload = { const payload = {
group_column: { group_column: {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": search, "value": search,
} }
] ]
}, },
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [], "columns": [],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.columns.push( payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
) )
} else { } else {
payload.columns.push( payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
payload.joins.push( payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } { name: "m_company", column_join: "company_id", column_results: ["company_name"] }
) )
payload.group_column.where.push( payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
) )
} }
const result = await axios const result = await axios
.post(CHECKLIST_K3_SEARCH, payload, config) .post(CHECKLIST_K3_SEARCH, payload, config)
@ -183,8 +210,8 @@ const ChecklistK3 = ({ params }) => {
if (role_name === 'Super Admin') { if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name; dataRow.Company = val.join_first_company_name;
} }
dataRow.Nama=val.name; dataRow.Nama = val.name;
dataRow.Deskripsi=val.description; dataRow.Deskripsi = val.description;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
@ -324,6 +351,8 @@ const ChecklistK3 = ({ params }) => {
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataParent={allDataMenu} dataParent={allDataMenu}
company_id={company_id} company_id={company_id}
listCompany={listCompany}
role_name={role_name}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -367,11 +396,11 @@ const ChecklistK3 = ({ params }) => {
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
{role_name === 'Super Admin'&& {role_name === 'Super Admin' &&
( (
<td>{n.join_first_company_name}</td> <td>{n.join_first_company_name}</td>
) )
} }
<td>{n.name}</td> <td>{n.name}</td>
<td>{n.description}</td> <td>{n.description}</td>
</tr> </tr>

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

@ -81,12 +81,13 @@ import ReportAnalysis from "./ReportAnalysis";
import { Icon } from "@iconify/react"; import { Icon } from "@iconify/react";
// import SubProyekComp from './SubProyekComp'; // import SubProyekComp from './SubProyekComp';
import { Link, useHistory, withRouter } from "react-router-dom"; import { Link, useHistory, withRouter } from "react-router-dom";
import { t } from "i18next";
const url = ""; const url = "";
const format = "DD-MM-YYYY"; const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => { const CreatedProyek = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
user_id = props.user_id; user_id = props.user_id;
@ -417,7 +418,7 @@ const CreatedProyek = ({ params, ...props }) => {
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
); );
} }
if(role_name !== 'Super Admin') { if (role_name !== 'Super Admin') {
payload.columns.push( payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
); );
@ -1369,7 +1370,7 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportExcel = async () => { const handleExportExcel = async () => {
const payload = { const payload = {
columns:[], columns: [],
group_column: { group_column: {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
@ -1392,7 +1393,7 @@ const CreatedProyek = ({ params, ...props }) => {
); );
} }
if(role_name !== 'Super Admin') { if (role_name !== 'Super Admin') {
payload.columns.push( payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
); );
@ -1421,25 +1422,25 @@ const CreatedProyek = ({ params, ...props }) => {
dataRow.Sortname = n.kode_sortname ? n.kode_sortname : ""; dataRow.Sortname = n.kode_sortname ? n.kode_sortname : "";
dataRow["Nama Project"] = n.nama ? n.nama : ""; dataRow["Nama Project"] = n.nama ? n.nama : "";
dataRow["Tanggal Mulai"] = n.mulai_proyek dataRow["Tanggal Mulai"] = n.mulai_proyek
? moment(n.mulai_proyek).format(format) ? moment(n.mulai_proyek).format(format)
: "-"; : "-";
dataRow["Tanggal Selesai"] = n.akhir_proyek dataRow["Tanggal Selesai"] = n.akhir_proyek
? moment(n.akhir_proyek).format(format) ? moment(n.akhir_proyek).format(format)
: "-"; : "-";
dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : ""; dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : "";
dataRow["Perusahaan"] = n.company ? n.company : ""; dataRow["Perusahaan"] = n.company ? n.company : "";
dataRow["Keterangan"] = n.keterangan ? n.keterangan : ""; dataRow["Keterangan"] = n.keterangan ? n.keterangan : "";
dataRow["Dianggap sukses ketika"] = n.considered_success_when dataRow["Dianggap sukses ketika"] = n.considered_success_when
? n.considered_success_when ? n.considered_success_when
: ""; : "";
dataRow["Tujuan Proyek"] = n.project_objectives ? n.project_objectives : ""; dataRow["Tujuan Proyek"] = n.project_objectives ? n.project_objectives : "";
dataRow["Resiko potensial"] = n.potential_risk ? n.potential_risk : ""; dataRow["Resiko potensial"] = n.potential_risk ? n.potential_risk : "";
dataRow["Rencana Biaya"] = n.rencana_biaya dataRow["Rencana Biaya"] = n.rencana_biaya
? formatThousand(n.rencana_biaya) ? formatThousand(n.rencana_biaya)
: "-"; : "-";
dataRow["Testing Environment"] = n.testing_environment dataRow["Testing Environment"] = n.testing_environment
? n.testing_environment ? n.testing_environment
: "-"; : "-";
excelData.push(dataRow); excelData.push(dataRow);
}); });
@ -1452,11 +1453,11 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportPdf = async () => { const handleExportPdf = async () => {
const doc = new jsPDF(); const doc = new jsPDF();
let headers = [ let headers = [
[role_name === 'Super Admin' ? "Company" : null,"Project Name", "Budget", "Project Type", "PM", "Time Project"], [role_name === 'Super Admin' ? "Company" : null, "Project Name", "Budget", "Project Type", "PM", "Time Project"],
]; ];
const payload = { const payload = {
columns:[], columns: [],
group_column: { group_column: {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
@ -1500,7 +1501,7 @@ const CreatedProyek = ({ params, ...props }) => {
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
); );
} }
if(role_name !== 'Super Admin') { if (role_name !== 'Super Admin') {
payload.columns.push( payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
); );
@ -1754,16 +1755,15 @@ const CreatedProyek = ({ params, ...props }) => {
</> </>
), ),
}, },
{ ...(role_name === 'Super Admin' ? [
title: role_name === 'Super Admin' ? "Company Name" : null, {
dataIndex: "join_third_company_name", title: t('company'),
key: "join_third_company_name", dataIndex: "join_third_company_name",
render: (text, record) => { key: "join_third_company_name",
return role_name === 'Super Admin' ? ( render: (text, record) => (
<span>{record.join_third_company_name}</span> <span>{record.join_third_company_name}</span>
) : null; )
} }] : []),
},
{ title: "Project Name", dataIndex: "nama", key: "nama" }, { title: "Project Name", dataIndex: "nama", key: "nama" },
{ {
title: "Budget", title: "Budget",

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

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

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

@ -4,33 +4,27 @@ import React, { useState, useEffect } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH } from '../../../const/ApiConst'; import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const column = [
{ name: "Company Name" },
{ name: "Nama Divisi" },
{ name: "Deskripsi" },
{ name: "Color" },
]
const ProjectType = ({ params, ...props }) => { const ProjectType = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
user_id = props.user_id; user_id = props.user_id;
token = props.token; token = props.token;
isLogin = props.isLogin; isLogin = props.isLogin;
company_id = props.company_id; company_id = props.company_id;
all_project = props.all_project; all_project = props.all_project;
role_name = props.role_name; role_name = props.role_name;
isLogin = props.isLogin; isLogin = props.isLogin;
hierarchy = props.hierarchy; hierarchy = props.hierarchy;
user_name = props.user_name; user_name = props.user_name;
} }
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -53,8 +47,14 @@ const ProjectType = ({ params, ...props }) => {
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [dataDivisions, setDataDivisions] = useState([]) const [dataDivisions, setDataDivisions] = useState([])
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
const column = [
role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('nameDivision') },
{ name: t('description') },
{ name: t('color') },
].filter(column => column && column.name);
useEffect(() => { useEffect(() => {
getDataProjectType(); getDataProjectType();
}, [currentPage, rowsPerPage, search]) }, [currentPage, rowsPerPage, search])
@ -65,6 +65,20 @@ const ProjectType = ({ params, ...props }) => {
exportExcel() exportExcel()
} }
}, [dataExport]) }, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getListDivision = async () => { const getListDivision = async () => {
const payload = { const payload = {
@ -72,13 +86,13 @@ const ProjectType = ({ params, ...props }) => {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": search, "value": search,
} }
] ]
}, },
columns: [], columns: [],
"orders": { "orders": {
"ascending": true, "ascending": true,
@ -102,10 +116,10 @@ const ProjectType = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
payload.joins.push( payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } { name: "m_company", column_join: "company_id", column_results: ["company_name"] }
) )
payload.group_column.where.push( payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
) )
} }
const listDivions = await axios const listDivions = await axios
@ -135,13 +149,13 @@ const ProjectType = ({ params, ...props }) => {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": search, "value": search,
} }
] ]
}, },
columns: [], columns: [],
"orders": { "orders": {
"ascending": true, "ascending": true,
@ -196,13 +210,13 @@ const ProjectType = ({ params, ...props }) => {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": search, "value": search,
} }
] ]
}, },
"columns": [], "columns": [],
"orders": { "orders": {
"ascending": true, "ascending": true,
@ -218,17 +232,17 @@ const ProjectType = ({ params, ...props }) => {
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.columns.push( payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
) )
} else { } else {
payload.columns.push( payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
payload.joins.push( payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } { name: "m_company", column_join: "company_id", column_results: ["company_name"] }
) )
payload.group_column.where.push( payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
) )
} }
const result = await axios const result = await axios
@ -241,10 +255,10 @@ const ProjectType = ({ params, ...props }) => {
resData.map((val, index) => { resData.map((val, index) => {
let dataRow = {}; let dataRow = {};
if (role_name === 'Super Admin') { if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name; dataRow.Company = val.join_first_company_name;
} }
dataRow["Nama Divisi"]=val.name; dataRow["Nama Divisi"] = val.name;
dataRow.Deskripsi=val.description; dataRow.Deskripsi = val.description;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData) await setDataExport(excelData)
@ -393,6 +407,8 @@ const ProjectType = ({ params, ...props }) => {
dataParent={allDataMenu} dataParent={allDataMenu}
dataDivisions={dataDivisions} dataDivisions={dataDivisions}
company_id={company_id} company_id={company_id}
listCompany={listCompany}
role_name={role_name}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -436,10 +452,10 @@ const ProjectType = ({ params, ...props }) => {
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
{role_name === 'Super Admin'&& {role_name === 'Super Admin' &&
( (
<td>{n.join_first_company_name}</td> <td>{n.join_first_company_name}</td>
) )
} }
<td>{n.name}</td> <td>{n.name}</td>
<td>{n.description ?? '-'}</td> <td>{n.description ?? '-'}</td>

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

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

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

@ -11,8 +11,8 @@ import DialogFoto from './DialogFoto';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const Index = ({ params,...props }) => { 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=''; 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) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
user_id = props.user_id; user_id = props.user_id;
@ -92,6 +92,15 @@ const Index = ({ params,...props }) => {
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (role_name === 'Super Admin') {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.columns.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios const result = await axios
@ -244,6 +253,18 @@ const Index = ({ params,...props }) => {
</Tooltip> </Tooltip>
</>, </>,
}, },
...(role_name === 'Super Admin'
? [
{
title: t('company'),
dataIndex: "join_second_company_name",
key: "join_second_company_name",
render: (text, record) => (
<span>{record.join_second_company_name}</span>
)
},
]
: []),
{ title: t('nik'), dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' }, { title: t('nik'), dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' },
{ title: t('nameHR'), dataIndex: 'join_first_name', key: 'join_first_name' }, { title: t('nameHR'), dataIndex: 'join_first_name', key: 'join_first_name' },
{ title: t('presenceIn'), dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) }, { title: t('presenceIn'), dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) },

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

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

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

@ -8,12 +8,13 @@ import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons'; import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst'; import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd'; import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const ProjectType = ({ params, ...props }) => { const ProjectType = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
user_id = props.user_id; user_id = props.user_id;
@ -49,6 +50,7 @@ const ProjectType = ({ params, ...props }) => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation(); const { t } = useTranslation();
useEffect(() => { useEffect(() => {
getDataProjectType() getDataProjectType()
@ -61,6 +63,21 @@ const ProjectType = ({ params, ...props }) => {
} }
}, [dataExport]) }, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataProjectType = async () => { const getDataProjectType = async () => {
let start = 0; let start = 0;
@ -194,8 +211,8 @@ const ProjectType = ({ params, ...props }) => {
if (role_name === 'Super Admin') { if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name; dataRow.Company = val.join_first_company_name;
} }
dataRow.Nama=val.name; dataRow.Nama = val.name;
dataRow.Deskripsi=val.description; dataRow.Deskripsi = val.description;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
@ -346,16 +363,16 @@ const ProjectType = ({ params, ...props }) => {
</Tooltip> </Tooltip>
</>, </>,
}, },
{ ...(role_name === 'Super Admin' ? [
title: role_name === 'Super Admin' ? "Company Name" : null, {
dataIndex: "join_first_company_name", title: t('company'),
key: "join_first_company_name", dataIndex: "join_first_company_name",
render: (text, record) => { key: "join_first_company_name",
return role_name === 'Super Admin' ? ( render: (text, record) => (
<span>{record.join_first_company_name}</span> <span>{record.join_first_company_name}</span>
) : null; )
} }] : []),
},
{ title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: t('description'), dataIndex: 'description', key: 'description' }, { title: t('description'), dataIndex: 'description', key: 'description' },
]; ];
@ -394,6 +411,9 @@ const ProjectType = ({ params, ...props }) => {
dataEdit={dataEdit} dataEdit={dataEdit}
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataParent={allDataMenu} dataParent={allDataMenu}
listCompany={listCompany}
company_id={company_id}
role_name={role_name}
/> />
<DialogInitialGantt <DialogInitialGantt
openDialog={openDialogIG} openDialog={openDialogIG}

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

@ -15,7 +15,7 @@ import {
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const ResourceWorker = ({ params, ...props }) => { const ResourceWorker = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
user_id = props.user_id; user_id = props.user_id;
@ -558,16 +558,15 @@ const ResourceWorker = ({ params, ...props }) => {
</Tooltip> </Tooltip>
</>, </>,
}, },
{ ...(role_name === 'Super Admin' ? [
title: role_name === 'Super Admin' ? "Company Name" : null, {
dataIndex: "join_third_company_name", title: t('company'),
key: "join_third_company_name", dataIndex: "join_third_company_name",
render: (text, record) => { key: "join_third_company_name",
return role_name === 'Super Admin' ? ( render: (text, record) => (
<span>{record.join_third_company_name}</span> <span>{record.join_third_company_name}</span>
) : null; )
} }] : []),
},
{ title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' }, { title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' },
{ title: t('nameHR'), dataIndex: 'name', key: 'name' }, { title: t('nameHR'), dataIndex: 'name', key: 'name' },
{ title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' }, { title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' },

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

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

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

@ -6,24 +6,24 @@ import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip } from 'antd';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst'; import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const Satuan = ({ params, ...props }) => { const Satuan = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
user_id = props.user_id; user_id = props.user_id;
token = props.token; token = props.token;
isLogin = props.isLogin; isLogin = props.isLogin;
company_id = props.company_id; company_id = props.company_id;
all_project = props.all_project; all_project = props.all_project;
role_name = props.role_name; role_name = props.role_name;
isLogin = props.isLogin; isLogin = props.isLogin;
hierarchy = props.hierarchy; hierarchy = props.hierarchy;
user_name = props.user_name; user_name = props.user_name;
} }
const HEADER = { const HEADER = {
headers: { headers: {
@ -46,6 +46,7 @@ const Satuan = ({ params, ...props }) => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
useEffect(() => { useEffect(() => {
getDataSatuan() getDataSatuan()
@ -58,11 +59,27 @@ const Satuan = ({ params, ...props }) => {
} }
}, [dataExport]) }, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const column = [ const column = [
{ name: "Company Name" }, role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('name') }, { name: t('name') },
{ name: t('description') }, { name: t('description') },
] ].filter(column => column && column.name);
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataSatuan = async () => { const getDataSatuan = async () => {
let start = 0; let start = 0;
@ -76,11 +93,11 @@ const Satuan = ({ params, ...props }) => {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": search, "value": search,
} }
] ]
}, },
"columns": [], "columns": [],
@ -106,10 +123,10 @@ const Satuan = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
payload.joins.push( payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } { name: "m_company", column_join: "company_id", column_results: ["company_name"] }
) )
payload.group_column.where.push( payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
) )
} }
@ -143,13 +160,13 @@ const Satuan = ({ params, ...props }) => {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
"where": [ "where": [
{ {
"name": "name", "name": "name",
"logic_operator": "~*", "logic_operator": "~*",
"value": search, "value": search,
} }
] ]
}, },
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [], "columns": [],
"orders": { "columns": ["id"], "ascending": false }, "orders": { "columns": ["id"], "ascending": false },
@ -157,17 +174,17 @@ const Satuan = ({ params, ...props }) => {
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.columns.push( payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
) )
} else { } else {
payload.columns.push( payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
payload.joins.push( payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } { name: "m_company", column_join: "company_id", column_results: ["company_name"] }
) )
payload.group_column.where.push( payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
) )
} }
const result = await axios const result = await axios
@ -179,11 +196,11 @@ const Satuan = ({ params, ...props }) => {
const excelData = []; const excelData = [];
resData.map((val, index) => { resData.map((val, index) => {
let dataRow = {}; let dataRow = {};
if (role_name === 'Super Admin') { if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name; dataRow.Company = val.join_first_company_name;
} }
dataRow.Nama=val.name; dataRow.Nama = val.name;
dataRow.Deskripsi=val.description; dataRow.Deskripsi = val.description;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
@ -322,6 +339,9 @@ const Satuan = ({ params, ...props }) => {
dataEdit={dataEdit} dataEdit={dataEdit}
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
dataParent={allDataMenu} dataParent={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -367,10 +387,10 @@ const Satuan = ({ params, ...props }) => {
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
{role_name === 'Super Admin'&& {role_name === 'Super Admin' &&
( (
<td>{n.join_first_company_name}</td> <td>{n.join_first_company_name}</td>
) )
} }
<td>{n.name}</td> <td>{n.name}</td>
<td>{n.description}</td> <td>{n.description}</td>

Loading…
Cancel
Save