CorporateAnnualTarget.js 269 KB
Newer Older
1
import React, { Component } from 'react';
d.arizona's avatar
d.arizona committed
2
import { Typography, Paper, createMuiTheme, ThemeProvider, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, withStyles, makeStyles, Snackbar } from '@material-ui/core';
3 4
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
faisalhamdi's avatar
faisalhamdi committed
5
import api from '../../api';
faisalhamdi's avatar
faisalhamdi committed
6 7 8 9 10
import AddIcon from '@material-ui/icons/Add';
import { values } from 'ramda';
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
d.arizona's avatar
d.arizona committed
11 12 13
import Tooltip from '@material-ui/core/Tooltip';
import { titleCase } from '../../library/Utils';
import Constant from '../../library/Constant';
d.arizona's avatar
d.arizona committed
14
import { Alert, Autocomplete } from '@material-ui/lab';
d.arizona's avatar
d.arizona committed
15 16
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
d.arizona's avatar
d.arizona committed
17
import * as R from 'ramda'
18

d.arizona's avatar
d.arizona committed
19
const LightTooltip = withStyles((theme) => ({
Deni Rinaldi's avatar
Deni Rinaldi committed
20 21 22 23 24 25
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
d.arizona's avatar
d.arizona committed
26
}))(Tooltip);
27
var ct = require("../../library/CustomTable");
d.arizona's avatar
d.arizona committed
28
const getMuiTheme = () => createMuiTheme(ct.customTable3());
29 30 31 32 33 34 35 36 37 38 39

const options = ct.customOptionsFixedColumn();
const style = {
    position: "sticky",
    left: 0,
    background: "white",
    zIndex: 101,
};
const style2 = {
    position: "sticky",
    background: "white",
faisalhamdi's avatar
faisalhamdi committed
40
    zIndex: 100
41
};
d.arizona's avatar
d.arizona committed
42 43 44

const theme = createMuiTheme({
    overrides: {
Deni Rinaldi's avatar
Deni Rinaldi committed
45 46 47 48 49 50
        // Style sheet name ⚛️
        MuiInputBase: {
            input: {
                color: '#5198ea'
            }
        }
d.arizona's avatar
d.arizona committed
51
    },
Deni Rinaldi's avatar
Deni Rinaldi committed
52
});
d.arizona's avatar
d.arizona committed
53

54 55 56 57 58
export default class CorporateAnnualTarget extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [
faisalhamdi's avatar
faisalhamdi committed
59 60 61 62 63 64
                // ["FINANCIAL PERSPECTIVE", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181"],
                // ["Control", "-", "-"],
                // ["Accumulated Depreciation (negative value)", "2,647,647", "2,058,898"],
                // ["Control", "-", "-"],
                // ["Gain / (Loss) on Fixed Assets", "-", "-"],
                // ["Control", "-", "-"]
d.arizona's avatar
d.arizona committed
65 66 67 68
            ],
            loading: false,
            uomList: [],
            formulaYtdList: {
d.arizona's avatar
d.arizona committed
69
                options: [{ value: 'SUM' }, { value: 'AVG' }, { value: 'LAST' }, { value: 'FORMULA' }],
d.arizona's avatar
d.arizona committed
70 71 72 73
                getOptionLabel: (option) => titleCase(option.value),
            },
            kpiTypeList: [],
            maxAchList: [],
d.arizona's avatar
d.arizona committed
74
            visibleCAT: true,
d.arizona's avatar
d.arizona committed
75
            buttonError: true,
d.arizona's avatar
d.arizona committed
76
            // formulaYTDList: null,,
d.arizona's avatar
d.arizona committed
77
            dataDelete: [],
d.arizona's avatar
d.arizona committed
78
            dataReal: [],
d.arizona's avatar
d.arizona committed
79
            buttonDraft: true,
Riri Novita's avatar
Riri Novita committed
80
            updateBy: [],
Deni Rinaldi's avatar
Deni Rinaldi committed
81
            handleTekTekTek: 0,
82 83
            editable: false,
            dataCustomerPrs: [],
d.arizona's avatar
d.arizona committed
84 85 86 87
            dataInternalBsn: [],
            dataFin: [],
            dataLearn: [],
            handleDataSalah: false,
88
        }
d.arizona's avatar
d.arizona committed
89 90
        this.fileHandler = this.fileHandler.bind(this);

91 92 93
    }

    componentDidMount() {
d.arizona's avatar
d.arizona committed
94
        this.getKPIType()
d.arizona's avatar
d.arizona committed
95
        this.getMaxAch()
d.arizona's avatar
d.arizona committed
96
        this.getLatestUpdate()
d.arizona's avatar
d.arizona committed
97 98
        // // // console.log(this.props.status)
        // // // // console.log(this.props.lastStatus);
Deni Rinaldi's avatar
Deni Rinaldi committed
99

100 101
    }

faisalhamdi's avatar
faisalhamdi committed
102
    getItemHierarki() {
faisalhamdi's avatar
faisalhamdi committed
103
        this.setState({ loading: true })
faisalhamdi's avatar
faisalhamdi committed
104 105
        let payload = {
            "report_id": this.props.report_id,
faisalhamdi's avatar
faisalhamdi committed
106 107
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
faisalhamdi's avatar
faisalhamdi committed
108 109
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID
faisalhamdi's avatar
faisalhamdi committed
110
        }
d.arizona's avatar
d.arizona committed
111
        console.log(JSON.stringify(payload))
faisalhamdi's avatar
faisalhamdi committed
112
        api.create().getDetailReportMB(payload).then(response => {
d.arizona's avatar
d.arizona committed
113
            let dataTable = []
114 115
            let dataCustomerPrs = []
            let dataInternalBsn = []
d.arizona's avatar
d.arizona committed
116 117
            let dataFin = []
            let dataLearn = []
d.arizona's avatar
d.arizona committed
118
            console.log(response)
Dida Adams Arizona's avatar
Dida Adams Arizona committed
119
            if (response.data) {
120 121 122 123 124 125 126
                if (response.ok) {
                    if (response.data.status == 'success') {
                        let res = response.data.data
                        const handlePushChild = (item) => {
                            let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                            if (indexIDzz === -1) {
                                let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE'
Deni Rinaldi's avatar
Deni Rinaldi committed
127

128 129 130 131 132 133 134 135
                                if (item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
                                    if (item.type_report_id !== 4) {
                                        dataInternalBsn.push({
                                            id: item.id,
                                            name: item.description,
                                            check: false
                                        })
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
136 137
                                }

138 139 140 141 142 143
                                if (item.parent_name == 'CUSTOMER PERSPECTIVE') {
                                    if (item.type_report_id !== 4) {
                                        dataCustomerPrs.push({
                                            id: item.id,
                                            name: item.description,
                                            check: false
Deni Rinaldi's avatar
Deni Rinaldi committed
144
                                        })
145 146
                                    }
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
147

d.arizona's avatar
d.arizona committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
                                if (item.parent_name == 'FINANCIAL PERSPECTIVE') {
                                    if (item.type_report_id !== 4) {
                                        dataFin.push({
                                            id: item.id,
                                            name: item.description,
                                            check: false
                                        })
                                    }
                                }

                                if (item.parent_name == 'LEARNING & GROWTH PERSPECTIVE') {
                                    if (item.type_report_id !== 4) {
                                        dataLearn.push({
                                            id: item.id,
                                            name: item.description,
                                            check: false
                                        })
                                    }
                                }

168 169 170 171 172 173 174 175
                                dataTable.push([
                                    item.type_report_id,
                                    item.id,
                                    item.parent,
                                    item.formula,
                                    item.level,
                                    "",
                                    item.description,
d.arizona's avatar
d.arizona committed
176
                                    item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(Number(String(item.cat.weight).substr(0, String(item.cat.weight).length - 1)).toFixed(1)) + '%'),
177 178 179 180
                                    parentTrue ? item.cat.uom : item.uom,
                                    parentTrue ? item.cat.kpi_type == "" ? null : { value: item.cat.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
                                    parentTrue ? item.cat.max_ach == "" ? null : { value: titleCase(item.cat.max_ach) } : item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
                                    parentTrue ? item.cat.formula == "" ? null : { value: item.cat.formula } : item.formula_ytd == "" ? null : { value: item.formula_ytd },
Deni Rinaldi's avatar
Deni Rinaldi committed
181
                                    item.cat.total_actual_before == "" ? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1 ? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1),
d.arizona's avatar
d.arizona committed
182 183 184 185 186 187 188 189 190 191 192 193
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1)) : { value: item.cat.january, formula: item.cat.january_formula } : (item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.february == "" ? item.cat.february : String(item.cat.february).indexOf(".") == -1 ? Number(item.cat.february) : Number(item.cat.february).toFixed(1)) : { value: item.cat.february, formula: item.cat.february_formula } : (item.cat.february == "" ? item.cat.february : String(item.cat.february).indexOf(".") == -1 ? Number(item.cat.february) : Number(item.cat.february).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.march == "" ? item.cat.march : String(item.cat.march).indexOf(".") == -1 ? Number(item.cat.march) : Number(item.cat.march).toFixed(1)) : { value: item.cat.march, formula: item.cat.march_formula } : (item.cat.march == "" ? item.cat.march : String(item.cat.march).indexOf(".") == -1 ? Number(item.cat.march) : Number(item.cat.march).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.april == "" ? item.cat.april : String(item.cat.april).indexOf(".") == -1 ? Number(item.cat.april) : Number(item.cat.april).toFixed(1)) : { value: item.cat.april, formula: item.cat.april_formula } : (item.cat.april == "" ? item.cat.april : String(item.cat.april).indexOf(".") == -1 ? Number(item.cat.april) : Number(item.cat.april).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.may == "" ? item.cat.may : String(item.cat.may).indexOf(".") == -1 ? Number(item.cat.may) : Number(item.cat.may).toFixed(1)) : { value: item.cat.may, formula: item.cat.may_formula } : (item.cat.may == "" ? item.cat.may : String(item.cat.may).indexOf(".") == -1 ? Number(item.cat.may) : Number(item.cat.may).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.june == "" ? item.cat.june : String(item.cat.june).indexOf(".") == -1 ? Number(item.cat.june) : Number(item.cat.june).toFixed(1)) : { value: item.cat.june, formula: item.cat.june_formula } : (item.cat.june == "" ? item.cat.june : String(item.cat.june).indexOf(".") == -1 ? Number(item.cat.june) : Number(item.cat.june).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.july == "" ? item.cat.july : String(item.cat.july).indexOf(".") == -1 ? Number(item.cat.july) : Number(item.cat.july).toFixed(1)) : { value: item.cat.july, formula: item.cat.july_formula } : (item.cat.july == "" ? item.cat.july : String(item.cat.july).indexOf(".") == -1 ? Number(item.cat.july) : Number(item.cat.july).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.august == "" ? item.cat.august : String(item.cat.august).indexOf(".") == -1 ? Number(item.cat.august) : Number(item.cat.august).toFixed(1)) : { value: item.cat.august, formula: item.cat.august_formula } : (item.cat.august == "" ? item.cat.august : String(item.cat.august).indexOf(".") == -1 ? Number(item.cat.august) : Number(item.cat.august).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.september == "" ? item.cat.september : String(item.cat.september).indexOf(".") == -1 ? Number(item.cat.september) : Number(item.cat.september).toFixed(1)) : { value: item.cat.september, formula: item.cat.september_formula } : (item.cat.september == "" ? item.cat.september : String(item.cat.september).indexOf(".") == -1 ? Number(item.cat.september) : Number(item.cat.september).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.october == "" ? item.cat.october : String(item.cat.october).indexOf(".") == -1 ? Number(item.cat.october) : Number(item.cat.october).toFixed(1)) : { value: item.cat.october, formula: item.cat.october_formula } : (item.cat.october == "" ? item.cat.october : String(item.cat.october).indexOf(".") == -1 ? Number(item.cat.october) : Number(item.cat.october).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.november == "" ? item.cat.november : String(item.cat.november).indexOf(".") == -1 ? Number(item.cat.november) : Number(item.cat.november).toFixed(1)) : { value: item.cat.november, formula: item.cat.november_formula } : (item.cat.november == "" ? item.cat.november : String(item.cat.november).indexOf(".") == -1 ? Number(item.cat.november) : Number(item.cat.november).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.cat.december == "" ? item.cat.december : String(item.cat.december).indexOf(".") == -1 ? Number(item.cat.december) : Number(item.cat.december).toFixed(1)) : { value: item.cat.december, formula: item.cat.december_formula } : (item.cat.december == "" ? item.cat.december : String(item.cat.december).indexOf(".") == -1 ? Number(item.cat.december) : Number(item.cat.december).toFixed(1)),
d.arizona's avatar
d.arizona committed
194
                                    item.cat.total_current_year == "" ? 0 : String(item.cat.total_current_year).indexOf(".") == -1 ? Number(item.cat.total_current_year) : Number(item.cat.total_current_year).toFixed(1),
d.arizona's avatar
d.arizona committed
195 196
                                    item.cat.total_next_year == "" ? item.cat.total_next_year : String(item.cat.total_next_year).indexOf(".") == -1 ? Number(item.cat.total_next_year) : Number(item.cat.total_next_year).toFixed(1),
                                    item.cat.total_more_year == "" ? item.cat.total_more_year : String(item.cat.total_more_year).indexOf(".") == -1 ? Number(item.cat.total_more_year) : Number(item.cat.total_more_year).toFixed(1),
197
                                    item.cat.strategic,
d.arizona's avatar
d.arizona committed
198 199 200
                                    item.cat.pic,
                                    item.cat.forecast_formula,
                                    item.order
201
                                ])
Dida Adams Arizona's avatar
Dida Adams Arizona committed
202
                            }
203 204 205 206 207 208
                            if (item.children !== null) {
                                if (item.children.length > 0) {
                                    item.children.map((items, indexs) => {
                                        handlePushChild(items)
                                    })
                                }
Dida Adams Arizona's avatar
Dida Adams Arizona committed
209
                            }
210
                        }
211 212 213 214 215 216 217 218 219
                        res.map((item, index) => {
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                "",
                                item.description,
d.arizona's avatar
d.arizona committed
220
                                item.type_report_id == 1 ? (`${String(item.weight).includes('%')? String(item.weight) : String((Number(item.weight) * 100) + '% ')}`) : (String(Number(String(item.cat.weight).substr(0, String(item.cat.weight).length - 1)).toFixed(1)) + '%'),
221 222 223 224
                                item.cat.uom,
                                item.kpi_type == "" ? null : { value: item.kpi_type },
                                item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
                                item.formula == "" ? null : { value: item.formula_ytd },
Deni Rinaldi's avatar
Deni Rinaldi committed
225
                                item.cat.total_actual_before == "" ? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1 ? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1),
d.arizona's avatar
d.arizona committed
226 227 228 229 230 231 232 233 234 235 236 237
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.january, formula: item.cat.january_formula } : (item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.february, formula: item.cat.february_formula } : (item.cat.february == "" ? item.cat.february : String(item.cat.february).indexOf(".") == -1 ? Number(item.cat.february) : Number(item.cat.february).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.march, formula: item.cat.march_formula } : (item.cat.march == "" ? item.cat.march : String(item.cat.march).indexOf(".") == -1 ? Number(item.cat.march) : Number(item.cat.march).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.april, formula: item.cat.april_formula } : (item.cat.april == "" ? item.cat.april : String(item.cat.april).indexOf(".") == -1 ? Number(item.cat.april) : Number(item.cat.april).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.may, formula: item.cat.may_formula } : (item.cat.may == "" ? item.cat.may : String(item.cat.may).indexOf(".") == -1 ? Number(item.cat.may) : Number(item.cat.may).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.june, formula: item.cat.june_formula } : (item.cat.june == "" ? item.cat.june : String(item.cat.june).indexOf(".") == -1 ? Number(item.cat.june) : Number(item.cat.june).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.july, formula: item.cat.july_formula } : (item.cat.july == "" ? item.cat.july : String(item.cat.july).indexOf(".") == -1 ? Number(item.cat.july) : Number(item.cat.july).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.august, formula: item.cat.august_formula } : (item.cat.august == "" ? item.cat.august : String(item.cat.august).indexOf(".") == -1 ? Number(item.cat.august) : Number(item.cat.august).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.september, formula: item.cat.september_formula } : (item.cat.september == "" ? item.cat.september : String(item.cat.september).indexOf(".") == -1 ? Number(item.cat.september) : Number(item.cat.september).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.october, formula: item.cat.october_formula } : (item.cat.october == "" ? item.cat.october : String(item.cat.october).indexOf(".") == -1 ? Number(item.cat.october) : Number(item.cat.october).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.november, formula: item.cat.november_formula } : (item.cat.november == "" ? item.cat.november : String(item.cat.november).indexOf(".") == -1 ? Number(item.cat.november) : Number(item.cat.november).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.cat.december, formula: item.cat.december_formula } : (item.cat.december == "" ? item.cat.december : String(item.cat.december).indexOf(".") == -1 ? Number(item.cat.december) : Number(item.cat.december).toFixed(1)),
d.arizona's avatar
d.arizona committed
238
                                item.cat.total_current_year == "" ? 0 : String(item.cat.total_current_year).indexOf(".") == -1 ? Number(item.cat.total_current_year) : Number(item.cat.total_current_year).toFixed(1),
d.arizona's avatar
d.arizona committed
239 240
                                item.cat.total_next_year == "" ? item.cat.total_next_year : String(item.cat.total_next_year).indexOf(".") == -1 ? Number(item.cat.total_next_year) : Number(item.cat.total_next_year).toFixed(1),
                                item.cat.total_more_year == "" ? item.cat.total_more_year : String(item.cat.total_more_year).indexOf(".") == -1 ? Number(item.cat.total_more_year) : Number(item.cat.total_more_year).toFixed(1),
241
                                item.cat.strategic,
d.arizona's avatar
d.arizona committed
242 243 244
                                item.cat.pic,
                                item.cat.forecast_formula,
                                item.order
245 246 247 248 249 250 251 252 253
                            ])
                            if (item.children !== null) {
                                if (item.children.length > 0) {
                                    item.children.map((items, indexs) => {
                                        handlePushChild(items)
                                    })
                                }
                            }
                        })
d.arizona's avatar
d.arizona committed
254
                        console.log(dataTable)
d.arizona's avatar
d.arizona committed
255
                        this.setState({ dataTable, loading: false, dataReal: res, editable: true, dataCustomerPrs, dataInternalBsn, dataFin, dataLearn }, () => {
d.arizona's avatar
d.arizona committed
256
                            // // // console.log(dataCustomerPrs)
257 258 259
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
260
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
261 262 263 264 265 266
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
267
                    };
268 269
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
Dida Adams Arizona's avatar
Dida Adams Arizona committed
270 271
                }
            } else {
d.arizona's avatar
d.arizona committed
272
                this.setState({ alert: true, messageAlert: 'Connection Timeout, please check your Connection', tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
273
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
274 275


faisalhamdi's avatar
faisalhamdi committed
276 277 278
        })
    }

