CorporateAnnualTarget.js 294 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
import Tooltip from '@material-ui/core/Tooltip';
syadziy's avatar
syadziy committed
12
import { roundMath, titleCase } from '../../library/Utils';
d.arizona's avatar
d.arizona committed
13
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: [],
81
            handleDoubleClick: 0,
82 83
            editable: false,
            dataCustomerPrs: [],
d.arizona's avatar
d.arizona committed
84 85 86 87
            dataInternalBsn: [],
            dataFin: [],
            dataLearn: [],
            handleDataSalah: false,
Riri Novita's avatar
Riri Novita committed
88 89
            defaultCurrencyUpload: this.props.defaultCurrency,
            visibleAlertSave: false
90
        }
d.arizona's avatar
d.arizona committed
91
        this.fileHandler = this.fileHandler.bind(this);
Riri Novita's avatar
Riri Novita committed
92
        this.fileHandlerSimulasi = this.fileHandlerSimulasi.bind(this);
d.arizona's avatar
d.arizona committed
93

94 95 96
    }

    componentDidMount() {
d.arizona's avatar
d.arizona committed
97
        this.getKPIType()
d.arizona's avatar
d.arizona committed
98
        this.getMaxAch()
d.arizona's avatar
d.arizona committed
99
        this.getLatestUpdate()
d.arizona's avatar
d.arizona committed
100 101
        // // // console.log(this.props.status)
        // // // // console.log(this.props.lastStatus);
102 103
    }

faisalhamdi's avatar
faisalhamdi committed
104
    getItemHierarki() {
faisalhamdi's avatar
faisalhamdi committed
105
        this.setState({ loading: true })
faisalhamdi's avatar
faisalhamdi committed
106 107
        let payload = {
            "report_id": this.props.report_id,
faisalhamdi's avatar
faisalhamdi committed
108 109
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
faisalhamdi's avatar
faisalhamdi committed
110
            "company_id": this.props.company.company_id,
Riri Novita's avatar
Riri Novita committed
111 112
            "submission_id": this.props.submissionID,
            "currency_id": this.props.defaultCurrency.id
faisalhamdi's avatar
faisalhamdi committed
113
        }
d.arizona's avatar
d.arizona committed
114
        console.log(JSON.stringify(payload))
faisalhamdi's avatar
faisalhamdi committed
115
        api.create().getDetailReportMB(payload).then(response => {
d.arizona's avatar
d.arizona committed
116
            let dataTable = []
117 118
            let dataCustomerPrs = []
            let dataInternalBsn = []
d.arizona's avatar
d.arizona committed
119 120
            let dataFin = []
            let dataLearn = []
d.arizona's avatar
d.arizona committed
121
            console.log(response)
Dida Adams Arizona's avatar
Dida Adams Arizona committed
122
            if (response.data) {
123 124 125 126 127 128 129
                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
130

131 132 133 134 135 136 137 138
                                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
139 140
                                }

141 142 143 144 145 146
                                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
147
                                        })
148 149
                                    }
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
150

d.arizona's avatar
d.arizona committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
                                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
                                        })
                                    }
                                }

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


faisalhamdi's avatar
faisalhamdi committed
279 280 281
        })
    }

d.arizona's avatar
d.arizona committed
282 283
    downloadTemplate = async () => {
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
284
            `${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}&&currency_id=${this.props.defaultCurrency.id}`
d.arizona's avatar
d.arizona committed
285 286
        )
        res = await res.blob()
d.arizona's avatar
d.arizona committed
287
        // // // // console.log(res)
d.arizona's avatar
d.arizona committed
288 289 290 291
        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
292
            a.download = 'Template Master Budget CAT.xlsx';
d.arizona's avatar
d.arizona committed
293 294 295 296 297
            a.click();
        }
    }

    async downloadAllData() {
d.arizona's avatar
d.arizona committed
298
        // // // // console.log('masuk')
Deni Rinaldi's avatar
Deni Rinaldi committed
299
        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
300
        // // // // console.log(bram)
faisalhamdi's avatar
faisalhamdi committed
301 302
        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
303
        let res = await fetch(
Deni Rinaldi's avatar
Deni Rinaldi committed
304
            this.props.submissionID == null ? resNull : resReal
d.arizona's avatar
d.arizona committed
305 306
        )
        res = await res.blob()
d.arizona's avatar
d.arizona committed
307
        // // // // console.log(res)
d.arizona's avatar
d.arizona committed
308 309 310 311 312
        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
313
            a.download = 'Master Budget CAT.xlsx';
d.arizona's avatar
d.arizona committed
314 315 316 317 318 319 320
            a.click();
        }
    }

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

                        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(),
qorri_di's avatar
qorri_di committed
364
                                    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
365 366
                                    uom: i[3] === undefined ? "" : String(i[3]).trim(),
                                    kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
d.arizona's avatar
d.arizona committed
367
                                    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
368
                                    formula: i[6] === undefined ? "" : String(i[6]).trim(),
syadziy's avatar
syadziy committed
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
                                    total_actual_before: i[7] === undefined ? "0.0" : reg.test(String(i[7])) === false ? "0.0" : String(roundMath(Number(i[7]), 1)).trim(),
                                    january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(roundMath(Number(i[8]), 1)).trim(),
                                    february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(roundMath(Number(i[9]), 1)).trim(),
                                    march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(roundMath(Number(i[10]), 1)).trim(),
                                    april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(roundMath(Number(i[11]), 1)).trim(),
                                    may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(roundMath(Number(i[12]), 1)).trim(),
                                    june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(roundMath(Number(i[13]), 1)).trim(),
                                    july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(roundMath(Number(i[14]), 1)).trim(),
                                    august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(roundMath(Number(i[15]), 1)).trim(),
                                    september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(roundMath(Number(i[16]), 1)).trim(),
                                    october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(roundMath(Number(i[17]), 1)).trim(),
                                    november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(roundMath(Number(i[18]), 1)).trim(),
                                    december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(roundMath(Number(i[19]), 1)).trim(),
                                    total_current_year: i[20] == 0 ? "0.0" : String(roundMath(Number(i[20]), 1)).trim(),
                                    total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(roundMath(Number(i[21]), 1)).trim(),
                                    total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(roundMath(Number(i[22]), 1)).trim(),
d.arizona's avatar
d.arizona committed
385 386 387 388 389 390 391 392
                                    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(),
qorri_di's avatar
qorri_di committed
393
                                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
394 395
                                uom: i[3] === undefined ? "" : String(i[3]).trim(),
                                kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
d.arizona's avatar
d.arizona committed
396
                                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
397
                                formula: i[6] === undefined ? "" : String(i[6]).trim(),
syadziy's avatar
syadziy committed
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
                                total_actual_before: i[7] === undefined ? "0.0" : reg.test(String(i[7])) === false ? "0.0" : String(roundMath(Number(i[7]), 1)).trim(),
                                january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(roundMath(Number(i[8]), 1)).trim(),
                                february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(roundMath(Number(i[9]), 1)).trim(),
                                march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(roundMath(Number(i[10]), 1)).trim(),
                                april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(roundMath(Number(i[11]), 1)).trim(),
                                may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(roundMath(Number(i[12]), 1)).trim(),
                                june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(roundMath(Number(i[13]), 1)).trim(),
                                july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(roundMath(Number(i[14]), 1)).trim(),
                                august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(roundMath(Number(i[15]), 1)).trim(),
                                september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(roundMath(Number(i[16]), 1)).trim(),
                                october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(roundMath(Number(i[17]), 1)).trim(),
                                november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(roundMath(Number(i[18]), 1)).trim(),
                                december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(roundMath(Number(i[19]), 1)).trim(),
                                total_current_year: i[20] == 0 ? "0.0" : String(roundMath(Number(i[20]), 1)).trim(),
                                total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(roundMath(Number(i[21]), 1)).trim(),
                                total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(roundMath(Number(i[22]), 1)).trim(),
d.arizona's avatar
d.arizona committed
414 415 416 417
                                strategic: i[23] === undefined ? "" : String(i[23]).trim(),
                                pic: i[24] === undefined ? "" : String(i[24]).trim()
                            })
                        }
d.arizona's avatar
d.arizona committed
418 419 420
                        // // 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
421

d.arizona's avatar
d.arizona committed
422 423
                    }
                })
d.arizona's avatar
d.arizona committed
424

d.arizona's avatar
d.arizona committed
425
                // // console.log(payload)
d.arizona's avatar
d.arizona committed
426 427 428 429
                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
430
                    status: '',
d.arizona's avatar
d.arizona committed
431
                    cat: payload,
Riri Novita's avatar
Riri Novita committed
432
                    status: 'submitted'
d.arizona's avatar
d.arizona committed
433
                }
d.arizona's avatar
d.arizona committed
434
                // // // // console.log(body)
d.arizona's avatar
d.arizona committed
435 436 437 438 439
                this.setState({ payload: body, judul: resp.rows[1][0] })
            }
        });
    }

Riri Novita's avatar
Riri Novita committed
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
    fileHandlerSimulasi = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // // // // // console.log(resp)
            if (err) {
                // // // // console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                // // console.log(isi);
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                let newValidate = false
                isi.map((i, index) => {
                    if (i.length > 0) {
                        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)
                                        }
                                    }
                                })
                            }
                            nilaiTotal = i[6] == 'SUM' ? total : i[6] == 'AVG' ? total / 12 : lastValz
                        }

                        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(),
                                    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)) + '%'),
                                    uom: i[3] === undefined ? "" : String(i[3]).trim(),
                                    kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
                                    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(),
                                    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(roundMath(Number(i[7]), 1)).trim(),
                                    january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(roundMath(Number(i[8]), 1)).trim(),
                                    february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(roundMath(Number(i[9]), 1)).trim(),
                                    march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(roundMath(Number(i[10]), 1)).trim(),
                                    april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(roundMath(Number(i[11]), 1)).trim(),
                                    may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(roundMath(Number(i[12]), 1)).trim(),
                                    june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(roundMath(Number(i[13]), 1)).trim(),
                                    july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(roundMath(Number(i[14]), 1)).trim(),
                                    august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(roundMath(Number(i[15]), 1)).trim(),
                                    september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(roundMath(Number(i[16]), 1)).trim(),
                                    october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(roundMath(Number(i[17]), 1)).trim(),
                                    november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(roundMath(Number(i[18]), 1)).trim(),
                                    december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(roundMath(Number(i[19]), 1)).trim(),
                                    total_current_year: i[20] == 0 ? "0.0" : String(roundMath(Number(i[20]), 1)).trim(),
                                    total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(roundMath(Number(i[21]), 1)).trim(),
                                    total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(roundMath(Number(i[22]), 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(),
                                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)) + '%'),
                                uom: i[3] === undefined ? "" : String(i[3]).trim(),
                                kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
                                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(),
                                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(roundMath(Number(i[7]), 1)).trim(),
                                january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(roundMath(Number(i[8]), 1)).trim(),
                                february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(roundMath(Number(i[9]), 1)).trim(),
                                march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(roundMath(Number(i[10]), 1)).trim(),
                                april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(roundMath(Number(i[11]), 1)).trim(),
                                may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(roundMath(Number(i[12]), 1)).trim(),
                                june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(roundMath(Number(i[13]), 1)).trim(),
                                july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(roundMath(Number(i[14]), 1)).trim(),
                                august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(roundMath(Number(i[15]), 1)).trim(),
                                september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(roundMath(Number(i[16]), 1)).trim(),
                                october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(roundMath(Number(i[17]), 1)).trim(),
                                november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(roundMath(Number(i[18]), 1)).trim(),
                                december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(roundMath(Number(i[19]), 1)).trim(),
                                total_current_year: i[20] == 0 ? "0.0" : String(roundMath(Number(i[20]), 1)).trim(),
                                total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(roundMath(Number(i[21]), 1)).trim(),
                                total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(roundMath(Number(i[22]), 1)).trim(),
                                strategic: i[23] === undefined ? "" : String(i[23]).trim(),
                                pic: i[24] === undefined ? "" : String(i[24]).trim()
                            })
                        }
                        // // 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)) + '%')

                    }
                })

                // // console.log(payload)
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    status: '',
                    cat: payload,
                    status: 'submitted'
                }
                // // // // console.log(body)
                this.setState({ payload: body, judul: resp.rows[1][0] })
            }
        });
    }

