Browse Source

Merge pull request 'Upload 02-04-2024' (#78) from staging into master

Reviewed-on: ibnu/generic-ospro-frontend#78
pull/1/head
farhantock 6 months ago
parent
commit
7aa5ff73ec
  1. 19
      src/const/ApiConst.js
  2. 1
      src/containers/DefaultLayout/DefaultLayout.js
  3. 6
      src/routes.js
  4. 31
      src/views/Master/MasterCompany/DialogForm.js
  5. 15
      src/views/Master/MasterCompany/index.js
  6. 141
      src/views/Master/MasterRoles/DialogMenuRoles.js
  7. 22
      src/views/Master/MasterRoles/index.js
  8. 203
      src/views/Master/MasterTransaction/DialogForm.js
  9. 470
      src/views/Master/MasterTransaction/index.js
  10. 394
      src/views/Master/MasterWidget/index.js
  11. 15
      src/views/Pages/Login/Login.js
  12. 7
      src/views/SimproV2/CreatedProyek/AsignCustProject.js
  13. 8
      src/views/SimproV2/CreatedProyek/AsignHrProject.js
  14. 6
      src/views/SimproV2/CreatedProyek/DialogAssignCust.js
  15. 50
      src/views/SimproV2/CreatedProyek/DialogDocument.js
  16. 2
      src/views/SimproV2/CreatedProyek/DialogFormProyek.js
  17. 29
      src/views/SimproV2/CreatedProyek/DialogGantt.js
  18. 17
      src/views/SimproV2/CreatedProyek/FormDocument.js
  19. 188
      src/views/SimproV2/CreatedProyek/FormFolderDocument.js
  20. 84
      src/views/SimproV2/CreatedProyek/index.js
  21. 10
      src/views/SimproV2/Divisi/index.js
  22. 6
      src/views/SimproV2/Gantt/GanttFrame.js
  23. 6
      src/views/SimproV2/Gantt/index.js
  24. 12
      src/views/SimproV2/Kanban/index.js
  25. 352
      src/views/SimproV2/LimitasiUser/index.js
  26. 73
      src/views/SimproV2/ResourceWorker/DialogForm.js
  27. 16
      src/views/SimproV2/ResourceWorker/index.js
  28. 3
      src/views/SimproV2/Satuan/index.js
  29. 2
      src/views/SimproV2/Settings/DialogForm.js
  30. 4
      src/views/SimproV2/Settings/components/MyProfile/Index.js
  31. 19
      src/views/SimproV2/Settings/components/Plan/Container1.js

19
src/const/ApiConst.js

@ -121,11 +121,11 @@ export let BASE_OSPRO = "http://localhost:8444/generic-ospro-backend";
export let BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; export let BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`;
export let BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; export let BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`;
export let BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; export let BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`;
export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file, company_name) => { export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file, company_name, dateFile) => {
return `${BASE_OSPRO}/assets/${company_name}/file/project/${file}`; return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/file/project/${file}`;
} }
export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file, company_name) => { export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file, company_name, dateFile) => {
return `${BASE_OSPRO}/assets/${company_name}/image/${file}`; return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/image/${file}`;
} }
export const USERROLE_ADD = `${BASE_SIMPRO}/user-role/add`; export const USERROLE_ADD = `${BASE_SIMPRO}/user-role/add`;
@ -279,10 +279,15 @@ export const TRANSACTION_GET_ID = (id) => {
export const TRANSACTION_EDIT = (id) => { export const TRANSACTION_EDIT = (id) => {
return `${BASE_SIMPRO_LUMEN}/product-transaction/update/${id}`; return `${BASE_SIMPRO_LUMEN}/product-transaction/update/${id}`;
}; };
export const TRANSACTION_DELETE = (id) => {
return `${BASE_SIMPRO_LUMEN}/product-transaction/delete/${id}`;
};
export const TRANSACTION_LIST = `${BASE_SIMPRO_LUMEN}/product-transaction/list`;
export const STORAGE_LIMIT_INFORMATION = (company_name) => { export const STORAGE_LIMIT_INFORMATION = (company_name) => {
return `${BASE_SIMPRO_LUMEN}/information-storage/${company_name}`; return `${BASE_SIMPRO_LUMEN}/information-storage/${company_name}`;
}; };
export const STORAGE_LIMIT_INFORMATION_ALL_COMPANY = `${BASE_SIMPRO_LUMEN}/information-storage-all-company`
export const ABSENSI_ADD = `${BASE_SIMPRO_LUMEN}/permit/add`; export const ABSENSI_ADD = `${BASE_SIMPRO_LUMEN}/permit/add`;
export const ABSENSI_SEARCH = `${BASE_SIMPRO_LUMEN}/permit/search`; export const ABSENSI_SEARCH = `${BASE_SIMPRO_LUMEN}/permit/search`;
@ -731,8 +736,8 @@ export const FOLDER_DOCUMENT_PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/folder-document-
export const FOLDER_DOCUMENT_PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/folder-document-proyek/search`; export const FOLDER_DOCUMENT_PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/folder-document-proyek/search`;
export const FOLDER_DOCUMENT_PROYEK_UPDATE = (id) => export const FOLDER_DOCUMENT_PROYEK_UPDATE = (id) =>
`${BASE_SIMPRO_LUMEN}/folder-document-proyek/update/${id}`; `${BASE_SIMPRO_LUMEN}/folder-document-proyek/update/${id}`;
export const FOLDER_DOCUMENT_PROYEK_DELETE = (id) => export const FOLDER_DOCUMENT_PROYEK_DELETE = (id, company_id) =>
`${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}`; `${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}/${company_id}`;
export const FOLDER_DOCUMENT_PROYEK_GET_TREE = (proyek_id) => export const FOLDER_DOCUMENT_PROYEK_GET_TREE = (proyek_id) =>
`${BASE_SIMPRO_LUMEN}/folder-document-proyek/get-tree/${proyek_id}`; `${BASE_SIMPRO_LUMEN}/folder-document-proyek/get-tree/${proyek_id}`;
@ -853,4 +858,4 @@ export const SALES_CONTACT_GET_ID = (id) => {
}; };
export const SALES_CONTACT_DELETE = (id) => { export const SALES_CONTACT_DELETE = (id) => {
return `${BASE_SIMPRO_LUMEN}/sales-contact/delete/${id}`; return `${BASE_SIMPRO_LUMEN}/sales-contact/delete/${id}`;
}; };

1
src/containers/DefaultLayout/DefaultLayout.js

@ -370,6 +370,7 @@ class DefaultLayout extends Component {
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")}
configApp={props.location.state ? props.location.state.configApp : localStorage.getItem("configApp")}
{...props} {...props}
/> />
)} /> )} />

6
src/routes.js

@ -58,9 +58,12 @@ const DashboardProjectCarousell = React.lazy(() => import('./views/Dashboard/Das
const MapMonitoring = React.lazy(() => import('./views/MapMonitoring')); const MapMonitoring = React.lazy(() => import('./views/MapMonitoring'));
const Settings = React.lazy(() => import('./views/SimproV2/Settings/Desktop')); const Settings = React.lazy(() => import('./views/SimproV2/Settings/Desktop'));
const CompanyManagement = React.lazy(() => import('./views/Master/MasterCompany')) const CompanyManagement = React.lazy(() => import('./views/Master/MasterCompany'))
const TransactionManagement = React.lazy(() => import('./views/Master/MasterTransaction'))
const DemoRequest = React.lazy(() => import('./views/SimproV2/DemoRequest')) const DemoRequest = React.lazy(() => import('./views/SimproV2/DemoRequest'))
const ReferralCode = React.lazy(() => import('./views/SimproV2/ReferralCode')) const ReferralCode = React.lazy(() => import('./views/SimproV2/ReferralCode'))
const SalesContact = React.lazy(() => import('./views/SimproV2/SalesContact')) const SalesContact = React.lazy(() => import('./views/SimproV2/SalesContact'))
const MasterWidget = React.lazy(() => import('./views/Master/MasterWidget'))
const LimitasiUser = React.lazy(() => import('./views/SimproV2/LimitasiUser'))
const routes = [ const routes = [
{ path: '/', exact: true, name: 'Home' }, { path: '/', exact: true, name: 'Home' },
{ path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD }, { path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD },
@ -125,10 +128,13 @@ const routes = [
{ path: '/map-monitoring', exact: true, name: 'Map Monitoring', component: MapMonitoring }, { path: '/map-monitoring', exact: true, name: 'Map Monitoring', component: MapMonitoring },
// { path: '/dashboard-project/:ID/:GANTTID', exact: true, name: 'Dashboard Project', component: DashboardProject }, // { path: '/dashboard-project/:ID/:GANTTID', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ path: '/settings', exact: true, name: 'Settings', component: Settings }, { path: '/settings', exact: true, name: 'Settings', component: Settings },
{ path: '/transaction-management', exact: true, name: 'Transaksi Management', component: TransactionManagement },
{ path: '/register-management', exact: true, name: 'Register Management', component: CompanyManagement }, { path: '/register-management', exact: true, name: 'Register Management', component: CompanyManagement },
{ path: '/demo-request', exact: true, name: 'Request Demo', component: DemoRequest }, { path: '/demo-request', exact: true, name: 'Request Demo', component: DemoRequest },
{ path: '/referral-code-management', exact: true, name: 'Referral Code Management', component: ReferralCode }, { path: '/referral-code-management', exact: true, name: 'Referral Code Management', component: ReferralCode },
{ path: '/sales-contact', exact: true, name: 'Sales Contact', component: SalesContact }, { path: '/sales-contact', exact: true, name: 'Sales Contact', component: SalesContact },
{ path: '/master-widget', exact: true, name: 'Master Widget', component: MasterWidget },
{ path: '/limitasi-user', exact: true, name: 'Limitasi User', component: LimitasiUser },
]; ];

31
src/views/Master/MasterCompany/DialogForm.js

@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import moment from 'moment'; import moment from 'moment';
import { import {
USER_SEARCH, MENU_COMPANY_DELETE, USER_DELETE, ROLE_SEARCH, COMPANY_MANAGEMENT_GET_ID, MENU_COMPANY_SEARCH, BASE_SIMPRO_LUMEN_IMAGE USER_SEARCH, MENU_COMPANY_DELETE, USER_DELETE, ROLE_SEARCH, COMPANY_MANAGEMENT_GET_ID, MENU_COMPANY_SEARCH, BASE_SIMPRO_LUMEN_IMAGE_COMPANY
} from '../../../const/ApiConst'; } from '../../../const/ApiConst';
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
const config = { const config = {
@ -594,6 +594,24 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
} }
}; };
const imageUrl = (() => {
let imageType = '';
let createdAt = '';
if (typeImage === 'imageHeader' && imageHeader) {
imageType = imageHeader.image;
createdAt = moment(imageHeader.created_at).format('YYYY-MM');
} else if (typeImage === 'imageLogin' && imageLogin) {
imageType = imageLogin.image;
createdAt = moment(imageLogin.created_at).format('YYYY-MM');
} else if (typeImage === 'favIcon' && imageFavIcon) {
imageType = imageFavIcon.image;
createdAt = moment(imageFavIcon.created_at).format('YYYY-MM');
}
return BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageType, companyNameProp, createdAt);
})();
const renderFromCompany = () => { const renderFromCompany = () => {
return ( return (
<> <>
@ -823,21 +841,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
typeImage !== 'imageSlider' ? ( typeImage !== 'imageSlider' ? (
imageLogin || imageHeader || imageFavIcon ? ( imageLogin || imageHeader || imageFavIcon ? (
<img <img
src={ src={imageUrl}
`${BASE_SIMPRO_LUMEN_IMAGE}/` +
(typeImage === 'imageHeader' && imageHeader ? imageHeader.image :
typeImage === 'imageLogin' && imageLogin ? imageLogin.image :
typeImage === 'favIcon' && imageFavIcon ? imageFavIcon.image : '')
}
style={{ maxWidth: "100%" }} style={{ maxWidth: "100%" }}
alt="Image Preview" alt="Not Image Preview"
/> />
) : ('-') ) : ('-')
) : ( ) : (
<Row style={{ display: 'flex', justifyContent: 'center' }}> <Row style={{ display: 'flex', justifyContent: 'center' }}>
{imageSlider && imageSlider.map((item, index) => ( {imageSlider && imageSlider.map((item, index) => (
<Col md={6} style={{ marginBottom: '20px' }}> <Col md={6} style={{ marginBottom: '20px' }}>
<img key={index} src={`${BASE_SIMPRO_LUMEN_IMAGE}/` + item.image} style={{ width: '150px', display: 'block' }}></img> <img key={index} src={`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(item?.image, companyNameProp, moment(item?.created_at).format('YYYY-MM'))}`} style={{ width: '150px', display: 'block' }}></img>
</Col> </Col>
))} ))}
</Row> </Row>

15
src/views/Master/MasterCompany/index.js

@ -125,11 +125,13 @@ const MasterCompany = ({ params }) => {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
const sourceData = result.data.data; const sourceData = result.data.data;
const countRecord = result.data.totalRecord;
setDatatable(sourceData); setDatatable(sourceData);
setTotalPage(result.data.totalRecord); setTotalPage(countRecord);
const lastCompanyId = sourceData[sourceData.length - 1].id; const lastCompanyId = countRecord > 0 ? sourceData[sourceData.length - 1].id : null;
setLastCompanyId(lastCompanyId); setLastCompanyId(lastCompanyId);
setLoading(false) setLoading(false)
} else { } else {
@ -145,7 +147,8 @@ const MasterCompany = ({ params }) => {
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
setProjectImageHeader(result.data.data); const dataRes = result.data.data;
setProjectImageHeader(dataRes);
} }
} }
@ -187,7 +190,7 @@ const MasterCompany = ({ params }) => {
const sourceData = result.data.data; const sourceData = result.data.data;
setProjectImageSlider(sourceData); setProjectImageSlider(sourceData);
} }
} }
const handleSearch = e => { const handleSearch = e => {
const value = e.target.value const value = e.target.value

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

@ -22,11 +22,13 @@ export default class DialogMenuRoles extends Component {
openDialog: false, openDialog: false,
isParentClick: false, isParentClick: false,
menu: [], menu: [],
menuIds: [],
stateMenu: [], stateMenu: [],
stateRead: [], stateRead: [],
stateCreate: [], stateCreate: [],
stateUpdate: [], stateUpdate: [],
stateDelete: [], stateDelete: [],
role_name: props.role_name || '',
stateReadAll: false, stateReadAll: false,
stateCreateAll: false, stateCreateAll: false,
stateUpdateAll: false, stateUpdateAll: false,
@ -35,11 +37,13 @@ export default class DialogMenuRoles extends Component {
company_id: props.company_id || null, company_id: props.company_id || null,
} }
} }
async componentDidMount() { async componentDidMount() {
this.props.showDialog(this.showDialog); this.props.showDialog(this.showDialog);
this.getAllMenu(); this.getAllMenu();
} }
async componentDidUpdate() {
async componentDidUpdate(prevProps, prevState) {
if (this.state.isParentClick === true) { if (this.state.isParentClick === true) {
const { idRoles } = this.props const { idRoles } = this.props
this.setStateMenu(true); this.setStateMenu(true);
@ -48,23 +52,31 @@ export default class DialogMenuRoles extends Component {
this.setStateCreate(true); this.setStateCreate(true);
this.setStateDelete(true); this.setStateDelete(true);
this.setState({ isParentClick: false, id: idRoles }); this.setState({ isParentClick: false, id: idRoles });
// if (prevState.menu == this.state.menu) {
// await this.setStateReadAfterRender();
// }
} }
} }
showDialog = () => { showDialog = () => {
this.setState({ isParentClick: true }); this.setState({ isParentClick: true });
} }
getAllMenu = async () => { getAllMenu = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }
],
"joins": [ "joins": [
{ "name": "t_roles_menu", "column_join": "menu_id", "column_results": ["create", "update", "delete", "read"] }, { "name": "t_roles_menu", "column_join": "menu_id", "column_results": ["create", "update", "delete", "read"] },
{ "name": "m_menu", "column_join": "menu_id", "column_results": ["name"] } { "name": "m_menu", "column_join": "menu_id", "column_results": ["name"] }
], ],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (this.state.role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }
)
}
const result = await axios const result = await axios
.post(MENU_COMPANY_SEARCH, payload, config) .post(MENU_COMPANY_SEARCH, payload, config)
.then(res => res) .then(res => res)
@ -73,9 +85,9 @@ export default class DialogMenuRoles extends Component {
this.setState({ menu: result.data.data }, () => { this.setState({ menu: result.data.data }, () => {
this.setStateMenu(false); this.setStateMenu(false);
}); });
} else {
} }
} }
setStateMenu = edit => { setStateMenu = edit => {
const stateMenu = []; const stateMenu = [];
this.state.menu.map((val) => { this.state.menu.map((val) => {
@ -89,6 +101,7 @@ export default class DialogMenuRoles extends Component {
}) })
}) })
} }
setStateRead = edit => { setStateRead = edit => {
const stateRead = []; const stateRead = [];
this.state.menu.map((val) => { this.state.menu.map((val) => {
@ -102,6 +115,15 @@ export default class DialogMenuRoles extends Component {
}) })
}) })
} }
// setStateReadAfterRender = async () => {
// await new Promise((resolve) => {
// this.setState({}, resolve);
// });
// // Now you have access to the rendered elements and can update state based on it
// this.setStateRead(true);
// }
setStateCreate = edit => { setStateCreate = edit => {
const stateCreate = []; const stateCreate = [];
this.state.menu.map((val) => { this.state.menu.map((val) => {
@ -115,6 +137,7 @@ export default class DialogMenuRoles extends Component {
}) })
}) })
} }
setStateUpdate = edit => { setStateUpdate = edit => {
const stateUpdate = []; const stateUpdate = [];
this.state.menu.map((val) => { this.state.menu.map((val) => {
@ -128,6 +151,7 @@ export default class DialogMenuRoles extends Component {
}) })
}) })
} }
setStateDelete = edit => { setStateDelete = edit => {
const stateDelete = []; const stateDelete = [];
this.state.menu.map((val) => { this.state.menu.map((val) => {
@ -141,6 +165,7 @@ export default class DialogMenuRoles extends Component {
}) })
}) })
} }
checkMenuRoles = () => { checkMenuRoles = () => {
let copyStateMenu = [...this.state.stateMenu]; let copyStateMenu = [...this.state.stateMenu];
this.props.menuRoles.map((val, indexMenu) => { this.props.menuRoles.map((val, indexMenu) => {
@ -158,14 +183,15 @@ export default class DialogMenuRoles extends Component {
} }
}) })
} }
checkReadRoles = () => { checkReadRoles = () => {
let copyStateRead = [...this.state.stateRead]; let copyStateRead = [...this.state.stateRead];
this.props.menuRoles.map((val) => { this.props.menuRoles.map((val) => {
let index = this.getIndexDataMenu(val.menu_id); let index = this.getIndexDataMenu(val.menu_id);
if (val.read === true) { if (val.read === true) {
copyStateRead[index] = true; copyStateRead[val.menu_id] = true;
} else { } else {
copyStateRead[index] = false; copyStateRead[val.menu_id] = false;
} }
}) })
this.setState({ stateRead: [] }, () => { this.setState({ stateRead: [] }, () => {
@ -177,14 +203,15 @@ export default class DialogMenuRoles extends Component {
} }
}) })
} }
checkCreateRoles = () => { checkCreateRoles = () => {
let copyStateCreate = [...this.state.stateCreate]; let copyStateCreate = [...this.state.stateCreate];
this.props.menuRoles.map((val) => { this.props.menuRoles.map((val) => {
let index = this.getIndexDataMenu(val.menu_id); let index = this.getIndexDataMenu(val.menu_id);
if (val.create === true) { if (val.create === true) {
copyStateCreate[index] = true; copyStateCreate[val.menu_id] = true;
} else { } else {
copyStateCreate[index] = false; copyStateCreate[val.menu_id] = false;
} }
}) })
this.setState({ stateCreate: [] }, () => { this.setState({ stateCreate: [] }, () => {
@ -196,14 +223,15 @@ export default class DialogMenuRoles extends Component {
} }
}) })
} }
checkUpdateRoles = () => { checkUpdateRoles = () => {
let copyStateUpdate = [...this.state.stateUpdate]; let copyStateUpdate = [...this.state.stateUpdate];
this.props.menuRoles.map((val) => { this.props.menuRoles.map((val) => {
let index = this.getIndexDataMenu(val.menu_id); let index = this.getIndexDataMenu(val.menu_id);
if (val.update === true) { if (val.update === true) {
copyStateUpdate[index] = true; copyStateUpdate[val.menu_id] = true;
} else { } else {
copyStateUpdate[index] = false; copyStateUpdate[val.menu_id] = false;
} }
}) })
this.setState({ stateUpdate: [] }, () => { this.setState({ stateUpdate: [] }, () => {
@ -215,14 +243,15 @@ export default class DialogMenuRoles extends Component {
} }
}) })
} }
checkDeleteRoles = () => { checkDeleteRoles = () => {
let copyStateDelete = [...this.state.stateDelete]; let copyStateDelete = [...this.state.stateDelete];
this.props.menuRoles.map((val) => { this.props.menuRoles.map((val) => {
let index = this.getIndexDataMenu(val.menu_id); let index = this.getIndexDataMenu(val.menu_id);
if (val.delete === true) { if (val.delete === true) {
copyStateDelete[index] = true; copyStateDelete[val.menu_id] = true;
} else { } else {
copyStateDelete[index] = false; copyStateDelete[val.menu_id] = false;
} }
}) })
this.setState({ stateDelete: [] }, () => { this.setState({ stateDelete: [] }, () => {
@ -234,26 +263,32 @@ export default class DialogMenuRoles extends Component {
} }
}) })
} }
getIndexDataMenu = (id) => { getIndexDataMenu = (id) => {
let index = this.state.menu.findIndex(obj => obj.id === id); let index = this.state.menu.findIndex(obj => obj.menu_id === id);
return index return index
} }
getIndexDataCreate = (id) => { getIndexDataCreate = (id) => {
let index = this.state.stateCreate.findIndex(obj => obj.id === id); let index = this.state.stateCreate.findIndex(obj => obj.menu_id === id);
return index return index
} }
getIndexDataDelete = (id) => { getIndexDataDelete = (id) => {
let index = this.state.stateDelete.findIndex(obj => obj.id === id); let index = this.state.stateDelete.findIndex(obj => obj.menu_id === id);
return index return index
} }
getIndexDataRead = (id) => { getIndexDataRead = (id) => {
let index = this.state.stateRead.findIndex(obj => obj.id === id); let index = this.state.stateRead.findIndex(obj => obj.menu_id === id);
return index return index
} }
getIndexDataUpdate = (id) => { getIndexDataUpdate = (id) => {
let index = this.state.stateUpdate.findIndex(obj => obj.id === id); let index = this.state.stateUpdate.findIndex(obj => obj.menu_id === id);
return index return index
} }
handleSave = () => { handleSave = () => {
const { const {
stateMenu, stateMenu,
@ -262,17 +297,18 @@ export default class DialogMenuRoles extends Component {
stateRead, stateRead,
stateUpdate, stateUpdate,
menu, menu,
menuIds,
id id
} = this.state } = this.state
const arrayData = []; const arrayData = [];
menu.map((val, index) => { menu.map((val, index) => {
let data = { let data = {
roles_id: id, roles_id: id,
menu_id: val.id, menu_id: menuIds[val.menu_id],
read: stateRead[index], read: stateRead[val.menu_id],
create: stateCreate[index], create: stateCreate[val.menu_id],
update: stateUpdate[index], update: stateUpdate[val.menu_id],
delete: stateDelete[index], delete: stateDelete[val.menu_id],
checked: stateMenu[index], checked: stateMenu[index],
} }
arrayData.push(data); arrayData.push(data);
@ -280,17 +316,20 @@ export default class DialogMenuRoles extends Component {
this.props.closeDialog('save', arrayData); this.props.closeDialog('save', arrayData);
this.setState({ id: 0 }); this.setState({ id: 0 });
} }
handleCancel = () => { handleCancel = () => {
this.props.closeDialog('cancel', 'none') this.props.closeDialog('cancel', 'none')
} }
handleChangeCheckbox = (checked, index) => { handleChangeCheckbox = (checked, index) => {
let copyStateMenu = [...this.state.stateMenu]; let copyStateMenu = [...this.state.stateMenu];
copyStateMenu[index] = checked; copyStateMenu[index] = checked;
this.setState({ stateMenu: copyStateMenu }) this.setState({ stateMenu: copyStateMenu })
} }
handleChangeCheckboxRead = (checked, index, menuItem = null, menuIdxList = []) => { handleChangeCheckboxRead = (checked, index, menuItem = null, menuIdxList = []) => {
let copyStateRead = [...this.state.stateRead]; let copyStateRead = [...this.state.stateRead];
copyStateRead[index] = checked; let copyMenuIds = [...this.state.menuIds];
let menu = this.state.menu; let menu = this.state.menu;
let checkMenuParent = menu.map((state, index) => { let checkMenuParent = menu.map((state, index) => {
if (state.parent_menu_id === menuItem.menu_id) { if (state.parent_menu_id === menuItem.menu_id) {
@ -303,18 +342,23 @@ export default class DialogMenuRoles extends Component {
menuIdxList.forEach((menu, index) => { menuIdxList.forEach((menu, index) => {
checkMenuParent.forEach((check, idx) => { checkMenuParent.forEach((check, idx) => {
if (check === menu) { if (check === menu) {
stateReadIdx.push(index); copyMenuIds[menu] = menu
stateReadIdx.push(menu);
} }
}); });
}); });
stateReadIdx.map((stateRead) => { stateReadIdx.map((stateRead) => {
copyStateRead[stateRead] = checked copyStateRead[stateRead] = checked
}) })
copyStateRead[menuItem.menu_id] = checked
copyMenuIds[menuItem.menu_id] = menuItem.menu_id
this.setState({ stateRead: copyStateRead }) this.setState({ stateRead: copyStateRead })
this.setState({ menuIds: copyMenuIds })
} }
handleChangeCheckboxCreate = (checked, index, menuItem = null, menuIdxList = []) => { handleChangeCheckboxCreate = (checked, index, menuItem = null, menuIdxList = []) => {
let copyStateCreate = [...this.state.stateCreate]; let copyStateCreate = [...this.state.stateCreate];
copyStateCreate[index] = checked; let copyMenuIds = [...this.state.menuIds];
let menu = this.state.menu; let menu = this.state.menu;
let checkMenuParent = menu.map((state, index) => { let checkMenuParent = menu.map((state, index) => {
if (state.parent_menu_id === menuItem.menu_id) { if (state.parent_menu_id === menuItem.menu_id) {
@ -327,18 +371,23 @@ export default class DialogMenuRoles extends Component {
menuIdxList.forEach((menu, index) => { menuIdxList.forEach((menu, index) => {
checkMenuParent.forEach((check, idx) => { checkMenuParent.forEach((check, idx) => {
if (check === menu) { if (check === menu) {
stateCreateIdx.push(index); copyMenuIds[menu] = menu
stateCreateIdx.push(menu);
} }
}); });
}); });
stateCreateIdx.map((stateCreate) => { stateCreateIdx.map((stateCreate) => {
copyStateCreate[stateCreate] = checked copyStateCreate[stateCreate] = checked
}) })
copyStateCreate[menuItem.menu_id] = checked
copyMenuIds[menuItem.menu_id] = menuItem.menu_id
this.setState({ stateCreate: copyStateCreate }) this.setState({ stateCreate: copyStateCreate })
this.setState({ menuIds: copyMenuIds })
} }
handleChangeCheckboxEdit = (checked, index, menuItem = null, menuIdxList = []) => { handleChangeCheckboxEdit = (checked, index, menuItem = null, menuIdxList = []) => {
let copyStateEdit = [...this.state.stateUpdate]; let copyStateEdit = [...this.state.stateUpdate];
copyStateEdit[index] = checked; let copyMenuIds = [...this.state.menuIds];
let menu = this.state.menu; let menu = this.state.menu;
let checkMenuParent = menu.map((state, index) => { let checkMenuParent = menu.map((state, index) => {
if (state.parent_menu_id === menuItem.menu_id) { if (state.parent_menu_id === menuItem.menu_id) {
@ -351,18 +400,23 @@ export default class DialogMenuRoles extends Component {
menuIdxList.forEach((menu, index) => { menuIdxList.forEach((menu, index) => {
checkMenuParent.forEach((check, idx) => { checkMenuParent.forEach((check, idx) => {
if (check === menu) { if (check === menu) {
stateEditIdx.push(index); copyMenuIds[menu] = menu
stateEditIdx.push(menu);
} }
}); });
}); });
stateEditIdx.map((stateEdit) => { stateEditIdx.map((stateEdit) => {
copyStateEdit[stateEdit] = checked copyStateEdit[stateEdit] = checked
}) })
copyStateEdit[menuItem.menu_id] = checked
copyMenuIds[menuItem.menu_id] = menuItem.menu_id
this.setState({ stateUpdate: copyStateEdit }) this.setState({ stateUpdate: copyStateEdit })
this.setState({ menuIds: copyMenuIds })
} }
handleChangeCheckboxDelete = (checked, index, menuItem = null, menuIdxList = []) => { handleChangeCheckboxDelete = (checked, index, menuItem = null, menuIdxList = []) => {
let copyStateDelete = [...this.state.stateDelete]; let copyStateDelete = [...this.state.stateDelete];
copyStateDelete[index] = checked; let copyMenuIds = [...this.state.menuIds];
let menu = this.state.menu; let menu = this.state.menu;
let checkMenuParent = menu.map((state, index) => { let checkMenuParent = menu.map((state, index) => {
if (state.parent_menu_id === menuItem.menu_id) { if (state.parent_menu_id === menuItem.menu_id) {
@ -375,15 +429,20 @@ export default class DialogMenuRoles extends Component {
menuIdxList.forEach((menu, index) => { menuIdxList.forEach((menu, index) => {
checkMenuParent.forEach((check, idx) => { checkMenuParent.forEach((check, idx) => {
if (check === menu) { if (check === menu) {
stateDeleteIdx.push(index); copyMenuIds[menu] = menu
stateDeleteIdx.push(menu);
} }
}); });
}); });
stateDeleteIdx.map((stateDelete) => { stateDeleteIdx.map((stateDelete) => {
copyStateDelete[stateDelete] = checked copyStateDelete[stateDelete] = checked
}) })
copyStateDelete[menuItem.menu_id] = checked
copyMenuIds[menuItem.menu_id] = menuItem.menu_id
this.setState({ stateDelete: copyStateDelete }) this.setState({ stateDelete: copyStateDelete })
this.setState({ menuIds: copyMenuIds })
} }
handleChangeCheckboxReadAll = (checked) => { handleChangeCheckboxReadAll = (checked) => {
let copyStateRead = [...this.state.stateRead]; let copyStateRead = [...this.state.stateRead];
copyStateRead.map((val, index) => { copyStateRead.map((val, index) => {
@ -391,6 +450,7 @@ export default class DialogMenuRoles extends Component {
}) })
this.setState({ stateRead: copyStateRead }) this.setState({ stateRead: copyStateRead })
} }
handleChangeCheckboxCreateAll = (checked, index) => { handleChangeCheckboxCreateAll = (checked, index) => {
let copyStateCreate = [...this.state.stateCreate]; let copyStateCreate = [...this.state.stateCreate];
copyStateCreate.map((val, index) => { copyStateCreate.map((val, index) => {
@ -398,6 +458,7 @@ export default class DialogMenuRoles extends Component {
}) })
this.setState({ stateCreate: copyStateCreate }) this.setState({ stateCreate: copyStateCreate })
} }
handleChangeCheckboxEditAll = (checked, index) => { handleChangeCheckboxEditAll = (checked, index) => {
let copyStateEdit = [...this.state.stateUpdate]; let copyStateEdit = [...this.state.stateUpdate];
copyStateEdit.map((val, index) => { copyStateEdit.map((val, index) => {
@ -405,6 +466,7 @@ export default class DialogMenuRoles extends Component {
}) })
this.setState({ stateUpdate: copyStateEdit }) this.setState({ stateUpdate: copyStateEdit })
} }
handleChangeCheckboxDeleteAll = (checked, index) => { handleChangeCheckboxDeleteAll = (checked, index) => {
let copyStateDelete = [...this.state.stateDelete]; let copyStateDelete = [...this.state.stateDelete];
copyStateDelete.map((val, index) => { copyStateDelete.map((val, index) => {
@ -412,6 +474,7 @@ export default class DialogMenuRoles extends Component {
}) })
this.setState({ stateDelete: copyStateDelete }) this.setState({ stateDelete: copyStateDelete })
} }
renderForm = () => { renderForm = () => {
const { menu, stateRead, stateCreate, stateUpdate, stateDelete } = this.state; const { menu, stateRead, stateCreate, stateUpdate, stateDelete } = this.state;
let menuIdxList = [] let menuIdxList = []
@ -427,13 +490,13 @@ export default class DialogMenuRoles extends Component {
menuIdx++ menuIdx++
const paddingLeft = depth * 30; const paddingLeft = depth * 30;
return ( return (
<React.Fragment key={menuIdx - 1}> <React.Fragment key={menuItem.menu_id}>
<tr > <tr >
<td style={{ paddingLeft: paddingLeft }}>{menuItem.join_second_name}</td> <td style={{ paddingLeft: paddingLeft }}>{menuItem.join_second_name}</td>
<td><input type="checkbox" onClick={(e) => this.handleChangeCheckboxRead(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateRead[currentIndex]} /></td> <td><input type="checkbox" onClick={(e) => this.handleChangeCheckboxRead(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateRead[menuItem.menu_id]} /></td>
<td><input type="checkbox" onClick={(e) => this.handleChangeCheckboxCreate(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateCreate[currentIndex]} /></td> <td><input type="checkbox" onClick={(e) => this.handleChangeCheckboxCreate(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateCreate[menuItem.menu_id]} /></td>
<td><input type="checkbox" onClick={(e) => this.handleChangeCheckboxEdit(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateUpdate[currentIndex]} /></td> <td><input type="checkbox" onClick={(e) => this.handleChangeCheckboxEdit(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateUpdate[menuItem.menu_id]} /></td>
<td><input type="checkbox" onClick={(e) => this.handleChangeCheckboxDelete(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateDelete[currentIndex]} /></td> <td><input type="checkbox" onClick={(e) => this.handleChangeCheckboxDelete(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateDelete[menuItem.menu_id]} /></td>
</tr> </tr>
{renderMenu(menuItem.menu_id, depth + 1)} {renderMenu(menuItem.menu_id, depth + 1)}
</React.Fragment> </React.Fragment>
@ -449,6 +512,7 @@ export default class DialogMenuRoles extends Component {
</React.Fragment> </React.Fragment>
); );
}; };
renderAll = () => { renderAll = () => {
return ( return (
<tr> <tr>
@ -460,9 +524,11 @@ export default class DialogMenuRoles extends Component {
</tr> </tr>
) )
} }
checkArray = (val) => { checkArray = (val) => {
return val === false; return val === false;
} }
handleAllChecked = (checked) => { handleAllChecked = (checked) => {
this.setState({ allChecked: !this.state.allChecked }); this.setState({ allChecked: !this.state.allChecked });
if (checked === true) { if (checked === true) {
@ -486,6 +552,7 @@ export default class DialogMenuRoles extends Component {
}) })
} }
} }
render() { render() {
return ( return (
<Modal size="xl" scrollable={true} isOpen={this.props.openDialog} toggle={this.props.toggleDialog}> <Modal size="xl" scrollable={true} isOpen={this.props.openDialog} toggle={this.props.toggleDialog}>
@ -523,4 +590,4 @@ export default class DialogMenuRoles extends Component {
</Modal> </Modal>
) )
} }
} }

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

@ -156,9 +156,9 @@ class index extends Component {
{ "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"] }
) )
@ -320,13 +320,17 @@ class index extends Component {
handleMenuRoles = async (id) => { handleMenuRoles = async (id) => {
const formData = { const formData = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "role_id", "logic_operator": "=", "value": `${id}`, "operator": "AND" }
],
"joins": [{ "name": "m_menu", "column_join": "menu_id", "column_results": ["parent_id", "name"] }], "joins": [{ "name": "m_menu", "column_join": "menu_id", "column_results": ["parent_id", "name"] }],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "role_id", "logic_operator": "=", "value": `${id}`, "operator": "AND" }
)
}
const result = await axios const result = await axios
.post(ROLEMENU_SEARCH, formData, this.state.config) .post(ROLEMENU_SEARCH, formData, this.state.config)
.then(res => res) .then(res => res)
@ -412,9 +416,9 @@ class index extends Component {
{ "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"] }
) )

203
src/views/Master/MasterTransaction/DialogForm.js

@ -0,0 +1,203 @@
import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css';
import axios from 'axios';
import { COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next';
import { NotificationManager } from 'react-notifications';
import { Select, DatePicker } from 'antd';
import moment from "moment";
const { Option } = Select
class DialogForm extends Component {
constructor(props) {
super(props)
this.state = {
id: 0,
name: "",
ExpiredDateOspro: moment(),
description: "",
openDialog: false,
companyList: [],
scompany_id:null,
isParentClick: false,
company_id: props.company_id || null,
role_name: props.role_name || '',
token: props.token || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
}
}
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getDataProyekCompany();
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
if (this.props.typeDialog === "Edit") {
const { dataEdit } = this.props
this.setState({
id: dataEdit.id,
name: dataEdit.name,
description: dataEdit.description,
scompany_id : dataEdit.company_id
})
} else {
this.setState({
id: 0,
name: "",
description: "",
scompany_id:null
})
}
this.setState({ isParentClick: false });
}
}
showDialog = () => {
this.setState({ isParentClick: true });
}
getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, this.state.config)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
this.setState({companyList: dataRes})
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
handleDatePicker = (date, dateString) => {
this.setState({ ExpiredDateOspro: date })
};
validation = () => {
if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") {
alert("Company data cannot be empty!");
return true;
}
}
handleSave = () => {
const {
id,
name,
description,
role_name,
company_id,
scompany_id
} = this.state
let data = '';
const err = this.validation();
if(!err) {
if (this.props.typeDialog === "Save") {
data = {
id,
name,
description,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
}
this.props.closeDialog('save', data);
} else {
data = {
id,
name,
description,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
}
this.props.closeDialog('edit', data);
}
}
this.setState({ id: 0 });
}
handleCancel = () => {
this.props.closeDialog('cancel', 'none')
}
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => {
const { t } = this.props;
return (
<Form>
{
this.state.role_name === 'Super Admin' && (
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={this.state.scompany_id}
defaultValue={this.state.scompany_id}
onChange={this.onChangeCompanyProject}
style={{ width: "100%" }}
>
{this.state.companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
)
}
<FormGroup>
<Label>{this.props.t('Type Paket')}</Label>
<Input type="text" value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} />
</FormGroup>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>
Expired Date<span style={{ color: "red" }}>*</span>
</Label>
{/* <DatePicker
// disabledDate={(current) => {
// let currentDate = moment(current).format("YYYY-MM-DD");
// let customDate = moment(this.state.ExpiredDateOspro)
// .add(1, "days")
// .format("YYYY-MM-DD");
// return current && currentDate < customDate;
// }}
format={"DD-MM-YYYY"}
style={{ width: "100%" }}
value={this.state.ExpiredDateOspro}
onChange={this.handleDatePicker()}
/> */}
</FormGroup>
</Form>
)
}
render() {
return (
<Modal isOpen={this.props.openDialog} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.props.closeDialog}>{this.props.typeDialog == "Save" ? "Tambah" : "Edit"} {this.props.t('Transaksi')}</ModalHeader>
<ModalBody>
{this.renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => this.handleSave()}>{this.props.typeDialog}</Button>{' '}
<Button color="secondary" onClick={() => this.handleCancel()}>{this.props.t('cancel')}</Button>
</ModalFooter>
</Modal>
)
}
}
export default withTranslation()(DialogForm);

470
src/views/Master/MasterTransaction/index.js

@ -0,0 +1,470 @@
import * as XLSX from 'xlsx';
import DialogForm from './DialogForm';
import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_ROLE_ADD, TRANSACTION_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE } from '../../../const/ApiConst.js';
import { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next';
import { checkActMenup } from '../../../const/CustomFunc';
import moment from "moment";
const LENGTH_DATA = 10
class index extends Component {
constructor(props) {
super(props);
this.state = {
alertDelete: false,
alertNotDelete: false,
currentPage: 1,
dataEdit: null,
dataExport: [],
dataGs: [],
dataIdHo: [],
dataTable: [],
dialogMenuForm: false,
idDelete: 0,
idRoles: 0,
menuRoles: [],
openDialog: false,
page: 0,
rowsPerPage: LENGTH_DATA,
search: "",
tooltipDelete: false,
tooltipEdit: false,
tooltipExport: false,
tooltipImport: false,
tooltipMenu: false,
tooltipTambah: false,
totalPage: 0,
typeDialog: 'Save',
company_id: props.company_id || 0,
role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
};
this.columns = [
{
title: this.props.t('action'),
dataIndex: '',
key: 'x',
className: 'nowrap',
render: (text, record) => <>
<Tooltip title={this.props.t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
{/* {
checkActMenup('/product-transaction', 'delete') ?
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
:
null
} */}
</Tooltip>
<Tooltip title={this.props.t('edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
{/* {
checkActMenup('/product-transaction', 'update') ?
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
:
null
} */}
</Tooltip>
</>,
},
...(this.state.role_name === 'Super Admin' ? [
{
title: "Company Name",
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => {
return <span>{ record.join_first_company_name }</span>;
}
}] : [])
,
{ title: 'Type Paket', dataIndex: 'type_paket', key: 'type_paket', className: "nowrap",
render: (text,record) => {
return <span>{ !["Basic","Free"].includes(record.type_paket) ? 'Enterprise' : record.type_paket}</span>
}
},
{
title: this.props.t('Expired Date'), dataIndex: 'exp_ospro', key: 'exp_ospro',
render: (text,record) => {
return <span>{ moment(record.exp_ospro).format('DD MMMM, YYYY') }</span>;
}
},
];
}
async componentDidMount() {
this.getDataTransaction();
}
async componentDidUpdate(prevProps, prevState) {
const { search } = this.state
if (search !== prevState.search) this.getDataTransaction()
}
handleSearch = e => {
const value = e.target.value
this.setState({ search: value, currentPage: 1 })
};
getDataTransaction = async () => {
let start = 0;
if (this.state.currentPage !== 1 && this.state.currentPage > 1) {
start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage
}
const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "type_paket",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": parseInt(this.state.company_id), "operator": "AND" },
)
} else {
formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(TRANSACTION_SEARCH, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord });
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
handleOpenDialog = (type) => {
this.setState({ openDialog: true, typeDialog: type })
this.showChildDialog();
}
handleCloseDialog = (type, data) => {
if (type === "save") {
this.saveRole(data);
} else if (type === "edit") {
this.editRole(data);
}
this.setState({ openDialog: false })
}
handleOpenDialogMr = () => {
this.setState({ dialogMenuForm: true })
this.showMenuRolesDialog();
}
handleCloseDialogMr = (type, data) => {
if (type === "save") {
this.saveMenuRoles(data)
}
this.setState({ dialogMenuForm: false })
}
toggleAddDialog = () => {
this.setState({ openDialog: !this.state.openDialog })
}
onConfirmDelete = async () => {
const { idDelete } = this.state
const url = PROJECT_ROLE_DELETE(idDelete)
const result = await axios.delete(url, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataTransaction()
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.success(`Data project role berhasil dihapus`, 'Success!!');
} else {
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.error(`Data project role gagal dihapus`, 'Failed!!');
}
}
saveRole = async (data) => {
const formData = {
name: data.name,
description: data.description,
company_id: data.company_id
}
const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataTransaction();
NotificationManager.success(`Data project role berhasil ditambah`, 'Success!!');
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
editRole = async (data) => {
const formData = {
name: data.name,
description: data.description,
company_id : data.company_id
}
const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataTransaction();
NotificationManager.success(`Data project role berhasil diedit`, 'Success!!');
} else {
NotificationManager.error(`Data project role gagal di edit`, `Failed!!`);
}
}
handleEdit = (data) => {
this.setState({ dataEdit: data });
this.handleOpenDialog('Edit');
}
handleDelete = (id) => {
id == '1' ? this.setState({ alertNotDelete: true }) :
this.setState({ alertDelete: true, idDelete: id });
}
onShowSizeChange = (current, pageSize) => {
this.setState({ rowsPerPage: pageSize }, () => {
this.getDataTransaction();
})
}
onPagination = (current, pageSize) => {
this.setState({ currentPage: current, page: (current - 1) * pageSize }, () => {
this.getDataTransaction();
})
}
toggle = (param) => {
if (param === "edit") {
this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit }))
} else if (param === "delete") {
this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete }))
} else if (param === "menu") {
this.setState(prevState => ({ tooltipMenu: !prevState.tooltipMenu }))
} else if (param === "tambah") {
this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah }))
} else if (param === "export") {
this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport }))
}
}
dataNotAvailable = () => {
if (this.state.dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">{this.props.t('noData')}</td>
</tr>
)
}
}
handleExportExcel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [],
"group_column": {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(TRANSACTION_SEARCH, payload, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.statusText == "OK") {
const dataRes = result.data.data || [];
const dataExport = [];
dataRes.map((val, index) => {
let row = {};
if (this.state.role_name === 'Super Admin') {
row.Company = val.join_first_company_name;
}
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row);
})
this.setState({ dataExport: dataExport }, () => {
this.exportExcel();
});
} else {
NotificationManager.error('Failed retreiving data!!', 'Failed');
}
}
exportExcel = () => {
const dataExcel = this.state.dataExport || [];
const fileName = "Data Project Role.xlsx";
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Data Project Role');
XLSX.writeFile(wb, fileName);
}
render() {
const { t } = this.props;
const { dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state
let noSeq = 0;
return (
<div>
<NotificationContainer />
<SweetAlert
show={this.state.alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={this.props.t('deleteConfirm')}
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
{this.props.t('deleteMsg')}
</SweetAlert>
<SweetAlert
show={this.state.alertNotDelete}
warning
confirmBtnText="Can't Delete"
confirmBtnBsStyle="danger"
title="Data can't be delete!"
onConfirm={() => this.setState({ alertNotDelete: false })}
>
Data project role tidak dapat di hapus!!
</SweetAlert>
<DialogForm
openDialog={openDialog}
closeDialog={this.handleCloseDialog}
toggleDialog={() => this.toggleAddDialog}
typeDialog={this.state.typeDialog}
dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4>
<Row>
<Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('search')} />
</Col>
<Col>
<Tooltip title={this.props.t('rolesAdd')}>
{
checkActMenup('/roles', 'create') ?
<Button Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i>
</Button>
:
null
}
</Tooltip>
<Tooltip title={this.props.t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
</CardHeader>
<CardBody>
<Table
rowKey="id"
size="small"
columns={this.columns}
dataSource={dataTable}
pagination={false}
bordered={false}
/>
<Pagination
style={{ marginTop: "25px" }}
showSizeChanger
onShowSizeChange={this.onShowSizeChange}
onChange={this.onPagination}
defaultCurrent={currentPage}
pageSize={rowsPerPage}
total={totalPage}
pageSizeOptions={["10", "15", "20", "25", "30", "35", "40"]}
/>
</CardBody>
</Card>
</div>
)
}
}
export default withTranslation()(index);

394
src/views/Master/MasterWidget/index.js

@ -0,0 +1,394 @@
import * as XLSX from 'xlsx';
import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE } from '../../../const/ApiConst.js';
import { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next';
const LENGTH_DATA = 10
class index extends Component {
constructor(props) {
super(props);
this.state = {
alertDelete: false,
alertNotDelete: false,
currentPage: 1,
dataEdit: null,
dataExport: [],
dataGs: [],
dataIdHo: [],
dataTable: [],
idDelete: 0,
idRoles: 0,
menuRoles: [],
page: 0,
rowsPerPage: LENGTH_DATA,
search: "",
tooltipDelete: false,
tooltipEdit: false,
tooltipExport: false,
tooltipImport: false,
tooltipMenu: false,
tooltipTambah: false,
totalPage: 0,
company_id: props.company_id || 0,
role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
};
this.columns = [
{
title: this.props.t('action'),
dataIndex: '',
key: 'x',
className: 'nowrap',
render: (text, record) => <>
<Tooltip title={this.props.t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title={this.props.t('edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
</Tooltip>
</>,
},
{
title: this.state.role_name === 'Super Admin' ? "Company Name" : null,
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => {
return this.state.role_name === 'Super Admin' ? (
<span>{record.join_first_company_name}</span>
) : null;
}
},
{ title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('Alias Name'), dataIndex: 'aliasname', key: 'aliasname' },
{ title: this.props.t('Type Layout'), dataIndex: 'aliasname', key: 'aliasname' },
{ title: this.props.t('Master Data'), dataIndex: 'aliasname', key: 'aliasname' },
];
}
async componentDidMount() {
this.getDataRoles();
}
async componentDidUpdate(prevProps, prevState) {
const { search } = this.state
if (search !== prevState.search) this.getDataRoles()
}
handleSearch = e => {
const value = e.target.value
this.setState({ search: value, currentPage: 1 })
};
getDataRoles = async () => {
let start = 0;
if (this.state.currentPage !== 1 && this.state.currentPage > 1) {
start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage
}
const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
} else {
formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_ROLE_SEARCH, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord });
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
onConfirmDelete = async () => {
const { idDelete } = this.state
const url = PROJECT_ROLE_DELETE(idDelete)
const result = await axios.delete(url, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataRoles()
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.success(`Data project role berhasil dihapus`, 'Success!!');
} else {
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.error(`Data project role gagal dihapus`, 'Failed!!');
}
}
saveRole = async (data) => {
const formData = {
name: data.name,
description: data.description,
company_id: data.company_id
}
const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataRoles();
NotificationManager.success(`Data project role berhasil ditambah`, 'Success!!');
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
editRole = async (data) => {
const formData = {
name: data.name,
description: data.description,
company_id : data.company_id
}
const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataRoles();
NotificationManager.success(`Data project role berhasil diedit`, 'Success!!');
} else {
NotificationManager.error(`Data project role gagal di edit`, `Failed!!`);
}
}
handleEdit = (data) => {
this.setState({ dataEdit: data });
}
handleDelete = (id) => {
id == '1' ? this.setState({ alertNotDelete: true }) :
this.setState({ alertDelete: true, idDelete: id });
}
onShowSizeChange = (current, pageSize) => {
this.setState({ rowsPerPage: pageSize }, () => {
this.getDataRoles();
})
}
onPagination = (current, pageSize) => {
this.setState({ currentPage: current, page: (current - 1) * pageSize }, () => {
this.getDataRoles();
})
}
toggle = (param) => {
if (param === "edit") {
this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit }))
} else if (param === "delete") {
this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete }))
} else if (param === "menu") {
this.setState(prevState => ({ tooltipMenu: !prevState.tooltipMenu }))
} else if (param === "tambah") {
this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah }))
} else if (param === "export") {
this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport }))
}
}
dataNotAvailable = () => {
if (this.state.dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">{this.props.t('noData')}</td>
</tr>
)
}
}
handleExportExcel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [],
"group_column": {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_ROLE_SEARCH, payload, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.statusText == "OK") {
const dataRes = result.data.data || [];
const dataExport = [];
dataRes.map((val, index) => {
let row = {};
if (this.state.role_name === 'Super Admin') {
row.Company = val.join_first_company_name;
}
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row);
})
this.setState({ dataExport: dataExport }, () => {
this.exportExcel();
});
} else {
NotificationManager.error('Failed retreiving data!!', 'Failed');
}
}
exportExcel = () => {
const dataExcel = this.state.dataExport || [];
const fileName = "Data Project Role.xlsx";
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Data Project Role');
XLSX.writeFile(wb, fileName);
}
render() {
const { t } = this.props;
const { tooltipTambah, tooltipExport, dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state
let noSeq = 0;
return (
<div>
<NotificationContainer />
<SweetAlert
show={this.state.alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={this.props.t('deleteConfirm')}
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
{this.props.t('deleteMsg')}
</SweetAlert>
<SweetAlert
show={this.state.alertNotDelete}
warning
confirmBtnText="Can't Delete"
confirmBtnBsStyle="danger"
title="Data can't be delete!"
onConfirm={() => this.setState({ alertNotDelete: false })}
>
Data project role tidak dapat di hapus!!
</SweetAlert>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4>
<Row>
<Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('search')} />
</Col>
<Col>
<Tooltip title={this.props.t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
</CardHeader>
<CardBody>
<Table
rowKey="id"
size="small"
columns={this.columns}
dataSource={dataTable}
pagination={false}
bordered={false}
/>
<Pagination
style={{ marginTop: "25px" }}
showSizeChanger
onShowSizeChange={this.onShowSizeChange}
onChange={this.onPagination}
defaultCurrent={currentPage}
pageSize={rowsPerPage}
total={totalPage}
pageSizeOptions={["10", "15", "20", "25", "30", "35", "40"]}
/>
</CardBody>
</Card>
</div>
)
}
}
export default withTranslation()(index);

15
src/views/Pages/Login/Login.js

@ -212,7 +212,8 @@ class Login extends Component {
company_id, company_id,
role_name, role_name,
all_project, all_project,
user_name user_name,
configApp
} }
}); });
} }
@ -366,8 +367,8 @@ class Login extends Component {
<div style={{ <div style={{
boxShadow: '1px 1px 11px 1px rgba(221,211,211,0.75)', boxShadow: '1px 1px 11px 1px rgba(221,211,211,0.75)',
}}> }}>
<CardGroup style={{height:'100%', display:'flex', alignContent:'center'}}> <CardGroup style={{height:'100%', display:'flex', alignContent:'center', backgroundColor:'#fff'}}>
<Card className="p-4" style={{border:'solid #fff'}}> <Card className="p-4" style={{border:'solid #fff', backgroundColor:'#fff'}}>
<CardBody> <CardBody>
<Form onSubmit={this.submitForm}> <Form onSubmit={this.submitForm}>
{this.getLoginLogo()} {this.getLoginLogo()}
@ -375,7 +376,7 @@ class Login extends Component {
<h1 className="mb-1" style={{coror:'#232323'}}>Welcome to OSPRO!</h1> <h1 className="mb-1" style={{coror:'#232323'}}>Welcome to OSPRO!</h1>
<p style={{fontSize:'16px', color:'#898989'}}>Please sign-in to your account and start the adventure</p> <p style={{fontSize:'16px', color:'#898989'}}>Please sign-in to your account and start the adventure</p>
</div> </div>
<InputGroup className="mb-3"> <InputGroup className="mb-3">
<InputGroupAddon addonType="prepend"> <InputGroupAddon addonType="prepend">
<InputGroupText> <InputGroupText>
@ -393,7 +394,7 @@ class Login extends Component {
}} }}
/> />
</InputGroup> </InputGroup>
<InputGroup > <InputGroup >
<InputGroupAddon addonType="prepend"> <InputGroupAddon addonType="prepend">
<InputGroupText> <InputGroupText>
@ -427,7 +428,7 @@ class Login extends Component {
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col className="text-right "> <Col className="text-right ">
{this.state.loader ? ( {this.state.loader ? (
<Spin indicator={antIcon} /> <Spin indicator={antIcon} />
@ -436,7 +437,7 @@ class Login extends Component {
)} )}
</Col> </Col>
</Row> </Row>
</Form> </Form>
</CardBody> </CardBody>
</Card> </Card>

7
src/views/SimproV2/CreatedProyek/AsignCustProject.js

@ -13,8 +13,7 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignCust from './DialogAssignCust'; import FormAsignCust from './DialogAssignCust';
const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id }) => { const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id, token }) => {
const token = localStorage.getItem("token")
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -42,7 +41,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
}, },
"columns": [ "columns": [
{ "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" }, { "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" },
{ "name": "proyek_id", "logic_operator": "=", "value": idTask }, { "name": "proyek_id", "logic_operator": "=", "value": parseInt(idTask) },
{ "name": "is_customer", "logic_operator": "=", "value": "true" } { "name": "is_customer", "logic_operator": "=", "value": "true" }
], ],
"joins": [ "joins": [
@ -84,7 +83,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
} }
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete, company_id) let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete, parseInt(company_id))
const result = await axios.delete(urlDel, HEADER) const result = await axios.delete(urlDel, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

8
src/views/SimproV2/CreatedProyek/AsignHrProject.js

@ -11,8 +11,7 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignHr from './FormAsignHr'; import FormAsignHr from './FormAsignHr';
import { formatThousand } from '../../../const/CustomFunc'; import { formatThousand } from '../../../const/CustomFunc';
const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName }) => { const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName, token }) => {
const token = localStorage.getItem("token")
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -93,7 +92,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan
"length": -1 "length": -1
}, },
"columns": [ "columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) },
], ],
"orders": { "orders": {
"columns": [ "columns": [
@ -119,8 +118,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan
"length": -1 "length": -1
}, },
"columns": [ "columns": [
{ "name": "created_by", "logic_operator": "ilike", "value": "" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) },
{ "name": "company_id", "logic_operator": "=", "value": company_id },
], ],
"joins": [], "joins": [],
"orders": { "orders": {

6
src/views/SimproV2/CreatedProyek/DialogAssignCust.js

@ -44,14 +44,14 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, compa
"select": [ "select": [
"id", "id",
"name", "name",
"role_id" "is_customer"
], ],
"paging": { "paging": {
"start": 0, "start": 0,
"length": -1 "length": -1
}, },
"columns": [ "columns": [
{ "name": "role_id", "logic_operator": "=", "value": 44 }, { "name": "is_customer", "logic_operator": "=", "value": true },
{ "name": "company_id", "logic_operator": "=", "value": company_id }, { "name": "company_id", "logic_operator": "=", "value": company_id },
], ],
"orders": { "orders": {
@ -69,7 +69,7 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, compa
if (result && result.status == 200) { if (result && result.status == 200) {
let dataRes = result.data.data; let dataRes = result.data.data;
const filteredData = dataRes.filter(item => item.role_id === 44); const filteredData = dataRes.filter(item => item.is_customer === true);
setTransferUser(filteredData); setTransferUser(filteredData);
} }
} }

50
src/views/SimproV2/CreatedProyek/DialogDocument.js

@ -5,14 +5,12 @@ import { Table, Tooltip, Popover, Spin } from 'antd';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import moment from 'moment'; import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE_COMPANY, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst'; import { DOCUMENT_DOWNLOAD, BASE_SIMPRO_LUMEN_FILE_COMPANY, DOCUMENT_DELETE, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import DialogRequest from './FormDocument'; import DialogRequest from './FormDocument';
import DialogRequestFolder from './FormFolderDocument'; import DialogRequestFolder from './FormFolderDocument';
const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => { const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, token, role_name, companyName }) => {
const token = localStorage.getItem("token")
const role = window.localStorage.getItem('role_name');
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -28,14 +26,13 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
const [dataEdit, setDataEdit] = useState(null) const [dataEdit, setDataEdit] = useState(null)
const [parentIdNewFolder, setParentIdNewFolder] = useState(0) const [parentIdNewFolder, setParentIdNewFolder] = useState(0)
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const company_id = window.localStorage.getItem('company_id');
useEffect(() => { useEffect(() => {
if (idTask > 0) { if (parseInt(idTask) > 0) {
setLoading(true); setLoading(true);
getDataDocument(); getDataDocument();
} }
}, [idTask, openDialog]) }, [openDialog])
useEffect(() => { useEffect(() => {
if (!openDialog) { if (!openDialog) {
@ -45,13 +42,8 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
} }
}, [openDialog]) }, [openDialog])
const getDataDocument = async () => { const getDataDocument = async () => {
const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask) const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(parseInt(idTask))
const result = await axios const result = await axios
.get(url, HEADER) .get(url, HEADER)
.then(res => res) .then(res => res)
@ -81,7 +73,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
} }
const handleDownload = (id, file) => { const handleDownload = (id, file) => {
fetch(DOCUMENT_DOWNLOAD(id, company_id), { fetch(DOCUMENT_DOWNLOAD(id, parseInt(companyId)), {
headers: new Headers({ headers: new Headers({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': `Bearer ${token}` 'Authorization': `Bearer ${token}`
@ -99,12 +91,8 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}); });
} }
const handleShow = (file) => { const handleShow = (file, dateFile) => {
let configApp = ''; const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, companyName, dateFile)}`
if (role !== 'Super Admin') {
configApp = JSON.parse(window.localStorage.getItem('configApp'));
}
const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, configApp != '' ? configApp.company_name : 'undifined')}`
window.open(urlShow); window.open(urlShow);
} }
@ -128,15 +116,16 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
openDialogRequest() openDialogRequest()
} }
const renderShowDokumen = (file) => { const renderShowDokumen = (data) => {
let arrayFile = file.split(".") let arrayFile = data.file.split(".")
const dateFile = moment(data.created_at).format('YYYY-MM');
let length = arrayFile.length let length = arrayFile.length
length = length - 1 length = length - 1
const fileExt = arrayFile[length]; const fileExt = arrayFile[length];
if (fileExt == "pdf" || fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg" || fileExt == "gif") { if (["pdf", "png", "jpg", "jpeg", "gif"].includes(fileExt)) {
return ( return (
<Tooltip title="View Document"> <Tooltip title="View Document">
<Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(file)}><i className="fa fa-eye"></i></Button> <Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(data.file, dateFile)}><i className="fa fa-eye"></i></Button>
</Tooltip> </Tooltip>
) )
} }
@ -165,7 +154,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
{record.isDir && <Tooltip title="New File"> {record.isDir && <Tooltip title="New File">
<Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button> <Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button>
</Tooltip>}{" "} </Tooltip>}{" "}
{text.file ? renderShowDokumen(text.file) : ""} {text.file ? renderShowDokumen(text) : ""}
</> </>
, ,
}, },
@ -211,7 +200,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
} }
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let urlDel = DOCUMENT_DELETE(idDelete, company_id) let urlDel = DOCUMENT_DELETE(idDelete, parseInt(companyId))
const result = await axios.delete(urlDel, HEADER) const result = await axios.delete(urlDel, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -229,7 +218,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
} }
const onConfirmDeleteFolder = async () => { const onConfirmDeleteFolder = async () => {
let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete) let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete, parseInt(companyId))
const result = await axios.delete(urlDel, HEADER) const result = await axios.delete(urlDel, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -322,16 +311,19 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
openDialog={openDialogReq} openDialog={openDialogReq}
closeDialog={closeDialogReq} closeDialog={closeDialogReq}
toggleDialog={toggleDialogReq} toggleDialog={toggleDialogReq}
idTask={idTask} idTask={parseInt(idTask)}
parentIdNewFolder={parentIdNewFolder} parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit} dataEdit={dataEdit}
companyId={companyId}
token={token}
role_name={role_name}
/> />
<DialogRequestFolder <DialogRequestFolder
openDialog={openDialogNewFolder} openDialog={openDialogNewFolder}
closeDialog={closeDialogNewFolder} closeDialog={closeDialogNewFolder}
toggleDialog={toggleDialogNewFolder} toggleDialog={toggleDialogNewFolder}
idTask={idTask} idTask={parseInt(idTask)}
parentIdNewFolder={parentIdNewFolder} parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit} dataEdit={dataEdit}
/> />

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

@ -37,9 +37,9 @@ const DialogFormProyek = ({
projectImage, projectImage,
company_id, company_id,
role_name, role_name,
token,
companyList companyList
}) => { }) => {
const token = localStorage.getItem("token");
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",

29
src/views/SimproV2/CreatedProyek/DialogGantt.js

@ -13,18 +13,7 @@ import DialogUserGantt from './DialogUserGantt';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
const { Option } = Select const { Option } = Select
const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id, dataViewStartDate }) => { const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id, dataViewStartDate }) => {
if (role_id && user_id && token && isLogin) {
role_id = role_id;
user_id = user_id;
token = token;
isLogin = isLogin;
} else {
role_id = localStorage.getItem("role_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
}
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -140,16 +129,22 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
<Link to={{ <Link to={{
pathname: `/projects/${text.id}/${idTask}/gantt`, pathname: `/projects/${text.id}/${idTask}/gantt`,
state: { state: {
isLogin: isLogin, isLogin,
token: token, token,
role_id: role_id, role_id,
user_id: user_id, user_id,
dataViewStartDate: dataViewStartDate company_id: companyId,
dataViewStartDate
} }
}}> }}>
<Tooltip title="Gantt"> <Tooltip title="Gantt">
<Button size={"sm"} color='primary'><i className="fa fa-gears"></i></Button> <Button size={"sm"} color='primary'><i className="fa fa-gears"></i></Button>
</Tooltip></Link>{" "} </Tooltip></Link>{" "}
<Link to={`/kanban/${idTask}/${text.id}`}>
<Tooltip title="Kanban">
<Button id="kanban" className="kanban" name="kanban" size={"sm"} color='primary'><i className="fa fa-calendar"></i></Button>
</Tooltip>
</Link>{" "}
</> </>
, ,
}, },

17
src/views/SimproV2/CreatedProyek/FormDocument.js

@ -6,9 +6,8 @@ import { DOCUMENT_ADD } from '../../../const/ApiConst';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { NotificationManager } from 'react-notifications'; import { NotificationManager } from 'react-notifications';
const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => { const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder, token, role_name, companyId }) => {
const token = localStorage.getItem("token");
const role = window.localStorage.getItem('role_name');
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -34,12 +33,9 @@ const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentId
} }
const uploadDokumen = async () => { const uploadDokumen = async () => {
let configApp = '';
const formData = new FormData; const formData = new FormData;
if (role !== 'Super Admin') {
configApp = JSON.parse(window.localStorage.getItem('configApp')); formData.append('company_id', parseInt(companyId));
formData.append('company_name',configApp.company_name);
}
formData.append('dokumen', file, file.name); formData.append('dokumen', file, file.name);
if (parentIdNewFolder > 0) { if (parentIdNewFolder > 0) {
formData.append('ref_id', parentIdNewFolder); // folder_id formData.append('ref_id', parentIdNewFolder); // folder_id
@ -73,8 +69,9 @@ const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentId
return ( return (
<Form> <Form>
<FormGroup> <FormGroup>
<Label className="capitalize">Upload File</Label> <Label className="capitalize">Upload File<span style={{ color:'red' }}>*</span></Label>
<Input type="file" onChange={(e) => setFile(e.target.files[0])} /> <Input type="file" onChange={(e) => setFile(e.target.files[0])}/>
<small><span style={{ color:'red' }}>*</span>All Type File Accepted</small>
</FormGroup> </FormGroup>
</Form> </Form>
) )

188
src/views/SimproV2/CreatedProyek/FormFolderDocument.js

@ -1,96 +1,92 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap';
import axios from "../../../const/interceptorApi"; import axios from "../../../const/interceptorApi";
import { DOCUMENT_ADD, FOLDER_DOCUMENT_PROYEK_ADD } from '../../../const/ApiConst'; import { FOLDER_DOCUMENT_PROYEK_ADD } from '../../../const/ApiConst';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { NotificationManager } from 'react-notifications'; import { NotificationManager } from 'react-notifications';
const DialogRequestFolder = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => { const DialogRequestFolder = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => {
const token = localStorage.getItem("token") const token = localStorage.getItem("token")
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": `Bearer ${token}` "Authorization": `Bearer ${token}`
} }
} }
const [id, setId] = useState(0) const [id, setId] = useState(0)
const [folderName, setFolderName] = useState('') const [folderName, setFolderName] = useState('')
const handleClearData = () => { const handleClearData = () => {
setId(0) setId(0)
setFolderName('') setFolderName('')
} }
useEffect(() => { useEffect(() => {
handleClearData() handleClearData()
}, [openDialog]) }, [openDialog])
const handleSave = () => { const handleSave = () => {
saveFolder() saveFolder()
handleClearData() handleClearData()
} }
const saveFolder = async () => { const saveFolder = async () => {
let payload = {
"proyek_id": idTask,
"name_folder": folderName
}
let payload = {
"proyek_id": idTask, if (parentIdNewFolder > 0) {
"name_folder": folderName payload.parent_id = parentIdNewFolder
} }
if (parentIdNewFolder > 0) { const result = await axios
payload.parent_id = parentIdNewFolder .post(FOLDER_DOCUMENT_PROYEK_ADD, payload, HEADER)
} .then(res => res)
.catch((error) => error.response);
const result = await axios
.post(FOLDER_DOCUMENT_PROYEK_ADD, payload, HEADER) if (result && result.data && result.data.code == 200) {
.then(res => res) NotificationManager.success('Success create folder!!', 'Success');
.catch((error) => error.response); closeDialog("upload");
} else {
if (result && result.data && result.data.code == 200) { NotificationManager.error('Failed to create folder!!', 'Failed');
NotificationManager.success('Success create folder!!', 'Success'); }
closeDialog("upload"); }
} else {
NotificationManager.error('Failed to create folder!!', 'Failed'); const handleCancel = () => {
} closeDialog('cancel')
} handleClearData()
}
const handleCancel = () => {
closeDialog('cancel') const renderForm = () => {
handleClearData() return (
} <Form>
<FormGroup>
const renderForm = () => { <Label className="capitalize">Folder Name</Label>
return ( <Input type="text" onChange={(e) => setFolderName(e.target.value)} />
<Form> </FormGroup>
<FormGroup> </Form>
<Label className="capitalize">Folder Name</Label> )
<Input type="text" onChange={(e) => setFolderName(e.target.value)} /> }
</FormGroup>
</Form>
) return (
} <>
<Modal isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>Create New Folder</ModalHeader>
return ( <ModalBody>
<> {renderForm()}
<Modal isOpen={openDialog} toggle={toggleDialog}> </ModalBody>
<ModalHeader className="capitalize" toggle={closeDialog}>Create New Folder</ModalHeader> <ModalFooter>
<ModalBody> <Button color="primary" onClick={() => handleSave()}>Save</Button>{' '}
{renderForm()} <Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Cancel</Button>
</ModalBody> </ModalFooter>
<ModalFooter> </Modal>
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '} </>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Cancel</Button> )
</ModalFooter>
</Modal> }
</>
) export default DialogRequestFolder;
}
export default DialogRequestFolder;

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

@ -91,7 +91,7 @@ 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 = '', configApp={};
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;
@ -155,6 +155,8 @@ const CreatedProyek = ({ params, ...props }) => {
const [openDialogDoc, setOpenDialogDoc] = useState(false); const [openDialogDoc, setOpenDialogDoc] = useState(false);
const [proyekName, setProyekName] = useState(""); const [proyekName, setProyekName] = useState("");
const [openDialogProyek, setOpenDialogProyek] = useState(false); const [openDialogProyek, setOpenDialogProyek] = useState(false);
const [companyId, setCompanyId] = useState(props.role_name !== 'Super Admin' ? company_id : 0);
const [companyName, setCompanyName] = useState('');
// project charter // project charter
const [projectCharter, setProjectCharter] = useState(null); const [projectCharter, setProjectCharter] = useState(null);
const [projectParticipant, setProjectParticipant] = useState(null); const [projectParticipant, setProjectParticipant] = useState(null);
@ -369,7 +371,14 @@ const CreatedProyek = ({ params, ...props }) => {
} }
const payload = { const payload = {
columns: [], columns: [
{
name: "deleted_at",
logic_operator: "isnull",
value: "null",
operator: "AND"
}
],
group_column: { group_column: {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
@ -401,6 +410,9 @@ const CreatedProyek = ({ params, ...props }) => {
"currency_symbol", "currency_symbol",
"mulai_proyek", "mulai_proyek",
"akhir_proyek", "akhir_proyek",
"company_id",
"deleted_at",
"deleted_by_id"
], ],
joins: [ joins: [
{ {
@ -418,12 +430,12 @@ const CreatedProyek = ({ params, ...props }) => {
paging: { start: start, length: rowsPerPage }, paging: { start: start, length: rowsPerPage },
}; };
if (all_project !== null && all_project === true) { if (role_name !== 'Super Admin' && all_project === 'true') {
payload.columns.push( payload.columns.push(
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } { name: "company_id", logic_operator: "like", value: parseInt(company_id), operator: "AND" }
); );
} }
if (role_name !== 'Super Admin') { if (role_name !== 'Super Admin' && all_project === 'null') {
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" }
); );
@ -553,11 +565,12 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
const handleOpenDialogProyek = async (id) => { const handleOpenDialogProyek = async (text) => {
setCompanyId(text.company_id);
setOpenDialogProyek(true); setOpenDialogProyek(true);
setidTask(id); setidTask(text.id);
if (id !== 0) { if (text.id !== 0) {
await getProjectImage(id); await getProjectImage(text.id);
} }
}; };
@ -565,6 +578,7 @@ const CreatedProyek = ({ params, ...props }) => {
setDataViewStartDate(data.mulai_proyek) setDataViewStartDate(data.mulai_proyek)
setidTask(data.id); setidTask(data.id);
setProyekName(data.nama); setProyekName(data.nama);
setCompanyId(data.company_id);
setOpenDialogGantt(true); setOpenDialogGantt(true);
}; };
@ -599,12 +613,16 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenAsignHr = (data) => { const handleOpenAsignHr = (data) => {
setidTask(data.id); setidTask(data.id);
setProyekName(data.nama); setProyekName(data.nama);
setCompanyId(data.company_id);
setCompanyName(role_name === 'Super Admin' ? data.join_third_company_name : JSON.parse(props.configApp).company_name);
setOpenDialogAsignHR(true); setOpenDialogAsignHR(true);
}; };
const handleOpenAsignCust = (data) => { const handleOpenAsignCust = (data) => {
setidTask(data.id); setidTask(data.id);
setProyekName(data.nama); setProyekName(data.nama);
setCompanyId(data.company_id);
setCompanyName(role_name === 'Super Admin' ? data.join_third_company_name : JSON.parse(props.configApp).company_name);
setOpenDialogAsignCust(true); setOpenDialogAsignCust(true);
}; };
@ -1375,7 +1393,14 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportExcel = async () => { const handleExportExcel = async () => {
const payload = { const payload = {
columns: [], columns: [
{
name: "deleted_at",
logic_operator: "isnull",
value: "null",
operator: "AND"
}
],
group_column: { group_column: {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
@ -1462,7 +1487,14 @@ const CreatedProyek = ({ params, ...props }) => {
]; ];
const payload = { const payload = {
columns: [], columns: [
{
name: "deleted_at",
logic_operator: "isnull",
value: "null",
operator: "AND"
}
],
group_column: { group_column: {
"operator": "AND", "operator": "AND",
"group_operator": "OR", "group_operator": "OR",
@ -1568,6 +1600,8 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenDokumen = async (data) => { const handleOpenDokumen = async (data) => {
await setidTask(data.id); await setidTask(data.id);
setProyekName(data.nama); setProyekName(data.nama);
setCompanyId(data.company_id);
setCompanyName(role_name === 'Super Admin' ? data.join_third_company_name : JSON.parse(props.configApp).company_name);
setOpenDialogDoc(true); setOpenDialogDoc(true);
}; };
@ -1627,7 +1661,7 @@ const CreatedProyek = ({ params, ...props }) => {
</div> </div>
<div <div
className="menu-list" className="menu-list"
onClick={() => handleOpenDialogProyek(text.id)} onClick={() => handleOpenDialogProyek(text)}
> >
<span className="menu-icon"> <span className="menu-icon">
<i className="fa fa-edit"></i> <i className="fa fa-edit"></i>
@ -1656,7 +1690,17 @@ const CreatedProyek = ({ params, ...props }) => {
{!loadVersionGantt && text.type_proyek_id !== 9 && ( {!loadVersionGantt && text.type_proyek_id !== 9 && (
<> <>
{dataVersionGantt.slice(0, 8).map((res) => ( {dataVersionGantt.slice(0, 8).map((res) => (
<Link to={`/projects/${res.id}/${text.id}/gantt`}> <Link to={{
pathname : `/projects/${res.id}/${text.id}/gantt`,
state: {
isLogin,
token,
role_id,
user_id,
company_id: text.company_id,
dataViewStartDate
}
}}>
<div className="menu-list"> <div className="menu-list">
<span className="menu-icon"> <span className="menu-icon">
<i className="fa fa-file"></i> <i className="fa fa-file"></i>
@ -1888,9 +1932,10 @@ const CreatedProyek = ({ params, ...props }) => {
dataDivisions={dataDivisions} dataDivisions={dataDivisions}
dataPM={dataPm} dataPM={dataPm}
projectImage={image} projectImage={image}
company_id={company_id} company_id={companyId}
role_name={role_name} role_name={role_name}
companyList={companyList} companyList={companyList}
token={token}
/> />
), ),
[ [
@ -1952,7 +1997,8 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogAsignHr} handleClose={handleCloseDialogAsignHr}
idTask={idTask} idTask={idTask}
proyekName={proyekName} proyekName={proyekName}
company_id={company_id} company_id={companyId}
token={token}
/> />
), ),
[openDialogAsignHR] [openDialogAsignHR]
@ -1968,7 +2014,8 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogAsignCust} handleClose={handleCloseDialogAsignCust}
idTask={idTask} idTask={idTask}
proyekName={proyekName} proyekName={proyekName}
company_id={company_id} company_id={companyId}
token={token}
/> />
), ),
[openDialogAsignCust] [openDialogAsignCust]
@ -2003,6 +2050,10 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogDoc} handleClose={handleCloseDialogDoc}
idTask={idTask} idTask={idTask}
proyekName={proyekName} proyekName={proyekName}
companyId={companyId}
token={token}
role_name={role_name}
companyName={companyName}
/> />
), ),
[openDialogDoc] [openDialogDoc]
@ -2053,6 +2104,7 @@ const CreatedProyek = ({ params, ...props }) => {
token={token} token={token}
isLogin={isLogin} isLogin={isLogin}
proyekName={proyekName} proyekName={proyekName}
companyId={companyId}
dataViewStartDate={dataViewStartDate} dataViewStartDate={dataViewStartDate}
/> />
), ),

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

@ -4,7 +4,7 @@ import React, { useState, useEffect, useMemo } 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 } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; import { 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, Table, Spin } from 'antd'; import { Pagination, Button, Tooltip, Table, Spin } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -120,9 +120,6 @@ const ProjectType = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
) )
} else { } else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
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"] }
) )
@ -183,9 +180,6 @@ const ProjectType = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
) )
} else { } else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
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"] }
) )
@ -414,7 +408,7 @@ const ProjectType = ({ params, ...props }) => {
: :
null null
} }
</Tooltip> </Tooltip>
<Tooltip title="Add"> <Tooltip title="Add">
{ {

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

@ -4,9 +4,9 @@ import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
const GanttFrame = React.memo((props) => { const GanttFrame = React.memo((props) => {
const history = useHistory(); const history = useHistory();
const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, company_id, role_name } = props; const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, companyId, role_name } = props;
const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`; const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}`;
// const iframeSrc = `http://localhost:8444/generic-ospro-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`; // const iframeSrc = `http://localhost:8444/generic-ospro-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}`;
const [batchEntityData, setBatchEntityData] = useState(null); const [batchEntityData, setBatchEntityData] = useState(null);
useEffect(() => { useEffect(() => {

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

@ -15,13 +15,13 @@ import GanttFrame from "./GanttFrame";
let roCount = 0; let roCount = 0;
const Gantt = (props) => { const Gantt = (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 = '', companyId = 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; companyId = 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;
@ -114,7 +114,7 @@ const Gantt = (props) => {
token={token} token={token}
ro={ro} ro={ro}
role_name={role_name} role_name={role_name}
company_id={company_id} companyId={companyId}
timestamp={timestamp} timestamp={timestamp}
/> />
)} )}

12
src/views/SimproV2/Kanban/index.js

@ -240,7 +240,7 @@ const Kanban = ({ params, ...props }) => {
const payload = { const payload = {
columns: [ columns: [
{ {
name: "created_by", name: "created_by_id",
logic_operator: "IN", logic_operator: "IN",
value: hierarchy, value: hierarchy,
operator: "AND" operator: "AND"
@ -261,11 +261,9 @@ const Kanban = ({ params, ...props }) => {
orders: { columns: ["id"], ascending: false }, orders: { columns: ["id"], ascending: false },
}; };
if (parseInt(role_id) !== 1) { // if (parseInt(role_id) !== 1) {
payload["columns"] = [ // payload.columns.push( { name: "id", logic_operator: "=", value: project, operator: "AND" });
{ name: "id", logic_operator: "=", value: project, operator: "AND" }, // }
];
}
const result = await axios const result = await axios
.post(PROYEK_SEARCH, payload, HEADER) .post(PROYEK_SEARCH, payload, HEADER)
@ -435,7 +433,7 @@ const Kanban = ({ params, ...props }) => {
} }
} }
// Board // Board
const handleCloseDialogBoard = (type, data) => { const handleCloseDialogBoard = (type, data) => {
if (type === "save") { if (type === "save") {

352
src/views/SimproV2/LimitasiUser/index.js

@ -0,0 +1,352 @@
import * as XLSX from 'xlsx';
import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import moment from 'moment';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, STORAGE_LIMIT_INFORMATION_ALL_COMPANY, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE } from '../../../const/ApiConst.js';
import { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next';
const LENGTH_DATA = 10
class index extends Component {
constructor(props) {
super(props);
this.state = {
alertDelete: false,
alertNotDelete: false,
currentPage: 1,
dataEdit: null,
dataExport: [],
dataGs: [],
dataIdHo: [],
dataTable: [],
idDelete: 0,
idRoles: 0,
menuRoles: [],
page: 0,
rowsPerPage: LENGTH_DATA,
search: "",
tooltipDelete: false,
tooltipEdit: false,
tooltipExport: false,
tooltipImport: false,
tooltipMenu: false,
tooltipTambah: false,
totalPage: 0,
company_id: props.company_id || 0,
role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
};
this.columns = [
{
title: this.state.role_name === 'Super Admin' ? "Company Name" : null,
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => {
return this.state.role_name === 'Super Admin' ? (
<span>{record.join_first_company_name}</span>
) : null;
}
},
{ title: this.props.t('Company'), dataIndex: 'company_name', key: 'company_name', className: "nowrap" },
{
title: this.props.t('Expired'),
dataIndex: 'exp_ospro',
key: 'exp_ospro',
render: (text, record) => {
return text ? moment(text).format("D-M-YYYY HH:mm:ss") : '-';
}
},
{ title: this.props.t('Storage'), dataIndex: 'size', key: 'size' },
{ title: this.props.t('Total Project'), dataIndex: 'project_total', key: 'project_total' },
];
}
async componentDidMount() {
this.getDataRoles();
}
async componentDidUpdate(prevProps, prevState) {
const { search } = this.state
if (search !== prevState.search) this.getDataRoles()
}
handleSearch = e => {
const value = e.target.value
this.setState({ search: value, currentPage: 1 })
};
getDataRoles = async () => {
const result = await axios
.get(STORAGE_LIMIT_INFORMATION_ALL_COMPANY, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result) {
this.setState({ dataTable: result.data});
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
onConfirmDelete = async () => {
const { idDelete } = this.state
const url = PROJECT_ROLE_DELETE(idDelete)
const result = await axios.delete(url, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataRoles()
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.success(`Data project role berhasil dihapus`, 'Success!!');
} else {
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.error(`Data project role gagal dihapus`, 'Failed!!');
}
}
saveRole = async (data) => {
const formData = {
name: data.name,
description: data.description,
company_id: data.company_id
}
const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataRoles();
NotificationManager.success(`Data project role berhasil ditambah`, 'Success!!');
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
editRole = async (data) => {
const formData = {
name: data.name,
description: data.description,
company_id : data.company_id
}
const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.getDataRoles();
NotificationManager.success(`Data project role berhasil diedit`, 'Success!!');
} else {
NotificationManager.error(`Data project role gagal di edit`, `Failed!!`);
}
}
handleEdit = (data) => {
this.setState({ dataEdit: data });
}
handleDelete = (id) => {
id == '1' ? this.setState({ alertNotDelete: true }) :
this.setState({ alertDelete: true, idDelete: id });
}
onShowSizeChange = (current, pageSize) => {
this.setState({ rowsPerPage: pageSize }, () => {
this.getDataRoles();
})
}
onPagination = (current, pageSize) => {
this.setState({ currentPage: current, page: (current - 1) * pageSize }, () => {
this.getDataRoles();
})
}
toggle = (param) => {
if (param === "edit") {
this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit }))
} else if (param === "delete") {
this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete }))
} else if (param === "menu") {
this.setState(prevState => ({ tooltipMenu: !prevState.tooltipMenu }))
} else if (param === "tambah") {
this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah }))
} else if (param === "export") {
this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport }))
}
}
dataNotAvailable = () => {
if (this.state.dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">{this.props.t('noData')}</td>
</tr>
)
}
}
handleExportExcel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [],
"group_column": {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_ROLE_SEARCH, payload, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.statusText == "OK") {
const dataRes = result.data.data || [];
const dataExport = [];
dataRes.map((val, index) => {
let row = {};
if (this.state.role_name === 'Super Admin') {
row.Company = val.join_first_company_name;
}
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row);
})
this.setState({ dataExport: dataExport }, () => {
this.exportExcel();
});
} else {
NotificationManager.error('Failed retreiving data!!', 'Failed');
}
}
exportExcel = () => {
const dataExcel = this.state.dataExport || [];
const fileName = "Data Project Role.xlsx";
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Data Project Role');
XLSX.writeFile(wb, fileName);
}
render() {
const { t } = this.props;
const { tooltipTambah, tooltipExport, dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state
let noSeq = 0;
return (
<div>
<NotificationContainer />
<SweetAlert
show={this.state.alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={this.props.t('deleteConfirm')}
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
{this.props.t('deleteMsg')}
</SweetAlert>
<SweetAlert
show={this.state.alertNotDelete}
warning
confirmBtnText="Can't Delete"
confirmBtnBsStyle="danger"
title="Data can't be delete!"
onConfirm={() => this.setState({ alertNotDelete: false })}
>
Data project role tidak dapat di hapus!!
</SweetAlert>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4>
<Row>
<Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('search')} />
</Col>
<Col>
<Tooltip title={this.props.t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
</CardHeader>
<CardBody>
<Table
rowKey="id"
size="small"
columns={this.columns}
dataSource={dataTable}
pagination={false}
bordered={false}
/>
<Pagination
style={{ marginTop: "25px" }}
showSizeChanger
onShowSizeChange={this.onShowSizeChange}
onChange={this.onPagination}
defaultCurrent={currentPage}
pageSize={rowsPerPage}
total={totalPage}
pageSizeOptions={["10", "15", "20", "25", "30", "35", "40"]}
/>
</CardBody>
</Card>
</div>
)
}
}
export default withTranslation()(index);

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

@ -33,7 +33,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [divisionId, setDivisionId] = useState('') const [divisionId, setDivisionId] = useState('')
const [statusResource, setStatusResource] = useState('active') const [statusResource, setStatusResource] = useState('active')
const [statusRestriction, setStatusRestriction] = useState(false) const [statusRestriction, setStatusRestriction] = useState(false)
const [statusCustomer, setStatusCustomer] = useState(false)
const { t } = useTranslation() const { t } = useTranslation()
useEffect(() => { useEffect(() => {
if (typeDialog === "Edit" || typeDialog === "Set") { if (typeDialog === "Edit" || typeDialog === "Set") {
setId(dataEdit.id) setId(dataEdit.id)
@ -55,6 +57,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setDivisionId(dataEdit.divisi_id) setDivisionId(dataEdit.divisi_id)
setAddress(dataEdit.address) setAddress(dataEdit.address)
setStatusRestriction(dataEdit.status_boundary) setStatusRestriction(dataEdit.status_boundary)
setStatusCustomer(dataEdit.is_customer)
} else { } else {
setId(0) setId(0)
setResourceName('') setResourceName('')
@ -76,6 +79,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setCompanyId(null) setCompanyId(null)
setStatusResource('active') setStatusResource('active')
setStatusRestriction(false) setStatusRestriction(false)
setStatusCustomer(false)
} }
}, [dataEdit, openDialog]) }, [dataEdit, openDialog])
@ -104,14 +108,17 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
gender, gender,
birth_place: birthPlace, birth_place: birthPlace,
ktp_number: ktpNumber, ktp_number: ktpNumber,
role_id: roleId,
divisi_id: divisionId,
address, address,
status_resource: statusResource, status_resource: statusResource,
status_boundary: statusRestriction, status_boundary: statusRestriction,
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
} }
if(statusCustomer === false) {
data.role_id = roleId;
data.divisi_id = divisionId;
}
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
data['birth_date'] = birthDate; data['birth_date'] = birthDate;
} }
@ -153,13 +160,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
blood_type: bloodType, blood_type: bloodType,
ktp_number: ktpNumber, ktp_number: ktpNumber,
biaya_per_jam: biayaPerJam.replace('.', ''), biaya_per_jam: biayaPerJam.replace('.', ''),
role_id: roleId,
divisi_id: divisionId,
address, address,
status_resource: statusResource, status_resource: statusResource,
status_boundary: statusRestriction, status_boundary: statusRestriction,
is_customer: statusCustomer,
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
} }
if(statusCustomer === false) {
data.role_id = roleId;
data.divisi_id = divisionId;
}
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
data['birth_date'] = birthDate; data['birth_date'] = birthDate;
@ -283,25 +293,28 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
<Row> {
<Col md={6}> statusCustomer === false && (
<FormGroup> <Row>
<Label className="capitalize">{t('roles')} <span style={{ color: "red" }}>*</span></Label> <Col md={6}>
<Select showSearch defaultValue={roleId} onChange={(val) => setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}> <FormGroup>
{setupSelectRole()} <Label className="capitalize">{t('roles')} <span style={{ color: "red" }}>*</span></Label>
</Select> <Select showSearch defaultValue={roleId} onChange={(val) => setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}>
</FormGroup> {setupSelectRole()}
</Col> </Select>
<Col md={6}> </FormGroup>
<FormGroup> </Col>
<Label className="capitalize">{t('division')} <span style={{ color: "red" }}>*</span></Label> <Col md={6}>
<Select showSearch defaultValue={divisionId} onChange={(val) => setDivisionId(val)} placeholder={t('selectDivision')} style={{ width: '100%' }}> <FormGroup>
{setupSelectDivisi()} <Label className="capitalize">{t('division')} <span style={{ color: "red" }}>*</span></Label>
</Select> <Select showSearch defaultValue={divisionId} onChange={(val) => setDivisionId(val)} placeholder={t('selectDivision')} style={{ width: '100%' }}>
</FormGroup> {setupSelectDivisi()}
</Col> </Select>
</Row> </FormGroup>
</Col>
</Row>
)
}
<Row> <Row>
{ {
role_name === 'Super Admin' && ( role_name === 'Super Admin' && (
@ -329,8 +342,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
) )
} }
<Col md={6}> <Col md={6}>
<Label className="capitalize">{t('restrictions')}</Label> <Label className="capitalize">{t('Customer')}</Label>
<Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}> <Select style={{ width: "100%" }} defaultValue={statusCustomer} onChange={(e) => setStatusCustomer(e)}>
<Option value={true}>Ya</Option> <Option value={true}>Ya</Option>
<Option value={false}>Tidak</Option> <Option value={false}>Tidak</Option>
</Select> </Select>
@ -342,13 +355,19 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Option value={'inactive'}>Inactive</Option> <Option value={'inactive'}>Inactive</Option>
</Select> </Select>
</Col> </Col>
<Col md={6}> <Col md={6} style={{ marginTop:'13px' }}>
<Label className="capitalize">{t('restrictions')}</Label>
<Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}>
<Option value={true}>Ya</Option>
<Option value={false}>Tidak</Option>
</Select>
</Col>
<Col md={6} style={{ marginTop:'13px' }}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('address')}</Label> <Label className="capitalize">{t('address')}</Label>
<Input type="textarea" value={address} onChange={(e) => setAddress(e.target.value)} placeholder={t('inputaddress')} /> <Input type="textarea" value={address} onChange={(e) => setAddress(e.target.value)} placeholder={t('inputaddress')} />
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
</Form> </Form>
) )

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