d.arizona's avatar
d.arizona committed
279 280
    downloadTemplate = async () => {
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
281
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
d.arizona's avatar
d.arizona committed
282 283
        )
        res = await res.blob()
d.arizona's avatar
d.arizona committed
284
        // // // // console.log(res)
d.arizona's avatar
d.arizona committed
285 286 287 288
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
d.arizona's avatar
d.arizona committed
289
            a.download = 'Template Master Budget CAT.xlsx';
d.arizona's avatar
d.arizona committed
290 291 292 293 294
            a.click();
        }
    }

    async downloadAllData() {
d.arizona's avatar
d.arizona committed
295
        // // // // console.log('masuk')
Deni Rinaldi's avatar
Deni Rinaldi committed
296
        let bram = [this.props.submissionID, this.props.report_id, this.props.company.company_id, this.props.periode, this.props.revision]
d.arizona's avatar
d.arizona committed
297
        // // // // console.log(bram)
faisalhamdi's avatar
faisalhamdi committed
298 299
        let resReal = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
        let resNull = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
d.arizona's avatar
d.arizona committed
300
        let res = await fetch(
Deni Rinaldi's avatar
Deni Rinaldi committed
301
            this.props.submissionID == null ? resNull : resReal
d.arizona's avatar
d.arizona committed
302 303
        )
        res = await res.blob()
d.arizona's avatar
d.arizona committed
304
        // // // // console.log(res)
d.arizona's avatar
d.arizona committed
305 306 307 308 309
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
d.arizona's avatar
d.arizona committed
310
            a.download = 'Master Budget CAT.xlsx';
d.arizona's avatar
d.arizona committed
311 312 313 314 315 316 317
            a.click();
        }
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
d.arizona's avatar
d.arizona committed
318
            // // // // // console.log(resp)
d.arizona's avatar
d.arizona committed
319
            if (err) {
d.arizona's avatar
d.arizona committed
320
                // // // // console.log(err);
d.arizona's avatar
d.arizona committed
321 322 323
            }
            else {
                let isi = resp.rows.slice(3)
d.arizona's avatar
d.arizona committed
324
                // // console.log(isi);
d.arizona's avatar
d.arizona committed
325
                let payload = []
d.arizona's avatar
d.arizona committed
326
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
d.arizona's avatar
d.arizona committed
327
                let newValidate = false
d.arizona's avatar
d.arizona committed
328 329
                isi.map((i, index) => {
                    if (i.length > 0) {
d.arizona's avatar
d.arizona committed
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
                        let total = 0
                        let lastValz = 0
                        let nilaiTotal = 0
                        if (i[6] !== undefined) {
                            if (i[6] == 'SUM' || i[6] == 'AVG' || i[6] == 'LAST') {
                                i.map((items, indexs) => {
                                    if (indexs >= 8 && indexs <= 19) {
                                        let valItem = items == undefined || items == "" ? 0 : items
                                        total += Number(valItem)
                                        if (index == 19) {
                                            lastValz += Number(valItem)
                                        }
                                    }
                                })
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
345
                            nilaiTotal = i[6] == 'SUM' ? total : i[6] == 'AVG' ? total / 12 : lastValz
d.arizona's avatar
d.arizona committed
346
                        }
d.arizona's avatar
d.arizona committed
347 348 349 350 351 352 353 354 355 356 357 358 359 360

                        if (String(i[1]).trim().toLocaleUpperCase() == "CUSTOMER PERSPECTIVE") {
                            newValidate = true
                        }

                        if (String(i[1]).trim().toLocaleUpperCase() == "LEARNING & GROWTH PERSPECTIVE") {
                            newValidate = false
                        }

                        if (i[0] === undefined || i[0] === null) {
                            if (newValidate) {
                                payload.push({
                                    item_report_id: i[0] === undefined ? 0 : reg.test(String(i[0])) === false ? 0 : String(i[0]).trim(),
                                    item_report: i[1] === undefined ? "" : String(i[1]).trim(),
Riri Novita's avatar
Riri Novita committed
361
                                    weight: i[2] === undefined ? "" : (String(i[2]).includes('%') ? Number(String(i[2]).substr(0, String(i[2]).length-1)) : String(Number(i[2] * 100).toFixed(1)) + '%'),
d.arizona's avatar
d.arizona committed
362 363
                                    uom: i[3] === undefined ? "" : String(i[3]).trim(),
                                    kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
d.arizona's avatar
d.arizona committed
364
                                    max_ach: i[5] === undefined ? "" : String(i[5]).toLocaleLowerCase() !== 'unlimited' ? (String(i[5]).includes('%') ? String(i[5].trim()) : String(Number(i[5] * 100) + '%')) : String(i[5]).trim(),
d.arizona's avatar
d.arizona committed
365 366 367 368
                                    formula: i[6] === undefined ? "" : String(i[6]).trim(),
                                    total_actual_before: i[7] === undefined ? "0.0" : reg.test(String(i[7])) === false ? "0.0" : String(Number(i[7]).toFixed(1)).trim(),
                                    january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(Number(i[8]).toFixed(1)).trim(),
                                    february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(Number(i[9]).toFixed(1)).trim(),
rifkaki's avatar
rifkaki committed
369
                                    march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(Number(i[10]).toFixed(1)).trim(),
d.arizona's avatar
d.arizona committed
370
                                    april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(Number(i[11]).toFixed(1)).trim(),
rifkaki's avatar
rifkaki committed
371 372 373
                                    may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(Number(i[12]).toFixed(1)).trim(),
                                    june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(Number(i[13]).toFixed(1)).trim(),
                                    july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(Number(i[14]).toFixed(1)).trim(),
d.arizona's avatar
d.arizona committed
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
                                    august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(Number(i[15]).toFixed(1)).trim(),
                                    september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(Number(i[16]).toFixed(1)).trim(),
                                    october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(Number(i[17]).toFixed(1)).trim(),
                                    november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(Number(i[18]).toFixed(1)).trim(),
                                    december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(Number(i[19]).toFixed(1)).trim(),
                                    total_current_year: i[20] == 0 ? "0.0" : String(Number(nilaiTotal).toFixed(1)).trim(),
                                    total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(Number(i[21]).toFixed(1)).trim(),
                                    total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(Number(i[22]).toFixed(1)).trim(),
                                    strategic: i[23] === undefined ? "" : String(i[23]).trim(),
                                    pic: i[24] === undefined ? "" : String(i[24]).trim()
                                })
                            }
                        } else {
                            payload.push({
                                item_report_id: i[0] === undefined ? 0 : reg.test(String(i[0])) === false ? 0 : String(i[0]).trim(),
                                item_report: i[1] === undefined ? "" : String(i[1]).trim(),
Riri Novita's avatar
Riri Novita committed
390
                                weight: i[2] === undefined ? "" : (String(i[2]).includes('%') ? Number(String(i[2]).substr(0, String(i[2]).length-1)) : String(Number(i[2] * 100).toFixed(1)) + '%'),
d.arizona's avatar
d.arizona committed
391 392
                                uom: i[3] === undefined ? "" : String(i[3]).trim(),
                                kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
d.arizona's avatar
d.arizona committed
393
                                max_ach: i[5] === undefined ? "" : String(i[5]).toLocaleLowerCase() !== 'unlimited' ? (String(i[5]).includes('%') ? String(i[5].trim()) : String(Number(i[5] * 100) + '%')) : String(i[5]).trim(),
d.arizona's avatar
d.arizona committed
394 395 396 397
                                formula: i[6] === undefined ? "" : String(i[6]).trim(),
                                total_actual_before: i[7] === undefined ? "0.0" : reg.test(String(i[7])) === false ? "0.0" : String(Number(i[7]).toFixed(1)).trim(),
                                january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(Number(i[8]).toFixed(1)).trim(),
                                february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(Number(i[9]).toFixed(1)).trim(),
rifkaki's avatar
rifkaki committed
398
                                march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(Number(i[10]).toFixed(1)).trim(),
d.arizona's avatar
d.arizona committed
399
                                april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(Number(i[11]).toFixed(1)).trim(),
rifkaki's avatar
rifkaki committed
400 401 402
                                may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(Number(i[12]).toFixed(1)).trim(),
                                june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(Number(i[13]).toFixed(1)).trim(),
                                july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(Number(i[14]).toFixed(1)).trim(),
d.arizona's avatar
d.arizona committed
403 404 405 406 407 408 409 410 411 412 413 414
                                august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(Number(i[15]).toFixed(1)).trim(),
                                september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(Number(i[16]).toFixed(1)).trim(),
                                october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(Number(i[17]).toFixed(1)).trim(),
                                november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(Number(i[18]).toFixed(1)).trim(),
                                december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(Number(i[19]).toFixed(1)).trim(),
                                total_current_year: i[20] == 0 ? "0.0" : String(Number(nilaiTotal).toFixed(1)).trim(),
                                total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(Number(i[21]).toFixed(1)).trim(),
                                total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(Number(i[22]).toFixed(1)).trim(),
                                strategic: i[23] === undefined ? "" : String(i[23]).trim(),
                                pic: i[24] === undefined ? "" : String(i[24]).trim()
                            })
                        }
d.arizona's avatar
d.arizona committed
415 416 417
                        // // console.log(i[2])
                        // // // console.log(Number(i[2] * 100))
                        // // // // // console.log(i[2] === undefined ? "" : String(Number(i[2]*100)).length > 3? String(Number(i[2]*100).toFixed(0) + '%') : String(Number(i[2]*100)) + '%')
d.arizona's avatar
d.arizona committed
418

d.arizona's avatar
d.arizona committed
419 420
                    }
                })
d.arizona's avatar
d.arizona committed
421

d.arizona's avatar
d.arizona committed
422
                // // console.log(payload)
d.arizona's avatar
d.arizona committed
423 424 425 426
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
d.arizona's avatar
d.arizona committed
427
                    status: '',
d.arizona's avatar
d.arizona committed
428 429
                    cat: payload,
                    status: 'submitted'
d.arizona's avatar
d.arizona committed
430
                }
d.arizona's avatar
d.arizona committed
431
                // // // // console.log(body)
d.arizona's avatar
d.arizona committed
432 433 434 435 436 437
                this.setState({ payload: body, judul: resp.rows[1][0] })
            }
        });
    }

    checkUpload() {
d.arizona's avatar
d.arizona committed
438
        this.setState({ loading: true, dataTable: [] })
d.arizona's avatar
d.arizona committed
439 440 441
        let dataDelete = this.state.dataDelete
        api.create().getIdDeleteFromExcel(this.state.payload).then((response) => {
            if (response.data) {
d.arizona's avatar
d.arizona committed
442
                // // // // // console.log(response.data)
d.arizona's avatar
d.arizona committed
443 444
                let idDelete = response.data.data.item_report_id
                if (idDelete.length > 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
445
                    idDelete.map((item, index) => {
d.arizona's avatar
d.arizona committed
446 447
                        dataDelete.push(item)
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
448
                    this.setState({ dataDelete })
d.arizona's avatar
d.arizona committed
449 450 451
                }
            }
        })
d.arizona's avatar
d.arizona committed
452
        console.log(this.state.payload)
d.arizona's avatar
d.arizona committed
453
        api.create().checkUploadMB(this.state.payload).then(response => {
d.arizona's avatar
d.arizona committed
454
            // // console.log(JSON.stringify(this.state.payload));
d.arizona's avatar
d.arizona committed
455
            console.log(response)
d.arizona's avatar
d.arizona committed
456
            if (response.data) {
Deni Rinaldi's avatar
Deni Rinaldi committed
457
                if (response.ok) {
458 459 460 461 462 463 464
                    if (response.data.status === 'success') {
                        // this.setState({ visibleUpload: false, visibleCAT: false })
                        this.setState({ visibleUpload: false, visibleCAT: false })
                        let dataTable = []
                        let custoId = 0
                        let bisnsId = 0
                        let dataDelete = this.state.dataDelete
d.arizona's avatar
d.arizona committed
465 466 467
                        let dataFin = this.state.dataFin
                        let dataLearn = this.state.dataLearn
                        let newValidate = false
468 469 470
                        response.data.data.map((item, index) => {
                            if (item.item_report == 'CUSTOMER PERSPECTIVE') {
                                custoId = item.item_report_id
471
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
472

473 474
                            if (item.item_report == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
                                bisnsId = item.item_report_id
475
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
476

d.arizona's avatar
d.arizona committed
477 478 479
                            if (String(item.item_report).trim().toLocaleUpperCase() == "CUSTOMER PERSPECTIVE") {
                                newValidate = true
                            }
d.arizona's avatar
d.arizona committed
480

d.arizona's avatar
d.arizona committed
481 482 483
                            if (String(item.item_report).trim().toLocaleUpperCase() == "LEARNING & GROWTH PERSPECTIVE") {
                                newValidate = false
                            }
d.arizona's avatar
d.arizona committed
484

485 486 487 488 489 490
                            if (item.type_report_id !== 4 && item.parent !== null && (item.parent == custoId || item.parent == bisnsId)) {
                                let indexCust = this.state.dataCustomerPrs.findIndex((val) => val.name == item.item_report)
                                let indexBisn = this.state.dataInternalBsn.findIndex((val) => val.name == item.item_report)
                                if (indexCust !== -1 && item.item_report_id == 0) {
                                    dataDelete.push(this.state.dataCustomerPrs[indexCust].id)
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
491

492 493 494
                                if (indexBisn !== -1 && item.item_report_id == 0) {
                                    dataDelete.push(this.state.dataInternalBsn[indexBisn].id)
                                }
d.arizona's avatar
d.arizona committed
495
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
496

d.arizona's avatar
d.arizona committed
497 498 499 500 501 502 503 504 505 506 507
                            if (newValidate == false) {
                                let indexIDx = dataFin.findIndex((val) => String(val.name).toLocaleLowerCase() == String(item.item_report).toLocaleLowerCase())
                                let indexIDz = dataLearn.findIndex((val) => String(val.name).toLocaleLowerCase() == String(item.item_report).toLocaleLowerCase())
                                if (indexIDx != -1) {
                                    dataFin[indexIDx].check = true
                                }
                                if (indexIDz != -1) {
                                    dataLearn[indexIDz].check = true
                                }
                            }

508 509 510 511 512 513 514 515
                            dataTable.push([
                                item.type_report_id,
                                item.item_report_id,
                                item.parent,
                                item.formula,
                                item.level == null ? 1 : item.level,
                                "",
                                item.item_report,
d.arizona's avatar
d.arizona committed
516
                                item.type_report_id == 1 ? (`${String(item.weight).includes('%')? String(item.weight) : String((Number(item.weight) * 100) + '% ')}`) : (String(item.weight)),
517 518 519 520
                                item.uom,
                                item.kpi_type == "" || item.kpi_type == null ? null : { value: item.kpi_type },
                                item.max_ach == "" || item.max_ach == null ? null : { value: titleCase(item.max_ach) },
                                item.formula_ytd == "" || item.formula_ytd == null ? null : { value: item.formula_ytd },
Deni Rinaldi's avatar
Deni Rinaldi committed
521
                                item.total_actual_before == "" ? item.total_actual_before : String(item.total_actual_before).indexOf(".") == -1 ? Number(item.total_actual_before) : Number(item.total_actual_before).toFixed(1),
d.arizona's avatar
d.arizona committed
522 523 524 525 526 527 528 529 530 531 532 533
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.january).toFixed(1) : { value: item.january, formula: item.january_formula } : item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.february).toFixed(1) : { value: item.february, formula: item.february_formula } : item.february == "" ? item.february : String(item.february).indexOf(".") == -1 ? Number(item.february) : Number(item.february).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.march).toFixed(1) : { value: item.march, formula: item.march_formula } : item.march == "" ? item.march : String(item.march).indexOf(".") == -1 ? Number(item.march) : Number(item.march).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.april).toFixed(1) : { value: item.april, formula: item.april_formula } : item.april == "" ? item.april : String(item.april).indexOf(".") == -1 ? Number(item.april) : Number(item.april).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.may).toFixed(1) : { value: item.may, formula: item.may_formula } : item.may == "" ? item.may : String(item.may).indexOf(".") == -1 ? Number(item.may) : Number(item.may).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.june).toFixed(1) : { value: item.june, formula: item.june_formula } : item.june == "" ? item.june : String(item.june).indexOf(".") == -1 ? Number(item.june) : Number(item.june).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.july).toFixed(1) : { value: item.july, formula: item.july_formula } : item.july == "" ? item.july : String(item.july).indexOf(".") == -1 ? Number(item.july) : Number(item.july).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.august).toFixed(1) : { value: item.august, formula: item.august_formula } : item.august == "" ? item.august : String(item.august).indexOf(".") == -1 ? Number(item.august) : Number(item.august).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.september).toFixed(1) : { value: item.september, formula: item.september_formula } : item.september == "" ? item.september : String(item.september).indexOf(".") == -1 ? Number(item.september) : Number(item.september).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.october).toFixed(1) : { value: item.october, formula: item.october_formula } : item.october == "" ? item.october : String(item.october).indexOf(".") == -1 ? Number(item.october) : Number(item.october).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.november).toFixed(1) : { value: item.november, formula: item.november_formula } : item.november == "" ? item.november : String(item.november).indexOf(".") == -1 ? Number(item.november) : Number(item.november).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.december).toFixed(1) : { value: item.december, formula: item.december_formula } : item.december == "" ? item.december : String(item.december).indexOf(".") == -1 ? Number(item.december) : Number(item.december).toFixed(1),
Deni Rinaldi's avatar
Deni Rinaldi committed
534
                                item.total_current_year == "" ? item.total_current_year : String(item.total_current_year).indexOf(".") == -1 ? Number(item.total_current_year) : Number(item.total_current_year).toFixed(1),
d.arizona's avatar
d.arizona committed
535 536
                                item.total_next_year == "" ? item.total_next_year : String(item.total_next_year).indexOf(".") == -1 ? Number(item.total_next_year) : Number(item.total_next_year).toFixed(1),
                                item.total_more_year == "" ? item.total_more_year : String(item.total_more_year).indexOf(".") == -1 ? Number(item.total_more_year) : Number(item.total_more_year).toFixed(1),
537
                                item.strategic,
Deni Rinaldi's avatar
Deni Rinaldi committed
538 539
                                item.pic,
                                item.forecast_formula,
d.arizona's avatar
d.arizona committed
540
                                item.orders,
541 542
                                item.error
                            ])
d.arizona's avatar
d.arizona committed
543
                        })
