Commit 4b74ba4c authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

Deni dev(pc)

See merge request !442
parents 5955d0e4 0932a41f
...@@ -205,6 +205,7 @@ const create = (type = "") => { ...@@ -205,6 +205,7 @@ const create = (type = "") => {
const approvalSubmission = (body) => api.post('transaction/master_budget/approval_submission', body) const approvalSubmission = (body) => api.post('transaction/master_budget/approval_submission', body)
const getCompanySubmitted = (body) => api.post('transaction/master_budget/get_company_submitted', 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 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 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)
...@@ -369,7 +370,8 @@ const create = (type = "") => { ...@@ -369,7 +370,8 @@ const create = (type = "") => {
checkApprover, checkApprover,
approvalSubmission, approvalSubmission,
getCompanySubmitted, getCompanySubmitted,
getLastPeriod getLastPeriod,
getSubmitMasterBudget
} }
} }
......
...@@ -184,7 +184,9 @@ export default class BudgetTahunan extends Component { ...@@ -184,7 +184,9 @@ export default class BudgetTahunan extends Component {
] ]
}) })
// console.log(dataTable); // 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 { } else {
this.setState({ loading: false }) this.setState({ loading: false })
...@@ -192,6 +194,21 @@ export default class BudgetTahunan extends Component { ...@@ -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() { getDetailUser() {
let userId = localStorage.getItem(Constant.USER) let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => { api.create().getDetailUser(userId).then((response) => {
...@@ -209,6 +226,7 @@ export default class BudgetTahunan extends Component { ...@@ -209,6 +226,7 @@ export default class BudgetTahunan extends Component {
getCompanyActive() { getCompanyActive() {
api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
...@@ -233,7 +251,7 @@ export default class BudgetTahunan extends Component { ...@@ -233,7 +251,7 @@ export default class BudgetTahunan extends Component {
getOptionLabel: (option) => titleCase(option.company_name), getOptionLabel: (option) => titleCase(option.company_name),
}; };
let index = arrayBaru.findIndex((val) => val.company_id == comID) 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() this.getLastPeriod()
}) })
} else { } else {
...@@ -252,11 +270,11 @@ export default class BudgetTahunan extends Component { ...@@ -252,11 +270,11 @@ export default class BudgetTahunan extends Component {
}) })
} }
getLastPeriod(){ getLastPeriod() {
api.create().getLastPeriod(this.state.company.company_id).then(response => { api.create().getLastPeriod(this.state.company.company_id).then(response => {
console.log(response); console.log(response);
if (response.data.status === "success") { 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() this.getPeriode()
}) })
} }
...@@ -268,7 +286,7 @@ export default class BudgetTahunan extends Component { ...@@ -268,7 +286,7 @@ export default class BudgetTahunan extends Component {
// let dateNow = new Date // let dateNow = new Date
// let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy') // let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy')
let currentYear = new Date().getFullYear() let currentYear = new Date().getFullYear()
console.log(currentYear) // console.log(currentYear)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
let data = [] let data = []
...@@ -292,12 +310,11 @@ export default class BudgetTahunan extends Component { ...@@ -292,12 +310,11 @@ export default class BudgetTahunan extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, 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))
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(data) // console.log(this.state.lastPeriod)
console.log(this.state.lastPeriod) // console.log(periodeData)
console.log(periodeData) // 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) { if (this.state.isApprover === true) {
this.getCompanySubmitted() this.getCompanySubmitted()
...@@ -349,7 +366,7 @@ export default class BudgetTahunan extends Component { ...@@ -349,7 +366,7 @@ export default class BudgetTahunan extends Component {
if (response) { if (response) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ this.setState({
submissionID: response.data.data.submission_id, isSubmit: false, submissionID: response.data.data.submission_id,
submitter: response.data.data.submitter, submitter: response.data.data.submitter,
approverID: response.data.data.approve_id, pic: response.data.data.approver == null ? '' : response.data.data.approver, 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, lastStatus: response.data.data.last_status === null ? 'SUBMIT' : response.data.data.last_status,
...@@ -976,7 +993,7 @@ export default class BudgetTahunan extends Component { ...@@ -976,7 +993,7 @@ export default class BudgetTahunan extends Component {
: null : null
} }
</div> </div>
{!this.state.isApprover && (this.state.lastStatus !== 'SUBMITTED' && this.state.lastStatus !== 'APPROVED') && ( {!this.state.isApprover && (this.state.lastStatus !== 'SUBMITTED' && this.state.lastStatus !== 'APPROVED') && (
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
{this.state.listAttachment.length > 0 ? {this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item) => { this.state.listAttachment.map((item) => {
...@@ -1090,7 +1107,7 @@ export default class BudgetTahunan extends Component { ...@@ -1090,7 +1107,7 @@ export default class BudgetTahunan extends Component {
</div> </div>
</div> : null </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' }} > <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button <button
style={{ 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