Commit 19076a4b authored by Deni Rinaldi's avatar Deni Rinaldi

mamam

parent 0703d033
...@@ -201,6 +201,7 @@ const create = (type = "") => { ...@@ -201,6 +201,7 @@ const create = (type = "") => {
const countingFormula = (body) => api.post('transaction/counting_formula', body) const countingFormula = (body) => api.post('transaction/counting_formula', body)
const submitMasterBudget = (body) => api.post('transaction/master_budget/submit_master_budget', body) const submitMasterBudget = (body) => api.post('transaction/master_budget/submit_master_budget', body)
const checkIsSubmit = (body) => api.post('transaction/master_budget/is_can_submit', body) const checkIsSubmit = (body) => api.post('transaction/master_budget/is_can_submit', body)
const checkApprover = () => api.get('transaction/master_budget/is_approver')
const getIdDeleteFromExcel = (body) => api.post('transaction/master_budget/delete_from_excel', body) const getIdDeleteFromExcel = (body) => api.post('transaction/master_budget/delete_from_excel', body)
const getOpetratingIndID = (body) => api.post('transaction/get_operating_indicator_id', body) const getOpetratingIndID = (body) => api.post('transaction/get_operating_indicator_id', body)
...@@ -361,7 +362,8 @@ const create = (type = "") => { ...@@ -361,7 +362,8 @@ const create = (type = "") => {
checkIsSubmit, checkIsSubmit,
getIdDeleteFromExcel, getIdDeleteFromExcel,
getDashboard, getDashboard,
historyApproval historyApproval,
checkApprover
} }
} }
......
...@@ -50,13 +50,32 @@ export default class BudgetTahunan extends Component { ...@@ -50,13 +50,32 @@ export default class BudgetTahunan extends Component {
messageAlert: '', messageAlert: '',
submissionID: null, submissionID: null,
isSubmit: false, isSubmit: false,
visibleTableHistory: false visibleTableHistory: false,
isApprover: false,
lastStatus: ""
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
componentDidMount() { componentDidMount() {
this.getDetailUser() this.props.selectIndex('Master Budget & CAT')
if (this.props.location.state !== undefined) {
this.setState({ userType: this.props.location.state.userType })
}
this.checkApprover()
}
checkApprover() {
api.create().checkApprover().then(response => {
console.log(response);
if (response.data.data.is_approver === true) {
this.setState({ isApprover: true }, () =>
this.getDetailUser())
} else {
this.setState({ isApprover: false }, () =>
this.getDetailUser())
}
})
} }
getReportAttachment() { getReportAttachment() {
...@@ -221,13 +240,17 @@ export default class BudgetTahunan extends Component { ...@@ -221,13 +240,17 @@ export default class BudgetTahunan extends Component {
getSubmission() { getSubmission() {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
"periode": this.state.periode.periode "periode": this.state.periode.periode,
"is_approver": this.state.isApprover
} }
api.create().getSubmission(payload).then(response => { api.create().getSubmission(payload).then(response => {
console.log(response) console.log(response)
if (response) { if (response) {
if (response.data.data) { if (response.data.data) {
this.setState({ submissionID: response.data.data.submission_id, isSubmit: false }, () => { this.setState({
submissionID: response.data.data.submission_id, isSubmit: false,
lastStatus: response.data.data.last_status === null ? 'SUBMIT' : response.data.data.last_status
}, () => {
this.checkIsSubmit() this.checkIsSubmit()
this.historyApproval() this.historyApproval()
}) })
...@@ -240,7 +263,8 @@ export default class BudgetTahunan extends Component { ...@@ -240,7 +263,8 @@ export default class BudgetTahunan extends Component {
historyApproval() { historyApproval() {
let body = { let body = {
"submission_id": this.state.submissionID "company_id": this.state.company.company_id,
"periode": this.state.periode.periode
} }
api.create().historyApproval(body).then(response => { api.create().historyApproval(body).then(response => {
console.log(response); console.log(response);
...@@ -260,17 +284,17 @@ export default class BudgetTahunan extends Component { ...@@ -260,17 +284,17 @@ export default class BudgetTahunan extends Component {
} }
checkIsSubmit() { checkIsSubmit() {
let body = { // let body = {
"submission_id": this.state.submissionID // "submission_id": this.state.submissionID
} // }
api.create().checkIsSubmit(body).then(response => { // api.create().checkIsSubmit(body).then(response => {
// console.log(response); // console.log(response.data.data.result);
if (response.data) { // if (response.data) {
if (response.data.status === "Success") { // if (response.data.status === "Success") {
this.setState({ isSubmit: response.data.data.result }) // this.setState({ isSubmit: response.data.data.result })
} // }
} // }
}) // })
} }
clickDetail(item, id, revision, status) { clickDetail(item, id, revision, status) {
...@@ -415,30 +439,41 @@ export default class BudgetTahunan extends Component { ...@@ -415,30 +439,41 @@ export default class BudgetTahunan extends Component {
validate() { validate() {
let array = [] let array = []
let canSubmit = true
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[3].includes("not-yet") || item[3].includes("draft")) { if (item[1] !== 'Cash Flow') {
array.push(item[3]) if (item[3] !== "submitted") {
} else { canSubmit = false
array.push(item[3]) array.push(item[3])
} }
}) }
// if (array.includes("not-yet" || "draft")) { // if (item[3].includes("not-yet") || item[3].includes("draft")) {
// console.log('gagal'); // array.push(item[3])
// } else { // } else {
// console.log('masuk'); // array.push(item[3])
// } // }
})
if (canSubmit === true) {
let body = { let body = {
submission_id: this.state.submissionID submission_id: this.state.submissionID
} }
if (this.state.isSubmit === true) {
api.create().submitMasterBudget(body).then(response => { api.create().submitMasterBudget(body).then(response => {
console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "Success") { if (response.data.status === "Success") {
this.getCompanyActive() this.getCompanyActive()
} }
} }
}) })
} else {
this.setState({ alert: true, messageAlert: 'Data Is Not Complete', tipeAlert: 'warning' })
} }
// if (array.includes("not-yet" || "draft")) {
// console.log('gagal');
// } else {
// console.log('masuk');
// }
} }
render() { render() {
...@@ -490,6 +525,8 @@ export default class BudgetTahunan extends Component { ...@@ -490,6 +525,8 @@ export default class BudgetTahunan extends Component {
<span>Revisi</span> : <span>Revisi</span> :
val === "approval_proccess" ? val === "approval_proccess" ?
<span>Approval Proccess</span> : <span>Approval Proccess</span> :
val === "approval_review" ?
<span>Approval Review</span> :
val === "not-yet" ? val === "not-yet" ?
null : null :
<img src={Images.cross} style={{ width: 31, height: 24 }} /> <img src={Images.cross} style={{ width: 31, height: 24 }} />
...@@ -580,6 +617,7 @@ export default class BudgetTahunan extends Component { ...@@ -580,6 +617,7 @@ export default class BudgetTahunan extends Component {
{...this.state.listPeriode} {...this.state.listPeriode}
id="periode" id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
this.getRevision() this.getRevision()
this.getReport() this.getReport()
this.getReportAttachment() this.getReportAttachment()
...@@ -598,6 +636,7 @@ export default class BudgetTahunan extends Component { ...@@ -598,6 +636,7 @@ export default class BudgetTahunan extends Component {
{...this.state.listCompany} {...this.state.listCompany}
id="company" id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
this.getRevision() this.getRevision()
this.getReport() this.getReport()
this.getReportAttachment() this.getReportAttachment()
...@@ -684,6 +723,32 @@ export default class BudgetTahunan extends Component { ...@@ -684,6 +723,32 @@ export default class BudgetTahunan extends Component {
} }
</div> </div>
</div> </div>
{this.state.isApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center' }}>
<span>{this.state.lastStatus}</span>
</div> : this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center' }}>
<span>{this.state.lastStatus}</span>
</div> : null
:
this.state.lastStatus === 'SUBMITTED' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center' }}>
<span>{this.state.lastStatus}</span>
</div> :
this.state.lastStatus === 'WAITING FOR APPROVAL' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center' }}>
<span>{this.state.lastStatus}</span>
</div> :
this.state.lastStatus === 'REVISION' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center' }}>
<span>NEED REVISION</span>
</div> :
this.state.lastStatus === 'APPROVED' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center' }}>
<span>APPROVED</span>
</div> : null
}
{this.state.visibleTableHistory && ( {this.state.visibleTableHistory && (
<div style={{ marginTop: 20 }}> <div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
...@@ -696,21 +761,89 @@ export default class BudgetTahunan extends Component { ...@@ -696,21 +761,89 @@ export default class BudgetTahunan extends Component {
</div> </div>
)} )}
</div> </div>
{this.state.isApprover === 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={() => null}
>
<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' ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => null}
>
<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>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => null}
>
<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' ?
<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={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.isSubmit === true ? 'pointer' : 'cursor', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
}} }}
onClick={() => this.state.isSubmit === true ? this.validate() : null} onClick={() => this.validate()}
> >
<div style={{ backgroundColor: '#354960', 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' }}>Submit</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
</div> </div>
</button> </button>
</div> :
this.state.lastStatus === 'SUBMITTED' ?
<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={() => null}
>
<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> </div>
</button>
</div> : null
}
</Paper> </Paper>
</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