d.arizona's avatar
d.arizona committed
544 545 546 547 548 549 550
                        let checkDataFin = dataFin.filter((val) => val.check == false)
                        let checkDataLearn = dataLearn.filter((val) => val.check == false)
                        let handleDataSalah = this.state.handleDataSalah

                        if (checkDataFin.length > 0 || checkDataLearn.length > 0) {
                            handleDataSalah = true
                        }
d.arizona's avatar
d.arizona committed
551 552
                        // // console.log(indexCheck)
                        // // // // console.log(this.state.buttonError)
d.arizona's avatar
d.arizona committed
553
                        console.log(dataTable)
d.arizona's avatar
d.arizona committed
554
                        this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, dataDelete, handleDataSalah }, () => {
555 556
                            this.state.dataTable.map(item => {
                                if (item[30].length > 0) {
d.arizona's avatar
d.arizona committed
557
                                    // // // // console.log('masuk')
558 559 560
                                    this.setState({ buttonError: true, errorPreview: true, editable: true })
                                }
                            })
d.arizona's avatar
d.arizona committed
561
                            // // // // // console.log(this.state.dataTable);
562 563 564
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
565
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
566 567 568 569 570 571
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
572
                    }
573 574
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
575
                }
576 577
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
578 579 580 581
            }
        })
    }

d.arizona's avatar
d.arizona committed
582
    uploadCAT(type) {
583
        // let dataDelete = this.state.dataDelete
d.arizona's avatar
d.arizona committed
584
        // // // // console.log(dataDelete)
Deni Rinaldi's avatar
Deni Rinaldi committed
585
        let payload = { "item_report_id": this.state.dataDelete }
d.arizona's avatar
d.arizona committed
586 587 588 589 590 591 592
        if (this.state.dataDelete.length > 0) {
            api.create().deleteAllItemReport(payload).then((response) => {
                this.functionUpload(type)
            })
        } else {
            this.functionUpload(type)
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
593

d.arizona's avatar
d.arizona committed
594 595 596
    }

    functionUpload(type) {
d.arizona's avatar
d.arizona committed
597
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
598
        let stateFR = false
d.arizona's avatar
d.arizona committed
599
        // // // console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
600
        this.state.dataTable.map(i => {
Deni Rinaldi's avatar
Deni Rinaldi committed
601 602 603 604 605 606 607 608 609
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
                if (indexID !== -1) {
                    if (this.state.dataTable[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
d.arizona's avatar
d.arizona committed
610 611
            } else {
                stateFR = false
Deni Rinaldi's avatar
Deni Rinaldi committed
612
            }
d.arizona's avatar
d.arizona committed
613

d.arizona's avatar
d.arizona committed
614
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
615
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
616 617 618
                "item_report": String(i[6]),
                "weight": String(i[7]),
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
619 620 621 622
                "kpi_type": i[9] == null ? "" : i[9].value,
                "max_ach": i[10] == null ? "" : i[10].value,
                "formula": i[11] == null ? "" : i[11].value,
                "total_actual_before": String(i[12]) == "" ? "0.0" : String(i[12]),
d.arizona's avatar
d.arizona committed
623 624 625 626 627 628 629 630 631 632 633 634
                "january": i[13].value != undefined? String(Number(i[13].value).toFixed(1)) : String(i[13]),
                "february": i[14].value != undefined? String(Number(i[14].value).toFixed(1)) : String(i[14]),
                "march": i[15].value != undefined? String(Number(i[15].value).toFixed(1)) : String(i[15]),
                "april": i[16].value != undefined? String(Number(i[16].value).toFixed(1)) : String(i[16]),
                "may": i[17].value != undefined? String(Number(i[17].value).toFixed(1)) : String(i[17]),
                "june": i[18].value != undefined? String(Number(i[18].value).toFixed(1)) : String(i[18]),
                "july": i[19].value != undefined? String(Number(i[19].value).toFixed(1)) : String(i[19]),
                "august": i[20].value != undefined? String(Number(i[20].value).toFixed(1)) : String(i[20]),
                "september": i[21].value != undefined? String(Number(i[21].value).toFixed(1)) : String(i[21]),
                "october": i[22].value != undefined? String(Number(i[22].value).toFixed(1)) : String(i[22]),
                "november": i[23].value != undefined? String(Number(i[23].value).toFixed(1)) : String(i[23]),
                "december": i[24].value != undefined? String(Number(i[24].value).toFixed(1)) : String(i[24]),
d.arizona's avatar
d.arizona committed
635 636 637
                "total_current_year": String(Number(i[25]).toFixed(1)) == "" ? "0.0" : String(Number(i[25]).toFixed(1)),
                "total_next_year": String(Number(i[26]).toFixed(1)) == "" ? "0.0" : String(Number(i[26]).toFixed(1)),
                "total_more_year": String(Number(i[27]).toFixed(1)) == "" ? "0.0" : String(Number(i[27]).toFixed(1)),
d.arizona's avatar
d.arizona committed
638 639
                "strategic": String(i[28]),
                "pic": String(i[29])
d.arizona's avatar
d.arizona committed
640 641 642 643
            })
        })
        let body = {
            "report_id": this.props.report_id,
d.arizona's avatar
d.arizona committed
644 645 646 647
            // "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID,
d.arizona's avatar
d.arizona committed
648
            "status": type,
d.arizona's avatar
d.arizona committed
649
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
650
        }
d.arizona's avatar
d.arizona committed
651 652
        // // console.log(data);
        // // console.log(JSON.stringify(body))
d.arizona's avatar
d.arizona committed
653
        api.create('UPLOAD').uploadMasterBudget(body).then(response => {
d.arizona's avatar
d.arizona committed
654
            // // // // console.log(response);
d.arizona's avatar
d.arizona committed
655
            if (response.data) {
656 657 658 659 660 661
                if (response.ok) {
                    if (response.data.status === "success") {
                        this.props.onClickClose()
                        this.props.getReport()
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
662
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
663 664 665 666 667 668 669
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
d.arizona's avatar
d.arizona committed
670
                } else {
671
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
672 673
                }
            } else {
d.arizona's avatar
d.arizona committed
674
                this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
675 676
            }
        })
677 678
    }

d.arizona's avatar
d.arizona committed
679 680
    handleValidate() {
        let data = []
d.arizona's avatar
d.arizona committed
681
        // // // console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
682 683 684 685
        let totalWeight = 0
        let dataTableBaru = this.state.dataTable
        let dataTampung = []
        let weightReal = null
d.arizona's avatar
d.arizona committed
686
        let handleKosongKPIMAXYTD = false
Deni Rinaldi's avatar
Deni Rinaldi committed
687
        let stateFR = false
d.arizona's avatar
d.arizona committed
688
        console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
689
        this.state.dataTable.map((i, index) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
690
            if (i[0] == 1) {
d.arizona's avatar
d.arizona committed
691 692 693 694 695 696 697 698
                dataTampung.push({
                    id: i[1],
                    maxValue: i[7],
                    valChild: 0
                })
            }

            if (i[0] !== 1 && i[0] !== 4) {
Deni Rinaldi's avatar
Deni Rinaldi committed
699
                totalWeight += Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
700
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
701

d.arizona's avatar
d.arizona committed
702 703
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
d.arizona's avatar
d.arizona committed
704 705
                // // // // console.log(indexID)
                // // // // console.log(i[2])
d.arizona's avatar
d.arizona committed
706
                if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
707
                    // // // // console.log(dataTableBaru[indexID][6])
d.arizona's avatar
d.arizona committed
708 709 710
                    if (dataTableBaru[indexID][6] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || dataTableBaru[indexID][6] == 'CUSTOMER PERSPECTIVE') {
                        if (i[6] == "" || i[7] == "" || i[9] == null || i[10] == null || i[11] == null) {
                            handleKosongKPIMAXYTD = true
d.arizona's avatar
d.arizona committed
711
                            // // // // console.log(handleKosongKPIMAXYTD)
d.arizona's avatar
d.arizona committed
712
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
713 714 715 716
                    } else if (dataTableBaru[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
d.arizona's avatar
d.arizona committed
717 718 719 720
                    }
                }
            }

d.arizona's avatar
d.arizona committed
721 722 723
            // if (i[0] == null && i[2] == null) {
            //     if (i[6] == "" || i[7] == "" || i[9] == null || i[10] == null || i[11] == null) {
            //         handleKosongKPIMAXYTD = true
d.arizona's avatar
d.arizona committed
724
            //         // // // // console.log(handleKosongKPIMAXYTD)
d.arizona's avatar
d.arizona committed
725 726
            //     }
            // }
d.arizona's avatar
d.arizona committed
727

d.arizona's avatar
d.arizona committed
728 729 730
            if (i[2] !== null) {
                let indexID = dataTampung.findIndex((val) => val.id == i[2])
                if (indexID !== -1) {
Deni Rinaldi's avatar
Deni Rinaldi committed
731
                    let weightParent = Number(dataTampung[indexID].maxValue == "" || dataTampung[indexID].maxValue == undefined ? 0 : dataTampung[indexID].maxValue.replace('%', ''))
d.arizona's avatar
d.arizona committed
732
                    let valChild = Number(dataTampung[indexID].valChild)
Deni Rinaldi's avatar
Deni Rinaldi committed
733
                    let valReal = Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
734 735
                    let totalBaru = valChild + valReal
                    if (totalBaru > weightParent) {
d.arizona's avatar
d.arizona committed
736
                        dataTableBaru[index][7] = `${String(Number(weightParent - valChild).toFixed(1)) + '%'}`
d.arizona's avatar
d.arizona committed
737
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + weightParent - valChild
d.arizona's avatar
d.arizona committed
738
                        weightReal = `${String(Number(weightParent - valChild).toFixed(1)) + '%'}`
d.arizona's avatar
d.arizona committed
739 740 741
                    } else {
                        dataTableBaru[index][7] = i[7]
                        weightReal = i[7]
Deni Rinaldi's avatar
Deni Rinaldi committed
742
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
743
                    }
d.arizona's avatar
d.arizona committed
744
                    // // // // console.log(weightReal)
d.arizona's avatar
d.arizona committed
745 746
                    // console.log(dataTableBaru[index][7])
                    // console.log(dataTampung[indexID].valChild)
d.arizona's avatar
d.arizona committed
747 748
                }
            }
d.arizona's avatar
d.arizona committed
749 750
            // // console.log(String(weightReal).substr(0,String(weightReal).length-1))
            // // console.log(Number(String(weightReal).substr(0,String(weightReal).length-1)).toFixed(1));
d.arizona's avatar
d.arizona committed
751 752 753 754
            console.log(weightReal)
            console.log(i[7])
            let b = []
            // console.log(i[13].value == undefined? 'Y' : 'N')
d.arizona's avatar
d.arizona committed
755
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
756
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
757
                "item_name": String(i[6]),
d.arizona's avatar
d.arizona committed
758
                "parent": i[2] == "" ? null : i[2],
d.arizona's avatar
d.arizona committed
759
                "weight": weightReal == null ? String(i[7]) : weightReal,
d.arizona's avatar
d.arizona committed
760
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
761 762 763 764
                "kpi_type": i[9] == null ? "" : i[9].value,
                "max_ach": i[10] == null ? "" : i[10].value,
                "formula": i[11] == null ? "" : i[11].value,
                "total_actual_before": String(i[12]) == "" ? "0.0" : String(i[12]),
d.arizona's avatar
d.arizona committed
765
                "january": i[13].value == undefined ? (String(i[13]) == '' ? "0.0" : String(i[13])) : String(i[13].value),
d.arizona's avatar
d.arizona committed
766
                // "january": stateFR ? String(i[13].value) : String(i[13]) == "" ? "0.0" : String(i[13]),
d.arizona's avatar
d.arizona committed
767 768 769 770 771 772 773 774 775 776 777
                "february": i[14].value == undefined ? (String(i[14]) == '' ? "0.0" : String(i[14])) : String(i[14].value),
                "march": i[15].value == undefined ? (String(i[15]) == '' ? "0.0" : String(i[15])) : String(i[15].value),
                "april": i[16].value == undefined ? (String(i[16]) == '' ? "0.0" : String(i[16])) : String(i[16].value),
                "may": i[17].value == undefined ? (String(i[17]) == '' ? "0.0" : String(i[17])) : String(i[17].value),
                "june": i[18].value == undefined ? (String(i[18]) == '' ? "0.0" : String(i[18])) : String(i[18].value),
                "july": i[19].value == undefined ? (String(i[19]) == '' ? "0.0" : String(i[19])) : String(i[19].value),
                "august": i[20].value == undefined ? (String(i[20]) == '' ? "0.0" : String(i[20])) : String(i[20].value),
                "september": i[21].value == undefined ? (String(i[21]) == '' ? "0.0" : String(i[21])) : String(i[21].value),
                "october": i[22].value == undefined ? (String(i[22]) == '' ? "0.0" : String(i[22])) : String(i[22].value),
                "november": i[23].value == undefined ? (String(i[23]) == '' ? "0.0" : String(i[23])) : String(i[23].value),
                "december": i[24].value == undefined ? (String(i[24]) == '' ? "0.0" : String(i[24])) : String(i[24].value),
Deni Rinaldi's avatar
Deni Rinaldi committed
778 779 780
                "total_current_year": String(i[25]) == "" ? "0.0" : String(i[25]),
                "total_next_year": String(i[26]) == "" ? "0.0" : String(i[26]),
                "total_more_year": String(i[27]) == "" ? "0.0" : String(i[27]),
d.arizona's avatar
d.arizona committed
781 782 783
                "strategic": String(i[28]),
                "pic": String(i[29])
            })
d.arizona's avatar
d.arizona committed
784
            stateFR = false
d.arizona's avatar
d.arizona committed
785
        })
d.arizona's avatar
d.arizona committed
786

d.arizona's avatar
d.arizona committed
787 788
        // // // // console.log(dataTableBaru)
        // // // // console.log(JSON.stringify(data))
d.arizona's avatar
d.arizona committed
789 790 791 792 793 794 795 796
        let payload = {
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": "submitted",
            "cat": data
        }
d.arizona's avatar
d.arizona committed
797
        // // // // console.log(totalWeight)
d.arizona's avatar
d.arizona committed
798
        // this.setState({dataTable: dataTampung})
d.arizona's avatar
d.arizona committed
799
        if (handleKosongKPIMAXYTD) {
Deni Rinaldi's avatar
Deni Rinaldi committed
800
            this.setState({ alert: true, messageAlert: 'KPI / Weight / KPI Type / Max Ach / Formula YTD / Cannot be Empty', tipeAlert: 'warning', loading: false, editable: true })
d.arizona's avatar
d.arizona committed
801
        } else if (totalWeight < 100) {
Deni Rinaldi's avatar
Deni Rinaldi committed
802
            this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, editable: true })
