Commit 7fd05354 authored by d.arizona's avatar d.arizona

update

parent 2cb7103e
...@@ -312,6 +312,9 @@ const create = (type = "") => { ...@@ -312,6 +312,9 @@ const create = (type = "") => {
const uploadMonthlyReportLOCF = (body) => api.post('transaction/locf/monthly_report/import_monthly_report', body) const uploadMonthlyReportLOCF = (body) => api.post('transaction/locf/monthly_report/import_monthly_report', body)
const validateSubmitReportOI = (body) => api.post('transaction/operating_indicator/monthly_report/validate_save', body) const validateSubmitReportOI = (body) => api.post('transaction/operating_indicator/monthly_report/validate_save', body)
const getListUserSubcoMB = (periode) => api.get(`transaction/get_dashboard_sub_co/master_budget/${periode}`)
const getListUserSubcoMR = (months,periode) => api.get(`transaction/get_dashboard_sub_co/monthly_report/${periode}/${months}`)
// MonthlyPL // MonthlyPL
// const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body) // const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body)
// const createMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/create_monthly_report', body) // const createMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/create_monthly_report', body)
...@@ -561,7 +564,9 @@ const create = (type = "") => { ...@@ -561,7 +564,9 @@ const create = (type = "") => {
deleteAllItemReportLOCF, deleteAllItemReportLOCF,
submitMonthlyReport, submitMonthlyReport,
approvalMonthly, approvalMonthly,
createPeriodeRevisionMonthly createPeriodeRevisionMonthly,
getListUserSubcoMB,
getListUserSubcoMR
} }
} }
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, MuiThemeProvider, createMuiTheme, Paper } from '@material-ui/core'; import { Typography, MuiThemeProvider, createMuiTheme, Paper, TextField} from '@material-ui/core';
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import Images from '../assets/Images'; import Images from '../assets/Images';
import DonutChart from 'react-d3-donut'; import DonutChart from 'react-d3-donut';
...@@ -9,6 +9,7 @@ import { Link } from 'react-router-dom'; ...@@ -9,6 +9,7 @@ import { Link } from 'react-router-dom';
import { PropagateLoader } from 'react-spinners'; import { PropagateLoader } from 'react-spinners';
import { titleCase } from '../library/Utils'; import { titleCase } from '../library/Utils';
import { format } from 'date-fns'; import { format } from 'date-fns';
import Autocomplete from '@material-ui/lab/Autocomplete';
var ct = require("../library/CustomTable"); var ct = require("../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -31,6 +32,12 @@ class HomePage extends Component { ...@@ -31,6 +32,12 @@ class HomePage extends Component {
valueSubmit: 0, valueSubmit: 0,
listdmb: [], listdmb: [],
dataTableMB: [], dataTableMB: [],
listPeriodeMB: null,
listPeriodeMR: null,
listMonth: null,
periodeMB: null,
periodeMR: null,
month: null,
loading: false, loading: false,
accessMB: false, accessMB: false,
accessMR: false, accessMR: false,
...@@ -61,9 +68,10 @@ class HomePage extends Component { ...@@ -61,9 +68,10 @@ class HomePage extends Component {
this.getPermissionMB() this.getPermissionMB()
this.getPermissionMR() this.getPermissionMR()
this.getApprMat() this.getApprMat()
this.getListUserSubco() // this.getListUserSubco()
this.getDashboardMB() this.getDashboardMB()
this.getDashboard() this.getDashboard()
this.getMonth()
} }
componentDidUpdate() { componentDidUpdate() {
...@@ -73,12 +81,94 @@ class HomePage extends Component { ...@@ -73,12 +81,94 @@ class HomePage extends Component {
} }
} }
getPeriode() {
let currentYear = new Date().getFullYear()
let MB = []
let MR = []
for(var i=2000;i<=currentYear; i++) {
MB.push({name: String(i), value: i})
MR.push({name: String(i), value: i})
if (i == currentYear) {
MB.push({name: String(i+1), value: i+1})
}
}
let defaultPropsMB = {
options: MB,
getOptionLabel: (option) => option.name,
};
let defaultPropsMR = {
options: MR,
getOptionLabel: (option) => option.name,
};
this.setState({listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[MR.length - 1]}, () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
})
}
getMonth() {
api.create().getMonthTransaction().then(response => {
let dateNow = new Date
let month = format(dateNow, 'MMMM')
// console.log(response);
if (response.data) {
if (response.data.status === "success") {
// console.log(response);
let data = response.data.data
let monthData = data.map((item) => {
return {
month_id: item.id,
month_value: String(item.month_name).substr(0, 3)
}
})
let defaultProps = {
options: monthData,
getOptionLabel: (option) => option.month_value,
};
let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == month)
// console.log(month)
// console.log(index)
this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => {
// if (this.state.isApprover === true) {
// if (this.state.submittedOnly) {
// console.log('masuk cuk')
// this.getPeriode()
// } else {
// this.getLastPeriod()
// }
this.getPeriode()
// } else {
// this.getLastPeriod()
// this.getPeriode()
// }
})
} else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
// if (response.data.message.includes("Someone Logged In")) {
// setTimeout(() => {
// localStorage.removeItem(Constant.TOKEN)
// window.location.reload();
// }, 1000);
// }
// })
}
} else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
})
}
getPermissionMB() { getPermissionMB() {
let payload = { let payload = {
menu: "Master Budget & CAT" menu: "Master Budget & CAT"
} }
api.create().getPermission(payload).then(response => { api.create().getPermission(payload).then(response => {
console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ this.setState({
...@@ -106,7 +196,7 @@ class HomePage extends Component { ...@@ -106,7 +196,7 @@ class HomePage extends Component {
menu: "monthly report" menu: "monthly report"
} }
api.create().getPermission(payload).then(response => { api.create().getPermission(payload).then(response => {
console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ this.setState({
...@@ -128,10 +218,65 @@ class HomePage extends Component { ...@@ -128,10 +218,65 @@ class HomePage extends Component {
} }
}) })
} }
getListUserSubcoMB() {
// console.log(this.state.month.month_id)
// console.log(this.state.periodeMR.value)
api.create().getListUserSubcoMB(this.state.periodeMB.value).then((response) => {
// console.log(response)
let valueSubmit = 0
let dataMB = []
if (response.data) {
if (response.data.status === "success") {
response.data.data.map((item, index) => {
if (item.is_submit === true) {
valueSubmit += 1
}
dataMB.push(item)
})
this.setState({
listSubcoMB: dataMB,
valueSubmit,
loading: false
})
}
} else {
this.setState({loading: false})
}
})
}
getListUserSubcoMR() {
// console.log(this.state.month.month_id)
// console.log(this.state.periodeMR.value)
api.create().getListUserSubcoMR(this.state.month.month_id, this.state.periodeMR.value).then((response) => {
let valueSubmitMR = 0
let dataMR = []
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
response.data.data.map((item, index) => {
if (item.is_submit === true ) {
valueSubmitMR += 1
}
dataMR.push(item)
})
this.setState({
listSubcoMR: dataMR,
valueSubmitMR,
loading: false
})
}
} else {
this.setState({loading: false})
}
})
}
getListUserSubco() { getListUserSubco() {
api.create().getDashboardUser().then(response => { api.create().getDashboardUser().then(response => {
console.log(response); // console.log(response);
let valueSubmit = 0 let valueSubmit = 0
let valueSubmitMR = 0 let valueSubmitMR = 0
let dataMB = [] let dataMB = []
...@@ -160,8 +305,8 @@ class HomePage extends Component { ...@@ -160,8 +305,8 @@ class HomePage extends Component {
}) })
} }
} }
console.log(this.state.listSubcoMB) // console.log(this.state.listSubcoMB)
console.log(this.state.listSubcoMR) // console.log(this.state.listSubcoMR)
}) })
} }
...@@ -169,7 +314,7 @@ class HomePage extends Component { ...@@ -169,7 +314,7 @@ class HomePage extends Component {
let listDashboard = [] let listDashboard = []
let rawData = [] let rawData = []
api.create().getDashboard().then((response) => { api.create().getDashboard().then((response) => {
console.log(response); // console.log(response);
if (String(response.data.status).toLocaleLowerCase() == 'success') { if (String(response.data.status).toLocaleLowerCase() == 'success') {
let data = response.data.data let data = response.data.data
data.map((item, index) => { data.map((item, index) => {
...@@ -199,7 +344,7 @@ class HomePage extends Component { ...@@ -199,7 +344,7 @@ class HomePage extends Component {
let isApproverMR = false let isApproverMR = false
let isApproverMB = false let isApproverMB = false
api.create().getAM().then((response) => { api.create().getAM().then((response) => {
console.log(response); // console.log(response);
let actAMActive = [] let actAMActive = []
let actAM = response.data.data.map((item, index) => { let actAM = response.data.data.map((item, index) => {
if (String(item.status).toLocaleLowerCase() == 'active') { if (String(item.status).toLocaleLowerCase() == 'active') {
...@@ -208,7 +353,7 @@ class HomePage extends Component { ...@@ -208,7 +353,7 @@ class HomePage extends Component {
} }
}) })
let userId = localStorage.getItem(Constant.USER) let userId = localStorage.getItem(Constant.USER)
console.log(userId); // console.log(userId);
let indexId = actAMActive.findIndex((val) => val.user_id == userId) let indexId = actAMActive.findIndex((val) => val.user_id == userId)
actAMActive.map((item, index) => { actAMActive.map((item, index) => {
if (item.approval_type_name === "MONTHLY_REPORT"){ if (item.approval_type_name === "MONTHLY_REPORT"){
...@@ -220,7 +365,8 @@ class HomePage extends Component { ...@@ -220,7 +365,8 @@ class HomePage extends Component {
if (indexId === -1) { if (indexId === -1) {
this.setState({ isApprover: false }) this.setState({ isApprover: false })
this.getListUserSubco() this.getMonth()
// this.getListUserSubco()
} }
this.setState({ isApproverMB, isApproverMR}) this.setState({ isApproverMB, isApproverMR})
this.getDashboardMB() this.getDashboardMB()
...@@ -231,7 +377,7 @@ class HomePage extends Component { ...@@ -231,7 +377,7 @@ class HomePage extends Component {
getDashboardMB() { getDashboardMB() {
api.create().getDashboardMB().then((response) => { api.create().getDashboardMB().then((response) => {
console.log(response) // console.log(response)
if (String(response.data.status).toLocaleLowerCase() == 'success') { if (String(response.data.status).toLocaleLowerCase() == 'success') {
let data = response.data.data let data = response.data.data
let listdmb = data.sort((a, b) => a.company_id - b.company_id).map((item, index) => { let listdmb = data.sort((a, b) => a.company_id - b.company_id).map((item, index) => {
...@@ -257,7 +403,7 @@ class HomePage extends Component { ...@@ -257,7 +403,7 @@ class HomePage extends Component {
name: "Action", name: "Action",
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
console.log(tableMeta); // console.log(tableMeta);
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Link to={{ <Link to={{
...@@ -519,7 +665,7 @@ class HomePage extends Component { ...@@ -519,7 +665,7 @@ class HomePage extends Component {
<Typography style={{ fontSize: '24px', color: 'white' }}>{this.state.userData === null ? '' : `Welcome, ${this.state.userData.fullname} !`}</Typography> <Typography style={{ fontSize: '24px', color: 'white' }}>{this.state.userData === null ? '' : `Welcome, ${this.state.userData.fullname} !`}</Typography>
</div> </div>
{(this.state.accessMB || this.state.accessMR) && {(this.state.accessMB || this.state.accessMR) &&
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, paddingLeft: 20, paddingRight: 20, paddingTop: 20, paddingBottom: 0, width: '100%' }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Tasks to be Complete</Typography> <Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Tasks to be Complete</Typography>
</div> </div>
...@@ -535,7 +681,26 @@ class HomePage extends Component { ...@@ -535,7 +681,26 @@ class HomePage extends Component {
<div style={{ display: 'inline-flex' }}> <div style={{ display: 'inline-flex' }}>
{this.state.accessMB && {this.state.accessMB &&
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ width: 450, padding: 20, borderRadius: 10 }}> <div style={{ display: 'flex' }}>
<Autocomplete
{...this.state.listPeriodeMB}
id="periodeMB"
onChange={(event, newInputValue) => this.setState({ periodeMB: newInputValue, loading: true }, () => {
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }\
this.getListUserSubcoMB()
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Periode MB" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.periodeMB}
/>
</div>
<Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Master Budget ${this.state.valueSubmit}/${this.state.listSubcoMB.length}`}</Typography> <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Master Budget ${this.state.valueSubmit}/${this.state.listSubcoMB.length}`}</Typography>
{this.state.listSubcoMB.map((item, index) => { {this.state.listSubcoMB.map((item, index) => {
return ( return (
...@@ -574,7 +739,42 @@ class HomePage extends Component { ...@@ -574,7 +739,42 @@ class HomePage extends Component {
} }
{this.state.accessMR && {this.state.accessMR &&
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ width: 450, padding: 20, borderRadius: 10 }}> <div style={{ display: 'flex' }}>
<Autocomplete
{...this.state.listMonth}
id="month"
onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }
})}
disableClearable
style={{ minWidth: 250, marginRight: 20 }}
renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.month}
/>
<Autocomplete
{...this.state.listPeriodeMR}
id="periodeMR"
onChange={(event, newInputValue) => this.setState({ periodeMR: newInputValue, loading: true }, () => {
this.getListUserSubcoMR()
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Periode MR" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.periodeMR}
/>
</div>
<Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5}}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Monthly Report - ${bulan} ${tahun} ${this.state.valueSubmitMR}/${this.state.listSubcoMR.length}`}</Typography> <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Monthly Report - ${bulan} ${tahun} ${this.state.valueSubmitMR}/${this.state.listSubcoMR.length}`}</Typography>
{this.state.listSubcoMR.map((item, index) => { {this.state.listSubcoMR.map((item, index) => {
return ( return (
......
...@@ -1050,12 +1050,14 @@ export default class MonthlyReport extends Component { ...@@ -1050,12 +1050,14 @@ export default class MonthlyReport extends Component {
cursor: tableMeta.rowData[5] ? 'pointer' : 'default', cursor: tableMeta.rowData[5] ? 'pointer' : 'default',
borderColor: 'transparent' borderColor: 'transparent'
}} }}
onClick={() =>{ onClick={() =>
this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3]) // {
console.log(tableMeta.rowData) tableMeta.rowData[5] ?
} this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
// tableMeta.rowData[5] ? : null
// : null // console.log(tableMeta.rowData)
// }
} }
> >
<Typography style={{ color: tableMeta.rowData[5] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography> <Typography style={{ color: tableMeta.rowData[5] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment