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 >
......
...@@ -57,7 +57,9 @@ export default class ProfitLossMR extends Component { ...@@ -57,7 +57,9 @@ export default class ProfitLossMR extends Component {
dataTable: [], dataTable: [],
loading: true, loading: true,
visiblePLMR: true, visiblePLMR: true,
valueThreshold: 0 // valueThreshold: 0,
minValue: 0,
maxValue: 0
} }
} }
...@@ -78,7 +80,10 @@ export default class ProfitLossMR extends Component { ...@@ -78,7 +80,10 @@ export default class ProfitLossMR extends Component {
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ 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() this.getItemHierarki()
}) })
...@@ -391,8 +396,8 @@ export default class ProfitLossMR extends Component { ...@@ -391,8 +396,8 @@ export default class ProfitLossMR extends Component {
periode: this.props.periode, periode: this.props.periode,
report_id: this.props.report_id, report_id: this.props.report_id,
months: this.props.month.month_id, months: this.props.month.month_id,
profit_loss: data, status: type,
status: type profit_loss: data
} }
// console.log(data); // console.log(data);
api.create('UPLOAD').uploadMonthlyReportPL(body).then(response => { api.create('UPLOAD').uploadMonthlyReportPL(body).then(response => {
...@@ -686,7 +691,7 @@ export default class ProfitLossMR extends Component { ...@@ -686,7 +691,7 @@ export default class ProfitLossMR extends Component {
customBodyRender: (val, tableMeta, updateValue) => { customBodyRender: (val, tableMeta, updateValue) => {
return ( return (
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{tableMeta.rowData[0] === 4 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1?
null null
: :
tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 6 ?
...@@ -986,7 +991,7 @@ export default class ProfitLossMR extends Component { ...@@ -986,7 +991,7 @@ export default class ProfitLossMR extends Component {
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={tableMeta.rowData[9]} value={tableMeta.rowData[11]}
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
...@@ -1052,7 +1057,7 @@ export default class ProfitLossMR extends Component { ...@@ -1052,7 +1057,7 @@ export default class ProfitLossMR extends Component {
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={tableMeta.rowData[9]} value={Number(tableMeta.rowData[12]).toFixed(1)}
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
...@@ -1179,6 +1184,23 @@ export default class ProfitLossMR extends Component { ...@@ -1179,6 +1184,23 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null 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 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -1232,6 +1254,23 @@ export default class ProfitLossMR extends Component { ...@@ -1232,6 +1254,23 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null 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 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -1285,6 +1324,23 @@ export default class ProfitLossMR extends Component { ...@@ -1285,6 +1324,23 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null 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 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -1380,7 +1436,7 @@ export default class ProfitLossMR extends Component { ...@@ -1380,7 +1436,7 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null 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 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -1435,7 +1491,7 @@ export default class ProfitLossMR extends Component { ...@@ -1435,7 +1491,7 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null 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 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -1490,7 +1546,7 @@ export default class ProfitLossMR extends Component { ...@@ -1490,7 +1546,7 @@ export default class ProfitLossMR extends Component {
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
null 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 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
......
...@@ -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,
...@@ -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({
// 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({ 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,
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