Browse Source

Merge pull request 'dev-wahyun' (#7) from dev-wahyun into staging

Reviewed-on: #7
pull/8/head
ibnu 5 months ago
parent
commit
575ecf41c6
  1. 40
      src/const/ApiConst.js
  2. 67
      src/containers/DefaultLayout/DefaultLayout.js
  3. 2
      src/routes.js
  4. 31
      src/views/Dashboard/DashboardBOD.js
  5. 3
      src/views/Dashboard/DashboardCustomer.js
  6. 119
      src/views/Dashboard/DashboardProject.js
  7. 5
      src/views/Dashboard/DashboardProjectCarousell.js
  8. 5
      src/views/MapMonitoring/index.js
  9. 1189
      src/views/Master/MasterAbsensi/index.js
  10. 821
      src/views/Master/MasterBroadcast/DialogForm.js
  11. 51
      src/views/Master/MasterBroadcast/index.js
  12. 8
      src/views/Master/MasterCompany/index.js
  13. 62
      src/views/Master/MasterRoles/DialogForm.js
  14. 7
      src/views/Master/MasterRoles/DialogMenuRoles.js
  15. 49
      src/views/Master/MasterRoles/index.js
  16. 7
      src/views/Master/ProjectExpenditure/DialogForm.js
  17. 13
      src/views/Master/ProjectExpenditure/index.js
  18. 7
      src/views/Master/ProjectFinancialHealth/DialogForm.js
  19. 13
      src/views/Master/ProjectFinancialHealth/index.js
  20. 7
      src/views/Master/ProjectInvoice/DialogForm.js
  21. 13
      src/views/Master/ProjectInvoice/index.js
  22. 223
      src/views/Master/ProjectPhase/DialogForm.js
  23. 71
      src/views/Master/ProjectPhase/index.js
  24. 7
      src/views/Master/ProjectScheduleHealth/DialogForm.js
  25. 13
      src/views/Master/ProjectScheduleHealth/index.js
  26. 3
      src/views/Master/Proyek/index.js
  27. 73
      src/views/Master/RoleProject/DialogForm.js
  28. 73
      src/views/Master/RoleProject/index.js
  29. 8
      src/views/Pages/Login/Login.js
  30. 26
      src/views/Report/k3/index.js
  31. 237
      src/views/SimproV2/ChecklistK3/DialogForm.js
  32. 75
      src/views/SimproV2/ChecklistK3/index.js
  33. 3
      src/views/SimproV2/Closing/index.js
  34. 5
      src/views/SimproV2/CreatedProyek/AsignCustProject.js
  35. 8
      src/views/SimproV2/CreatedProyek/AsignHrProject.js
  36. 5
      src/views/SimproV2/CreatedProyek/DialogAssignCust.js
  37. 16
      src/views/SimproV2/CreatedProyek/DialogDocument.js
  38. 57
      src/views/SimproV2/CreatedProyek/DialogFormProyek.js
  39. 4
      src/views/SimproV2/CreatedProyek/DialogGantt.js
  40. 10
      src/views/SimproV2/CreatedProyek/FormDocument.js
  41. 152
      src/views/SimproV2/CreatedProyek/index.js
  42. 5
      src/views/SimproV2/DemoRequest/index.js
  43. 71
      src/views/SimproV2/Divisi/DialogForm.js
  44. 79
      src/views/SimproV2/Divisi/index.js
  45. 6
      src/views/SimproV2/Gantt/GanttFrame.js
  46. 4
      src/views/SimproV2/Gantt/index.js
  47. 27
      src/views/SimproV2/LimitasiUser/index.js
  48. 13
      src/views/SimproV2/PanicButton/index.js
  49. 712
      src/views/SimproV2/PlanningHarian/index.js
  50. 26
      src/views/SimproV2/Presence/index.js
  51. 8
      src/views/SimproV2/Profile/index.js
  52. 41
      src/views/SimproV2/ProjectType/DialogForm.js
  53. 70
      src/views/SimproV2/ProjectType/index.js
  54. 10
      src/views/SimproV2/ResourceMaterial/index.js
  55. 43
      src/views/SimproV2/ResourceWorker/DialogForm.js
  56. 80
      src/views/SimproV2/ResourceWorker/index.js
  57. 54
      src/views/SimproV2/Satuan/DialogForm.js
  58. 69
      src/views/SimproV2/Satuan/index.js
  59. 12
      src/views/SimproV2/Settings/components/MyProfile/Index.js
  60. 21
      src/views/SimproV2/Settings/components/Plan/Container1.js
  61. 486
      src/views/testgantt/index.js

40
src/const/ApiConst.js

@ -126,11 +126,11 @@ export let BASE_OSPRO = "https://si-api.ospro.id";
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, dateFile) => {
return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/file/project/${file}`;
export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file) => {
return `${BASE_OSPRO}/assets/file/project/${file}`;
}
export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file, company_name, dateFile) => {
return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/image/${file}`;
export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file) => {
return `${BASE_OSPRO}/assets/image/${file}`;
}
export const USERROLE_ADD = `${BASE_SIMPRO}/user-role/add`;
@ -289,9 +289,7 @@ export const 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 = `${BASE_SIMPRO_LUMEN}/information-storage`;
export const STORAGE_LIMIT_INFORMATION_ALL_COMPANY = `${BASE_SIMPRO_LUMEN}/information-storage-all-company`
export const ABSENSI_ADD = `${BASE_SIMPRO_LUMEN}/permit/add`;
@ -320,11 +318,11 @@ export const DOCUMENT_SEARCH = `${BASE_SIMPRO_LUMEN}/document-project/search`;
export const DOCUMENT_EDIT = (id) => {
return `${BASE_SIMPRO_LUMEN}/document-project/update/${id}`;
};
export const DOCUMENT_DELETE = (id, company_id) => {
return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}/${company_id}`;
export const DOCUMENT_DELETE = (id) => {
return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}`;
};
export const DOCUMENT_DOWNLOAD = (id, company_id) => {
return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}/${company_id}`;
export const DOCUMENT_DOWNLOAD = (id) => {
return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}`;
};
export const ROLE_ADD = `${BASE_SIMPRO_LUMEN}/role/add`;
@ -436,8 +434,8 @@ export const PROYEK_GET_ID = (id) => {
export const PROYEK_EDIT = (id) => {
return `${BASE_SIMPRO_LUMEN}/project/update/${id}`;
};
export const PROYEK_DELETE = (id, company_id) => {
return `${BASE_SIMPRO_LUMEN}/project/delete/${id}/${company_id}`;
export const PROYEK_DELETE = (id) => {
return `${BASE_SIMPRO_LUMEN}/project/delete/${id}`;
};
export const PROJECT_ROLE_ADD = `${BASE_SIMPRO_LUMEN}/project-role/add`;
@ -722,8 +720,8 @@ export const ASSIGN_HR_PROJECT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-proyek/sea
export const ASSIGN_HR_PROJECT_EDIT = (id) => {
return `${BASE_SIMPRO_LUMEN}/user-to-proyek/update/${id}`;
};
export const ASSIGN_HR_PROJECT_DELETE = (id, company_id) => {
return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}/${company_id}`;
export const ASSIGN_HR_PROJECT_DELETE = (id) => {
return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}`;
};
export const ASSIGN_HR_PROJECT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-proyek/list`;
@ -741,8 +739,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, company_id) =>
`${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}/${company_id}`;
export const FOLDER_DOCUMENT_PROYEK_DELETE = (id) =>
`${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}`;
export const FOLDER_DOCUMENT_PROYEK_GET_TREE = (proyek_id) =>
`${BASE_SIMPRO_LUMEN}/folder-document-proyek/get-tree/${proyek_id}`;
@ -793,11 +791,11 @@ export const IMAGE_SEARCH = `${BASE_SIMPRO_LUMEN}/image/search`;
export const OSPRO_BASE_IMAGE = `${BASE_OSPRO}/api/assets/image`;
export const IMAGE_UPLOAD = `${BASE_SIMPRO_LUMEN}/image/upload`;
export const IMAGE_MULTIPLE_UPLOAD = `${BASE_SIMPRO_LUMEN}/image/multiple-upload`;
export const IMAGE_MULTIPLE_DELETE = (id, category, company_id) => {
return `${BASE_SIMPRO_LUMEN}/image/multiple-delete/${id}/${category}/${company_id}`;
export const IMAGE_MULTIPLE_DELETE = (id, category) => {
return `${BASE_SIMPRO_LUMEN}/image/multiple-delete/${id}/${category}`;
}
export const IMAGE_DELETE = (id, category, company_id) => {
return `${BASE_SIMPRO_LUMEN}/image/delete/${id}/${category}/${company_id}`;
export const IMAGE_DELETE = (id, category) => {
return `${BASE_SIMPRO_LUMEN}/image/delete/${id}/${category}`;
}

67
src/containers/DefaultLayout/DefaultLayout.js

@ -39,16 +39,14 @@ class DefaultLayout extends Component {
constructor(props) {
super(props);
let role_id = '', token = '', company_id = 0, menu = ''
let role_id = '', token = '', menu = ''
if (props.location.state && props.location.state.role_id) {
role_id = props.location.state.role_id;
token = props.location.state.token;
company_id = props.location.state.company_id;
menu = props.location.state.menu_login;
} else {
role_id = localStorage.getItem("role_id");
token = localStorage.getItem("token");
company_id = localStorage.getItem('company_id');
menu = localStorage.getItem("menu_login");
}
@ -59,8 +57,7 @@ class DefaultLayout extends Component {
routes2: routes,
finalRoutes: [],
breadrCrumbReady: false,
minimized: true,
company_id: company_id
minimized: true
};
}
async componentDidMount() {
@ -70,6 +67,7 @@ class DefaultLayout extends Component {
if (!localStorage.getItem("token")) {
this.signOut();
}
this.getQueryParams();
window.myData = "Data dari komponen React";
try {
const storedData = localStorage.getItem('configApp');
@ -136,6 +134,12 @@ class DefaultLayout extends Component {
LayoutHelper.sidebarToggle(!this.state.minimized);
};
getQueryParams() {
const searchParams = new URLSearchParams(this.props.location.search);
const dashboardGantt = searchParams.get('dashboardGantt');
this.setState({ dashboardGantt });
}
setFinalRoutes = () => {
const { routes2 } = this.state;
if (routes2) {
@ -161,7 +165,6 @@ class DefaultLayout extends Component {
e.preventDefault()
}
await localStorage.removeItem("role_id");
await localStorage.removeItem("company_id");
document.getElementById('title').innerText = 'OSPRO';
this.setFavicon(`${process.env.PUBLIC_URL}/OSPRO.ico`);
await window.localStorage.clear();
@ -267,7 +270,7 @@ class DefaultLayout extends Component {
}
getAppBreadcrumb = () => {
const { u_group } = this.state;
const { u_group, dashboardGantt } = this.state;
if (u_group == 'kominfo') {
routes.map((route, idx) => {
if (route.path == '/dashboard-kominfo') {
@ -279,7 +282,7 @@ class DefaultLayout extends Component {
});
}
else {
if (!window.location.href.includes("dashboard")) {
if (!window.location.href.includes("dashboard") || window.location.href.includes("dashboard-project") && !dashboardGantt) {
return <AppBreadcrumb appRoutes={this.state.finalRoutes} router={router} />
}
}
@ -299,12 +302,11 @@ class DefaultLayout extends Component {
const { location } = this.props;
const { pathname } = location;
let renderSidebar = false
const isDashboardProject = this.props.location.pathname.startsWith('/dashboard-project/');
if (pathname.includes("/dashboard-project")) {
// Remove the base URL and hash
const path = pathname.replace("/dashboard-project/", "");
// Split the remaining path by "/"
// Split the remaining path by "/"
const parts = path.split("/");
if (parts[2] == "1") {
renderSidebar = true
@ -313,37 +315,33 @@ class DefaultLayout extends Component {
return (
<div className="app">
{!window.location.href.includes("false-header") && (
<AppHeader fixed>
<DefaultHeader />
</AppHeader>
)
}
<div className="app-body">
{!window.location.href.includes("dashboard-project") || renderSidebar ? (
<AppSidebar minimized={this.state.minimized} fixed display="lg">
<AppSidebarHeader />
<AppSidebarForm />
<Suspense>
{(isDashboardProject ? true : !window.location.href.includes("dashboard-project")) || renderSidebar ? (
(!this.state.dashboardGantt ? (
<AppSidebar minimized={this.state.minimized} fixed display="lg">
<hr />
<AppSidebarHeader />
<AppSidebarForm />
<Suspense>
{this.getMenu()}
</Suspense>
<AppSidebarFooter />
{this.state.minimized ? null :
</Suspense>
<AppSidebarFooter />
{this.state.minimized ? null :
<UncontrolledDropdown direction="down">
<DropdownToggle nav>
<i className="nav-icon fa fa-user-circle"></i> {localStorage.getItem('user_name')}
<i className="nav-icon fa fa-user-circle"></i> {localStorage.getItem('user_name')}
</DropdownToggle>
<DropdownMenu right>
<DropdownItem color="primary" size="sm" onClick={() => handleChangeLng("id")}>ID</DropdownItem>
<DropdownItem color="success" size="sm" onClick={() => handleChangeLng("en")}>EN</DropdownItem>
<DropdownItem href="#/settings"><i className="fa fa-user"></i>Profile</DropdownItem>
<DropdownItem onClick={e => this.signOut(e)}><i className="fa fa-sign-out"></i> Logout</DropdownItem>
<DropdownItem color="primary" size="sm" onClick={() => handleChangeLng("id")}>ID</DropdownItem>
<DropdownItem color="success" size="sm" onClick={() => handleChangeLng("en")}>EN</DropdownItem>
<DropdownItem href="#/settings"><i className="fa fa-user"></i>Profile</DropdownItem>
<DropdownItem onClick={e => this.signOut(e)}><i className="fa fa-sign-out"></i> Logout</DropdownItem>
</DropdownMenu>
</UncontrolledDropdown>}
<button className='sidebar-minimizer mt-auto' type='button' onClick={this.toggleMinimized}>
</button>
</AppSidebar>
<button className='sidebar-minimizer mt-auto' type='button' onClick={this.toggleMinimized}>
</button>
</AppSidebar>
) : null)
) : null}
<main className="main">
{this.state.breadrCrumbReady ? this.getAppBreadcrumb() : null}
@ -364,7 +362,6 @@ class DefaultLayout extends Component {
user_id={props.location.state ? props.location.state.user_id : localStorage.getItem("user_id")}
role_id={props.location.state ? props.location.state.role_id : localStorage.getItem("role_id")}
isLogin={props.location.state ? props.location.state.isLogin : localStorage.getItem("isLogin")}
company_id={props.location.state ? props.location.state.company_id : localStorage.getItem("company_id")}
role_name={props.location.state ? props.location.state.role_name : localStorage.getItem("role_name")}
all_project={props.location.state ? props.location.state.all_project : localStorage.getItem("all_project")}
token={props.location.state ? props.location.state.token : localStorage.getItem("token")}

2
src/routes.js

@ -68,7 +68,7 @@ const routes = [
{ path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD },
{ path: '/dashboard-dyna', name: 'DashboardBOD', component: DashboardDyna },
{ path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID/:SCURVE', name: 'DashboardCustomer', component: DashboardCustomer },
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:Header', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ path: '/dashboard-perproject', exact: true, name: 'Dashboard Project Carousell', component: DashboardProjectCarousell },
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:SCURVE', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ path: '/projects', exact: true, name: 'Projects', component: CreatedProyek },

31
src/views/Dashboard/DashboardBOD.js

@ -15,13 +15,12 @@ import { HealthByBudget, HealthBySchedule } from './Components';
import { Link } from 'react-router-dom';
import { Card, CardBody, CardHeader, Input } from "reactstrap";
const DashboardBOD = (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 = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -81,7 +80,7 @@ const DashboardBOD = (props) => {
// project expenditure
const getCompanyCashFlow = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Expenditure.";
@ -107,31 +106,31 @@ const DashboardBOD = (props) => {
// Project Expenditure Color
const getCompanyExpenditureColor = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${company_id}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_EXPENDITURE_COLOR(result.data.data)
}
const getCompanyFinancialHealthColor = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${company_id}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_FINANCIAL_HEALTH_COLOR(result.data.data)
}
const getCompanyScheduleHealthColor = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${company_id}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_SCHEDULE_HEALTH_COLOR(result.data.data)
}
const getCompanyInvoiceColor = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${company_id}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
SET_PROJECT_INVOICE_COLOR(result.data.data)
}
const getInvoiceOutstanding = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Invoice vs Cash In.";
@ -154,7 +153,7 @@ const DashboardBOD = (props) => {
}
const getProjectPerScheduleHealth = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health.";
@ -178,7 +177,7 @@ const DashboardBOD = (props) => {
}
const getProjectPerBudgetHealth = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Budget Health.";
@ -201,7 +200,7 @@ const DashboardBOD = (props) => {
}
const getProjectBudgetHealthPerDivision = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health per Division.";
@ -225,7 +224,7 @@ const DashboardBOD = (props) => {
}
const getProjectScheduleHealthPerDivision = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Schedule Health.";
@ -248,7 +247,7 @@ const DashboardBOD = (props) => {
}
const getProjectPerPhase = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Phase.";
@ -273,7 +272,7 @@ const DashboardBOD = (props) => {
}
const getTotalProjectPerDivision = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project by Division.";
@ -298,7 +297,7 @@ const DashboardBOD = (props) => {
}
const getTotalProjectValuePerDivision = async () => {
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Value by Division";
@ -327,7 +326,7 @@ const DashboardBOD = (props) => {
return;
}
setOpenDetailedView(true);
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${company_id}/${all_project}/${hierarchy}/${role_name}`
const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${all_project}/${hierarchy}/${role_name}`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Detail Expenditure";

3
src/views/Dashboard/DashboardCustomer.js

@ -26,13 +26,12 @@ const center = {
}
const DashboardCustomer = (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 = '', all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;

119
src/views/Dashboard/DashboardProject.js

@ -31,57 +31,39 @@ import {
import { Fab, Action } from "react-tiny-fab";
import "react-tiny-fab/dist/styles.css";
import { useHistory, useLocation, useParams } from "react-router-dom";
import { Icon } from '@iconify/react';
import arrowLeft from '@iconify/icons-ion/ios-arrow-back';
const { TextArea } = Input;
const styles = {
cardContainer: {
backgroundColor: "#F8F8F8",
margin: 2,
paddingLeft: 20,
paddingRight: 20,
paddingTop: 10,
},
cardHeaderContainer: {
display: "flex",
flexDirection: "row",
marginBottom: 10,
},
cardChartContainer: {
position: "relative",
height: "21vh",
margin: "auto",
paddingBottom: 10,
justifyContent: "center",
},
cardTitle: { color: "#444444", fontSize: 16, fontWeight: "bold" },
cardSubtitle: { color: "#888888", fontSize: 12 },
};
const center = {
lat: -6.2,
lng: 106.816666,
};
const DashboardProject = (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 = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const HEADER = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
};
const { PROJECT_ID, GANTT_ID, SCURVE } = useParams();
const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`;
// const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`;
const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}`;
// const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}`;
const mapRef = useRef();
const [projectName, setProjectName] = useState("");
@ -98,6 +80,7 @@ const DashboardProject = (props) => {
const [activeTabIdx, setActiveTabIdx] = useState(0);
const [activeTabCommentIdx, setActiveTabCommentIdx] = useState(0);
const [planningProgress, setPlanningProgress] = useState(0);
const [planningProgressToDay, setPlanningProgressToDay] = useState(0);
const [actualProgress, setActualProgress] = useState(0);
const [currentBudget, setCurrentBudget] = useState(null);
const [addCostToComplete, setAddCostToComplete] = useState(null);
@ -135,6 +118,7 @@ const DashboardProject = (props) => {
const [isReadyGanttParents, setIsReadyGanttParents] = useState(false);
const [calculationStatus, setCalculationStatus] = useState(false);
const [isHierarchy, setIsHierarchy] = useState(null);
const [dashboardGantt, setDashboardStatus] = useState(false);
let history = useHistory();
useEffect(() => {
getProjectDetail();
@ -143,9 +127,11 @@ const DashboardProject = (props) => {
getComments();
getGantt();
getGanttParents();
getQueryParams();
return () => {
};
}, []);
useEffect(() => {
if (isHierarchy != null) {
getSCurve();
@ -155,11 +141,13 @@ const DashboardProject = (props) => {
window.removeEventListener("message", handleIframeMessage);
};
}, [isHierarchy]);
useEffect(() => {
if (activeTabIdx === 1) {
initMap();
}
}, [activeTabIdx]);
useEffect(() => {
async function fetchData() {
await Promise.all([
@ -170,6 +158,7 @@ const DashboardProject = (props) => {
}
fetchData();
}, []);
useEffect(() => {
let deviation = 0;
if (plannedCost && totalCost) {
@ -177,9 +166,11 @@ const DashboardProject = (props) => {
}
setRemToComplete(deviation.toString());
}, [plannedCost, totalCost]);
const handleRedirect = () => {
history.push("/projects/" + GANTT_ID + "/" + PROJECT_ID + "/gantt");
};
const getManpower = async () => {
const url = `${BASE_OSPRO}/api/project/manpower/${PROJECT_ID}`;
try {
@ -188,6 +179,7 @@ const DashboardProject = (props) => {
} catch (error) {
}
};
const getGantt = async () => {
setIsReadyGantt(false);
const url = `${BASE_OSPRO}/api/version-gantt/edit/${GANTT_ID}`;
@ -204,6 +196,7 @@ const DashboardProject = (props) => {
setIsReadyGantt(true);
}
};
const getGanttParents = async () => {
setIsReadyGanttParents(false);
const url = `${BASE_OSPRO}/api/hierarchy-ftths/tree-gantt/${GANTT_ID}`;
@ -215,6 +208,7 @@ const DashboardProject = (props) => {
setIsReadyGanttParents(true);
}
};
const getAssignedHR = async () => {
const url = `${BASE_OSPRO}/api/project/manpower/assigned/${GANTT_ID}`;
try {
@ -230,6 +224,7 @@ const DashboardProject = (props) => {
} catch (error) {
}
};
const getActualHR = async () => {
const dateStart = moment().startOf("day").toDate();
const dateEnd = moment().endOf("day").toDate();
@ -269,6 +264,7 @@ const DashboardProject = (props) => {
console.error("Failed to get actual HR:", error);
}
};
const getProjectDetail = async () => {
setIsReadyProjectDetail(false);
let URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`;
@ -353,6 +349,7 @@ const DashboardProject = (props) => {
}
}
};
const getSCurve = async () => {
setIsReadySCurve(false);
let URL = `${BASE_OSPRO}/api/project/get-s-curve`;
@ -385,6 +382,7 @@ const DashboardProject = (props) => {
let selisihProgress = 0;
let planningProgress = 0;
let actualProgress = 0;
let progressPlanToDay = 0;
let statusHealthBySchedule = "behind-schedule";
if (
result.data.data.length > 0 &&
@ -424,6 +422,14 @@ const DashboardProject = (props) => {
planningProgress = result.data.data[0].data?.percentagePlan[n];
setPlanningProgress(planningProgress);
}
if (
result.data.data.length > 0 &&
result.data.data[0].data?.progressPlanToDay &&
result.data.data[0].data?.progressPlanToDay != null
) {
progressPlanToDay = result.data.data[0].data?.progressPlanToDay;
setPlanningProgressToDay(+(Math.round(progressPlanToDay + "e+2") + "e-2"));
}
if (
result.data.data.length > 0 &&
result.data.data[0].data?.percentageReal &&
@ -445,6 +451,7 @@ const DashboardProject = (props) => {
setIsReadySCurve(true);
}
};
const getOverdueActivities = async () => {
setIsReadyOverdueActivities(false);
const URL = `${BASE_OSPRO}/api/project/get-overdue-activities`;
@ -478,6 +485,7 @@ const DashboardProject = (props) => {
setIsReadyOverdueActivities(true);
}
};
const getIntegrationInvoice = async (kode_sortname, id, gantt_id = null) => {
setIsReadyIntegrationInvoice(false);
const URL = `${BASE_OSPRO}/api/project/get-integration-invoice`;
@ -521,6 +529,7 @@ const DashboardProject = (props) => {
setIsReadyIntegrationInvoice(true);
}
};
const getReportDistribution = async () => {
setIsReadyReportDistribution(false);
const URL = `${BASE_OSPRO}/api/project/get-report-distribution`;
@ -553,6 +562,7 @@ const DashboardProject = (props) => {
setIsReadyReportDistribution(true);
}
};
const getComments = async () => {
setIsReadyComments(false);
const URL = `${BASE_OSPRO}/api/project-comment/search`;
@ -581,6 +591,7 @@ const DashboardProject = (props) => {
orders: { columns: ["created_at"], ascending: false },
paging: { start: 0, length: -1 },
};
const result = await axios
.post(URL, payload, HEADER)
.then((res) => res)
@ -602,6 +613,7 @@ const DashboardProject = (props) => {
setIsReadyComments(true);
}
};
const handleSendComment = async () => {
setIsSendingComment(true);
if (comment === "") {
@ -641,10 +653,23 @@ const DashboardProject = (props) => {
getComments();
}
};
const resetInputComment = () => {
setComment("");
setIsSendingComment(false);
};
const getQueryParams = () => {
const searchParams = new URLSearchParams(props.location.search);
const dashboardGantt = searchParams.get('dashboardGantt');
setDashboardStatus(dashboardGantt);
}
const handleBack = async () => {
const domainUrl = window.location.origin;
!SCURVE ? (dashboardGantt ? window.parent.location.reload() : window.location.replace(`${domainUrl}/#/projects/${GANTT_ID}/${PROJECT_ID}/gantt`)) : window.history.go(-1);
};
const initMap = () => {
let mymap = L.map("map-area", {
center: center,
@ -656,6 +681,7 @@ const DashboardProject = (props) => {
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
}).addTo(mymap);
};
useEffect(() => {
if (mymap) {
if (reportDistribution.length > 0) {
@ -667,6 +693,7 @@ const DashboardProject = (props) => {
}
}
}, [mymap, reportDistribution]);
useEffect(() => {
// Add event listener for receiving messages from the iframe
window.addEventListener("message", handleIframeMessage);
@ -675,6 +702,7 @@ const DashboardProject = (props) => {
window.removeEventListener("message", handleIframeMessage);
};
}, []);
const handleIframeMessage = (event) => {
if (event.data && event.data.action === "getUrl") {
const childUrl = window.location.href;
@ -685,6 +713,7 @@ const DashboardProject = (props) => {
);
}
};
const RenderGantt = useMemo(
() => (
<iframe
@ -701,6 +730,7 @@ const DashboardProject = (props) => {
),
[activeTabIdx]
);
const RenderComments = useMemo(() => {
return (
<>
@ -804,12 +834,25 @@ const DashboardProject = (props) => {
);
}, [overdueActivities, isReadyOverdueActivities]);
return (
<div style={{ marginLeft: -25, marginRight: -25 }}>
<div style={{ marginLeft: dashboardGantt ? -80 : -25, marginRight: -25 }}>
<NotificationContainer />
<Row>
<Col span={18}>
<Row>
<Col span={8}>
<Col span={2}>
<Button
style={{
height: "100%",
width: "100%",
fontSize: "18px"
}}
onClick={handleBack}
type="primary"
>
<Icon icon={arrowLeft} style={{ fontSize: "20px" }} /> Back
</Button>
</Col>
<Col span={6}>
<div
style={{
border: "solid",
@ -858,14 +901,14 @@ const DashboardProject = (props) => {
}
return SCURVE && SCURVE == "1"
? projectName
? calculationStatus
? projectName + " - S-Curve Ready"
: projectName + " - S-Curve Loading"
: null
: projectName +
parentNames +
" - " +
dataGantt.data.data.name_version;
// ? calculationStatus
// ? projectName + " - S-Curve Ready"
// : projectName + " - S-Curve Loading"
// : null
: projectName
// + parentNames +
// " - " +
// dataGantt.data.data.name_version;
})()
) : (
<SingleTextLoader />
@ -1416,7 +1459,7 @@ const DashboardProject = (props) => {
</div>
{isReadySCurve ? (
<ProgressPlanningBar
progress={planningProgress > 100 ? 100 : planningProgress}
progress={planningProgressToDay > 100 ? 100 : planningProgressToDay}
/>
) : (
<SingleTextLoader width={"100%"} height={30} />

5
src/views/Dashboard/DashboardProjectCarousell.js

@ -70,13 +70,12 @@ const center = {
};
const DashboardProject = ({args,...props}) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -129,7 +128,7 @@ const DashboardProject = ({args,...props}) => {
setIsReadyProjectDetail(false);
setIsReadySCurve(false)
setIsReadySCurve(false);
const URL = `${BASE_OSPRO}/api/project-carausell/${company_id}/${all_project}/${hierarchy}`;
const URL = `${BASE_OSPRO}/api/project-carausell/${all_project}/${hierarchy}`;
const result = await axios
.get(URL, HEADER)
.then((res) => res)

5
src/views/MapMonitoring/index.js

@ -29,13 +29,12 @@ import moment from 'moment';
import axios from "../../const/interceptorApi";
const MapMonitoring = ({ ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='', configApp={};
let role_id = 0, user_id = 0, isLogin = false, token = '', 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;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -225,7 +224,7 @@ const MapMonitoring = ({ ...props }) => {
const pointToLayerUserPoints = (feature, latlng) => {
let imgSrc = DEFAULT_USER_ICON;
if (feature && feature.properties && feature.properties.image && feature.properties.image !== '') {
imgSrc = `${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(feature.properties.image, JSON.parse(configApp).company_name, moment(feature.properties.created_at).format('YYYY-MM'))}`
imgSrc = `${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(feature.properties.image)}`
}
let img = `<img src="${imgSrc}" />`
let logoMarker = L.divIcon({

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

File diff suppressed because it is too large Load Diff

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

@ -1,434 +1,387 @@
import 'antd/dist/antd.css';
import React, { Component } from 'react';
import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import Select from 'react-select';
import axios from 'axios';
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst';
import { Transfer } from 'antd';
import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const ERROR_TITLE = "judul is required!"
const ERROR_MESSAGE = "message is required!"
const BASE_URL = "https://oslog.id/geohr-api/";
const roleName = window.localStorage.getItem('role_name');
let countError = 0;
class DialogForm extends Component {
constructor(props) {
super(props)
this.state = {
id: 0,
title: "",
description: "",
message: "",
openDialog: false,
isParentClick: false,
errorTitle: "",
errorMessage: "",
errorDivision: "",
errorEmployee: "",
penerima: "all",
displayKaryawan: "none",
displayDivisi: "none",
listOrganizationSelect: [],
currentSelectDiv: null,
dataEmployee: [],
dataSourceEmployee: [],
idOrganization: 0,
targetKeys: [],
selectedKeys: [],
allEmployeeId: [],
idEmployeeDivision: [],
idOrganization: [],
disableTransfer: true,
listCompany: [],
company_id: this.props.company_id,
role_name: ''
}
}
async componentDidMount() {
if (this.props.company_id !== null) {
this.getDataRole();
this.getDataUsers();
}
this.props.showDialog(this.showDialog);
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
if (this.props.typeDialog === "Edit") {
const { dataEdit } = this.props
this.setState({
id: dataEdit.id,
title: dataEdit.title_notif,
description: dataEdit.description,
message: dataEdit.message_notif,
company_id: dataEdit.company_id
})
} else {
this.setState({
id: 0,
title: "",
description: "",
message: "",
company_id: 0
})
}
this.setState({ isParentClick: false });
}
}
showDialog = () => {
this.setState({ isParentClick: true });
}
validate = () => {
let isError = false
const { title, message, penerima } = this.state
if (title === "") {
isError = true
this.setState({ errorTitle: ERROR_TITLE })
} else if (title.length < 3 || title.length > 100) {
isError = true
this.setState({ errorTitle: "Title minimum 3-100 karakter!" })
}
if (message === "") {
isError = true
this.setState({ errorMessage: ERROR_MESSAGE })
} else if (message.length < 3 || message.length > 200) {
isError = true
this.setState({ errorMessage: "message minimum 3-200 karakter!" })
}
if (penerima === "division") {
if (this.state.idOrganization === 0) {
this.setState({ errorDivision: "Silahkan pilih divisi penerima!" })
}
} else if (penerima === "karyawan") {
if (this.state.selectedKeys.length === 0) {
this.setState({ errorEmployee: "Silahkan pilih karyawan penerima!" })
}
}
return isError
}
handleSave = (param) => {
let err = this.validate()
if (!err) {
const {
id,
title,
description,
message,
penerima,
} = this.state
let {
company_id
} = this.state
let idSend = [];
let send_to_type = "all";
if (penerima === "all") {
idSend = this.state.allEmployeeId;
send_to_type = "all";
} else if (penerima === "organization") {
idSend = this.state.idOrganization;
send_to_type = "roles";
} else if (penerima === "karyawan") {
idSend = this.state.targetKeys;
send_to_type = "users";
}
if (Array.isArray(idSend)) {
idSend = idSend.map(function (e) {
return e.toString()
});
} else {
idSend = idSend;
}
if (this.props.role_name !== 'Super Admin') {
company_id = parseInt(this.props.company_id)
}
const data = {
title,
description,
message,
send_to_type,
id: idSend,
company_id: company_id
}
if (param === 'registered' || param === 'send') {
this.props.handleSaveBroadcast(param, data)
}
this.setState({ id: 0, idOrganization: 0, currentSelectDiv: null, targetKeys: [], penerima: "all", displayKaryawan: "none", displayDivisi: "none", disableTransfer: true });
}
}
handleCancel = () => {
this.props.handleSaveBroadcast('cancel', 'none')
}
handleChangePenerima = type => {
if (type === "organization") {
this.setState({ displayDivisi: "block", displayKaryawan: "none", disableTransfer: true, errorDivision: "", targetKeys: [] })
} else if (type === "karyawan") {
this.setState({ displayKaryawan: "block", displayDivisi: "none", disableTransfer: false, errorEmployee: "", idEmployeeDivision: [], currentSelectDiv: null })
} else {
this.setState({ displayKaryawan: "none", displayDivisi: "none", disableTransfer: true, errorDivision: "", errorEmployee: "", targetKeys: [], idEmployeeDivision: [], currentSelectDiv: null })
}
this.setState({ penerima: type });
}
handleSelectOrganization = (inputValue, actionMeta) => {
this.setState({ idOrganization: inputValue.value, currentSelectDiv: { value: inputValue.value, label: inputValue.label }, errorDivision: "" }, () => {
this.setEmployeeOrganization();
});
}
setEmployeeOrganization = () => {
let arrEd = this.state.dataEmployee.data;
let cek = arrEd.filter(this.filterId)
this.setState({ idEmployeeDivision: cek })
}
filterId = (val) => {
return val.organization_id == this.state.idOrganization
}
getDataRole = async () => {
const payload = {
"paging": {
"start": 0,
"length": -1
},
"columns": [
{
"name": "company_id",
"logic_operator": "=",
"value": this.state.company_id,
"operator": "AND"
}
],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(ROLE_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.setState({ dataDivision: result.data.data }, () => {
this.setDataOrganization();
})
} else {
}
}
setDataOrganization = () => {
const { dataDivision } = this.state
const listOrganization = []
dataDivision.map((val, index) => {
listOrganization.push({
value: val.id,
label: val.name
})
})
this.setState({ listOrganizationSelect: listOrganization })
}
getDataUsers = async () => {
const payload = {
"paging": {
"start": 0,
"length": -1
},
"columns": [
{
"name": "name",
"logic_operator": "like",
"value": "",
"operator": "AND",
"table_name": "m_users"
},
{
"name": "company_id",
"logic_operator": "=",
"value": this.state.company_id,
"operator": "AND"
}
],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
//TODO should use search instead
const result = await axios
.post(USER_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.status == 200) {
this.setState({ dataEmployee: result.data }, () => {
this.setDataEmployee();
});
} else {
}
}
setDataEmployee = () => {
const listEmployee = [];
const allIdEmployee = [];
this.state.dataEmployee.data.map((val, index) => {
allIdEmployee.push(val.id);
listEmployee.push({
key: val.id,
id: val.id,
title: val.name
});
})
this.setState({ dataSourceEmployee: listEmployee, allEmployeeId: allIdEmployee })
}
handleChangeTransfer = (nextTargetKeys, direction, moveKeys) => {
this.setState({ targetKeys: nextTargetKeys, errorEmployee: "" });
};
handleSelectChangeTransfer = (sourceSelectedKeys, targetSelectedKeys) => {
this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys], errorEmployee: "" });
};
handleSelectCompany = (selectedOption) => {
const selectedCompanyId = selectedOption.value;
this.setState({ company_id: selectedCompanyId }, () => {
this.getDataRole();
this.getDataUsers();
});
}
renderForm = () => {
const t = this.props
const { errorTitle, errorMessage } = this.state
return (
<Form>
{this.props.role_name === 'Super Admin' && (
<FormGroup>
<Label>{this.props.t('company')}</Label>
<Select
options={this.props.listCompany.map(company => ({ value: company.id, label: company.company_name }))}
onChange={this.handleSelectCompany}
value={this.state.company_id}
/>
</FormGroup>
)}
<FormGroup>
<Label>{this.props.t('receiver')}</Label>
<Input type="select" value={this.state.penerima} onChange={(e) => this.handleChangePenerima(e.target.value)}>
<option value="all">{this.props.t('all')}</option>
<option value="organization">{this.props.t('roles')}</option>
<option value="karyawan">{this.props.t('user')}</option>
</Input>
</FormGroup>
<FormGroup style={{ display: this.state.displayDivisi }}>
<Label>{this.props.t('roles')}</Label>
<Select options={this.state.listOrganizationSelect} onChange={this.handleSelectOrganization} value={this.state.currentSelectDiv} />
{this.state.errorDivision && <FormFeedback>{this.state.errorDivision}</FormFeedback>}
</FormGroup>
<FormGroup style={{ display: this.state.displayKaryawan }}>
<Label>{this.props.t('user')}</Label>
{!this.state.disableTransfer &&
<Transfer
dataSource={this.state.dataSourceEmployee}
showSearch
titles={['', 'Terpilih']}
targetKeys={this.state.targetKeys}
selectedKeys={this.state.selectedKeys}
onChange={this.handleChangeTransfer}
onSelectChange={this.handleSelectChangeTransfer}
render={item => item.title}
disabled={this.state.disableTransfer}
/>
}
{this.state.errorEmployee && <FormFeedback>{this.state.errorEmployee}</FormFeedback>}
</FormGroup>
<FormGroup>
<Label>{this.props.t('title')}</Label>
<Input invalid={errorTitle} type="text" value={this.state.title}
onChange={(e) =>
this.setState(
{
errorTitle: e.target.value !== "" ? "" : ERROR_TITLE,
title: e.target.value
})}
placeholder={this.props.t('inputTitle')} />
{errorTitle && (
<FormFeedback>{errorTitle}</FormFeedback>
)}
</FormGroup>
<FormGroup>
<Label>{this.props.t('messageBroadcast')}</Label>
<Input
invalid={errorMessage}
style={{ minHeight: "100px" }}
type="textarea"
value={this.state.message}
onChange={(e) => this.setState({ errorMessage: e.target.value !== "" ? "" : ERROR_MESSAGE, message: e.target.value })} placeholder={this.props.t('inputMsg')} />
{errorMessage && (
<FormFeedback>{errorMessage}</FormFeedback>
)}
</FormGroup>
<FormGroup>
<Label>{this.props.t('broadcastDescription')}</Label>
<Input style={{ minHeight: "100px" }} type="textarea" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} />
</FormGroup>
</Form >
)
}
handleCloseDialog = () => {
this.props.closeDialog()
this.setState({
errorTitle: "",
errorMessage: "",
errorDivision: "",
errorEmployee: ""
})
}
render() {
return (
<Modal isOpen={this.props.openDialog} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.handleCloseDialog}>{this.props.t('broadcastDetail')}</ModalHeader>
<ModalBody>
{this.renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => this.handleSave("send")}>{this.props.t('saveSend')}</Button>{' '}
<Button color="primary" onClick={() => this.handleSave("registered")}>{this.props.t('save')}</Button>{' '}
<Button color="secondary" onClick={this.handleCloseDialog}>{this.props.t('cancel')}</Button>
</ModalFooter>
</Modal>
)
}
}
export default withTranslation()(DialogForm);
import 'antd/dist/antd.css';
import React, { Component } from 'react';
import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import Select from 'react-select';
import axios from 'axios';
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst';
import { Transfer } from 'antd';
import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const ERROR_TITLE = "judul is required!"
const ERROR_MESSAGE = "message is required!"
const BASE_URL = "https://oslog.id/geohr-api/";
const roleName = window.localStorage.getItem('role_name');
let countError = 0;
class DialogForm extends Component {
constructor(props) {
super(props)
this.state = {
id: 0,
title: "",
description: "",
message: "",
openDialog: false,
isParentClick: false,
errorTitle: "",
errorMessage: "",
errorDivision: "",
errorEmployee: "",
penerima: "all",
displayKaryawan: "none",
displayDivisi: "none",
listOrganizationSelect: [],
currentSelectDiv: null,
dataEmployee: [],
dataSourceEmployee: [],
idOrganization: 0,
targetKeys: [],
selectedKeys: [],
allEmployeeId: [],
idEmployeeDivision: [],
idOrganization: [],
disableTransfer: true,
role_name: ''
}
}
async componentDidMount() {
this.props.showDialog(this.showDialog);
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
if (this.props.typeDialog === "Edit") {
const { dataEdit } = this.props
this.setState({
id: dataEdit.id,
title: dataEdit.title_notif,
description: dataEdit.description,
message: dataEdit.message_notif
})
} else {
this.setState({
id: 0,
title: "",
description: "",
message: ""
})
}
this.setState({ isParentClick: false });
}
}
showDialog = () => {
this.setState({ isParentClick: true });
}
validate = () => {
let isError = false
const { title, message, penerima } = this.state
if (title === "") {
isError = true
this.setState({ errorTitle: ERROR_TITLE })
} else if (title.length < 3 || title.length > 100) {
isError = true
this.setState({ errorTitle: "Title minimum 3-100 karakter!" })
}
if (message === "") {
isError = true
this.setState({ errorMessage: ERROR_MESSAGE })
} else if (message.length < 3 || message.length > 200) {
isError = true
this.setState({ errorMessage: "message minimum 3-200 karakter!" })
}
if (penerima === "division") {
if (this.state.idOrganization === 0) {
this.setState({ errorDivision: "Silahkan pilih divisi penerima!" })
}
} else if (penerima === "karyawan") {
if (this.state.selectedKeys.length === 0) {
this.setState({ errorEmployee: "Silahkan pilih karyawan penerima!" })
}
}
return isError
}
handleSave = (param) => {
let err = this.validate()
if (!err) {
const {
id,
title,
description,
message,
penerima,
} = this.state
let idSend = [];
let send_to_type = "all";
if (penerima === "all") {
idSend = this.state.allEmployeeId;
send_to_type = "all";
} else if (penerima === "organization") {
idSend = this.state.idOrganization;
send_to_type = "roles";
} else if (penerima === "karyawan") {
idSend = this.state.targetKeys;
send_to_type = "users";
}
if (Array.isArray(idSend)) {
idSend = idSend.map(function (e) {
return e.toString()
});
} else {
idSend = idSend;
}
const data = {
title,
description,
message,
send_to_type,
id: idSend
}
if (param === 'registered' || param === 'send') {
this.props.handleSaveBroadcast(param, data)
}
this.setState({ id: 0, idOrganization: 0, currentSelectDiv: null, targetKeys: [], penerima: "all", displayKaryawan: "none", displayDivisi: "none", disableTransfer: true });
}
}
handleCancel = () => {
this.props.handleSaveBroadcast('cancel', 'none')
}
handleChangePenerima = type => {
if (type === "organization") {
this.setState({ displayDivisi: "block", displayKaryawan: "none", disableTransfer: true, errorDivision: "", targetKeys: [] })
} else if (type === "karyawan") {
this.setState({ displayKaryawan: "block", displayDivisi: "none", disableTransfer: false, errorEmployee: "", idEmployeeDivision: [], currentSelectDiv: null })
} else {
this.setState({ displayKaryawan: "none", displayDivisi: "none", disableTransfer: true, errorDivision: "", errorEmployee: "", targetKeys: [], idEmployeeDivision: [], currentSelectDiv: null })
}
this.setState({ penerima: type });
}
handleSelectOrganization = (inputValue, actionMeta) => {
this.setState({ idOrganization: inputValue.value, currentSelectDiv: { value: inputValue.value, label: inputValue.label }, errorDivision: "" }, () => {
this.setEmployeeOrganization();
});
}
setEmployeeOrganization = () => {
let arrEd = this.state.dataEmployee.data;
let cek = arrEd.filter(this.filterId)
this.setState({ idEmployeeDivision: cek })
}
filterId = (val) => {
return val.organization_id == this.state.idOrganization
}
getDataRole = async () => {
const payload = {
"paging": {
"start": 0,
"length": -1
},
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(ROLE_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
this.setState({ dataDivision: result.data.data }, () => {
this.setDataOrganization();
})
} else {
}
}
setDataOrganization = () => {
const { dataDivision } = this.state
const listOrganization = []
dataDivision.map((val, index) => {
listOrganization.push({
value: val.id,
label: val.name
})
})
this.setState({ listOrganizationSelect: listOrganization })
}
getDataUsers = async () => {
const payload = {
"paging": {
"start": 0,
"length": -1
},
"columns": [
{
"name": "name",
"logic_operator": "like",
"value": "",
"operator": "AND",
"table_name": "m_users"
}
],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
//TODO should use search instead
const result = await axios
.post(USER_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.status == 200) {
this.setState({ dataEmployee: result.data }, () => {
this.setDataEmployee();
});
} else {
}
}
setDataEmployee = () => {
const listEmployee = [];
const allIdEmployee = [];
this.state.dataEmployee.data.map((val, index) => {
allIdEmployee.push(val.id);
listEmployee.push({
key: val.id,
id: val.id,
title: val.name
});
})
this.setState({ dataSourceEmployee: listEmployee, allEmployeeId: allIdEmployee })
}
handleChangeTransfer = (nextTargetKeys, direction, moveKeys) => {
this.setState({ targetKeys: nextTargetKeys, errorEmployee: "" });
};
handleSelectChangeTransfer = (sourceSelectedKeys, targetSelectedKeys) => {
this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys], errorEmployee: "" });
};
renderForm = () => {
const t = this.props
const { errorTitle, errorMessage } = this.state
return (
<Form>
<FormGroup>
<Label>{this.props.t('receiver')}</Label>
<Input type="select" value={this.state.penerima} onChange={(e) => this.handleChangePenerima(e.target.value)}>
<option value="all">{this.props.t('all')}</option>
<option value="organization">{this.props.t('roles')}</option>
<option value="karyawan">{this.props.t('user')}</option>
</Input>
</FormGroup>
<FormGroup style={{ display: this.state.displayDivisi }}>
<Label>{this.props.t('roles')}</Label>
<Select options={this.state.listOrganizationSelect} onChange={this.handleSelectOrganization} value={this.state.currentSelectDiv} />
{this.state.errorDivision && <FormFeedback>{this.state.errorDivision}</FormFeedback>}
</FormGroup>
<FormGroup style={{ display: this.state.displayKaryawan }}>
<Label>{this.props.t('user')}</Label>
{!this.state.disableTransfer &&
<Transfer
dataSource={this.state.dataSourceEmployee}
showSearch
titles={['', 'Terpilih']}
targetKeys={this.state.targetKeys}
selectedKeys={this.state.selectedKeys}
onChange={this.handleChangeTransfer}
onSelectChange={this.handleSelectChangeTransfer}
render={item => item.title}
disabled={this.state.disableTransfer}
/>
}
{this.state.errorEmployee && <FormFeedback>{this.state.errorEmployee}</FormFeedback>}
</FormGroup>
<FormGroup>
<Label>{this.props.t('title')}</Label>
<Input invalid={errorTitle} type="text" value={this.state.title}
onChange={(e) =>
this.setState(
{
errorTitle: e.target.value !== "" ? "" : ERROR_TITLE,
title: e.target.value
})}
placeholder={this.props.t('inputTitle')} />
{errorTitle && (
<FormFeedback>{errorTitle}</FormFeedback>
)}
</FormGroup>
<FormGroup>
<Label>{this.props.t('messageBroadcast')}</Label>
<Input
invalid={errorMessage}
style={{ minHeight: "100px" }}
type="textarea"
value={this.state.message}
onChange={(e) => this.setState({ errorMessage: e.target.value !== "" ? "" : ERROR_MESSAGE, message: e.target.value })} placeholder={this.props.t('inputMsg')} />
{errorMessage && (
<FormFeedback>{errorMessage}</FormFeedback>
)}
</FormGroup>
<FormGroup>
<Label>{this.props.t('broadcastDescription')}</Label>
<Input style={{ minHeight: "100px" }} type="textarea" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} />
</FormGroup>
</Form >
)
}
handleCloseDialog = () => {
this.props.closeDialog()
this.setState({
errorTitle: "",
errorMessage: "",
errorDivision: "",
errorEmployee: ""
})
}
render() {
return (
<Modal isOpen={this.props.openDialog} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.handleCloseDialog}>{this.props.t('broadcastDetail')}</ModalHeader>
<ModalBody>
{this.renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => this.handleSave("send")}>{this.props.t('saveSend')}</Button>{' '}
<Button color="primary" onClick={() => this.handleSave("registered")}>{this.props.t('save')}</Button>{' '}
<Button color="secondary" onClick={this.handleCloseDialog}>{this.props.t('cancel')}</Button>
</ModalFooter>
</Modal>
)
}
}
export default withTranslation()(DialogForm);

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

@ -5,7 +5,7 @@ import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import moment from 'moment';
import { USER_LIST, BASE_SIMPRO_LUMEN, ROLE_LIST, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
import { Button, Card, CardBody, CardHeader, DropdownItem, DropdownMenu, DropdownToggle, Input, InputGroup, InputGroupButtonDropdown, Table, Row, Col } from 'reactstrap';
import { DatePicker, Pagination } from 'antd';
import { NotificationContainer, NotificationManager } from 'react-notifications';
@ -66,9 +66,7 @@ class index extends Component {
totalPage: 0,
typeClock: "All",
typeDialog: 'Save',
role_name: props.role_name || '',
company_id: props.company_id,
listCompany: []
role_name: props.role_name || ''
}
}
@ -82,17 +80,6 @@ class index extends Component {
if (startDate !== prevState.startDate) this.getDataBroadcast()
}
getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
this.setState({ listCompany: result.data.data })
}
}
handleSearch = e => {
const value = e.target.value
this.setState({ search: value, currentPage: 1 })
@ -139,24 +126,6 @@ class index extends Component {
}
}
if (this.state.role_name === 'Super Admin') {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.columns.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
} else {
payload.columns.push(
{
"name": "company_id",
"logic_operator": "=",
"value": this.state.company_id,
"operator": "AND"
}
)
}
const result = await axios
.post(url, payload, config)
.then(res => res)
@ -164,7 +133,6 @@ class index extends Component {
if (result && result.data) {
if (result.data.code === 200) {
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord });
this.getDataCompany()
} else {
NotificationManager.error('Failed retreiving data!!', 'Failed');
}
@ -217,8 +185,7 @@ class index extends Component {
"status_send": type,
"send_to_type": "all",
"message_notif": data.message,
"description": data.description,
"company_id": data.company_id
"description": data.description
}
const paramRoles = {
@ -227,8 +194,7 @@ class index extends Component {
"send_to_type": "roles",
"message_notif": data.message,
"description": data.description,
"send_to_id": data.id,
"company_id": data.company_id
"send_to_id": data.id
}
const paramUsers = {
@ -237,8 +203,7 @@ class index extends Component {
"send_to_type": "users",
"message_notif": data.message,
"description": data.description,
"send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null,
"company_id": data.company_id
"send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null
}
if (data.send_to_type === "all") {
@ -491,9 +456,6 @@ class index extends Component {
</Col>
</Row>
</td>
{this.state.role_name === 'Super Admin' &&
<td>{n.join_first_company_name ? n.join_first_company_name : "-"}</td>
}
<td>{n.title_notif}</td>
<td>{n.message_notif !== "" ? n.message_notif : "-"}</td>
<td>{n.description !== "" ? n.description : "-"}</td>
@ -560,7 +522,6 @@ class index extends Component {
render() {
const column = [
{ name: this.props.t('action') },
this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null,
{ name: this.props.t('title') },
{ name: this.props.t('message') },
{ name: this.props.t('description') },
@ -595,9 +556,7 @@ class index extends Component {
dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
listCompany={this.state.listCompany}
/>
<DialogDetail
openDialog={this.state.openDialogDetail}

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

@ -443,7 +443,7 @@ const MasterCompany = ({ params }) => {
// Delete Image Function
const deleteImageHeader = async (id) => {
const URL = IMAGE_DELETE(id, 'company_logo_header', companyID != '' ? companyID : 'undifined');
const URL = IMAGE_DELETE(id, 'company_logo_header');
await axios
.delete(URL, HEADER)
.then(res => res)
@ -452,7 +452,7 @@ const MasterCompany = ({ params }) => {
};
const deleteImageLogin = async (id) => {
const URL = IMAGE_DELETE(id, 'company_logo_login', companyID != '' ? companyID : 'undifined');
const URL = IMAGE_DELETE(id, 'company_logo_login');
await axios
.delete(URL, HEADER)
.then(res => res)
@ -461,7 +461,7 @@ const MasterCompany = ({ params }) => {
};
const deleteImageFavicon = async (id) => {
const URL = IMAGE_DELETE(id, 'company_favicon', companyID != '' ? companyID : 'undifined');
const URL = IMAGE_DELETE(id, 'company_favicon');
await axios
.delete(URL, HEADER)
.then(res => res)
@ -470,7 +470,7 @@ const MasterCompany = ({ params }) => {
};
const deleteImageSlider = async (id) => {
const URL = IMAGE_MULTIPLE_DELETE(id, 'company_slider_login', companyID != '' ? companyID : 'undifined');
const URL = IMAGE_MULTIPLE_DELETE(id, 'company_slider_login');
await axios
.delete(URL, HEADER)
.then(res => res)

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

@ -5,7 +5,7 @@ import { withTranslation } from 'react-i18next';
import axios from 'axios';
import { NotificationManager } from 'react-notifications';
import { Select } from 'antd';
import { COMPANY_MANAGEMENT_LIST, MENU_SEARCH } from '../../../const/ApiConst.js';
import { MENU_SEARCH } from '../../../const/ApiConst.js';
const { Option } = Select
@ -18,12 +18,9 @@ class DialogForm extends Component {
description: "",
openDialog: false,
isParentClick: false,
companyList: [],
scompany_id:null,
menu: [],
selectedMenu: null,
all_project: false,
company_id: props.company_id || null,
role_name: props.role_name || '',
token: props.token || '',
config: {
@ -35,7 +32,6 @@ class DialogForm extends Component {
}
}
async componentDidMount() {
this.getDataProyekCompany();
this.getAllMenu();
this.props.showDialog(this.showDialog);
}
@ -47,36 +43,20 @@ class DialogForm extends Component {
id: dataEdit.id,
name: dataEdit.name,
description: dataEdit.description,
selectedMenu: dataEdit.default_page,
scompany_id : dataEdit.company_id
selectedMenu: dataEdit.default_page
})
} else {
this.setState({
id: 0,
name: "",
description: "",
selectedMenu: null,
scompany_id : null
selectedMenu: null
})
}
this.setState({ isParentClick: false });
}
}
getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, this.state.config)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
this.setState({companyList: dataRes})
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
getAllMenu = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
@ -100,10 +80,6 @@ class DialogForm extends Component {
}
validation = () => {
if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") {
alert("Company data cannot be empty!");
return true;
}
if (!this.state.name || this.state.name === "") {
alert("Role Name cannot be empty!");
return true;
@ -125,8 +101,6 @@ class DialogForm extends Component {
description,
selectedMenu,
role_name,
company_id,
scompany_id,
all_project
} = this.state
@ -139,7 +113,6 @@ class DialogForm extends Component {
name,
description,
selectedMenu,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project
}
@ -150,7 +123,6 @@ class DialogForm extends Component {
name,
description,
selectedMenu,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project
}
this.props.closeDialog('edit', data);
@ -163,9 +135,6 @@ class DialogForm extends Component {
this.props.closeDialog('cancel', 'none')
}
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => {
const { t } = this.props;
return (
@ -176,31 +145,6 @@ class DialogForm extends Component {
</Col>
</Row>
<Row>
{
this.state.role_name === 'Super Admin' && (
<Col md={12}>
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={this.state.scompany_id}
defaultValue={this.state.scompany_id}
onChange={this.onChangeCompanyProject}
style={{ width: "100%" }}
>
{this.state.companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
<Col md={12}>
<FormGroup>
<Label>{this.props.t('nameRole')}<span style={{ color: "red" }}>*</span></Label>

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

@ -3,7 +3,7 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Table } from 'reactstrap';
import { Button, Form } from 'reactstrap';
import 'antd/dist/antd.css';
import axios from 'axios';
import { MENU_COMPANY_SEARCH } from '../../../const/ApiConst.js';
import { MENU_SEARCH } from '../../../const/ApiConst';
const token = window.localStorage.getItem('token');
const config = {
headers:
@ -68,11 +68,8 @@ export default class DialogMenuRoles extends Component {
],
"orders": { "columns": ["id"], "ascending": false }
}
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.props.company_id, "operator": "AND" }
)
const result = await axios
.post(MENU_COMPANY_SEARCH, payload, config)
.post(MENU_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {

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

@ -51,7 +51,6 @@ class index extends Component {
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
company_id: props.company_id || 0,
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
@ -92,18 +91,6 @@ class index extends Component {
</Tooltip>
</>,
},
...(this.state.role_name === 'Super Admin'
? [
{
title: this.props.t('company'),
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => (
<span>{record.join_first_company_name}</span>
),
}
]
: []),
{ title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' },
]
@ -148,18 +135,6 @@ class index extends Component {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.props.company_id, "operator": "AND" },
)
} else {
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(ROLE_SEARCH, formData, this.state.config)
.then(res => res)
@ -226,7 +201,6 @@ class index extends Component {
name: data.name,
description: data.description,
default_page: data.selectedMenu,
company_id: data.company_id,
all_project: data.all_project
}
@ -247,7 +221,6 @@ class index extends Component {
name: data.name,
description: data.description,
default_page: data.selectedMenu,
company_id: data.company_id,
all_project: data.all_project
}
const url = ROLE_EDIT(data.id)
@ -264,7 +237,7 @@ class index extends Component {
}
handleEdit = (data) => {
this.setState({ dataEdit: data, company_id: data.company_id });
this.setState({ dataEdit: data });
this.handleOpenDialog('Edit');
}
@ -324,7 +297,7 @@ class index extends Component {
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
this.setState({ menuRoles: result.data.data, idRoles: data.id, company_id: data.company_id }, () => {
this.setState({ menuRoles: result.data.data, idRoles: data.id }, () => {
this.handleOpenDialogMr();
});
}
@ -395,19 +368,6 @@ class index extends Component {
"orders": { "columns": ["id"], "ascending": false }
}
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.props.company_id, "operator": "AND" },
)
} else {
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios
.post(ROLE_SEARCH, formData, this.state.config)
.then(res => res)
@ -418,9 +378,6 @@ class index extends Component {
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);
@ -478,7 +435,6 @@ class index extends Component {
dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>
@ -488,7 +444,6 @@ class index extends Component {
idRoles={this.state.idRoles}
showDialog={showDialog => this.showMenuRolesDialog = showDialog}
menuRoles={this.state.menuRoles}
company_id={this.state.company_id}
role_name={this.state.role_name}
role_id={this.state.role_id}
token={this.state.token}

7
src/views/Master/ProjectExpenditure/DialogForm.js

@ -9,7 +9,6 @@ import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id")
const { Option } = Select;
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0)
@ -33,16 +32,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
if (typeDialog === "Save") {
data = {
name: projectExpenditure,
color,
company_id
color
}
closeDialog('save', data);
} else {
data = {
id,
name: projectExpenditure,
color,
company_id
color
}
closeDialog('edit', data);
}

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

@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next';
const ProjectExpenditure = ({ 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 = '', all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -85,15 +84,7 @@ const ProjectExpenditure = ({ params, ...props }) => {
"start": start
}
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
}
const result = await axios
.post(PROJECT_EXPENDITURE_SEARCH, payload, HEADER)
.then((res) => res)

7
src/views/Master/ProjectFinancialHealth/DialogForm.js

@ -9,7 +9,6 @@ import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id")
const { Option } = Select;
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0)
@ -33,16 +32,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
if (typeDialog === "Save") {
data = {
name: projectFinancialHealth,
color,
company_id
color
}
closeDialog('save', data);
} else {
data = {
id,
name: projectFinancialHealth,
color,
company_id
color
}
closeDialog('edit', data);
}

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

@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next';
const ProjectFinancialHealth = ({ 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 = '', all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -85,15 +84,7 @@ const ProjectFinancialHealth = ({ params, ...props }) => {
"start": start
}
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
}
const result = await axios
.post(PROJECT_FINANCIAL_HEALTH_SEARCH, payload, HEADER)
.then((res) => res)

7
src/views/Master/ProjectInvoice/DialogForm.js

@ -9,7 +9,6 @@ import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id")
const { Option } = Select;
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0)
@ -33,16 +32,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
if (typeDialog === "Save") {
data = {
name: projectInvoice,
color,
company_id
color
}
closeDialog('save', data);
} else {
data = {
id,
name: projectInvoice,
color,
company_id
color
}
closeDialog('edit', data);
}

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

@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next';
const ProjectInvoice = ({ 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 = '', all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -85,15 +84,7 @@ const ProjectInvoice = ({ params, ...props }) => {
"start": start
}
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
}
const result = await axios
.post(PROJECT_INVOICE_SEARCH, payload, HEADER)
.then((res) => res)

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

@ -1,132 +1,91 @@
import React, { useEffect, useState } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import 'antd/dist/antd.css';
import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next';
import { Select } from 'antd';
const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const [id, setId] = useState(0)
const [projectType, setProjectType] = useState('')
const [color, setColor] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation();
useEffect(() => {
if (typeDialog === "Edit") {
setId(dataEdit.id)
setProjectType(dataEdit.name)
setColor(dataEdit.color)
setSelectedCompany(dataEdit.company_id)
} else {
setId(0)
setColor('')
setProjectType('')
}
}, [dataEdit, openDialog])
const handleSave = () => {
let data = '';
if (typeDialog === "Save") {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
name: projectType,
color,
company_id: company_id
}
closeDialog('save', data);
} else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
id,
name: projectType,
color,
company_id: company_id
}
closeDialog('edit', data);
}
setId(0)
}
const handleCancel = () => {
closeDialog('cancel', 'none')
setId(0)
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
<Form>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('phase')}</Label>
<Input type="text" value={projectType} onChange={(e) => setProjectType(e.target.value)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('color')}</Label>
<InputColor value={color} color={color} onChange={(e) => setColor(e.color)} />
</FormGroup>
</Col>
</Row>
{role_name === 'Super Admin' &&
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
}
</Form>
)
}
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} data</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
</>
)
}
export default DialogForm;
import React, { useEffect, useState } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import 'antd/dist/antd.css';
import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next';
import { Select } from 'antd';
const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, role_name }) => {
const [id, setId] = useState(0)
const [projectType, setProjectType] = useState('')
const [color, setColor] = useState('')
const { t } = useTranslation();
useEffect(() => {
if (typeDialog === "Edit") {
setId(dataEdit.id)
setProjectType(dataEdit.name)
setColor(dataEdit.color)
} else {
setId(0)
setColor('')
setProjectType('')
}
}, [dataEdit, openDialog])
const handleSave = () => {
let data = '';
if (typeDialog === "Save") {
data = {
name: projectType,
color
}
closeDialog('save', data);
} else {
data = {
id,
name: projectType,
color
}
closeDialog('edit', data);
}
setId(0)
}
const handleCancel = () => {
closeDialog('cancel', 'none')
setId(0)
}
const renderForm = () => {
return (
<Form>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('phase')}</Label>
<Input type="text" value={projectType} onChange={(e) => setProjectType(e.target.value)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('color')}</Label>
<InputColor value={color} color={color} onChange={(e) => setColor(e.color)} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} data</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
</>
)
}
export default DialogForm;

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

@ -6,27 +6,22 @@ import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, COMPANY_MANAGEMENT_LIST, BASE_OSPRO } from '../../../const/ApiConst';
import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, BASE_OSPRO } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
import {
formatNumber,
formatRupiah,
formatThousand,
renderFormatRupiah,
checkActMenup,
} from "../../../const/CustomFunc";
import { useLocation } from "react-router-dom";
const ProjectPhase = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -58,7 +53,6 @@ const ProjectPhase = ({ params, ...props }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation()
useEffect(() => {
getDataProjectPhase()
@ -71,21 +65,6 @@ const ProjectPhase = ({ params, ...props }) => {
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataProjectPhase = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
@ -116,21 +95,7 @@ const ProjectPhase = ({ params, ...props }) => {
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_PHASE_SEARCH, payload, HEADER)
.then((res) => res)
@ -189,21 +154,6 @@ const ProjectPhase = ({ params, ...props }) => {
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_PHASE_SEARCH, payload, HEADER)
@ -214,9 +164,6 @@ const ProjectPhase = ({ params, ...props }) => {
const excelData = [];
resData.map((val, index) => {
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name;
}
dataRow.Nama = val.name;
dataRow.Color = val.color;
excelData.push(dataRow)
@ -376,16 +323,6 @@ const ProjectPhase = ({ params, ...props }) => {
</Tooltip>{" "}
</>,
},
...(role_name === 'Super Admin' ?
[{
title: t('companyName'),
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => (
<span>{record.join_first_company_name}</span>
)
}]
: []),
{
title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap"
},
@ -435,9 +372,7 @@ const ProjectPhase = ({ params, ...props }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>

7
src/views/Master/ProjectScheduleHealth/DialogForm.js

@ -9,7 +9,6 @@ import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id")
const { Option } = Select;
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0)
@ -33,16 +32,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
if (typeDialog === "Save") {
data = {
name: projectScheduleHealth,
color,
company_id
color
}
closeDialog('save', data);
} else {
data = {
id,
name: projectScheduleHealth,
color,
company_id
color
}
closeDialog('edit', data);
}

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

@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next';
const ProjectScheduleHealth = ({ 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 = '', all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -85,15 +84,7 @@ const ProjectScheduleHealth = ({ params, ...props }) => {
"start": start
}
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
}
const result = await axios
.post(PROJECT_SCHEDULE_HEALTH_SEARCH, payload, HEADER)
.then((res) => res)

3
src/views/Master/Proyek/index.js

@ -48,7 +48,6 @@ const data = [
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const company_id = window.localStorage.getItem('company_id');
const IndexRole = ({ params }) => {
const token = localStorage.getItem("token")
@ -215,7 +214,7 @@ const IndexRole = ({ params }) => {
}
const onConfirmDelete = async () => {
let urlDel = PROYEK_DELETE(idDelete, company_id);
let urlDel = PROYEK_DELETE(idDelete);
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);

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

@ -2,7 +2,6 @@ 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 } from 'antd';
@ -15,10 +14,7 @@ class DialogForm extends Component {
name: "",
description: "",
openDialog: false,
companyList: [],
scompany_id:null,
isParentClick: false,
company_id: props.company_id || null,
role_name: props.role_name || '',
token: props.token || '',
config: {
@ -32,7 +28,6 @@ class DialogForm extends Component {
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getDataProyekCompany();
}
async componentDidUpdate() {
@ -42,15 +37,13 @@ class DialogForm extends Component {
this.setState({
id: dataEdit.id,
name: dataEdit.name,
description: dataEdit.description,
scompany_id : dataEdit.company_id
description: dataEdit.description
})
} else {
this.setState({
id: 0,
name: "",
description: "",
scompany_id:null
description: ""
})
}
this.setState({ isParentClick: false });
@ -62,58 +55,29 @@ class DialogForm extends Component {
this.setState({ isParentClick: true });
}
getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, this.state.config)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
this.setState({companyList: dataRes})
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
validation = () => {
if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") {
alert("Company data cannot be empty!");
return true;
}
}
handleSave = () => {
const {
id,
name,
description,
role_name,
company_id,
scompany_id
description
} = 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,
description
}
this.props.closeDialog('save', data);
} else {
data = {
id,
name,
description,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
description
}
this.props.closeDialog('edit', data);
}
}
this.setState({ id: 0 });
}
@ -121,37 +85,10 @@ class DialogForm extends Component {
this.props.closeDialog('cancel', 'none')
}
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => {
const { t } = this.props;
return (
<Form>
{
this.state.role_name === 'Super Admin' && (
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={this.state.scompany_id}
defaultValue={this.state.scompany_id}
onChange={this.onChangeCompanyProject}
style={{ width: "100%" }}
>
{this.state.companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
)
}
<FormGroup>
<Label>{this.props.t('name')}</Label>
<Input type="text" value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} />

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

@ -39,7 +39,6 @@ class index extends Component {
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,
@ -65,32 +64,22 @@ class index extends Component {
render: (text, record) => <>
<Tooltip title={this.props.t('delete')}>
{
checkActMenup('/project-role', 'delete') ?
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
:
null
}
checkActMenup('/project-role', 'delete') ?
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
:
null
}
</Tooltip>
<Tooltip title={this.props.t('edit')}>
{
checkActMenup('/project-role', 'update') ?
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
:
null
}
checkActMenup('/project-role', 'update') ?
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
:
null
}
</Tooltip>
</>,
},
{
title: this.state.role_name === 'Super Admin' ? "Company Name" : null,
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => {
return this.state.role_name === 'Super Admin' ? (
<span>{record.join_first_company_name}</span>
) : null;
}
},
{ title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' },
];
@ -133,21 +122,7 @@ class index extends Component {
"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(PROJECT_ROLE_SEARCH, formData, this.state.config)
.then(res => res)
@ -212,8 +187,7 @@ class index extends Component {
const formData = {
name: data.name,
description: data.description,
company_id: data.company_id
description: data.description
}
const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config)
@ -233,8 +207,7 @@ class index extends Component {
const formData = {
name: data.name,
description: data.description,
company_id : data.company_id
description: data.description
}
const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.state.config)
@ -315,21 +288,7 @@ class index extends Component {
"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)
@ -339,9 +298,6 @@ class index extends Component {
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);
@ -401,7 +357,6 @@ class index extends Component {
dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>

8
src/views/Pages/Login/Login.js

@ -134,7 +134,7 @@ class Login extends Component {
}
}
getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name, configApp) => {
getDataMenu = async (token, role_id, hierarchy, user_id, role_name, all_project, user_name, configApp) => {
const config = {
headers:
{
@ -167,7 +167,6 @@ class Login extends Component {
user_id,
token,
isLogin: true,
company_id,
role_name,
all_project,
user_name,
@ -186,7 +185,6 @@ class Login extends Component {
user_id,
token,
isLogin: true,
company_id,
role_name,
all_project,
user_name,
@ -209,7 +207,6 @@ class Login extends Component {
user_id,
token,
isLogin: true,
company_id,
role_name,
all_project,
user_name,
@ -259,13 +256,12 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name, data_user.configApp)
this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.role.name, data_user.role.all_project, data_user.user_name, data_user.configApp)
window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id);
window.localStorage.setItem('user_name', data_user.name);
window.localStorage.setItem('role_id', data_user.role_id);
window.localStorage.setItem('company_id', data_user.company_id);
window.localStorage.setItem('role_name', data_user.role.name);
window.localStorage.setItem('all_project', data_user.role.all_project);
window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy));

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

@ -26,13 +26,12 @@ const LENGTH_DATA = 10
class index extends Component {
constructor(props) {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp={};
let role_id = 0, user_id = 0, isLogin = false, token = '', 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;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -76,9 +75,7 @@ class index extends Component {
proyekIds: [],
allDataProyek: [],
finishSetupOption: false,
company_id: company_id,
role_name: role_name,
companyName: JSON.parse(configApp).company_name,
role_id: role_id,
hierarchy: hierarchy
}
@ -210,24 +207,8 @@ class index extends Component {
if (currentProyek) {
payload.columns.push({ "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek })
if (this.state.role_name === "Super Admin") {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.columns.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
} else {
payload.columns.push({ "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds })
if (this.state.role_name === "Super Admin") {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.columns.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
}
const result = await axios
@ -481,9 +462,6 @@ class index extends Component {
{dataTable2.length !== 0 ? dataTable2.map((n) => {
return (
<tr key={n.id}>
{this.state.role_name === 'Super Admin' &&
<td>{n.join_third_company_name ? n.join_third_company_name : "-"}</td>
}
<td>{n.join_first_name ? n.join_first_name : "-"}</td>
<td>{n.join_second_nama ? n.join_second_nama : "-"}</td>
<td>{n.report_date ? moment(n.report_date).format("DD-MM-YYYY") : "-"}</td>
@ -553,7 +531,6 @@ class index extends Component {
render() {
const column = [
this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null,
{ name: this.props.t('nameHR') },
{ name: this.props.t('projectName') },
{ name: this.props.t('dateReport') },
@ -585,7 +562,6 @@ class index extends Component {
closeDialog={this.handleCloseDialog}
toggleDialog={() => this.toggleAddDialog}
dataImage={this.state.dataImage}
companyName={this.state.companyName}
showDialog={showDialog => this.showChildDialog = showDialog}
/>
<Card>

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

@ -1,140 +1,97 @@
import React, { useEffect, useState } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
import { Select } from 'antd';
const { Option } = Select;
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [description, setDescription] = useState('')
const [selectedCompany, setSelectedCompany] = useState(null)
const { t } = useTranslation()
useEffect(() => {
if (typeDialog === "Edit") {
setId(dataEdit.id)
setDescription(dataEdit.description)
setName(dataEdit.name)
setSelectedCompany(dataEdit.company_id);
} else {
handleClearData()
}
}, [dataEdit, openDialog])
const handleSave = () => {
let data = '';
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
if (typeDialog === "Save") {
data = {
name: name,
description: description,
company_id: parseInt(company_id),
}
closeDialog('save', data);
} else {
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
data = {
id,
name: name,
description: description,
company_id: company_id,
}
closeDialog('edit', data);
}
handleClearData()
}
const handleCancel = () => {
closeDialog('cancel', 'none')
handleClearData()
}
const handleClearData = () => {
setId(0)
setName('')
setDescription('')
setSelectedCompany(null)
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
<Form>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('name')}</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('description')}</Label>
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={t('inputDescription')} />
</FormGroup>
</Col>
</Row>
{role_name === 'Super Admin' &&
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
</Row>
}
</Form>
)
}
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Checlist K3</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
</>
)
}
export default DialogForm;
import React, { useEffect, useState } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
import { Select } from 'antd';
const { Option } = Select;
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, role_name }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [description, setDescription] = useState('')
const { t } = useTranslation()
useEffect(() => {
if (typeDialog === "Edit") {
setId(dataEdit.id)
setDescription(dataEdit.description)
setName(dataEdit.name)
} else {
handleClearData()
}
}, [dataEdit, openDialog])
const handleSave = () => {
let data = '';
if (typeDialog === "Save") {
data = {
name: name,
description: description
}
closeDialog('save', data);
} else {
data = {
id,
name: name,
description: description
}
closeDialog('edit', data);
}
handleClearData()
}
const handleCancel = () => {
closeDialog('cancel', 'none')
handleClearData()
}
const handleClearData = () => {
setId(0)
setName('')
setDescription('')
}
const renderForm = () => {
return (
<Form>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('name')}</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('description')}</Label>
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={t('inputDescription')} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Checlist K3</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
</>
)
}
export default DialogForm;

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

@ -7,17 +7,11 @@ import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip, } from 'antd';
import {
CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH, COMPANY_MANAGEMENT_LIST
CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH
} from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
import { useLocation } from "react-router-dom";
import {
formatNumber,
formatRupiah,
formatThousand,
renderFormatRupiah,
checkActMenup,
} from "../../../const/CustomFunc";
import { checkActMenup } from "../../../const/CustomFunc";
const token = window.localStorage.getItem('token');
const config = {
@ -29,13 +23,12 @@ const config = {
};
const ChecklistK3 = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -64,10 +57,8 @@ const ChecklistK3 = ({ params, ...props }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation()
const column = [
role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('name') },
{ name: t('description') },
].filter(column => column && column.name)
@ -82,30 +73,11 @@ const ChecklistK3 = ({ params, ...props }) => {
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataChecklistK3 = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
group_column: {
"operator": "AND",
@ -132,22 +104,6 @@ const ChecklistK3 = ({ params, ...props }) => {
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(CHECKLIST_K3_SEARCH, payload, config)
.then(res => res)
@ -190,21 +146,6 @@ const ChecklistK3 = ({ params, ...props }) => {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(CHECKLIST_K3_SEARCH, payload, config)
@ -216,9 +157,6 @@ const ChecklistK3 = ({ params, ...props }) => {
const excelData = [];
resData.map((val, index) => {
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name;
}
dataRow.Nama = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow)
@ -359,8 +297,6 @@ const ChecklistK3 = ({ params, ...props }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
company_id={company_id}
listCompany={listCompany}
role_name={role_name}
/>
<Card>
@ -420,11 +356,6 @@ const ChecklistK3 = ({ params, ...props }) => {
}
</Tooltip>
</td>
{role_name === 'Super Admin' &&
(
<td>{n.join_first_company_name}</td>
)
}
<td>{n.name}</td>
<td>{n.description}</td>
</tr>

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

@ -14,7 +14,6 @@ import { formatRupiah } from '../../../const/CustomFunc'
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const company_id = window.localStorage.getItem('company_id');
const format = "DD-MM-YYYY";
const Closing = ({ params, ...props }) => {
@ -145,7 +144,7 @@ const Closing = ({ params, ...props }) => {
const toggleAddDialogView = () => setOpenDialogViewDetail(!openDialogViewDetail)
const onConfirmDelete = async () => {
let urlDel = PROYEK_DELETE(idDelete, company_id)
let urlDel = PROYEK_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);

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

@ -13,7 +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, token }) => {
const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, token }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -83,7 +83,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
}
const onConfirmDelete = async () => {
let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete, parseInt(company_id))
let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -198,7 +198,6 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
closeDialog={handleCloseDialogFormTools}
toggleDialog={toogleDialogFormTools}
idTask={idTask}
company_id={company_id}
token={token}
/>
</>

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

@ -11,7 +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, token }) => {
const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, token }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -91,9 +91,6 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan
"start": 0,
"length": -1
},
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) },
],
"orders": {
"columns": [
"id"
@ -117,9 +114,6 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan
"start": 0,
"length": -1
},
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) },
],
"joins": [],
"orders": {
"columns": [

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

@ -12,7 +12,7 @@ import 'antd/dist/antd.css';
import { NotificationManager } from 'react-notifications';
const role_id = localStorage.getItem('role_id');
const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, token }) => {
const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, token }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -50,8 +50,7 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, compa
"length": -1
},
"columns": [
{ "name": "is_customer", "logic_operator": "=", "value": true },
{ "name": "company_id", "logic_operator": "=", "value": company_id },
{ "name": "is_customer", "logic_operator": "=", "value": true }
],
"orders": {
"columns": [

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

@ -10,7 +10,7 @@ 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, companyId, token, role_name, companyName }) => {
const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, token, role_name }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -73,7 +73,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}
const handleDownload = (id, file) => {
fetch(DOCUMENT_DOWNLOAD(id, parseInt(companyId)), {
fetch(DOCUMENT_DOWNLOAD(id), {
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
@ -91,8 +91,8 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
});
}
const handleShow = (file, dateFile) => {
const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, companyName, dateFile)}`
const handleShow = (file) => {
const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file)}`
window.open(urlShow);
}
@ -118,14 +118,13 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
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 (["pdf", "png", "jpg", "jpeg", "gif"].includes(fileExt)) {
return (
<Tooltip title="View Document">
<Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(data.file, dateFile)}><i className="fa fa-eye"></i></Button>
<Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(data.file)}><i className="fa fa-eye"></i></Button>
</Tooltip>
)
}
@ -200,7 +199,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}
const onConfirmDelete = async () => {
let urlDel = DOCUMENT_DELETE(idDelete, parseInt(companyId))
let urlDel = DOCUMENT_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -218,7 +217,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}
const onConfirmDeleteFolder = async () => {
let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete, parseInt(companyId))
let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -314,7 +313,6 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
idTask={parseInt(idTask)}
parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit}
companyId={companyId}
token={token}
role_name={role_name}
/>

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

@ -32,10 +32,8 @@ const DialogFormProyek = ({
dataDivisions,
dataPM,
projectImage,
company_id,
role_name,
token,
companyList
token
}) => {
const HEADER = {
headers: {
@ -65,8 +63,6 @@ const DialogFormProyek = ({
const [organization, setProjectStructureOrg] = useState(null);
const [finance, setFinance] = useState("");
const [investor, setInvestor] = useState("");
const [company, setCompany] = useState("");
const [scompany_id, setCompanyId] = useState(null);
const [step, setStep] = useState(1);
const [currencyList, setCurrencyList] = useState(null);
const [currencyCode, setCurrencyCode] = useState("IDR");
@ -117,8 +113,6 @@ const DialogFormProyek = ({
setWorkArea(val.area_kerja);
setProjectDuration(val.durasi_proyek);
setInvestor(val.investor);
setCompany(val.company);
setCompanyId(val.company_id)
setFinance(val.finance);
setObjectives(val.project_objectives ? val.project_objectives : "");
setTestingEnv(val.testing_environment);
@ -209,8 +203,6 @@ const DialogFormProyek = ({
setProjectDuration("");
setDivisiProject(null);
setProjectStructureOrg(null);
setCompany("");
setCompanyId(null)
setCurrencyCode("IDR");
setCurrencySymbol("Rp");
setCurrencyName("Indonesian rupiah");
@ -268,7 +260,6 @@ const DialogFormProyek = ({
pm_id: pic,
investor,
finance,
company,
area_kerja: workArea,
durasi_proyek: parseInt(duration),
late_consequence: late,
@ -280,7 +271,6 @@ const DialogFormProyek = ({
currency_symbol: currencySymbol,
currency_code: currencyCode,
currency_name: currencyName,
company_id: role_name !== "Super Admin" ? parseInt(company_id) : parseInt(scompany_id),
value_proyek: valueProyek,
income_year: incomeYearly
};
@ -301,7 +291,6 @@ const DialogFormProyek = ({
pm_id: pic,
investor,
finance,
company,
area_kerja: workArea,
durasi_proyek: parseInt(duration),
late_consequence: late,
@ -313,7 +302,6 @@ const DialogFormProyek = ({
currency_symbol: currencySymbol,
currency_code: currencyCode,
currency_name: currencyName,
company_id: role_name !== "Super Admin" ? parseInt(company_id) : parseInt(scompany_id),
value_proyek: valueProyek,
income_year: incomeYearly
};
@ -334,10 +322,6 @@ const DialogFormProyek = ({
setTypeproject(val);
};
const onChangeCompanyProject = (val) => {
setCompanyId(val);
};
const onChangePhaseProject = (val) => {
setPhaseProject(val);
};
@ -424,10 +408,6 @@ const DialogFormProyek = ({
alert("End Date cannot be empty!");
return false;
}
if (role_name === 'Super Admin' && !scompany_id || scompany_id === "") {
alert("Company data cannot be empty!");
return false;
}
if (!biaya || biaya === "") {
alert("Budget cannot be empty!");
return false;
@ -782,41 +762,6 @@ const DialogFormProyek = ({
</Col>
</Row>
<Row>
{
role_name === 'Super Admin' && (
<Col md={6}>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={scompany_id}
defaultValue={scompany_id}
onChange={onChangeCompanyProject}
style={{ width: "100%" }}
>
{companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
<Col md={6}>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Company</Label>
<Input
type="text"
value={company}
onChange={(e) => setCompany(e.target.value)}
/>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>

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

@ -13,7 +13,7 @@ import DialogUserGantt from './DialogUserGantt';
import { Link } from 'react-router-dom';
const { Option } = Select
const DialogGantt = ({ openDialog, closeDialog, role_name, toggleDialog, idTask, proyekName, companyId, companyName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id, dataViewStartDate }) => {
const DialogGantt = ({ openDialog, closeDialog, role_name, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id, dataViewStartDate }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -132,9 +132,7 @@ const DialogGantt = ({ openDialog, closeDialog, role_name, toggleDialog, idTask,
token,
role_id,
user_id,
company_id: companyId,
dataViewStartDate,
companyName,
role_name,
ganttName : text.name_version
}

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

@ -1,12 +1,12 @@
import React, { useEffect, useState } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import axios from "../../../const/interceptorApi";
import { DOCUMENT_ADD } from '../../../const/ApiConst';
import 'antd/dist/antd.css';
import { NotificationManager } from 'react-notifications';
const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder, token, role_name, companyId }) => {
const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder, token }) => {
const HEADER = {
headers: {
@ -34,15 +34,13 @@ const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentId
const uploadDokumen = async () => {
const formData = new FormData;
formData.append('company_id', parseInt(companyId));
formData.append('dokumen', file, file.name);
if (parentIdNewFolder > 0) {
formData.append('ref_id', parentIdNewFolder); // folder_id
formData.append('ref_id', parentIdNewFolder);
formData.append('type_dokumen', 'project-document-in-folder');
}
else {
formData.append('ref_id', idTask); // proyek_id
formData.append('ref_id', idTask);
formData.append('type_dokumen', 'project-document-out-folder')
}

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

@ -32,15 +32,13 @@ import {
PROJECT_MILESTONE_DELETE_BY_PROYEK,
PROJECT_APPROVAL_DELETE_BY_PROYEK,
USER_SEARCH,
PROYEK_DELETE,
PROJECT_TYPE_SEARCH,
PROYEK_ADD,
PROYEK_SEARCH,
COMPANY_MANAGEMENT_LIST,
PROYEK_EDIT,
ASSIGN_HR_PROJECT_SEARCH,
PROJECT_CHECKLIST_SEARCH,
PROYEK_DELETE,
PROJECT_ISSUE_SEARCH,
PROJECT_RISK_SEARCH,
PROJECT_CHECKLIST_DELETE_BY_PROYEK,
@ -70,10 +68,7 @@ import DialogInitDocument from "./DialogInitDocument";
import DialogGantt from "./DialogGantt";
import DialogHierarchy from "./DialogHierarchy";
import {
formatNumber,
formatRupiah,
formatThousand,
renderFormatRupiah,
checkActMenup,
} from "../../../const/CustomFunc";
// import DialogAsignHr from './AsignHrProject';
@ -92,13 +87,12 @@ const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => {
let pageRow = 10;
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp = {};
let role_id = 0, user_id = 0, isLogin = false, token = '', 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;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -125,7 +119,6 @@ const CreatedProyek = ({ params, ...props }) => {
const [idTask, setidTask] = useState(0);
const [projectId, setProjectId] = useState(0);
const [dataTable, setDatatable] = useState([]);
const [companyList, setDataCompany] = useState([]);
const [search, setSearch] = useState("");
const [currentPage, setCurrentPage] = useState(1);
const [totalPage, setTotalPage] = useState(0);
@ -159,8 +152,6 @@ const CreatedProyek = ({ params, ...props }) => {
const [openDialogDoc, setOpenDialogDoc] = useState(false);
const [proyekName, setProyekName] = useState("");
const [openDialogProyek, setOpenDialogProyek] = useState(false);
const [companyId, setCompanyId] = useState(role_name !== 'Super Admin' ? company_id : 0);
const [companyName, setCompanyName] = useState('');
// project charter
const [projectCharter, setProjectCharter] = useState(null);
const [projectParticipant, setProjectParticipant] = useState(null);
@ -210,12 +201,6 @@ const CreatedProyek = ({ params, ...props }) => {
}
}, [openDialogProyek]);
useEffect(() => {
if (role_name === 'Super Admin') {
getDataProyekCompany();
}
}, [])
useEffect(() => {
if (parseInt(role_id) === 44) {
getDataProyekByCustomer()
@ -255,11 +240,6 @@ const CreatedProyek = ({ params, ...props }) => {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (role_name !== 'Super Admin') {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }
)
}
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER)
.then((res) => res)
@ -276,11 +256,6 @@ const CreatedProyek = ({ params, ...props }) => {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (role_name !== 'Super Admin') {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }
)
}
const result = await axios
.post(PROJECT_PHASE_SEARCH, payload, HEADER)
.then((res) => res)
@ -297,11 +272,7 @@ const CreatedProyek = ({ params, ...props }) => {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (role_name !== 'Super Admin') {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }
)
}
const result = await axios
.post(DIVISI_SEARCH, payload, HEADER)
.then((res) => res)
@ -320,11 +291,7 @@ const CreatedProyek = ({ params, ...props }) => {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (role_name !== 'Super Admin') {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }
)
}
const result = await axios
.post(USER_SEARCH, payload, HEADER)
.then((res) => res)
@ -336,22 +303,6 @@ const CreatedProyek = ({ params, ...props }) => {
}
};
const getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
setDataCompany(dataRes);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
const handleDashboard = async (id) => {
const URL = `${BASE_OSPRO}/api/project/detail/${id}`;
const result = await axios
@ -426,7 +377,6 @@ const CreatedProyek = ({ params, ...props }) => {
"akhir_proyek",
"value_proyek",
"income_year",
"company_id",
"deleted_at",
"deleted_by_id"
],
@ -446,23 +396,9 @@ const CreatedProyek = ({ params, ...props }) => {
paging: { start: start, length: rowsPerPage },
};
if (role_name !== 'Super Admin' && all_project === 'true') {
payload.columns.push(
{ name: "company_id", logic_operator: "like", value: parseInt(company_id), operator: "AND" }
);
}
if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') {
payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
);
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
);
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
@ -582,7 +518,6 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenDialogProyek = async (text) => {
setCompanyId(text.company_id);
setOpenDialogProyek(true);
setidTask(text.id);
if (text.id !== 0) {
@ -594,8 +529,6 @@ const CreatedProyek = ({ params, ...props }) => {
setDataViewStartDate(data.mulai_proyek)
setidTask(data.id);
setProyekName(data.nama);
setCompanyName(role_name === 'Super Admin' ? data.join_third_company_name : JSON.parse(configApp).company_name);
setCompanyId(data.company_id);
setOpenDialogGantt(true);
};
@ -630,16 +563,12 @@ 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(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(configApp).company_name);
setOpenDialogAsignCust(true);
};
@ -1009,7 +938,7 @@ const CreatedProyek = ({ params, ...props }) => {
};
const onConfirmDelete = async () => {
let urlDel = PROYEK_DELETE(idDelete, company_id);
let urlDel = PROYEK_DELETE(idDelete);
const result = await axios
.delete(urlDel, HEADER)
.then((res) => res)
@ -1230,8 +1159,7 @@ const CreatedProyek = ({ params, ...props }) => {
};
const deleteImage = async (id) => {
const company_id = localStorage.getItem("company_id");
const URL = IMAGE_DELETE(id, 'project_structure_organization', company_id);
const URL = IMAGE_DELETE(id, 'project_structure_organization');
await axios
.delete(URL, HEADER)
.then(res => res)
@ -1435,25 +1363,11 @@ const CreatedProyek = ({ params, ...props }) => {
joins: [],
orders: { columns: ["id"], ascending: false },
};
if (role_name !== 'Super Admin' && all_project === 'true') {
payload.columns.push(
{ name: "company_id", logic_operator: "like", value: parseInt(company_id), operator: "AND" }
);
}
if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') {
if (all_project === 'false' || all_project === 'null') {
payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
);
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.then((res) => res)
@ -1464,9 +1378,6 @@ const CreatedProyek = ({ params, ...props }) => {
const excelData = [];
resData.map((n, index) => {
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = n.join_first_company_name;
}
dataRow.Sortname = n.kode_sortname ? n.kode_sortname : "";
dataRow["Nama Project"] = n.nama ? n.nama : "";
dataRow["Tanggal Mulai"] = n.mulai_proyek
@ -1476,7 +1387,6 @@ const CreatedProyek = ({ params, ...props }) => {
? moment(n.akhir_proyek).format(format)
: "-";
dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : "";
dataRow["Perusahaan"] = n.company ? n.company : "";
dataRow["Keterangan"] = n.keterangan ? n.keterangan : "";
dataRow["Dianggap sukses ketika"] = n.considered_success_when
? n.considered_success_when
@ -1501,7 +1411,7 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportPdf = async () => {
const doc = new jsPDF();
let headers = [
[role_name === 'Super Admin' ? "Company" : null, "Project Name", "Nilai Kontrak", "Pendapatan Pertahun", "Anggaran Biaya", "Project Type", "PM", "Time Project"],
["Project Name", "Nilai Kontrak", "Pendapatan Pertahun", "Anggaran Biaya", "Project Type", "PM", "Time Project"],
];
const payload = {
@ -1550,25 +1460,11 @@ const CreatedProyek = ({ params, ...props }) => {
],
orders: { columns: ["nama"], ascending: true },
};
if (role_name !== 'Super Admin' && all_project === 'true') {
payload.columns.push(
{ name: "company_id", logic_operator: "like", value: parseInt(company_id), operator: "AND" }
);
}
if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') {
if (all_project === 'false' || all_project === 'null') {
payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
);
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.then((res) => res)
@ -1576,7 +1472,6 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const data = resData.map((elt) => [
role_name === 'Super Admin' ? elt.join_third_company_name : null,
elt.nama,
`Rp. ${formatThousand(elt.rencana_biaya)}`,
elt.join_second_name,
@ -1618,8 +1513,6 @@ 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(configApp).company_name);
setOpenDialogDoc(true);
};
@ -1716,9 +1609,7 @@ const CreatedProyek = ({ params, ...props }) => {
role_id,
user_id,
role_name,
company_id: text.company_id,
dataViewStartDate,
companyName: (role_name === 'Super Admin' ? text.join_third_company_name : JSON.parse(configApp).company_name),
ganttName : res.name_version
}
}}>
@ -1836,15 +1727,6 @@ const CreatedProyek = ({ params, ...props }) => {
</>
),
},
...(role_name === 'Super Admin' ? [
{
title: t('company'),
dataIndex: "join_third_company_name",
key: "join_third_company_name",
render: (text, record) => (
<span>{record.join_third_company_name}</span>
)
}] : []),
{ title: "Project Name", dataIndex: "nama", key: "nama", width: 200 },
{
title: "Pendapatan Pertahun", dataIndex: "income_year",
@ -1974,9 +1856,7 @@ const CreatedProyek = ({ params, ...props }) => {
dataDivisions={dataDivisions}
dataPM={dataPm}
projectImage={image}
company_id={company_id}
role_name={role_name}
companyList={companyList}
token={token}
/>
),
@ -2039,7 +1919,6 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogAsignHr}
idTask={idTask}
proyekName={proyekName}
company_id={companyId}
token={token}
/>
),
@ -2056,7 +1935,6 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogAsignCust}
idTask={idTask}
proyekName={proyekName}
company_id={companyId}
token={token}
/>
),
@ -2093,10 +1971,8 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogDoc}
idTask={idTask}
proyekName={proyekName}
companyId={companyId}
token={token}
role_name={role_name}
companyName={companyName}
/>
),
[openDialogDoc]
@ -2148,9 +2024,7 @@ const CreatedProyek = ({ params, ...props }) => {
user_id={user_id}
token={token}
isLogin={isLogin}
companyName={companyName}
proyekName={proyekName}
companyId={companyId}
role_name={role_name}
dataViewStartDate={dataViewStartDate}
/>
@ -2169,9 +2043,7 @@ const CreatedProyek = ({ params, ...props }) => {
user_id={user_id}
token={token}
isLogin={isLogin}
companyName={companyName}
proyekName={proyekName}
companyId={companyId}
dataViewStartDate={dataViewStartDate}
/>
),

5
src/views/SimproV2/DemoRequest/index.js

@ -11,13 +11,12 @@ import { useTranslation } from 'react-i18next';
const ProjectType = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -46,8 +45,6 @@ const ProjectType = ({ params, ...props }) => {
const [search, setSearch] = useState("")
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataDemo, setDataDemo] = useState([])
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation()
const column = [
{ name: t('name') },

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

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

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

@ -4,28 +4,23 @@ 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_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH } from '../../../const/ApiConst';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip, Table, Spin } from 'antd';
import { useTranslation } from 'react-i18next';
import { useLocation } from "react-router-dom";
import {
formatNumber,
formatRupiah,
formatThousand,
renderFormatRupiah,
checkActMenup,
} from "../../../const/CustomFunc";
const ProjectType = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -55,11 +50,9 @@ const ProjectType = ({ params, ...props }) => {
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataDivisions, setDataDivisions] = useState([])
const [listCompany, setListCompany] = useState([])
const [loading, setLoading] = useState(true)
const { t } = useTranslation()
const column = [
role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('nameDivision') },
{ name: t('description') },
{ name: t('color') },
@ -74,20 +67,6 @@ const ProjectType = ({ params, ...props }) => {
exportExcel()
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getListDivision = async () => {
const payload = {
@ -115,18 +94,6 @@ const ProjectType = ({ params, ...props }) => {
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const listDivions = await axios
.post(DIVISI_SEARCH, payload, HEADER)
@ -175,18 +142,6 @@ const ProjectType = ({ params, ...props }) => {
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(DIVISI_SEARCH, payload, HEADER)
@ -235,21 +190,7 @@ const ProjectType = ({ params, ...props }) => {
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(DIVISI_SEARCH, payload, HEADER)
.then(res => res)
@ -259,9 +200,6 @@ const ProjectType = ({ params, ...props }) => {
const excelData = [];
resData.map((val, index) => {
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name;
}
dataRow["Nama Divisi"] = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow)
@ -429,15 +367,6 @@ const ProjectType = ({ params, ...props }) => {
</>
,
},
...(role_name === 'Super Admin' ? [
{
title: t('company'),
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => (
<span>{record.join_first_company_name}</span>
)
}] : []),
{ title: 'Nama', dataIndex: 'name', key: 'name' },
{ title: 'Deskripsi', dataIndex: 'description', key: 'description' },
{
@ -515,8 +444,6 @@ const ProjectType = ({ params, ...props }) => {
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
dataDivisions={dataDivisions}
company_id={company_id}
listCompany={listCompany}
role_name={role_name}
/>
<Card>

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

@ -2,11 +2,11 @@ import React, { useEffect, useState } from 'react';
import { useHistory, withRouter } from 'react-router-dom';
import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
const GanttFrame = React.memo(({ versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, companyId, role_name, company_name, ganttName }) => {
const GanttFrame = React.memo(({ versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, role_name, ganttName }) => {
const history = useHistory();
const iframeSrc = `https://si-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}&company_name=${company_name}&gantt_name=${ganttName}`;
// const iframeSrc = `http://localhost:8444/surveyor_indonesia_gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}&company_name=${company_name}&gantt_name=${ganttName}`;
// const iframeSrc = `https://si-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&gantt_name=${ganttName}`;
const iframeSrc = `http://localhost:8444/surveyor_indonesia_gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&gantt_name=${ganttName}`;
const [batchEntityData, setBatchEntityData] = useState(null);
useEffect(() => {

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

@ -10,7 +10,7 @@ let roCount = 0;
const Gantt = (props) => {
const location = useLocation();
const { company_id, dataViewStartDate, companyName, role_name } = location.state || {};
const { dataViewStartDate, role_name } = location.state || {};
let role_id = '', userId = '', isLogin = '', token = '', ganttName = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
@ -113,10 +113,8 @@ const Gantt = (props) => {
token={token}
ro={ro}
role_name={role_name}
companyId={company_id}
timestamp={timestamp}
dataViewStartDate={dataViewStartDate}
company_name={companyName}
ganttName={ganttName}
/>
)}

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

@ -35,7 +35,6 @@ class index extends Component {
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,
@ -53,7 +52,6 @@ class index extends Component {
};
this.columns = [
{ title: this.props.t('Company'), dataIndex: 'company_name', key: 'company_name', className: "nowrap" },
{
title: this.props.t('Expired Date'), dataIndex: 'exp_ospro', key: 'exp_ospro',
render: (text,record) => {
@ -116,8 +114,7 @@ class index extends Component {
const formData = {
name: data.name,
description: data.description,
company_id: data.company_id
description: data.descriptio
}
const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config)
@ -137,8 +134,7 @@ class index extends Component {
const formData = {
name: data.name,
description: data.description,
company_id : data.company_id
description: data.description
}
const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.state.config)
@ -218,21 +214,7 @@ class index extends Component {
"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)
@ -242,9 +224,6 @@ class index extends Component {
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);

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

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

712
src/views/SimproV2/PlanningHarian/index.js

@ -1,357 +1,355 @@
import React, { useState, useEffect, useMemo } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import axios from "../../../const/interceptorApi"
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip } from 'antd';
import {
BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE,
USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE,
USERROLE_SEARCH, ROLE_SEARCH
} from '../../../const/ApiConst';
import moment from 'moment'
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const PlanningHarian = ({ params }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataEdit, setDataEdit] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [totalPage, setTotalPage] = useState(0)
const [roleList, setRoleList] = useState([])
useEffect(() => {
getDataUser()
getRoleList()
}, [])
const getRoleList = async () => {
const formData = {
"paging": { "start": 0, "length": -1 },
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(ROLE_SEARCH, formData, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setRoleList(result.data.data);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const getDataUser = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
"paging": {
"start": start,
"length": rowsPerPage
},
"columns": [
{
"name": "name",
"logic_operator": "ilike",
"value": search,
"operator": "AND"
}
],
"joins": [
{
"name": "m_roles",
"column_join": "role_id",
"column_results": [
"name",
"description"
]
}
],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
const result = await axios
.post(USER_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const handleSearch = e => {
const value = e.target.value
setSearch(value);
setCurrentPage(1)
};
const handleOpenDialog = (type) => {
setOpenDialog(true)
setTypeDialog(type)
}
const handleExportExcel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (parseInt(role_id) !== 1) {
payload["columns"] = [
{ "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" }
]
}
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"Nama Proyek": n.nama,
"Biaya": n.biaya,
"Color Progress": n.color_progress,
"Jumlah Pekerja": n.jumlah_pekerja,
"Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-",
"Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-",
}
excelData.push(dataRow)
})
await setDataExport(excelData);
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
const handleEdit = (data) => {
setDataEdit(data)
handleOpenDialog('Edit');
}
const handleDelete = async (id) => {
await setAlertDelete(true)
await setIdDelete(id)
}
const handleCloseDialog = (type, data) => {
if (type === "save") {
saveUser(data);
} else if (type === "edit") {
editUser(data);
}
setDataEdit([])
setOpenDialog(false)
}
const saveUser = async (data) => {
const formData = data
const result = await axios.post(USER_ADD, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataUser();
NotificationManager.success(`Data resource berhasil ditambah`, 'Success!!');
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
const editUser = async (data) => {
let urlEdit = USER_EDIT(data.id)
const formData = data
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataUser();
NotificationManager.success(`Data resource berhasil diedit`, 'Success!!');
} else {
NotificationManager.error(`Data resource gagal di edit`, `Failed!!`);
}
}
const toggleAddDialog = () => {
setOpenDialog(!openDialog)
}
const onConfirmDelete = async () => {
let url = USER_DELETE(idDelete);
const result = await axios.delete(url, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataUser()
setIdDelete(0)
setAlertDelete(false)
NotificationManager.success(`Data user berhasil dihapus!`, 'Success!!');
} else {
setIdDelete(0)
setAlertDelete(false)
NotificationManager.error(`Data user gagal dihapus!}`, 'Failed!!');
}
}
const cancelDelete = () => {
setAlertDelete(false)
setIdDelete(0)
}
const RenderTable = useMemo(() => {
const columns = [
{ title: 'Subproject Name', dataIndex: 'name', key: 'name' },
{ title: 'Activity', dataIndex: 'name', key: 'name' },
{ title: 'Target', dataIndex: 'name', key: 'name' },
{ title: 'Unit', dataIndex: 'name', key: 'name' },
{ title: 'Resource Name', dataIndex: 'name', key: 'name' },
{
title: 'Planning Start Date',
dataIndex: 'name',
key: 'name',
render: (text, record) => <>{text}</>,
},
{
title: 'Planning End Date',
dataIndex: 'name',
key: 'name',
render: (text, record) => <>{text}</>,
},
{ title: 'Address', dataIndex: 'name', key: 'name' },
{
title: 'Action',
dataIndex: '',
key: 'x',
render: (text, record) => <>
{/* <Tooltip title="Tambah Sub">
<Button size="small" type="link" style={{color:'green'}} onClick={() => handleOpenDialogSub('Save', text)}><i className="fa fa-plus"></i></Button>
</Tooltip> */}
<Tooltip title="Edit">
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
</Tooltip>
<Tooltip title="Hapus">
<Button size="small" type="link" style={{ color: 'red' }} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>
</>,
},
];
return (
<Table
size="small"
columns={columns}
dataSource={dataTable}
/>
)
}, [dataTable])
return (
<div>
<NotificationContainer />
<SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
</SweetAlert>
<DialogForm
openDialog={openDialog}
closeDialog={handleCloseDialog}
toggleDialog={() => toggleAddDialog}
typeDialog={typeDialog}
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
roleList={roleList}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search...`} />
</Col>
<Col>
<Tooltip title="Add Resource">
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
</CardHeader>
<CardBody>
{RenderTable}
</CardBody>
</Card>
</div>
)
}
export default PlanningHarian;
import React, { useState, useEffect, useMemo } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import axios from "../../../const/interceptorApi"
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip } from 'antd';
import {
PROYEK_SEARCH,USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE,ROLE_SEARCH
} from '../../../const/ApiConst';
import moment from 'moment'
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const PlanningHarian = ({ params }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataEdit, setDataEdit] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [totalPage, setTotalPage] = useState(0)
const [roleList, setRoleList] = useState([])
useEffect(() => {
getDataUser()
getRoleList()
}, [])
const getRoleList = async () => {
const formData = {
"paging": { "start": 0, "length": -1 },
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(ROLE_SEARCH, formData, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setRoleList(result.data.data);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const getDataUser = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
"paging": {
"start": start,
"length": rowsPerPage
},
"columns": [
{
"name": "name",
"logic_operator": "ilike",
"value": search,
"operator": "AND"
}
],
"joins": [
{
"name": "m_roles",
"column_join": "role_id",
"column_results": [
"name",
"description"
]
}
],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
const result = await axios
.post(USER_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const handleSearch = e => {
const value = e.target.value
setSearch(value);
setCurrentPage(1)
};
const handleOpenDialog = (type) => {
setOpenDialog(true)
setTypeDialog(type)
}
const handleExportExcel = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (parseInt(role_id) !== 1) {
payload["columns"] = [
{ "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" }
]
}
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"Nama Proyek": n.nama,
"Biaya": n.biaya,
"Color Progress": n.color_progress,
"Jumlah Pekerja": n.jumlah_pekerja,
"Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-",
"Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-",
}
excelData.push(dataRow)
})
await setDataExport(excelData);
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
const handleEdit = (data) => {
setDataEdit(data)
handleOpenDialog('Edit');
}
const handleDelete = async (id) => {
await setAlertDelete(true)
await setIdDelete(id)
}
const handleCloseDialog = (type, data) => {
if (type === "save") {
saveUser(data);
} else if (type === "edit") {
editUser(data);
}
setDataEdit([])
setOpenDialog(false)
}
const saveUser = async (data) => {
const formData = data
const result = await axios.post(USER_ADD, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataUser();
NotificationManager.success(`Data resource berhasil ditambah`, 'Success!!');
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
const editUser = async (data) => {
let urlEdit = USER_EDIT(data.id)
const formData = data
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataUser();
NotificationManager.success(`Data resource berhasil diedit`, 'Success!!');
} else {
NotificationManager.error(`Data resource gagal di edit`, `Failed!!`);
}
}
const toggleAddDialog = () => {
setOpenDialog(!openDialog)
}
const onConfirmDelete = async () => {
let url = USER_DELETE(idDelete);
const result = await axios.delete(url, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataUser()
setIdDelete(0)
setAlertDelete(false)
NotificationManager.success(`Data user berhasil dihapus!`, 'Success!!');
} else {
setIdDelete(0)
setAlertDelete(false)
NotificationManager.error(`Data user gagal dihapus!}`, 'Failed!!');
}
}
const cancelDelete = () => {
setAlertDelete(false)
setIdDelete(0)
}
const RenderTable = useMemo(() => {
const columns = [
{ title: 'Subproject Name', dataIndex: 'name', key: 'name' },
{ title: 'Activity', dataIndex: 'name', key: 'name' },
{ title: 'Target', dataIndex: 'name', key: 'name' },
{ title: 'Unit', dataIndex: 'name', key: 'name' },
{ title: 'Resource Name', dataIndex: 'name', key: 'name' },
{
title: 'Planning Start Date',
dataIndex: 'name',
key: 'name',
render: (text, record) => <>{text}</>,
},
{
title: 'Planning End Date',
dataIndex: 'name',
key: 'name',
render: (text, record) => <>{text}</>,
},
{ title: 'Address', dataIndex: 'name', key: 'name' },
{
title: 'Action',
dataIndex: '',
key: 'x',
render: (text, record) => <>
{/* <Tooltip title="Tambah Sub">
<Button size="small" type="link" style={{color:'green'}} onClick={() => handleOpenDialogSub('Save', text)}><i className="fa fa-plus"></i></Button>
</Tooltip> */}
<Tooltip title="Edit">
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
</Tooltip>
<Tooltip title="Hapus">
<Button size="small" type="link" style={{ color: 'red' }} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>
</>,
},
];
return (
<Table
size="small"
columns={columns}
dataSource={dataTable}
/>
)
}, [dataTable])
return (
<div>
<NotificationContainer />
<SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
</SweetAlert>
<DialogForm
openDialog={openDialog}
closeDialog={handleCloseDialog}
toggleDialog={() => toggleAddDialog}
typeDialog={typeDialog}
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
roleList={roleList}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search...`} />
</Col>
<Col>
<Tooltip title="Add Resource">
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
</CardHeader>
<CardBody>
{RenderTable}
</CardBody>
</Card>
</div>
)
}
export default PlanningHarian;

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

@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next';
const { RangePicker } = DatePicker;
const Index = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp = {};
let role_id = 0, user_id = 0, isLogin = false, token = '', 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;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -93,17 +92,6 @@ const Index = ({ params, ...props }) => {
"orders": { "columns": ["id"], "ascending": false }
}
if (role_name === 'Super Admin') {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.columns.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PRESENCE_SEARCH, payload, config)
.then(res => res)
@ -255,18 +243,6 @@ const Index = ({ params, ...props }) => {
</Tooltip>
</>,
},
...(role_name === 'Super Admin'
? [
{
title: t('company'),
dataIndex: "join_second_company_name",
key: "join_second_company_name",
render: (text, record) => (
<span>{record.join_second_company_name}</span>
)
},
]
: []),
{ title: t('nik'), dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' },
{ title: t('nameHR'), dataIndex: 'join_first_name', key: 'join_first_name' },
{ title: t('presenceIn'), dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) },

8
src/views/SimproV2/Profile/index.js

@ -1,11 +1,9 @@
import * as XLSX from 'xlsx';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import React, { useState, useEffect } from 'react';
import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table, Button } from 'reactstrap';
import { Card, Col, Row, Button } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip } from 'antd';
import { USER_EDIT, SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst';
import { USER_EDIT } from '../../../const/ApiConst';
import profile from '../../../assets/img/profile.png'
import DialogForm from './DialogForm'
import { ROLE_SEARCH, USER_GET_ID } from '../../../const/ApiConst'

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

@ -9,13 +9,12 @@ import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, role_name }) => {
const [id, setId] = useState(0)
const [projectType, setProjectType] = useState('')
const [uom, setUom] = useState('')
const [description, setDescription] = useState('')
const [unitPrice, setUnitPrice] = useState()
const [selectedCompany, setSelectedCompany] = useState(null)
const [isMultiLocation, setIsMultiLocation] = useState(false);
const { t } = useTranslation();
@ -30,7 +29,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setProjectType(dataEdit.name)
setSelectedCompany(dataEdit.company_id)
setIsMultiLocation(dataEdit.is_multiLocation)
} else {
handleClear()
@ -39,14 +37,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const handleSave = () => {
let data = '';
if (role_name === 'Super Admin') {
company_id = selectedCompany
}
if (typeDialog === "Save") {
data = {
name: projectType,
description,
company_id: parseInt(company_id),
is_multiLocation: isMultiLocation
}
@ -56,7 +50,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
id,
name: projectType,
description,
company_id: parseInt(company_id),
is_multiLocation: isMultiLocation
}
closeDialog('edit', data);
@ -68,7 +61,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setId(0)
setProjectType('')
setDescription('')
setSelectedCompany(null)
setIsMultiLocation(false)
}
@ -78,10 +70,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
handleClear();
}
const onChangeCompany = (val) => {
setSelectedCompany(val);
};
const renderForm = () => {
return (
<Form>
@ -108,33 +96,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</div>
</FormGroup>
</Col>
{
role_name === 'Super Admin' && (
<Col md={6}>
<FormGroup>
<Label className="capitalize">
{t('company')}<span style={{ color: "red" }}>*</span>
</Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={selectedCompany}
defaultValue={selectedCompany}
onChange={onChangeCompany}
style={{ width: "100%" }}
>
{listCompany.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
</Row>
</Form>
)

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

@ -8,7 +8,7 @@ import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
import { checkActMenup } from '../../../const/CustomFunc.js';
@ -16,13 +16,12 @@ import { useLocation } from "react-router-dom";
const ProjectType = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -53,7 +52,6 @@ const ProjectType = ({ params, ...props }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation();
useEffect(() => {
getDataProjectType()
@ -66,29 +64,11 @@ const ProjectType = ({ params, ...props }) => {
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataProjectType = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
group_column: {
"operator": "AND",
@ -114,21 +94,7 @@ const ProjectType = ({ params, ...props }) => {
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER)
.then(res => res)
@ -185,21 +151,6 @@ const ProjectType = ({ params, ...props }) => {
},
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER)
@ -211,9 +162,6 @@ const ProjectType = ({ params, ...props }) => {
const excelData = [];
resData.map((val, index) => {
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name;
}
dataRow.Nama = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow)
@ -376,16 +324,6 @@ const ProjectType = ({ params, ...props }) => {
</Tooltip>
</>,
},
...(role_name === 'Super Admin' ? [
{
title: t('company'),
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => (
<span>{record.join_first_company_name}</span>
)
}] : []),
{ title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: t('description'), dataIndex: 'description', key: 'description' },
];
@ -424,8 +362,6 @@ const ProjectType = ({ params, ...props }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
listCompany={listCompany}
company_id={company_id}
role_name={role_name}
/>
<DialogInitialGantt

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

@ -10,22 +10,14 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { Pagination, Table, Button, Tooltip, Tabs, Collapse } from 'antd';
import { formatRupiah, formatNumber, renderLabelStatus } from '../../../const/CustomFunc'
import {
BASE_SIMPRO,
PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE,
MATERIAL_RESOURCE_ADD, MATERIAL_RESOURCE_EDIT, MATERIAL_RESOURCE_DELETE, MATERIAL_RESOURCE_SEARCH,
REQUEST_MATERIAL_SEARCH, REQUEST_MATERIAL_EDIT,
REQUEST_MATERIAL_UPDATE_WAREHOUSE_SITE, SATUAN_SEARCH
REQUEST_MATERIAL_SEARCH, REQUEST_MATERIAL_EDIT, SATUAN_SEARCH
} from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
const { TabPane } = Tabs;
const { Panel } = Collapse;
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY";
const groupBy = (array, key) => {
return array.reduce((result, currentValue) => {
(result[currentValue[key]] = result[currentValue[key]] || []).push(

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

@ -10,7 +10,7 @@ import { formatNumber } from '../../../const/CustomFunc'
import { useTranslation } from 'react-i18next';
const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name }) => {
const [id, setId] = useState(0)
const [resourceName, setResourceName] = useState('')
const [username, setUsername] = useState('')
@ -26,7 +26,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [ktpNumber, setKtpNumber] = useState('')
const [biayaPerJam, setBiayaPerJam] = useState('')
const [roleId, setRoleId] = useState('')
const [scompany_id, setCompanyId] = useState(null);
const [address, setAddress] = useState('')
const [divisionId, setDivisionId] = useState('')
const [statusResource, setStatusResource] = useState('active')
@ -45,7 +44,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setPhoneNo(dataEdit.phone_number)
setEmail(dataEdit.email)
setGender(dataEdit.gender)
setCompanyId(dataEdit.company_id)
setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "")
setBirthPlace(dataEdit.birth_place)
setBloodType(dataEdit.blood_type)
@ -74,7 +72,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setRoleId('')
setDivisionId('')
setAddress('')
setCompanyId(null)
setStatusResource('active')
setStatusRestriction(false)
setStatusCustomer(false)
@ -116,8 +113,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
ktp_number: ktpNumber,
address,
status_resource: statusResource,
status_boundary: statusRestriction,
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
status_boundary: statusRestriction
}
if(statusCustomer === false) {
@ -149,8 +145,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
id,
username,
password,
email,
company_id: parseInt(company_id)
email
}
closeDialog('edit', data);
@ -170,8 +165,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
biaya_per_jam: biayaPerJam.replace('.', ''),
address,
status_resource: statusResource,
status_boundary: statusRestriction,
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
status_boundary: statusRestriction
}
if(statusCustomer === false) {
data.role_id = roleId;
@ -188,10 +182,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
}
}
const onChangeCompanyProject = (val) => {
setCompanyId(val);
};
const handleCancel = () => {
closeDialog('cancel', 'none')
}
@ -318,31 +308,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</Col>
</Row>
<Row>
{
role_name === 'Super Admin' && (
<Col md={6} style={{ marginTop:'15px' }}>
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={scompany_id}
defaultValue={scompany_id}
onChange={onChangeCompanyProject}
style={{ width: "100%" }}
>
{companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
{
statusCustomer === false && (
<>

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

@ -9,7 +9,7 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { useLocation } from "react-router-dom";
import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
import {
USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, COMPANY_MANAGEMENT_LIST
USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD
} from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
import {
@ -17,13 +17,12 @@ import {
} from "../../../const/CustomFunc";
const ResourceWorker = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -45,7 +44,6 @@ const ResourceWorker = ({ params, ...props }) => {
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [divisiList, setDivisiList] = useState([])
const [companyList, setDataCompany] = useState([]);
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogShift, setOpenDialogShift] = useState(false)
@ -62,9 +60,6 @@ const ResourceWorker = ({ params, ...props }) => {
useEffect(() => {
getRoleList()
getDivisiList()
if(role_name === 'Super Admin') {
getDataProyekCompany();
}
}, [])
useEffect(() => {
@ -93,15 +88,7 @@ const ResourceWorker = ({ params, ...props }) => {
"orders": { "columns": ["id"], "ascending": false },
"columns": [],
}
if (role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
)
} else {
formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
}
const result = await axios
.post(ROLE_SEARCH, formData, HEADER)
.then(res => res)
@ -118,12 +105,6 @@ const ResourceWorker = ({ params, ...props }) => {
"columns": [],
}
if (role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
)
}
const result = await axios
.post(DIVISI_SEARCH, formData, HEADER)
.then(res => res)
@ -223,19 +204,6 @@ const ResourceWorker = ({ params, ...props }) => {
}
}
if (role_name !== "Super Admin") {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
)
} else {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
);
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
);
}
const result = await axios
.post(USER_SEARCH, payload, HEADER)
.then(res => res)
@ -251,22 +219,6 @@ const ResourceWorker = ({ params, ...props }) => {
}
}
const getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
setDataCompany(dataRes);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
const handleSearch = e => {
const value = e.target.value
setSearch(value);
@ -372,18 +324,6 @@ const ResourceWorker = ({ params, ...props }) => {
}
}
if (role_name !== "Super Admin") {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
)
} else {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
);
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
);
}
const result = await axios
.post(USER_SEARCH, payload, HEADER)
.then(res => res)
@ -394,9 +334,6 @@ const ResourceWorker = ({ params, ...props }) => {
const excelData = [];
resData.map((n, index) => {
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = n.join_third_company_name;
}
dataRow["NIK (Nomor Induk Karyawan)"] = n.ktp_number;
dataRow["Employee Name"] = n.name;
dataRow["Divisi"] = n.join_second_name;
@ -594,15 +531,6 @@ const ResourceWorker = ({ params, ...props }) => {
</Tooltip>
</>,
},
...(role_name === 'Super Admin' ? [
{
title: t('company'),
dataIndex: "join_third_company_name",
key: "join_third_company_name",
render: (text, record) => (
<span>{record.join_third_company_name}</span>
)
}] : []),
{ title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' },
{ title: t('nameHR'), dataIndex: 'name', key: 'name' },
{ title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' },
@ -654,8 +582,6 @@ const ResourceWorker = ({ params, ...props }) => {
roleList={roleList}
divisiList={divisiList}
role_name={role_name}
companyList={companyList}
company_id={company_id}
/>
<DialogFormUserShift
openDialog={openDialogShift}

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

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

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

@ -6,26 +6,21 @@ import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
import { useLocation } from "react-router-dom";
import {
formatNumber,
formatRupiah,
formatThousand,
renderFormatRupiah,
checkActMenup,
} from "../../../const/CustomFunc";
const Satuan = ({ params, ...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '';
let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = '';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
@ -54,7 +49,6 @@ const Satuan = ({ params, ...props }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [listCompany, setListCompany] = useState([])
const { t } = useTranslation()
useEffect(() => {
getDataSatuan()
@ -67,35 +61,16 @@ const Satuan = ({ params, ...props }) => {
}
}, [dataExport])
useEffect(() => {
getDataCompany()
}, [])
const column = [
role_name === 'Super Admin' ? { name: t('company') } : null,
{ name: t('name') },
{ name: t('description') },
].filter(column => column && column.name);
const getDataCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setListCompany(result.data.data);
}
}
const getDataSatuan = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
group_column: {
"operator": "AND",
@ -122,20 +97,6 @@ const Satuan = ({ params, ...props }) => {
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" },
)
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(SATUAN_SEARCH, payload, HEADER)
.then(res => res)
@ -177,21 +138,7 @@ const Satuan = ({ params, ...props }) => {
"orders": { "columns": ["id"], "ascending": false },
'joins': []
}
if (role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
}
const result = await axios
.post(SATUAN_SEARCH, payload, HEADER)
.then(res => res)
@ -201,9 +148,6 @@ const Satuan = ({ params, ...props }) => {
const excelData = [];
resData.map((val, index) => {
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = val.join_first_company_name;
}
dataRow.Nama = val.name;
dataRow.Deskripsi = val.description;
excelData.push(dataRow)
@ -344,9 +288,7 @@ const Satuan = ({ params, ...props }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
listCompany={listCompany}
role_name={role_name}
company_id={company_id}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -407,11 +349,6 @@ const Satuan = ({ params, ...props }) => {
}
</Tooltip>
</td>
{role_name === 'Super Admin' &&
(
<td>{n.join_first_company_name}</td>
)
}
<td>{n.name}</td>
<td>{n.description}</td>
</tr>

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

@ -14,10 +14,9 @@ import { Modal, ModalBody, ModalFooter, Button } from 'reactstrap';
const Index = () => {
const token = localStorage.getItem("token")
const user_id = localStorage.getItem("user_id")
let company_id = '', configApp = '';
let configApp = '';
const role = window.localStorage.getItem('role_name');
if(role !== 'Super Admin') {
company_id = localStorage.getItem("company_id");
configApp = JSON.parse(window.localStorage.getItem('configApp'));
}
const config = {
@ -132,9 +131,6 @@ const Index = () => {
formData.append('ref_id', id);
formData.append('category', 'profile_picture');
formData.append('files', data);
if(role !== 'Super Admin') {
formData.append('company_name', configApp.company_name);
}
await axios
.post(IMAGE_UPLOAD, formData, HEADER_MULTIPART)
.then(res => res)
@ -143,7 +139,7 @@ const Index = () => {
// Delete Image Function
const deleteImageProfile = async (id) => {
const URL = IMAGE_DELETE(id, 'profile_picture', company_id != '' ? company_id : 'undifined');
const URL = IMAGE_DELETE(id, 'profile_picture');
await axios
.delete(URL, config)
.then(res => res)
@ -254,7 +250,7 @@ const Index = () => {
<div className={stylesHead.img} style={{ cursor:imageProfile ? 'pointer' : '' }} onClick={imageProfile ? () => handleImageClick() : ''}>
<img className={stylesHead.obejct11} src={
imageProfile ? (
`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image, role != 'Super Admin' ? configApp?.company_name : 'undifined', moment(imageProfile?.created_at).format('YYYY-MM'))}`
`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image)}`
) : profile
} />
</div>
@ -416,7 +412,7 @@ const Index = () => {
<img
src={
imageProfile ? (
`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image, role != 'Super Admin' ? configApp?.company_name : 'undifined', moment(imageProfile?.created_at).format('YYYY-MM'))}`
`${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(imageProfile?.image,)}`
) : profile
}
style={{ maxWidth: "100%" }}

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

@ -12,14 +12,13 @@ const Container1 = () => {
const [totalPage, setTotalPage] = useState(0);
const [transaction, setTransaction] = useState([]);
const [storage, setLimitInformation] = useState(0)
const currentDate = new Date(); // Now date
const givenDate = new Date(transaction.exp_ospro); // Parse exp ospro to date format
const differenceInMillis = givenDate.getTime() - currentDate.getTime(); // Get time difference
const currentDate = new Date();
const givenDate = new Date(transaction.exp_ospro);
const differenceInMillis = givenDate.getTime() - currentDate.getTime();
const differenceInDays = role !== 'Super Admin' ? Math.ceil(differenceInMillis / (1000 * 60 * 60 * 24)) : 30;
let company_id = '', configApp = '';
let configApp = '';
if(role !== 'Super Admin') {
company_id = localStorage.getItem("company_id");
configApp = JSON.parse(window.localStorage.getItem('configApp'));
}
const config = {
@ -39,14 +38,10 @@ const Container1 = () => {
const getDataProyek = async () => {
const payload = {
"columns": [
{"name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND"}
],
"select": [
"nama",
"mulai_proyek",
"akhir_proyek",
"company_id"
"akhir_proyek"
],
};
const result = await axios
@ -63,11 +58,7 @@ const Container1 = () => {
const getDataTransaction = async () => {
const formData = {
"paging": {"start": 0, "length": 1},
"columns": [
{"name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND"}
],
"select": [
"company_id",
"type_paket",
"amount",
"exp_ospro",
@ -88,7 +79,7 @@ const Container1 = () => {
}
const getLimitInformation = async () => {
const url = STORAGE_LIMIT_INFORMATION(role !== 'Super Admin' ? configApp.company_name : 'Super Admin');
const url = STORAGE_LIMIT_INFORMATION;
const result = await axios
.get(url, config)
.then((res) => res)

486
src/views/testgantt/index.js

@ -1,243 +1,243 @@
import React, { useEffect, useMemo, useState } from 'react';
import Timeline from 'react-calendar-timeline'
import 'react-calendar-timeline/lib/Timeline.css'
import moment from 'moment';
import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH_DETAIL, PROYEK_EDIT, PROYEK_DELETE } from '../../const/ApiConst';
import axios from 'axios';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Button } from 'antd';
import {
Container, Col, Row, UncontrolledTooltip,
Card,
CardBody,
CardHeader,
Table,
Modal, ModalHeader, ModalBody, ModalFooter
} from 'reactstrap';
import GanttFull from './GanttDhtmlx2';
import DialogForm from '../Master/Proyek/DialogForm';
import DialogFormSub from '../Master/Proyek/DialogFormSub';
import Iframe from "@nicholasadamou/react-iframe";
const GanttTimeLine = () => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [dataGantt, setDataGantt] = useState([]);
const [prevProyekId, setPrevProyekId] = useState(0);
const [dataGroupGantt, setDataGroupGantt] = useState([]);
const [maxDateGantt, setMaxDateGantt] = useState(null);
const [minDateGantt, setMinDateGantt] = useState(null);
const [dataAllTimeLine, setDataAllTimeLine] = useState([]);
const [prevDataAllTimeLine, setPrevDataAllTimeLine] = useState(null);
const [idTask, setidTask] = useState(0);
const [dataTable, setDatatable] = useState([])
const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1)
const [totalPage, setTotalPage] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogSub, setOpenDialogSub] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save');
const [typeDialogSub, setTypeDialogSub] = useState('Save')
const [idDelete, setIdDelete] = useState(0)
const [alertDelete, setAlertDelete] = useState(false)
const [dataEdit, setDataEdit] = useState([])
const [dataEditSub, setDataEditSub] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [clickOpenModal, setClickOpenModal] = useState(false)
const [dataExport, setDataExport] = useState([])
const [allDataMenu, setAllDataMenu] = useState([])
const [idSubtask, setIdSubtask] = useState(0);
const handleMappingDataGantt = (data) => {
const minDates = data.map(res => moment(res.mulai_proyek)),
minDate = moment.min(minDates)
const maxDates = data.map(res => moment(res.akhir_proyek)),
maxDate = moment.max(maxDates)
let groups = []
let items = []
data.map((res, idx) => {
let group = {
id: res.id,
title: res.nama,
stackItems: true,
height: 50
}
let item = {
id: res.id,
group: res.id,
title: res.pic,
start_time: moment(res.mulai_proyek),
end_time: moment(res.akhir_proyek),
}
groups.push(group)
items.push(item)
})
setDataGantt(items)
setDataGroupGantt(groups)
setMaxDateGantt(maxDate)
setMinDateGantt(minDate)
}
const handleGetDataProyek = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"joins": [
{ "name": "subproyeks.m_proyek", "column_join": "proyek_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual", "lat", "lon", "buffer_radius", "geom"] },
{ "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual", "lat", "lon", "buffer_radius", "geom"] }
],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(PROYEK_SEARCH_DETAIL, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
const { data } = result.data
setDataAllTimeLine(data)
setPrevDataAllTimeLine(data)
handleMappingDataGantt(data)
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
useEffect(() => {
handleGetDataProyek()
}, []);
const handleClickGroupGantt = param => {
const row = prevDataAllTimeLine.filter(res => res.id === param)
if (row.length > 0) {
const { subproyeks, proyek_id, parent_id } = row[0]
setPrevProyekId(parent_id || proyek_id)
handleMappingDataGantt(subproyeks)
setDataAllTimeLine(subproyeks)
}
}
const handleOpenDialog = (type) => {
setOpenDialog(true)
setTypeDialog(type)
}
const handleOpenDialogSub = (type, param) => {
const { id, parent_id, proyek_id, parent } = param
const idParent = parent == 0 ? 0 : parent == proyek_id ? id : parent_id
setidTask(proyek_id)
setIdSubtask(idParent)
setOpenDialogSub(true)
setTypeDialogSub(type)
}
const handleCloseDialog = (type, data) => {
if (type === "save") {
saveProyek(data);
}
setDataEdit([])
setOpenDialog(false)
}
const handleCloseDialogSub = (type, data) => {
setDataEditSub([])
setOpenDialogSub(false)
if (type !== "cancel") {
handleGetDataProyek()
}
}
const toggleAddDialog = () => {
setOpenDialog(!openDialog)
}
const toggleAddDialogSub = () => {
setOpenDialogSub(!openDialogSub)
}
const saveProyek = async (data) => {
const formData = data
const result = await axios.post(PROYEK_ADD, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
handleGetDataProyek()
NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!');
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
const RenderGantt = useMemo(() => (
<GanttFull
handleOpenDialogSub={handleOpenDialogSub}
data={dataAllTimeLine}
startDate={minDateGantt ? minDateGantt.format("YYYY-MM-DD HH:mm:ss") : moment().add(-40, 'days').format("YYYY-MM-DD HH:mm:ss")}
endDate={maxDateGantt ? maxDateGantt.format("YYYY-MM-DD HH:mm:ss") : moment().add(40, 'days').format("YYYY-MM-DD HH:mm:ss")}
/>
), [dataAllTimeLine, maxDateGantt, minDateGantt])
return (
<div>
<NotificationContainer />
{/* time line gantt */}
<DialogForm
openDialog={openDialog}
closeDialog={handleCloseDialog}
toggleDialog={() => toggleAddDialog}
typeDialog={typeDialog}
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
/>
<DialogFormSub
openDialog={openDialogSub}
closeDialog={handleCloseDialogSub}
toggleDialog={() => toggleAddDialogSub}
typeDialog={typeDialogSub}
dataEdit={dataEditSub}
idTask={idTask}
idSubtask={idSubtask}
/>
{/* <Row>
<Col md={6} />
<Col md={6}>
<Button style={{ float: 'right' }} onClick={() => handleOpenDialog('Save')} type="primary">Add Proyek</Button>
</Col>
</Row> */}
{/* {RenderGantt} */}
<Iframe
src="http://siopas.co.id/simpro-gantt/gantt.html"
headers={{
}}
style={{
width: '100%',
height: '75vh',
}}
scrolling="no"
frameBorder="0"
/>
</div>
);
}
export default GanttTimeLine;
import React, { useEffect, useMemo, useState } from 'react';
import Timeline from 'react-calendar-timeline'
import 'react-calendar-timeline/lib/Timeline.css'
import moment from 'moment';
import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH_DETAIL } from '../../const/ApiConst';
import axios from 'axios';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Button } from 'antd';
import {
Container, Col, Row, UncontrolledTooltip,
Card,
CardBody,
CardHeader,
Table,
Modal, ModalHeader, ModalBody, ModalFooter
} from 'reactstrap';
import GanttFull from './GanttDhtmlx2';
import DialogForm from '../Master/Proyek/DialogForm';
import DialogFormSub from '../Master/Proyek/DialogFormSub';
import Iframe from "@nicholasadamou/react-iframe";
const GanttTimeLine = () => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [dataGantt, setDataGantt] = useState([]);
const [prevProyekId, setPrevProyekId] = useState(0);
const [dataGroupGantt, setDataGroupGantt] = useState([]);
const [maxDateGantt, setMaxDateGantt] = useState(null);
const [minDateGantt, setMinDateGantt] = useState(null);
const [dataAllTimeLine, setDataAllTimeLine] = useState([]);
const [prevDataAllTimeLine, setPrevDataAllTimeLine] = useState(null);
const [idTask, setidTask] = useState(0);
const [dataTable, setDatatable] = useState([])
const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1)
const [totalPage, setTotalPage] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogSub, setOpenDialogSub] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save');
const [typeDialogSub, setTypeDialogSub] = useState('Save')
const [idDelete, setIdDelete] = useState(0)
const [alertDelete, setAlertDelete] = useState(false)
const [dataEdit, setDataEdit] = useState([])
const [dataEditSub, setDataEditSub] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [clickOpenModal, setClickOpenModal] = useState(false)
const [dataExport, setDataExport] = useState([])
const [allDataMenu, setAllDataMenu] = useState([])
const [idSubtask, setIdSubtask] = useState(0);
const handleMappingDataGantt = (data) => {
const minDates = data.map(res => moment(res.mulai_proyek)),
minDate = moment.min(minDates)
const maxDates = data.map(res => moment(res.akhir_proyek)),
maxDate = moment.max(maxDates)
let groups = []
let items = []
data.map((res, idx) => {
let group = {
id: res.id,
title: res.nama,
stackItems: true,
height: 50
}
let item = {
id: res.id,
group: res.id,
title: res.pic,
start_time: moment(res.mulai_proyek),
end_time: moment(res.akhir_proyek),
}
groups.push(group)
items.push(item)
})
setDataGantt(items)
setDataGroupGantt(groups)
setMaxDateGantt(maxDate)
setMinDateGantt(minDate)
}
const handleGetDataProyek = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"joins": [
{ "name": "subproyeks.m_proyek", "column_join": "proyek_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual", "lat", "lon", "buffer_radius", "geom"] },
{ "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual", "lat", "lon", "buffer_radius", "geom"] }
],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(PROYEK_SEARCH_DETAIL, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
const { data } = result.data
setDataAllTimeLine(data)
setPrevDataAllTimeLine(data)
handleMappingDataGantt(data)
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
useEffect(() => {
handleGetDataProyek()
}, []);
const handleClickGroupGantt = param => {
const row = prevDataAllTimeLine.filter(res => res.id === param)
if (row.length > 0) {
const { subproyeks, proyek_id, parent_id } = row[0]
setPrevProyekId(parent_id || proyek_id)
handleMappingDataGantt(subproyeks)
setDataAllTimeLine(subproyeks)
}
}
const handleOpenDialog = (type) => {
setOpenDialog(true)
setTypeDialog(type)
}
const handleOpenDialogSub = (type, param) => {
const { id, parent_id, proyek_id, parent } = param
const idParent = parent == 0 ? 0 : parent == proyek_id ? id : parent_id
setidTask(proyek_id)
setIdSubtask(idParent)
setOpenDialogSub(true)
setTypeDialogSub(type)
}
const handleCloseDialog = (type, data) => {
if (type === "save") {
saveProyek(data);
}
setDataEdit([])
setOpenDialog(false)
}
const handleCloseDialogSub = (type, data) => {
setDataEditSub([])
setOpenDialogSub(false)
if (type !== "cancel") {
handleGetDataProyek()
}
}
const toggleAddDialog = () => {
setOpenDialog(!openDialog)
}
const toggleAddDialogSub = () => {
setOpenDialogSub(!openDialogSub)
}
const saveProyek = async (data) => {
const formData = data
const result = await axios.post(PROYEK_ADD, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
handleGetDataProyek()
NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!');
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
const RenderGantt = useMemo(() => (
<GanttFull
handleOpenDialogSub={handleOpenDialogSub}
data={dataAllTimeLine}
startDate={minDateGantt ? minDateGantt.format("YYYY-MM-DD HH:mm:ss") : moment().add(-40, 'days').format("YYYY-MM-DD HH:mm:ss")}
endDate={maxDateGantt ? maxDateGantt.format("YYYY-MM-DD HH:mm:ss") : moment().add(40, 'days').format("YYYY-MM-DD HH:mm:ss")}
/>
), [dataAllTimeLine, maxDateGantt, minDateGantt])
return (
<div>
<NotificationContainer />
{/* time line gantt */}
<DialogForm
openDialog={openDialog}
closeDialog={handleCloseDialog}
toggleDialog={() => toggleAddDialog}
typeDialog={typeDialog}
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
/>
<DialogFormSub
openDialog={openDialogSub}
closeDialog={handleCloseDialogSub}
toggleDialog={() => toggleAddDialogSub}
typeDialog={typeDialogSub}
dataEdit={dataEditSub}
idTask={idTask}
idSubtask={idSubtask}
/>
{/* <Row>
<Col md={6} />
<Col md={6}>
<Button style={{ float: 'right' }} onClick={() => handleOpenDialog('Save')} type="primary">Add Proyek</Button>
</Col>
</Row> */}
{/* {RenderGantt} */}
<Iframe
src="http://siopas.co.id/simpro-gantt/gantt.html"
headers={{
}}
style={{
width: '100%',
height: '75vh',
}}
scrolling="no"
frameBorder="0"
/>
</div>
);
}
export default GanttTimeLine;

Loading…
Cancel
Save