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 {
periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId}
month={this.state.month}
onClickClose={() => this.setState({ visibleOI: false, visibleMonthlyReport: true })}
/>
)}
</div >
......
......@@ -57,7 +57,9 @@ export default class ProfitLossMR extends Component {
dataTable: [],
loading: true,
visiblePLMR: true,
valueThreshold: 0
// valueThreshold: 0,
minValue: 0,
maxValue: 0
}
}
......@@ -78,7 +80,10 @@ export default class ProfitLossMR extends Component {
if (response.data) {
if (response.data.status === 'success') {
this.setState({
valueThreshold: response.data.data[0] ? response.data.data[0].value : null
// valueThreshold: response.data.data[0] ? response.data.data[0].value : null,
minValue: response.data.data[0] ? response.data.data[0].min_value : -10,
maxValue: response.data.data[0] ? response.data.data[0].max_value : 10,
}, () => {
this.getItemHierarki()
})
......@@ -391,8 +396,8 @@ export default class ProfitLossMR extends Component {
periode: this.props.periode,
report_id: this.props.report_id,
months: this.props.month.month_id,
profit_loss: data,
status: type
status: type,
profit_loss: data
}
// console.log(data);
api.create('UPLOAD').uploadMonthlyReportPL(body).then(response => {
......@@ -686,7 +691,7 @@ export default class ProfitLossMR extends Component {
customBodyRender: (val, tableMeta, updateValue) => {
return (
<div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ?
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1?
null
:
tableMeta.rowData[0] === 6 ?
......@@ -986,7 +991,7 @@ export default class ProfitLossMR extends Component {
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[9]}
value={tableMeta.rowData[11]}
control={
<NumberFormat
thousandSeparator={true}
......@@ -1052,7 +1057,7 @@ export default class ProfitLossMR extends Component {
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[9]}
value={Number(tableMeta.rowData[12]).toFixed(1)}
control={
<NumberFormat
thousandSeparator={true}
......@@ -1179,6 +1184,23 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: 'red', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleVariancePercent(tableMeta, 1, 1)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1232,6 +1254,23 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: 'red', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleVariancePercent(tableMeta, 2, 3)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1285,6 +1324,23 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
Number(tableMeta.rowData[18]) <= this.state.minValue || Number(tableMeta.rowData[18]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<NumberFormat
thousandSeparator={true}
style={{ color: 'red', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleVariancePercent(tableMeta, 3, 5)).toFixed(1)}
/>
}
/>
</div> :
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1380,7 +1436,7 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
Number(tableMeta.rowData[19]).toFixed(3) > Number(this.state.valueThreshold).toFixed(3) ?
Number(tableMeta.rowData[19]) <= this.state.minValue || Number(tableMeta.rowData[19]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1435,7 +1491,7 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
Number(tableMeta.rowData[20]).toFixed(3) > Number(this.state.valueThreshold).toFixed(3) ?
Number(tableMeta.rowData[20]) <= this.state.minValue || Number(tableMeta.rowData[20]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......@@ -1490,7 +1546,7 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null
:
Number(tableMeta.rowData[21]).toFixed(3) > Number(this.state.valueThreshold).toFixed(3) ?
Number(tableMeta.rowData[21]) <= this.state.minValue || Number(tableMeta.rowData[21]) >= this.state.maxValue ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
......
......@@ -11,6 +11,7 @@ import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload";
import { format } from 'date-fns';
import Constant from '../../library/Constant';
import OperatingIndicatorMR from '../MonthlyReport/OperatingIndicatorMR';
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
......@@ -27,8 +28,11 @@ export default class OperatingIndicator extends Component {
revision: null,
visibleOperatingIndicator: true,
visibleDetailOpt: false,
visibleDetailMonthly: false,
visibleDetailRolling: false,
listPeriode: null,
periode: null,
month: null,
listCompany: null,
company: null,
report_id: null,
......@@ -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() {
let payload = {
"company_id": this.state.company.company_id,
......@@ -108,7 +152,7 @@ export default class OperatingIndicator extends Component {
"report_type": "operating indicator",
}
api.create().getAllOperatingInd(payload).then(response => {
// console.log(response);
console.log(response);
if (response.data) {
if (response.data.status === "success") {
let dataTable = response.data.data.map((item, index) => {
......@@ -189,7 +233,7 @@ export default class OperatingIndicator extends Component {
};
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : arrayBaru[0] }, () => {
this.getLastPeriod()
this.getMonth()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -318,12 +362,46 @@ export default class OperatingIndicator extends Component {
clickDetail(item, id) {
let index = this.state.dataReport.findIndex((val) => val.report_name == item[1])
if (index !== -1) {
// 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,
// })
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 {
borderColor: 'transparent'
}}
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>
......@@ -584,6 +665,24 @@ export default class OperatingIndicator extends Component {
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 && (
<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