Commit 402123ae authored by d.arizona's avatar d.arizona

update buanyak rek

parent 99c11cb8
......@@ -274,6 +274,7 @@ const create = (type = "") => {
const checkUploadRollingOutlookOI = (body) => api.post('transaction/operating_indicator/rolling_outlook/check_import', body)
const uploadRollingOutlookOI = (body) => api.post('transaction/operating_indicator/rolling_outlook/import_rolling_outlook', body)
const submitRollingOutlook = (body) => api.post('transaction/rolling_outlook/submit_rolling_outlook', body)
const getRollingOutlookCompanySubmitted = (body) => api.post('transaction/rolling_outlook/get_company_submitted', body)
//REPORT NEW
const getAllReportBS = (body) => api.post('/transaction/db_balance_sheet/get_report_hierarki', body)
......@@ -762,7 +763,8 @@ const create = (type = "") => {
getLastestUpdateROOI,
checkUploadRollingOutlookOI,
uploadRollingOutlookOI,
submitRollingOutlook
submitRollingOutlook,
getRollingOutlookCompanySubmitted
}
}
......
......@@ -492,7 +492,7 @@ export default class MonthlyReport extends Component {
"months": this.state.month.month_id,
"status": selectedStatus
}
this.setState({ isApprovedMB: true })
// this.setState({ isApprovedMB: true })
api.create().getCompanySubmittedMonthly(body).then(response => {
console.log(response);
if (response.data) {
......
......@@ -64,10 +64,12 @@ export default class RollingOutlook extends Component {
minDateRevision: new Date(),
maxDateRevision: new Date(),
btnApprove: false,
listStatus: [],
selectedStatus: [],
quarterList: [
{value: 'q1', name: 'Q1'},
{value: 'q2', name: 'Q2'},
{value: 'q3', name: 'Q3'},
{ value: 'q1', name: 'Q1' },
{ value: 'q2', name: 'Q2' },
{ value: 'q3', name: 'Q3' },
// {value: 'ol_pa', name: 'OL PA'},
],
quarter: null
......@@ -87,31 +89,82 @@ export default class RollingOutlook extends Component {
// this.checkApprover()
// })
// } else {
this.checkApprover()
this.getPermission()
// }
}
getPermission() {
let payload = {
menu: "rolling outlook & cat revision"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
btnCreate: response.data.data.create,
btnEdit: response.data.data.edit
}, () => {
this.checkApprover()
})
} 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' })
}
})
}
checkApprover() {
let listStatus1 = [
{ name: 'Open', value: 'not-yet' },
{ name: 'Submitted', value: 'approval_review' },
{ name: 'Waiting for Review / Approval', value: 'approval_proccess' },
{ name: 'Approved', value: 'approved' },
]
let listStatus2 = [
{ name: 'Open', value: 'not-yet' },
{ name: 'Submitted', value: 'approval_review' },
{ name: 'Approved', value: 'approved' },
]
api.create().getRollingOutlookIsApprover().then(response => {
console.log(response);
if (response.data.data.is_approver === true) {
this.setState({ isApprover: true, checkApprover: true }, () =>
this.setState({ isApprover: true, checkApprover: true, listStatus: listStatus1, selectedStatus: listStatus1 }, () =>
this.getPeriode())
} else {
this.setState({ isApprover: false, checkApprover: false }, () =>
this.getDetailUser())
this.setState({ isApprover: false, checkApprover: false, listStatus: listStatus2, selectedStatus: listStatus2 }, () =>
this.getPeriode())
// this.getDetailUser())
}
})
}
getCompanySubmitted() {
let selectedStatus = this.state.selectedStatus.map((item) => {
return item.value
})
let body = {
"periode": this.state.periode.periode
"periode": this.state.periode.periode,
"quartal": this.state.quarter.value,
"status": selectedStatus
}
api.create().getCompanySubmitted(body).then(response => {
// this.setState({ isApprovedMB: true })
api.create().getRollingOutlookCompanySubmitted(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === 'success') {
if (response.data.data.length > 0) {
let data = response.data.data
let companyData = data.map((item) => {
return {
......@@ -120,23 +173,42 @@ export default class RollingOutlook extends Component {
}
})
if (companyData.length > 0) {
companyData = companyData.sort((a,b) => a.company_name.localeCompare(b.company_name))
let arrayBaru = []
this.state.userCompany.map((item, index) => {
let indexID = companyData.findIndex((val) => val.company_id == item)
if (indexID !== -1) {
arrayBaru.push(companyData[indexID])
}
})
if (arrayBaru.length > 0) {
arrayBaru = arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name))
}
let defaultProps = {
options: companyData,
options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name),
};
this.setState({ listCompany: defaultProps, company: companyData[0] }, () => {
// console.log(response.data.data);
}
let indexID = null
if (this.state.rawData !== undefined) {
indexID = arrayBaru.findIndex((val) => val.company_id == this.state.rawData.company_id)
}
// console.log(response.data.data.length)
this.setState({ listCompany: defaultProps, company: indexID == null ? arrayBaru[0] : arrayBaru[indexID], company_submit: defaultProps }, () => {
// console.log(response.data.data.length)
if (response.data.data.length > 0) {
this.getRevision()
} else {
this.setState({ listRevision: null, revision: null, dataTable: [], loading: false, checkApprover: false, lastRevision: "", visibleTableHistory: false })
// console.log(this.state.listCompany)
// console.log(this.state.company_submit)
this.setState({ listRevision: null, revision: null, dataTable: [], lastRevision: "", visibleTableHistory: false })
}
//
})
} else {
this.setState({ listRevision: null, revision: null, listCompany: null, company: null, dataTable: [], lastRevision: "", visibleTableHistory: false, loading: false }, () => {
document.body.style.overflow = 'unset';
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
......@@ -235,11 +307,41 @@ export default class RollingOutlook extends Component {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.getRole(response.data.data.role_id)
this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive()
this.getCompanySubmitted()
})
}
}
}
})
}
getRole(id) {
api.create().getDetailRole(id).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
// this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
// // // console.log(response.data.data)
if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') {
this.setState({ isAdmin: true })
}
} 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.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -259,7 +361,7 @@ export default class RollingOutlook extends Component {
})
if (companyData.length > 0) {
companyData = companyData.sort((a,b) => a.company_name.localeCompare(b.company_name))
companyData = companyData.sort((a, b) => a.company_name.localeCompare(b.company_name))
}
let arrayBaru = []
......@@ -271,7 +373,7 @@ export default class RollingOutlook extends Component {
})
if (arrayBaru.length > 0) {
arrayBaru = arrayBaru.sort((a,b) => a.company_name.localeCompare(b.company_name))
arrayBaru = arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name))
}
let defaultProps = {
......@@ -311,20 +413,21 @@ export default class RollingOutlook extends Component {
getPeriode() {
api.create().getPeriodeTransaction().then(response => {
// let dateNow = new Date
// let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy')
console.log(response)
let currentYear = new Date().getFullYear()
// console.log(currentYear)
if (response.data) {
if (response.data.status === "success") {
let data = []
response.data.data.map((item) => {
if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
if (item >= 2000 && item <= (Number(currentYear))) {
data.push(item)
}
} else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
// if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
// data.push(item)
// }
if ((item >= 2000) && (item == currentYear || item <= currentYear)) {
data.push(item)
}
}
......@@ -338,25 +441,42 @@ export default class RollingOutlook extends Component {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod === undefined ? String(Number(currentYear)) : this.state.lastPeriod)
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let yearNow = dateNow.getFullYear()
// let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
// console.log(yearNow)
let index = data.sort((a, b) => a - b).findIndex((val) => val == yearNow)
// console.log(data)
// console.log(this.state.lastPeriod)
// console.log(periodeData)
// console.log(index)
let defaultPropsQuarter = {
options: this.state.quarterList,
getOptionLabel: (option) => option.name
}
let index = data.sort((a, b) => a - b).findIndex((val) => val === (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.latestPeriode))
// console.log(data)
console.log(this.state.lastPeriod)
// console.log(periodeData)
// console.log(index)
this.setState({ listQuarter: defaultPropsQuarter, quarter: this.state.quarterList[0], listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
if (this.state.isApprover === true) {
this.getCompanySubmitted()
this.setState({ listPeriode: defaultProps, listQuarter: defaultPropsQuarter, quarter: this.state.quarterList[0], periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
// if (this.state.isApprover === true && this.state.submittedOnly) {
this.getDetailUser()
// this.getCompanySubmitted()
// console.log('masuk')
// } else {
// this.getRevision()
// }
})
} else {
this.getRevision()
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.data.message, tipeAlert: 'error' })
}
})
}
......@@ -618,8 +738,8 @@ export default class RollingOutlook extends Component {
let cobaSplit = String(fileName).split("-")
let mapSplit = ""
cobaSplit.map((item, index) => {
if (item != ""){
mapSplit+= index == 0 ? `${titleCase(item)}` : ` ${item}`
if (item != "") {
mapSplit += index == 0 ? `${titleCase(item)}` : ` ${item}`
}
})
// console.log(mapSplit);
......@@ -634,7 +754,7 @@ export default class RollingOutlook extends Component {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = "(Rolling Outlook Attachment) - " +mapSplit;
a.download = "(Rolling Outlook Attachment) - " + mapSplit;
a.click();
}
}
......@@ -682,7 +802,7 @@ export default class RollingOutlook extends Component {
validateRevision() {
let arrayRevisi = this.state.detailRevisiCheck
let remarksKosong = 0
arrayRevisi.map((item,index) => {
arrayRevisi.map((item, index) => {
if (item.remarks == "") {
remarksKosong += 1
}
......@@ -697,7 +817,7 @@ export default class RollingOutlook extends Component {
render() {
const handleMaxDate = () => {
let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
return handleDate < 0? moment(this.state.minDateRevision).format('YYYY/MM/DD') : moment(this.state.maxDateRevision).format('YYYY/MM/DD')
return handleDate < 0 ? moment(this.state.minDateRevision).format('YYYY/MM/DD') : moment(this.state.maxDateRevision).format('YYYY/MM/DD')
}
const columns = ["#", "Report Type",
{
......@@ -943,10 +1063,10 @@ export default class RollingOutlook extends Component {
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
if (this.state.isApprover === true) {
this.setState({ visibleTableHistory: false })
if (this.state.listCompany == null) {
this.getCompanySubmitted()
} else {
this.setState({ visibleTableHistory: false })
this.getRevision()
}
})}
......@@ -966,14 +1086,35 @@ export default class RollingOutlook extends Component {
disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ quarter: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
if (this.state.listCompany == null) {
this.getCompanySubmitted()
} else {
this.getRevision()
}
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
renderInput={(params) => <TextField {...params} label="Quarter" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.quarter}
/>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
multiple
id="tags-standard"
options={this.state.listStatus}
getOptionLabel={(option) => option.name}
style={{ width: 250 }}
onChange={(event, newInputValue) => {
this.setState({ selectedStatus: newInputValue, loading: true }, () => {
console.log(newInputValue);
this.getCompanySubmitted()
})
}}
value={this.state.selectedStatus}
renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />}
/>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listCompany}
......@@ -1370,7 +1511,7 @@ export default class RollingOutlook extends Component {
id="startDate"
label="Valid From"
format="dd-MM-yyyy"
onChange={(e) => this.setState({minDateRevision: moment(e).format('YYYY/MM/DD')}, () => this.setState({maxDateRevision: handleMaxDate()}))}
onChange={(e) => this.setState({ minDateRevision: moment(e).format('YYYY/MM/DD') }, () => this.setState({ maxDateRevision: handleMaxDate() }))}
value={moment(this.state.minDateRevision).format('YYYY/MM/DD')}
KeyboardButtonProps={{
'aria-label': 'change date',
......@@ -1397,7 +1538,7 @@ export default class RollingOutlook extends Component {
id="startDate"
label="Valid To"
format="dd-MM-yyyy"
onChange={(e) => this.setState({maxDateRevision: moment(e).format('YYYY/MM/DD')})}
onChange={(e) => this.setState({ maxDateRevision: moment(e).format('YYYY/MM/DD') })}
minDate={moment(this.state.minDateRevision).format('YYYY/MM/DD')}
value={moment(this.state.maxDateRevision).format('YYYY/MM/DD')}
KeyboardButtonProps={{
......
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