Commit 7013a73f authored by r.kurnia's avatar r.kurnia

home

parent 115b3b35
......@@ -416,6 +416,8 @@ const create = (type = "") => {
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}`)
const getListUserSubcoRO = (periode,quartal) => api.get(`transaction/get_dashboard_sub_co/rolling_outlook/${periode}/${quartal}`)
const getListUserSubcoOL = (periode) => api.get(`transaction/get_dashboard_sub_co/outlook_pa/${periode}`)
// Cronjob
const getHierarkiCronJobMBPL = () => api.get('/transaction/report/get_hierarki_master_budget/profit_loss')
......@@ -678,6 +680,8 @@ const create = (type = "") => {
createPeriodeRevisionMonthly,
getListUserSubcoMB,
getListUserSubcoMR,
getListUserSubcoRO,
getListUserSubcoOL,
validateSubmitReportFAM,
createMonthlyReportCF,
getReportBSMB,
......
......@@ -30,25 +30,39 @@ class HomePage extends Component {
isApprover: true,
listSubcoMB: [],
listSubcoMR: [],
listSubcoRO: [],
listSubcoOL: [],
valueSubmit: 0,
listdmb: [],
dataTableMB: [],
listPeriodeMB: null,
listPeriodeMR: null,
listPeriodeRO: null,
listPeriodeOL: null,
listMonth: null,
periodeMB: null,
periodeMR: null,
periodeRO: null,
periodeOL: null,
month: null,
monthCAT: null,
periodeCAT: null,
loading: false,
accessMB: false,
accessMR: false,
accessRO: false,
accessOL: false,
company: [],
dataDashboardCAT: [],
loading2: false,
loading3: false,
parameterPerfom: []
parameterPerfom: [],
quarterList: [
{ value: 'q1', name: 'Q1' },
{ value: 'q2', name: 'Q2' },
{ value: 'q3', name: 'Q3' },
],
quarter: null
}
}
......@@ -75,6 +89,8 @@ class HomePage extends Component {
// })
this.getPermissionMB()
this.getPermissionMR()
this.getPermissionRO()
this.getPermissionOL()
this.getApprMat()
// this.getListUserSubco()
this.getMonth()
......@@ -91,9 +107,13 @@ class HomePage extends Component {
let currentYear = new Date().getFullYear()
let MB = []
let MR = []
let ROut = []
let OL = []
for (var i = 2000; i <= currentYear; i++) {
MB.push({ name: String(i), value: i })
MR.push({ name: String(i), value: i })
ROut.push({ name: String(i), value: i })
OL.push({ name: String(i), value: i })
if (i == currentYear) {
MB.push({ name: String(i + 1), value: i + 1 })
}
......@@ -108,13 +128,41 @@ class HomePage extends Component {
options: MR,
getOptionLabel: (option) => option.name,
};
let defaultPropsRO = {
options: ROut,
getOptionLabel: (option) => option.name,
};
let defaultPropsOL = {
options: OL,
getOptionLabel: (option) => option.name,
};
// console.log(MR[MR.length - 1])
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let yearNow = dateNow.getFullYear()
let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
let indexMonthRO = ROut.findIndex((val) => val.value == yearNow)
let indexMonthOL = OL.findIndex((val) => val.value == yearNow)
this.setState({ listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[indexMonthMR], listPeriodeCAT: defaultPropsMB, periodeCAT: MB[indexMonthMR] }, () => {
let defaultPropsQuarter = {
options: this.state.quarterList,
getOptionLabel: (option) => option.name
}
this.setState({ listPeriodeMB: defaultPropsMB,
periodeMB: MB[MB.length - 1],
listPeriodeMR: defaultPropsMR,
periodeMR: MR[indexMonthMR],
listPeriodeRO: defaultPropsRO,
periodeRO: ROut[indexMonthRO],
listQuarter: defaultPropsQuarter,
quarter: this.state.quarterList[0],
listPeriodeOL: defaultPropsOL,
periodeOL: OL[indexMonthOL],
listPeriodeCAT: defaultPropsMB,
periodeCAT: MB[indexMonthMR] }, () => {
this.getParameterGroupPerfom()
})
}
......@@ -276,6 +324,62 @@ class HomePage extends Component {
})
}
getPermissionRO() {
let payload = {
menu: "rolling outlook & cat revision"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
btnCreateRO: response.data.data.create,
btnEditRO: response.data.data.edit,
load: true
}, () => {
if (this.state.btnCreateRO === true && this.state.btnEditRO === true) {
this.setState({ accessRO: true })
}
})
} else {
this.setState({
load: true
})
}
} else {
this.setState({ load: true })
}
})
}
getPermissionOL() {
let payload = {
menu: "outlook performance appraisal"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
btnCreateOL: response.data.data.create,
btnEditOL: response.data.data.edit,
load: true
}, () => {
if (this.state.btnCreateOL === true && this.state.btnEditOL === true) {
this.setState({ accessOL: true })
}
})
} else {
this.setState({
load: true
})
}
} else {
this.setState({ load: true })
}
})
}
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
......@@ -359,6 +463,60 @@ class HomePage extends Component {
})
}
getListUserSubcoRO() {
// console.log(this.state.month.month_id)
// console.log(this.state.periodeMR.value)
api.create().getListUserSubcoRO(this.state.periodeRO.value, this.state.quarter.value).then((response) => {
let valueSubmitRO = 0
let dataRO = []
console.log(response)
if (response.data) {
if (response.data.status === "success") {
response.data.data.map((item, index) => {
if (item.is_submit === true) {
valueSubmitRO += 1
}
dataRO.push(item)
})
this.setState({
listSubcoRO: dataRO,
valueSubmitRO,
loading: false
})
}
} else {
this.setState({ loading: false })
}
})
}
getListUserSubcoOL() {
// console.log(this.state.month.month_id)
// console.log(this.state.periodeOL.value)
api.create().getListUserSubcoOL(this.state.periodeOL.value).then((response) => {
let valueSubmitOL = 0
let dataOL = []
console.log(response)
if (response.data) {
if (response.data.status === "success") {
response.data.data.map((item, index) => {
if (item.is_submit === true) {
valueSubmitOL += 1
}
dataOL.push(item)
})
this.setState({
listSubcoOL: dataOL,
valueSubmitOL,
loading: false
})
}
} else {
this.setState({ loading: false })
}
})
}
getListUserSubco() {
api.create().getDashboardUser().then(response => {
// console.log(response);
......@@ -513,12 +671,16 @@ class HomePage extends Component {
this.setState({ parameterPerfom: response.data.data } , () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
this.getListUserSubcoRO()
this.getListUserSubcoOL()
this.getDetailUser()
})
} else {
this.setState({ parameterPerfom: [] } , () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
this.getListUserSubcoRO()
this.getListUserSubcoOL()
this.getDetailUser()
})
}
......@@ -1024,14 +1186,14 @@ class HomePage extends Component {
})}
</div>
{(this.state.accessMB || this.state.accessMR) &&
{(this.state.accessMB || this.state.accessMR || this.state.accessRO || this.state.accessOL ) &&
<div style={{ flex: 1, paddingLeft: 20, paddingRight: 20, paddingTop: 20, paddingBottom: 0, width: '100%' }}>
<div style={{ display: 'flex' }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Tasks to be Completed</Typography>
</div>
</div>
}
{(this.state.accessMB === false && this.state.accessMR === false) &&
{(this.state.accessMB === false && this.state.accessMR === false && this.state.accessRO === false && this.state.accessOL === false ) &&
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div style={{ display: 'flex' }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>You don't have pending task</Typography>
......@@ -1113,7 +1275,7 @@ class HomePage extends Component {
// }
})}
disableClearable
style={{ minWidth: 250, marginRight: 20 }}
style={{ minWidth: 210, marginRight: 20 }}
renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.month}
/>
......@@ -1130,7 +1292,7 @@ class HomePage extends Component {
// }
})}
disableClearable
style={{ width: 250 }}
style={{ width: 210 }}
renderInput={(params) => <TextField {...params} label="Periode MR" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.periodeMR}
/>
......@@ -1173,6 +1335,142 @@ class HomePage extends Component {
</Paper>
</div>
}
{this.state.accessRO &&
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div style={{ display: 'flex' }}>
<Autocomplete
{...this.state.listPeriodeRO}
id="periodeRO"
onChange={(event, newInputValue) => this.setState({ periodeRO: newInputValue, loading: true }, () => {
this.getListUserSubcoRO()
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }
})}
disableClearable
style={{ minWidth: 210, marginRight: 20 }}
renderInput={(params) => <TextField {...params} label="Periode RO" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.periodeRO}
/>
<Autocomplete
{...this.state.listQuarter}
id="quartal"
disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ quarter: newInputValue, loading: true }, () => {
this.getListUserSubcoRO()
// this.setState({ visibleTableHistory: false })
// if (this.state.listCompany == null) {
// this.getCompanySubmitted()
// } else {
// this.getRevision()
// }
})}
disableClearable
style={{ width: 210 }}
renderInput={(params) => <TextField {...params} label="Quarter" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.quarter}
/>
</div>
<Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
{!this.state.loading2 && <Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Rolling Outlook & CAT - ${this.state.periodeRO.value} ${this.state.quarter.value} ${this.state.valueSubmitRO}/${this.state.listSubcoRO.length}`}</Typography>}
{this.state.listSubcoRO.map((item, index) => {
console.log(item)
return (
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
<div style={{ display: 'flex' }}>
<img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
<Link to={{
pathname: `/home/rolling-outlook/`,
state: {
userType: 'user',
rawData: item,
quarter: this.state.quarter
}
}}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5,
outline: 'none'
}}>
<Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
</button>
</Link>
</div>
{item.is_submit === false && item.is_overdue && (
<div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
<Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
</div>
)}
</div>
)
})}
</Paper>
</div>
}
{this.state.accessOL &&
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div style={{ display: 'flex' }}>
<Autocomplete
{...this.state.listPeriodeOL}
id="periodeOL"
onChange={(event, newInputValue) => this.setState({ periodeOL: newInputValue, loading: true }, () => {
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }\
this.getListUserSubcoOL()
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Periode OL" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.periodeOL}
/>
</div>
<Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Outlook Performance Appraisal ${this.state.valueSubmit}/${this.state.listSubcoOL.length}`}</Typography>
{this.state.listSubcoOL.map((item, index) => {
return (
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
<div style={{ display: 'flex' }}>
<img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
<Link to={{
pathname: `/home/outlook-performance/`,
state: {
userType: 'user',
rawData: item
}
}}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5,
outline: 'none'
}}>
<Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
</button>
</Link>
</div>
{item.is_submit === false && item.is_overdue && (
<div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
<Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
</div>
)}
</div>
)
})}
</Paper>
</div>
}
</div>
</div>
}
......
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