d.arizona's avatar
d.arizona committed
562
    checkUpload() {
Riri Novita's avatar
Riri Novita committed
563 564 565 566
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
d.arizona's avatar
d.arizona committed
567
        this.setState({ loading: true, dataTable: [] })
d.arizona's avatar
d.arizona committed
568
        let dataDelete = this.state.dataDelete
Riri Novita's avatar
Riri Novita committed
569
        api.create().getIdDeleteFromExcel(payload).then((response) => {
d.arizona's avatar
d.arizona committed
570
            if (response.data) {
d.arizona's avatar
d.arizona committed
571
                // // // // // console.log(response.data)
d.arizona's avatar
d.arizona committed
572 573
                let idDelete = response.data.data.item_report_id
                if (idDelete.length > 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
574
                    idDelete.map((item, index) => {
d.arizona's avatar
d.arizona committed
575 576
                        dataDelete.push(item)
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
577
                    this.setState({ dataDelete })
d.arizona's avatar
d.arizona committed
578 579 580
                }
            }
        })
Riri Novita's avatar
Riri Novita committed
581 582
        console.log(payload)
        api.create().checkUploadMB(payload).then(response => {
d.arizona's avatar
d.arizona committed
583
            // // console.log(JSON.stringify(this.state.payload));
d.arizona's avatar
d.arizona committed
584
            console.log(response)
d.arizona's avatar
d.arizona committed
585
            if (response.data) {
Deni Rinaldi's avatar
Deni Rinaldi committed
586
                if (response.ok) {
587 588 589 590 591 592 593
                    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
594 595 596
                        let dataFin = this.state.dataFin
                        let dataLearn = this.state.dataLearn
                        let newValidate = false
597 598 599
                        response.data.data.map((item, index) => {
                            if (item.item_report == 'CUSTOMER PERSPECTIVE') {
                                custoId = item.item_report_id
600
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
601

602 603
                            if (item.item_report == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
                                bisnsId = item.item_report_id
604
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
605

d.arizona's avatar
d.arizona committed
606 607 608
                            if (String(item.item_report).trim().toLocaleUpperCase() == "CUSTOMER PERSPECTIVE") {
                                newValidate = true
                            }
d.arizona's avatar
d.arizona committed
609

d.arizona's avatar
d.arizona committed
610 611 612
                            if (String(item.item_report).trim().toLocaleUpperCase() == "LEARNING & GROWTH PERSPECTIVE") {
                                newValidate = false
                            }
d.arizona's avatar
d.arizona committed
613

614 615 616 617 618 619
                            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
620

621 622 623
                                if (indexBisn !== -1 && item.item_report_id == 0) {
                                    dataDelete.push(this.state.dataInternalBsn[indexBisn].id)
                                }
d.arizona's avatar
d.arizona committed
624
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
625

d.arizona's avatar
d.arizona committed
626 627 628 629 630 631 632 633 634 635 636
                            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
                                }
                            }

637 638 639 640 641 642 643 644
                            dataTable.push([
                                item.type_report_id,
                                item.item_report_id,
                                item.parent,
                                item.formula,
                                item.level == null ? 1 : item.level,
                                "",
                                item.item_report,
qorri_di's avatar
qorri_di committed
645
                                item.type_report_id == 1 ? (`${String(item.weight).includes('%') ? String(item.weight) : String((Number(item.weight) * 100) + '% ')}`) : (String(item.weight)),
646 647 648 649
                                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
650
                                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
651 652 653 654 655 656 657 658 659 660 661 662
                                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),
Riri Novita's avatar
Riri Novita committed
663
                                item.total_current_year === "NaN" ? "0.0" : 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
664 665
                                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),
666
                                item.strategic,
Deni Rinaldi's avatar
Deni Rinaldi committed
667 668
                                item.pic,
                                item.forecast_formula,
d.arizona's avatar
d.arizona committed
669
                                item.orders,
670 671
                                item.error
                            ])
d.arizona's avatar
d.arizona committed
672
                        })
d.arizona's avatar
d.arizona committed
673 674 675 676 677 678 679
                        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
680 681
                        // // console.log(indexCheck)
                        // // // // console.log(this.state.buttonError)
d.arizona's avatar
d.arizona committed
682
                        console.log(dataTable)
d.arizona's avatar
d.arizona committed
683
                        this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, dataDelete, handleDataSalah }, () => {
684 685
                            this.state.dataTable.map(item => {
                                if (item[30].length > 0) {
d.arizona's avatar
d.arizona committed
686
                                    // // // // console.log('masuk')
687 688 689
                                    this.setState({ buttonError: true, errorPreview: true, editable: true })
                                }
                            })
d.arizona's avatar
d.arizona committed
690
                            // // // // // console.log(this.state.dataTable);
691 692 693
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
694
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
695 696 697 698 699 700
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
701
                    }
702 703
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
704
                }
705 706
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
707 708 709 710
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
    uploadSimulasi() {
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        this.setState({ loading: true, dataTable: [] })
        // let dataDelete = this.state.dataDelete
        // api.create().getIdDeleteFromExcel(payload).then((response) => {
        //     if (response.data) {
        //         // // // // // console.log(response.data)
        //         let idDelete = response.data.data.item_report_id
        //         if (idDelete.length > 0) {
        //             idDelete.map((item, index) => {
        //                 dataDelete.push(item)
        //             })
        //             this.setState({ dataDelete })
        //         }
        //     }
        // })
        console.log(payload)
Riri Novita's avatar
Riri Novita committed
731
        api.create().uploadSimulasiMB(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
732 733 734 735
            console.log(response)
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === "success") {
Riri Novita's avatar
Riri Novita committed
736 737 738
                        this.props.getReport('CAT')
                        this.props.onClickClose()
                        this.setState({ loading: false })
Riri Novita's avatar
Riri Novita committed
739 740 741 742 743 744 745 746 747 748 749 750
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
                }
            } else {
                this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false })
            }
        })
    }

d.arizona's avatar
d.arizona committed
751
    uploadCAT(type) {
752
        // let dataDelete = this.state.dataDelete
d.arizona's avatar
d.arizona committed
753
        // // // // console.log(dataDelete)
Deni Rinaldi's avatar
Deni Rinaldi committed
754
        let payload = { "item_report_id": this.state.dataDelete }
d.arizona's avatar
d.arizona committed
755 756 757 758 759 760 761
        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
762

d.arizona's avatar
d.arizona committed
763 764 765
    }

    functionUpload(type) {
d.arizona's avatar
d.arizona committed
766
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
767
        let stateFR = false
d.arizona's avatar
d.arizona committed
768
        // // // console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
769
        this.state.dataTable.map(i => {
Deni Rinaldi's avatar
Deni Rinaldi committed
770 771 772 773 774 775 776 777 778
            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
779 780
            } else {
                stateFR = false
Deni Rinaldi's avatar
Deni Rinaldi committed
781
            }
d.arizona's avatar
d.arizona committed
782

d.arizona's avatar
d.arizona committed
783
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
784
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
785 786 787
                "item_report": String(i[6]),
                "weight": String(i[7]),
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
788 789 790 791
                "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]),
qorri_di's avatar
qorri_di committed
792 793 794 795 796 797 798 799 800 801 802 803
                "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
804 805 806
                "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
807 808
                "strategic": String(i[28]),
                "pic": String(i[29])
d.arizona's avatar
d.arizona committed
809 810 811 812
            })
        })
        let body = {
            "report_id": this.props.report_id,
Riri Novita's avatar
Riri Novita committed
813
            // "revision": Number(this.props.revision), 
d.arizona's avatar
d.arizona committed
814 815 816
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID,
Riri Novita's avatar
Riri Novita committed
817
            "currency_id": this.state.defaultCurrencyUpload?.id,
d.arizona's avatar
d.arizona committed
818
            "status": type,
d.arizona's avatar
d.arizona committed
819
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
820
        }
d.arizona's avatar
d.arizona committed
821 822
        // // console.log(data);
        // // console.log(JSON.stringify(body))
d.arizona's avatar
d.arizona committed
823
        api.create('UPLOAD').uploadMasterBudget(body).then(response => {
Riri Novita's avatar
Riri Novita committed
824
            console.log(response);
d.arizona's avatar
d.arizona committed
825
            if (response.data) {
826 827
                if (response.ok) {
                    if (response.data.status === "success") {
Riri Novita's avatar
Riri Novita committed
828
                        if (type == 'submitted') {
Riri Novita's avatar
Riri Novita committed
829
                            this.props.getReport(body, 'CAT')
Riri Novita's avatar
Riri Novita committed
830
                        } else {
Riri Novita's avatar
Riri Novita committed
831
                            this.props.getReport(body, 'DraftCAT')
Riri Novita's avatar
Riri Novita committed
832
                        }
Riri Novita's avatar
Riri Novita committed
833
                        this.setState({ loading: false })
Riri Novita's avatar
Riri Novita committed
834
                        this.props.onClickClose()
Riri Novita's avatar
Riri Novita committed
835
                        // this.props.getReport()
836
                    } else {
Riri Novita's avatar
Riri Novita committed
837 838 839 840 841 842 843 844 845 846 847 848
                        if (response.data?.message == "Please Set Up Rate Currency First") {
                            this.setState({ visibleAlertSave: true })
                        } else {
                            this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                                if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                    setTimeout(() => {
                                        localStorage.removeItem(Constant.TOKEN)
                                        window.location.reload();
                                    }, 1000);
                                }
                            })
                        }
849
                    }
d.arizona's avatar
d.arizona committed
850
                } else {
851
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
852 853
                }
            } else {
d.arizona's avatar
d.arizona committed
854
                this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
855 856
            }
        })