d.arizona's avatar
d.arizona committed
803
        } else {
d.arizona's avatar
d.arizona committed
804
            console.log(JSON.stringify(payload))
d.arizona's avatar
d.arizona committed
805
            api.create().validateSubmitReport(payload).then((response) => {
d.arizona's avatar
d.arizona committed
806
                console.log(response)
d.arizona's avatar
d.arizona committed
807
                if (response.data.data.result) {
d.arizona's avatar
d.arizona committed
808
                    this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false })
d.arizona's avatar
d.arizona committed
809
                } else {
d.arizona's avatar
d.arizona committed
810
                    this.setState({ loading: false, buttonError: true, editable: true, buttonDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
811
                }
d.arizona's avatar
d.arizona committed
812 813
            })
        }
d.arizona's avatar
d.arizona committed
814 815 816 817 818 819
    }

    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
820 821
    backToMasterBudget(type) {
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
822
        let stateFR = false
d.arizona's avatar
d.arizona committed
823
        // // // console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
824
        this.state.dataTable.map(i => {
Deni Rinaldi's avatar
Deni Rinaldi committed
825 826
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
d.arizona's avatar
d.arizona committed
827 828
                // // // // console.log(indexID)
                // // // // console.log(i[2])
Deni Rinaldi's avatar
Deni Rinaldi committed
829
                if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
830
                    // // // // console.log(dataTableBaru[indexID][6])
Deni Rinaldi's avatar
Deni Rinaldi committed
831 832 833 834 835 836
                    if (this.state.dataTable[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
d.arizona's avatar
d.arizona committed
837 838
            } else {
                stateFR = false
Deni Rinaldi's avatar
Deni Rinaldi committed
839
            }
d.arizona's avatar
d.arizona committed
840
            // // // // // console.log(i[9] == null? "" : i[9].value)
faisalhamdi's avatar
faisalhamdi committed
841
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
842
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
843 844
                "item_name": String(i[6]),
                "parent": i[2] == "" ? null : i[2],
d.arizona's avatar
d.arizona committed
845 846
                "weight": String(i[7]),
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
847 848 849 850
                "kpi_type": i[9] == null ? "" : i[9].value,
                "max_ach": i[10] == null ? "" : i[10].value,
                "formula": i[11] == null ? "" : i[11].value,
                "total_actual_before": String(i[12]) == "" ? "0.0" : String(i[12]),
d.arizona's avatar
d.arizona committed
851 852 853 854 855 856 857 858 859 860 861 862
                "january": i[13].value != undefined? String(Number(i[13].value).toFixed(1)) : String(i[13]),
                "february": i[14].value != undefined? String(Number(i[14].value).toFixed(1)) : String(i[14]),
                "march": i[15].value != undefined? String(Number(i[15].value).toFixed(1)) : String(i[15]),
                "april": i[16].value != undefined? String(Number(i[16].value).toFixed(1)) : String(i[16]),
                "may": i[17].value != undefined? String(Number(i[17].value).toFixed(1)) : String(i[17]),
                "june": i[18].value != undefined? String(Number(i[18].value).toFixed(1)) : String(i[18]),
                "july": i[19].value != undefined? String(Number(i[19].value).toFixed(1)) : String(i[19]),
                "august": i[20].value != undefined? String(Number(i[20].value).toFixed(1)) : String(i[20]),
                "september": i[21].value != undefined? String(Number(i[21].value).toFixed(1)) : String(i[21]),
                "october": i[22].value != undefined? String(Number(i[22].value).toFixed(1)) : String(i[22]),
                "november": i[23].value != undefined? String(Number(i[23].value).toFixed(1)) : String(i[23]),
                "december": i[24].value != undefined? String(Number(i[24].value).toFixed(1)) : String(i[24]),
d.arizona's avatar
d.arizona committed
863 864 865
                "total_current_year": String(Number(i[25]).toFixed(1)) == "" ? "0.0" : String(Number(i[25]).toFixed(1)),
                "total_next_year": String(Number(i[26]).toFixed(1)) == "" ? "0.0" : String(Number(i[26]).toFixed(1)),
                "total_more_year": String(Number(i[27]).toFixed(1)) == "" ? "0.0" : String(Number(i[27]).toFixed(1)),
d.arizona's avatar
d.arizona committed
866 867
                "strategic": String(i[28]),
                "pic": String(i[29])
faisalhamdi's avatar
faisalhamdi committed
868 869
            })
        })
d.arizona's avatar
d.arizona committed
870
        // // // console.log(JSON.stringify(data))
faisalhamdi's avatar
faisalhamdi committed
871 872 873 874 875 876
        let payload = {
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
d.arizona's avatar
d.arizona committed
877
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
878
        }
d.arizona's avatar
d.arizona committed
879
        console.log(JSON.stringify(payload));
d.arizona's avatar
d.arizona committed
880
        this.deleteReport(payload)
d.arizona's avatar
d.arizona committed
881 882
    }

d.arizona's avatar
d.arizona committed
883
    deleteReport(payloadBro) {
Deni Rinaldi's avatar
Deni Rinaldi committed
884 885
        let payload = { "item_report_id": this.state.dataDelete }

d.arizona's avatar
d.arizona committed
886 887
        if (this.state.dataDelete.length > 0) {
            api.create().deleteAllItemReport(payload).then((response) => {
d.arizona's avatar
d.arizona committed
888
                // // // // console.log(response)
d.arizona's avatar
d.arizona committed
889

d.arizona's avatar
d.arizona committed
890
                // api.create().validateSubmitReport(payloadBro).then((response) => {
d.arizona's avatar
d.arizona committed
891
                //     // // // // console.log(response)
d.arizona's avatar
d.arizona committed
892
                //     if (response.data.data.result) {
Deni Rinaldi's avatar
Deni Rinaldi committed
893 894
                this.props.saveToMasterBudget(payloadBro)
                this.props.onClickClose()
d.arizona's avatar
d.arizona committed
895
                //     } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
896

d.arizona's avatar
d.arizona committed
897 898 899 900
                //     }
                // })
            })
        } else {
d.arizona's avatar
d.arizona committed
901
            // // // // // console.log('sini jing')
d.arizona's avatar
d.arizona committed
902
            // api.create().validateSubmitReport(payloadBro).then((response) => {
d.arizona's avatar
d.arizona committed
903
            //     // // // // console.log(response)
d.arizona's avatar
d.arizona committed
904
            //     if (response.data.data.result) {
Deni Rinaldi's avatar
Deni Rinaldi committed
905 906
            this.props.saveToMasterBudget(payloadBro)
            this.props.onClickClose()
d.arizona's avatar
d.arizona committed
907
            //     } else {
d.arizona's avatar
d.arizona committed
908

d.arizona's avatar
d.arizona committed
909 910 911
            //     }
            // })
        }
faisalhamdi's avatar
faisalhamdi committed
912 913
    }

d.arizona's avatar
d.arizona committed
914

d.arizona's avatar
d.arizona committed
915 916 917 918 919 920 921
    getKPIType() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'KPI_TYPE'
        }
        api.create().getAllSettingByType(body).then(response => {
d.arizona's avatar
d.arizona committed
922
            // // // // // console.log(response)
d.arizona's avatar
d.arizona committed
923 924 925 926
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
d.arizona's avatar
d.arizona committed
927
                        // // // // console.log(data)
d.arizona's avatar
d.arizona committed
928
                        let inputKPI = []
Deni Rinaldi's avatar
Deni Rinaldi committed
929

d.arizona's avatar
d.arizona committed
930 931
                        data.map((item) => {
                            inputKPI.push({
d.arizona's avatar
d.arizona committed
932
                                value: item.value
d.arizona's avatar
d.arizona committed
933
                            })
d.arizona's avatar
d.arizona committed
934 935 936 937 938
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
d.arizona's avatar
d.arizona committed
939
                        // // // // console.log(defaultProps)
d.arizona's avatar
d.arizona committed
940 941 942
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
943
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979
                                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' })
            }
        })
    }

    getMaxAch() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'MAX_ACHIEVEMENT'
        }
        api.create().getAllSettingByType(body).then(response => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let inputMaxAch = data.map((item) => {
                            return {
                                value: item.value
                            }
                        })
                        let defaultProps = {
                            options: inputMaxAch,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
d.arizona's avatar
d.arizona committed
980
                        // setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
981
                        this.setState({ maxAchList: defaultProps })
d.arizona's avatar
d.arizona committed
982
                        // }, 300);
d.arizona's avatar
d.arizona committed
983 984
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
985
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
986 987 988 989 990 991 992 993 994 995 996 997 998 999
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                        // alert(response.data.message)
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
d.arizona's avatar
d.arizona committed
1000
            this.getItemHierarki()
d.arizona's avatar
d.arizona committed
1001 1002 1003
        })
    }

