CorporateAnnualTarget.js 276 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 92
        this.fileHandler = this.fileHandler.bind(this);

93 94 95
    }

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

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

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

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

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

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


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

d.arizona's avatar
d.arizona committed
281 282
    downloadTemplate = async () => {
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
283
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
d.arizona's avatar
d.arizona committed
284 285
        )
        res = await res.blob()
d.arizona's avatar
d.arizona committed
286
        // // // // console.log(res)
d.arizona's avatar
d.arizona committed
287 288 289 290
        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
291
            a.download = 'Template Master Budget CAT.xlsx';
d.arizona's avatar
d.arizona committed
292 293 294 295 296
            a.click();
        }
    }

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

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

                        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
363
                                    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
364 365
                                    uom: i[3] === undefined ? "" : String(i[3]).trim(),
                                    kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
d.arizona's avatar
d.arizona committed
366
                                    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
367
                                    formula: i[6] === undefined ? "" : String(i[6]).trim(),
syadziy's avatar
syadziy committed
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
                                    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
384 385 386 387 388 389 390 391
                                    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
392
                                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
393 394
                                uom: i[3] === undefined ? "" : String(i[3]).trim(),
                                kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
d.arizona's avatar
d.arizona committed
395
                                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
396
                                formula: i[6] === undefined ? "" : String(i[6]).trim(),
syadziy's avatar
syadziy committed
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
                                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
413 414 415 416
                                strategic: i[23] === undefined ? "" : String(i[23]).trim(),
                                pic: i[24] === undefined ? "" : String(i[24]).trim()
                            })
                        }
d.arizona's avatar
d.arizona committed
417 418 419
                        // // 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
420

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

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

    checkUpload() {
Riri Novita's avatar
Riri Novita committed
440 441 442 443
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
d.arizona's avatar
d.arizona committed
444
        this.setState({ loading: true, dataTable: [] })
d.arizona's avatar
d.arizona committed
445
        let dataDelete = this.state.dataDelete
Riri Novita's avatar
Riri Novita committed
446
        api.create().getIdDeleteFromExcel(payload).then((response) => {
d.arizona's avatar
d.arizona committed
447
            if (response.data) {
d.arizona's avatar
d.arizona committed
448
                // // // // // console.log(response.data)
d.arizona's avatar
d.arizona committed
449 450
                let idDelete = response.data.data.item_report_id
                if (idDelete.length > 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
451
                    idDelete.map((item, index) => {
d.arizona's avatar
d.arizona committed
452 453
                        dataDelete.push(item)
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
454
                    this.setState({ dataDelete })
d.arizona's avatar
d.arizona committed
455 456 457
                }
            }
        })
Riri Novita's avatar
Riri Novita committed
458 459
        console.log(payload)
        api.create().checkUploadMB(payload).then(response => {
d.arizona's avatar
d.arizona committed
460
            // // console.log(JSON.stringify(this.state.payload));
d.arizona's avatar
d.arizona committed
461
            console.log(response)
d.arizona's avatar
d.arizona committed
462
            if (response.data) {
Deni Rinaldi's avatar
Deni Rinaldi committed
463
                if (response.ok) {
464 465 466 467 468 469 470
                    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
471 472 473
                        let dataFin = this.state.dataFin
                        let dataLearn = this.state.dataLearn
                        let newValidate = false
474 475 476
                        response.data.data.map((item, index) => {
                            if (item.item_report == 'CUSTOMER PERSPECTIVE') {
                                custoId = item.item_report_id
477
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
478

479 480
                            if (item.item_report == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
                                bisnsId = item.item_report_id
481
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
482

d.arizona's avatar
d.arizona committed
483 484 485
                            if (String(item.item_report).trim().toLocaleUpperCase() == "CUSTOMER PERSPECTIVE") {
                                newValidate = true
                            }
d.arizona's avatar
d.arizona committed
486

d.arizona's avatar
d.arizona committed
487 488 489
                            if (String(item.item_report).trim().toLocaleUpperCase() == "LEARNING & GROWTH PERSPECTIVE") {
                                newValidate = false
                            }
d.arizona's avatar
d.arizona committed
490

491 492 493 494 495 496
                            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
497

498 499 500
                                if (indexBisn !== -1 && item.item_report_id == 0) {
                                    dataDelete.push(this.state.dataInternalBsn[indexBisn].id)
                                }
d.arizona's avatar
d.arizona committed
501
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
502

d.arizona's avatar
d.arizona committed
503 504 505 506 507 508 509 510 511 512 513
                            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
                                }
                            }

514 515 516 517 518 519 520 521
                            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
522
                                item.type_report_id == 1 ? (`${String(item.weight).includes('%') ? String(item.weight) : String((Number(item.weight) * 100) + '% ')}`) : (String(item.weight)),
523 524 525 526
                                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
527
                                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
528 529 530 531 532 533 534 535 536 537 538 539
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.january).toFixed(1) : { value: item.january, formula: item.january_formula } : item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.february).toFixed(1) : { value: item.february, formula: item.february_formula } : item.february == "" ? item.february : String(item.february).indexOf(".") == -1 ? Number(item.february) : Number(item.february).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.march).toFixed(1) : { value: item.march, formula: item.march_formula } : item.march == "" ? item.march : String(item.march).indexOf(".") == -1 ? Number(item.march) : Number(item.march).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.april).toFixed(1) : { value: item.april, formula: item.april_formula } : item.april == "" ? item.april : String(item.april).indexOf(".") == -1 ? Number(item.april) : Number(item.april).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.may).toFixed(1) : { value: item.may, formula: item.may_formula } : item.may == "" ? item.may : String(item.may).indexOf(".") == -1 ? Number(item.may) : Number(item.may).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.june).toFixed(1) : { value: item.june, formula: item.june_formula } : item.june == "" ? item.june : String(item.june).indexOf(".") == -1 ? Number(item.june) : Number(item.june).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.july).toFixed(1) : { value: item.july, formula: item.july_formula } : item.july == "" ? item.july : String(item.july).indexOf(".") == -1 ? Number(item.july) : Number(item.july).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.august).toFixed(1) : { value: item.august, formula: item.august_formula } : item.august == "" ? item.august : String(item.august).indexOf(".") == -1 ? Number(item.august) : Number(item.august).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.september).toFixed(1) : { value: item.september, formula: item.september_formula } : item.september == "" ? item.september : String(item.september).indexOf(".") == -1 ? Number(item.september) : Number(item.september).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.october).toFixed(1) : { value: item.october, formula: item.october_formula } : item.october == "" ? item.october : String(item.october).indexOf(".") == -1 ? Number(item.october) : Number(item.october).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.november).toFixed(1) : { value: item.november, formula: item.november_formula } : item.november == "" ? item.november : String(item.november).indexOf(".") == -1 ? Number(item.november) : Number(item.november).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.december).toFixed(1) : { value: item.december, formula: item.december_formula } : item.december == "" ? item.december : String(item.december).indexOf(".") == -1 ? Number(item.december) : Number(item.december).toFixed(1),
Deni Rinaldi's avatar
Deni Rinaldi committed
540
                                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