857 858
    }

d.arizona's avatar
d.arizona committed
859 860
    handleValidate() {
        let data = []
d.arizona's avatar
d.arizona committed
861
        // // // console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
862 863 864 865
        let totalWeight = 0
        let dataTableBaru = this.state.dataTable
        let dataTampung = []
        let weightReal = null
d.arizona's avatar
d.arizona committed
866
        let handleKosongKPIMAXYTD = false
Deni Rinaldi's avatar
Deni Rinaldi committed
867
        let stateFR = false
d.arizona's avatar
d.arizona committed
868
        console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
869
        this.state.dataTable.map((i, index) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
870
            if (i[0] == 1) {
d.arizona's avatar
d.arizona committed
871 872 873 874 875 876 877 878
                dataTampung.push({
                    id: i[1],
                    maxValue: i[7],
                    valChild: 0
                })
            }

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

d.arizona's avatar
d.arizona committed
882 883
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
d.arizona's avatar
d.arizona committed
884 885
                // // // // console.log(indexID)
                // // // // console.log(i[2])
d.arizona's avatar
d.arizona committed
886
                if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
887
                    // // // // console.log(dataTableBaru[indexID][6])
d.arizona's avatar
d.arizona committed
888 889 890
                    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
891
                            // // // // console.log(handleKosongKPIMAXYTD)
d.arizona's avatar
d.arizona committed
892
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
893 894 895 896
                    } else if (dataTableBaru[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
d.arizona's avatar
d.arizona committed
897 898 899 900
                    }
                }
            }

d.arizona's avatar
d.arizona committed
901 902 903
            // 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
904
            //         // // // // console.log(handleKosongKPIMAXYTD)
d.arizona's avatar
d.arizona committed
905 906
            //     }
            // }
d.arizona's avatar
d.arizona committed
907

d.arizona's avatar
d.arizona committed
908 909 910
            if (i[2] !== null) {
                let indexID = dataTampung.findIndex((val) => val.id == i[2])
                if (indexID !== -1) {
Deni Rinaldi's avatar
Deni Rinaldi committed
911
                    let weightParent = Number(dataTampung[indexID].maxValue == "" || dataTampung[indexID].maxValue == undefined ? 0 : dataTampung[indexID].maxValue.replace('%', ''))
d.arizona's avatar
d.arizona committed
912
                    let valChild = Number(dataTampung[indexID].valChild)
Deni Rinaldi's avatar
Deni Rinaldi committed
913
                    let valReal = Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
914 915
                    let totalBaru = valChild + valReal
                    if (totalBaru > weightParent) {
d.arizona's avatar
d.arizona committed
916
                        dataTableBaru[index][7] = `${String(Number(weightParent - valChild).toFixed(1)) + '%'}`
d.arizona's avatar
d.arizona committed
917
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + weightParent - valChild
d.arizona's avatar
d.arizona committed
918
                        weightReal = `${String(Number(weightParent - valChild).toFixed(1)) + '%'}`
d.arizona's avatar
d.arizona committed
919 920 921
                    } else {
                        dataTableBaru[index][7] = i[7]
                        weightReal = i[7]
Deni Rinaldi's avatar
Deni Rinaldi committed
922
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
923
                    }
d.arizona's avatar
d.arizona committed
924
                    // // // // console.log(weightReal)
d.arizona's avatar
d.arizona committed
925 926
                    // console.log(dataTableBaru[index][7])
                    // console.log(dataTampung[indexID].valChild)
d.arizona's avatar
d.arizona committed
927 928
                }
            }
d.arizona's avatar
d.arizona committed
929 930
            // // console.log(String(weightReal).substr(0,String(weightReal).length-1))
            // // console.log(Number(String(weightReal).substr(0,String(weightReal).length-1)).toFixed(1));
Riri Novita's avatar
Riri Novita committed
931 932
            // console.log(weightReal)
            // console.log(i[7])
d.arizona's avatar
d.arizona committed
933 934
            let b = []
            // console.log(i[13].value == undefined? 'Y' : 'N')
d.arizona's avatar
d.arizona committed
935
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
936
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
937
                "item_name": String(i[6]),
d.arizona's avatar
d.arizona committed
938
                "parent": i[2] == "" ? null : i[2],
d.arizona's avatar
d.arizona committed
939
                "weight": weightReal == null ? String(i[7]) : weightReal,
d.arizona's avatar
d.arizona committed
940
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
941 942 943 944
                "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
945
                "january": i[13].value == undefined ? (String(i[13]) == '' ? "0.0" : String(i[13])) : String(i[13].value),
d.arizona's avatar
d.arizona committed
946
                // "january": stateFR ? String(i[13].value) : String(i[13]) == "" ? "0.0" : String(i[13]),
d.arizona's avatar
d.arizona committed
947 948 949 950 951 952 953 954 955 956 957
                "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
958 959 960
                "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
961 962 963
                "strategic": String(i[28]),
                "pic": String(i[29])
            })
d.arizona's avatar
d.arizona committed
964
            stateFR = false
d.arizona's avatar
d.arizona committed
965
        })
d.arizona's avatar
d.arizona committed
966

d.arizona's avatar
d.arizona committed
967 968
        // // // // console.log(dataTableBaru)
        // // // // console.log(JSON.stringify(data))
d.arizona's avatar
d.arizona committed
969 970 971 972 973
        let payload = {
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
Riri Novita's avatar
Riri Novita committed
974
            "currency_id": this.props.defaultCurrency.id,
d.arizona's avatar
d.arizona committed
975 976 977
            "status": "submitted",
            "cat": data
        }
d.arizona's avatar
d.arizona committed
978
        // // // // console.log(totalWeight)
d.arizona's avatar
d.arizona committed
979
        // this.setState({dataTable: dataTampung})
d.arizona's avatar
d.arizona committed
980
        if (handleKosongKPIMAXYTD) {
Deni Rinaldi's avatar
Deni Rinaldi committed
981
            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
982
        } else if (totalWeight < 100) {
Deni Rinaldi's avatar
Deni Rinaldi committed
983
            this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, editable: true })
d.arizona's avatar
d.arizona committed
984
        } else {
d.arizona's avatar
d.arizona committed
985
            console.log(JSON.stringify(payload))
d.arizona's avatar
d.arizona committed
986
            api.create().validateSubmitReport(payload).then((response) => {
d.arizona's avatar
d.arizona committed
987
                console.log(response)
d.arizona's avatar
d.arizona committed
988
                if (response.data.data.result) {
d.arizona's avatar
d.arizona committed
989
                    this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false })
d.arizona's avatar
d.arizona committed
990
                } else {
d.arizona's avatar
d.arizona committed
991
                    this.setState({ loading: false, buttonError: true, editable: true, buttonDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
992
                }
d.arizona's avatar
d.arizona committed
993 994
            })
        }
d.arizona's avatar
d.arizona committed
995 996 997 998 999 1000
    }

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

faisalhamdi's avatar
faisalhamdi committed
1001 1002
    backToMasterBudget(type) {
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
1003
        let stateFR = false
d.arizona's avatar
d.arizona committed
1004
        // // // console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
1005
        this.state.dataTable.map(i => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1006 1007
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
d.arizona's avatar
d.arizona committed
1008 1009
                // // // // console.log(indexID)
                // // // // console.log(i[2])
Deni Rinaldi's avatar
Deni Rinaldi committed
1010
                if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
1011
                    // // // // console.log(dataTableBaru[indexID][6])
Deni Rinaldi's avatar
Deni Rinaldi committed
1012 1013 1014 1015 1016 1017
                    if (this.state.dataTable[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
d.arizona's avatar
d.arizona committed
1018 1019
            } else {
                stateFR = false
Deni Rinaldi's avatar
Deni Rinaldi committed
1020
            }
d.arizona's avatar
d.arizona committed
1021
            // // // // // console.log(i[9] == null? "" : i[9].value)
faisalhamdi's avatar
faisalhamdi committed
1022
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
1023
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
1024 1025
                "item_name": String(i[6]),
                "parent": i[2] == "" ? null : i[2],
d.arizona's avatar
d.arizona committed
1026 1027
                "weight": String(i[7]),
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
1028 1029 1030 1031
                "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]),
qorri_di's avatar
qorri_di committed
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
                "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
1044 1045 1046
                "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
1047 1048
                "strategic": String(i[28]),
                "pic": String(i[29])
faisalhamdi's avatar
faisalhamdi committed
1049 1050
            })
        })
d.arizona's avatar
d.arizona committed
1051
        // // // console.log(JSON.stringify(data))
faisalhamdi's avatar
faisalhamdi committed
1052 1053 1054 1055 1056
        let payload = {
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
Riri Novita's avatar
Riri Novita committed
1057
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
1058
            "status": type,
d.arizona's avatar
d.arizona committed
1059
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
1060
        }
d.arizona's avatar
d.arizona committed
1061
        console.log(JSON.stringify(payload));
1062
        this.deleteReport(payload, type)
d.arizona's avatar
d.arizona committed
1063 1064
    }

1065
    deleteReport(payloadBro, type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1066 1067
        let payload = { "item_report_id": this.state.dataDelete }

d.arizona's avatar
d.arizona committed
1068 1069
        if (this.state.dataDelete.length > 0) {
            api.create().deleteAllItemReport(payload).then((response) => {
d.arizona's avatar
d.arizona committed
1070
                // // // // console.log(response)
d.arizona's avatar
d.arizona committed
1071

d.arizona's avatar
d.arizona committed
1072
                // api.create().validateSubmitReport(payloadBro).then((response) => {
d.arizona's avatar
d.arizona committed
1073
                //     // // // // console.log(response)
d.arizona's avatar
d.arizona committed
1074
                //     if (response.data.data.result) {
Riri Novita's avatar
Riri Novita committed
1075 1076 1077 1078
                if (response.data.status === "success") {
                    if (type == 'submitted') {
                        this.props.saveToMasterBudget(payloadBro, 'CAT')
                    } else {
Riri Novita's avatar
Riri Novita committed
1079
                        this.props.saveToMasterBudget(payloadBro, 'DraftCAT')
Riri Novita's avatar
Riri Novita committed
1080
                    }
1081
                } else {
Riri Novita's avatar
Riri Novita committed
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
1094
                }
Riri Novita's avatar
Riri Novita committed
1095

1096 1097
                // this.props.saveToMasterBudget(payloadBro)
                // this.props.onClickClose()
d.arizona's avatar
d.arizona committed
1098
                //     } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1099

d.arizona's avatar
d.arizona committed
1100 1101 1102 1103
                //     }
                // })
            })
        } else {
d.arizona's avatar
d.arizona committed
1104
            // // // // // console.log('sini jing')
d.arizona's avatar
d.arizona committed
1105
            // api.create().validateSubmitReport(payloadBro).then((response) => {
d.arizona's avatar
d.arizona committed
1106
            //     // // // // console.log(response)
d.arizona's avatar
d.arizona committed
1107
            //     if (response.data.data.result) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1108 1109
            this.props.saveToMasterBudget(payloadBro)
            this.props.onClickClose()
d.arizona's avatar
d.arizona committed
1110
            //     } else {
d.arizona's avatar
d.arizona committed
1111

d.arizona's avatar
d.arizona committed
1112 1113 1114
            //     }
            // })
        }
faisalhamdi's avatar
faisalhamdi committed
1115 1116
    }

