Commit 6b0778f4 authored by Deni Rinaldi's avatar Deni Rinaldi

duarrr konflik

parent 878fbf47
...@@ -78,7 +78,7 @@ export default class BudgetTahunan extends Component { ...@@ -78,7 +78,7 @@ export default class BudgetTahunan extends Component {
scrollToMyRef = () => window.scrollTo(0, this.myRef.current.offsetTop) scrollToMyRef = () => window.scrollTo(0, this.myRef.current.offsetTop)
componentDidMount() { componentDidMount() {
this.setState({ loading: true }, ()=> { this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
}) })
this.props.selectIndex('Master Budget & CAT') this.props.selectIndex('Master Budget & CAT')
...@@ -93,7 +93,7 @@ export default class BudgetTahunan extends Component { ...@@ -93,7 +93,7 @@ export default class BudgetTahunan extends Component {
// this.checkApprover() // this.checkApprover()
} }
} }
getPermission() { getPermission() {
let payload = { let payload = {
menu: "Master Budget & CAT" menu: "Master Budget & CAT"
...@@ -107,16 +107,21 @@ export default class BudgetTahunan extends Component { ...@@ -107,16 +107,21 @@ export default class BudgetTahunan extends Component {
btnedit: response.data.data.edit, btnedit: response.data.data.edit,
btndelete: response.data.data.delete, btndelete: response.data.data.delete,
// load: true // load: true
}, ()=> { }, () => {
this.checkApprover() this.checkApprover()
}) })
} else { } else {
this.setState({ this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
// load: true if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
}) })
} }
} else { } else {
this.setState({ load: true }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -129,7 +134,7 @@ export default class BudgetTahunan extends Component { ...@@ -129,7 +134,7 @@ export default class BudgetTahunan extends Component {
// this.setState({ tempData: response.data.data, privileges: response.data.data.privileges }) // this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
// // console.log(response.data.data) // // console.log(response.data.data)
if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') { if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') {
this.setState({isAdmin: true}) this.setState({ isAdmin: true })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -156,45 +161,17 @@ export default class BudgetTahunan extends Component { ...@@ -156,45 +161,17 @@ export default class BudgetTahunan extends Component {
checkApprover() { checkApprover() {
api.create().checkApprover().then(response => { api.create().checkApprover().then(response => {
// console.log(response.data.data) console.log(response.data.data)
if (response.data) {
if (response.data.status === "success") {
// // console.log(response);
if (response.data.data.is_approver === true) {
this.setState({ isApprover: true, checkApprover: true }, () =>
this.getPeriode())
} else {
this.setState({ isApprover: false, checkApprover: false }, () =>
this.getDetailUser())
}
} 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.problem, tipeAlert: 'error'})
}
})
}
getPermission() {
let payload = {
menu: "master budget & cat"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ // // console.log(response);
btncreate: response.data.data.create, if (response.data.data.is_approver === true) {
loadview: response.data.data.view this.setState({ isApprover: true, checkApprover: true }, () =>
}) this.getPeriode())
} else {
this.setState({ isApprover: false, checkApprover: false }, () =>
this.getDetailUser())
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -237,7 +214,7 @@ export default class BudgetTahunan extends Component { ...@@ -237,7 +214,7 @@ export default class BudgetTahunan extends Component {
indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id) indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id)
} }
this.setState({ listCompany: defaultProps, company: indexID == null? companyData[0] : companyData[indexID]}, () => { this.setState({ listCompany: defaultProps, company: indexID == null ? companyData[0] : companyData[indexID] }, () => {
// // console.log(response.data.data); // // console.log(response.data.data);
if (response.data.data.length > 0) { if (response.data.data.length > 0) {
this.getRevision() this.getRevision()
...@@ -247,7 +224,7 @@ export default class BudgetTahunan extends Component { ...@@ -247,7 +224,7 @@ export default class BudgetTahunan extends Component {
// //
}) })
} else { } else {
this.setState({ listRevision: null, revision: null, dataTable: [], checkApprover: false, lastRevision: "", visibleTableHistory: false, loading: false }, ()=> { this.setState({ listRevision: null, revision: null, dataTable: [], checkApprover: false, lastRevision: "", visibleTableHistory: false, loading: false }, () => {
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
}) })
} }
...@@ -307,22 +284,22 @@ export default class BudgetTahunan extends Component { ...@@ -307,22 +284,22 @@ export default class BudgetTahunan extends Component {
}) })
let dataTableRevision = [] let dataTableRevision = []
response.data.data.map((item, index) => { response.data.data.map((item, index) => {
if (item.report_name !== 'Cash Flow') { if (item.report_name !== 'Cash Flow') {
dataTableRevision.push([ dataTableRevision.push([
item.report_id, item.report_id,
item.report_name === 'CAT' ? 'Corporate Annual Target' : item.report_name, item.report_name === 'CAT' ? 'Corporate Annual Target' : item.report_name,
"", "",
item.number item.number
]) ])
} }
}) })
// // console.log(dataTableRevision); // // console.log(dataTableRevision);
this.setState({ dataTable, loading: false, dataTableRevision: dataTableRevision.sort((a,b) => a.number - b.number), dataForRevision: response.data.data }, ()=> { this.setState({ dataTable, loading: false, dataTableRevision: dataTableRevision.sort((a, b) => a.number - b.number), dataForRevision: response.data.data }, () => {
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
}) })
} }
} else { } else {
this.setState({ loading: false }, ()=> { this.setState({ loading: false }, () => {
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
}) })
} }
...@@ -489,24 +466,24 @@ export default class BudgetTahunan extends Component { ...@@ -489,24 +466,24 @@ export default class BudgetTahunan extends Component {
this.setState({ listRevision: defaultProps, revision: revisionData[0] }, () => { this.setState({ listRevision: defaultProps, revision: revisionData[0] }, () => {
this.getSubmission() this.getSubmission()
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => { setTimeout(() => {
localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
window.location.reload(); window.location.reload();
}, 1000); }, 1000);
} }
}) })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listRevision: null, revision: null }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listRevision: null, revision: null })
} }
}) })
} }
getSubmission() { getSubmission() {
this.setState({ loading: true }, ()=> { this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
}) })
let payload = { let payload = {
...@@ -532,7 +509,7 @@ export default class BudgetTahunan extends Component { ...@@ -532,7 +509,7 @@ export default class BudgetTahunan extends Component {
this.getLatestPeriodSubmit() this.getLatestPeriodSubmit()
api.create().checkApprover().then(response => { api.create().checkApprover().then(response => {
// // console.log(response); // // console.log(response);
if (this.state.btncreate === true && this.state.btnedit === true ) { if (this.state.btncreate === true && this.state.btnedit === true) {
this.setState({ isApprover: false, checkApprover: false }) this.setState({ isApprover: false, checkApprover: false })
} else { } else {
this.setState({ isApprover: true, checkApprover: true }) this.setState({ isApprover: true, checkApprover: true })
...@@ -540,20 +517,20 @@ export default class BudgetTahunan extends Component { ...@@ -540,20 +517,20 @@ export default class BudgetTahunan extends Component {
}) })
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', submissionID: null, loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', submissionID: null, loading: false }, () => {
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => { setTimeout(() => {
localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
window.location.reload(); window.location.reload();
}, 1000); }, 1000);
} }
}) })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -581,7 +558,7 @@ export default class BudgetTahunan extends Component { ...@@ -581,7 +558,7 @@ export default class BudgetTahunan extends Component {
approvalSubmission(type) { approvalSubmission(type) {
this.scrollToMyRef() this.scrollToMyRef()
this.setState({ loading: true }, ()=> { this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
}) })
let body = { let body = {
...@@ -744,7 +721,7 @@ export default class BudgetTahunan extends Component { ...@@ -744,7 +721,7 @@ export default class BudgetTahunan extends Component {
} }
saveToMasterBudget(data) { saveToMasterBudget(data) {
this.setState({ loading: true }, ()=> { this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
}) })
// // console.log(JSON.stringify(data)); // // console.log(JSON.stringify(data));
...@@ -778,7 +755,7 @@ export default class BudgetTahunan extends Component { ...@@ -778,7 +755,7 @@ export default class BudgetTahunan extends Component {
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_attachment?fileName=${fileurl}&&fileType=${fileType}` `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_attachment?fileName=${fileurl}&&fileType=${fileType}`
) )
res = await res.blob() res = await res.blob()
this.setState({ loading: false }, ()=> { this.setState({ loading: false }, () => {
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
}) })
if (res.size > 0) { if (res.size > 0) {
...@@ -791,7 +768,7 @@ export default class BudgetTahunan extends Component { ...@@ -791,7 +768,7 @@ export default class BudgetTahunan extends Component {
} }
validate() { validate() {
this.setState({ loading: true }, ()=> { this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
}) })
let array = [] let array = []
...@@ -822,7 +799,7 @@ export default class BudgetTahunan extends Component { ...@@ -822,7 +799,7 @@ export default class BudgetTahunan extends Component {
} }
}) })
} else { } else {
this.setState({ alert: true, messageAlert: 'Data Is Not Complete', tipeAlert: 'warning', loading: false }, ()=> { this.setState({ alert: true, messageAlert: 'Data Is Not Complete', tipeAlert: 'warning', loading: false }, () => {
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
}) })
} }
...@@ -1040,10 +1017,10 @@ export default class BudgetTahunan extends Component { ...@@ -1040,10 +1017,10 @@ export default class BudgetTahunan extends Component {
number: value[3] number: value[3]
} }
let indexDataRevisi = this.state.dataTableRevision.findIndex((val) => val[3] == value[3]) let indexDataRevisi = this.state.dataTableRevision.findIndex((val) => val[3] == value[3])
let indexId = detailRevisiCheck.sort((a,b) => a.number - b.number).findIndex((val) => val.number == value[3]) let indexId = detailRevisiCheck.sort((a, b) => a.number - b.number).findIndex((val) => val.number == value[3])
// console.log(indexId) // console.log(indexId)
if (indexId == -1) { if (indexId == -1) {
this.state.dataTableRevision.map((item,index) => { this.state.dataTableRevision.map((item, index) => {
if (index > indexDataRevisi) { if (index > indexDataRevisi) {
let indexIds = detailRevisiCheck.findIndex((val) => val.number == item[3]) let indexIds = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIds == -1) { if (indexIds == -1) {
...@@ -1058,15 +1035,15 @@ export default class BudgetTahunan extends Component { ...@@ -1058,15 +1035,15 @@ export default class BudgetTahunan extends Component {
}) })
detailRevisiCheck.push(payload) detailRevisiCheck.push(payload)
} else { } else {
let x = 0 let x = 0
detailRevisiCheck.sort((a,b) => a.number - b.number).map((item,index) => { detailRevisiCheck.sort((a, b) => a.number - b.number).map((item, index) => {
if (item.number < value[3]) { if (item.number < value[3]) {
x += 1 x += 1
} }
}) })
if (x < 1) { if (x < 1) {
this.state.dataTableRevision.map((item,index) => { this.state.dataTableRevision.map((item, index) => {
if (index > indexDataRevisi) { if (index > indexDataRevisi) {
let indexIdz = detailRevisiCheck.findIndex((val) => val.number == item[3]) let indexIdz = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIdz !== -1) { if (indexIdz !== -1) {
...@@ -1077,7 +1054,7 @@ export default class BudgetTahunan extends Component { ...@@ -1077,7 +1054,7 @@ export default class BudgetTahunan extends Component {
detailRevisiCheck.splice(indexId, 1) detailRevisiCheck.splice(indexId, 1)
} }
} }
this.setState({ detailRevisiCheck: detailRevisiCheck.sort((a,b) => a.number - b.number) }) this.setState({ detailRevisiCheck: detailRevisiCheck.sort((a, b) => a.number - b.number) })
// console.log(detailRevisiCheck) // console.log(detailRevisiCheck)
} }
...@@ -1326,7 +1303,7 @@ export default class BudgetTahunan extends Component { ...@@ -1326,7 +1303,7 @@ export default class BudgetTahunan extends Component {
</div> </div>
)} )}
</div> </div>
{this.state.isAdmin && this.state.lastStatus == 'APPROVED'? {this.state.isAdmin && this.state.lastStatus == 'APPROVED' ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}> <div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" /> <div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}> <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
...@@ -1359,76 +1336,9 @@ export default class BudgetTahunan extends Component { ...@@ -1359,76 +1336,9 @@ export default class BudgetTahunan extends Component {
</button> */} </button> */}
</div> </div>
</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' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() =>
this.approvalSubmission('review')
}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Review</Typography>
</div>
</button>
</div> : (this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' && this.state.btnApprove) ?
<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',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
</div>
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<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> : null
: :
(this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && this.state.isSubmit === true ? this.state.checkApprover === true ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} > this.state.lastStatus === 'WAITING FOR REVIEW' ?
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.validate()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
</div>
</button>
</div> :
this.state.lastStatus === 'SUBMITTED' && this.state.submitter ?
<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
style={{ style={{
...@@ -1437,13 +1347,80 @@ export default class BudgetTahunan extends Component { ...@@ -1437,13 +1347,80 @@ export default class BudgetTahunan extends Component {
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
}} }}
onClick={() => this.approvalSubmission('cancel')} onClick={() =>
this.approvalSubmission('review')
}
> >
<div style={{ backgroundColor: 'gray', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Review</Typography>
</div> </div>
</button> </button>
</div> : null </div> : (this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' && this.state.btnApprove) ?
<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',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
</div>
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<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> : null
:
(this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && this.state.isSubmit === true ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.validate()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
</div>
</button>
</div> :
this.state.lastStatus === 'SUBMITTED' && this.state.submitter ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('cancel')}
>
<div style={{ backgroundColor: 'gray', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div> : null
} }
</Paper> </Paper>
......
...@@ -54,7 +54,7 @@ export default class MonthlyReport extends Component { ...@@ -54,7 +54,7 @@ export default class MonthlyReport extends Component {
alert: false, alert: false,
tipeAlert: '', tipeAlert: '',
messageAlert: '', messageAlert: '',
btncreate: false, btnCreate: false,
loadview: false loadview: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -69,8 +69,10 @@ export default class MonthlyReport extends Component { ...@@ -69,8 +69,10 @@ export default class MonthlyReport extends Component {
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ this.setState({
btncreate: response.data.data.create, btnCreate: response.data.data.create,
loadview: response.data.data.view btnEdit: response.data.data.edit
}, () => {
this.getChecApprover()
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -89,7 +91,6 @@ export default class MonthlyReport extends Component { ...@@ -89,7 +91,6 @@ export default class MonthlyReport extends Component {
} }
componentDidMount() { componentDidMount() {
this.getChecApprover()
this.getPermission() this.getPermission()
this.setState({ loading: true }) this.setState({ loading: true })
// this.getCompanyActive() // this.getCompanyActive()
...@@ -100,14 +101,13 @@ export default class MonthlyReport extends Component { ...@@ -100,14 +101,13 @@ export default class MonthlyReport extends Component {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
// console.log(response); if (response.data.data.is_approver === true) {
// if (response.data.data.is_approver === true) { this.setState({ isApprover: true, checkApprover: true }, () =>
// this.setState({ isApprover: true, checkApprover: true }, () => this.getPeriode())
// this.getPeriode()) } else {
// } else {
this.setState({ isApprover: false, checkApprover: false }, () => this.setState({ isApprover: false, checkApprover: false }, () =>
this.getCompanyActive()) this.getCompanyActive())
// } }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -455,12 +455,13 @@ export default class MonthlyReport extends Component { ...@@ -455,12 +455,13 @@ export default class MonthlyReport extends Component {
this.getReportAttachment() this.getReportAttachment()
api.create().checkApproverMonthly().then(response => { api.create().checkApproverMonthly().then(response => {
// // console.log(response); // // console.log(response);
if (response.data.data.is_approver === true) { if (this.state.btnCreate === true && this.state.btnEdit === true) {
this.setState({ isApprover: true, checkApprover: true }) console.log('editable');
} else {
this.setState({ isApprover: false, checkApprover: false }) this.setState({ isApprover: false, checkApprover: false })
} else {
console.log('just view');
this.setState({ isApprover: true, checkApprover: true })
} }
}) })
}) })
} else { } else {
...@@ -1106,6 +1107,7 @@ export default class MonthlyReport extends Component { ...@@ -1106,6 +1107,7 @@ export default class MonthlyReport extends Component {
month={this.state.month} month={this.state.month}
saveToMonthlyReport={this.saveToMonthlyReport.bind(this)} saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
onClickClose={() => this.setState({ visibleBS: false, visibleMonthlyReport: true })} onClickClose={() => this.setState({ visibleBS: false, visibleMonthlyReport: true })}
isApprover={this.state.isApprover}
// getReport={this.getCompanyActive.bind(this)} // getReport={this.getCompanyActive.bind(this)}
/> />
)} )}
...@@ -1139,7 +1141,7 @@ export default class MonthlyReport extends Component { ...@@ -1139,7 +1141,7 @@ export default class MonthlyReport extends Component {
month={this.state.month} month={this.state.month}
saveToMonthlyReport={this.saveToMonthlyReport.bind(this)} saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
onClickClose={() => this.setState({ visibleTP: false, visibleMonthlyReport: true })} onClickClose={() => this.setState({ visibleTP: false, visibleMonthlyReport: true })}
btncreate={this.state.btncreate} btnCreate={this.state.btnCreate}
loadview={this.state.loadview} loadview={this.state.loadview}
// getReport={this.getCompanyActive.bind(this)} // getReport={this.getCompanyActive.bind(this)}
/> />
......
...@@ -1014,10 +1014,10 @@ export default class BalanceSheetMR extends Component { ...@@ -1014,10 +1014,10 @@ export default class BalanceSheetMR extends Component {
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: this.props.isApprover ? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={false} disabled={this.props.isApprover}
value={Number(tableMeta.rowData[9]).toFixed(1)} value={Number(tableMeta.rowData[9]).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
...@@ -1684,55 +1684,78 @@ export default class BalanceSheetMR extends Component { ...@@ -1684,55 +1684,78 @@ export default class BalanceSheetMR extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> {this.props.isApprover === true ?
<a data-tip={'Download Template'} data-for="template"> <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button <a data-tip={'Download'} data-for="download">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
margin: 5 borderColor: 'transparent',
}} margin: 5
onClick={() => this.downloadTemplate()} }}
> onClick={() =>
<img src={Images.template} /> this.setState({ loading: true }, () => {
</button> setTimeout(() => {
</a> this.downloadAllData()
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" /> }, 100);
<a data-tip={'Upload'} data-for="upload"> })}
<button >
style={{ <img src={Images.download} />
backgroundColor: 'transparent', </button>
cursor: 'pointer', </a>
borderColor: 'transparent', <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
margin: 5 </div> :
}} <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
onClick={() => this.setState({ visibleUpload: true })} <a data-tip={'Download Template'} data-for="template">
> <button
<img src={Images.upload} /> style={{
</button> backgroundColor: 'transparent',
</a> cursor: 'pointer',
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" /> borderColor: 'transparent',
<a data-tip={'Download'} data-for="download"> margin: 5
<button }}
style={{ onClick={() => this.downloadTemplate()}
backgroundColor: 'transparent', >
cursor: 'pointer', <img src={Images.template} />
borderColor: 'transparent', </button>
margin: 5 </a>
}} <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
onClick={() => <a data-tip={'Upload'} data-for="upload">
this.setState({ loading: true }, () => { <button
setTimeout(() => { style={{
this.downloadAllData() backgroundColor: 'transparent',
}, 100); cursor: 'pointer',
})} borderColor: 'transparent',
> margin: 5
<img src={Images.download} /> }}
</button> onClick={() => this.setState({ visibleUpload: true })}
</a> >
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> <img src={Images.upload} />
</div> </button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
}, 100);
})}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
</div>
}
</div> </div>
</div> </div>
...@@ -1774,76 +1797,80 @@ export default class BalanceSheetMR extends Component { ...@@ -1774,76 +1797,80 @@ export default class BalanceSheetMR extends Component {
</div> </div>
</button> </button>
</div> </div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}> {this.props.isApprover === true ?
<button <div className="col-2">
className="button" </div> :
type="button" <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
style={{ <button
backgroundColor: 'transparent', className="button"
cursor: 'pointer', type="button"
borderColor: 'transparent', style={{
outline: 'none', backgroundColor: 'transparent',
marginRight: 20 cursor: 'pointer',
}} borderColor: 'transparent',
onClick={() => { outline: 'none',
this.setState({ loading: true }, () => { marginRight: 20
setTimeout(() => { }}
this.setState({ loading: false }) onClick={() => {
// this.handleValidate() this.setState({ loading: true }, () => {
}, 100); setTimeout(() => {
}) this.setState({ loading: false })
}} // this.handleValidate()
> }, 100);
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}> })
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography> }}
</div> >
</button> <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<button <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
className="button" </div>
type="button" </button>
style={{ <button
backgroundColor: 'transparent', className="button"
cursor: this.state.saveDraft !== true ? 'pointer' : 'default', type="button"
borderColor: 'transparent', style={{
outline: 'none', backgroundColor: 'transparent',
marginRight: 20 cursor: this.state.saveDraft !== true ? 'pointer' : 'default',
}} borderColor: 'transparent',
onClick={() => outline: 'none',
this.state.saveDraft === true ? marginRight: 20
null : }}
this.state.handleTekTekTek == 1 ? null : onClick={() =>
this.setState({ handleTekTekTek: 1 }, () => { this.state.saveDraft === true ?
this.backToMonthlyReport('draft') null :
}) this.state.handleTekTekTek == 1 ? null :
} this.setState({ handleTekTekTek: 1 }, () => {
> this.backToMonthlyReport('draft')
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> })
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography> }
</div> >
</button> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<button <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
type="button" </div>
// disabled={this.state.buttonError} </button>
onClick={() => <button
this.state.buttonError ? type="button"
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) // disabled={this.state.buttonError}
: onClick={() =>
this.state.handleTekTekTek == 1 ? null : this.state.buttonError ?
this.setState({ handleTekTekTek: 1 }, () => { this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
this.backToMonthlyReport('submitted') :
})} this.state.handleTekTekTek == 1 ? null :
style={{ this.setState({ handleTekTekTek: 1 }, () => {
backgroundColor: 'transparent', this.backToMonthlyReport('submitted')
cursor: this.state.buttonError === true ? 'default' : 'pointer', })}
borderColor: 'transparent', style={{
outline: 'none', backgroundColor: 'transparent',
}} cursor: this.state.buttonError === true ? 'default' : 'pointer',
> borderColor: 'transparent',
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> outline: 'none',
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography> }}
</div> >
</button> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
</div> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
</div>
</button>
</div>
}
</div> </div>
{/* : null {/* : null
} */} } */}
......
...@@ -131,7 +131,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -131,7 +131,7 @@ export default class FixedAssetsMovementMR extends Component {
} }
} }
}) })
console.log(dataTable); // console.log(dataTable);
this.setState({ dataTable, loading: false }) this.setState({ dataTable, loading: false })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
...@@ -407,7 +407,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -407,7 +407,7 @@ export default class FixedAssetsMovementMR extends Component {
// console.log(tableMeta); // console.log(tableMeta);
// console.log(tst); // console.log(tst);
let indexID = dataTable2[tableMeta.rowIndex][16].findIndex((val) => val.item_formula == tst) let indexID = dataTable2[tableMeta.rowIndex][16].findIndex((val) => val.item_formula == tst)
console.log(indexID); // console.log(indexID);
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = dataTable2[tableMeta.rowIndex][16][indexID].value let valuezz = dataTable2[tableMeta.rowIndex][16][indexID].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