@ -6,7 +6,6 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" 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 { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { Pagination, Table, Button, Tooltip, Spin } from 'antd'; import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
@ -101,7 +100,7 @@ const ResourceWorker = ({ params, ...props }) => {
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
) )
} else { } else {
formData.columns.push( formData.columns.push(
@ -120,18 +119,13 @@ const ResourceWorker = ({ params, ...props }) => {
const getDivisiList = async () => { const getDivisiList = async () => {
const formData = { const formData = {
"paging": { "start": 0, "length": -1 },
"orders": { "columns": ["id"], "ascending": false }, "orders": { "columns": ["id"], "ascending": false },
"columns": [], "columns": [],
} }
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
)
} else {
formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
} }
@ -236,7 +230,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.group_column.where.push( payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
) )
} else { } else {
payload.group_column.where.push( payload.group_column.where.push(
@ -385,7 +379,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") { if (role_name !== "Super Admin") {
payload.group_column.where.push( payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
) )
} else { } else {
payload.group_column.where.push( payload.group_column.where.push(
@ -598,7 +592,7 @@ const ResourceWorker = ({ params, ...props }) => {
title: t('roles'), title: t('roles'),
dataIndex: 'join_first_name', dataIndex: 'join_first_name',
key: 'join_first_name', key: 'join_first_name',
render: (text, record) => <>{record.join_first_name}</> render: (text, record) => <>{ record.is_customer === true ? 'Customer' : record.join_first_name}</>
}, },
{ title: 'Phone No.', dataIndex: 'phone_number', key: 'phone_number' }, { title: 'Phone No.', dataIndex: 'phone_number', key: 'phone_number' },
{ title: 'Email', dataIndex: 'email', key: 'email' }, { title: 'Email', dataIndex: 'email', key: 'email' },

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

@ -127,9 +127,6 @@ const Satuan = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
) )
} else { } else {
payload.columns.push(
{ "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"] }
) )