541 542
                                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),
543
                                item.strategic,
Deni Rinaldi's avatar
Deni Rinaldi committed
544 545
                                item.pic,
                                item.forecast_formula,
d.arizona's avatar
d.arizona committed
546
                                item.orders,
547 548
                                item.error
                            ])
d.arizona's avatar
d.arizona committed
549
                        })
d.arizona's avatar
d.arizona committed
550 551 552 553 554 555 556
                        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
557 558
                        // // console.log(indexCheck)
                        // // // // console.log(this.state.buttonError)
d.arizona's avatar
d.arizona committed
559
                        console.log(dataTable)
d.arizona's avatar
d.arizona committed
560
                        this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, dataDelete, handleDataSalah }, () => {
561 562
                            this.state.dataTable.map(item => {
                                if (item[30].length > 0) {
d.arizona's avatar
d.arizona committed
563
                                    // // // // console.log('masuk')
564 565 566
                                    this.setState({ buttonError: true, errorPreview: true, editable: true })
                                }
                            })
d.arizona's avatar
d.arizona committed
567
                            // // // // // console.log(this.state.dataTable);
568 569 570
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
571
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
572 573 574 575 576 577
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
578
                    }
579 580
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
581
                }
582 583
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
584 585 586 587
            }
        })
    }

d.arizona's avatar
d.arizona committed
588
    uploadCAT(type) {
589
        // let dataDelete = this.state.dataDelete
d.arizona's avatar
d.arizona committed
590
        // // // // console.log(dataDelete)
Deni Rinaldi's avatar
Deni Rinaldi committed
591
        let payload = { "item_report_id": this.state.dataDelete }
d.arizona's avatar
d.arizona committed
592 593 594 595 596 597 598
        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
599

d.arizona's avatar
d.arizona committed
600 601 602
    }

    functionUpload(type) {
d.arizona's avatar
d.arizona committed
603
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
604
        let stateFR = false
d.arizona's avatar
d.arizona committed
605
        // // // console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
606
        this.state.dataTable.map(i => {
Deni Rinaldi's avatar
Deni Rinaldi committed
607 608 609 610 611 612 613 614 615
            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
616 617
            } else {
                stateFR = false
Deni Rinaldi's avatar
Deni Rinaldi committed
618
            }
d.arizona's avatar
d.arizona committed
619

d.arizona's avatar
d.arizona committed
620
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
621
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
622 623 624
                "item_report": String(i[6]),
                "weight": String(i[7]),
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
625 626 627 628
                "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
629 630 631 632 633 634 635 636 637 638 639 640
                "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
641 642 643
                "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
644 645
                "strategic": String(i[28]),
                "pic": String(i[29])
d.arizona's avatar
d.arizona committed
646 647 648 649
            })
        })
        let body = {
            "report_id": this.props.report_id,
d.arizona's avatar
d.arizona committed
650 651 652 653
            // "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID,
Riri Novita's avatar
Riri Novita committed
654
            "currency_id": this.state.defaultCurrencyUpload?.id,
d.arizona's avatar
d.arizona committed
655
            "status": type,
d.arizona's avatar
d.arizona committed
656
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
657
        }
d.arizona's avatar
d.arizona committed
658 659
        // // console.log(data);
        // // console.log(JSON.stringify(body))
