Commit 8c9c1125 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

update month periode

See merge request !1099
parents b76eabbb 7d6e8282
...@@ -449,7 +449,7 @@ export default class BudgetTahunan extends Component { ...@@ -449,7 +449,7 @@ export default class BudgetTahunan extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, getOptionLabel: (option) => option.periode,
}; };
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod) let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode) let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// // console.log(this.props.location.state.rawData) // // console.log(this.props.location.state.rawData)
// console.log(this.state.lastPeriod) // console.log(this.state.lastPeriod)
......
...@@ -100,8 +100,13 @@ class HomePage extends Component { ...@@ -100,8 +100,13 @@ class HomePage extends Component {
options: MR, options: MR,
getOptionLabel: (option) => option.name, getOptionLabel: (option) => option.name,
}; };
// console.log(MR[MR.length - 1])
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let yearNow = dateNow.getFullYear()
let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
this.setState({listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[MR.length - 1]}, () => { this.setState({listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[indexMonthMR]}, () => {
this.getListUserSubcoMB() this.getListUserSubcoMB()
this.getListUserSubcoMR() this.getListUserSubcoMR()
}) })
...@@ -109,9 +114,10 @@ class HomePage extends Component { ...@@ -109,9 +114,10 @@ class HomePage extends Component {
getMonth() { getMonth() {
api.create().getMonthTransaction().then(response => { api.create().getMonthTransaction().then(response => {
let dateNow = new Date let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let month = format(dateNow, 'MMMM') let month = format(dateNow, 'MMMM')
console.log(response); // console.log(month);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
// console.log(response); // console.log(response);
...@@ -312,7 +318,7 @@ class HomePage extends Component { ...@@ -312,7 +318,7 @@ class HomePage extends Component {
let listDashboard = [] let listDashboard = []
let rawData = [] let rawData = []
api.create().getDashboard().then((response) => { api.create().getDashboard().then((response) => {
// console.log(response); console.log(response);
if (String(response.data.status).toLocaleLowerCase() == 'success') { if (String(response.data.status).toLocaleLowerCase() == 'success') {
let data = response.data.data let data = response.data.data
data.map((item, index) => { data.map((item, index) => {
...@@ -398,6 +404,14 @@ class HomePage extends Component { ...@@ -398,6 +404,14 @@ class HomePage extends Component {
} }
render() { render() {
const getDataMonth = (item) => {
let months = item.months
let dataMonth = this.state.listMonth.options
let indexID = dataMonth.findIndex((val) => val.month_id == months)
// console.log(dataMonth[indexID])
return dataMonth[indexID]
}
const columns = ["#", "ID", "Company", "Report Type", "Revision", const columns = ["#", "ID", "Company", "Report Type", "Revision",
{ {
name: "", name: "",
...@@ -416,7 +430,7 @@ class HomePage extends Component { ...@@ -416,7 +430,7 @@ class HomePage extends Component {
state: { state: {
userType: 'approver', userType: 'approver',
rawData: this.state.rawData[tableMeta.rowIndex], rawData: this.state.rawData[tableMeta.rowIndex],
month: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? null : this.state.month month: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? null : getDataMonth(this.state.rawData[tableMeta.rowIndex])
} }
}}> }}>
<button <button
......
...@@ -165,8 +165,13 @@ export default class SubHolding extends Component { ...@@ -165,8 +165,13 @@ export default class SubHolding extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, getOptionLabel: (option) => option.periode,
}; };
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod) let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode) let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let yearNow = dateNow.getFullYear()
console.log(yearNow)
console.log(periode)
let index = data.sort((a, b) => a - b).findIndex((val) => val == String(this.state.report.label).toLocaleLowerCase().includes('summary') ? yearNow : periode)
// console.log(data) // console.log(data)
// console.log(this.state.latestPeriode) // console.log(this.state.latestPeriode)
...@@ -189,8 +194,9 @@ export default class SubHolding extends Component { ...@@ -189,8 +194,9 @@ export default class SubHolding extends Component {
getMonth() { getMonth() {
api.create().getMonthTransaction().then(response => { api.create().getMonthTransaction().then(response => {
let dateNow = new Date let dateNow = new Date()
let month = format(dateNow, 'MMMM') dateNow.setMonth(dateNow.getMonth() - 1);
let month = format(dateNow, 'MMMM')
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
...@@ -832,7 +838,7 @@ export default class SubHolding extends Component { ...@@ -832,7 +838,7 @@ export default class SubHolding extends Component {
FRID = null FRID = null
} }
this.setState({ FRID }, () => { this.setState({ FRID }, () => {
let payloads = {...payload, submission_id: this.state.FRID, months: this.state.month.month_id, quarter: 0} let payloads = {...payload, report_id: 29, submission_id: this.state.FRID, months: this.state.month.month_id, quarter: 0}
api.create().getReportFR(payloads).then(response => { api.create().getReportFR(payloads).then(response => {
console.log(payload); console.log(payload);
console.log(response); console.log(response);
......
...@@ -307,7 +307,8 @@ export default class MonthlyReport extends Component { ...@@ -307,7 +307,8 @@ export default class MonthlyReport extends Component {
getMonth() { getMonth() {
api.create().getMonthTransaction().then(response => { api.create().getMonthTransaction().then(response => {
let dateNow = new Date let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let month = format(dateNow, 'MMMM') let month = format(dateNow, 'MMMM')
console.log(response); console.log(response);
if (response.data) { if (response.data) {
...@@ -402,11 +403,16 @@ export default class MonthlyReport extends Component { ...@@ -402,11 +403,16 @@ export default class MonthlyReport extends Component {
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 periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod === undefined ? String(Number(currentYear)) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode) 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(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 && this.state.submittedOnly) { // if (this.state.isApprover === true && this.state.submittedOnly) {
this.getDetailUser() this.getDetailUser()
......
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