d.arizona's avatar
d.arizona committed
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
    getLatestUpdate() {
        let payload = {
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID
        }
        api.create().getLastestUpdateMB(payload).then(response => {
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
1016
                        updateBy: response.data.data.detail === null ? '-' : response.data.data.detail
d.arizona's avatar
d.arizona committed
1017
                    })
Riri Novita's avatar
Riri Novita committed
1018 1019
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
1020
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
1021 1022 1023 1024 1025 1026
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
d.arizona's avatar
d.arizona committed
1027 1028 1029 1030 1031
                }
            }
        })
    }

1032
    render() {
faisalhamdi's avatar
faisalhamdi committed
1033
        let dataTable2 = this.state.dataTable
d.arizona's avatar
d.arizona committed
1034
        let dataDelete = this.state.dataDelete
faisalhamdi's avatar
faisalhamdi committed
1035 1036
        const handleChange = (value, tableMeta) => {
            let val = String(value).split(",").join("")
d.arizona's avatar
d.arizona committed
1037
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
d.arizona's avatar
d.arizona committed
1038 1039
        }

d.arizona's avatar
d.arizona committed
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
        const handleValueFormula = (value, tableMeta, column, periode, forecast) => {
            // loading = true
            let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
            let baru = []
            let anjay = []

            splitFormula.map((item, index) => {
                let items = String(item).substr(Number(String(item).length) - 1, 1)
                let subForm = String(item).substr(0, Number(String(item).length) - 1)
                let re = /^[a-zA-Z0-9_]+$/;
                if (item !== "") {
                    if (!re.test(items)) {
                        baru.push(subForm)
                        baru.push(items)
                    } else {
                        baru.push(String(item))
                    }
                }
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
1059

d.arizona's avatar
d.arizona committed
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069
            baru.map((item, index) => {
                if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
                    anjay.push(item)
                } else if (item == '' || item == '@') {

                } else if (item == "CurrMonth") {
                    anjay.push(String(column))
                } else if (item.includes('[CM]SUM')) {
                    let columnStart = 13
                    let indexX = String(item).indexOf('[')
Deni Rinaldi's avatar
Deni Rinaldi committed
1070
                    let formulaAwal = String(item).substr(0, indexX)
d.arizona's avatar
d.arizona committed
1071
                    let columnEnd = 24
Deni Rinaldi's avatar
Deni Rinaldi committed
1072
                    let month = column - 1
d.arizona's avatar
d.arizona committed
1073
                    let total = 0
d.arizona's avatar
d.arizona committed
1074
                    // // // console.log(formulaAwal)
Deni Rinaldi's avatar
Deni Rinaldi committed
1075 1076
                    if (forecast == undefined) {
                        dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
d.arizona's avatar
d.arizona committed
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
                            if (indexz >= columnStart && indexz <= columnStart + month) {
                                let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${formulaAwal}`) && val.periode == Number(this.props.periode))
                                if (indexID !== -1) {
                                    let valuezz = Number(value.formula[indexID].value)
                                    total += valuezz
                                }
                            }
                        })
                    } else {

                    }
                    anjay.push(String(total))
                } else if (item.includes('[CM]AVG')) {
                    if (forecast == undefined) {
                        anjay.push('/')
Deni Rinaldi's avatar
Deni Rinaldi committed
1092
                        anjay.push(column)
d.arizona's avatar
d.arizona committed
1093 1094 1095
                    }
                } else if (item.includes('X')) {
                    let indexX = String(item).indexOf('X')
d.arizona's avatar
d.arizona committed
1096
                    // console.log(item)
d.arizona's avatar
d.arizona committed
1097
                    if (indexX == 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1098
                        anjay.push(String(item).substr(1, String(item).length))
d.arizona's avatar
d.arizona committed
1099
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1100 1101 1102 1103
                        let formulaAwal = String(item).substr(0, indexX - 1)
                        let operatorX = String(item).substr(indexX - 1, 1)
                        let nilaiX = String(item).substr(indexX + 1, String(item).length)

d.arizona's avatar
d.arizona committed
1104
                        if (forecast == undefined) {
d.arizona's avatar
d.arizona committed
1105 1106 1107 1108
                            let convertID = -1
                            if (tableMeta.rowData[11].value == 'FORMULA') {
                                let indexIDReport = dataTable2.findIndex((val) => val[1] == formulaAwal)
                                convertID = dataTable2[indexIDReport][31]
d.arizona's avatar
d.arizona committed
1109 1110
                                let indexID = dataTable2.findIndex((val) => val[31] == (convertID == -1 ? item : convertID))
                                let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
d.arizona's avatar
d.arizona committed
1111
                                anjay.push(valuezz == "" ? 0 : valuezz)
d.arizona's avatar
d.arizona committed
1112 1113 1114 1115 1116 1117
                            } else {
                                let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${formulaAwal}`) && val.periode == Number(this.props.periode))
                                if (indexID !== -1) {
                                    let valuezz = value.formula[indexID].value
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
d.arizona's avatar
d.arizona committed
1118 1119
                            }
                        } else {
d.arizona's avatar
d.arizona committed
1120
                            // // // console.log(dataTable2[tableMeta.rowIndex][30])
d.arizona's avatar
d.arizona committed
1121
                            let array = dataTable2[tableMeta.rowIndex][30].filter((val) => val.periode == Number(column))
d.arizona's avatar
d.arizona committed
1122
                            let valuezz = array[0].value
d.arizona's avatar
d.arizona committed
1123
                            // // // console.log(valuezz)
d.arizona's avatar
d.arizona committed
1124 1125 1126 1127 1128 1129 1130
                            anjay.push(valuezz == "" ? 0 : valuezz)
                            // let indexID = dataTable2[tableMeta.rowIndex][30].findIndex((val) => val.periode == Number(this.props.periode))
                            // if (indexID !== -1) {
                            //     let valuezz = value.formula[indexID].value
                            //     anjay.push(valuezz == "" ? 0 : valuezz)
                            // }
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
1131

d.arizona's avatar
d.arizona committed
1132 1133 1134 1135
                        anjay.push(operatorX)
                        anjay.push(nilaiX)
                    }
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1136
                    if (String(item).includes('#')) {
d.arizona's avatar
d.arizona committed
1137 1138 1139 1140
                        if (forecast == undefined) {
                            let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
                            if (indexID !== -1) {
                                let valuezz = value.formula[indexID].value
Deni Rinaldi's avatar
Deni Rinaldi committed
1141
                                anjay.push(valuezz == "" || valuezz == null ? "0" : valuezz)
d.arizona's avatar
d.arizona committed
1142
                            }
d.arizona's avatar
d.arizona committed
1143 1144 1145 1146
                        } else {
                            let array = dataTable2[tableMeta.rowIndex][30].filter((val) => val.periode == Number(column))
                            let valuezz = array[0].value
                            anjay.push(valuezz == "" ? 0 : valuezz)
d.arizona's avatar
d.arizona committed
1147 1148
                        }
                    } else {
d.arizona's avatar
d.arizona committed
1149 1150 1151 1152 1153
                        let convertID = -1
                        if (tableMeta.rowData[11].value == 'FORMULA') {
                            let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
                            convertID = dataTable2[indexIDReport][31]
                        }
d.arizona's avatar
d.arizona committed
1154
                        let indexID = dataTable2.findIndex((val) => val[31] == (convertID == -1 ? item : convertID))
d.arizona's avatar
d.arizona committed
1155
                        if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
1156
                            let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
d.arizona's avatar
d.arizona committed
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169
                            if (item == dataTable2[tableMeta.rowIndex][31]) {
                                anjay.push(0)
                            } else {
                                anjay.push(valuezz == "" ? "0" : valuezz)
                            }
                        } else {
                            if (item === '(-1)') {
                                anjay.push(-1)
                            }
                        }
                    }
                }
            })
d.arizona's avatar
d.arizona committed
1170 1171 1172 1173 1174
            // if (tableMeta.rowData[11].value == 'FORMULA') {
            //     console.log(anjay)
            //     console.log(column)

            // }
d.arizona's avatar
d.arizona committed
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186

            let anjay2 = []
            let kurung = false
            let item1 = []
            let brpKurung = 0
            anjay.map((item, index) => {
                if (item == "(") {
                    kurung = true
                    // brpKurung += 1
                } else if (item == ")") {
                    // brpKurung -= 1
                    // if (brpKurung == 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1187 1188 1189
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
d.arizona's avatar
d.arizona committed
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292
                    // }
                } else {
                    if (kurung) {
                        item1.push(item)
                    } else {
                        anjay2.push(item)
                    }
                }
            })

            let total = 0
            let opt = ""
            let totalPrio = 0
            let optPrio = ""
            let prio = false
            anjay2.map((item, index) => {
                if (Array.isArray(item)) {
                    prio = true
                    item.map((items, indexs) => {
                        if (items == "+") {
                            optPrio = "tambah"
                        } else if (items == "-") {
                            optPrio = "kurang"
                        } else if (items == "*") {
                            optPrio = "kali"
                        } else if (items == "/") {
                            optPrio = "bagi"
                        } else {
                            if (optPrio == "tambah") {
                                totalPrio = Number(totalPrio) + Number(items)
                            } else if (optPrio == "kurang") {
                                totalPrio = Number(totalPrio) - Number(items)
                            } else if (optPrio == "kali") {
                                totalPrio = Number(totalPrio) * Number(items)
                            } else if (optPrio == "bagi") {
                                totalPrio = Number(totalPrio) / Number(items) == NaN ? 0 : Number(totalPrio) / Number(items)
                            } else {
                                totalPrio += Number(items)
                            }
                        }
                    })

                    if (index == anjay2.length - 1) {
                        if (opt == "tambah") {
                            total = Number(total) + Number(totalPrio)
                        } else if (opt == "kurang") {
                            total = Number(total) - Number(totalPrio)
                        } else if (opt == "kali") {
                            total = Number(total) * Number(totalPrio)
                        } else if (opt == "bagi") {
                            total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                        } else {
                            total += Number(totalPrio)
                        }
                    }
                } else {
                    if (item == "+") {
                        opt = "tambah"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "-") {
                        opt = "kurang"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "*") {
                        opt = "kali"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "/") {
                        opt = "bagi"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else {
                        if (opt == "tambah") {
                            total = Number(total) + Number(item)
                        } else if (opt == "kurang") {
                            total = Number(total) - Number(item)
                        } else if (opt == "kali") {
                            total = Number(total) * Number(item)
                        } else if (opt == "bagi") {
                            total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
                        } else {
                            total += Number(item)
                        }
                    }
                }
            })
d.arizona's avatar
d.arizona committed
1293
            // if (dataTable2[tableMeta.rowIndex][6] == "NPAT" && forecast !== undefined) {
d.arizona's avatar
d.arizona committed
1294 1295 1296 1297 1298 1299 1300
            //     // // console.log(tableMeta.rowData[3])
            //     // // console.log(splitFormula)
            //     // // console.log(baru)
            //     // // console.log(anjay)
            //     // // // console.log(item1)
            //     // // console.log(anjay2)
            //     // // console.log(total)
d.arizona's avatar
d.arizona committed
1301
            // }
d.arizona's avatar
d.arizona committed
1302 1303 1304 1305 1306 1307 1308
            // // // console.log(tableMeta.rowData[3])
            // // // console.log(splitFormula)
            // // // console.log(baru)
            // // // console.log(anjay)
            // // // console.log(item1)
            // // // console.log(anjay2)
            // // // console.log(total)
Deni Rinaldi's avatar
Deni Rinaldi committed
1309

d.arizona's avatar
d.arizona committed
1310 1311 1312 1313 1314 1315 1316 1317
            total = R.equals(total, NaN) ? "0.0" : total
            // if (dataTable2[tableMeta.rowIndex][6] == "ROIC") {
            //     if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
            //         dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = "0"
            //     } else {
            //         dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = "0"
            //     }
            // } else {
d.arizona's avatar
d.arizona committed
1318
                if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
d.arizona's avatar
d.arizona committed
1319
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total.toFixed(1)
d.arizona's avatar
d.arizona committed
1320
                } else {
d.arizona's avatar
d.arizona committed
1321
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total.toFixed(1)
d.arizona's avatar
d.arizona committed
1322
                }
d.arizona's avatar
d.arizona committed
1323
            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
1324

d.arizona's avatar
d.arizona committed
1325 1326 1327 1328 1329 1330
            return total
        }

        const handleValueForecast = (value, tableMeta, periode) => {
            return handleValueFormula(value, tableMeta, periode, periode, 'forecast')
        }
d.arizona's avatar
d.arizona committed
1331

d.arizona's avatar
d.arizona committed
1332
        const handleChangeDropdown = (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
1333
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
d.arizona's avatar
d.arizona committed
1334 1335 1336
            let valz = value.value
            let total = 0
            let lastValz = 0
d.arizona's avatar
d.arizona committed
1337
            if (valz == 'SUM' || valz == 'AVG' || valz == 'LAST' || valz == 'FORMULA') {
Deni Rinaldi's avatar
Deni Rinaldi committed
1338
                dataTable2[tableMeta.rowIndex].map((item, index) => {
d.arizona's avatar
d.arizona committed
1339
                    if (index >= 13 && index <= 24) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1340
                        let valItem = item == undefined || item == "" ? 0 : item
d.arizona's avatar
d.arizona committed
1341 1342 1343 1344 1345 1346
                        total += Number(valItem)
                        if (index == 24) {
                            lastValz += Number(valItem)
                        }
                    }
                })
d.arizona's avatar
d.arizona committed
1347 1348 1349 1350
                if (valz == 'FORMULA') {
                    dataTable2[tableMeta.rowIndex][0] = 5
                }
                dataTable2[tableMeta.rowIndex][25] = valz == 'FORMULA' ? 0 : ((valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz)))
d.arizona's avatar
d.arizona committed
1351
            }
d.arizona's avatar
d.arizona committed
1352
        }
d.arizona's avatar
d.arizona committed
1353
        const handleValueDropdown = (value, type, tableMeta) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1354
            let data = type == 'KPI' ? this.state.kpiTypeList.options : (type == 'MAX' ? this.state.maxAchList.options : this.state.formulaYtdList.options)
d.arizona's avatar
d.arizona committed
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368
            let index = 0
            if (value == null) {
                index = -1
            } else {
                index = data.findIndex((val) => val.value == value.value)
            }
            if (index == -1) {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = null
                return null
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
                return value
            }
        }