d.arizona's avatar
d.arizona committed
660
        api.create('UPLOAD').uploadMasterBudget(body).then(response => {
Riri Novita's avatar
Riri Novita committed
661
            console.log(response);
d.arizona's avatar
d.arizona committed
662
            if (response.data) {
663 664 665 666 667
                if (response.ok) {
                    if (response.data.status === "success") {
                        this.props.onClickClose()
                        this.props.getReport()
                    } else {
668
                        this.setState({alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
669
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
670 671 672 673 674 675 676
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
d.arizona's avatar
d.arizona committed
677
                } else {
678
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
679 680
                }
            } else {
d.arizona's avatar
d.arizona committed
681
                this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
682 683
            }
        })
684 685
    }

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

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

d.arizona's avatar
d.arizona committed
709 710
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
d.arizona's avatar
d.arizona committed
711 712
                // // // // console.log(indexID)
                // // // // console.log(i[2])
d.arizona's avatar
d.arizona committed
713
                if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
714
                    // // // // console.log(dataTableBaru[indexID][6])
d.arizona's avatar
d.arizona committed
715 716 717
                    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
718
                            // // // // console.log(handleKosongKPIMAXYTD)
d.arizona's avatar
d.arizona committed
719
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
720 721 722 723
                    } else if (dataTableBaru[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
d.arizona's avatar
d.arizona committed
724 725 726 727
                    }
                }
            }

d.arizona's avatar
d.arizona committed
728 729 730
            // 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
731
            //         // // // // console.log(handleKosongKPIMAXYTD)
d.arizona's avatar
d.arizona committed
732 733
            //     }
            // }
d.arizona's avatar
d.arizona committed
734

d.arizona's avatar
d.arizona committed
735 736 737
            if (i[2] !== null) {
                let indexID = dataTampung.findIndex((val) => val.id == i[2])
                if (indexID !== -1) {
Deni Rinaldi's avatar
Deni Rinaldi committed
738
                    let weightParent = Number(dataTampung[indexID].maxValue == "" || dataTampung[indexID].maxValue == undefined ? 0 : dataTampung[indexID].maxValue.replace('%', ''))
d.arizona's avatar
d.arizona committed
739
                    let valChild = Number(dataTampung[indexID].valChild)
Deni Rinaldi's avatar
Deni Rinaldi committed
740
                    let valReal = Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
741 742
                    let totalBaru = valChild + valReal
                    if (totalBaru > weightParent) {
d.arizona's avatar
d.arizona committed
743
                        dataTableBaru[index][7] = `${String(Number(weightParent - valChild).toFixed(1)) + '%'}`
d.arizona's avatar
d.arizona committed
744
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + weightParent - valChild
d.arizona's avatar
d.arizona committed
745
                        weightReal = `${String(Number(weightParent - valChild).toFixed(1)) + '%'}`
d.arizona's avatar
d.arizona committed
746 747 748
                    } else {
                        dataTableBaru[index][7] = i[7]
                        weightReal = i[7]
Deni Rinaldi's avatar
Deni Rinaldi committed
749
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
750
                    }
d.arizona's avatar
d.arizona committed
751
                    // // // // console.log(weightReal)
d.arizona's avatar
d.arizona committed
752 753
                    // console.log(dataTableBaru[index][7])
                    // console.log(dataTampung[indexID].valChild)
d.arizona's avatar
d.arizona committed
754 755
                }
            }
d.arizona's avatar
d.arizona committed
756 757
            // // console.log(String(weightReal).substr(0,String(weightReal).length-1))
            // // console.log(Number(String(weightReal).substr(0,String(weightReal).length-1)).toFixed(1));
d.arizona's avatar
d.arizona committed
758 759 760 761
            console.log(weightReal)
            console.log(i[7])
            let b = []
            // console.log(i[13].value == undefined? 'Y' : 'N')
d.arizona's avatar
d.arizona committed
762
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
763
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
764
                "item_name": String(i[6]),
d.arizona's avatar
d.arizona committed
765
                "parent": i[2] == "" ? null : i[2],
d.arizona's avatar
d.arizona committed
766
                "weight": weightReal == null ? String(i[7]) : weightReal,
d.arizona's avatar
d.arizona committed
767
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
768 769 770 771
                "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
772
                "january": i[13].value == undefined ? (String(i[13]) == '' ? "0.0" : String(i[13])) : String(i[13].value),
d.arizona's avatar
d.arizona committed
773
                // "january": stateFR ? String(i[13].value) : String(i[13]) == "" ? "0.0" : String(i[13]),
d.arizona's avatar
d.arizona committed
774 775 776 777 778 779 780 781 782 783 784
                "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
785 786 787
                "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
788 789 790
                "strategic": String(i[28]),
                "pic": String(i[29])
            })
d.arizona's avatar
d.arizona committed
791
            stateFR = false
d.arizona's avatar
d.arizona committed
792
        })
d.arizona's avatar
d.arizona committed
793

d.arizona's avatar
d.arizona committed
794 795
        // // // // console.log(dataTableBaru)
        // // // // console.log(JSON.stringify(data))
d.arizona's avatar
d.arizona committed
796 797 798 799 800
        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
801
            "currency_id": this.props.defaultCurrency.id,
d.arizona's avatar
d.arizona committed
802 803 804
            "status": "submitted",
            "cat": data
        }
d.arizona's avatar
d.arizona committed
805
        // // // // console.log(totalWeight)
d.arizona's avatar
d.arizona committed
806
        // this.setState({dataTable: dataTampung})
