Commit 0932a41f authored by Deni Rinaldi's avatar Deni Rinaldi

udh dulu kali

parent 014a991a
......@@ -205,6 +205,7 @@ const create = (type = "") => {
const approvalSubmission = (body) => api.post('transaction/master_budget/approval_submission', body)
const getCompanySubmitted = (body) => api.post('transaction/master_budget/get_company_submitted', body)
const getLastPeriod = (idCompany) => api.get(`transaction/master_budget/get_last_periode/${idCompany}`)
const getSubmitMasterBudget = (body) => api.post('transaction/master_budget/get_latest_periode_submit', body)
const getIdDeleteFromExcel = (body) => api.post('transaction/master_budget/delete_from_excel', body)
const getOpetratingIndID = (body) => api.post('transaction/get_operating_indicator_id', body)
......@@ -369,7 +370,8 @@ const create = (type = "") => {
checkApprover,
approvalSubmission,
getCompanySubmitted,
getLastPeriod
getLastPeriod,
getSubmitMasterBudget
}
}
......
......@@ -184,7 +184,9 @@ export default class BudgetTahunan extends Component {
]
})
// console.log(dataTable);
this.setState({ dataTable, loading: false, dataTableRevision, dataForRevision: response.data.data })
this.setState({ dataTable, loading: false, dataTableRevision, dataForRevision: response.data.data }, () => {
this.getLatestPeriodSubmit()
})
}
} else {
this.setState({ loading: false })
......@@ -192,6 +194,21 @@ export default class BudgetTahunan extends Component {
})
}
getLatestPeriodSubmit() {
let body = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode
}
api.create().getSubmitMasterBudget(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({ isSubmit: response.data.data.is_can_submit })
}
}
})
}
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
......@@ -209,6 +226,7 @@ export default class BudgetTahunan extends Component {
getCompanyActive() {
api.create().getPerusahaanActive().then((response) => {
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
......@@ -233,7 +251,7 @@ export default class BudgetTahunan extends Component {
getOptionLabel: (option) => titleCase(option.company_name),
};
let index = arrayBaru.findIndex((val) => val.company_id == comID)
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
this.getLastPeriod()
})
} else {
......@@ -252,11 +270,11 @@ export default class BudgetTahunan extends Component {
})
}
getLastPeriod(){
getLastPeriod() {
api.create().getLastPeriod(this.state.company.company_id).then(response => {
console.log(response);
if (response.data.status === "success") {
this.setState({ lastPeriod : response.data.data.last_periode, latestPeriode: response.data.data.latest_periode}, ()=> {
this.setState({ lastPeriod: response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => {
this.getPeriode()
})
}
......@@ -268,7 +286,7 @@ export default class BudgetTahunan extends Component {
// let dateNow = new Date
// let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy')
let currentYear = new Date().getFullYear()
console.log(currentYear)
// console.log(currentYear)
if (response.data) {
if (response.data.status === "success") {
let data = []
......@@ -292,12 +310,11 @@ export default class BudgetTahunan extends Component {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
console.log(this.state.lastPeriod);
let index = data.sort((a, b) => a - b).findIndex((val) => val === (this.state.lastPeriod == ""? String(Number(currentYear) + 1) : this.state.lastPeriod))
console.log(data)
console.log(this.state.lastPeriod)
console.log(periodeData)
console.log(index)
let index = data.sort((a, b) => a - b).findIndex((val) => val === (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod))
// console.log(data)
// console.log(this.state.lastPeriod)
// console.log(periodeData)
// console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
if (this.state.isApprover === true) {
this.getCompanySubmitted()
......@@ -349,7 +366,7 @@ export default class BudgetTahunan extends Component {
if (response) {
if (response.data.status === "success") {
this.setState({
submissionID: response.data.data.submission_id, isSubmit: false,
submissionID: response.data.data.submission_id,
submitter: response.data.data.submitter,
approverID: response.data.data.approve_id, pic: response.data.data.approver == null ? '' : response.data.data.approver,
lastStatus: response.data.data.last_status === null ? 'SUBMIT' : response.data.data.last_status,
......@@ -1090,7 +1107,7 @@ export default class BudgetTahunan extends Component {
</div>
</div> : null
:
this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION' ?
(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={{
......
This diff is collapsed.
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