d.arizona's avatar
d.arizona committed
1369 1370

        const handleChangePercentage = (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
1371
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
d.arizona's avatar
d.arizona committed
1372

d.arizona's avatar
d.arizona committed
1373 1374 1375 1376
        }

        const handleChangeText = (value, tableMeta) => {
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
faisalhamdi's avatar
faisalhamdi committed
1377
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
1378

d.arizona's avatar
d.arizona committed
1379
        const handleAction = (idParent, typeReport, tableMeta) => {
d.arizona's avatar
d.arizona committed
1380 1381
            if (this.props.isApprover) {
                return false
d.arizona's avatar
d.arizona committed
1382
            } else {
d.arizona's avatar
d.arizona committed
1383 1384 1385 1386 1387 1388 1389 1390
                if ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) {
                    if (idParent !== null) {
                        let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
                        if (dataTable2[indexsss][6] == 'CUSTOMER PERSPECTIVE' || dataTable2[indexsss][6] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
                            return true
                        } else {
                            return false
                        }
d.arizona's avatar
d.arizona committed
1391
                    } else {
d.arizona's avatar
d.arizona committed
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403
                        if (typeReport == null || typeReport == 3) {
                            return true
                        } else if (tableMeta !== undefined && tableMeta.rowData[0] == 1) {
                            let indexID = dataTable2.findIndex((val) => val[2] == tableMeta.rowData[1])
                            if (indexID !== -1) {
                                return false
                            } else {
                                return true
                            }
                        } else {
                            return false
                        }
d.arizona's avatar
d.arizona committed
1404
                    }
d.arizona's avatar
d.arizona committed
1405 1406 1407
                } else {
                    return false
                }
d.arizona's avatar
d.arizona committed
1408
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1409

d.arizona's avatar
d.arizona committed
1410 1411
        }

d.arizona's avatar
d.arizona committed
1412 1413 1414 1415
        const handleReturnFormula = (idParent, tableMeta) => {
            if (idParent !== null) {
                let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
                if (dataTable2[indexsss][6] == 'FINANCIAL PERSPECTIVE') {
d.arizona's avatar
d.arizona committed
1416 1417 1418 1419 1420
                    if (tableMeta.rowData[0] == 3) {
                        return false
                    } else {
                        return true
                    }
d.arizona's avatar
d.arizona committed
1421 1422 1423 1424 1425 1426 1427 1428
                } else {
                    return false
                }
            } else {
                return false
            }
        }

d.arizona's avatar
d.arizona committed
1429
        const handleTambah = (data, rowIndex) => {
d.arizona's avatar
d.arizona committed
1430
            // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
1431 1432 1433
            let newData = []
            dataTable2.map((item, index) => {
                newData.push(item)
d.arizona's avatar
d.arizona committed
1434
                if (index == rowIndex) {
d.arizona's avatar
d.arizona committed
1435
                    newData.push([
d.arizona's avatar
d.arizona committed
1436
                        null,
d.arizona's avatar
d.arizona committed
1437
                        "",
Deni Rinaldi's avatar
Deni Rinaldi committed
1438
                        item[2] == null || item[2] == "" ? item[1] : item[2],
d.arizona's avatar
d.arizona committed
1439 1440 1441 1442 1443 1444
                        item[3],
                        item[4],
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
1445 1446 1447
                        null,
                        null,
                        null,
d.arizona's avatar
d.arizona committed
1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
1464
                        "",
d.arizona's avatar
d.arizona committed
1465 1466
                        ""
                    ])
Deni Rinaldi's avatar
Deni Rinaldi committed
1467

d.arizona's avatar
d.arizona committed
1468 1469 1470
                }
            })
            dataTable2 = newData
Deni Rinaldi's avatar
Deni Rinaldi committed
1471
            this.setState({ dataTable: dataTable2 }, () => {
d.arizona's avatar
d.arizona committed
1472
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1473
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
1474
                    // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1475
                }, 500)
d.arizona's avatar
d.arizona committed
1476 1477 1478 1479
            })
        }

        const handleDelete = (index) => {
d.arizona's avatar
d.arizona committed
1480 1481 1482
            if (dataTable2[index][1] !== "") {
                dataDelete.push(dataTable2[index][1])
            }
d.arizona's avatar
d.arizona committed
1483
            dataTable2.splice(index, 1)
Deni Rinaldi's avatar
Deni Rinaldi committed
1484
            this.setState({ dataTable: dataTable2, dataDelete }, () => {
d.arizona's avatar
d.arizona committed
1485
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1486
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
1487
                }, 100)
d.arizona's avatar
d.arizona committed
1488 1489
            })
        }
d.arizona's avatar
d.arizona committed
1490

Deni Rinaldi's avatar
Deni Rinaldi committed
1491
        const handleTotal = (tableMeta, type) => {
d.arizona's avatar
d.arizona committed
1492 1493 1494
            // let val = String(value).split(",").join("")
            let total = 0
            let lastValz = 0
d.arizona's avatar
d.arizona committed
1495 1496 1497 1498 1499
            // if (type === 'roic') {
            //     dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = tableMeta.rowData[24]
            //     total = Number(tableMeta.rowData[24])
            //     return total
            // } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1500 1501 1502 1503 1504 1505 1506
                dataTable2[tableMeta.rowIndex].map((item, index) => {
                    if (index >= 13 && index <= 24) {
                        let valItem = item == undefined || item == "" ? 0 : item
                        total += Number(valItem)
                        if (index == 24) {
                            lastValz += Number(valItem)
                        }
d.arizona's avatar
d.arizona committed
1507
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1508 1509 1510 1511
                })
                let valz = dataTable2[tableMeta.rowIndex][11] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][11].value
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
                return (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
d.arizona's avatar
d.arizona committed
1512
            // }
d.arizona's avatar
d.arizona committed
1513 1514
        }

1515
        const columns = [{
faisalhamdi's avatar
faisalhamdi committed
1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
d.arizona's avatar
d.arizona committed
1541 1542
            name: "",
            options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
1543
                filter: false,
d.arizona's avatar
d.arizona committed
1544
                display: this.props.isApprover ? false : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? true : false),
Deni Rinaldi's avatar
Deni Rinaldi committed
1545 1546 1547 1548
                customHeadRender: (columnMeta) => (
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#dbdbdb' }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                    </TableCell>
d.arizona's avatar
d.arizona committed
1549
                ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1550 1551 1552
                customBodyRender: (val, tableMeta) => {
                    return (
                        // handleAction(tableMeta.rowData[2]) && 
d.arizona's avatar
d.arizona committed
1553
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1554
                            {/* {tableMeta.rowData[6] === "Active" ? */}
d.arizona's avatar
d.arizona committed
1555
                            {handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && <span>
Deni Rinaldi's avatar
Deni Rinaldi committed
1556 1557 1558 1559 1560 1561 1562
                                <LightTooltip title={'Add'} arrow>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                        }}
d.arizona's avatar
d.arizona committed
1563
                                        // onClick={() => // // // // console.log(tableMeta.rowData[1])}
Deni Rinaldi's avatar
Deni Rinaldi committed
1564 1565 1566 1567 1568 1569 1570 1571 1572
                                        onClick={() => {
                                            this.setState({ loading: true })
                                            handleTambah(tableMeta.rowData[1], tableMeta.rowIndex)
                                        }}
                                    >
                                        <img src={Images.add} />
                                    </button>
                                </LightTooltip>
                            </span>}
d.arizona's avatar
d.arizona committed
1573
                            {handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) && <span>
Deni Rinaldi's avatar
Deni Rinaldi committed
1574 1575 1576 1577 1578 1579 1580 1581 1582
                                <LightTooltip title={'Delete'} arrow>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            marginLeft: 5
                                        }}
                                        onClick={() => {
d.arizona's avatar
d.arizona committed
1583 1584
                                            this.setState({ loading: true })
                                            handleDelete(tableMeta.rowIndex)
Deni Rinaldi's avatar
Deni Rinaldi committed
1585 1586 1587 1588 1589
                                        }}
                                    >
                                        <img src={Images.delete} />
                                    </button>
                                </LightTooltip>
d.arizona's avatar
d.arizona committed
1590
                            </span>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1591 1592 1593
                        </div >
                    );
                }
d.arizona's avatar
d.arizona committed
1594
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1595
        }, {
1596 1597 1598
            name: "Key Performance Indicator",
            options: {
                customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1599
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8' }}>
d.arizona's avatar
d.arizona committed
1600
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
1601 1602 1603 1604 1605
                    </TableCell>
                ),
                setCellProps: () => ({ style }),
                customBodyRender: (val, tableMeta) => {
                    return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1606
                        handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && (tableMeta.rowData[1] == "" || String(this.props.status).toLocaleLowerCase() == 'draft' || String(this.props.status).toLocaleLowerCase() == 'submitted' || String(this.props.status).toLocaleLowerCase() == 'revision') ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1607
                            <div style={{ textAlign: 'left', paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
d.arizona's avatar
d.arizona committed
1608
                                {!this.state.loading && <FormControlLabel
Deni Rinaldi's avatar
Deni Rinaldi committed
1609 1610 1611 1612 1613 1614 1615 1616 1617 1618
                                    style={{ margin: 0 }}
                                    control={
                                        <Input
                                            disableUnderline={true}
                                            style={{ color: tableMeta.rowData[1] == "" ? "#5198ea" : "black", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            defaultValue={val}
                                            // disabled={!handleAction(tableMeta.rowData[2])}
                                            onBlur={(event) => {
d.arizona's avatar
d.arizona committed
1619
                                                // // // // console.log(event.target.value)
Deni Rinaldi's avatar
Deni Rinaldi committed
1620
                                                handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1621
                                                // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1622 1623 1624
                                            }}
                                        />
                                    }
d.arizona's avatar
d.arizona committed
1625
                                />}
Deni Rinaldi's avatar
Deni Rinaldi committed
1626 1627 1628
                            </div>
                            :
                            <div style={{ width: 300 }}>
d.arizona's avatar
d.arizona committed
1629 1630
                                {tableMeta.rowData[32] ?
                                    tableMeta.rowData[32].length > 0 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                            <LightTooltip title={"Report Items Not Registered"} arrow>
                                                <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </LightTooltip>
                                        </div>
                                        :
                                        tableMeta.rowData[4] == 0 ?
                                            <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                            :
                                            tableMeta.rowData[1] == null ?
                                                <div style={{ paddingLeft: 20 }}>
                                                    <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                </div>
                                                :
                                                <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                    <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                </div>
d.arizona's avatar
d.arizona committed
1648 1649 1650 1651
                                    :
                                    tableMeta.rowData[4] == 0 ?
                                        <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                        :
Deni Rinaldi's avatar
Deni Rinaldi committed
1652 1653
                                        tableMeta.rowData[1] == null ?
                                            <div style={{ paddingLeft: 20 }}>
d.arizona's avatar
d.arizona committed
1654 1655
                                                <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1656
                                            :
d.arizona's avatar
d.arizona committed
1657 1658 1659
                                            <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1660 1661
                                }
                            </div>
1662 1663 1664 1665 1666 1667 1668
                    )
                }
            }
        }, {
            name: "Weight",
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1669
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1670 1671 1672
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1673 1674 1675 1676
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1677
                            {tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1678
                                null :
Deni Rinaldi's avatar
Deni Rinaldi committed
1679
                                tableMeta.rowData[0] === 1 ?
d.arizona's avatar
d.arizona committed
1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693
                                    value
                                    :
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    suffix="%"
                                                    style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    value={value}
Deni Rinaldi's avatar
Deni Rinaldi committed
1694
                                                    disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
d.arizona's avatar
d.arizona committed
1695 1696 1697 1698 1699 1700 1701 1702 1703
                                                    maxLength={4}
                                                    onBlur={(event) => {
                                                        // updateValue(some)
                                                        handleChangePercentage(event.target.value, tableMeta)
                                                    }}
                                                />
                                            }
                                        />
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
1704 1705 1706 1707
                            }
                        </div>
                    )
                }
1708 1709 1710 1711 1712
            }
        }, {
            name: "UOM",
            options: {
                customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1713
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8' }}>
1714 1715 1716 1717 1718 1719
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1720
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1721 1722 1723
                                null :
                                <FormControlLabel
                                    style={{ margin: 0 }}
d.arizona's avatar
d.arizona committed
1724
                                    // value={value}
d.arizona's avatar
d.arizona committed
1725
                                    control={
d.arizona's avatar
d.arizona committed
1726
                                        !handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) ?
d.arizona's avatar
d.arizona committed
1727 1728
                                            <Input
                                                disableUnderline={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1729
                                                style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginTop: -10 }}
d.arizona's avatar
d.arizona committed
1730 1731 1732 1733
                                                type="text"
                                                placeholder=""
                                                defaultValue={value}
                                                color={"#5198ea"}
d.arizona's avatar
d.arizona committed
1734
                                                disabled={true}
d.arizona's avatar
d.arizona committed
1735
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
1736
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
1737 1738
                                                    // updateValue(event.target.value)
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1739
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
1740
                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1741 1742 1743 1744 1745 1746 1747 1748 1749
                                            /> :
                                            <ThemeProvider theme={theme}>
                                                <Input
                                                    disableUnderline={true}
                                                    style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginBottom: -5 }}
                                                    type="text"
                                                    placeholder=""
                                                    defaultValue={value}
                                                    color={"#5198ea"}
d.arizona's avatar
d.arizona committed
1750
                                                    // disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))}
Deni Rinaldi's avatar
Deni Rinaldi committed
1751
                                                    onBlur={(event) => {
d.arizona's avatar
d.arizona committed
1752
                                                        // // // // console.log(event.target.value)
Deni Rinaldi's avatar
Deni Rinaldi committed
1753 1754
                                                        // updateValue(event.target.value)
                                                        handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1755
                                                        // // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1756 1757 1758
                                                    }}
                                                />
                                            </ThemeProvider>
d.arizona's avatar
d.arizona committed
1759
                                    }
d.arizona's avatar
d.arizona committed
1760
                                />
1761 1762 1763 1764 1765 1766
                            }
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
1767
            name: "KPI Type",
1768 1769
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
1770
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1771 1772 1773
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
1774
                customBodyRender: (val, tableMeta) => {
1775 1776
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1777
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1778 1779 1780 1781 1782 1783 1784
                                null :
                                <Autocomplete
                                    {...this.state.kpiTypeList}
                                    id="kpiType"
                                    onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
                                    debug
                                    disableClearable
d.arizona's avatar
d.arizona committed
1785
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
d.arizona's avatar
d.arizona committed
1786
                                    value={handleValueDropdown(val, 'KPI', tableMeta)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1787
                                    style={{ padding: 0, margin: 0 }}
d.arizona's avatar
d.arizona committed
1788
                                    renderInput={(params) =>
Deni Rinaldi's avatar
Deni Rinaldi committed
1789
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
d.arizona's avatar
d.arizona committed
1790
                                            <input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0, color: handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) ? "#5198ea" : "black" }} type="text" {...params.inputProps} />
d.arizona's avatar
d.arizona committed
1791 1792 1793 1794
                                        </div>
                                    }
                                />
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1795

1796 1797 1798 1799 1800 1801 1802 1803
                        </div>
                    )
                }
            }
        }, {
            name: "Max Ach.",
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
1804
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1805 1806 1807
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
1808
                customBodyRender: (val, tableMeta) => {
1809 1810
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1811
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1812 1813
                                null :
                                <Autocomplete
Deni Rinaldi's avatar
Deni Rinaldi committed
1814 1815 1816 1817 1818
                                    {...this.state.maxAchList}
                                    id="maxAchList"
                                    onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
                                    debug
                                    disableClearable
d.arizona's avatar
d.arizona committed
1819
                                    value={handleValueDropdown(val, 'MAX', tableMeta)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1820
                                    style={{ padding: 0, margin: 0 }}
d.arizona's avatar
d.arizona committed
1821
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
Deni Rinaldi's avatar
Deni Rinaldi committed
1822 1823
                                    renderInput={(params) =>
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
d.arizona's avatar
d.arizona committed
1824
                                            <input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0, color: handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) ? "#5198ea" : "black" }} type="text" {...params.inputProps} />
Deni Rinaldi's avatar
Deni Rinaldi committed
1825 1826
                                        </div>
                                    }