d.arizona's avatar
d.arizona committed
807
        if (handleKosongKPIMAXYTD) {
Deni Rinaldi's avatar
Deni Rinaldi committed
808
            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
809
        } else if (totalWeight < 100) {
Deni Rinaldi's avatar
Deni Rinaldi committed
810
            this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, editable: true })
d.arizona's avatar
d.arizona committed
811
        } else {
d.arizona's avatar
d.arizona committed
812
            console.log(JSON.stringify(payload))
d.arizona's avatar
d.arizona committed
813
            api.create().validateSubmitReport(payload).then((response) => {
d.arizona's avatar
d.arizona committed
814
                console.log(response)
d.arizona's avatar
d.arizona committed
815
                if (response.data.data.result) {
d.arizona's avatar
d.arizona committed
816
                    this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false })
d.arizona's avatar
d.arizona committed
817
                } else {
d.arizona's avatar
d.arizona committed
818
                    this.setState({ loading: false, buttonError: true, editable: true, buttonDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
819
                }
d.arizona's avatar
d.arizona committed
820 821
            })
        }
d.arizona's avatar
d.arizona committed
822 823 824 825 826 827
    }

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

faisalhamdi's avatar
faisalhamdi committed
828 829
    backToMasterBudget(type) {
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
830
        let stateFR = false
d.arizona's avatar
d.arizona committed
831
        // // // console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
832
        this.state.dataTable.map(i => {
Deni Rinaldi's avatar
Deni Rinaldi committed
833 834
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
d.arizona's avatar
d.arizona committed
835 836
                // // // // console.log(indexID)
                // // // // console.log(i[2])
Deni Rinaldi's avatar
Deni Rinaldi committed
837
                if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
838
                    // // // // console.log(dataTableBaru[indexID][6])
Deni Rinaldi's avatar
Deni Rinaldi committed
839 840 841 842 843 844
                    if (this.state.dataTable[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
d.arizona's avatar
d.arizona committed
845 846
            } else {
                stateFR = false
Deni Rinaldi's avatar
Deni Rinaldi committed
847
            }
d.arizona's avatar
d.arizona committed
848
            // // // // // console.log(i[9] == null? "" : i[9].value)
faisalhamdi's avatar
faisalhamdi committed
849
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
850
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
851 852
                "item_name": String(i[6]),
                "parent": i[2] == "" ? null : i[2],
d.arizona's avatar
d.arizona committed
853 854
                "weight": String(i[7]),
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
855 856 857 858
                "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
859 860 861 862 863 864 865 866 867 868 869 870
                "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
871 872 873
                "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
874 875
                "strategic": String(i[28]),
                "pic": String(i[29])
faisalhamdi's avatar
faisalhamdi committed
876 877
            })
        })
d.arizona's avatar
d.arizona committed
878
        // // // console.log(JSON.stringify(data))
faisalhamdi's avatar
faisalhamdi committed
879 880 881 882 883
        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
884
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
885
            "status": type,
d.arizona's avatar
d.arizona committed
886
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
887
        }
d.arizona's avatar
d.arizona committed
888
        console.log(JSON.stringify(payload));
889
        this.deleteReport(payload, type)
d.arizona's avatar
d.arizona committed
890 891
    }

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

d.arizona's avatar
d.arizona committed
895 896
        if (this.state.dataDelete.length > 0) {
            api.create().deleteAllItemReport(payload).then((response) => {
d.arizona's avatar
d.arizona committed
897
                // // // // console.log(response)
d.arizona's avatar
d.arizona committed
898

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

d.arizona's avatar
d.arizona committed
911 912 913 914
                //     }
                // })
            })
        } else {
d.arizona's avatar
d.arizona committed
915
            // // // // // console.log('sini jing')
d.arizona's avatar
d.arizona committed
916
            // api.create().validateSubmitReport(payloadBro).then((response) => {
d.arizona's avatar
d.arizona committed
917
            //     // // // // console.log(response)
d.arizona's avatar
d.arizona committed
918
            //     if (response.data.data.result) {
Deni Rinaldi's avatar
Deni Rinaldi committed
919 920
            this.props.saveToMasterBudget(payloadBro)
            this.props.onClickClose()
d.arizona's avatar
d.arizona committed
921
            //     } else {
d.arizona's avatar
d.arizona committed
922

d.arizona's avatar
d.arizona committed
923 924 925
            //     }
            // })
        }
faisalhamdi's avatar
faisalhamdi committed
926 927
    }

d.arizona's avatar
d.arizona committed
928

d.arizona's avatar
d.arizona committed
929 930 931 932 933 934 935
    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
936
            // // // // // console.log(response)
d.arizona's avatar
d.arizona committed
937 938 939 940
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
d.arizona's avatar
d.arizona committed
941
                        // // // // console.log(data)
d.arizona's avatar
d.arizona committed
942
                        let inputKPI = []
Deni Rinaldi's avatar
Deni Rinaldi committed
943

d.arizona's avatar
d.arizona committed
944 945
                        data.map((item) => {
                            inputKPI.push({
d.arizona's avatar
d.arizona committed
946
                                value: item.value
d.arizona's avatar
d.arizona committed
947
                            })
d.arizona's avatar
d.arizona committed
948 949 950 951 952
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
d.arizona's avatar
d.arizona committed
953
                        // // // // console.log(defaultProps)
d.arizona's avatar
d.arizona committed
954 955 956
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
957
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993
                                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
994
                        // setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
995
                        this.setState({ maxAchList: defaultProps })
d.arizona's avatar
d.arizona committed
996
                        // }, 300);
d.arizona's avatar
d.arizona committed
997 998
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
999
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
                                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
1014
            this.getItemHierarki()
d.arizona's avatar
d.arizona committed
1015 1016 1017
        })
    }