d.arizona's avatar
d.arizona committed
1117

d.arizona's avatar
d.arizona committed
1118 1119 1120 1121 1122 1123 1124
    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
1125
            // // // // // console.log(response)
d.arizona's avatar
d.arizona committed
1126 1127 1128 1129
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
d.arizona's avatar
d.arizona committed
1130
                        // // // // console.log(data)
d.arizona's avatar
d.arizona committed
1131
                        let inputKPI = []
Deni Rinaldi's avatar
Deni Rinaldi committed
1132

d.arizona's avatar
d.arizona committed
1133 1134
                        data.map((item) => {
                            inputKPI.push({
d.arizona's avatar
d.arizona committed
1135
                                value: item.value
d.arizona's avatar
d.arizona committed
1136
                            })
d.arizona's avatar
d.arizona committed
1137 1138 1139 1140 1141
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
d.arizona's avatar
d.arizona committed
1142
                        // // // // console.log(defaultProps)
d.arizona's avatar
d.arizona committed
1143 1144 1145
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
1146
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
                                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
1183
                        // setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1184
                        this.setState({ maxAchList: defaultProps })
d.arizona's avatar
d.arizona committed
1185
                        // }, 300);
d.arizona's avatar
d.arizona committed
1186 1187
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
1188
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202
                                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
1203
            this.getItemHierarki()
d.arizona's avatar
d.arizona committed
1204 1205 1206
        })
    }

d.arizona's avatar
d.arizona committed
1207 1208 1209 1210 1211 1212
    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,
Riri Novita's avatar
Riri Novita committed
1213
            "submission_id": this.props.submissionID,
d.arizona's avatar
d.arizona committed
1214 1215 1216 1217 1218
        }
        api.create().getLastestUpdateMB(payload).then(response => {
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
1219
                        updateBy: response.data.data.detail === null ? '-' : response.data.data.detail
d.arizona's avatar
d.arizona committed
1220
                    })
Riri Novita's avatar
Riri Novita committed
1221 1222
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
1223
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
1224 1225 1226 1227 1228 1229
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
d.arizona's avatar
d.arizona committed
1230 1231 1232 1233 1234
                }
            }
        })
    }

1235
    render() {
faisalhamdi's avatar
faisalhamdi committed
1236
        let dataTable2 = this.state.dataTable
d.arizona's avatar
d.arizona committed
1237
        let dataDelete = this.state.dataDelete
faisalhamdi's avatar
faisalhamdi committed
1238 1239
        const handleChange = (value, tableMeta) => {
            let val = String(value).split(",").join("")
d.arizona's avatar
d.arizona committed
1240
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
d.arizona's avatar
d.arizona committed
1241 1242
        }

d.arizona's avatar
d.arizona committed
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261
        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
1262

d.arizona's avatar
d.arizona committed
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272
            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
1273
                    let formulaAwal = String(item).substr(0, indexX)
d.arizona's avatar
d.arizona committed
1274
                    let columnEnd = 24
Deni Rinaldi's avatar
Deni Rinaldi committed
1275
                    let month = column - 1
d.arizona's avatar
d.arizona committed
1276
                    let total = 0
d.arizona's avatar
d.arizona committed
1277
                    // // // console.log(formulaAwal)
Deni Rinaldi's avatar
Deni Rinaldi committed
1278 1279
                    if (forecast == undefined) {
                        dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
d.arizona's avatar
d.arizona committed
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294
                            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
1295
                        anjay.push(column)
d.arizona's avatar
d.arizona committed
1296 1297 1298
                    }
                } else if (item.includes('X')) {
                    let indexX = String(item).indexOf('X')
d.arizona's avatar
d.arizona committed
1299
                    // console.log(item)
d.arizona's avatar
d.arizona committed
1300
                    if (indexX == 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1301
                        anjay.push(String(item).substr(1, String(item).length))
d.arizona's avatar
d.arizona committed
1302
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1303 1304 1305 1306
                        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
1307
                        if (forecast == undefined) {
d.arizona's avatar
d.arizona committed
1308 1309 1310 1311
                            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
1312 1313
                                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
1314
                                anjay.push(valuezz == "" ? 0 : valuezz)
d.arizona's avatar
d.arizona committed
1315 1316 1317 1318 1319 1320
                            } 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
1321 1322
                            }
                        } else {
syadziy's avatar
syadziy committed
1323 1324 1325 1326 1327 1328
                            let convertID = -1
                            if (tableMeta.rowData[11].value == 'FORMULA') {
                                let indexIDReport = dataTable2.findIndex((val) => val[1] == formulaAwal)
                                convertID = dataTable2[indexIDReport][31]
                                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
syadziy's avatar
syadziy committed
1329
                                anjay.push(valuezz == "" ? 0 : valuezz)
syadziy's avatar
syadziy committed
1330 1331 1332 1333 1334 1335 1336 1337
                            } else {
                                // // // console.log(dataTable2[tableMeta.rowIndex][30])
                                let array = dataTable2[tableMeta.rowIndex][30].filter((val) => val.periode == Number(column))
                                if (array.length > 0 && array[0] != undefined) {
                                    let valuezz = array[0].value
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                                // // // console.log(valuezz)
syadziy's avatar
syadziy committed
1338
                            }
qorri_di's avatar
qorri_di committed
1339

d.arizona's avatar
d.arizona committed
1340 1341 1342 1343 1344 1345
                            // 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
1346

d.arizona's avatar
d.arizona committed
1347 1348 1349 1350
                        anjay.push(operatorX)
                        anjay.push(nilaiX)
                    }
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1351
                    if (String(item).includes('#')) {
d.arizona's avatar
d.arizona committed
1352 1353 1354 1355
                        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
1356
                                anjay.push(valuezz == "" || valuezz == null ? "0" : valuezz)
d.arizona's avatar
d.arizona committed
1357
                            }
d.arizona's avatar
d.arizona committed
1358 1359 1360 1361
                        } 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
1362 1363
                        }
                    } else {
d.arizona's avatar
d.arizona committed
1364 1365 1366
                        let convertID = -1
                        if (tableMeta.rowData[11].value == 'FORMULA') {
                            let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
syadziy's avatar
syadziy committed
1367 1368 1369 1370
                            // console.log(indexIDReport);
                            if (indexIDReport != -1) {
                                convertID = dataTable2[indexIDReport][31]
                            }
d.arizona's avatar
d.arizona committed
1371
                        }
d.arizona's avatar
d.arizona committed
1372
                        let indexID = dataTable2.findIndex((val) => val[31] == (convertID == -1 ? item : convertID))
d.arizona's avatar
d.arizona committed
1373
                        if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
1374
                            let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
d.arizona's avatar
d.arizona committed
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387
                            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
1388 1389 1390 1391 1392
            // if (tableMeta.rowData[11].value == 'FORMULA') {
            //     console.log(anjay)
            //     console.log(column)

            // }
d.arizona's avatar
d.arizona committed
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404

            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
1405 1406 1407
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
d.arizona's avatar
d.arizona committed
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
                    // }
                } 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
1511
            // if (dataTable2[tableMeta.rowIndex][6] == "NPAT" && forecast !== undefined) {
d.arizona's avatar
d.arizona committed
1512 1513 1514 1515 1516 1517 1518
            //     // // 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
1519
            // }
d.arizona's avatar
d.arizona committed
1520 1521 1522 1523 1524 1525 1526
            // // // 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
1527

d.arizona's avatar
d.arizona committed
1528
            total = R.equals(total, NaN) ? "0.0" : total
Riri Novita's avatar
Riri Novita committed
1529
            // console.log(total);
d.arizona's avatar
d.arizona committed
1530 1531 1532 1533 1534 1535 1536
            // 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 {
qorri_di's avatar
qorri_di committed
1537 1538 1539 1540 1541
            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(1)
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = Number(total).toFixed(1)
            }
d.arizona's avatar
d.arizona committed
1542
            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
1543

d.arizona's avatar
d.arizona committed
1544 1545 1546 1547 1548 1549
            return total
        }

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

d.arizona's avatar
d.arizona committed
1551
        const handleChangeDropdown = (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
1552
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
d.arizona's avatar
d.arizona committed
1553 1554 1555
            let valz = value.value
            let total = 0
            let lastValz = 0
d.arizona's avatar
d.arizona committed
1556
            if (valz == 'SUM' || valz == 'AVG' || valz == 'LAST' || valz == 'FORMULA') {
Deni Rinaldi's avatar
Deni Rinaldi committed
1557
                dataTable2[tableMeta.rowIndex].map((item, index) => {
d.arizona's avatar
d.arizona committed
1558
                    if (index >= 13 && index <= 24) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1559
                        let valItem = item == undefined || item == "" ? 0 : item
d.arizona's avatar
d.arizona committed
1560 1561 1562 1563 1564 1565
                        total += Number(valItem)
                        if (index == 24) {
                            lastValz += Number(valItem)
                        }
                    }
                })
d.arizona's avatar
d.arizona committed
1566 1567 1568 1569
                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
1570
            }
d.arizona's avatar
d.arizona committed
1571
        }
d.arizona's avatar
d.arizona committed
1572
        const handleValueDropdown = (value, type, tableMeta) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1573
            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
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587
            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
1588 1589

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

d.arizona's avatar
d.arizona committed
1592 1593 1594 1595
        }

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

d.arizona's avatar
d.arizona committed
1598
        const handleAction = (idParent, typeReport, tableMeta) => {
d.arizona's avatar
d.arizona committed
1599 1600
            if (this.props.isApprover) {
                return false
d.arizona's avatar
d.arizona committed
1601
            } else {
d.arizona's avatar
d.arizona committed
1602 1603 1604 1605 1606 1607 1608 1609
                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
1610
                    } else {
d.arizona's avatar
d.arizona committed
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622
                        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
1623
                    }
d.arizona's avatar
d.arizona committed
1624 1625 1626
                } else {
                    return false
                }
d.arizona's avatar
d.arizona committed
1627
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1628

d.arizona's avatar
d.arizona committed
1629 1630
        }

d.arizona's avatar
d.arizona committed
1631 1632 1633 1634
        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
1635 1636 1637 1638 1639
                    if (tableMeta.rowData[0] == 3) {
                        return false
                    } else {
                        return true
                    }
d.arizona's avatar
d.arizona committed
1640 1641 1642 1643 1644 1645 1646 1647
                } else {
                    return false
                }
            } else {
                return false
            }
        }

