diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js
index 7bdc817..0f12fb5 100644
--- a/src/const/ApiConst.js
+++ b/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_IMAGE = `${BASE_OSPRO}/assets/image`;
export let BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`;
-export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file, company_name) => {
- return `${BASE_OSPRO}/assets/${company_name}/file/project/${file}`;
+export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file, company_name, dateFile) => {
+ return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/file/project/${file}`;
}
-export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file, company_name) => {
- return `${BASE_OSPRO}/assets/${company_name}/image/${file}`;
+export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file, company_name, dateFile) => {
+ return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/image/${file}`;
}
export const USERROLE_ADD = `${BASE_SIMPRO}/user-role/add`;
@@ -279,10 +279,15 @@ export const TRANSACTION_GET_ID = (id) => {
export const TRANSACTION_EDIT = (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) => {
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_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_UPDATE = (id) =>
`${BASE_SIMPRO_LUMEN}/folder-document-proyek/update/${id}`;
-export const FOLDER_DOCUMENT_PROYEK_DELETE = (id) =>
- `${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}`;
+export const FOLDER_DOCUMENT_PROYEK_DELETE = (id, company_id) =>
+ `${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}/${company_id}`;
export const 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) => {
return `${BASE_SIMPRO_LUMEN}/sales-contact/delete/${id}`;
-};
\ No newline at end of file
+};
diff --git a/src/containers/DefaultLayout/DefaultLayout.js b/src/containers/DefaultLayout/DefaultLayout.js
index 3f2fbbb..ef4d6af 100644
--- a/src/containers/DefaultLayout/DefaultLayout.js
+++ b/src/containers/DefaultLayout/DefaultLayout.js
@@ -370,6 +370,7 @@ class DefaultLayout extends Component {
token={props.location.state ? props.location.state.token : localStorage.getItem("token")}
menu_login={props.location.state ? props.location.state.menu_login : localStorage.getItem("menu_login")}
user_name={props.location.state ? props.location.state.user_name : localStorage.getItem("user_name")}
+ configApp={props.location.state ? props.location.state.configApp : localStorage.getItem("configApp")}
{...props}
/>
)} />
diff --git a/src/routes.js b/src/routes.js
index bc7f34c..cfa3855 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -58,9 +58,12 @@ const DashboardProjectCarousell = React.lazy(() => import('./views/Dashboard/Das
const MapMonitoring = React.lazy(() => import('./views/MapMonitoring'));
const Settings = React.lazy(() => import('./views/SimproV2/Settings/Desktop'));
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 ReferralCode = React.lazy(() => import('./views/SimproV2/ReferralCode'))
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 = [
{ path: '/', exact: true, name: 'Home' },
{ path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD },
@@ -125,10 +128,13 @@ const routes = [
{ path: '/map-monitoring', exact: true, name: 'Map Monitoring', component: MapMonitoring },
// { path: '/dashboard-project/:ID/:GANTTID', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ 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: '/demo-request', exact: true, name: 'Request Demo', component: DemoRequest },
{ path: '/referral-code-management', exact: true, name: 'Referral Code Management', component: ReferralCode },
{ 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 },
];
diff --git a/src/views/Master/MasterCompany/DialogForm.js b/src/views/Master/MasterCompany/DialogForm.js
index 1b34c6c..33149f0 100644
--- a/src/views/Master/MasterCompany/DialogForm.js
+++ b/src/views/Master/MasterCompany/DialogForm.js
@@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next';
import axios from "../../../const/interceptorApi"
import moment from 'moment';
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';
const token = window.localStorage.getItem('token');
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 = () => {
return (
<>
@@ -823,21 +841,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company
typeImage !== 'imageSlider' ? (
imageLogin || imageHeader || imageFavIcon ? (
) : ('-')
) : (
{imageSlider && imageSlider.map((item, index) => (
-
+
))}
diff --git a/src/views/Master/MasterCompany/index.js b/src/views/Master/MasterCompany/index.js
index a7bab4f..9c5c9b5 100644
--- a/src/views/Master/MasterCompany/index.js
+++ b/src/views/Master/MasterCompany/index.js
@@ -125,11 +125,13 @@ const MasterCompany = ({ params }) => {
.then(res => res)
.catch((error) => error.response);
- if (result && result.data && result.data.code == 200) {
- const sourceData = result.data.data;
+ if (result && result.data && result.data.code == 200) {
+ const sourceData = result.data.data;
+ const countRecord = result.data.totalRecord;
+
setDatatable(sourceData);
- setTotalPage(result.data.totalRecord);
- const lastCompanyId = sourceData[sourceData.length - 1].id;
+ setTotalPage(countRecord);
+ const lastCompanyId = countRecord > 0 ? sourceData[sourceData.length - 1].id : null;
setLastCompanyId(lastCompanyId);
setLoading(false)
} else {
@@ -145,7 +147,8 @@ const MasterCompany = ({ params }) => {
.then((res) => res)
.catch((err) => err.response);
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;
setProjectImageSlider(sourceData);
}
- }
+ }
const handleSearch = e => {
const value = e.target.value
diff --git a/src/views/Master/MasterRoles/DialogMenuRoles.js b/src/views/Master/MasterRoles/DialogMenuRoles.js
index a00128e..2ed266b 100644
--- a/src/views/Master/MasterRoles/DialogMenuRoles.js
+++ b/src/views/Master/MasterRoles/DialogMenuRoles.js
@@ -22,11 +22,13 @@ export default class DialogMenuRoles extends Component {
openDialog: false,
isParentClick: false,
menu: [],
+ menuIds: [],
stateMenu: [],
stateRead: [],
stateCreate: [],
stateUpdate: [],
stateDelete: [],
+ role_name: props.role_name || '',
stateReadAll: false,
stateCreateAll: false,
stateUpdateAll: false,
@@ -35,11 +37,13 @@ export default class DialogMenuRoles extends Component {
company_id: props.company_id || null,
}
}
+
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getAllMenu();
}
- async componentDidUpdate() {
+
+ async componentDidUpdate(prevProps, prevState) {
if (this.state.isParentClick === true) {
const { idRoles } = this.props
this.setStateMenu(true);
@@ -48,23 +52,31 @@ export default class DialogMenuRoles extends Component {
this.setStateCreate(true);
this.setStateDelete(true);
this.setState({ isParentClick: false, id: idRoles });
+ // if (prevState.menu == this.state.menu) {
+ // await this.setStateReadAfterRender();
+ // }
}
}
+
showDialog = () => {
this.setState({ isParentClick: true });
}
+
getAllMenu = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
- "columns": [
- { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }
- ],
+ "columns": [],
"joins": [
{ "name": "t_roles_menu", "column_join": "menu_id", "column_results": ["create", "update", "delete", "read"] },
{ "name": "m_menu", "column_join": "menu_id", "column_results": ["name"] }
],
"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
.post(MENU_COMPANY_SEARCH, payload, config)
.then(res => res)
@@ -73,9 +85,9 @@ export default class DialogMenuRoles extends Component {
this.setState({ menu: result.data.data }, () => {
this.setStateMenu(false);
});
- } else {
}
}
+
setStateMenu = edit => {
const stateMenu = [];
this.state.menu.map((val) => {
@@ -89,6 +101,7 @@ export default class DialogMenuRoles extends Component {
})
})
}
+
setStateRead = edit => {
const stateRead = [];
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 => {
const stateCreate = [];
this.state.menu.map((val) => {
@@ -115,6 +137,7 @@ export default class DialogMenuRoles extends Component {
})
})
}
+
setStateUpdate = edit => {
const stateUpdate = [];
this.state.menu.map((val) => {
@@ -128,6 +151,7 @@ export default class DialogMenuRoles extends Component {
})
})
}
+
setStateDelete = edit => {
const stateDelete = [];
this.state.menu.map((val) => {
@@ -141,6 +165,7 @@ export default class DialogMenuRoles extends Component {
})
})
}
+
checkMenuRoles = () => {
let copyStateMenu = [...this.state.stateMenu];
this.props.menuRoles.map((val, indexMenu) => {
@@ -158,14 +183,15 @@ export default class DialogMenuRoles extends Component {
}
})
}
+
checkReadRoles = () => {
let copyStateRead = [...this.state.stateRead];
this.props.menuRoles.map((val) => {
let index = this.getIndexDataMenu(val.menu_id);
if (val.read === true) {
- copyStateRead[index] = true;
+ copyStateRead[val.menu_id] = true;
} else {
- copyStateRead[index] = false;
+ copyStateRead[val.menu_id] = false;
}
})
this.setState({ stateRead: [] }, () => {
@@ -177,14 +203,15 @@ export default class DialogMenuRoles extends Component {
}
})
}
+
checkCreateRoles = () => {
let copyStateCreate = [...this.state.stateCreate];
this.props.menuRoles.map((val) => {
let index = this.getIndexDataMenu(val.menu_id);
if (val.create === true) {
- copyStateCreate[index] = true;
+ copyStateCreate[val.menu_id] = true;
} else {
- copyStateCreate[index] = false;
+ copyStateCreate[val.menu_id] = false;
}
})
this.setState({ stateCreate: [] }, () => {
@@ -196,14 +223,15 @@ export default class DialogMenuRoles extends Component {
}
})
}
+
checkUpdateRoles = () => {
let copyStateUpdate = [...this.state.stateUpdate];
this.props.menuRoles.map((val) => {
let index = this.getIndexDataMenu(val.menu_id);
if (val.update === true) {
- copyStateUpdate[index] = true;
+ copyStateUpdate[val.menu_id] = true;
} else {
- copyStateUpdate[index] = false;
+ copyStateUpdate[val.menu_id] = false;
}
})
this.setState({ stateUpdate: [] }, () => {
@@ -215,14 +243,15 @@ export default class DialogMenuRoles extends Component {
}
})
}
+
checkDeleteRoles = () => {
let copyStateDelete = [...this.state.stateDelete];
this.props.menuRoles.map((val) => {
let index = this.getIndexDataMenu(val.menu_id);
if (val.delete === true) {
- copyStateDelete[index] = true;
+ copyStateDelete[val.menu_id] = true;
} else {
- copyStateDelete[index] = false;
+ copyStateDelete[val.menu_id] = false;
}
})
this.setState({ stateDelete: [] }, () => {
@@ -234,26 +263,32 @@ export default class DialogMenuRoles extends Component {
}
})
}
+
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
}
+
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
}
+
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
}
+
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
}
+
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
}
+
handleSave = () => {
const {
stateMenu,
@@ -262,17 +297,18 @@ export default class DialogMenuRoles extends Component {
stateRead,
stateUpdate,
menu,
+ menuIds,
id
} = this.state
const arrayData = [];
menu.map((val, index) => {
let data = {
roles_id: id,
- menu_id: val.id,
- read: stateRead[index],
- create: stateCreate[index],
- update: stateUpdate[index],
- delete: stateDelete[index],
+ menu_id: menuIds[val.menu_id],
+ read: stateRead[val.menu_id],
+ create: stateCreate[val.menu_id],
+ update: stateUpdate[val.menu_id],
+ delete: stateDelete[val.menu_id],
checked: stateMenu[index],
}
arrayData.push(data);
@@ -280,17 +316,20 @@ export default class DialogMenuRoles extends Component {
this.props.closeDialog('save', arrayData);
this.setState({ id: 0 });
}
+
handleCancel = () => {
this.props.closeDialog('cancel', 'none')
}
+
handleChangeCheckbox = (checked, index) => {
let copyStateMenu = [...this.state.stateMenu];
copyStateMenu[index] = checked;
this.setState({ stateMenu: copyStateMenu })
}
+
handleChangeCheckboxRead = (checked, index, menuItem = null, menuIdxList = []) => {
let copyStateRead = [...this.state.stateRead];
- copyStateRead[index] = checked;
+ let copyMenuIds = [...this.state.menuIds];
let menu = this.state.menu;
let checkMenuParent = menu.map((state, index) => {
if (state.parent_menu_id === menuItem.menu_id) {
@@ -303,18 +342,23 @@ export default class DialogMenuRoles extends Component {
menuIdxList.forEach((menu, index) => {
checkMenuParent.forEach((check, idx) => {
if (check === menu) {
- stateReadIdx.push(index);
+ copyMenuIds[menu] = menu
+ stateReadIdx.push(menu);
}
});
});
stateReadIdx.map((stateRead) => {
copyStateRead[stateRead] = checked
})
+ copyStateRead[menuItem.menu_id] = checked
+ copyMenuIds[menuItem.menu_id] = menuItem.menu_id
this.setState({ stateRead: copyStateRead })
+ this.setState({ menuIds: copyMenuIds })
}
+
handleChangeCheckboxCreate = (checked, index, menuItem = null, menuIdxList = []) => {
let copyStateCreate = [...this.state.stateCreate];
- copyStateCreate[index] = checked;
+ let copyMenuIds = [...this.state.menuIds];
let menu = this.state.menu;
let checkMenuParent = menu.map((state, index) => {
if (state.parent_menu_id === menuItem.menu_id) {
@@ -327,18 +371,23 @@ export default class DialogMenuRoles extends Component {
menuIdxList.forEach((menu, index) => {
checkMenuParent.forEach((check, idx) => {
if (check === menu) {
- stateCreateIdx.push(index);
+ copyMenuIds[menu] = menu
+ stateCreateIdx.push(menu);
}
});
});
stateCreateIdx.map((stateCreate) => {
copyStateCreate[stateCreate] = checked
})
+ copyStateCreate[menuItem.menu_id] = checked
+ copyMenuIds[menuItem.menu_id] = menuItem.menu_id
this.setState({ stateCreate: copyStateCreate })
+ this.setState({ menuIds: copyMenuIds })
}
+
handleChangeCheckboxEdit = (checked, index, menuItem = null, menuIdxList = []) => {
let copyStateEdit = [...this.state.stateUpdate];
- copyStateEdit[index] = checked;
+ let copyMenuIds = [...this.state.menuIds];
let menu = this.state.menu;
let checkMenuParent = menu.map((state, index) => {
if (state.parent_menu_id === menuItem.menu_id) {
@@ -351,18 +400,23 @@ export default class DialogMenuRoles extends Component {
menuIdxList.forEach((menu, index) => {
checkMenuParent.forEach((check, idx) => {
if (check === menu) {
- stateEditIdx.push(index);
+ copyMenuIds[menu] = menu
+ stateEditIdx.push(menu);
}
});
});
stateEditIdx.map((stateEdit) => {
copyStateEdit[stateEdit] = checked
})
+ copyStateEdit[menuItem.menu_id] = checked
+ copyMenuIds[menuItem.menu_id] = menuItem.menu_id
this.setState({ stateUpdate: copyStateEdit })
+ this.setState({ menuIds: copyMenuIds })
}
+
handleChangeCheckboxDelete = (checked, index, menuItem = null, menuIdxList = []) => {
let copyStateDelete = [...this.state.stateDelete];
- copyStateDelete[index] = checked;
+ let copyMenuIds = [...this.state.menuIds];
let menu = this.state.menu;
let checkMenuParent = menu.map((state, index) => {
if (state.parent_menu_id === menuItem.menu_id) {
@@ -375,15 +429,20 @@ export default class DialogMenuRoles extends Component {
menuIdxList.forEach((menu, index) => {
checkMenuParent.forEach((check, idx) => {
if (check === menu) {
- stateDeleteIdx.push(index);
+ copyMenuIds[menu] = menu
+ stateDeleteIdx.push(menu);
}
});
});
stateDeleteIdx.map((stateDelete) => {
copyStateDelete[stateDelete] = checked
})
+ copyStateDelete[menuItem.menu_id] = checked
+ copyMenuIds[menuItem.menu_id] = menuItem.menu_id
this.setState({ stateDelete: copyStateDelete })
+ this.setState({ menuIds: copyMenuIds })
}
+
handleChangeCheckboxReadAll = (checked) => {
let copyStateRead = [...this.state.stateRead];
copyStateRead.map((val, index) => {
@@ -391,6 +450,7 @@ export default class DialogMenuRoles extends Component {
})
this.setState({ stateRead: copyStateRead })
}
+
handleChangeCheckboxCreateAll = (checked, index) => {
let copyStateCreate = [...this.state.stateCreate];
copyStateCreate.map((val, index) => {
@@ -398,6 +458,7 @@ export default class DialogMenuRoles extends Component {
})
this.setState({ stateCreate: copyStateCreate })
}
+
handleChangeCheckboxEditAll = (checked, index) => {
let copyStateEdit = [...this.state.stateUpdate];
copyStateEdit.map((val, index) => {
@@ -405,6 +466,7 @@ export default class DialogMenuRoles extends Component {
})
this.setState({ stateUpdate: copyStateEdit })
}
+
handleChangeCheckboxDeleteAll = (checked, index) => {
let copyStateDelete = [...this.state.stateDelete];
copyStateDelete.map((val, index) => {
@@ -412,6 +474,7 @@ export default class DialogMenuRoles extends Component {
})
this.setState({ stateDelete: copyStateDelete })
}
+
renderForm = () => {
const { menu, stateRead, stateCreate, stateUpdate, stateDelete } = this.state;
let menuIdxList = []
@@ -427,13 +490,13 @@ export default class DialogMenuRoles extends Component {
menuIdx++
const paddingLeft = depth * 30;
return (
-
+
{menuItem.join_second_name}
- this.handleChangeCheckboxRead(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateRead[currentIndex]} />
- this.handleChangeCheckboxCreate(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateCreate[currentIndex]} />
- this.handleChangeCheckboxEdit(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateUpdate[currentIndex]} />
- this.handleChangeCheckboxDelete(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateDelete[currentIndex]} />
+ this.handleChangeCheckboxRead(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateRead[menuItem.menu_id]} />
+ this.handleChangeCheckboxCreate(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateCreate[menuItem.menu_id]} />
+ this.handleChangeCheckboxEdit(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateUpdate[menuItem.menu_id]} />
+ this.handleChangeCheckboxDelete(e.target.checked, currentIndex, menuItem, menuIdxList)} defaultChecked={stateDelete[menuItem.menu_id]} />
{renderMenu(menuItem.menu_id, depth + 1)}
@@ -449,6 +512,7 @@ export default class DialogMenuRoles extends Component {
);
};
+
renderAll = () => {
return (
@@ -460,9 +524,11 @@ export default class DialogMenuRoles extends Component {
)
}
+
checkArray = (val) => {
return val === false;
}
+
handleAllChecked = (checked) => {
this.setState({ allChecked: !this.state.allChecked });
if (checked === true) {
@@ -486,6 +552,7 @@ export default class DialogMenuRoles extends Component {
})
}
}
+
render() {
return (
@@ -523,4 +590,4 @@ export default class DialogMenuRoles extends Component {
)
}
-}
\ No newline at end of file
+}
diff --git a/src/views/Master/MasterRoles/index.js b/src/views/Master/MasterRoles/index.js
index 3d1137d..ff5045f 100644
--- a/src/views/Master/MasterRoles/index.js
+++ b/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" },
)
} else {
- formData.columns.push(
- { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
- )
+ // 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"] }
)
@@ -320,13 +320,17 @@ class index extends Component {
handleMenuRoles = async (id) => {
const formData = {
"paging": { "start": 0, "length": -1 },
- "columns": [
- { "name": "role_id", "logic_operator": "=", "value": `${id}`, "operator": "AND" }
- ],
+ "columns": [],
"joins": [{ "name": "m_menu", "column_join": "menu_id", "column_results": ["parent_id", "name"] }],
"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
.post(ROLEMENU_SEARCH, formData, this.state.config)
.then(res => res)
@@ -412,9 +416,9 @@ class index extends Component {
{ "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.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"] }
)
diff --git a/src/views/Master/MasterTransaction/DialogForm.js b/src/views/Master/MasterTransaction/DialogForm.js
new file mode 100644
index 0000000..94350f9
--- /dev/null
+++ b/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 (
+
+ )
+ }
+
+ render() {
+ return (
+
+ {this.props.typeDialog == "Save" ? "Tambah" : "Edit"} {this.props.t('Transaksi')}
+
+ {this.renderForm()}
+
+
+ this.handleSave()}>{this.props.typeDialog} {' '}
+ this.handleCancel()}>{this.props.t('cancel')}
+
+
+ )
+ }
+}
+export default withTranslation()(DialogForm);
diff --git a/src/views/Master/MasterTransaction/index.js b/src/views/Master/MasterTransaction/index.js
new file mode 100644
index 0000000..d3968dc
--- /dev/null
+++ b/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) => <>
+
+ this.handleDelete(text.id)}>
+ {/* {
+ checkActMenup('/product-transaction', 'delete') ?
+ this.handleDelete(text.id)}>
+ :
+ null
+ } */}
+
+
+ this.handleEdit(text)}>
+ {/* {
+ checkActMenup('/product-transaction', 'update') ?
+ this.handleEdit(text)}>
+ :
+ null
+ } */}
+
+ >,
+ },
+ ...(this.state.role_name === 'Super Admin' ? [
+ {
+ title: "Company Name",
+ dataIndex: "join_first_company_name",
+ key: "join_first_company_name",
+ render: (text, record) => {
+ return { record.join_first_company_name } ;
+ }
+ }] : [])
+ ,
+ { title: 'Type Paket', dataIndex: 'type_paket', key: 'type_paket', className: "nowrap",
+ render: (text,record) => {
+ return { !["Basic","Free"].includes(record.type_paket) ? 'Enterprise' : record.type_paket}
+ }
+ },
+ {
+ title: this.props.t('Expired Date'), dataIndex: 'exp_ospro', key: 'exp_ospro',
+ render: (text,record) => {
+ return { moment(record.exp_ospro).format('DD MMMM, YYYY') } ;
+ }
+ },
+ ];
+ }
+
+ 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 (
+
+ {this.props.t('noData')}
+
+ )
+ }
+ }
+
+ 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 (
+
+
+
this.setState({ alertDelete: false, idDelete: 0 })}
+ focusCancelBtn
+ >
+ {this.props.t('deleteMsg')}
+
+
this.setState({ alertNotDelete: false })}
+ >
+ Data project role tidak dapat di hapus!!
+
+
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}
+ />
+
+
+ {this.props.params.name}
+
+
+
+
+
+
+ {
+ checkActMenup('/roles', 'create') ?
+ this.handleOpenDialog('Save')}>
+
+ :
+ null
+ }
+
+
+ this.handleExportExcel()}>
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
+export default withTranslation()(index);
diff --git a/src/views/Master/MasterWidget/index.js b/src/views/Master/MasterWidget/index.js
new file mode 100644
index 0000000..f1e2680
--- /dev/null
+++ b/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) => <>
+
+ this.handleDelete(text.id)}>
+
+
+ this.handleEdit(text)}>
+
+ >,
+ },
+ {
+ title: this.state.role_name === 'Super Admin' ? "Company Name" : null,
+ dataIndex: "join_first_company_name",
+ key: "join_first_company_name",
+ render: (text, record) => {
+ return this.state.role_name === 'Super Admin' ? (
+ {record.join_first_company_name}
+ ) : null;
+ }
+ },
+ { title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" },
+ { title: this.props.t('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 (
+
+ {this.props.t('noData')}
+
+ )
+ }
+ }
+
+ 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 (
+
+
+
this.setState({ alertDelete: false, idDelete: 0 })}
+ focusCancelBtn
+ >
+ {this.props.t('deleteMsg')}
+
+
this.setState({ alertNotDelete: false })}
+ >
+ Data project role tidak dapat di hapus!!
+
+
+
+ {this.props.params.name}
+
+
+
+
+
+
+
+ this.handleExportExcel()}>
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
+export default withTranslation()(index);
diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js
index a8bac3b..df23776 100644
--- a/src/views/Pages/Login/Login.js
+++ b/src/views/Pages/Login/Login.js
@@ -212,7 +212,8 @@ class Login extends Component {
company_id,
role_name,
all_project,
- user_name
+ user_name,
+ configApp
}
});
}
@@ -366,8 +367,8 @@ class Login extends Component {
-
+
@@ -393,7 +394,7 @@ class Login extends Component {
}}
/>
-
+
@@ -427,7 +428,7 @@ class Login extends Component {
-
+
{this.state.loader ? (
@@ -436,7 +437,7 @@ class Login extends Component {
)}
-
+
diff --git a/src/views/SimproV2/CreatedProyek/AsignCustProject.js b/src/views/SimproV2/CreatedProyek/AsignCustProject.js
index 9bc6cb2..60d2020 100644
--- a/src/views/SimproV2/CreatedProyek/AsignCustProject.js
+++ b/src/views/SimproV2/CreatedProyek/AsignCustProject.js
@@ -13,8 +13,7 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignCust from './DialogAssignCust';
-const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id }) => {
- const token = localStorage.getItem("token")
+const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id, token }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@@ -42,7 +41,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
},
"columns": [
{ "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" }
],
"joins": [
@@ -84,7 +83,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
}
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)
.then(res => res)
.catch((error) => error.response);
diff --git a/src/views/SimproV2/CreatedProyek/AsignHrProject.js b/src/views/SimproV2/CreatedProyek/AsignHrProject.js
index 315ef1b..f38eea7 100644
--- a/src/views/SimproV2/CreatedProyek/AsignHrProject.js
+++ b/src/views/SimproV2/CreatedProyek/AsignHrProject.js
@@ -11,8 +11,7 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignHr from './FormAsignHr';
import { formatThousand } from '../../../const/CustomFunc';
-const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName }) => {
- const token = localStorage.getItem("token")
+const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName, token }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@@ -93,7 +92,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan
"length": -1
},
"columns": [
- { "name": "company_id", "logic_operator": "=", "value": company_id },
+ { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) },
],
"orders": {
"columns": [
@@ -119,8 +118,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan
"length": -1
},
"columns": [
- { "name": "created_by", "logic_operator": "ilike", "value": "" },
- { "name": "company_id", "logic_operator": "=", "value": company_id },
+ { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) },
],
"joins": [],
"orders": {
diff --git a/src/views/SimproV2/CreatedProyek/DialogAssignCust.js b/src/views/SimproV2/CreatedProyek/DialogAssignCust.js
index 57e6d8a..4d66d4e 100644
--- a/src/views/SimproV2/CreatedProyek/DialogAssignCust.js
+++ b/src/views/SimproV2/CreatedProyek/DialogAssignCust.js
@@ -44,14 +44,14 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, compa
"select": [
"id",
"name",
- "role_id"
+ "is_customer"
],
"paging": {
"start": 0,
"length": -1
},
"columns": [
- { "name": "role_id", "logic_operator": "=", "value": 44 },
+ { "name": "is_customer", "logic_operator": "=", "value": true },
{ "name": "company_id", "logic_operator": "=", "value": company_id },
],
"orders": {
@@ -69,7 +69,7 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, compa
if (result && result.status == 200) {
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);
}
}
diff --git a/src/views/SimproV2/CreatedProyek/DialogDocument.js b/src/views/SimproV2/CreatedProyek/DialogDocument.js
index 8dded7e..0826206 100644
--- a/src/views/SimproV2/CreatedProyek/DialogDocument.js
+++ b/src/views/SimproV2/CreatedProyek/DialogDocument.js
@@ -5,14 +5,12 @@ import { Table, Tooltip, Popover, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
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 { NotificationContainer, NotificationManager } from 'react-notifications';
import DialogRequest from './FormDocument';
import DialogRequestFolder from './FormFolderDocument';
-const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => {
- const token = localStorage.getItem("token")
- const role = window.localStorage.getItem('role_name');
+const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, token, role_name, companyName }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@@ -28,14 +26,13 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
const [dataEdit, setDataEdit] = useState(null)
const [parentIdNewFolder, setParentIdNewFolder] = useState(0)
const [loading, setLoading] = useState(true);
- const company_id = window.localStorage.getItem('company_id');
useEffect(() => {
- if (idTask > 0) {
+ if (parseInt(idTask) > 0) {
setLoading(true);
getDataDocument();
}
- }, [idTask, openDialog])
+ }, [openDialog])
useEffect(() => {
if (!openDialog) {
@@ -45,13 +42,8 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}
}, [openDialog])
-
-
-
-
-
const getDataDocument = async () => {
- const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask)
+ const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(parseInt(idTask))
const result = await axios
.get(url, HEADER)
.then(res => res)
@@ -81,7 +73,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}
const handleDownload = (id, file) => {
- fetch(DOCUMENT_DOWNLOAD(id, company_id), {
+ fetch(DOCUMENT_DOWNLOAD(id, parseInt(companyId)), {
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
@@ -99,12 +91,8 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
});
}
- const handleShow = (file) => {
- let configApp = '';
- if (role !== 'Super Admin') {
- configApp = JSON.parse(window.localStorage.getItem('configApp'));
- }
- const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, configApp != '' ? configApp.company_name : 'undifined')}`
+ const handleShow = (file, dateFile) => {
+ const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, companyName, dateFile)}`
window.open(urlShow);
}
@@ -128,15 +116,16 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
openDialogRequest()
}
- const renderShowDokumen = (file) => {
- let arrayFile = file.split(".")
+ const renderShowDokumen = (data) => {
+ let arrayFile = data.file.split(".")
+ const dateFile = moment(data.created_at).format('YYYY-MM');
let length = arrayFile.length
length = length - 1
const fileExt = arrayFile[length];
- if (fileExt == "pdf" || fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg" || fileExt == "gif") {
+ if (["pdf", "png", "jpg", "jpeg", "gif"].includes(fileExt)) {
return (
- handleShow(file)}>
+ handleShow(data.file, dateFile)}>
)
}
@@ -165,7 +154,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
{record.isDir &&
handleNewFileParent(record.id)}>
}{" "}
- {text.file ? renderShowDokumen(text.file) : ""}
+ {text.file ? renderShowDokumen(text) : ""}
>
,
},
@@ -211,7 +200,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}
const onConfirmDelete = async () => {
- let urlDel = DOCUMENT_DELETE(idDelete, company_id)
+ let urlDel = DOCUMENT_DELETE(idDelete, parseInt(companyId))
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
@@ -229,7 +218,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}
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)
.then(res => res)
.catch((error) => error.response);
@@ -322,16 +311,19 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
openDialog={openDialogReq}
closeDialog={closeDialogReq}
toggleDialog={toggleDialogReq}
- idTask={idTask}
+ idTask={parseInt(idTask)}
parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit}
+ companyId={companyId}
+ token={token}
+ role_name={role_name}
/>
diff --git a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js
index e53efc2..bb4feaa 100644
--- a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js
+++ b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js
@@ -37,9 +37,9 @@ const DialogFormProyek = ({
projectImage,
company_id,
role_name,
+ token,
companyList
}) => {
- const token = localStorage.getItem("token");
const HEADER = {
headers: {
"Content-Type": "application/json",
diff --git a/src/views/SimproV2/CreatedProyek/DialogGantt.js b/src/views/SimproV2/CreatedProyek/DialogGantt.js
index b3dd3a2..62ff784 100644
--- a/src/views/SimproV2/CreatedProyek/DialogGantt.js
+++ b/src/views/SimproV2/CreatedProyek/DialogGantt.js
@@ -13,18 +13,7 @@ import DialogUserGantt from './DialogUserGantt';
import { Link } from 'react-router-dom';
const { Option } = Select
-const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, 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 DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id, dataViewStartDate }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@@ -140,16 +129,22 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
{" "}
+
+
+
+
+ {" "}
>
,
},
diff --git a/src/views/SimproV2/CreatedProyek/FormDocument.js b/src/views/SimproV2/CreatedProyek/FormDocument.js
index f333717..fbeecac 100644
--- a/src/views/SimproV2/CreatedProyek/FormDocument.js
+++ b/src/views/SimproV2/CreatedProyek/FormDocument.js
@@ -6,9 +6,8 @@ import { DOCUMENT_ADD } from '../../../const/ApiConst';
import 'antd/dist/antd.css';
import { NotificationManager } from 'react-notifications';
-const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => {
- const token = localStorage.getItem("token");
- const role = window.localStorage.getItem('role_name');
+const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder, token, role_name, companyId }) => {
+
const HEADER = {
headers: {
"Content-Type": "application/json",
@@ -34,12 +33,9 @@ const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentId
}
const uploadDokumen = async () => {
- let configApp = '';
const formData = new FormData;
- if (role !== 'Super Admin') {
- configApp = JSON.parse(window.localStorage.getItem('configApp'));
- formData.append('company_name',configApp.company_name);
- }
+
+ formData.append('company_id', parseInt(companyId));
formData.append('dokumen', file, file.name);
if (parentIdNewFolder > 0) {
formData.append('ref_id', parentIdNewFolder); // folder_id
@@ -73,8 +69,9 @@ const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentId
return (
)
diff --git a/src/views/SimproV2/CreatedProyek/FormFolderDocument.js b/src/views/SimproV2/CreatedProyek/FormFolderDocument.js
index de7d56d..2ea5c7b 100644
--- a/src/views/SimproV2/CreatedProyek/FormFolderDocument.js
+++ b/src/views/SimproV2/CreatedProyek/FormFolderDocument.js
@@ -1,96 +1,92 @@
-import React, { useEffect, useState } from 'react'
-import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
-import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap';
-import axios from "../../../const/interceptorApi";
-import { DOCUMENT_ADD, FOLDER_DOCUMENT_PROYEK_ADD } from '../../../const/ApiConst';
-import 'antd/dist/antd.css';
-import { NotificationManager } from 'react-notifications';
-
-const DialogRequestFolder = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => {
- const token = localStorage.getItem("token")
- const HEADER = {
- headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${token}`
- }
- }
- const [id, setId] = useState(0)
- const [folderName, setFolderName] = useState('')
-
-
- const handleClearData = () => {
- setId(0)
- setFolderName('')
- }
-
- useEffect(() => {
- handleClearData()
- }, [openDialog])
-
- const handleSave = () => {
- saveFolder()
- handleClearData()
- }
-
- const saveFolder = async () => {
-
-
-
-
- let payload = {
- "proyek_id": idTask,
- "name_folder": folderName
- }
-
- if (parentIdNewFolder > 0) {
- payload.parent_id = parentIdNewFolder
- }
-
- const result = await axios
- .post(FOLDER_DOCUMENT_PROYEK_ADD, payload, HEADER)
- .then(res => res)
- .catch((error) => error.response);
-
- if (result && result.data && result.data.code == 200) {
- NotificationManager.success('Success create folder!!', 'Success');
- closeDialog("upload");
- } else {
- NotificationManager.error('Failed to create folder!!', 'Failed');
- }
- }
-
- const handleCancel = () => {
- closeDialog('cancel')
- handleClearData()
- }
-
- const renderForm = () => {
- return (
-
- )
- }
-
-
- return (
- <>
-
- Create New Folder
-
- {renderForm()}
-
-
- handleSave()}>Save {' '}
- handleCancel()}>Cancel
-
-
- >
- )
-
-}
-
-export default DialogRequestFolder;
\ No newline at end of file
+import React, { useEffect, useState } from 'react'
+import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
+import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap';
+import axios from "../../../const/interceptorApi";
+import { FOLDER_DOCUMENT_PROYEK_ADD } from '../../../const/ApiConst';
+import 'antd/dist/antd.css';
+import { NotificationManager } from 'react-notifications';
+
+const DialogRequestFolder = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => {
+ const token = localStorage.getItem("token")
+ const HEADER = {
+ headers: {
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${token}`
+ }
+ }
+ const [id, setId] = useState(0)
+ const [folderName, setFolderName] = useState('')
+
+
+ const handleClearData = () => {
+ setId(0)
+ setFolderName('')
+ }
+
+ useEffect(() => {
+ handleClearData()
+ }, [openDialog])
+
+ const handleSave = () => {
+ saveFolder()
+ handleClearData()
+ }
+
+ const saveFolder = async () => {
+ let payload = {
+ "proyek_id": idTask,
+ "name_folder": folderName
+ }
+
+ if (parentIdNewFolder > 0) {
+ payload.parent_id = parentIdNewFolder
+ }
+
+ const result = await axios
+ .post(FOLDER_DOCUMENT_PROYEK_ADD, payload, HEADER)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code == 200) {
+ NotificationManager.success('Success create folder!!', 'Success');
+ closeDialog("upload");
+ } else {
+ NotificationManager.error('Failed to create folder!!', 'Failed');
+ }
+ }
+
+ const handleCancel = () => {
+ closeDialog('cancel')
+ handleClearData()
+ }
+
+ const renderForm = () => {
+ return (
+
+ )
+ }
+
+
+ return (
+ <>
+
+ Create New Folder
+
+ {renderForm()}
+
+
+ handleSave()}>Save {' '}
+ handleCancel()}>Cancel
+
+
+ >
+ )
+
+}
+
+export default DialogRequestFolder;
diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js
index d9c86b4..e5f9a50 100644
--- a/src/views/SimproV2/CreatedProyek/index.js
+++ b/src/views/SimproV2/CreatedProyek/index.js
@@ -91,7 +91,7 @@ const url = "";
const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => {
- let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
+ let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp={};
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
@@ -155,6 +155,8 @@ const CreatedProyek = ({ params, ...props }) => {
const [openDialogDoc, setOpenDialogDoc] = useState(false);
const [proyekName, setProyekName] = useState("");
const [openDialogProyek, setOpenDialogProyek] = useState(false);
+ const [companyId, setCompanyId] = useState(props.role_name !== 'Super Admin' ? company_id : 0);
+ const [companyName, setCompanyName] = useState('');
// project charter
const [projectCharter, setProjectCharter] = useState(null);
const [projectParticipant, setProjectParticipant] = useState(null);
@@ -369,7 +371,14 @@ const CreatedProyek = ({ params, ...props }) => {
}
const payload = {
- columns: [],
+ columns: [
+ {
+ name: "deleted_at",
+ logic_operator: "isnull",
+ value: "null",
+ operator: "AND"
+ }
+ ],
group_column: {
"operator": "AND",
"group_operator": "OR",
@@ -401,6 +410,9 @@ const CreatedProyek = ({ params, ...props }) => {
"currency_symbol",
"mulai_proyek",
"akhir_proyek",
+ "company_id",
+ "deleted_at",
+ "deleted_by_id"
],
joins: [
{
@@ -418,12 +430,12 @@ const CreatedProyek = ({ params, ...props }) => {
paging: { start: start, length: rowsPerPage },
};
- if (all_project !== null && all_project === true) {
+ if (role_name !== 'Super Admin' && all_project === 'true') {
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(
{ 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);
- setidTask(id);
- if (id !== 0) {
- await getProjectImage(id);
+ setidTask(text.id);
+ if (text.id !== 0) {
+ await getProjectImage(text.id);
}
};
@@ -565,6 +578,7 @@ const CreatedProyek = ({ params, ...props }) => {
setDataViewStartDate(data.mulai_proyek)
setidTask(data.id);
setProyekName(data.nama);
+ setCompanyId(data.company_id);
setOpenDialogGantt(true);
};
@@ -599,12 +613,16 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenAsignHr = (data) => {
setidTask(data.id);
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);
};
const handleOpenAsignCust = (data) => {
setidTask(data.id);
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);
};
@@ -1375,7 +1393,14 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportExcel = async () => {
const payload = {
- columns: [],
+ columns: [
+ {
+ name: "deleted_at",
+ logic_operator: "isnull",
+ value: "null",
+ operator: "AND"
+ }
+ ],
group_column: {
"operator": "AND",
"group_operator": "OR",
@@ -1462,7 +1487,14 @@ const CreatedProyek = ({ params, ...props }) => {
];
const payload = {
- columns: [],
+ columns: [
+ {
+ name: "deleted_at",
+ logic_operator: "isnull",
+ value: "null",
+ operator: "AND"
+ }
+ ],
group_column: {
"operator": "AND",
"group_operator": "OR",
@@ -1568,6 +1600,8 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenDokumen = async (data) => {
await setidTask(data.id);
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);
};
@@ -1627,7 +1661,7 @@ const CreatedProyek = ({ params, ...props }) => {
handleOpenDialogProyek(text.id)}
+ onClick={() => handleOpenDialogProyek(text)}
>
@@ -1656,7 +1690,17 @@ const CreatedProyek = ({ params, ...props }) => {
{!loadVersionGantt && text.type_proyek_id !== 9 && (
<>
{dataVersionGantt.slice(0, 8).map((res) => (
-
+
@@ -1888,9 +1932,10 @@ const CreatedProyek = ({ params, ...props }) => {
dataDivisions={dataDivisions}
dataPM={dataPm}
projectImage={image}
- company_id={company_id}
+ company_id={companyId}
role_name={role_name}
companyList={companyList}
+ token={token}
/>
),
[
@@ -1952,7 +1997,8 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogAsignHr}
idTask={idTask}
proyekName={proyekName}
- company_id={company_id}
+ company_id={companyId}
+ token={token}
/>
),
[openDialogAsignHR]
@@ -1968,7 +2014,8 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogAsignCust}
idTask={idTask}
proyekName={proyekName}
- company_id={company_id}
+ company_id={companyId}
+ token={token}
/>
),
[openDialogAsignCust]
@@ -2003,6 +2050,10 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogDoc}
idTask={idTask}
proyekName={proyekName}
+ companyId={companyId}
+ token={token}
+ role_name={role_name}
+ companyName={companyName}
/>
),
[openDialogDoc]
@@ -2053,6 +2104,7 @@ const CreatedProyek = ({ params, ...props }) => {
token={token}
isLogin={isLogin}
proyekName={proyekName}
+ companyId={companyId}
dataViewStartDate={dataViewStartDate}
/>
),
diff --git a/src/views/SimproV2/Divisi/index.js b/src/views/SimproV2/Divisi/index.js
index d423c8f..627df0d 100644
--- a/src/views/SimproV2/Divisi/index.js
+++ b/src/views/SimproV2/Divisi/index.js
@@ -4,7 +4,7 @@ import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
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 { Pagination, Button, Tooltip, Table, Spin } from 'antd';
import { useTranslation } from 'react-i18next';
@@ -120,9 +120,6 @@ const ProjectType = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
- payload.columns.push(
- { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
- )
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
@@ -183,9 +180,6 @@ const ProjectType = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
- payload.columns.push(
- { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
- )
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
@@ -414,7 +408,7 @@ const ProjectType = ({ params, ...props }) => {
:
null
}
-
+
{
diff --git a/src/views/SimproV2/Gantt/GanttFrame.js b/src/views/SimproV2/Gantt/GanttFrame.js
index aa9f79c..fed3f82 100644
--- a/src/views/SimproV2/Gantt/GanttFrame.js
+++ b/src/views/SimproV2/Gantt/GanttFrame.js
@@ -4,9 +4,9 @@ import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
const GanttFrame = React.memo((props) => {
const history = useHistory();
- const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, company_id, role_name } = props;
- const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`;
- // const iframeSrc = `http://localhost:8444/generic-ospro-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`;
+ const { 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}×tamp=${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}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}`;
const [batchEntityData, setBatchEntityData] = useState(null);
useEffect(() => {
diff --git a/src/views/SimproV2/Gantt/index.js b/src/views/SimproV2/Gantt/index.js
index 817985c..e07e9d8 100644
--- a/src/views/SimproV2/Gantt/index.js
+++ b/src/views/SimproV2/Gantt/index.js
@@ -15,13 +15,13 @@ import GanttFrame from "./GanttFrame";
let roCount = 0;
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) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
- company_id = props.company_id;
+ companyId = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@@ -114,7 +114,7 @@ const Gantt = (props) => {
token={token}
ro={ro}
role_name={role_name}
- company_id={company_id}
+ companyId={companyId}
timestamp={timestamp}
/>
)}
diff --git a/src/views/SimproV2/Kanban/index.js b/src/views/SimproV2/Kanban/index.js
index de647c2..56ebcc6 100644
--- a/src/views/SimproV2/Kanban/index.js
+++ b/src/views/SimproV2/Kanban/index.js
@@ -240,7 +240,7 @@ const Kanban = ({ params, ...props }) => {
const payload = {
columns: [
{
- name: "created_by",
+ name: "created_by_id",
logic_operator: "IN",
value: hierarchy,
operator: "AND"
@@ -261,11 +261,9 @@ const Kanban = ({ params, ...props }) => {
orders: { columns: ["id"], ascending: false },
};
- if (parseInt(role_id) !== 1) {
- payload["columns"] = [
- { name: "id", logic_operator: "=", value: project, operator: "AND" },
- ];
- }
+ // if (parseInt(role_id) !== 1) {
+ // payload.columns.push( { name: "id", logic_operator: "=", value: project, operator: "AND" });
+ // }
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
@@ -435,7 +433,7 @@ const Kanban = ({ params, ...props }) => {
}
}
- // Board
+ // Board
const handleCloseDialogBoard = (type, data) => {
if (type === "save") {
diff --git a/src/views/SimproV2/LimitasiUser/index.js b/src/views/SimproV2/LimitasiUser/index.js
new file mode 100644
index 0000000..0c837d5
--- /dev/null
+++ b/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' ? (
+ {record.join_first_company_name}
+ ) : 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 (
+
+ {this.props.t('noData')}
+
+ )
+ }
+ }
+
+ 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 (
+
+
+
this.setState({ alertDelete: false, idDelete: 0 })}
+ focusCancelBtn
+ >
+ {this.props.t('deleteMsg')}
+
+
this.setState({ alertNotDelete: false })}
+ >
+ Data project role tidak dapat di hapus!!
+
+
+
+ {this.props.params.name}
+
+
+
+
+
+
+
+ this.handleExportExcel()}>
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
+export default withTranslation()(index);
diff --git a/src/views/SimproV2/ResourceWorker/DialogForm.js b/src/views/SimproV2/ResourceWorker/DialogForm.js
index 86a53ec..1301523 100644
--- a/src/views/SimproV2/ResourceWorker/DialogForm.js
+++ b/src/views/SimproV2/ResourceWorker/DialogForm.js
@@ -33,7 +33,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [divisionId, setDivisionId] = useState('')
const [statusResource, setStatusResource] = useState('active')
const [statusRestriction, setStatusRestriction] = useState(false)
+ const [statusCustomer, setStatusCustomer] = useState(false)
const { t } = useTranslation()
+
useEffect(() => {
if (typeDialog === "Edit" || typeDialog === "Set") {
setId(dataEdit.id)
@@ -55,6 +57,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setDivisionId(dataEdit.divisi_id)
setAddress(dataEdit.address)
setStatusRestriction(dataEdit.status_boundary)
+ setStatusCustomer(dataEdit.is_customer)
} else {
setId(0)
setResourceName('')
@@ -76,6 +79,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setCompanyId(null)
setStatusResource('active')
setStatusRestriction(false)
+ setStatusCustomer(false)
}
}, [dataEdit, openDialog])
@@ -104,14 +108,17 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
gender,
birth_place: birthPlace,
ktp_number: ktpNumber,
- role_id: roleId,
- divisi_id: divisionId,
address,
status_resource: statusResource,
status_boundary: statusRestriction,
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 != "") {
data['birth_date'] = birthDate;
}
@@ -153,13 +160,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
blood_type: bloodType,
ktp_number: ktpNumber,
biaya_per_jam: biayaPerJam.replace('.', ''),
- role_id: roleId,
- divisi_id: divisionId,
address,
status_resource: statusResource,
status_boundary: statusRestriction,
+ is_customer: statusCustomer,
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 != "") {
data['birth_date'] = birthDate;
@@ -283,25 +293,28 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
-
-
-
- {t('roles')} *
- setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}>
- {setupSelectRole()}
-
-
-
-
-
- {t('division')} *
- setDivisionId(val)} placeholder={t('selectDivision')} style={{ width: '100%' }}>
- {setupSelectDivisi()}
-
-
-
-
-
+ {
+ statusCustomer === false && (
+
+
+
+ {t('roles')} *
+ setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}>
+ {setupSelectRole()}
+
+
+
+
+
+ {t('division')} *
+ setDivisionId(val)} placeholder={t('selectDivision')} style={{ width: '100%' }}>
+ {setupSelectDivisi()}
+
+
+
+
+ )
+ }
{
role_name === 'Super Admin' && (
@@ -329,8 +342,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
)
}
- {t('restrictions')}
- setStatusRestriction(e)}>
+ {t('Customer')}
+ setStatusCustomer(e)}>
Ya
Tidak
@@ -342,13 +355,19 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
Inactive
-
+
+ {t('restrictions')}
+ setStatusRestriction(e)}>
+ Ya
+ Tidak
+
+
+
{t('address')}
setAddress(e.target.value)} placeholder={t('inputaddress')} />
-
)
diff --git a/src/views/SimproV2/ResourceWorker/index.js b/src/views/SimproV2/ResourceWorker/index.js
index 9219541..f28eeaa 100644
--- a/src/views/SimproV2/ResourceWorker/index.js
+++ b/src/views/SimproV2/ResourceWorker/index.js
@@ -6,7 +6,6 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
-import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { useLocation } from "react-router-dom";
import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
@@ -101,7 +100,7 @@ const ResourceWorker = ({ params, ...props }) => {
}
if (role_name !== "Super Admin") {
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(
@@ -120,18 +119,13 @@ const ResourceWorker = ({ params, ...props }) => {
const getDivisiList = async () => {
const formData = {
- "paging": { "start": 0, "length": -1 },
"orders": { "columns": ["id"], "ascending": false },
"columns": [],
}
if (role_name !== "Super Admin") {
formData.columns.push(
- { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
- )
- } else {
- formData.columns.push(
- { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
+ { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
)
}
@@ -236,7 +230,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") {
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 {
payload.group_column.where.push(
@@ -385,7 +379,7 @@ const ResourceWorker = ({ params, ...props }) => {
if (role_name !== "Super Admin") {
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 {
payload.group_column.where.push(
@@ -598,7 +592,7 @@ const ResourceWorker = ({ params, ...props }) => {
title: t('roles'),
dataIndex: '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: 'Email', dataIndex: 'email', key: 'email' },
diff --git a/src/views/SimproV2/Satuan/index.js b/src/views/SimproV2/Satuan/index.js
index 89cfad8..84c227f 100644
--- a/src/views/SimproV2/Satuan/index.js
+++ b/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" },
)
} 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"] }
)
diff --git a/src/views/SimproV2/Settings/DialogForm.js b/src/views/SimproV2/Settings/DialogForm.js
index 14ca80f..bf974ee 100644
--- a/src/views/SimproV2/Settings/DialogForm.js
+++ b/src/views/SimproV2/Settings/DialogForm.js
@@ -323,7 +323,7 @@ const DialogForm = ({
{
handleImageClick() : ''}>
@@ -416,7 +416,7 @@ const Index = () => {
{
const token = localStorage.getItem("token")
const user_id = localStorage.getItem("user_id")
- let company_id = '', configApp = '';
const role = window.localStorage.getItem('role_name');
const [totalPage, setTotalPage] = useState(0);
const [transaction, setTransaction] = useState([]);
@@ -17,9 +16,9 @@ const Container1 = () => {
const givenDate = new Date(transaction.exp_ospro);
const createdDate = new Date(transaction.created_at)
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') {
company_id = localStorage.getItem("company_id");
configApp = JSON.parse(window.localStorage.getItem('configApp'));
@@ -33,8 +32,10 @@ const Container1 = () => {
useEffect(()=>{
getDataProyek();
- getDataTransaction();
getLimitInformation();
+ if(role !== 'Super Admin') {
+ getDataTransaction();
+ }
},[])
const getDataProyek = async () => {
@@ -88,13 +89,13 @@ const Container1 = () => {
}
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
.get(url, config)
.then((res) => res)
.catch((error) => error.response);
if (result.data) {
- setLimitInformation(result.data);
+ setLimitInformation(role !== 'Super Admin' ? parseFloat(result.data) : 0);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
@@ -169,13 +170,13 @@ const Container1 = () => {
- {Math.abs(differenceInDays)} days remaining until your plan requires update
+ { role !== 'Super Admin' ? Math.abs(differenceInDays) : 0} days remaining until your plan requires update
Storage
-
{storage} of {transaction.type_paket === 'Basic' ? 500 : 50}MB
+
{storage} of {transaction?.type_paket === 'Basic' ? 500 : 50}MB
@@ -192,7 +193,7 @@ const Container1 = () => {
- {((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