d.arizona's avatar
d.arizona committed
1018 1019 1020 1021 1022 1023
    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
1024
            "submission_id": this.props.submissionID,
d.arizona's avatar
d.arizona committed
1025 1026 1027 1028 1029
        }
        api.create().getLastestUpdateMB(payload).then(response => {
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
1030
                        updateBy: response.data.data.detail === null ? '-' : response.data.data.detail
d.arizona's avatar
d.arizona committed
1031
                    })
Riri Novita's avatar
Riri Novita committed
1032 1033
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
1034
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
1035 1036 1037 1038 1039 1040
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
d.arizona's avatar
d.arizona committed
1041 1042 1043 1044 1045
                }
            }
        })
    }

1046
    render() {
faisalhamdi's avatar
faisalhamdi committed
1047
        let dataTable2 = this.state.dataTable
d.arizona's avatar
d.arizona committed
1048
        let dataDelete = this.state.dataDelete
faisalhamdi's avatar
faisalhamdi committed
1049 1050
        const handleChange = (value, tableMeta) => {
            let val = String(value).split(",").join("")
d.arizona's avatar
d.arizona committed
1051
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
d.arizona's avatar
d.arizona committed
1052 1053
        }

d.arizona's avatar
d.arizona committed
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
        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
1073

d.arizona's avatar
d.arizona committed
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
            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
1084
                    let formulaAwal = String(item).substr(0, indexX)
d.arizona's avatar
d.arizona committed
1085
                    let columnEnd = 24
Deni Rinaldi's avatar
Deni Rinaldi committed
1086
                    let month = column - 1
d.arizona's avatar
d.arizona committed
1087
                    let total = 0
d.arizona's avatar
d.arizona committed
1088
                    // // // console.log(formulaAwal)
Deni Rinaldi's avatar
Deni Rinaldi committed
1089 1090
                    if (forecast == undefined) {
                        dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
d.arizona's avatar
d.arizona committed
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105
                            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
1106
                        anjay.push(column)
d.arizona's avatar
d.arizona committed
1107 1108 1109
                    }
                } else if (item.includes('X')) {
                    let indexX = String(item).indexOf('X')
d.arizona's avatar
d.arizona committed
1110
                    // console.log(item)
d.arizona's avatar
d.arizona committed
1111
                    if (indexX == 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1112
                        anjay.push(String(item).substr(1, String(item).length))
d.arizona's avatar
d.arizona committed
1113
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1114 1115 1116 1117
                        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
1118
                        if (forecast == undefined) {
d.arizona's avatar
d.arizona committed
1119 1120 1121 1122
                            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
1123 1124
                                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
1125
                                anjay.push(valuezz == "" ? 0 : valuezz)
d.arizona's avatar
d.arizona committed
1126 1127 1128 1129 1130 1131
                            } 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
1132 1133
                            }
                        } else {
syadziy's avatar
syadziy committed
1134 1135 1136 1137 1138 1139
                            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
1140
                                anjay.push(valuezz == "" ? 0 : valuezz)
syadziy's avatar
syadziy committed
1141 1142 1143 1144 1145 1146 1147 1148
                            } 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
1149
                            }
qorri_di's avatar
qorri_di committed
1150

d.arizona's avatar
d.arizona committed
1151 1152 1153 1154 1155 1156
                            // 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
1157

d.arizona's avatar
d.arizona committed
1158 1159 1160 1161
                        anjay.push(operatorX)
                        anjay.push(nilaiX)
                    }
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1162
                    if (String(item).includes('#')) {
d.arizona's avatar
d.arizona committed
1163 1164 1165 1166
                        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
1167
                                anjay.push(valuezz == "" || valuezz == null ? "0" : valuezz)
d.arizona's avatar
d.arizona committed
1168
                            }
d.arizona's avatar
d.arizona committed
1169 1170 1171 1172
                        } 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
1173 1174
                        }
                    } else {
d.arizona's avatar
d.arizona committed
1175 1176 1177
                        let convertID = -1
                        if (tableMeta.rowData[11].value == 'FORMULA') {
                            let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
syadziy's avatar
syadziy committed
1178 1179 1180 1181
                            // console.log(indexIDReport);
                            if (indexIDReport != -1) {
                                convertID = dataTable2[indexIDReport][31]
                            }
d.arizona's avatar
d.arizona committed
1182
                        }
d.arizona's avatar
d.arizona committed
1183
                        let indexID = dataTable2.findIndex((val) => val[31] == (convertID == -1 ? item : convertID))
d.arizona's avatar
d.arizona committed
1184
                        if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
1185
                            let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
d.arizona's avatar
d.arizona committed
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198
                            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
1199 1200 1201 1202 1203
            // if (tableMeta.rowData[11].value == 'FORMULA') {
            //     console.log(anjay)
            //     console.log(column)

            // }
d.arizona's avatar
d.arizona committed
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215

            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
1216 1217 1218
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
d.arizona's avatar
d.arizona committed
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321
                    // }
                } 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
