Commit ce99fcbe authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'GGMAC' into 'master'

update superadmin approval & cf summ

See merge request !1538
parents dc2f45e1 6b4f7cdc
......@@ -478,6 +478,10 @@ const create = (type = "") => {
const getMonitoringMR = (body) => api.get(`transaction/monitoring/monthly_report/${body.year}/${body.month}`)
const getMonitoringRO = (body) => api.get(`transaction/monitoring/rolling_outlook/${body.year}/${body.quarter}`)
const getMonitoringOLPA = (body) => api.get(`transaction/monitoring/outlook_pa?year=${body.year}`)
// Superadmin Approve
const getListApprover = (report,monthlyReportId) => api.get(`transaction/${report}/get_approver/${monthlyReportId}`)
const getIdToken = (userId) => api.get(`transaction/get_token/${userId}`)
// ------
// STEP 3
// ------
......@@ -823,6 +827,8 @@ const create = (type = "") => {
getMonitoringMR,
getMonitoringRO,
getMonitoringOLPA,
getListApprover,
getIdToken
}
}
......
......@@ -75,7 +75,9 @@ export default class BudgetTahunan extends Component {
userType: '',
PLBSFAMSubmitted: false,
PLID: null,
FRID: null
FRID: null,
listApprover: null,
approver: null
}
this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this);
......@@ -292,7 +294,7 @@ export default class BudgetTahunan extends Component {
}
const handleOpbal = (item) => {
let isUpload = false
if (Number(this.state.periode.periode) <= 2020 ) {
if (Number(this.state.periode.periode) <= 2020) {
isUpload = true
} else {
isUpload = item
......@@ -531,7 +533,7 @@ export default class BudgetTahunan extends Component {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"is_approver": this.state.permissionhandle ? this.state.permissionhandle : this.state.isApprover
"is_approver": this.state.isAdmin && this.state.lastStatus == 'WAITING FOR APPROVAL'? false : (this.state.permissionhandle ? this.state.permissionhandle : this.state.isApprover)
}
console.log(payload)
api.create().getSubmission(payload).then(response => {
......@@ -553,6 +555,23 @@ export default class BudgetTahunan extends Component {
this.getLatestPeriodSubmit()
// this.getCashFlow(type)
// this.getPL(type)
if (this.state.isAdmin) {
console.log('masuk')
api.create().getListApprover('master_budget',this.state.submissionID).then((response) => {
console.log(response)
if (response.data.data) {
let dataListApprover = []
response.data.data.map((item,index) => {
dataListApprover.push({userId: item.user_id, fullname: item.fullname})
})
let defaultProps = {
options: dataListApprover,
getOptionLabel: (option) => option.fullname,
};
this.setState({listApprover: defaultProps})
}
})
}
if (type != undefined && type == 'PL') {
// this.getCashFlow(type)
this.getPL(type)
......@@ -1988,8 +2007,16 @@ export default class BudgetTahunan extends Component {
})
}
approvalSubmission(type) {
async approvalSubmission(type) {
// this.scrollToMyRef()
let realToken = await localStorage.getItem(Constant.TOKEN)
if (this.state.isAdmin && type == 'approve') {
api.create().getIdToken(this.state.approver.userId).then((response) => {
// console.log(response.data.data.token)
// console.log(realToken)
localStorage.setItem(Constant.TOKEN, response.data.data.token)
})
}
this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden';
})
......@@ -2007,15 +2034,23 @@ export default class BudgetTahunan extends Component {
console.log(payload)
// // console.log(this.props.location);
console.log(body)
setTimeout(() => {
api.create().approvalSubmission(body).then((res) => {
console.log(res)
// this.setState({ loading: false }, () => {
// })
if (this.state.isAdmin && type == 'approve') {
localStorage.setItem(Constant.TOKEN, realToken)
this.setState({visibleApproveSuperadmin: false})
}
setTimeout(() => {
if (type == 'revision') {
api.create().createPeriodeRevision(payload).then((res))
}
this.getSubmission()
}, 400);
})
}, 200);
}
clickDetail(item, id, revision, status) {
......@@ -2276,6 +2311,10 @@ export default class BudgetTahunan extends Component {
}
}
handleApproveAdmin() {
this.setState({ visibleApproveSuperadmin: true })
}
render() {
const handleMaxDate = () => {
let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
......@@ -2785,6 +2824,26 @@ export default class BudgetTahunan extends Component {
</div>
</div>
:
this.state.isAdmin && (this.state.lastStatus == 'WAITING FOR YOUR APPROVAL' || this.state.lastStatus == 'WAITING FOR APPROVAL') ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.handleApproveAdmin()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div>
:
this.state.checkApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
......@@ -3037,7 +3096,7 @@ export default class BudgetTahunan extends Component {
lastStatus={this.state.lastStatus}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
// PLBSFAMSubmitted={false}
PLBSFAMSubmitted={this.state.lastStatus == 'APPROVED'? true : false}
PLBSFAMSubmitted={this.state.lastStatus == 'APPROVED' ? true : false}
createCashFlow={this.createCashFlow.bind(this)}
/>
)
......@@ -3160,6 +3219,68 @@ export default class BudgetTahunan extends Component {
</div>
)
}
{this.state.visibleApproveSuperadmin && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Superadmin Approve</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
>
<img src={Images.close} />
</button>
</div>
</div>
<div className="border-bottom" style={{ padding: 20 }}>
<span>Choose approver you want</span>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listApprover}
id="periode"
onChange={(event, newInputValue) => this.setState({ approver: newInputValue })}
disabled={false}
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Approver" margin="normal" style={{ marginTop: 7 }}
/>}
value={this.state.approver}
/>
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.state.approver == null ? this.setState({ alert: true, messageAlert: 'Approver Cannot be Empty', tipeAlert: 'error' }) : this.approvalSubmission('approve')}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Confirm Approve</span>
</div>
</button>
</div>
</div>
</div>
</div>
)}
</div >
);
}
......
......@@ -18976,15 +18976,87 @@ export default class TableSubHolding extends Component {
},
]
const handleCashend = (tableMeta, col) => {
const handleCashend = (tableMeta, col, type) => {
let value = 0
if (String(type).includes('percent')) {
let mtd_actual = tableMeta.rowData[109] == '' ? 0 : Number(tableMeta.rowData[109])
let mtd = tableMeta.rowData[110] == '' ? 0 : Number(tableMeta.rowData[110])
// console.log(mtd)
// let persenMtd = Number(mtd_actual / mtd)
let persenMtd = 0
if (mtd < 0) {
if (mtd_actual >= mtd) {
persenMtd = ((mtd - mtd_actual) / mtd + 1 )
} else {
persenMtd = ((mtd - mtd_actual) / mtd)
}
}
else {
persenMtd = Number(mtd_actual / mtd)
}
let ytd_actual = tableMeta.rowData[113 ] == '' ? 0 : Number(tableMeta.rowData[113 ])
let ytd = tableMeta.rowData[114] == '' ? 0 : Number(tableMeta.rowData[114])
// let persenYtd = Number(ytd_actual / ytd)
let persenYtd = 0
if (ytd < 0) {
if (ytd_actual >= ytd) {
persenYtd = ((ytd - ytd_actual) / ytd + 1 )
} else {
persenYtd = ((ytd - ytd_actual) / ytd)
}
}
else {
persenYtd = Number(ytd_actual/ytd)
}
let quarter_actual = tableMeta.rowData[117] == '' ? 0 : Number(tableMeta.rowData[117])
let quarter = tableMeta.rowData[118] == '' ? 0 : Number(tableMeta.rowData[118])
// let persenQuarter = Number(quarter_actual / quarter)
let persenQuarter = 0
if (quarter < 0) {
if (quarter_actual >= quarter) {
persenQuarter = (quarter - quarter_actual) / quarter + 1
} else {
persenQuarter = (quarter - quarter_actual) / quarter
}
}
else {
persenQuarter = quarter_actual / quarter
}
let fy_actual = tableMeta.rowData[121] == '' ? 0 : Number(tableMeta.rowData[121])
let fy = tableMeta.rowData[122] == '' ? 0 : Number(tableMeta.rowData[122])
// let persenFy = Number(fy_actual / fy)
let persenFy = 0
if (fy < 0) {
if (fy_actual >= fy) {
persenFy = (fy - fy_actual) / fy + 1
} else {
persenFy = (fy - fy_actual) / fy
}
}
else {
persenFy = fy_actual / fy
}
value = String(type).includes('MTD') ? persenMtd : String(type).includes('YTD') ? persenYtd : String(type).includes('Quarter') ? persenQuarter : persenFy
value = (value == Infinity || value == -Infinity || isNaN(value) ? 0 : Number(value * 100).toFixed(1))
// value = isNaN(value) || value == 'Infinity' || value == '-Infinity' ? (value == '' || value == 0 ? -0 : 0) : (value== '' || value == 0 ? persenFy * -100 : persenFy * 100)
} else {
let indexRow = tableMeta.rowIndex
let indexCol = tableMeta.columnIndex
let dataTable = dataTable2
let value = Number(dataTable[indexRow-2][col]) + Number(dataTable[indexRow-1][col])
value = Number(dataTable[indexRow-2][col]) + Number(dataTable[indexRow-1][col])
value = Number(value).toFixed(1)
dataTable2[tableMeta.rowIndex][col] = value
}
return Number(value).toFixed(1)
return value
}
const columnDBCF = [
{
name: "",
......@@ -19138,7 +19210,7 @@ export default class TableSubHolding extends Component {
disabled={true}
suffix={'%'}
// value={Number(tableMeta.rowData[111]).toFixed(1)}
value={String(tableMeta.rowData[5]).toLocaleLowerCase() == 'cash at the end of the period' ? handleCashend(tableMeta, 111) : Number(tableMeta.rowData[111]).toFixed(1)}
value={String(tableMeta.rowData[5]).toLocaleLowerCase() == 'cash at the end of the period' ? handleCashend(tableMeta, 111, 'percentMTD') : Number(tableMeta.rowData[111]).toFixed(1)}
/>
}
/>
......@@ -19276,7 +19348,7 @@ export default class TableSubHolding extends Component {
placeholder=""
disabled={true}
suffix={'%'}
value={String(tableMeta.rowData[5]).toLocaleLowerCase() == 'cash at the end of the period' ? handleCashend(tableMeta, 115) : Number(tableMeta.rowData[115]).toFixed(1)}
value={String(tableMeta.rowData[5]).toLocaleLowerCase() == 'cash at the end of the period' ? handleCashend(tableMeta, 115, 'percentYTD') : Number(tableMeta.rowData[115]).toFixed(1)}
// value={Number(tableMeta.rowData[115]).toFixed(1)}
/>
}
......@@ -19416,7 +19488,7 @@ export default class TableSubHolding extends Component {
placeholder=""
disabled={true}
suffix={'%'}
value={String(tableMeta.rowData[5]).toLocaleLowerCase() == 'cash at the end of the period' ? handleCashend(tableMeta, 119) : Number(tableMeta.rowData[119]).toFixed(1)}
value={String(tableMeta.rowData[5]).toLocaleLowerCase() == 'cash at the end of the period' ? handleCashend(tableMeta, 119, 'percentQuarter') : Number(tableMeta.rowData[119]).toFixed(1)}
// value={Number(tableMeta.rowData[119]).toFixed(1)}
/>
}
......@@ -19554,7 +19626,7 @@ export default class TableSubHolding extends Component {
type="text"
placeholder=""
disabled={true}
value={String(tableMeta.rowData[5]).toLocaleLowerCase() == 'cash at the end of the period' ? handleCashend(tableMeta, 123) : Number(tableMeta.rowData[123]).toFixed(1)}
value={String(tableMeta.rowData[5]).toLocaleLowerCase() == 'cash at the end of the period' ? handleCashend(tableMeta, 123, 'percentFY') : Number(tableMeta.rowData[123]).toFixed(1)}
// value={Number(tableMeta.rowData[123]).toFixed(1)}
suffix={'%'}
/>
......@@ -75,7 +75,9 @@ export default class MonthlyReport extends Component {
dbPL: [],
PLBSFAMSubmitted: false,
PLID: null,
monthHome: null
monthHome: null,
listApprover: null,
approver: null
}
this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this);
......@@ -606,7 +608,7 @@ export default class MonthlyReport extends Component {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"months": this.state.month.month_id,
"is_approver": this.state.isApprover
"is_approver": this.state.isAdmin && this.state.lastStatus == 'WAITING FOR APPROVAL'? false : this.state.isApprover
}
this.setState({ visibleTableHistory: false })
api.create().getMonthlyReportID(payload).then(response => {
......@@ -626,6 +628,23 @@ export default class MonthlyReport extends Component {
// // console.log(this.state.lastStatus);
this.historyApproval()
this.getLatestPeriodSubmit()
if (this.state.isAdmin) {
console.log('masuk')
api.create().getListApprover('monthly_report',this.state.monthlyReportId).then((response) => {
console.log(response)
if (response.data.data) {
let dataListApprover = []
response.data.data.map((item,index) => {
dataListApprover.push({userId: item.user_id, fullname: item.fullname})
})
let defaultProps = {
options: dataListApprover,
getOptionLabel: (option) => option.fullname,
};
this.setState({listApprover: defaultProps})
}
})
}
// this.getPL(type)
if (type != undefined && type == 'PL') {
this.getPL(type)
......@@ -1024,9 +1043,14 @@ export default class MonthlyReport extends Component {
}
}
approvalSubmission(type) {
async approvalSubmission(type) {
// this.scrollToMyRef()
let realToken = await localStorage.getItem(Constant.TOKEN)
if (this.state.isAdmin && type == 'approve') {
api.create().getIdToken(this.state.approver.userId).then((response) => {
localStorage.setItem(Constant.TOKEN, response.data.data.token)
})
}
this.setState({ loading: true, selectedStatus: this.state.listStatus }, () => {
// document.body.style.overflow = 'hidden';
})
......@@ -1046,15 +1070,23 @@ export default class MonthlyReport extends Component {
console.log(payload)
// // console.log(this.props.location);
// // console.log(body)
setTimeout(() => {
api.create().approvalMonthly(body).then((res) => {
console.log(res)
// this.setState({ loading: false }, () => {
// })
if (this.state.isAdmin && type == 'approve') {
localStorage.setItem(Constant.TOKEN, realToken)
this.setState({visibleApproveSuperadmin: false})
}
setTimeout(() => {
if (type == 'revision') {
api.create().createPeriodeRevisionMonthly(payload).then((res))
}
this.getMonthlyReportID()
}, 300);
})
}, 100);
}
getCashFlow(type) {
......@@ -2099,6 +2131,10 @@ export default class MonthlyReport extends Component {
})
}
handleApproveAdmin() {
this.setState({ visibleApproveSuperadmin: true })
}
render() {
const columns = ["#", "Report Type",
{
......@@ -2743,6 +2779,26 @@ export default class MonthlyReport extends Component {
</div>
</div>
:
this.state.isAdmin && (this.state.lastStatus == 'WAITING FOR YOUR APPROVAL' || this.state.lastStatus == 'WAITING FOR APPROVAL')?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.handleApproveAdmin()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div>
:
this.state.checkApprover ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
......@@ -3152,6 +3208,68 @@ export default class MonthlyReport extends Component {
</div>
)
}
{this.state.visibleApproveSuperadmin && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Superadmin Approve</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
>
<img src={Images.close} />
</button>
</div>
</div>
<div className="border-bottom" style={{ padding: 20 }}>
<span>Choose approver you want</span>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listApprover}
id="periode"
onChange={(event, newInputValue) => this.setState({ approver: newInputValue })}
disabled={false}
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Approver" margin="normal" style={{ marginTop: 7 }}
/>}
value={this.state.approver}
/>
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.state.approver == null? this.setState({alert: true, messageAlert: 'Approver Cannot be Empty', tipeAlert: 'error'}) : this.approvalSubmission('approve')}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Confirm Approve</span>
</div>
</button>
</div>
</div>
</div>
</div>
)}
</div >
);
}
......
......@@ -69,7 +69,9 @@ export default class OutlookPA extends Component {
listStatus: [],
selectedStatus: [],
prevRevision: false,
dbPL: []
dbPL: [],
listApprover: null,
approver: null
}
this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this);
......@@ -467,7 +469,7 @@ export default class OutlookPA extends Component {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"is_approver": this.state.isApprover
"is_approver": this.state.isAdmin && this.state.lastStatus == 'WAITING FOR APPROVAL'? false : this.state.isApprover
}
api.create().getOutlookPAID(payload).then(response => {
console.log(response)
......@@ -482,6 +484,23 @@ export default class OutlookPA extends Component {
btnApprove: response.data.data.is_submit
}, () => {
// console.log(this.state.lastStatus);
if (this.state.isAdmin) {
console.log('masuk')
api.create().getListApprover('outlook_pa',this.state.outlook_pa_id).then((response) => {
console.log(response)
if (response.data.data) {
let dataListApprover = []
response.data.data.map((item,index) => {
dataListApprover.push({userId: item.user_id, fullname: item.fullname})
})
let defaultProps = {
options: dataListApprover,
getOptionLabel: (option) => option.fullname,
};
this.setState({listApprover: defaultProps})
}
})
}
this.historyApproval()
this.getLatestPeriodSubmit()
if (type != undefined && type == 'PL') {
......@@ -539,8 +558,16 @@ export default class OutlookPA extends Component {
})
}
approvalSubmission(type) {
async approvalSubmission(type) {
this.scrollToMyRef()
let realToken = await localStorage.getItem(Constant.TOKEN)
if (this.state.isAdmin && type == 'approve') {
api.create().getIdToken(this.state.approver.userId).then((response) => {
// console.log(realToken)
// console.log(response.data.data.token)
localStorage.setItem(Constant.TOKEN, response.data.data.token)
})
}
this.setState({ loading: true })
let body = {
"approval_id": this.props.location.state == undefined ? this.state.approverID : this.state.rawData.approval_id,
......@@ -553,15 +580,32 @@ export default class OutlookPA extends Component {
"max_periode": moment(this.state.maxDateRevision).format('YYYY-MM-DD')
}
// console.log(payload)
// api.create().approvalSubmissionOLPA(body).then((res) => {
// console.log(res)
// // this.setState({ loading: false }, () => {
// this.getOutlookPAID()
// // })
// if (type == 'revision') {
// api.create().createPeriodeRevisionOLPA(payload).then((res) => console.log(res))
// }
// })
setTimeout(() => {
api.create().approvalSubmissionOLPA(body).then((res) => {
console.log(res)
this.setState({ loading: false }, () => {
this.getOutlookPAID()
})
// this.setState({ loading: false }, () => {
// })
if (this.state.isAdmin && type == 'approve') {
localStorage.setItem(Constant.TOKEN, realToken)
this.setState({visibleApproveSuperadmin: false})
}
setTimeout(() => {
if (type == 'revision') {
api.create().createPeriodeRevisionOLPA(payload).then((res) => console.log(res))
api.create().createPeriodeRevisionOLPA(payload).then((res))
}
this.getOutlookPAID()
}, 300);
})
}, 100);
}
clickDetail(item, id, revision, status) {
......@@ -1296,6 +1340,10 @@ export default class OutlookPA extends Component {
})
}
handleApproveAdmin() {
this.setState({visibleApproveSuperadmin: true})
}
render() {
const handleMaxDate = () => {
let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
......@@ -1788,6 +1836,26 @@ export default class OutlookPA extends Component {
</div>
</div>
:
this.state.isAdmin && (this.state.lastStatus == 'WAITING FOR YOUR APPROVAL' || this.state.lastStatus == 'WAITING FOR APPROVAL') ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.handleApproveAdmin()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div>
:
this.state.checkApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
......@@ -2128,6 +2196,68 @@ export default class OutlookPA extends Component {
</div>
</div>
)}
{this.state.visibleApproveSuperadmin && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Superadmin Approve</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
>
<img src={Images.close} />
</button>
</div>
</div>
<div className="border-bottom" style={{ padding: 20 }}>
<span>Choose approver you want</span>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listApprover}
id="periode"
onChange={(event, newInputValue) => this.setState({ approver: newInputValue })}
disabled={false}
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Approver" margin="normal" style={{ marginTop: 7 }}
/>}
value={this.state.approver}
/>
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.state.approver == null? this.setState({alert: true, messageAlert: 'Approver Cannot be Empty', tipeAlert: 'error'}) : this.approvalSubmission('approve')}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Confirm Approve</span>
</div>
</button>
</div>
</div>
</div>
</div>
)}
</div >
);
}
......
......@@ -75,7 +75,9 @@ export default class RollingOutlook extends Component {
{ value: 'q3', name: 'Q3' },
// {value: 'ol_pa', name: 'OL PA'},
],
quarter: null
quarter: null,
listApprover: null,
approver: null
}
this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this);
......@@ -526,7 +528,7 @@ export default class RollingOutlook extends Component {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"is_approver": this.state.isApprover,
"is_approver": this.state.isAdmin && this.state.lastStatus == 'WAITING FOR APPROVAL'? false : this.state.isApprover,
"quartal": this.state.quarter.value
}
api.create().getRollingOutlookID(payload).then(response => {
......@@ -547,6 +549,23 @@ export default class RollingOutlook extends Component {
msgApproveRO: response.data.data.message_approval_rolling_outlook
}, () => {
console.log(this.state.lastStatus);
if (this.state.isAdmin) {
console.log('masuk')
api.create().getListApprover('rolling_outlook',this.state.rollingOutlookID).then((response) => {
console.log(response)
if (response.data.data) {
let dataListApprover = []
response.data.data.map((item,index) => {
dataListApprover.push({userId: item.user_id, fullname: item.fullname})
})
let defaultProps = {
options: dataListApprover,
getOptionLabel: (option) => option.fullname,
};
this.setState({listApprover: defaultProps})
}
})
}
this.historyApproval()
this.getLatestPeriodSubmit()
if (type != undefined && type == 'PL') {
......@@ -605,8 +624,16 @@ export default class RollingOutlook extends Component {
})
}
approvalSubmission(type) {
async approvalSubmission(type) {
// this.scrollToMyRef()
let realToken = await localStorage.getItem(Constant.TOKEN)
if (this.state.isAdmin && type == 'approve') {
api.create().getIdToken(this.state.approver.userId).then((response) => {
// console.log(realToken)
// console.log(response.data.data.token)
localStorage.setItem(Constant.TOKEN, response.data.data.token)
})
}
this.setState({ loading: true })
let body = {
"approval_id": this.props.location.state == undefined ? this.state.approverID : this.state.rawData.approval_id,
......@@ -622,15 +649,35 @@ export default class RollingOutlook extends Component {
"quartal": this.state.quarter.value
}
console.log(payload)
// api.create().approvalRolling(body).then((res) => {
// console.log(res)
// // this.setState({ loading: false }, () => {
// this.getRollingOutlookID()
// // })
// if (type == 'revision') {
// api.create().createPeriodeRevisionRO(payload).then((res) => console.log(res))
// }
// })
setTimeout(() => {
api.create().approvalRolling(body).then((res) => {
console.log(res)
// this.setState({ loading: false }, () => {
// })
if (this.state.isAdmin && type == 'approve') {
localStorage.setItem(Constant.TOKEN, realToken)
this.setState({visibleApproveSuperadmin: false})
}
setTimeout(() => {
if (type == 'revision') {
api.create().createPeriodeRevisionRO(payload).then((res))
}
this.setState({ loading: false }, () => {
this.getRollingOutlookID()
})
if (type == 'revision') {
api.create().createPeriodeRevisionRO(payload).then((res) => console.log(res))
}
}, 300);
})
}, 100);
}
clickDetail(item, id, revision, status) {
......@@ -1355,6 +1402,10 @@ export default class RollingOutlook extends Component {
})
}
handleApproveAdmin() {
this.setState({ visibleApproveSuperadmin: true })
}
render() {
const handleMaxDate = () => {
let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
......@@ -1864,6 +1915,26 @@ export default class RollingOutlook extends Component {
</div>
</div>
:
this.state.isAdmin && (this.state.lastStatus == 'WAITING FOR YOUR APPROVAL' || this.state.lastStatus == 'WAITING FOR APPROVAL') ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.handleApproveAdmin()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div>
:
this.state.checkApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
......@@ -2207,6 +2278,68 @@ export default class RollingOutlook extends Component {
</div>
</div>
)}
{this.state.visibleApproveSuperadmin && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Superadmin Approve</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
>
<img src={Images.close} />
</button>
</div>
</div>
<div className="border-bottom" style={{ padding: 20 }}>
<span>Choose approver you want</span>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listApprover}
id="periode"
onChange={(event, newInputValue) => this.setState({ approver: newInputValue })}
disabled={false}
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Approver" margin="normal" style={{ marginTop: 7 }}
/>}
value={this.state.approver}
/>
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.state.approver == null ? this.setState({ alert: true, messageAlert: 'Approver Cannot be Empty', tipeAlert: 'error' }) : this.approvalSubmission('approve')}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Confirm Approve</span>
</div>
</button>
</div>
</div>
</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