d.arizona's avatar
d.arizona committed
1827 1828 1829
                                // value={this.state.parent}
                                />
                            }
1830 1831 1832 1833 1834 1835 1836 1837
                        </div>
                    )
                }
            }
        }, {
            name: "Formula YTD",
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
1838
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1839 1840 1841
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
1842
                customBodyRender: (val, tableMeta, updateValue) => {
1843
                    return (
d.arizona's avatar
d.arizona committed
1844
                        <div style={{ width: 105 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1845
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1846 1847 1848 1849 1850 1851
                                null :
                                <Autocomplete
                                    {...this.state.formulaYtdList}
                                    id="formulaYtdList"
                                    onChange={(event, newInputValue) => {
                                        // updateValue(newInputValue)
Deni Rinaldi's avatar
Deni Rinaldi committed
1852 1853
                                        handleChangeDropdown(newInputValue, tableMeta)
                                    }
d.arizona's avatar
d.arizona committed
1854 1855 1856
                                    }
                                    debug
                                    disableClearable
d.arizona's avatar
d.arizona committed
1857
                                    value={handleValueDropdown(val, 'FORMULA', tableMeta)}
d.arizona's avatar
d.arizona committed
1858
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
Deni Rinaldi's avatar
Deni Rinaldi committed
1859
                                    style={{ padding: 0, margin: 0 }}
d.arizona's avatar
d.arizona committed
1860
                                    renderInput={(params) =>
Deni Rinaldi's avatar
Deni Rinaldi committed
1861
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
d.arizona's avatar
d.arizona committed
1862
                                            <input style={{ borderColor: 'white', width: 105, textAlign: 'center', padding: 0, margin: 0, color: handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) ? "#5198ea" : "black" }} type="text" {...params.inputProps} />
d.arizona's avatar
d.arizona committed
1863 1864
                                        </div>
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1865
                                // value={this.state.parent}
d.arizona's avatar
d.arizona committed
1866 1867
                                />
                            }
1868 1869 1870 1871 1872
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
1873
            name: `${Number(this.props.periode) - 1}`,
faisalhamdi's avatar
faisalhamdi committed
1874 1875
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1876
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1877 1878
                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
faisalhamdi's avatar
faisalhamdi committed
1879
                ),
d.arizona's avatar
d.arizona committed
1880
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1881 1882
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1883
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1884 1885 1886
                                null
                                :
                                <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929
                                    {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && tableMeta.rowData[11].value == 'FORMULA' ?
                                        // null
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    value={Number(handleValueFormula(value, tableMeta, 0)).toFixed(1)}
                                                    disabled
                                                    decimalScale={1}
                                                    onBlur={(event) => {
                                                        // updateValue(event.target.value)
                                                        handleChange(event.target.value, tableMeta)
                                                        // // // // console.log(tableMeta.rowData[0])
                                                    }}
                                                />
                                            }
                                        />
                                        :
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    value={Number(value).toFixed(1)}
                                                    disabled={true}
                                                    decimalScale={1}
                                                    onBlur={(event) => {
                                                        // updateValue(event.target.value)
                                                        handleChange(event.target.value, tableMeta)
                                                        // // // // console.log(dataTable2)
                                                    }}
                                                />
                                            }
                                        />}
Deni Rinaldi's avatar
Deni Rinaldi committed
1930
                                </div>
d.arizona's avatar
d.arizona committed
1931
                            }
faisalhamdi's avatar
faisalhamdi committed
1932 1933 1934 1935 1936
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
1937
            name: `Jan ${this.props.periode}`,
1938 1939
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
1940
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1941 1942 1943
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
1944
                customBodyRender: (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
1945
                    // // // // console.log(tableMeta.rowData[0])
1946 1947
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1948
                            {
d.arizona's avatar
d.arizona committed
1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 1)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
1993
                                            />
d.arizona's avatar
d.arizona committed
1994
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1995
                                        :
d.arizona's avatar
d.arizona committed
1996 1997 1998
                                        <div style={{ flex: 1 }}>
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
Deni Rinaldi's avatar
Deni Rinaldi committed
1999 2000 2001 2002 2003 2004
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
d.arizona's avatar
d.arizona committed
2005
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2006 2007
                                                            type="text"
                                                            placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
2008
                                                            value={Number(handleValueFormula(value, tableMeta, 1)).toFixed(1)}
d.arizona's avatar
d.arizona committed
2009
                                                            disabled
Deni Rinaldi's avatar
Deni Rinaldi committed
2010 2011 2012 2013
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
2014
                                                                // // // // console.log(tableMeta.rowData[0])
Deni Rinaldi's avatar
Deni Rinaldi committed
2015 2016 2017 2018
                                                            }}
                                                        />
                                                    }
                                                />
d.arizona's avatar
d.arizona committed
2019
                                                :
Deni Rinaldi's avatar
Deni Rinaldi committed
2020 2021 2022 2023 2024 2025 2026 2027 2028
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
2029
                                                            value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
2030 2031 2032 2033 2034
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
2035
                                                                // // // // console.log(tableMeta.rowData[0])
Deni Rinaldi's avatar
Deni Rinaldi committed
2036 2037 2038 2039
                                                            }}
                                                        />
                                                    }
                                                />
d.arizona's avatar
d.arizona committed
2040 2041
                                            }
                                        </div>)
d.arizona's avatar
d.arizona committed
2042
                            }
2043 2044 2045 2046 2047
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2048
            name: `Feb ${this.props.periode}`,
2049 2050
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2051
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
2052 2053 2054
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2055
                customBodyRender: (value, tableMeta) => {
2056 2057
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2058
                            {
d.arizona's avatar
d.arizona committed
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2103
                                            />
d.arizona's avatar
d.arizona committed
2104
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2105
                                        :
d.arizona's avatar
d.arizona committed
2106
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
2150
                                        </div>)
d.arizona's avatar
d.arizona committed
2151
                            }
2152 2153 2154 2155 2156
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2157
            name: `Mar ${this.props.periode}`,
2158 2159
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2160
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
2161 2162 2163
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2164
                customBodyRender: (value, tableMeta) => {
2165 2166
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2167
                            {
d.arizona's avatar
d.arizona committed
2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2212
                                            />
d.arizona's avatar
d.arizona committed
2213
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2214
                                        :
d.arizona's avatar
d.arizona committed
2215
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
2259 2260
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
2261 2262 2263 2264 2265 2266
                            }
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2267
            name: `Apr ${this.props.periode}`,
d.arizona's avatar
d.arizona committed
2268 2269 2270 2271 2272 2273 2274 2275
            options: {
                customHeadRender: (columnMeta) => (
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
                    return (
2276
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2277
                            {
d.arizona's avatar
d.arizona committed
2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 4)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2322
                                            />
d.arizona's avatar
d.arizona committed
2323
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2324
                                        :
d.arizona's avatar
d.arizona committed
2325
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 4)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
2369 2370
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
2371
                            }
2372 2373 2374 2375 2376
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2377
            name: `May ${this.props.periode}`,
2378 2379
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2380
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
2381 2382 2383
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2384
                customBodyRender: (value, tableMeta) => {
2385 2386
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2387
                            {
d.arizona's avatar
d.arizona committed
2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 5)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2432
                                            />
d.arizona's avatar
d.arizona committed
2433
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2434
                                        :
d.arizona's avatar
d.arizona committed
2435
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 5)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
                                        </div>
                                    )
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jun ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2495 2496
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2497
                            {
d.arizona's avatar
d.arizona committed
2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 6)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2542
                                            />
d.arizona's avatar
d.arizona committed
2543
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2544
                                        :
d.arizona's avatar
d.arizona committed
2545
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 6)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
2589 2590
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
2591
                            }
faisalhamdi's avatar
faisalhamdi committed
2592 2593 2594 2595 2596
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2597
            name: `Jul ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2598 2599
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2600
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
2601 2602 2603
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2604
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2605 2606
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2607
                            {
d.arizona's avatar
d.arizona committed
2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 7)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2652
                                            />
d.arizona's avatar
d.arizona committed
2653
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2654
                                        :
d.arizona's avatar
d.arizona committed
2655
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 7)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
2699 2700
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
2701
                            }
faisalhamdi's avatar
faisalhamdi committed
2702 2703 2704 2705 2706
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2707
            name: `Aug ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2708 2709
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2710
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
2711 2712 2713
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2714
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2715 2716
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2717
                            {
d.arizona's avatar
d.arizona committed
2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 8)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2762
                                            />
d.arizona's avatar
d.arizona committed
2763
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2764
                                        :
d.arizona's avatar
d.arizona committed
2765
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 8)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
2809 2810
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
2811
                            }
faisalhamdi's avatar
faisalhamdi committed
2812 2813 2814 2815 2816
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2817
            name: `Sep ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2818 2819
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2820
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
2821 2822 2823
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2824
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2825 2826
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2827
                            {
d.arizona's avatar
d.arizona committed
2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 9)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2872
                                            />
d.arizona's avatar
d.arizona committed
2873
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2874
                                        :
d.arizona's avatar
d.arizona committed
2875
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 9)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
2919 2920
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
2921
                            }
faisalhamdi's avatar
faisalhamdi committed
2922 2923 2924 2925 2926
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2927
            name: `Oct ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2928 2929
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2930
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
2931 2932 2933
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2934
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2935 2936
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2937
                            {
d.arizona's avatar
d.arizona committed
2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 10)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
2982
                                            />
d.arizona's avatar
d.arizona committed
2983
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2984
                                        :
d.arizona's avatar
d.arizona committed
2985
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 10)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
3029 3030
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
3031
                            }
faisalhamdi's avatar
faisalhamdi committed
3032 3033 3034 3035 3036
                        </div>
                    )
                }
            }
        }, {
Deni Rinaldi's avatar
Deni Rinaldi committed
3037
            name: `Nov ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
3038 3039
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3040
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
d.arizona's avatar
d.arizona committed
3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
                    return (
                        <div style={{ width: 96 }}>
                            {
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 11)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
3092
                                            />
d.arizona's avatar
d.arizona committed
3093
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3094
                                        :
d.arizona's avatar
d.arizona committed
3095
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 11)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
3139 3140
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
3141
                            }
faisalhamdi's avatar
faisalhamdi committed
3142 3143 3144 3145 3146
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3147
            name: `Dec ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
3148 3149
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3150
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
3151 3152 3153
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3154
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
3155 3156
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3157
                            {
d.arizona's avatar
d.arizona committed
3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueFormula(value, tableMeta, 12)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
3202
                                            />
d.arizona's avatar
d.arizona committed
3203
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3204
                                        :
d.arizona's avatar
d.arizona committed
3205
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 12)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
3249 3250
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
3251
                            }
faisalhamdi's avatar
faisalhamdi committed
3252 3253 3254 3255 3256
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3257
            name: `${this.props.periode} Total`,
faisalhamdi's avatar
faisalhamdi committed
3258 3259
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3260
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
3261 3262 3263
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3264
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
3265 3266
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3267
                            {
d.arizona's avatar
d.arizona committed
3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <div style={{ flex: 1 }}>
                                //         <FormControlLabel
                                //             style={{ margin: 0 }}
                                //             value={value}
                                //             control={
                                //                 <NumberFormat
                                //                     thousandSeparator={true}
                                //                     style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                     type="text"
                                //                     placeholder=""
                                //                     value={Number(handleTotal(tableMeta, 'roic')).toFixed(1)}
                                //                     disabled={true}
                                //                     onBlur={(event) => {
                                //                         // updateValue(event.target.value)
                                //                         handleChange(event.target.value, tableMeta)
                                //                         // // // // console.log(tableMeta.rowData[0])
                                //                     }}
                                //                 />
                                //             }
                                //         />
                                //     </div> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueForecast(value, tableMeta, this.props.periode)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
Deni Rinaldi's avatar
Deni Rinaldi committed
3319 3320 3321 3322 3323 3324 3325 3326 3327
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
d.arizona's avatar
d.arizona committed
3328 3329
                                                            value={Number(handleValueFormula(value, tableMeta, 13)).toFixed(1)}
                                                            disabled
Deni Rinaldi's avatar
Deni Rinaldi committed
3330 3331 3332 3333
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3334
                                                                // // // // console.log(tableMeta.rowData[0])
Deni Rinaldi's avatar
Deni Rinaldi committed
3335 3336 3337 3338
                                                            }}
                                                        />
                                                    }
                                                />
d.arizona's avatar
d.arizona committed
3339
                                                :
Deni Rinaldi's avatar
Deni Rinaldi committed
3340 3341 3342 3343 3344 3345 3346 3347 3348
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
3349
                                                            value={Number(handleTotal(tableMeta)).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
3350 3351 3352 3353 3354
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3355
                                                                // // // // console.log(tableMeta.rowData[0])
Deni Rinaldi's avatar
Deni Rinaldi committed
3356 3357 3358
                                                            }}
                                                        />
                                                    }
d.arizona's avatar
d.arizona committed
3359 3360 3361
                                                />}
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
3362
                            }
faisalhamdi's avatar
faisalhamdi committed
3363 3364 3365 3366 3367
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3368
            name: `${Number(this.props.periode) + 1} Total`,
3369 3370
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3371
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3372 3373 3374
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3375
                customBodyRender: (value, tableMeta) => {
3376 3377
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3378
                            {
d.arizona's avatar
d.arizona committed
3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueForecast(value, tableMeta, Number(this.props.periode) + 1)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
3423
                                            />
d.arizona's avatar
d.arizona committed
3424
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3425
                                        :
d.arizona's avatar
d.arizona committed
3426
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 14)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: '#5198ea', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={false}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
3470 3471
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
3472
                            }
3473 3474 3475 3476 3477
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3478
            name: `${Number(this.props.periode) + 2} Total`,
3479 3480
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3481
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3482 3483 3484
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3485
                customBodyRender: (value, tableMeta) => {
3486 3487
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3488
                            {
d.arizona's avatar
d.arizona committed
3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532
                                // tableMeta.rowData[6] === 'ROIC' ?
                                //     <FormControlLabel
                                //         style={{ margin: 0 }}
                                //         value={value}
                                //         control={
                                //             <NumberFormat
                                //                 thousandSeparator={true}
                                //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                //                 type="text"
                                //                 placeholder=""
                                //                 value={Number(value).toFixed(1)}
                                //                 disabled={true}
                                //                 onBlur={(event) => {
                                //                     // updateValue(event.target.value)
                                //                     handleChange(event.target.value, tableMeta)
                                //                     // // // // console.log(tableMeta.rowData[0])
                                //                 }}
                                //             />
                                //         }
                                //     /> :
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        value={Number(handleValueForecast(value, tableMeta, Number(this.props.periode) + 2)).toFixed(1)}
                                                        disabled={true}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // // // console.log(tableMeta.rowData[0])
                                                        }}
                                                    />
                                                }
d.arizona's avatar
d.arizona committed
3533
                                            />
d.arizona's avatar
d.arizona committed
3534
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3535
                                        :