1322
            // if (dataTable2[tableMeta.rowIndex][6] == "NPAT" && forecast !== undefined) {
d.arizona's avatar
d.arizona committed
1323 1324 1325 1326 1327 1328 1329
            //     // // 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
1330
            // }
d.arizona's avatar
d.arizona committed
1331 1332 1333 1334 1335 1336 1337
            // // // 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
1338

d.arizona's avatar
d.arizona committed
1339
            total = R.equals(total, NaN) ? "0.0" : total
syadziy's avatar
syadziy committed
1340
            console.log(total);
d.arizona's avatar
d.arizona committed
1341 1342 1343 1344 1345 1346 1347
            // 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
1348 1349 1350 1351 1352
            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
1353
            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
1354

d.arizona's avatar
d.arizona committed
1355 1356 1357 1358 1359 1360
            return total
        }

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

d.arizona's avatar
d.arizona committed
1362
        const handleChangeDropdown = (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
1363
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
d.arizona's avatar
d.arizona committed
1364 1365 1366
            let valz = value.value
            let total = 0
            let lastValz = 0
d.arizona's avatar
d.arizona committed
1367
            if (valz == 'SUM' || valz == 'AVG' || valz == 'LAST' || valz == 'FORMULA') {
Deni Rinaldi's avatar
Deni Rinaldi committed
1368
                dataTable2[tableMeta.rowIndex].map((item, index) => {
d.arizona's avatar
d.arizona committed
1369
                    if (index >= 13 && index <= 24) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1370
                        let valItem = item == undefined || item == "" ? 0 : item
d.arizona's avatar
d.arizona committed
1371 1372 1373 1374 1375 1376
                        total += Number(valItem)
                        if (index == 24) {
                            lastValz += Number(valItem)
                        }
                    }
                })
d.arizona's avatar
d.arizona committed
1377 1378 1379 1380
                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
1381
            }
d.arizona's avatar
d.arizona committed
1382
        }
d.arizona's avatar
d.arizona committed
1383
        const handleValueDropdown = (value, type, tableMeta) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1384
            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
1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398
            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
1399 1400

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

d.arizona's avatar
d.arizona committed
1403 1404 1405 1406
        }

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

d.arizona's avatar
d.arizona committed
1409
        const handleAction = (idParent, typeReport, tableMeta) => {
d.arizona's avatar
d.arizona committed
1410 1411
            if (this.props.isApprover) {
                return false
d.arizona's avatar
d.arizona committed
1412
            } else {
d.arizona's avatar
d.arizona committed
1413 1414 1415 1416 1417 1418 1419 1420
                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
1421
                    } else {
d.arizona's avatar
d.arizona committed
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433
                        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
1434
                    }
d.arizona's avatar
d.arizona committed
1435 1436 1437
                } else {
                    return false
                }
d.arizona's avatar
d.arizona committed
1438
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1439

d.arizona's avatar
d.arizona committed
1440 1441
        }

d.arizona's avatar
d.arizona committed
1442 1443 1444 1445
        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
1446 1447 1448 1449 1450
                    if (tableMeta.rowData[0] == 3) {
                        return false
                    } else {
                        return true
                    }
d.arizona's avatar
d.arizona committed
1451 1452 1453 1454 1455 1456 1457 1458
                } else {
                    return false
                }
            } else {
                return false
            }
        }

d.arizona's avatar
d.arizona committed
1459
        const handleTambah = (data, rowIndex) => {
d.arizona's avatar
d.arizona committed
1460
            // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
1461 1462 1463
            let newData = []
            dataTable2.map((item, index) => {
                newData.push(item)
d.arizona's avatar
d.arizona committed
1464
                if (index == rowIndex) {
d.arizona's avatar
d.arizona committed
1465
                    newData.push([
d.arizona's avatar
d.arizona committed
1466
                        null,
d.arizona's avatar
d.arizona committed
1467
                        "",
Deni Rinaldi's avatar
Deni Rinaldi committed
1468
                        item[2] == null || item[2] == "" ? item[1] : item[2],
d.arizona's avatar
d.arizona committed
1469 1470 1471 1472 1473 1474
                        item[3],
                        item[4],
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
1475 1476 1477
                        null,
                        null,
                        null,
d.arizona's avatar
d.arizona committed
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
1494
                        "",
d.arizona's avatar
d.arizona committed
1495 1496
                        ""
                    ])
Deni Rinaldi's avatar
Deni Rinaldi committed
1497

d.arizona's avatar
d.arizona committed
1498 1499 1500
                }
            })
            dataTable2 = newData
Deni Rinaldi's avatar
Deni Rinaldi committed
1501
            this.setState({ dataTable: dataTable2 }, () => {
d.arizona's avatar
d.arizona committed
1502
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1503
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
1504
                    // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1505
                }, 500)
d.arizona's avatar
d.arizona committed
1506 1507 1508 1509
            })
        }

        const handleDelete = (index) => {
d.arizona's avatar
d.arizona committed
1510 1511 1512
            if (dataTable2[index][1] !== "") {
                dataDelete.push(dataTable2[index][1])
            }
d.arizona's avatar
d.arizona committed
1513
            dataTable2.splice(index, 1)
Deni Rinaldi's avatar
Deni Rinaldi committed
1514
            this.setState({ dataTable: dataTable2, dataDelete }, () => {
d.arizona's avatar
d.arizona committed
1515
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1516
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
1517
                }, 100)
d.arizona's avatar
d.arizona committed
1518 1519
            })
        }