d.arizona's avatar
d.arizona committed
1648
        const handleTambah = (data, rowIndex) => {
d.arizona's avatar
d.arizona committed
1649
            // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
1650 1651 1652
            let newData = []
            dataTable2.map((item, index) => {
                newData.push(item)
d.arizona's avatar
d.arizona committed
1653
                if (index == rowIndex) {
d.arizona's avatar
d.arizona committed
1654
                    newData.push([
d.arizona's avatar
d.arizona committed
1655
                        null,
d.arizona's avatar
d.arizona committed
1656
                        "",
Deni Rinaldi's avatar
Deni Rinaldi committed
1657
                        item[2] == null || item[2] == "" ? item[1] : item[2],
d.arizona's avatar
d.arizona committed
1658 1659 1660 1661 1662 1663
                        item[3],
                        item[4],
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
1664 1665 1666
                        null,
                        null,
                        null,
d.arizona's avatar
d.arizona committed
1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
1683
                        "",
d.arizona's avatar
d.arizona committed
1684 1685
                        ""
                    ])
Deni Rinaldi's avatar
Deni Rinaldi committed
1686

d.arizona's avatar
d.arizona committed
1687 1688 1689
                }
            })
            dataTable2 = newData
Deni Rinaldi's avatar
Deni Rinaldi committed
1690
            this.setState({ dataTable: dataTable2 }, () => {
d.arizona's avatar
d.arizona committed
1691
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1692
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
1693
                    // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1694
                }, 500)
d.arizona's avatar
d.arizona committed
1695 1696 1697 1698
            })
        }

        const handleDelete = (index) => {
d.arizona's avatar
d.arizona committed
1699 1700 1701
            if (dataTable2[index][1] !== "") {
                dataDelete.push(dataTable2[index][1])
            }
d.arizona's avatar
d.arizona committed
1702
            dataTable2.splice(index, 1)
Deni Rinaldi's avatar
Deni Rinaldi committed
1703
            this.setState({ dataTable: dataTable2, dataDelete }, () => {
d.arizona's avatar
d.arizona committed
1704
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1705
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
1706
                }, 100)
d.arizona's avatar
d.arizona committed
1707 1708
            })
        }
d.arizona's avatar
d.arizona committed
1709

Deni Rinaldi's avatar
Deni Rinaldi committed
1710
        const handleTotal = (tableMeta, type) => {
d.arizona's avatar
d.arizona committed
1711 1712 1713
            // let val = String(value).split(",").join("")
            let total = 0
            let lastValz = 0
d.arizona's avatar
d.arizona committed
1714 1715 1716 1717 1718
            // if (type === 'roic') {
            //     dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = tableMeta.rowData[24]
            //     total = Number(tableMeta.rowData[24])
            //     return total
            // } else {
qorri_di's avatar
qorri_di committed
1719 1720 1721 1722 1723 1724
            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
1725
                    }
qorri_di's avatar
qorri_di committed
1726 1727 1728 1729 1730
                }
            })
            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
1731
            // }
d.arizona's avatar
d.arizona committed
1732 1733
        }

1734
        const columns = [{
faisalhamdi's avatar
faisalhamdi committed
1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759
            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
1760 1761
            name: "",
            options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
1762
                filter: false,
d.arizona's avatar
d.arizona committed
1763
                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
1764 1765 1766 1767
                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
1768
                ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1769 1770
                customBodyRender: (val, tableMeta) => {
                    return (
qorri_di's avatar
qorri_di committed
1771
                        // handleAction(tableMeta.rowData[2]) && 
d.arizona's avatar
d.arizona committed
1772
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1773
                            {/* {tableMeta.rowData[6] === "Active" ? */}
d.arizona's avatar
d.arizona committed
1774
                            {handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && <span>
Deni Rinaldi's avatar
Deni Rinaldi committed
1775 1776 1777 1778 1779 1780 1781
                                <LightTooltip title={'Add'} arrow>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                        }}
d.arizona's avatar
d.arizona committed
1782
                                        // onClick={() => // // // // console.log(tableMeta.rowData[1])}
Deni Rinaldi's avatar
Deni Rinaldi committed
1783 1784 1785 1786 1787 1788 1789 1790 1791
                                        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
1792
                            {handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) && <span>
Deni Rinaldi's avatar
Deni Rinaldi committed
1793 1794 1795 1796 1797 1798 1799 1800 1801
                                <LightTooltip title={'Delete'} arrow>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            marginLeft: 5
                                        }}
                                        onClick={() => {
d.arizona's avatar
d.arizona committed
1802 1803
                                            this.setState({ loading: true })
                                            handleDelete(tableMeta.rowIndex)
Deni Rinaldi's avatar
Deni Rinaldi committed
1804 1805 1806 1807 1808
                                        }}
                                    >
                                        <img src={Images.delete} />
                                    </button>
                                </LightTooltip>
d.arizona's avatar
d.arizona committed
1809
                            </span>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1810 1811 1812
                        </div >
                    );
                }
d.arizona's avatar
d.arizona committed
1813
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1814
        }, {
1815 1816 1817
            name: "Key Performance Indicator",
            options: {
                customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1818
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8' }}>
d.arizona's avatar
d.arizona committed
1819
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
1820 1821 1822 1823 1824
                    </TableCell>
                ),
                setCellProps: () => ({ style }),
                customBodyRender: (val, tableMeta) => {
                    return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1825
                        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
1826
                            <div style={{ textAlign: 'left', paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
d.arizona's avatar
d.arizona committed
1827
                                {!this.state.loading && <FormControlLabel
Deni Rinaldi's avatar
Deni Rinaldi committed
1828 1829 1830 1831 1832 1833 1834 1835 1836 1837
                                    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
1838
                                                // // // // console.log(event.target.value)
Deni Rinaldi's avatar
Deni Rinaldi committed
1839
                                                handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1840
                                                // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1841 1842 1843
                                            }}
                                        />
                                    }
d.arizona's avatar
d.arizona committed
1844
                                />}
Deni Rinaldi's avatar
Deni Rinaldi committed
1845 1846 1847
                            </div>
                            :
                            <div style={{ width: 300 }}>
d.arizona's avatar
d.arizona committed
1848 1849
                                {tableMeta.rowData[32] ?
                                    tableMeta.rowData[32].length > 0 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866
                                        <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
1867 1868 1869 1870
                                    :
                                    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
1871 1872
                                        tableMeta.rowData[1] == null ?
                                            <div style={{ paddingLeft: 20 }}>
d.arizona's avatar
d.arizona committed
1873 1874
                                                <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1875
                                            :
d.arizona's avatar
d.arizona committed
1876 1877 1878
                                            <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
1879 1880
                                }
                            </div>
1881 1882 1883 1884 1885 1886 1887
                    )
                }
            }
        }, {
            name: "Weight",
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1888
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1889 1890 1891
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1892 1893 1894 1895
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1896
                            {tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1897
                                null :
Deni Rinaldi's avatar
Deni Rinaldi committed
1898
                                tableMeta.rowData[0] === 1 ?
d.arizona's avatar
d.arizona committed
1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912
                                    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
1913
                                                    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
1914 1915 1916 1917 1918 1919 1920 1921 1922
                                                    maxLength={4}
                                                    onBlur={(event) => {
                                                        // updateValue(some)
                                                        handleChangePercentage(event.target.value, tableMeta)
                                                    }}
                                                />
                                            }
                                        />
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
1923 1924 1925 1926
                            }
                        </div>
                    )
                }
1927 1928 1929 1930 1931
            }
        }, {
            name: "UOM",
            options: {
                customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1932
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8' }}>
1933 1934 1935 1936 1937 1938
                        <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
1939
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1940 1941 1942
                                null :
                                <FormControlLabel
                                    style={{ margin: 0 }}
d.arizona's avatar
d.arizona committed
1943
                                    // value={value}
d.arizona's avatar
d.arizona committed
1944
                                    control={
d.arizona's avatar
d.arizona committed
1945
                                        !handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) ?
d.arizona's avatar
d.arizona committed
1946 1947
                                            <Input
                                                disableUnderline={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1948
                                                style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginTop: -10 }}
d.arizona's avatar
d.arizona committed
1949 1950 1951 1952
                                                type="text"
                                                placeholder=""
                                                defaultValue={value}
                                                color={"#5198ea"}
d.arizona's avatar
d.arizona committed
1953
                                                disabled={true}
d.arizona's avatar
d.arizona committed
1954
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
1955
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
1956 1957
                                                    // updateValue(event.target.value)
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1958
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
1959
                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1960 1961 1962 1963 1964 1965 1966 1967 1968
                                            /> :
                                            <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
1969
                                                    // 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
1970
                                                    onBlur={(event) => {
d.arizona's avatar
d.arizona committed
1971
                                                        // // // // console.log(event.target.value)
Deni Rinaldi's avatar
Deni Rinaldi committed
1972 1973
                                                        // updateValue(event.target.value)
                                                        handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1974
                                                        // // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1975 1976 1977
                                                    }}
                                                />
                                            </ThemeProvider>
d.arizona's avatar
d.arizona committed
1978
                                    }
d.arizona's avatar
d.arizona committed
1979
                                />
1980 1981 1982 1983 1984 1985
                            }
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
1986
            name: "KPI Type",