2
src/views/SimproV2/Settings/DialogForm.js

@ -323,7 +323,7 @@ const DialogForm = ({
<img <img
src={ src={
imageProfile ? ( imageProfile ? (
`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image, role != 'Super Admin' ? configApp.company_name : 'undifined')}` `${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image, role != 'Super Admin' ? configApp?.company_name : 'undifined', moment(imageProfile?.created_at).format('YYYY-MM') )}`
) : profile ) : profile
} }
style={{ maxWidth: "100%" }} style={{ maxWidth: "100%" }}

4
src/views/SimproV2/Settings/components/MyProfile/Index.js

@ -254,7 +254,7 @@ const Index = () => {
<div className={stylesHead.img} style={{ cursor:imageProfile ? 'pointer' : '' }} onClick={imageProfile ? () => handleImageClick() : ''}> <div className={stylesHead.img} style={{ cursor:imageProfile ? 'pointer' : '' }} onClick={imageProfile ? () => handleImageClick() : ''}>
<img className={stylesHead.obejct11} src={ <img className={stylesHead.obejct11} src={
imageProfile ? ( imageProfile ? (
`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image, role != 'Super Admin' ? configApp.company_name : 'undifined')}` `${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image, role != 'Super Admin' ? configApp?.company_name : 'undifined', moment(imageProfile?.created_at).format('YYYY-MM'))}`
) : profile ) : profile
} /> } />
</div> </div>
@ -416,7 +416,7 @@ const Index = () => {
<img <img
src={ src={
imageProfile ? ( imageProfile ? (
`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image, role != 'Super Admin' ? configApp.company_name : 'undifined')}` `${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image, role != 'Super Admin' ? configApp?.company_name : 'undifined', moment(imageProfile?.created_at).format('YYYY-MM'))}`
) : profile ) : profile
} }
style={{ maxWidth: "100%" }} style={{ maxWidth: "100%" }}

19
src/views/SimproV2/Settings/components/Plan/Container1.js

@ -8,7 +8,6 @@ import moment from "moment";
const Container1 = () => { const Container1 = () => {
const token = localStorage.getItem("token") const token = localStorage.getItem("token")
const user_id = localStorage.getItem("user_id") const user_id = localStorage.getItem("user_id")
let company_id = '', configApp = '';
const role = window.localStorage.getItem('role_name'); const role = window.localStorage.getItem('role_name');
const [totalPage, setTotalPage] = useState(0); const [totalPage, setTotalPage] = useState(0);
const [transaction, setTransaction] = useState([]); const [transaction, setTransaction] = useState([]);
@ -17,9 +16,9 @@ const Container1 = () => {
const givenDate = new Date(transaction.exp_ospro); const givenDate = new Date(transaction.exp_ospro);
const createdDate = new Date(transaction.created_at) const createdDate = new Date(transaction.created_at)
const differenceInMillis = givenDate.getTime() - currentDate.getTime(); const differenceInMillis = givenDate.getTime() - currentDate.getTime();
const differenceInDays = role !== 'Super Admin' ? Math.floor(differenceInMillis / (1000 * 60 * 60 * 24)) : 30;
const differenceInDays = Math.floor(differenceInMillis / (1000 * 60 * 60 * 24)); let company_id = '', configApp = '';
if(role !== 'Super Admin') { if(role !== 'Super Admin') {
company_id = localStorage.getItem("company_id"); company_id = localStorage.getItem("company_id");
configApp = JSON.parse(window.localStorage.getItem('configApp')); configApp = JSON.parse(window.localStorage.getItem('configApp'));
@ -33,8 +32,10 @@ const Container1 = () => {
useEffect(()=>{ useEffect(()=>{
getDataProyek(); getDataProyek();
getDataTransaction();
getLimitInformation(); getLimitInformation();
if(role !== 'Super Admin') {
getDataTransaction();
}
},[]) },[])
const getDataProyek = async () => { const getDataProyek = async () => {
@ -88,13 +89,13 @@ const Container1 = () => {
} }
const getLimitInformation = async () => { const getLimitInformation = async () => {
const url = STORAGE_LIMIT_INFORMATION(configApp.company_name); const url = STORAGE_LIMIT_INFORMATION(role !== 'Super Admin' ? configApp.company_name : 'Super Admin');
const result = await axios const result = await axios
.get(url, config) .get(url, config)
.then((res) => res) .then((res) => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result.data) { if (result.data) {
setLimitInformation(result.data); setLimitInformation(role !== 'Super Admin' ? parseFloat(result.data) : 0);
} else { } else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); NotificationManager.error("Gagal Mengambil Data!!", "Failed");
} }
@ -169,13 +170,13 @@ const Container1 = () => {
</div> </div>
</div> </div>
<div className={styles.daysRemainingUntil}> <div className={styles.daysRemainingUntil}>
{Math.abs(differenceInDays)} days remaining until your plan requires update { role !== 'Super Admin' ? Math.abs(differenceInDays) : 0} days remaining until your plan requires update
</div> </div>
</div> </div>
<div className={styles.days2}> <div className={styles.days2}>
<div className={styles.storageParent}> <div className={styles.storageParent}>
<div className={styles.storage}>Storage</div> <div className={styles.storage}>Storage</div>
<div className={styles.of500mb}>{storage} of {transaction.type_paket === 'Basic' ? 500 : 50}MB</div> <div className={styles.of500mb}>{storage} of {transaction?.type_paket === 'Basic' ? 500 : 50}MB</div>
</div> </div>
<div className={styles.rectangleParent}> <div className={styles.rectangleParent}>
<div className={styles.frameChild} /> <div className={styles.frameChild} />
@ -192,7 +193,7 @@ const Container1 = () => {
</div> </div>
</div> </div>
<div className={styles.storageRemainingUntil}> <div className={styles.storageRemainingUntil}>
{((storage / (transaction.type_paket === 'Basic' ? 500 : 50)) * 100).toFixed(2)}% storage remaining until your plan requires update {(((storage / (transaction.type_paket === 'Basic' ? 500 : 50)) * 100).toFixed(2))}% has been filled until your plan requires an update
</div> </div>
</div> </div>
<div className={styles.days3}> <div className={styles.days3}>

Loading…
Cancel
Save