d.arizona's avatar
d.arizona committed
1520

Deni Rinaldi's avatar
Deni Rinaldi committed
1521
        const handleTotal = (tableMeta, type) => {
d.arizona's avatar
d.arizona committed
1522 1523 1524
            // let val = String(value).split(",").join("")
            let total = 0
            let lastValz = 0
d.arizona's avatar
d.arizona committed
1525 1526 1527 1528 1529
            // 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
1530 1531 1532 1533 1534 1535
            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
1536
                    }
qorri_di's avatar
qorri_di committed
1537 1538 1539 1540 1541
                }
            })
            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
1542
            // }
d.arizona's avatar
d.arizona committed
1543 1544
        }

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

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

d.arizona's avatar
d.arizona committed
3663 3664
                                    }
                                />
d.arizona's avatar
d.arizona committed
3665
                            }
3666 3667 3668 3669 3670
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
3671
            name: "PIC",
3672 3673
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3674
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3675 3676 3677
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3678
                customBodyRender: (value, tableMeta) => {
3679
                    return (
d.arizona's avatar
d.arizona committed
3680
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3681
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
3682 3683 3684 3685 3686 3687 3688 3689 3690
                                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
3691 3692
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
3693
                                                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
3694
                                                defaultValue={value}
d.arizona's avatar
d.arizona committed
3695
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
3696
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
3697
                                                    // updateValue(event.target.value)
d.arizona's avatar
d.arizona committed
3698
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3699
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
3700 3701
                                                }}
                                            />
d.arizona's avatar
d.arizona committed
3702
                                        </ThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
3703

d.arizona's avatar
d.arizona committed
3704 3705
                                    }
                                />
d.arizona's avatar
d.arizona committed
3706
                            }
3707 3708 3709 3710
                        </div>
                    )
                }
            }
d.arizona's avatar
d.arizona committed
3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        },
3722
        ]
faisalhamdi's avatar
faisalhamdi committed
3723
        const loadingComponent = (
d.arizona's avatar
d.arizona committed
3724
            <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
3725 3726 3727 3728 3729 3730 3731 3732
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );
3733 3734 3735 3736

        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
3737
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
3738
                </div>
faisalhamdi's avatar
faisalhamdi committed
3739
                {/* {this.state.loading && loadingComponent} */}
d.arizona's avatar
d.arizona committed
3740
                <Snackbar open={this.state.alert} autoHideDuration={3000} onClose={() => this.closeAlert()}>