1987 1988
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
1989
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1990 1991 1992
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
1993
                customBodyRender: (val, tableMeta) => {
1994 1995
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1996
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1997 1998 1999 2000 2001 2002 2003
                                null :
                                <Autocomplete
                                    {...this.state.kpiTypeList}
                                    id="kpiType"
                                    onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
                                    debug
                                    disableClearable
d.arizona's avatar
d.arizona committed
2004
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
d.arizona's avatar
d.arizona committed
2005
                                    value={handleValueDropdown(val, 'KPI', tableMeta)}
Deni Rinaldi's avatar
Deni Rinaldi committed
2006
                                    style={{ padding: 0, margin: 0 }}
d.arizona's avatar
d.arizona committed
2007
                                    renderInput={(params) =>
Deni Rinaldi's avatar
Deni Rinaldi committed
2008
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
d.arizona's avatar
d.arizona committed
2009
                                            <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
2010 2011 2012 2013
                                        </div>
                                    }
                                />
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
2014

2015 2016 2017 2018 2019 2020 2021 2022
                        </div>
                    )
                }
            }
        }, {
            name: "Max Ach.",
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2023
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
2024 2025 2026
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2027
                customBodyRender: (val, tableMeta) => {
2028 2029
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2030
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
2031 2032
                                null :
                                <Autocomplete
Deni Rinaldi's avatar
Deni Rinaldi committed
2033 2034 2035 2036 2037
                                    {...this.state.maxAchList}
                                    id="maxAchList"
                                    onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
                                    debug
                                    disableClearable
d.arizona's avatar
d.arizona committed
2038
                                    value={handleValueDropdown(val, 'MAX', tableMeta)}
Deni Rinaldi's avatar
Deni Rinaldi committed
2039
                                    style={{ padding: 0, margin: 0 }}
d.arizona's avatar
d.arizona committed
2040
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
Deni Rinaldi's avatar
Deni Rinaldi committed
2041 2042
                                    renderInput={(params) =>
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
d.arizona's avatar
d.arizona committed
2043
                                            <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
2044 2045
                                        </div>
                                    }
qorri_di's avatar
qorri_di committed
2046
                                // value={this.state.parent}
d.arizona's avatar
d.arizona committed
2047 2048
                                />
                            }
2049 2050 2051 2052 2053 2054 2055 2056
                        </div>
                    )
                }
            }
        }, {
            name: "Formula YTD",
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2057
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
2058 2059 2060
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2061
                customBodyRender: (val, tableMeta, updateValue) => {
2062
                    return (
d.arizona's avatar
d.arizona committed
2063
                        <div style={{ width: 105 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2064
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
2065 2066 2067 2068 2069 2070
                                null :
                                <Autocomplete
                                    {...this.state.formulaYtdList}
                                    id="formulaYtdList"
                                    onChange={(event, newInputValue) => {
                                        // updateValue(newInputValue)
Deni Rinaldi's avatar
Deni Rinaldi committed
2071 2072
                                        handleChangeDropdown(newInputValue, tableMeta)
                                    }
d.arizona's avatar
d.arizona committed
2073 2074 2075
                                    }
                                    debug
                                    disableClearable
d.arizona's avatar
d.arizona committed
2076
                                    value={handleValueDropdown(val, 'FORMULA', tableMeta)}
d.arizona's avatar
d.arizona committed
2077
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
Deni Rinaldi's avatar
Deni Rinaldi committed
2078
                                    style={{ padding: 0, margin: 0 }}
d.arizona's avatar
d.arizona committed
2079
                                    renderInput={(params) =>
Deni Rinaldi's avatar
Deni Rinaldi committed
2080
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
d.arizona's avatar
d.arizona committed
2081
                                            <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
2082 2083
                                        </div>
                                    }
qorri_di's avatar
qorri_di committed
2084
                                // value={this.state.parent}
d.arizona's avatar
d.arizona committed
2085 2086
                                />
                            }
2087 2088 2089 2090 2091
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2092
            name: `${Number(this.props.periode) - 1}`,
faisalhamdi's avatar
faisalhamdi committed
2093 2094
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
2095
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2096 2097
                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
faisalhamdi's avatar
faisalhamdi committed
2098
                ),
d.arizona's avatar
d.arizona committed
2099
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2100 2101
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2102
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
2103 2104 2105
                                null
                                :
                                <div style={{ flex: 1 }}>
d.arizona's avatar
d.arizona committed
2106 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
                                    {(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
2149
                                </div>
d.arizona's avatar
d.arizona committed
2150
                            }
faisalhamdi's avatar
faisalhamdi committed
2151 2152 2153 2154 2155
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2156
            name: `Jan ${this.props.periode}`,
2157 2158
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2159
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
2160 2161 2162
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2163
                customBodyRender: (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
2164
                    // // // // console.log(tableMeta.rowData[0])
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
                                // 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
                                    :
d.arizona's avatar
d.arizona committed
2191
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
d.arizona's avatar
d.arizona committed
2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211
                                        <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
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 }}>
qorri_di's avatar
qorri_di committed
2216
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
d.arizona's avatar
d.arizona committed
2217
                                                // null
Deni Rinaldi's avatar
Deni Rinaldi committed
2218 2219 2220 2221 2222 2223
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
d.arizona's avatar
d.arizona committed
2224
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2225 2226
                                                            type="text"
                                                            placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
2227
                                                            value={Number(handleValueFormula(value, tableMeta, 1)).toFixed(1)}
d.arizona's avatar
d.arizona committed
2228
                                                            disabled
Deni Rinaldi's avatar
Deni Rinaldi committed
2229 2230 2231 2232
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
2233
                                                                // // // // console.log(tableMeta.rowData[0])
Deni Rinaldi's avatar
Deni Rinaldi committed
2234 2235 2236 2237
                                                            }}
                                                        />
                                                    }
                                                />
d.arizona's avatar
d.arizona committed
2238
                                                :
Deni Rinaldi's avatar
Deni Rinaldi committed
2239 2240 2241 2242 2243 2244 2245 2246 2247
                                                <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
2248
                                                            value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
2249 2250 2251 2252 2253
                                                            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
2254
                                                                // // // // console.log(tableMeta.rowData[0])
Deni Rinaldi's avatar
Deni Rinaldi committed
2255 2256 2257 2258
                                                            }}
                                                        />
                                                    }
                                                />
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: `Feb ${this.props.periode}`,
2268 2269
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2270
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
2271 2272 2273
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2274
                customBodyRender: (value, tableMeta) => {
2275 2276
                    return (
                        <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
                                // 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
                                    :
d.arizona's avatar
d.arizona committed
2301
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
d.arizona's avatar
d.arizona committed
2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321
                                        <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
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
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
d.arizona's avatar
d.arizona committed
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
                                                // 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
2368
                                                />
qorri_di's avatar
qorri_di committed
2369
                                            }
d.arizona's avatar
d.arizona committed
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: `Mar ${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
                                // 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
                                    :
qorri_di's avatar
qorri_di committed
2411
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
2438 2439 2440 2441 2442 2443 2444 2445 2446 2447
                                                <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)}
qorri_di's avatar
qorri_di committed
2448
                                                            disabled
d.arizona's avatar
d.arizona committed
2449 2450 2451 2452 2453 2454 2455 2456
                                                            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
2457
                                                />
qorri_di's avatar
qorri_di committed
2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
2481
                                    )
d.arizona's avatar
d.arizona committed
2482 2483 2484 2485 2486 2487
                            }
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2488
            name: `Apr ${this.props.periode}`,
d.arizona's avatar
d.arizona committed
2489 2490 2491 2492 2493 2494 2495 2496
            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 (
2497
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2498
                            {
d.arizona's avatar
d.arizona committed
2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521
                                // 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
                                    :
qorri_di's avatar
qorri_di committed
2522
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
2549 2550 2551 2552 2553 2554 2555 2556 2557 2558
                                                <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)}
qorri_di's avatar
qorri_di committed
2559
                                                            disabled
d.arizona's avatar
d.arizona committed
2560 2561 2562 2563 2564 2565 2566 2567
                                                            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
2568
                                                />
qorri_di's avatar
qorri_di committed
2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
2592
                                    )
d.arizona's avatar
d.arizona committed
2593
                            }
2594 2595 2596 2597 2598
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2599
            name: `May ${this.props.periode}`,
2600 2601
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2602
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
2603 2604 2605
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2606
                customBodyRender: (value, tableMeta) => {
2607 2608
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2609
                            {
d.arizona's avatar
d.arizona committed
2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632
                                // 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
                                    :
d.arizona's avatar
d.arizona committed
2633
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
2660 2661 2662 2663 2664 2665 2666 2667 2668 2669
                                                <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)}
qorri_di's avatar
qorri_di committed
2670
                                                            disabled
d.arizona's avatar
d.arizona committed
2671 2672 2673 2674 2675 2676 2677 2678
                                                            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
2679
                                                />
qorri_di's avatar
qorri_di committed
2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717
                                    )
                            }
                        </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
2718 2719
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2720
                            {
d.arizona's avatar
d.arizona committed
2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743
                                // 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
                                    :
d.arizona's avatar
d.arizona committed
2744
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
2771 2772 2773 2774 2775 2776 2777 2778 2779 2780
                                                <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)}
qorri_di's avatar
qorri_di committed
2781
                                                            disabled
d.arizona's avatar
d.arizona committed
2782 2783 2784 2785 2786 2787 2788 2789
                                                            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
2790
                                                />
qorri_di's avatar
qorri_di committed
2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
2814
                                    )
d.arizona's avatar
d.arizona committed
2815
                            }
faisalhamdi's avatar
faisalhamdi committed
2816 2817 2818 2819 2820
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2821
            name: `Jul ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2822 2823
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2824
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
2825 2826 2827
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2828
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2829 2830
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2831
                            {
d.arizona's avatar
d.arizona committed
2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854
                                // 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
                                    :
qorri_di's avatar
qorri_di committed
2855
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
2882 2883 2884 2885 2886 2887 2888 2889 2890 2891
                                                <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)}
qorri_di's avatar
qorri_di committed
2892
                                                            disabled
d.arizona's avatar
d.arizona committed
2893 2894 2895 2896 2897 2898 2899 2900
                                                            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
2901
                                                />
qorri_di's avatar
qorri_di committed
2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
2925
                                    )
d.arizona's avatar
d.arizona committed
2926
                            }
faisalhamdi's avatar
faisalhamdi committed
2927 2928 2929 2930 2931
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
2932
            name: `Aug ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2933 2934
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
2935
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
2936 2937 2938
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
2939
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2940 2941
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2942
                            {
d.arizona's avatar
d.arizona committed
2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965
                                // 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
                                    :
qorri_di's avatar
qorri_di committed
2966
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
2993 2994 2995 2996 2997 2998 2999 3000 3001 3002
                                                <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)}
qorri_di's avatar
qorri_di committed
3003
                                                            disabled
d.arizona's avatar
d.arizona committed
3004 3005 3006 3007 3008 3009 3010 3011
                                                            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
3012
                                                />
qorri_di's avatar
qorri_di committed
3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
3036
                                    )
d.arizona's avatar
d.arizona committed
3037
                            }
faisalhamdi's avatar
faisalhamdi committed
3038 3039 3040 3041 3042
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3043
            name: `Sep ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
3044 3045
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3046
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
3047 3048 3049
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3050
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
3051 3052
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3053
                            {
d.arizona's avatar
d.arizona committed
3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076
                                // 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
                                    :
d.arizona's avatar
d.arizona committed
3077
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
3104 3105 3106 3107 3108 3109 3110 3111 3112 3113
                                                <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)}
qorri_di's avatar
qorri_di committed
3114
                                                            disabled
d.arizona's avatar
d.arizona committed
3115 3116 3117 3118 3119 3120 3121 3122
                                                            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
3123
                                                />
qorri_di's avatar
qorri_di committed
3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
3147
                                    )
d.arizona's avatar
d.arizona committed
3148
                            }
faisalhamdi's avatar
faisalhamdi committed
3149 3150 3151 3152 3153
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3154
            name: `Oct ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
3155 3156
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3157
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
3158 3159 3160
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3161
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
3162 3163
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3164
                            {
d.arizona's avatar
d.arizona committed
3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187
                                // 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
                                    :
d.arizona's avatar
d.arizona committed
3188
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
3215 3216 3217 3218 3219 3220 3221 3222 3223 3224
                                                <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)}
qorri_di's avatar
qorri_di committed
3225
                                                            disabled
d.arizona's avatar
d.arizona committed
3226 3227 3228 3229 3230 3231 3232 3233
                                                            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
3234
                                                />
qorri_di's avatar
qorri_di committed
3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
3258
                                    )
d.arizona's avatar
d.arizona committed
3259
                            }
faisalhamdi's avatar
faisalhamdi committed
3260 3261 3262 3263 3264
                        </div>
                    )
                }
            }
        }, {
Deni Rinaldi's avatar
Deni Rinaldi committed
3265
            name: `Nov ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
