Commit 5914325e authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'riri' into 'master'

oi

See merge request !730
parents 0d006551 b9a33541
...@@ -1148,6 +1148,7 @@ export default class MonthlyReport extends Component { ...@@ -1148,6 +1148,7 @@ export default class MonthlyReport extends Component {
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
month={this.state.month} month={this.state.month}
onClickClose={() => this.setState({ visibleOI: false, visibleMonthlyReport: true })}
/> />
)} )}
</div > </div >
......
This diff is collapsed.
...@@ -11,6 +11,7 @@ import { ExcelRenderer } from 'react-excel-renderer'; ...@@ -11,6 +11,7 @@ import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { format } from 'date-fns'; import { format } from 'date-fns';
import Constant from '../../library/Constant'; import Constant from '../../library/Constant';
import OperatingIndicatorMR from '../MonthlyReport/OperatingIndicatorMR';
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -27,8 +28,11 @@ export default class OperatingIndicator extends Component { ...@@ -27,8 +28,11 @@ export default class OperatingIndicator extends Component {
revision: null, revision: null,
visibleOperatingIndicator: true, visibleOperatingIndicator: true,
visibleDetailOpt: false, visibleDetailOpt: false,
visibleDetailMonthly: false,
visibleDetailRolling: false,
listPeriode: null, listPeriode: null,
periode: null, periode: null,
month: null,
listCompany: null, listCompany: null,
company: null, company: null,
report_id: null, report_id: null,
...@@ -75,7 +79,7 @@ export default class OperatingIndicator extends Component { ...@@ -75,7 +79,7 @@ export default class OperatingIndicator extends Component {
} }
getLastPeriod() { getLastPeriod() {
api.create().getLastPeriodOI(this.state.company.company_id).then(response => { api.create().getLastPeriodOI(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 }, () => {
...@@ -85,6 +89,46 @@ export default class OperatingIndicator extends Component { ...@@ -85,6 +89,46 @@ export default class OperatingIndicator extends Component {
}) })
} }
getMonth() {
api.create().getMonthTransaction().then(response => {
console.log(response);
let dateNow = new Date
let month = format(dateNow, 'MMMM')
if (response.data) {
if (response.data.status === "success") {
console.log(response);
let data = response.data.data
let monthData = data.map((item) => {
return {
month_id: item.id,
month_value: String(item.month_name).substr(0, 3)
}
})
let defaultProps = {
options: monthData,
getOptionLabel: (option) => option.month_value,
};
let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == month)
console.log(index);
this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => {
this.getLastPeriod()
})
} 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' })
}
})
}
getReportAttachment() { getReportAttachment() {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
...@@ -108,7 +152,7 @@ export default class OperatingIndicator extends Component { ...@@ -108,7 +152,7 @@ export default class OperatingIndicator extends Component {
"report_type": "operating indicator", "report_type": "operating indicator",
} }
api.create().getAllOperatingInd(payload).then(response => { api.create().getAllOperatingInd(payload).then(response => {
// console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
...@@ -189,7 +233,7 @@ export default class OperatingIndicator extends Component { ...@@ -189,7 +233,7 @@ export default class OperatingIndicator extends Component {
}; };
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : arrayBaru[0] }, () => { this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : arrayBaru[0] }, () => {
this.getLastPeriod() this.getMonth()
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -318,12 +362,46 @@ export default class OperatingIndicator extends Component { ...@@ -318,12 +362,46 @@ export default class OperatingIndicator extends Component {
clickDetail(item, id) { clickDetail(item, id) {
let index = this.state.dataReport.findIndex((val) => val.report_name == item[1]) let index = this.state.dataReport.findIndex((val) => val.report_name == item[1])
if (index !== -1) { if (index !== -1) {
this.setState({ // this.setState({
statusDetail: String(item[2]).toLocaleLowerCase(), // statusDetail: String(item[2]).toLocaleLowerCase(),
dataDetail: { ...this.state.dataReport[index], periode: this.state.periode.periode, operatingIndID: this.state.operatingIndID, company: this.state.company }, // dataDetail: { ...this.state.dataReport[index], periode: this.state.periode.periode, operatingIndID: this.state.operatingIndID, company: this.state.company },
visibleOperatingIndicator: false, // visibleOperatingIndicator: false,
visibleDetailOpt: true, // visibleDetailOpt: true,
}) // })
if (String(item[1]).toLocaleLowerCase().includes("master budget")) {
this.setState({
statusDetail: String(item[2]).toLocaleLowerCase(),
dataDetail: { ...this.state.dataReport[index], periode: this.state.periode.periode, operatingIndID: this.state.operatingIndID, company: this.state.company },
visibleOperatingIndicator: false,
visibleDetailOpt: true,
visibleDetailMonthly: false,
visibleDetailRolling: false
})
} else if (String(item[1]).toLocaleLowerCase().includes("monthly report")) {
console.log(item);
this.setState({
statusDetail: String(item[2]).toLocaleLowerCase(),
dataDetail: { ...this.state.dataReport[index], periode: this.state.periode.periode, operatingIndID: this.state.operatingIndID, company: this.state.company },
visibleOperatingIndicator: false,
visibleDetailOpt: false,
visibleDetailMonthly: true,
visibleDetailRolling: false
}, () => console.log(this.state.dataDetail))
} else {
this.setState({
statusDetail: String(item[2]).toLocaleLowerCase(),
dataDetail: { ...this.state.dataReport[index], periode: this.state.periode.periode, operatingIndID: this.state.operatingIndID, company: this.state.company },
visibleOperatingIndicator: false,
visibleDetailOpt: false,
visibleDetailMonthly: false,
visibleDetailRolling: true
})
}
} }
} }
...@@ -447,7 +525,10 @@ export default class OperatingIndicator extends Component { ...@@ -447,7 +525,10 @@ export default class OperatingIndicator extends Component {
borderColor: 'transparent' borderColor: 'transparent'
}} }}
onClick={() => onClick={() =>
tableMeta.rowData[4] ? this.clickDetail(tableMeta.rowData, tableMeta.rowData[1], tableMeta.rowData[3], tableMeta.rowData[2]) : null // tableMeta.rowData[4] ?
this.clickDetail(tableMeta.rowData, tableMeta.rowData[1], tableMeta.rowData[3], tableMeta.rowData[2])
// :
// null
} }
> >
<Typography style={{ color: tableMeta.rowData[4] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography> <Typography style={{ color: tableMeta.rowData[4] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography>
...@@ -584,6 +665,24 @@ export default class OperatingIndicator extends Component { ...@@ -584,6 +665,24 @@ export default class OperatingIndicator extends Component {
permission={{ create: this.state.buttonCreate, edit: this.state.buttonEdit, delete: this.state.buttonDelete }} permission={{ create: this.state.buttonCreate, edit: this.state.buttonEdit, delete: this.state.buttonDelete }}
/> />
} }
{this.state.visibleDetailMonthly &&
<OperatingIndicatorMR
open={this.props.open}
data={this.state.dataDetail}
height={this.props.height}
width={this.props.width}
month={this.state.month}
company={this.state.company}
onClickClose={() => this.setState({ visibleDetailMonthly: false, visibleOperatingIndicator: true }, () => {
this.getOperatingID()
this.forceUpdate()
})}
getReport={() => this.getOperatingID()}
saveOperatingInd={this.saveOperatingInd.bind(this)}
isSubmit={this.state.statusDetail == 'closed'? false : this.state.isSubmit}
permission={{ create: this.state.buttonCreate, edit: this.state.buttonEdit, delete: this.state.buttonDelete }}
/>
}
{this.state.visibleUpload && ( {this.state.visibleUpload && (
<div className="test app-popup-show"> <div className="test app-popup-show">
......
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