d.arizona's avatar
d.arizona committed
3741 3742 3743 3744
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
3745
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3746
                    {this.state.visibleCAT ? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
qorri_di's avatar
qorri_di committed
3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811
                        <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>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                </div>
                                <div style={{ width: '50%' }}>
                                    {this.state.dataTable.length == 0 ? null : this.props.isApprover == true ?
                                        null
                                        // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                        //     <a data-tip={'Download'} data-for="download">
                                        //         <button
                                        //             style={{
                                        //                 backgroundColor: 'transparent',
                                        //                 cursor: 'pointer',
                                        //                 borderColor: 'transparent',
                                        //                 margin: 5
                                        //             }}
                                        //             onClick={() =>
                                        //                 this.setState({ loading: true }, () => {
                                        //                     setTimeout(() => {
                                        //                         this.downloadAllData()
                                        //                     }, 100);
                                        //                 })}
                                        //         >
                                        //             <img src={Images.download} />
                                        //         </button>
                                        //     </a>
                                        //     <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                        // </div> 
                                        :
                                        <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            {((!this.props.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
3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828
                                                <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
3829
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
qorri_di's avatar
qorri_di committed
3830 3831
                                        </div>
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
3832
                                </div>
qorri_di's avatar
qorri_di committed
3833
                            </div>
3834

qorri_di's avatar
qorri_di committed
3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855
                            <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
3856
                                </div>
qorri_di's avatar
qorri_di committed
3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877
                            </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>
3878
                                    </div>
qorri_di's avatar
qorri_di committed
3879
                                </button>
3880
                            </div>
qorri_di's avatar
qorri_di committed
3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935
                            {!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' })
                                                :
3936 3937
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
qorri_di's avatar
qorri_di committed
3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953
                                                        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
3954 3955
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
d.arizona's avatar
d.arizona committed
3956 3957 3958 3959
                            <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
3960
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
d.arizona's avatar
d.arizona committed
3961 3962 3963
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    {this.state.dataLoaded && (
d.arizona's avatar
d.arizona committed
3964
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
d.arizona's avatar
d.arizona committed
3965
                                            {this.state.loading && loadingComponent}
d.arizona's avatar
d.arizona committed
3966
                                            <MuiThemeProvider theme={getMuiTheme()}>
d.arizona's avatar
d.arizona committed
3967 3968 3969 3970 3971
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
d.arizona's avatar
d.arizona committed
3972
                                            </MuiThemeProvider>
d.arizona's avatar
d.arizona committed
3973 3974 3975
                                        </div>
                                    )}
                                </div>
d.arizona's avatar
d.arizona committed
3976 3977 3978 3979 3980 3981 3982 3983 3984 3985
                                <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
3986
                                            onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
3987
                                                this.setState({ loading: true, visibleCAT: true, dataTable: [] }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
3988 3989 3990 3991
                                                    setTimeout(() => {
                                                        this.getItemHierarki()
                                                    }, 100)
                                                })}
d.arizona's avatar
d.arizona committed
3992 3993
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
3994
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
d.arizona's avatar
d.arizona committed
3995 3996 3997
                                            </div>
                                        </button>
                                    </div>
d.arizona's avatar
d.arizona committed
3998
                                    {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
d.arizona's avatar
d.arizona committed
3999
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4000
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
4001
                                            onClick={() =>
d.arizona's avatar
d.arizona committed
4002
                                                this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
d.arizona's avatar
d.arizona committed
4003
                                                    setTimeout(() => {
d.arizona's avatar
d.arizona committed
4004
                                                        this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
4005
                                                        this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
d.arizona's avatar
d.arizona committed
4006
                                                    }, 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
4007
                                                })
d.arizona's avatar
d.arizona committed
4008 4009 4010 4011 4012 4013
                                            }
                                            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
4014
                                        </button>}
d.arizona's avatar
d.arizona committed
4015
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4016 4017
                                            className="button"
                                            type="button"
d.arizona's avatar
d.arizona committed
4018
                                            disabled={this.state.buttonDraft ? true : this.state.handleDataSalah ? true : false}
d.arizona's avatar
d.arizona committed
4019 4020
                                            style={{
                                                backgroundColor: 'transparent',
d.arizona's avatar
d.arizona committed
4021
                                                cursor: this.state.editable === true ? 'default' : this.state.handleDataSalah ? 'default' : 'pointer',
d.arizona's avatar
d.arizona committed
4022 4023 4024 4025
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
4026
                                            onClick={() => this.state.editable ?
d.arizona's avatar
d.arizona committed
4027
                                                this.setState({ alert: true }) : (this.state.handleDataSalah ? null : this.setState({ loading: true }, () =>
4028 4029
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
4030 4031 4032 4033
                                                            setTimeout(() => {
                                                                this.uploadCAT("draft")
                                                            }, 100);
                                                        })
d.arizona's avatar
d.arizona committed
4034
                                                ))
Deni Rinaldi's avatar
Deni Rinaldi committed
4035
                                            }
d.arizona's avatar
d.arizona committed
4036 4037 4038 4039
                                        >
                                            <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
4040
                                        </button>}
d.arizona's avatar
d.arizona committed
4041
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4042
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
4043 4044
                                            style={{
                                                backgroundColor: 'transparent',
d.arizona's avatar
d.arizona committed
4045
                                                cursor: this.state.editable === true ? 'default' : this.state.handleDataSalah ? 'default' : 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
4046 4047 4048
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
d.arizona's avatar
d.arizona committed
4049
                                            disabled={this.state.buttonDraft ? true : this.state.handleDataSalah ? true : false}
Deni Rinaldi's avatar
Deni Rinaldi committed
4050
                                            onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
4051 4052
                                                this.state.editable ? this.setState({ alert: true }) :
                                                    this.state.buttonError === true ?
d.arizona's avatar
d.arizona committed
4053
                                                        this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) : (this.state.handleDataSalah ? null : this.setState({ loading: true }, () =>
4054 4055
                                                            this.state.handleDoubleClick == 1 ? null :
                                                                this.setState({ handleDoubleClick: 1 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
4056 4057 4058 4059
                                                                    setTimeout(() => {
                                                                        this.uploadCAT("submitted")
                                                                    }, 100);
                                                                })
d.arizona's avatar
d.arizona committed
4060
                                                        ))
Deni Rinaldi's avatar
Deni Rinaldi committed
4061
                                            }
d.arizona's avatar
d.arizona committed
4062 4063 4064 4065
                                        >
                                            <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
4066
                                        </button>}
d.arizona's avatar
d.arizona committed
4067
                                    </div>}
d.arizona's avatar
d.arizona committed
4068 4069 4070
                                </div>
                            </div>
                        </Paper>}
4071
                </div>
d.arizona's avatar
d.arizona committed
4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091

                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                    </div>
                                </div>
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
                                </div>
                            </div>
Riri Novita's avatar
Riri Novita committed
4092
                            <div style={{ padding: '25px 30px' }}>
Riri Novita's avatar
Riri Novita committed
4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108
                                <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' })
                                    }}
                                />
                            </div>
Riri Novita's avatar
Riri Novita committed
4109 4110
                            <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
4111 4112 4113 4114
                        </div>
                    </div>
                )}

Riri Novita's avatar
Riri Novita committed
4115
                {this.state.visibleAlertSave && (
Riri Novita's avatar
Riri Novita committed
4116 4117
                    <div className="test app-popup-show">
                        <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
Riri Novita's avatar
Riri Novita committed
4118 4119
                            <div style={{ margin: 30 }}>
                                <div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
Riri Novita's avatar
Riri Novita committed
4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146
                                    <div style={{ alignSelf: 'center', marginRight: 25 }}>
                                        <img src={Images.warning} />
                                    </div>
                                    <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 })}
                                    >
                                        <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>
                            </div>
d.arizona's avatar
d.arizona committed
4147 4148 4149
                        </div>
                    </div>
                )}
4150 4151 4152 4153
            </div>
        );
    }
}