d.arizona's avatar
d.arizona committed
3536
                                        <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579
                                            {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                // null
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 16)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ color: '#5198ea', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(value).toFixed(1)}
                                                            disabled={false}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />}
d.arizona's avatar
d.arizona committed
3580 3581
                                        </div>
                                    )
d.arizona's avatar
d.arizona committed
3582
                            }
3583 3584 3585 3586 3587
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
3588
            name: "Strategic Initiative",
3589 3590
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3591
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3592 3593 3594
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3595
                customBodyRender: (value, tableMeta) => {
3596
                    return (
d.arizona's avatar
d.arizona committed
3597
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3598
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
3599 3600 3601 3602 3603 3604 3605 3606
                                null :
                                <FormControlLabel
                                    style={{ margin: 0 }}
                                    control={
                                        <ThemeProvider theme={theme}>
                                            <Input
                                                disableUnderline={true}
                                                style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginBottom: -5 }}
d.arizona's avatar
d.arizona committed
3607 3608
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
3609
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
d.arizona's avatar
d.arizona committed
3610
                                                defaultValue={value}
d.arizona's avatar
d.arizona committed
3611
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
3612
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
3613
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3614
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
3615 3616
                                                }}
                                            />
d.arizona's avatar
d.arizona committed
3617
                                        </ThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
3618

d.arizona's avatar
d.arizona committed
3619 3620
                                    }
                                />
d.arizona's avatar
d.arizona committed
3621
                            }
3622 3623 3624 3625 3626
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
3627
            name: "PIC",
3628 3629
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3630
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3631 3632 3633
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3634
                customBodyRender: (value, tableMeta) => {
3635
                    return (
d.arizona's avatar
d.arizona committed
3636
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3637
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
3638 3639 3640 3641 3642 3643 3644 3645 3646
                                null :
                                <FormControlLabel
                                    style={{ margin: 0 }}
                                    // value={value}
                                    control={
                                        <ThemeProvider theme={theme}>
                                            <Input
                                                disableUnderline={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginBottom: -5 }}
d.arizona's avatar
d.arizona committed
3647 3648
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
3649
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
d.arizona's avatar
d.arizona committed
3650
                                                defaultValue={value}
d.arizona's avatar
d.arizona committed
3651
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
3652
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
3653
                                                    // updateValue(event.target.value)
d.arizona's avatar
d.arizona committed
3654
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3655
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
3656 3657
                                                }}
                                            />
d.arizona's avatar
d.arizona committed
3658
                                        </ThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
3659

d.arizona's avatar
d.arizona committed
3660 3661
                                    }
                                />
d.arizona's avatar
d.arizona committed
3662
                            }
3663 3664 3665 3666
                        </div>
                    )
                }
            }
d.arizona's avatar
d.arizona committed
3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        },
3678
        ]
faisalhamdi's avatar
faisalhamdi committed
3679
        const loadingComponent = (
d.arizona's avatar
d.arizona committed
3680
            <div style={{ position: 'absolute', zIndex: 1500, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
faisalhamdi's avatar
faisalhamdi committed
3681 3682 3683 3684 3685 3686 3687 3688
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );
3689 3690 3691 3692

        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
d.arizona's avatar
d.arizona committed
3693
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
3694
                </div>
faisalhamdi's avatar
faisalhamdi committed
3695
                {/* {this.state.loading && loadingComponent} */}
d.arizona's avatar
d.arizona committed
3696
                <Snackbar open={this.state.alert} autoHideDuration={3000} onClose={() => this.closeAlert()}>
d.arizona's avatar
d.arizona committed
3697 3698 3699 3700
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
3701
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3702
                    {this.state.visibleCAT ? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
3703
                        <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
d.arizona's avatar
d.arizona committed
3704
                            <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Corporate Annual Target</Typography>
3705 3706
                        </div>
                        <div style={{ padding: 20 }}>
d.arizona's avatar
d.arizona committed
3707 3708 3709
                            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
3710
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
d.arizona's avatar
d.arizona committed
3711 3712
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758
                                <div style={{ width: '50%' }}>
                                    {this.state.dataTable.length == 0 ? null : this.props.isApprover == true ?
                                        <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            <a data-tip={'Download'} data-for="download">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() =>
                                                        this.setState({ loading: true }, () => {
                                                            setTimeout(() => {
                                                                this.downloadAllData()
                                                            }, 100);
                                                        })}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                        </div> :
                                        <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && <a data-tip={'Download Template'} data-for="template">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.downloadTemplate()}
                                                >
                                                    <img src={Images.template} />
                                                </button>
                                            </a>}
                                            <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                            {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && <a data-tip={'Upload'} data-for="upload">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
d.arizona's avatar
d.arizona committed
3759
                                                    onClick={() => this.setState({ visibleUpload: true, buttonDraft: true })}
Deni Rinaldi's avatar
Deni Rinaldi committed
3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786
                                                >
                                                    <img src={Images.upload} />
                                                </button>
                                            </a>}
                                            <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                            <a data-tip={'Download'} data-for="download">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() =>
                                                        // this.setState({ loading: true }, () => {
                                                        //     setTimeout(() => {
                                                        this.downloadAllData()}
                                                //     }, 100);
                                                // })}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                        </div>
                                    }
                                </div>
3787 3788
                            </div>

d.arizona's avatar
d.arizona committed
3789 3790
                            <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                {this.state.loading && loadingComponent}
3791 3792
                                <MuiThemeProvider theme={getMuiTheme()}>
                                    <MUIDataTable
d.arizona's avatar
d.arizona committed
3793
                                        data={dataTable2}
3794 3795 3796 3797 3798
                                        columns={columns}
                                        options={options}
                                    />
                                </MuiThemeProvider>
                            </div>
Riri Novita's avatar
Riri Novita committed
3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811
                            <div style={{ display: 'flex' }}>
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
                                    {
                                        this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
                                            return (
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                            )
                                        }) :
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
                                    }
                                </div>
                            </div>
3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822
                        </div>
                        <div className="grid grid-2x">
                            <div className="col-1">
                                <button
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
3823
                                    onClick={() =>
d.arizona's avatar
d.arizona committed
3824
                                        this.setState({ loading: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
3825 3826 3827 3828
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100)
                                        })}
3829 3830
                                >
                                    <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
3831
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
3832 3833 3834
                                    </div>
                                </button>
                            </div>
d.arizona's avatar
d.arizona committed
3835
                            {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3836
                                {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && <button
d.arizona's avatar
d.arizona committed
3837 3838 3839 3840 3841 3842 3843 3844 3845
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
                                        outline: 'none',
                                        marginRight: 20
                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
3846 3847
                                    onClick={() =>
                                        this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
d.arizona's avatar
d.arizona committed
3848 3849 3850 3851 3852
                                            setTimeout(() => {
                                                this.handleValidate()
                                            }, 100);
                                        })
                                    }
d.arizona's avatar
d.arizona committed
3853 3854
                                >
                                    <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
d.arizona's avatar
d.arizona committed
3855
                                        <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
d.arizona's avatar
d.arizona committed
3856
                                    </div>
d.arizona's avatar
d.arizona committed
3857
                                </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
3858
                                {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && <button
d.arizona's avatar
d.arizona committed
3859 3860 3861 3862
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
Deni Rinaldi's avatar
Deni Rinaldi committed
3863
                                        cursor: this.state.editable !== true ? 'pointer' : 'default',
d.arizona's avatar
d.arizona committed
3864 3865 3866 3867
                                        borderColor: 'transparent',
                                        outline: 'none',
                                        marginRight: 20
                                    }}
d.arizona's avatar
d.arizona committed
3868
                                    disabled={this.state.buttonDraft}
Deni Rinaldi's avatar
Deni Rinaldi committed
3869 3870
                                    onClick={() =>
                                        this.state.editable === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
3871
                                            this.setState({ alert: true }) :
Deni Rinaldi's avatar
Deni Rinaldi committed
3872 3873 3874 3875
                                            this.state.handleTekTekTek == 1 ? null :
                                                this.setState({ handleTekTekTek: 1 }, () => {
                                                    this.backToMasterBudget('draft')
                                                })
d.arizona's avatar
d.arizona committed
3876
                                    }
d.arizona's avatar
d.arizona committed
3877 3878
                                >
                                    <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
3879
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
d.arizona's avatar
d.arizona committed
3880
                                    </div>
d.arizona's avatar
d.arizona committed
3881
                                </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
3882
                                {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && <button
d.arizona's avatar
d.arizona committed
3883
                                    type="button"
d.arizona's avatar
d.arizona committed
3884
                                    disabled={this.state.buttonDraft}
Deni Rinaldi's avatar
Deni Rinaldi committed
3885 3886 3887 3888 3889 3890 3891 3892 3893
                                    onClick={() =>
                                        this.state.editable ? this.setState({ alert: true }) :
                                            this.state.buttonError ?
                                                this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1 }, () => {
                                                        this.backToMasterBudget('submitted')
                                                    })}
d.arizona's avatar
d.arizona committed
3894 3895 3896 3897 3898 3899 3900 3901
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: this.state.buttonError === true ? 'default' : 'pointer',
                                        borderColor: 'transparent',
                                        outline: 'none',
                                    }}
                                >
                                    <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
3902
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
d.arizona's avatar
d.arizona committed
3903
                                    </div>
d.arizona's avatar
d.arizona committed
3904
                                </button>}
d.arizona's avatar
d.arizona committed
3905
                            </div>}
3906 3907
                        </div>
                    </Paper>
Deni Rinaldi's avatar
Deni Rinaldi committed
3908 3909
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
d.arizona's avatar
d.arizona committed
3910 3911 3912 3913
                            <div>
                                <div style={{ padding: 25 }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
3914
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
d.arizona's avatar
d.arizona committed
3915 3916 3917
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    {this.state.dataLoaded && (
d.arizona's avatar
d.arizona committed
3918
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
d.arizona's avatar
d.arizona committed
3919
                                            {this.state.loading && loadingComponent}
d.arizona's avatar
d.arizona committed
3920
                                            <MuiThemeProvider theme={getMuiTheme()}>
d.arizona's avatar
d.arizona committed
3921 3922 3923 3924 3925
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
d.arizona's avatar
d.arizona committed
3926
                                            </MuiThemeProvider>
d.arizona's avatar
d.arizona committed
3927 3928 3929
                                        </div>
                                    )}
                                </div>
d.arizona's avatar
d.arizona committed
3930 3931 3932 3933 3934 3935 3936 3937 3938 3939
                                <div className="grid grid-2x">
                                    <div className="col-1">
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
3940
                                            onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
3941
                                                this.setState({ loading: true, visibleCAT: true, dataTable: [] }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
3942 3943 3944 3945
                                                    setTimeout(() => {
                                                        this.getItemHierarki()
                                                    }, 100)
                                                })}
d.arizona's avatar
d.arizona committed
3946 3947
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
3948
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
d.arizona's avatar
d.arizona committed
3949 3950 3951
                                            </div>
                                        </button>
                                    </div>
d.arizona's avatar
d.arizona committed
3952
                                    {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
d.arizona's avatar
d.arizona committed
3953
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
3954
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
3955
                                            onClick={() =>
d.arizona's avatar
d.arizona committed
3956
                                                this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
d.arizona's avatar
d.arizona committed
3957
                                                    setTimeout(() => {
d.arizona's avatar
d.arizona committed
3958
                                                        this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
3959
                                                        this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
d.arizona's avatar
d.arizona committed
3960
                                                    }, 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
3961
                                                })
d.arizona's avatar
d.arizona committed
3962 3963 3964 3965 3966 3967
                                            }
                                            style={{ marginRight: 20 }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
d.arizona's avatar
d.arizona committed
3968
                                        </button>}
d.arizona's avatar
d.arizona committed
3969
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
3970 3971
                                            className="button"
                                            type="button"
d.arizona's avatar
d.arizona committed
3972
                                            disabled={this.state.buttonDraft ? true : this.state.handleDataSalah ? true : false}
d.arizona's avatar
d.arizona committed
3973 3974
                                            style={{
                                                backgroundColor: 'transparent',
d.arizona's avatar
d.arizona committed
3975
                                                cursor: this.state.editable === true ? 'default' : this.state.handleDataSalah ? 'default' : 'pointer',
d.arizona's avatar
d.arizona committed
3976 3977 3978 3979
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
3980
                                            onClick={() => this.state.editable ?
d.arizona's avatar
d.arizona committed
3981
                                                this.setState({ alert: true }) : (this.state.handleDataSalah ? null : this.setState({ loading: true }, () =>
Deni Rinaldi's avatar
Deni Rinaldi committed
3982 3983 3984 3985 3986 3987
                                                    this.state.handleTekTekTek == 1 ? null :
                                                        this.setState({ handleTekTekTek: 1 }, () => {
                                                            setTimeout(() => {
                                                                this.uploadCAT("draft")
                                                            }, 100);
                                                        })
d.arizona's avatar
d.arizona committed
3988
                                                ))
Deni Rinaldi's avatar
Deni Rinaldi committed
3989
                                            }
d.arizona's avatar
d.arizona committed
3990 3991 3992 3993
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                            </div>
d.arizona's avatar
d.arizona committed
3994
                                        </button>}
d.arizona's avatar
d.arizona committed
3995
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
3996
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
3997 3998
                                            style={{
                                                backgroundColor: 'transparent',
d.arizona's avatar
d.arizona committed
3999
                                                cursor: this.state.editable === true ? 'default' : this.state.handleDataSalah ? 'default' : 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
4000 4001 4002
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
d.arizona's avatar
d.arizona committed
4003
                                            disabled={this.state.buttonDraft ? true : this.state.handleDataSalah ? true : false}
Deni Rinaldi's avatar
Deni Rinaldi committed
4004
                                            onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
4005 4006
                                                this.state.editable ? this.setState({ alert: true }) :
                                                    this.state.buttonError === true ?
d.arizona's avatar
d.arizona committed
4007
                                                        this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) : (this.state.handleDataSalah ? null : this.setState({ loading: true }, () =>
Deni Rinaldi's avatar
Deni Rinaldi committed
4008 4009 4010 4011 4012 4013
                                                            this.state.handleTekTekTek == 1 ? null :
                                                                this.setState({ handleTekTekTek: 1 }, () => {
                                                                    setTimeout(() => {
                                                                        this.uploadCAT("submitted")
                                                                    }, 100);
                                                                })
d.arizona's avatar
d.arizona committed
4014
                                                        ))
Deni Rinaldi's avatar
Deni Rinaldi committed
4015
                                            }
d.arizona's avatar
d.arizona committed
4016 4017 4018 4019
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
d.arizona's avatar
d.arizona committed
4020
                                        </button>}
d.arizona's avatar
d.arizona committed
4021
                                    </div>}
d.arizona's avatar
d.arizona committed
4022 4023 4024
                                </div>
                            </div>
                        </Paper>}
4025
                </div>
d.arizona's avatar
d.arizona committed
4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055

                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                    </div>
                                </div>
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
                                acceptedFiles={["xlsx"]}
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
                                onUpload={() => {
r.kurnia's avatar
r.kurnia committed
4056
                                    String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("CAT") ?
d.arizona's avatar
d.arizona committed
4057 4058 4059 4060 4061 4062 4063
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
4064 4065 4066 4067
            </div>
        );
    }
}