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

update buanyak rek

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