Commit 66a7b887 authored by d.arizona's avatar d.arizona

update

parent fe7c9a0d
...@@ -258,6 +258,9 @@ const create = (type = "") => { ...@@ -258,6 +258,9 @@ const create = (type = "") => {
// Monthly // Monthly
const getMonthlyReport = (body) => api.post('transaction/monthly_report/get_all_report', body) const getMonthlyReport = (body) => api.post('transaction/monthly_report/get_all_report', body)
const submitMonthlyReport = (body) => api.post('transaction/monthly_report/submit_monthly_report', body)
const approvalMonthly = (body) => api.post('transaction/monthly_report/approval_monthly', body)
const createPeriodeRevisionMonthly = (body) => api.post('transaction/monthly_report/create_periode_revision', body)
const getMonthlyOI = (body) => api.post('transaction/operating_indicator/monthly_report/get_operating_indicator_id', body) const getMonthlyOI = (body) => api.post('transaction/operating_indicator/monthly_report/get_operating_indicator_id', body)
const getMonthlyReportID = (body) => api.post('transaction/monthly_report/get_monthly_report_id', body) const getMonthlyReportID = (body) => api.post('transaction/monthly_report/get_monthly_report_id', body)
// const getHierarkiMontlyReportBS = (body) => api.post('transaction/monthly_report_bs/get_report_hierarki', body) // const getHierarkiMontlyReportBS = (body) => api.post('transaction/monthly_report_bs/get_report_hierarki', body)
...@@ -555,7 +558,10 @@ const create = (type = "") => { ...@@ -555,7 +558,10 @@ const create = (type = "") => {
getParameterByGroupName, getParameterByGroupName,
getSubmitMonthlyReport, getSubmitMonthlyReport,
getIdDeleteFromExcelLOCF, getIdDeleteFromExcelLOCF,
deleteAllItemReportLOCF deleteAllItemReportLOCF,
submitMonthlyReport,
approvalMonthly,
createPeriodeRevisionMonthly
} }
} }
......
...@@ -66,7 +66,8 @@ export default class MonthlyReport extends Component { ...@@ -66,7 +66,8 @@ export default class MonthlyReport extends Component {
lastStatus: '', lastStatus: '',
approverTrue: false, approverTrue: false,
listStatus: [], listStatus: [],
selectedStatus: [] selectedStatus: [],
detailRevisiCheck: []
} }
this.myRef = React.createRef() this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -114,17 +115,17 @@ export default class MonthlyReport extends Component { ...@@ -114,17 +115,17 @@ export default class MonthlyReport extends Component {
getChecApprover() { getChecApprover() {
let listStatus1 = [ let listStatus1 = [
{name: 'Open', value: 'not-yet'}, {name: 'Open', value: 'not-yet'},
{name: 'Submitted', value: 'submitted'}, {name: 'Submitted', value: 'approval_review'},
{name: 'Waiting for Review', value: 'approval_review'}, {name: 'Waiting for Review / Approval', value: 'approval_proccess'},
{name: 'Waiting for Approval', value: 'approval_process'}, // {name: 'Waiting for Approval', value: 'approval_proccess'},
{name: 'Revision', value: 'revision'}, // {name: 'Revision', value: 'revision'},
{name: 'Approved', value: 'approved'}, {name: 'Approved', value: 'approved'},
] ]
let listStatus2 = [ let listStatus2 = [
{name: 'Open', value: 'not-yet'}, {name: 'Open', value: 'not-yet'},
{name: 'Submitted', value: 'submitted'}, {name: 'Submitted', value: 'approval_review'},
{name: 'Revision', value: 'revision'}, // {name: 'Revision', value: 'revision'},
{name: 'Approved', value: 'approved'}, {name: 'Approved', value: 'approved'},
] ]
...@@ -133,7 +134,7 @@ export default class MonthlyReport extends Component { ...@@ -133,7 +134,7 @@ export default class MonthlyReport extends Component {
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
if (response.data.data.is_approver === true) { if (response.data.data.is_approver === true) {
this.setState({ isApprover: true, checkApprover: true, still_approver: true, approverTrue: true, listStatus: listStatus1, selectedStatus: [listStatus1[0]]}, () => this.setState({ isApprover: true, checkApprover: true, still_approver: true, approverTrue: true, listStatus: listStatus1, selectedStatus: listStatus1}, () =>
{ {
// if (this.state.submittedOnly) { // if (this.state.submittedOnly) {
this.getMonth() this.getMonth()
...@@ -142,7 +143,7 @@ export default class MonthlyReport extends Component { ...@@ -142,7 +143,7 @@ export default class MonthlyReport extends Component {
// } // }
}) })
} else { } else {
this.setState({ isApprover: false, checkApprover: false, still_approver: false, approverTrue: false, listStatus: listStatus2, selectedStatus: [listStatus2[0]]}, () => this.setState({ isApprover: false, checkApprover: false, still_approver: false, approverTrue: false, listStatus: listStatus2, selectedStatus: listStatus2}, () =>
this.getMonth()) this.getMonth())
// this.getCompanyActive()) // this.getCompanyActive())
} }
...@@ -375,7 +376,8 @@ export default class MonthlyReport extends Component { ...@@ -375,7 +376,8 @@ export default class MonthlyReport extends Component {
console.log(index) console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => { this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
// if (this.state.isApprover === true && this.state.submittedOnly) { // if (this.state.isApprover === true && this.state.submittedOnly) {
this.getCompanySubmitted() this.getDetailUser()
// this.getCompanySubmitted()
// console.log('masuk') // console.log('masuk')
// } else { // } else {
// this.getRevision() // this.getRevision()
...@@ -397,6 +399,51 @@ export default class MonthlyReport extends Component { ...@@ -397,6 +399,51 @@ export default class MonthlyReport extends Component {
}) })
} }
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.getRole(response.data.data.role_id)
this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanySubmitted()
})
}
}
}
})
}
getRole(id) {
api.create().getDetailRole(id).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
// this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
// // // console.log(response.data.data)
if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') {
this.setState({ isAdmin: true })
}
} 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' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getCompanySubmitted() { getCompanySubmitted() {
let selectedStatus = this.state.selectedStatus.map((item) => { let selectedStatus = this.state.selectedStatus.map((item) => {
return item.value return item.value
...@@ -406,6 +453,7 @@ export default class MonthlyReport extends Component { ...@@ -406,6 +453,7 @@ export default class MonthlyReport extends Component {
"months": this.state.month.month_id, "months": this.state.month.month_id,
"status": selectedStatus "status": selectedStatus
} }
api.create().getCompanySubmittedMonthly(body).then(response => { api.create().getCompanySubmittedMonthly(body).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
...@@ -419,16 +467,27 @@ export default class MonthlyReport extends Component { ...@@ -419,16 +467,27 @@ export default class MonthlyReport extends Component {
} }
}) })
let arrayBaru = []
this.state.userCompany.map((item, index) => {
let indexID = companyData.findIndex((val) => val.company_id == item)
if (indexID !== -1) {
arrayBaru.push(companyData[indexID])
}
})
if (arrayBaru.length > 0) {
arrayBaru = arrayBaru.sort((a,b) => a.company_name.localeCompare(b.company_name))
}
let defaultProps = { let defaultProps = {
options: companyData, options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name), getOptionLabel: (option) => titleCase(option.company_name),
} }
let indexID = null let indexID = null
if (this.state.rawData !== undefined) { if (this.state.rawData !== undefined) {
indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id) indexID = arrayBaru.findIndex((val) => val.company_id == this.state.rawData.company_id)
} }
// console.log(response.data.data.length) // console.log(response.data.data.length)
this.setState({ listCompany: defaultProps, company: indexID == null ? companyData[0] : companyData[indexID], company_submit: defaultProps }, () => { this.setState({ listCompany: defaultProps, company: indexID == null ? arrayBaru[0] : arrayBaru[indexID], company_submit: defaultProps }, () => {
// console.log(response.data.data.length) // console.log(response.data.data.length)
if (response.data.data.length > 0) { if (response.data.data.length > 0) {
this.getRevision() this.getRevision()
...@@ -509,6 +568,7 @@ export default class MonthlyReport extends Component { ...@@ -509,6 +568,7 @@ export default class MonthlyReport extends Component {
"months": this.state.month.month_id, "months": this.state.month.month_id,
"is_approver": this.state.isApprover "is_approver": this.state.isApprover
} }
this.setState({visibleTableHistory: false})
api.create().getMonthlyReportID(payload).then(response => { api.create().getMonthlyReportID(payload).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
...@@ -519,7 +579,7 @@ export default class MonthlyReport extends Component { ...@@ -519,7 +579,7 @@ export default class MonthlyReport extends Component {
lastStatus: response.data.data.last_status === null ? 'SUBMIT' : response.data.data.last_status, lastStatus: response.data.data.last_status === null ? 'SUBMIT' : response.data.data.last_status,
lastRevision: response.data.data.last_revision, lastRevision: response.data.data.last_revision,
btnApprove: response.data.data.is_submit, btnApprove: response.data.data.is_submit,
monthlyReportId: response.data.data ? response.data.data.monthly_report_id : null monthlyReportId: response.data.data ? response.data.data.monthly_report_id : null,
}, () => { }, () => {
// // console.log(this.state.lastStatus); // // console.log(this.state.lastStatus);
this.historyApproval() this.historyApproval()
...@@ -828,13 +888,13 @@ export default class MonthlyReport extends Component { ...@@ -828,13 +888,13 @@ export default class MonthlyReport extends Component {
}) })
if (canSubmit === true) { if (canSubmit === true) {
let body = { let body = {
submission_id: this.state.submissionID monthly_report_id: this.state.monthlyReportId
} }
api.create().submitMasterBudget(body).then(response => { api.create().submitMonthlyReport(body).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.getSubmission() this.getPermission()
} }
} }
}) })
...@@ -876,6 +936,7 @@ export default class MonthlyReport extends Component { ...@@ -876,6 +936,7 @@ export default class MonthlyReport extends Component {
let body = { let body = {
"approval_id": this.state.approverID, "approval_id": this.state.approverID,
"status": type, "status": type,
"months": this.state.month.month_id,
"detail": this.state.detailRevisiCheck "detail": this.state.detailRevisiCheck
} }
let payload = { let payload = {
...@@ -887,14 +948,14 @@ export default class MonthlyReport extends Component { ...@@ -887,14 +948,14 @@ export default class MonthlyReport extends Component {
// // // console.log(payload) // // // console.log(payload)
// // console.log(this.props.location); // // console.log(this.props.location);
// // console.log(body) // // console.log(body)
api.create().approvalSubmission(body).then((res) => { api.create().approvalMonthly(body).then((res) => {
// // // console.log(res) console.log(res)
// this.setState({ loading: false }, () => { // this.setState({ loading: false }, () => {
// }) // })
if (type == 'revision') { if (type == 'revision') {
api.create().createPeriodeRevision(payload).then((res)) api.create().createPeriodeRevisionMonthly(payload).then((res))
} }
this.getSubmission() this.getPermission()
}) })
} }
...@@ -1176,7 +1237,7 @@ export default class MonthlyReport extends Component { ...@@ -1176,7 +1237,7 @@ export default class MonthlyReport extends Component {
); );
return ( return (
<div style={{ flex: 1, backgroundColor: '#f8f8f8' }}> <div style={{ flex: 1, backgroundColor: '#f8f8f8' }} ref={this.myRef}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}> <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}> <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert} {this.state.messageAlert}
...@@ -1519,7 +1580,7 @@ export default class MonthlyReport extends Component { ...@@ -1519,7 +1580,7 @@ export default class MonthlyReport extends Component {
</div> </div>
</div> </div>
: :
this.state.checkApprover === true ? this.state.approverTrue?
this.state.lastStatus === 'WAITING FOR REVIEW' ? this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} > <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button <button
......
...@@ -662,7 +662,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -662,7 +662,7 @@ export default class CorporateAnnualTargetMR extends Component {
let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase()) let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase())
let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id) let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id)
let totalScore = 0 let totalScore = 0
let achx100 = item[9] == '100%' ? Number(totalAch) / 100 > 1 ? 1 : Number(totalAch) / 100 : Number(totalAch) / 100 let achx100 = item[9] == '100%' && (item[8] == 'HIB' || item[8] == 'HIG')? Number(totalAch) / 100 > 1 ? 1 : Number(totalAch) / 100 : Number(totalAch) / 100
if (listParameterFilterCompany.length == 0) { if (listParameterFilterCompany.length == 0) {
listParameterFilter.map((item, index) => { listParameterFilter.map((item, index) => {
if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) { if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
...@@ -1165,7 +1165,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1165,7 +1165,7 @@ export default class CorporateAnnualTargetMR extends Component {
let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase()) let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase())
let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id) let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id)
let totalScore = 0 let totalScore = 0
let achx100 = tableMeta.rowData[9] == '100%' ? Number(tableMeta.rowData[13]) / 100 > 1 ? 1 : Number(tableMeta.rowData[13]) / 100 : Number(tableMeta.rowData[13]) / 100 let achx100 = tableMeta.rowData[9] == '100%' && (tableMeta.rowData[8] == 'HIB' || tableMeta.rowData[8] == 'HIG') ? Number(tableMeta.rowData[13]) / 100 > 1 ? 1 : Number(tableMeta.rowData[13]) / 100 : Number(tableMeta.rowData[13]) / 100
if (listParameterFilterCompany.length == 0) { if (listParameterFilterCompany.length == 0) {
listParameterFilter.map((item, index) => { listParameterFilter.map((item, index) => {
if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) { if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
......
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