Commit ad779c59 authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into rifka

parents 57b57450 6590125a
......@@ -201,6 +201,7 @@ const create = (type = "") => {
const countingFormula = (body) => api.post('transaction/counting_formula', 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 checkApprover = () => api.get('transaction/master_budget/is_approver')
const getIdDeleteFromExcel = (body) => api.post('transaction/master_budget/delete_from_excel', body)
const getOpetratingIndID = (body) => api.post('transaction/get_operating_indicator_id', body)
......@@ -361,7 +362,8 @@ const create = (type = "") => {
checkIsSubmit,
getIdDeleteFromExcel,
getDashboard,
historyApproval
historyApproval,
checkApprover
}
}
......
......@@ -50,13 +50,32 @@ export default class BudgetTahunan extends Component {
messageAlert: '',
submissionID: null,
isSubmit: false,
visibleTableHistory: false
visibleTableHistory: false,
isApprover: false,
lastStatus: ""
}
this.fileHandler = this.fileHandler.bind(this);
}
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() {
......@@ -221,13 +240,17 @@ export default class BudgetTahunan extends Component {
getSubmission() {
let payload = {
"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 => {
console.log(response)
if (response) {
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.historyApproval()
})
......@@ -240,7 +263,8 @@ export default class BudgetTahunan extends Component {
historyApproval() {
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 => {
console.log(response);
......@@ -260,17 +284,17 @@ export default class BudgetTahunan extends Component {
}
checkIsSubmit() {
let body = {
"submission_id": this.state.submissionID
}
api.create().checkIsSubmit(body).then(response => {
// console.log(response);
if (response.data) {
if (response.data.status === "Success") {
this.setState({ isSubmit: response.data.data.result })
}
}
})
// let body = {
// "submission_id": this.state.submissionID
// }
// api.create().checkIsSubmit(body).then(response => {
// console.log(response.data.data.result);
// if (response.data) {
// if (response.data.status === "Success") {
// this.setState({ isSubmit: response.data.data.result })
// }
// }
// })
}
clickDetail(item, id, revision, status) {
......@@ -415,30 +439,41 @@ export default class BudgetTahunan extends Component {
validate() {
let array = []
let canSubmit = true
this.state.dataTable.map(item => {
if (item[3].includes("not-yet") || item[3].includes("draft")) {
array.push(item[3])
} else {
if (item[1] !== 'Cash Flow') {
if (item[3] !== "submitted") {
canSubmit = false
array.push(item[3])
}
})
// if (array.includes("not-yet" || "draft")) {
// console.log('gagal');
}
// if (item[3].includes("not-yet") || item[3].includes("draft")) {
// array.push(item[3])
// } else {
// console.log('masuk');
// array.push(item[3])
// }
})
if (canSubmit === true) {
let body = {
submission_id: this.state.submissionID
}
if (this.state.isSubmit === true) {
api.create().submitMasterBudget(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "Success") {
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() {
......@@ -490,6 +525,8 @@ export default class BudgetTahunan extends Component {
<span>Revisi</span> :
val === "approval_proccess" ?
<span>Approval Proccess</span> :
val === "approval_review" ?
<span>Approval Review</span> :
val === "not-yet" ?
null :
<img src={Images.cross} style={{ width: 31, height: 24 }} />
......@@ -580,6 +617,7 @@ export default class BudgetTahunan extends Component {
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
this.getRevision()
this.getReport()
this.getReportAttachment()
......@@ -598,6 +636,7 @@ export default class BudgetTahunan extends Component {
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
this.getRevision()
this.getReport()
this.getReportAttachment()
......@@ -684,6 +723,32 @@ export default class BudgetTahunan extends Component {
}
</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 && (
<div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}>
......@@ -696,21 +761,89 @@ export default class BudgetTahunan extends Component {
</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' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: this.state.isSubmit === true ? 'pointer' : 'cursor',
cursor: 'pointer',
borderColor: 'transparent',
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' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
</div>
</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>
</button>
</div> : null
}
</Paper>
</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