3266 3267
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3268
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
d.arizona's avatar
d.arizona committed
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
                        <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
                                    :
d.arizona's avatar
d.arizona committed
3299
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
3326 3327 3328 3329 3330 3331 3332 3333 3334 3335
                                                <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)}
qorri_di's avatar
qorri_di committed
3336
                                                            disabled
d.arizona's avatar
d.arizona committed
3337 3338 3339 3340 3341 3342 3343 3344
                                                            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
3345
                                                />
qorri_di's avatar
qorri_di committed
3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368
                                                :
                                                <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>
d.arizona's avatar
d.arizona committed
3369
                                    )
d.arizona's avatar
d.arizona committed
3370
                            }
faisalhamdi's avatar
faisalhamdi committed
3371 3372 3373 3374 3375
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3376
            name: `Dec ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
3377 3378
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3379
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
3380 3381 3382
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3383
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
3384 3385
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3386
                            {
d.arizona's avatar
d.arizona committed
3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409
                                // 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
                                    :
qorri_di's avatar
qorri_di committed
3410
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
3437 3438 3439 3440 3441 3442 3443 3444 3445
                                                <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=""
qorri_di's avatar
qorri_di committed
3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468
                                                            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)}
d.arizona's avatar
d.arizona committed
3469 3470 3471 3472 3473 3474 3475 3476
                                                            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
3477
                                                />
qorri_di's avatar
qorri_di committed
3478 3479
                                            }
                                        </div>
d.arizona's avatar
d.arizona committed
3480
                                    )
d.arizona's avatar
d.arizona committed
3481
                            }
faisalhamdi's avatar
faisalhamdi committed
3482 3483 3484 3485 3486
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3487
            name: `${this.props.periode} Total`,
faisalhamdi's avatar
faisalhamdi committed
3488 3489
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3490
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
3491 3492 3493
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3494
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
3495 3496
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3497
                            {
d.arizona's avatar
d.arizona committed
3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521
                                // 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 :
qorri_di's avatar
qorri_di committed
3522
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 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
                                        <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) && this.props.status !== 'CLOSED' ?
                                                // 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, 13)).toFixed(1)}
                                                            disabled
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // // // // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                                :
Deni Rinaldi's avatar
Deni Rinaldi committed
3570 3571 3572 3573 3574 3575 3576 3577 3578
                                                <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=""
qorri_di's avatar
qorri_di committed
3579
                                                            value={Number(handleTotal(tableMeta)).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
3580 3581 3582 3583 3584
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3585
                                                                // // // // console.log(tableMeta.rowData[0])
Deni Rinaldi's avatar
Deni Rinaldi committed
3586 3587 3588
                                                            }}
                                                        />
                                                    }
d.arizona's avatar
d.arizona committed
3589
                                                />
qorri_di's avatar
qorri_di committed
3590 3591
                                            }
                                        </div>
d.arizona's avatar
d.arizona committed
3592
                                    )
d.arizona's avatar
d.arizona committed
3593
                            }
faisalhamdi's avatar
faisalhamdi committed
3594 3595 3596 3597 3598
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3599
            name: `${Number(this.props.periode) + 1} Total`,
3600 3601
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3602
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3603 3604 3605
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3606
                customBodyRender: (value, tableMeta) => {
3607 3608
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3609
                            {
d.arizona's avatar
d.arizona committed
3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632
                                // 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
                                    :
d.arizona's avatar
d.arizona committed
3633
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
3660 3661 3662 3663 3664 3665 3666 3667 3668
                                                <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=""
qorri_di's avatar
qorri_di committed
3669 3670
                                                            value={Number(handleValueFormula(value, tableMeta, 14)).toFixed(1)}
                                                            disabled
d.arizona's avatar
d.arizona committed
3671 3672 3673 3674 3675 3676 3677 3678
                                                            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
3679
                                                />
qorri_di's avatar
qorri_di committed
3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702
                                                :
                                                <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])
                                                            }}
                                                        />
                                                    }
                                                />
                                            }
                                        </div>
d.arizona's avatar
d.arizona committed
3703
                                    )
d.arizona's avatar
d.arizona committed
3704
                            }
3705 3706 3707 3708 3709
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
3710
            name: `${Number(this.props.periode) + 2} Total`,
3711 3712
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3713
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3714 3715 3716
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3717
                customBodyRender: (value, tableMeta) => {
3718 3719
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3720
                            {
d.arizona's avatar
d.arizona committed
3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743
                                // 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
                                    :
qorri_di's avatar
qorri_di committed
3744
                                    (handleReturnFormula(tableMeta.rowData[2], tableMeta) && this.props.status !== 'CLOSED' ?
qorri_di's avatar
qorri_di committed
3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770
                                        <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])
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
                                        :
                                        <div style={{ flex: 1 }}>
                                            {(tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7) && this.props.status !== 'CLOSED' ?
                                                // null
d.arizona's avatar
d.arizona committed
3771 3772 3773 3774 3775 3776 3777 3778 3779
                                                <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=""
qorri_di's avatar
qorri_di committed
3780 3781
                                                            value={Number(handleValueFormula(value, tableMeta, 16)).toFixed(1)}
                                                            disabled
d.arizona's avatar
d.arizona committed
3782 3783 3784 3785 3786 3787 3788 3789
                                                            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
3790
                                                />
qorri_di's avatar
qorri_di committed
3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813
                                                :
                                                <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])
                                                            }}
                                                        />
                                                    }
                                                />
                                            }
                                        </div>
d.arizona's avatar
d.arizona committed
3814
                                    )
d.arizona's avatar
d.arizona committed
3815
                            }
3816 3817 3818 3819 3820
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
3821
            name: "Strategic Initiative",
3822 3823
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3824
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3825 3826 3827
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3828
                customBodyRender: (value, tableMeta) => {
3829
                    return (
d.arizona's avatar
d.arizona committed
3830
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3831
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
3832 3833 3834 3835 3836 3837 3838 3839
                                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
3840 3841
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
3842
                                                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
3843
                                                defaultValue={value}
d.arizona's avatar
d.arizona committed
3844
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
3845
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
3846
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3847
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
3848 3849
                                                }}
                                            />
d.arizona's avatar
d.arizona committed
3850
                                        </ThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
3851

d.arizona's avatar
d.arizona committed
3852 3853
                                    }
                                />
d.arizona's avatar
d.arizona committed
3854
                            }
3855 3856 3857 3858 3859
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
3860
            name: "PIC",
3861 3862
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3863
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3864 3865 3866
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3867
                customBodyRender: (value, tableMeta) => {
3868
                    return (
d.arizona's avatar
d.arizona committed
3869
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3870
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
3871 3872 3873 3874 3875 3876 3877 3878 3879
                                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
3880 3881
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
3882
                                                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
3883
                                                defaultValue={value}
d.arizona's avatar
d.arizona committed
3884
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
3885
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
3886
                                                    // updateValue(event.target.value)
d.arizona's avatar
d.arizona committed
3887
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3888
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
3889 3890
                                                }}
                                            />
d.arizona's avatar
d.arizona committed
3891
                                        </ThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
3892

d.arizona's avatar
d.arizona committed
3893 3894
                                    }
                                />
d.arizona's avatar
d.arizona committed
3895
                            }
3896 3897 3898 3899
                        </div>
                    )
                }
            }
d.arizona's avatar
d.arizona committed
3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        },
3911
        ]
faisalhamdi's avatar
faisalhamdi committed
3912
        const loadingComponent = (
d.arizona's avatar
d.arizona committed
3913
            <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
3914 3915 3916 3917 3918 3919 3920 3921
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );
3922 3923 3924 3925

        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
3926
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
3927
                </div>
faisalhamdi's avatar
faisalhamdi committed
3928
                {/* {this.state.loading && loadingComponent} */}
d.arizona's avatar
d.arizona committed
3929
                <Snackbar open={this.state.alert} autoHideDuration={3000} onClose={() => this.closeAlert()}>
d.arizona's avatar
d.arizona committed
3930 3931 3932 3933
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
3934
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3935
                    {this.state.visibleCAT ? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
qorri_di's avatar
qorri_di committed
3936 3937 3938 3939 3940 3941 3942 3943
                        <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                            <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Corporate Annual Target</Typography>
                        </div>
                        <div style={{ padding: 20 }}>
                            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
3944 3945 3946 3947 3948
                                    {this.props.defaultCurrency.id === 1 ?
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                        :
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                    }
qorri_di's avatar
qorri_di committed
3949 3950
                                </div>
                                <div style={{ width: '50%' }}>
Riri Novita's avatar
Riri Novita committed
3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971
                                    <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                                        <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                        <a data-tip={'Upload Simulasi'} data-for="upload">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })}
                                            >
                                                <img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} />
                                            </button>
                                        </a>
                                        <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                        {this.state.dataTable.length == 0 ? null : this.props.isApprover == true ?
                                            null
                                            :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                {/* <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
Riri Novita's avatar
Riri Novita committed
3972 3973 3974 3975 3976 3977 3978 3979 3980 3981
                                            <a data-tip={'Upload Simulasi'} data-for="upload">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.setState({ visibleUploadSimulasi: true, buttonDraft: true })}
                                                >
Riri Novita's avatar
Riri Novita committed
3982
                                                    <img src={Images.simulasiUpload} style={{ width: 40, height: 40, marginRight: 3 }} />
Riri Novita's avatar
Riri Novita committed
3983 3984
                                                </button>
                                            </a>
Riri Novita's avatar
Riri Novita committed
3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014
                                            <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" /> */}
                                                {((!this.props.truelyApprover) && (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.truelyApprover) && (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
                                                        }}
                                                        onClick={() => this.setState({ visibleUpload: true, buttonDraft: true })}
                                                    >
                                                        <img src={Images.upload} />
                                                    </button>
                                                </a>}
                                                <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                                {/* <a data-tip={'Download'} data-for="download">
Deni Rinaldi's avatar
Deni Rinaldi committed
4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031
                                                <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>
qorri_di's avatar
qorri_di committed
4032
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
Riri Novita's avatar
Riri Novita committed
4033 4034 4035
                                            </div>
                                        }
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
4036
                                </div>
qorri_di's avatar
qorri_di committed
4037
                            </div>
4038

qorri_di's avatar
qorri_di committed
4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059
                            <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                {this.state.loading && loadingComponent}
                                <MuiThemeProvider theme={getMuiTheme()}>
                                    <MUIDataTable
                                        data={dataTable2}
                                        columns={columns}
                                        options={options}
                                    />
                                </MuiThemeProvider>
                            </div>
                            <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>
                                    }
Riri Novita's avatar
Riri Novita committed
4060
                                </div>
qorri_di's avatar
qorri_di committed
4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081
                            </div>
                        </div>
                        <div className="grid grid-2x">
                            <div className="col-1">
                                <button
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
                                    }}
                                    onClick={() =>
                                        this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100)
                                        })}
                                >
                                    <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
4082
                                    </div>
qorri_di's avatar
qorri_di committed
4083
                                </button>
4084
                            </div>
qorri_di's avatar
qorri_di committed
4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139
                            {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                {((!this.props.truelyApprover) && (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
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
                                        outline: 'none',
                                        marginRight: 20
                                    }}
                                    onClick={() =>
                                        this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
                                            setTimeout(() => {
                                                this.handleValidate()
                                            }, 100);
                                        })
                                    }
                                >
                                    <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>
                                </button>}
                                {((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
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: this.state.editable !== true ? 'pointer' : 'default',
                                        borderColor: 'transparent',
                                        outline: 'none',
                                        marginRight: 20
                                    }}
                                    disabled={this.state.buttonDraft}
                                    onClick={() =>
                                        this.state.editable === true ?
                                            this.setState({ alert: true }) :
                                            this.state.handleDoubleClick == 1 ? null :
                                                this.setState({ handleDoubleClick: 1 }, () => {
                                                    this.backToMasterBudget('draft')
                                                })
                                    }
                                >
                                    <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>
                                </button>}
                                {((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
                                    type="button"
                                    disabled={this.state.buttonDraft}
                                    onClick={() =>
                                        this.state.editable ? this.setState({ alert: true }) :
                                            this.state.buttonError ?
                                                this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                :
4140 4141
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
qorri_di's avatar
qorri_di committed
4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157
                                                        this.backToMasterBudget('submitted')
                                                    })}
                                    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' }}>
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                    </div>
                                </button>}
                            </div>}
                        </div>
                    </Paper>
Deni Rinaldi's avatar
Deni Rinaldi committed
4158 4159
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
d.arizona's avatar
d.arizona committed
4160 4161 4162 4163
                            <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
4164
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
Riri Novita's avatar
Riri Novita committed
4165 4166 4167 4168 4169
                                        {this.props.defaultCurrency.id === 1 ?
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                            :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                        }
d.arizona's avatar
d.arizona committed
4170 4171
                                    </div>
                                    {this.state.dataLoaded && (
d.arizona's avatar
d.arizona committed
4172
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
d.arizona's avatar
d.arizona committed
4173
                                            {this.state.loading && loadingComponent}
d.arizona's avatar
d.arizona committed
4174
                                            <MuiThemeProvider theme={getMuiTheme()}>
d.arizona's avatar
d.arizona committed
4175 4176 4177 4178 4179
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
d.arizona's avatar
d.arizona committed
4180
                                            </MuiThemeProvider>
d.arizona's avatar
d.arizona committed
4181 4182 4183
                                        </div>
                                    )}
                                </div>
d.arizona's avatar
d.arizona committed
4184 4185 4186 4187 4188 4189 4190 4191 4192 4193
                                <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
4194
                                            onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
4195
                                                this.setState({ loading: true, visibleCAT: true, dataTable: [] }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
4196 4197 4198 4199
                                                    setTimeout(() => {
                                                        this.getItemHierarki()
                                                    }, 100)
                                                })}
d.arizona's avatar
d.arizona committed
4200 4201
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
4202
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
d.arizona's avatar
d.arizona committed
4203 4204 4205
                                            </div>
                                        </button>
                                    </div>
d.arizona's avatar
d.arizona committed
4206
                                    {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
d.arizona's avatar
d.arizona committed
4207
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4208
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
4209
                                            onClick={() =>
d.arizona's avatar
d.arizona committed
4210
                                                this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
d.arizona's avatar
d.arizona committed
4211
                                                    setTimeout(() => {
d.arizona's avatar
d.arizona committed
4212
                                                        this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
4213
                                                        this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
d.arizona's avatar
d.arizona committed
4214
                                                    }, 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
4215
                                                })
d.arizona's avatar
d.arizona committed
4216 4217 4218 4219 4220 4221
                                            }
                                            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
4222
                                        </button>}
d.arizona's avatar
d.arizona committed
4223
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4224 4225
                                            className="button"
                                            type="button"
d.arizona's avatar
d.arizona committed
4226
                                            disabled={this.state.buttonDraft ? true : this.state.handleDataSalah ? true : false}
d.arizona's avatar
d.arizona committed
4227 4228
                                            style={{
                                                backgroundColor: 'transparent',
d.arizona's avatar
d.arizona committed
4229
                                                cursor: this.state.editable === true ? 'default' : this.state.handleDataSalah ? 'default' : 'pointer',
d.arizona's avatar
d.arizona committed
4230 4231 4232 4233
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
4234
                                            onClick={() => this.state.editable ?
d.arizona's avatar
d.arizona committed
4235
                                                this.setState({ alert: true }) : (this.state.handleDataSalah ? null : this.setState({ loading: true }, () =>
4236 4237
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
4238 4239 4240 4241
                                                            setTimeout(() => {
                                                                this.uploadCAT("draft")
                                                            }, 100);
                                                        })
d.arizona's avatar
d.arizona committed
4242
                                                ))
Deni Rinaldi's avatar
Deni Rinaldi committed
4243
                                            }
d.arizona's avatar
d.arizona committed
4244 4245 4246 4247
                                        >
                                            <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
4248
                                        </button>}
d.arizona's avatar
d.arizona committed
4249
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4250
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
4251 4252
                                            style={{
                                                backgroundColor: 'transparent',
d.arizona's avatar
d.arizona committed
4253
                                                cursor: this.state.editable === true ? 'default' : this.state.handleDataSalah ? 'default' : 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
4254 4255 4256
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
d.arizona's avatar
d.arizona committed
4257
                                            disabled={this.state.buttonDraft ? true : this.state.handleDataSalah ? true : false}
Deni Rinaldi's avatar
Deni Rinaldi committed
4258
                                            onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
4259 4260
                                                this.state.editable ? this.setState({ alert: true }) :
                                                    this.state.buttonError === true ?
d.arizona's avatar
d.arizona committed
4261
                                                        this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) : (this.state.handleDataSalah ? null : this.setState({ loading: true }, () =>
4262 4263
                                                            this.state.handleDoubleClick == 1 ? null :
                                                                this.setState({ handleDoubleClick: 1 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
4264 4265 4266 4267
                                                                    setTimeout(() => {
                                                                        this.uploadCAT("submitted")
                                                                    }, 100);
                                                                })
d.arizona's avatar
d.arizona committed
4268
                                                        ))
Deni Rinaldi's avatar
Deni Rinaldi committed
4269
                                            }
d.arizona's avatar
d.arizona committed
4270 4271 4272 4273
                                        >
                                            <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
4274
                                        </button>}
d.arizona's avatar
d.arizona committed
4275
                                    </div>}
d.arizona's avatar
d.arizona committed
4276 4277 4278
                                </div>
                            </div>
                        </Paper>}
4279
                </div>
d.arizona's avatar
d.arizona committed
4280

Riri Novita's avatar
Riri Novita committed
4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298
                {
                    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>
d.arizona's avatar
d.arizona committed
4299 4300
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316
                                <div style={{ padding: '25px 30px' }}>
                                    <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={() => {
                                            String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("CAT") ?
                                                this.checkUpload() :
                                                this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                        }}
                                    />
d.arizona's avatar
d.arizona committed
4317
                                </div>
Riri Novita's avatar
Riri Novita committed
4318
                                <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div>
Riri Novita's avatar
Riri Novita committed
4319

Riri Novita's avatar
Riri Novita committed
4320
                            </div>
Riri Novita's avatar
Riri Novita committed
4321
                        </div>
Riri Novita's avatar
Riri Novita committed
4322 4323
                    )
                }
Riri Novita's avatar
Riri Novita committed
4324

Riri Novita's avatar
Riri Novita committed
4325 4326 4327 4328 4329 4330 4331
                {
                    this.state.visibleUploadSimulasi && (
                        <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">
Riri Novita's avatar
Riri Novita committed
4332
                                            <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File Simulasi</span>
Riri Novita's avatar
Riri Novita committed
4333
                                        </div>
Riri Novita's avatar
Riri Novita committed
4334
                                    </div>
Riri Novita's avatar
Riri Novita committed
4335 4336 4337 4338 4339 4340 4341 4342
                                    <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                        <button
                                            type="button"
                                            className="btn btn-circle btn-white"
                                            onClick={() => this.setState({ visibleUploadSimulasi: false })}
                                        >
                                            <img src={Images.close} />
                                        </button>
Riri Novita's avatar
Riri Novita committed
4343 4344
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
4345 4346 4347 4348 4349 4350 4351 4352 4353
                                <div style={{ padding: '25px 30px' }}>
                                    <UploadFile
                                        type={this.state.uploadStatusSimulasi}
                                        percentage={this.state.percentageSimulasi}
                                        result={this.state.resultSimulasi}
                                        acceptedFiles={["xlsx"]}
                                        onHandle={(dt) => {
                                            this.fileHandlerSimulasi(dt)
                                            this.setState({ uploadStatusSimulasi: 'idle', percentageSimulasi: '0' })
Riri Novita's avatar
Riri Novita committed
4354
                                        }}
Riri Novita's avatar
Riri Novita committed
4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376
                                        onUpload={() => {
                                            String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("CAT") ?
                                                this.uploadSimulasi() :
                                                this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                        }}
                                    />
                                </div>
                                <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> (Simulasi) Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div>

                            </div>
                        </div>
                    )
                }

                {
                    this.state.visibleAlertSave && (
                        <div className="test app-popup-show">
                            <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
                                <div style={{ margin: 30 }}>
                                    <div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
                                        <div style={{ alignSelf: 'center', marginRight: 25 }}>
                                            <img src={Images.warning} />
Riri Novita's avatar
Riri Novita committed
4377
                                        </div>
Riri Novita's avatar
Riri Novita committed
4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400
                                        <div style={{ justifyContent: 'center', fontSize: 20, color: '#1D2995', marginTop: 10 }}>
                                            <b>Rate Currency USD</b> pada periode yang dipilih <b>belum</b> diatur.<br /> Silahkan menghubungi Superadmin
                                        </div>
                                    </div>
                                    <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                background: '#F6F7F9',
                                                cursor: 'pointer',
                                                border: '1px solid #3549609e',
                                                outline: 'none',
                                                marginRight: 20,
                                                borderRadius: 9
                                            }}
                                            onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0 })}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 9, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
                                                <Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
                                            </div>
                                        </button>
                                    </div>
Riri Novita's avatar
Riri Novita committed
4401 4402
                                </div>
                            </div>
d.arizona's avatar
d.arizona committed
4403
                        </div>
Riri Novita's avatar
Riri Novita committed
4404 4405 4406
                    )
                }
            </div >
4407 4408 4409
        );
    }
}