CorporateAnnualTarget.js 287 KB
Newer Older
1
import React, { Component } from 'react';
d.arizona's avatar
d.arizona committed
2
import { Typography, Paper, createMuiTheme, ThemeProvider, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, withStyles, makeStyles, Snackbar } from '@material-ui/core';
3 4
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
faisalhamdi's avatar
faisalhamdi committed
5
import api from '../../api';
faisalhamdi's avatar
faisalhamdi committed
6 7 8 9 10
import AddIcon from '@material-ui/icons/Add';
import { values } from 'ramda';
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
d.arizona's avatar
d.arizona committed
11 12
import Tooltip from '@material-ui/core/Tooltip';
import Constant from '../../library/Constant';
d.arizona's avatar
d.arizona committed
13
import { Alert, Autocomplete } from '@material-ui/lab';
d.arizona's avatar
d.arizona committed
14 15
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
16 17
import * as R from 'ramda';
import { fixNumber, titleCase } from '../../library/Utils';
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
            defaultCurrencyUpload: this.props.defaultCurrency,
Riri Novita's avatar
Riri Novita committed
89
            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,
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))) + '%') : ((String(Number(item.cat.weight)) + '%') + '%')),
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 },
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
                                    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),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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),
                                    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),
                                    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),
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,
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))) + '%'),
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 },
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
                                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),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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),
                                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),
                                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),
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(
Riri Novita's avatar
Riri Novita 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}&&currency_id=${this.props.defaultCurrency.id}`
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(),
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)) + '%'),
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(),
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(Number(i[7])).trim(),
                                    january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(Number(i[8])).trim(),
                                    february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(Number(i[9])).trim(),
                                    march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(Number(i[10])).trim(),
                                    april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(Number(i[11])).trim(),
                                    may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(Number(i[12])).trim(),
                                    june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(Number(i[13])).trim(),
                                    july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(Number(i[14])).trim(),
                                    august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(Number(i[15])).trim(),
                                    september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(Number(i[16])).trim(),
                                    october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(Number(i[17])).trim(),
                                    november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(Number(i[18])).trim(),
                                    december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(Number(i[19])).trim(),
                                    total_current_year: i[20] == 0 ? "0.0" : String(Number(i[20])).trim(),
                                    total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(Number(i[21])).trim(),
                                    total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(Number(i[22])).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(),
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)) + '%'),
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(),
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(Number(i[7])).trim(),
                                january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(Number(i[8])).trim(),
                                february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(Number(i[9])).trim(),
                                march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(Number(i[10])).trim(),
                                april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(Number(i[11])).trim(),
                                may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(Number(i[12])).trim(),
                                june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(Number(i[13])).trim(),
                                july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(Number(i[14])).trim(),
                                august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(Number(i[15])).trim(),
                                september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(Number(i[16])).trim(),
                                october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(Number(i[17])).trim(),
                                november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(Number(i[18])).trim(),
                                december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(Number(i[19])).trim(),
                                total_current_year: i[20] == 0 ? "0.0" : String(Number(i[20])).trim(),
                                total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(Number(i[21])).trim(),
                                total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(Number(i[22])).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
                    cat: payload,
Riri Novita's avatar
Riri Novita committed
431
                    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 },
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
                                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),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.january) : { value: item.january, formula: item.january_formula } : item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.february) : { value: item.february, formula: item.february_formula } : item.february == "" ? item.february : String(item.february).indexOf(".") == -1 ? Number(item.february) : Number(item.february),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.march) : { value: item.march, formula: item.march_formula } : item.march == "" ? item.march : String(item.march).indexOf(".") == -1 ? Number(item.march) : Number(item.march),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.april) : { value: item.april, formula: item.april_formula } : item.april == "" ? item.april : String(item.april).indexOf(".") == -1 ? Number(item.april) : Number(item.april),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.may) : { value: item.may, formula: item.may_formula } : item.may == "" ? item.may : String(item.may).indexOf(".") == -1 ? Number(item.may) : Number(item.may),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.june) : { value: item.june, formula: item.june_formula } : item.june == "" ? item.june : String(item.june).indexOf(".") == -1 ? Number(item.june) : Number(item.june),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.july) : { value: item.july, formula: item.july_formula } : item.july == "" ? item.july : String(item.july).indexOf(".") == -1 ? Number(item.july) : Number(item.july),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.august) : { value: item.august, formula: item.august_formula } : item.august == "" ? item.august : String(item.august).indexOf(".") == -1 ? Number(item.august) : Number(item.august),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.september) : { value: item.september, formula: item.september_formula } : item.september == "" ? item.september : String(item.september).indexOf(".") == -1 ? Number(item.september) : Number(item.september),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.october) : { value: item.october, formula: item.october_formula } : item.october == "" ? item.october : String(item.october).indexOf(".") == -1 ? Number(item.october) : Number(item.october),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.november) : { value: item.november, formula: item.november_formula } : item.november == "" ? item.november : String(item.november).indexOf(".") == -1 ? Number(item.november) : Number(item.november),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.december) : { value: item.december, formula: item.december_formula } : item.december == "" ? item.december : String(item.december).indexOf(".") == -1 ? Number(item.december) : Number(item.december),
                                item.total_current_year === "NaN" ? "0.0" : item.total_current_year == "" ? item.total_current_year : String(item.total_current_year).indexOf(".") == -1 ? Number(item.total_current_year) : Number(item.total_current_year),
                                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),
                                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),
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
            }
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675
            if (this.state.defaultCurrencyUpload?.id == 2) {
                data.push({
                    "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
                    "item_report": String(i[6]),
                    "weight": String(i[7]),
                    "uom": String(i[8]),
                    "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]),
                    "january": i[13].value != undefined ? String(Number(i[13].value)) : String(i[13]),
                    "february": i[14].value != undefined ? String(Number(i[14].value)) : String(i[14]),
                    "march": i[15].value != undefined ? String(Number(i[15].value)) : String(i[15]),
                    "april": i[16].value != undefined ? String(Number(i[16].value)) : String(i[16]),
                    "may": i[17].value != undefined ? String(Number(i[17].value)) : String(i[17]),
                    "june": i[18].value != undefined ? String(Number(i[18].value)) : String(i[18]),
                    "july": i[19].value != undefined ? String(Number(i[19].value)) : String(i[19]),
                    "august": i[20].value != undefined ? String(Number(i[20].value)) : String(i[20]),
                    "september": i[21].value != undefined ? String(Number(i[21].value)) : String(i[21]),
                    "october": i[22].value != undefined ? String(Number(i[22].value)) : String(i[22]),
                    "november": i[23].value != undefined ? String(Number(i[23].value)) : String(i[23]),
                    "december": i[24].value != undefined ? String(Number(i[24].value)) : String(i[24]),
                    "total_current_year": String(Number(i[25])) == "" ? "0.0" : String(Number(i[25])),
                    "total_next_year": String(Number(i[26])) == "" ? "0.0" : String(Number(i[26])),
                    "total_more_year": String(Number(i[27])) == "" ? "0.0" : String(Number(i[27])),
                    "strategic": String(i[28]),
                    "pic": String(i[29])
                })
            } else {
                data.push({
                    "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
                    "item_report": String(i[6]),
                    "weight": String(i[7]),
                    "uom": String(i[8]),
                    "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]),
                    "january": i[13].value != undefined ? String(fixNumber(Number(i[13].value), 1)) : String(i[13]),
                    "february": i[14].value != undefined ? String(fixNumber(Number(i[14].value), 1)) : String(i[14]),
                    "march": i[15].value != undefined ? String(fixNumber(Number(i[15].value), 1)) : String(i[15]),
                    "april": i[16].value != undefined ? String(fixNumber(Number(i[16].value), 1)) : String(i[16]),
                    "may": i[17].value != undefined ? String(fixNumber(Number(i[17].value), 1)) : String(i[17]),
                    "june": i[18].value != undefined ? String(fixNumber(Number(i[18].value), 1)) : String(i[18]),
                    "july": i[19].value != undefined ? String(fixNumber(Number(i[19].value), 1)) : String(i[19]),
                    "august": i[20].value != undefined ? String(fixNumber(Number(i[20].value), 1)) : String(i[20]),
                    "september": i[21].value != undefined ? String(fixNumber(Number(i[21].value), 1)) : String(i[21]),
                    "october": i[22].value != undefined ? String(fixNumber(Number(i[22].value), 1)) : String(i[22]),
                    "november": i[23].value != undefined ? String(fixNumber(Number(i[23].value), 1)) : String(i[23]),
                    "december": i[24].value != undefined ? String(fixNumber(Number(i[24].value), 1)) : String(i[24]),
                    "total_current_year": String(fixNumber(Number(i[25]), 1)) == "" ? "0.0" : String(fixNumber(Number(i[25]), 1)),
                    "total_next_year": String(fixNumber(Number(i[26]), 1)) == "" ? "0.0" : String(fixNumber(Number(i[26]), 1)),
                    "total_more_year": String(fixNumber(Number(i[27]), 1)) == "" ? "0.0" : String(fixNumber(Number(i[27]), 1)),
                    "strategic": String(i[28]),
                    "pic": String(i[29])
                })
            }
d.arizona's avatar
d.arizona committed
676

d.arizona's avatar
d.arizona committed
677 678 679
        })
        let body = {
            "report_id": this.props.report_id,
Riri Novita's avatar
Riri Novita committed
680
            // "revision": Number(this.props.revision), 
d.arizona's avatar
d.arizona committed
681 682 683
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID,
Riri Novita's avatar
Riri Novita committed
684
            "currency_id": this.state.defaultCurrencyUpload?.id,
d.arizona's avatar
d.arizona committed
685
            "status": type,
d.arizona's avatar
d.arizona committed
686
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
687
        }
d.arizona's avatar
d.arizona committed
688 689
        // // console.log(data);
        // // console.log(JSON.stringify(body))
d.arizona's avatar
d.arizona committed
690
        api.create('UPLOAD').uploadMasterBudget(body).then(response => {
Riri Novita's avatar
Riri Novita committed
691
            console.log(response);
d.arizona's avatar
d.arizona committed
692
            if (response.data) {
693 694
                if (response.ok) {
                    if (response.data.status === "success") {
Riri Novita's avatar
Riri Novita committed
695 696 697 698 699 700 701
                        if (type == 'submitted') {
                            this.props.getReport(body, 'CAT')
                        } else {
                            this.props.getReport(body, 'DraftCAT')
                        }
                        this.setState({ loading: false })
                        this.props.onClickClose()
Riri Novita's avatar
Riri Novita committed
702
                        // this.props.getReport()
703
                    } else {
Riri Novita's avatar
Riri Novita committed
704
                        if (response.data?.message == "Please Set Up Rate Currency First") {
Riri Novita's avatar
Riri Novita committed
705
                            this.setState({ visibleAlertSave: true, loading: false })
Riri Novita's avatar
Riri Novita committed
706 707 708 709 710 711 712 713 714 715
                        } else {
                            this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                                if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                    setTimeout(() => {
                                        localStorage.removeItem(Constant.TOKEN)
                                        window.location.reload();
                                    }, 1000);
                                }
                            })
                        }
716
                    }
d.arizona's avatar
d.arizona committed
717
                } else {
718
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
719 720
                }
            } else {
d.arizona's avatar
d.arizona committed
721
                this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false })
d.arizona's avatar
d.arizona committed
722 723
            }
        })
724 725
    }

d.arizona's avatar
d.arizona committed
726 727
    handleValidate() {
        let data = []
d.arizona's avatar
d.arizona committed
728
        // // // console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
729 730 731 732
        let totalWeight = 0
        let dataTableBaru = this.state.dataTable
        let dataTampung = []
        let weightReal = null
d.arizona's avatar
d.arizona committed
733
        let handleKosongKPIMAXYTD = false
Deni Rinaldi's avatar
Deni Rinaldi committed
734
        let stateFR = false
d.arizona's avatar
d.arizona committed
735
        console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
736
        this.state.dataTable.map((i, index) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
737
            if (i[0] == 1) {
d.arizona's avatar
d.arizona committed
738 739 740 741 742 743 744 745
                dataTampung.push({
                    id: i[1],
                    maxValue: i[7],
                    valChild: 0
                })
            }

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

d.arizona's avatar
d.arizona committed
749 750
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
d.arizona's avatar
d.arizona committed
751 752
                // // // // console.log(indexID)
                // // // // console.log(i[2])
d.arizona's avatar
d.arizona committed
753
                if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
754
                    // // // // console.log(dataTableBaru[indexID][6])
d.arizona's avatar
d.arizona committed
755 756 757
                    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
758
                            // // // // console.log(handleKosongKPIMAXYTD)
d.arizona's avatar
d.arizona committed
759
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
760 761 762 763
                    } else if (dataTableBaru[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
d.arizona's avatar
d.arizona committed
764 765 766 767
                    }
                }
            }

d.arizona's avatar
d.arizona committed
768 769 770
            // 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
771
            //         // // // // console.log(handleKosongKPIMAXYTD)
d.arizona's avatar
d.arizona committed
772 773
            //     }
            // }
d.arizona's avatar
d.arizona committed
774

d.arizona's avatar
d.arizona committed
775 776 777
            if (i[2] !== null) {
                let indexID = dataTampung.findIndex((val) => val.id == i[2])
                if (indexID !== -1) {
Deni Rinaldi's avatar
Deni Rinaldi committed
778
                    let weightParent = Number(dataTampung[indexID].maxValue == "" || dataTampung[indexID].maxValue == undefined ? 0 : dataTampung[indexID].maxValue.replace('%', ''))
d.arizona's avatar
d.arizona committed
779
                    let valChild = Number(dataTampung[indexID].valChild)
Deni Rinaldi's avatar
Deni Rinaldi committed
780
                    let valReal = Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
781 782
                    let totalBaru = valChild + valReal
                    if (totalBaru > weightParent) {
783
                        dataTableBaru[index][7] = `${this.props.defaultCurrency.id == 1 ? String(fixNumber(Number(weightParent - valChild), 1)) : String(Number(weightParent - valChild)) + '%'}`
d.arizona's avatar
d.arizona committed
784
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + weightParent - valChild
785
                        weightReal = `${this.props.defaultCurrency.id == 1 ? String(fixNumber(Number(weightParent - valChild), 1)) : String(Number(weightParent - valChild)) + '%'}`
d.arizona's avatar
d.arizona committed
786 787 788
                    } else {
                        dataTableBaru[index][7] = i[7]
                        weightReal = i[7]
Deni Rinaldi's avatar
Deni Rinaldi committed
789
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
d.arizona's avatar
d.arizona committed
790
                    }
d.arizona's avatar
d.arizona committed
791
                    // // // // console.log(weightReal)
d.arizona's avatar
d.arizona committed
792 793
                    // console.log(dataTableBaru[index][7])
                    // console.log(dataTampung[indexID].valChild)
d.arizona's avatar
d.arizona committed
794 795
                }
            }
d.arizona's avatar
d.arizona committed
796 797
            // // console.log(String(weightReal).substr(0,String(weightReal).length-1))
            // // console.log(Number(String(weightReal).substr(0,String(weightReal).length-1)).toFixed(1));
Riri Novita's avatar
Riri Novita committed
798 799
            // console.log(weightReal)
            // console.log(i[7])
d.arizona's avatar
d.arizona committed
800 801
            let b = []
            // console.log(i[13].value == undefined? 'Y' : 'N')
d.arizona's avatar
d.arizona committed
802
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
803
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
d.arizona's avatar
d.arizona committed
804
                "item_name": String(i[6]),
d.arizona's avatar
d.arizona committed
805
                "parent": i[2] == "" ? null : i[2],
d.arizona's avatar
d.arizona committed
806
                "weight": weightReal == null ? String(i[7]) : weightReal,
d.arizona's avatar
d.arizona committed
807
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
808 809 810 811
                "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
812
                "january": i[13].value == undefined ? (String(i[13]) == '' ? "0.0" : String(i[13])) : String(i[13].value),
d.arizona's avatar
d.arizona committed
813
                // "january": stateFR ? String(i[13].value) : String(i[13]) == "" ? "0.0" : String(i[13]),
d.arizona's avatar
d.arizona committed
814 815 816 817 818 819 820 821 822 823 824
                "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
825 826 827
                "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
828 829 830
                "strategic": String(i[28]),
                "pic": String(i[29])
            })
d.arizona's avatar
d.arizona committed
831
            stateFR = false
d.arizona's avatar
d.arizona committed
832
        })
d.arizona's avatar
d.arizona committed
833

d.arizona's avatar
d.arizona committed
834 835
        // // // // console.log(dataTableBaru)
        // // // // console.log(JSON.stringify(data))
d.arizona's avatar
d.arizona committed
836 837 838 839 840
        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
841
            "currency_id": this.props.defaultCurrency.id,
d.arizona's avatar
d.arizona committed
842 843 844
            "status": "submitted",
            "cat": data
        }
d.arizona's avatar
d.arizona committed
845
        // // // // console.log(totalWeight)
d.arizona's avatar
d.arizona committed
846
        // this.setState({dataTable: dataTampung})
d.arizona's avatar
d.arizona committed
847
        if (handleKosongKPIMAXYTD) {
Deni Rinaldi's avatar
Deni Rinaldi committed
848
            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
849
        } else if (totalWeight < 100) {
Deni Rinaldi's avatar
Deni Rinaldi committed
850
            this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, editable: true })
d.arizona's avatar
d.arizona committed
851
        } else {
d.arizona's avatar
d.arizona committed
852
            console.log(JSON.stringify(payload))
d.arizona's avatar
d.arizona committed
853
            api.create().validateSubmitReport(payload).then((response) => {
d.arizona's avatar
d.arizona committed
854
                console.log(response)
d.arizona's avatar
d.arizona committed
855
                if (response.data.data.result) {
d.arizona's avatar
d.arizona committed
856
                    this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false })
d.arizona's avatar
d.arizona committed
857
                } else {
d.arizona's avatar
d.arizona committed
858
                    this.setState({ loading: false, buttonError: true, editable: true, buttonDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
859
                }
d.arizona's avatar
d.arizona committed
860 861
            })
        }
d.arizona's avatar
d.arizona committed
862 863 864 865 866 867
    }

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

faisalhamdi's avatar
faisalhamdi committed
868 869
    backToMasterBudget(type) {
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
870
        let stateFR = false
d.arizona's avatar
d.arizona committed
871
        // // // console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
872
        this.state.dataTable.map(i => {
Deni Rinaldi's avatar
Deni Rinaldi committed
873 874
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
d.arizona's avatar
d.arizona committed
875 876
                // // // // console.log(indexID)
                // // // // console.log(i[2])
Deni Rinaldi's avatar
Deni Rinaldi committed
877
                if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
878
                    // // // // console.log(dataTableBaru[indexID][6])
Deni Rinaldi's avatar
Deni Rinaldi committed
879 880 881 882 883 884
                    if (this.state.dataTable[indexID][6] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
d.arizona's avatar
d.arizona committed
885 886
            } else {
                stateFR = false
Deni Rinaldi's avatar
Deni Rinaldi committed
887
            }
d.arizona's avatar
d.arizona committed
888
            // // // // // console.log(i[9] == null? "" : i[9].value)
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948
            if (this.props.defaultCurrency.id == 2) {
                data.push({
                    "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
                    "item_name": String(i[6]),
                    "parent": i[2] == "" ? null : i[2],
                    "weight": String(i[7]),
                    "uom": String(i[8]),
                    "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]),
                    "january": i[13].value != undefined ? String(Number(i[13].value)) : String(i[13]),
                    "february": i[14].value != undefined ? String(Number(i[14].value)) : String(i[14]),
                    "march": i[15].value != undefined ? String(Number(i[15].value)) : String(i[15]),
                    "april": i[16].value != undefined ? String(Number(i[16].value)) : String(i[16]),
                    "may": i[17].value != undefined ? String(Number(i[17].value)) : String(i[17]),
                    "june": i[18].value != undefined ? String(Number(i[18].value)) : String(i[18]),
                    "july": i[19].value != undefined ? String(Number(i[19].value)) : String(i[19]),
                    "august": i[20].value != undefined ? String(Number(i[20].value)) : String(i[20]),
                    "september": i[21].value != undefined ? String(Number(i[21].value)) : String(i[21]),
                    "october": i[22].value != undefined ? String(Number(i[22].value)) : String(i[22]),
                    "november": i[23].value != undefined ? String(Number(i[23].value)) : String(i[23]),
                    "december": i[24].value != undefined ? String(Number(i[24].value)) : String(i[24]),
                    "total_current_year": String(Number(i[25])) == "" ? "0.0" : String(Number(i[25])),
                    "total_next_year": String(Number(i[26])) == "" ? "0.0" : String(Number(i[26])),
                    "total_more_year": String(Number(i[27])) == "" ? "0.0" : String(Number(i[27])),
                    "strategic": String(i[28]),
                    "pic": String(i[29])
                })
            } else {
                data.push({
                    "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
                    "item_name": String(i[6]),
                    "parent": i[2] == "" ? null : i[2],
                    "weight": String(i[7]),
                    "uom": String(i[8]),
                    "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]),
                    "january": i[13].value != undefined ? String(fixNumber(Number(i[13].value), 1)) : String(i[13]),
                    "february": i[14].value != undefined ? String(fixNumber(Number(i[14].value), 1)) : String(i[14]),
                    "march": i[15].value != undefined ? String(fixNumber(Number(i[15].value), 1)) : String(i[15]),
                    "april": i[16].value != undefined ? String(fixNumber(Number(i[16].value), 1)) : String(i[16]),
                    "may": i[17].value != undefined ? String(fixNumber(Number(i[17].value), 1)) : String(i[17]),
                    "june": i[18].value != undefined ? String(fixNumber(Number(i[18].value), 1)) : String(i[18]),
                    "july": i[19].value != undefined ? String(fixNumber(Number(i[19].value), 1)) : String(i[19]),
                    "august": i[20].value != undefined ? String(fixNumber(Number(i[20].value), 1)) : String(i[20]),
                    "september": i[21].value != undefined ? String(fixNumber(Number(i[21].value), 1)) : String(i[21]),
                    "october": i[22].value != undefined ? String(fixNumber(Number(i[22].value), 1)) : String(i[22]),
                    "november": i[23].value != undefined ? String(fixNumber(Number(i[23].value), 1)) : String(i[23]),
                    "december": i[24].value != undefined ? String(fixNumber(Number(i[24].value), 1)) : String(i[24]),
                    "total_current_year": String(fixNumber(Number(i[25]), 1)) == "" ? "0.0" : String(fixNumber(Number(i[25]), 1)),
                    "total_next_year": String(fixNumber(Number(i[26]), 1)) == "" ? "0.0" : String(fixNumber(Number(i[26]), 1)),
                    "total_more_year": String(fixNumber(Number(i[27]), 1)) == "" ? "0.0" : String(fixNumber(Number(i[27]), 1)),
                    "strategic": String(i[28]),
                    "pic": String(i[29])
                })
            }

faisalhamdi's avatar
faisalhamdi committed
949
        })
d.arizona's avatar
d.arizona committed
950
        // // // console.log(JSON.stringify(data))
faisalhamdi's avatar
faisalhamdi committed
951 952 953 954 955
        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
956
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
957
            "status": type,
d.arizona's avatar
d.arizona committed
958
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
959
        }
d.arizona's avatar
d.arizona committed
960
        console.log(JSON.stringify(payload));
961
        this.deleteReport(payload, type)
d.arizona's avatar
d.arizona committed
962 963
    }

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

d.arizona's avatar
d.arizona committed
967 968
        if (this.state.dataDelete.length > 0) {
            api.create().deleteAllItemReport(payload).then((response) => {
Riri Novita's avatar
Riri Novita committed
969
                console.log(response)
d.arizona's avatar
d.arizona committed
970

d.arizona's avatar
d.arizona committed
971
                // api.create().validateSubmitReport(payloadBro).then((response) => {
d.arizona's avatar
d.arizona committed
972
                //     // // // // console.log(response)
d.arizona's avatar
d.arizona committed
973
                //     if (response.data.data.result) {
Riri Novita's avatar
Riri Novita committed
974 975 976
                if (response.data.status === "success") {
                    if (type == 'submitted') {
                        this.props.saveToMasterBudget(payloadBro, 'CAT')
Riri Novita's avatar
Riri Novita committed
977
                        // this.props.onClickClose()
Riri Novita's avatar
Riri Novita committed
978
                    } else {
Riri Novita's avatar
Riri Novita committed
979
                        this.props.saveToMasterBudget(payloadBro, 'DraftCAT')
Riri Novita's avatar
Riri Novita committed
980
                        // this.props.onClickClose()
Riri Novita's avatar
Riri Novita committed
981
                    }
982
                } else {
Riri Novita's avatar
Riri Novita committed
983 984 985 986 987 988 989 990 991 992 993 994
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
995
                }
Riri Novita's avatar
Riri Novita committed
996

997 998
                // this.props.saveToMasterBudget(payloadBro)
                // this.props.onClickClose()
d.arizona's avatar
d.arizona committed
999
                //     } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1000

d.arizona's avatar
d.arizona committed
1001 1002 1003 1004
                //     }
                // })
            })
        } else {
Riri Novita's avatar
Riri Novita committed
1005
            console.log("kesini bukan?");
d.arizona's avatar
d.arizona committed
1006
            // // // // // console.log('sini jing')
d.arizona's avatar
d.arizona committed
1007
            // api.create().validateSubmitReport(payloadBro).then((response) => {
d.arizona's avatar
d.arizona committed
1008
            //     // // // // console.log(response)
d.arizona's avatar
d.arizona committed
1009
            //     if (response.data.data.result) {
Riri Novita's avatar
Riri Novita committed
1010
            this.props.saveToMasterBudget(payloadBro, 'CAT')
Deni Rinaldi's avatar
Deni Rinaldi committed
1011
            this.props.onClickClose()
d.arizona's avatar
d.arizona committed
1012
            //     } else {
d.arizona's avatar
d.arizona committed
1013

d.arizona's avatar
d.arizona committed
1014 1015 1016
            //     }
            // })
        }
faisalhamdi's avatar
faisalhamdi committed
1017 1018
    }

d.arizona's avatar
d.arizona committed
1019

d.arizona's avatar
d.arizona committed
1020 1021 1022 1023 1024 1025 1026
    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
1027
            // // // // // console.log(response)
d.arizona's avatar
d.arizona committed
1028 1029 1030 1031
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
d.arizona's avatar
d.arizona committed
1032
                        // // // // console.log(data)
d.arizona's avatar
d.arizona committed
1033
                        let inputKPI = []
Deni Rinaldi's avatar
Deni Rinaldi committed
1034

d.arizona's avatar
d.arizona committed
1035 1036
                        data.map((item) => {
                            inputKPI.push({
d.arizona's avatar
d.arizona committed
1037
                                value: item.value
d.arizona's avatar
d.arizona committed
1038
                            })
d.arizona's avatar
d.arizona committed
1039 1040 1041 1042 1043
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
d.arizona's avatar
d.arizona committed
1044
                        // // // // console.log(defaultProps)
d.arizona's avatar
d.arizona committed
1045 1046 1047
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
1048
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084
                                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
1085
                        // setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1086
                        this.setState({ maxAchList: defaultProps })
d.arizona's avatar
d.arizona committed
1087
                        // }, 300);
d.arizona's avatar
d.arizona committed
1088 1089
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
1090
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104
                                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
1105
            this.getItemHierarki()
d.arizona's avatar
d.arizona committed
1106 1107 1108
        })
    }

d.arizona's avatar
d.arizona committed
1109 1110 1111 1112 1113 1114
    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
1115
            "submission_id": this.props.submissionID,
d.arizona's avatar
d.arizona committed
1116 1117 1118 1119 1120
        }
        api.create().getLastestUpdateMB(payload).then(response => {
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
1121
                        updateBy: response.data.data.detail === null ? '-' : response.data.data.detail
d.arizona's avatar
d.arizona committed
1122
                    })
Riri Novita's avatar
Riri Novita committed
1123 1124
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
1125
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
1126 1127 1128 1129 1130 1131
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
d.arizona's avatar
d.arizona committed
1132 1133 1134 1135 1136
                }
            }
        })
    }

1137
    render() {
faisalhamdi's avatar
faisalhamdi committed
1138
        let dataTable2 = this.state.dataTable
d.arizona's avatar
d.arizona committed
1139
        let dataDelete = this.state.dataDelete
faisalhamdi's avatar
faisalhamdi committed
1140 1141
        const handleChange = (value, tableMeta) => {
            let val = String(value).split(",").join("")
d.arizona's avatar
d.arizona committed
1142
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
d.arizona's avatar
d.arizona committed
1143 1144
        }

d.arizona's avatar
d.arizona committed
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
        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
1164

d.arizona's avatar
d.arizona committed
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174
            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
1175
                    let formulaAwal = String(item).substr(0, indexX)
d.arizona's avatar
d.arizona committed
1176
                    let columnEnd = 24
Deni Rinaldi's avatar
Deni Rinaldi committed
1177
                    let month = column - 1
d.arizona's avatar
d.arizona committed
1178
                    let total = 0
d.arizona's avatar
d.arizona committed
1179
                    // // // console.log(formulaAwal)
Deni Rinaldi's avatar
Deni Rinaldi committed
1180 1181
                    if (forecast == undefined) {
                        dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
d.arizona's avatar
d.arizona committed
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196
                            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
1197
                        anjay.push(column)
d.arizona's avatar
d.arizona committed
1198 1199 1200
                    }
                } else if (item.includes('X')) {
                    let indexX = String(item).indexOf('X')
d.arizona's avatar
d.arizona committed
1201
                    // console.log(item)
d.arizona's avatar
d.arizona committed
1202
                    if (indexX == 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1203
                        anjay.push(String(item).substr(1, String(item).length))
d.arizona's avatar
d.arizona committed
1204
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1205 1206 1207 1208
                        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
1209
                        if (forecast == undefined) {
d.arizona's avatar
d.arizona committed
1210 1211 1212 1213
                            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
1214 1215
                                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
1216
                                anjay.push(valuezz == "" ? 0 : valuezz)
d.arizona's avatar
d.arizona committed
1217 1218 1219 1220 1221 1222
                            } 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
1223 1224
                            }
                        } else {
syadziy's avatar
syadziy committed
1225 1226 1227 1228 1229 1230
                            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
1231
                                anjay.push(valuezz == "" ? 0 : valuezz)
syadziy's avatar
syadziy committed
1232 1233 1234 1235 1236 1237 1238 1239
                            } 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
1240
                            }
qorri_di's avatar
qorri_di committed
1241

d.arizona's avatar
d.arizona committed
1242 1243 1244 1245 1246 1247
                            // 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
1248

d.arizona's avatar
d.arizona committed
1249 1250 1251 1252
                        anjay.push(operatorX)
                        anjay.push(nilaiX)
                    }
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1253
                    if (String(item).includes('#')) {
d.arizona's avatar
d.arizona committed
1254 1255 1256 1257
                        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
1258
                                anjay.push(valuezz == "" || valuezz == null ? "0" : valuezz)
d.arizona's avatar
d.arizona committed
1259
                            }
d.arizona's avatar
d.arizona committed
1260 1261 1262 1263
                        } 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
1264 1265
                        }
                    } else {
d.arizona's avatar
d.arizona committed
1266 1267 1268
                        let convertID = -1
                        if (tableMeta.rowData[11].value == 'FORMULA') {
                            let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
syadziy's avatar
syadziy committed
1269 1270 1271 1272
                            // console.log(indexIDReport);
                            if (indexIDReport != -1) {
                                convertID = dataTable2[indexIDReport][31]
                            }
d.arizona's avatar
d.arizona committed
1273
                        }
d.arizona's avatar
d.arizona committed
1274
                        let indexID = dataTable2.findIndex((val) => val[31] == (convertID == -1 ? item : convertID))
d.arizona's avatar
d.arizona committed
1275
                        if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
1276
                            let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
d.arizona's avatar
d.arizona committed
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289
                            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
1290 1291 1292 1293 1294
            // if (tableMeta.rowData[11].value == 'FORMULA') {
            //     console.log(anjay)
            //     console.log(column)

            // }
d.arizona's avatar
d.arizona committed
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306

            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
1307 1308 1309
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
d.arizona's avatar
d.arizona committed
1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412
                    // }
                } 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
1413
            // if (dataTable2[tableMeta.rowIndex][6] == "NPAT" && forecast !== undefined) {
d.arizona's avatar
d.arizona committed
1414 1415 1416 1417 1418 1419 1420
            //     // // 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
1421
            // }
d.arizona's avatar
d.arizona committed
1422 1423 1424 1425 1426 1427 1428
            // // // 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
1429

d.arizona's avatar
d.arizona committed
1430
            total = R.equals(total, NaN) ? "0.0" : total
Riri Novita's avatar
Riri Novita committed
1431
            // console.log(total);
d.arizona's avatar
d.arizona committed
1432 1433 1434 1435 1436 1437 1438
            // 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
1439
            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
1440
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
qorri_di's avatar
qorri_di committed
1441
            } else {
1442
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 1) : Number(total)
qorri_di's avatar
qorri_di committed
1443
            }
d.arizona's avatar
d.arizona committed
1444
            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
1445

d.arizona's avatar
d.arizona committed
1446 1447 1448 1449 1450 1451
            return total
        }

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

d.arizona's avatar
d.arizona committed
1453
        const handleChangeDropdown = (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
1454
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
d.arizona's avatar
d.arizona committed
1455 1456 1457
            let valz = value.value
            let total = 0
            let lastValz = 0
d.arizona's avatar
d.arizona committed
1458
            if (valz == 'SUM' || valz == 'AVG' || valz == 'LAST' || valz == 'FORMULA') {
Deni Rinaldi's avatar
Deni Rinaldi committed
1459
                dataTable2[tableMeta.rowIndex].map((item, index) => {
d.arizona's avatar
d.arizona committed
1460
                    if (index >= 13 && index <= 24) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1461
                        let valItem = item == undefined || item == "" ? 0 : item
d.arizona's avatar
d.arizona committed
1462 1463 1464 1465 1466 1467
                        total += Number(valItem)
                        if (index == 24) {
                            lastValz += Number(valItem)
                        }
                    }
                })
d.arizona's avatar
d.arizona committed
1468 1469 1470 1471
                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
1472
            }
d.arizona's avatar
d.arizona committed
1473
        }
d.arizona's avatar
d.arizona committed
1474
        const handleValueDropdown = (value, type, tableMeta) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1475
            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
1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489
            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
1490 1491

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

d.arizona's avatar
d.arizona committed
1494 1495 1496 1497
        }

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

d.arizona's avatar
d.arizona committed
1500
        const handleAction = (idParent, typeReport, tableMeta) => {
d.arizona's avatar
d.arizona committed
1501 1502
            if (this.props.isApprover) {
                return false
d.arizona's avatar
d.arizona committed
1503
            } else {
d.arizona's avatar
d.arizona committed
1504 1505 1506 1507 1508 1509 1510 1511
                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
1512
                    } else {
d.arizona's avatar
d.arizona committed
1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524
                        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
1525
                    }
d.arizona's avatar
d.arizona committed
1526 1527 1528
                } else {
                    return false
                }
d.arizona's avatar
d.arizona committed
1529
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1530

d.arizona's avatar
d.arizona committed
1531 1532
        }

d.arizona's avatar
d.arizona committed
1533 1534 1535 1536
        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
1537 1538 1539 1540 1541
                    if (tableMeta.rowData[0] == 3) {
                        return false
                    } else {
                        return true
                    }
d.arizona's avatar
d.arizona committed
1542 1543 1544 1545 1546 1547 1548 1549
                } else {
                    return false
                }
            } else {
                return false
            }
        }

d.arizona's avatar
d.arizona committed
1550
        const handleTambah = (data, rowIndex) => {
d.arizona's avatar
d.arizona committed
1551
            // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
1552 1553 1554
            let newData = []
            dataTable2.map((item, index) => {
                newData.push(item)
d.arizona's avatar
d.arizona committed
1555
                if (index == rowIndex) {
d.arizona's avatar
d.arizona committed
1556
                    newData.push([
d.arizona's avatar
d.arizona committed
1557
                        null,
d.arizona's avatar
d.arizona committed
1558
                        "",
Deni Rinaldi's avatar
Deni Rinaldi committed
1559
                        item[2] == null || item[2] == "" ? item[1] : item[2],
d.arizona's avatar
d.arizona committed
1560 1561 1562 1563 1564 1565
                        item[3],
                        item[4],
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
1566 1567 1568
                        null,
                        null,
                        null,
d.arizona's avatar
d.arizona committed
1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
1585
                        "",
d.arizona's avatar
d.arizona committed
1586 1587
                        ""
                    ])
Deni Rinaldi's avatar
Deni Rinaldi committed
1588

d.arizona's avatar
d.arizona committed
1589 1590 1591
                }
            })
            dataTable2 = newData
Deni Rinaldi's avatar
Deni Rinaldi committed
1592
            this.setState({ dataTable: dataTable2 }, () => {
d.arizona's avatar
d.arizona committed
1593
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1594
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
1595
                    // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1596
                }, 500)
d.arizona's avatar
d.arizona committed
1597 1598 1599 1600
            })
        }

        const handleDelete = (index) => {
d.arizona's avatar
d.arizona committed
1601 1602 1603
            if (dataTable2[index][1] !== "") {
                dataDelete.push(dataTable2[index][1])
            }
d.arizona's avatar
d.arizona committed
1604
            dataTable2.splice(index, 1)
Deni Rinaldi's avatar
Deni Rinaldi committed
1605
            this.setState({ dataTable: dataTable2, dataDelete }, () => {
d.arizona's avatar
d.arizona committed
1606
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1607
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
1608
                }, 100)
d.arizona's avatar
d.arizona committed
1609 1610
            })
        }
d.arizona's avatar
d.arizona committed
1611

Deni Rinaldi's avatar
Deni Rinaldi committed
1612
        const handleTotal = (tableMeta, type) => {
d.arizona's avatar
d.arizona committed
1613 1614 1615
            // let val = String(value).split(",").join("")
            let total = 0
            let lastValz = 0
d.arizona's avatar
d.arizona committed
1616 1617 1618 1619 1620
            // 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
1621 1622 1623 1624 1625 1626
            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
1627
                    }
qorri_di's avatar
qorri_di committed
1628 1629 1630 1631 1632
                }
            })
            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
1633
            // }
d.arizona's avatar
d.arizona committed
1634 1635
        }

1636
        const columns = [{
faisalhamdi's avatar
faisalhamdi committed
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661
            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
1662 1663
            name: "",
            options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
1664
                filter: false,
d.arizona's avatar
d.arizona committed
1665
                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
1666 1667 1668 1669
                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
1670
                ),
Deni Rinaldi's avatar
Deni Rinaldi committed
1671 1672
                customBodyRender: (val, tableMeta) => {
                    return (
qorri_di's avatar
qorri_di committed
1673
                        // handleAction(tableMeta.rowData[2]) && 
d.arizona's avatar
d.arizona committed
1674
                        <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1675
                            {/* {tableMeta.rowData[6] === "Active" ? */}
d.arizona's avatar
d.arizona committed
1676
                            {handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && <span>
Deni Rinaldi's avatar
Deni Rinaldi committed
1677 1678 1679 1680 1681 1682 1683
                                <LightTooltip title={'Add'} arrow>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                        }}
d.arizona's avatar
d.arizona committed
1684
                                        // onClick={() => // // // // console.log(tableMeta.rowData[1])}
Deni Rinaldi's avatar
Deni Rinaldi committed
1685 1686 1687 1688 1689 1690 1691 1692 1693
                                        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
1694
                            {handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) && <span>
Deni Rinaldi's avatar
Deni Rinaldi committed
1695 1696 1697 1698 1699 1700 1701 1702 1703
                                <LightTooltip title={'Delete'} arrow>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            marginLeft: 5
                                        }}
                                        onClick={() => {
d.arizona's avatar
d.arizona committed
1704 1705
                                            this.setState({ loading: true })
                                            handleDelete(tableMeta.rowIndex)
Deni Rinaldi's avatar
Deni Rinaldi committed
1706 1707 1708 1709 1710
                                        }}
                                    >
                                        <img src={Images.delete} />
                                    </button>
                                </LightTooltip>
d.arizona's avatar
d.arizona committed
1711
                            </span>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1712 1713 1714
                        </div >
                    );
                }
d.arizona's avatar
d.arizona committed
1715
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1716
        }, {
1717 1718 1719
            name: "Key Performance Indicator",
            options: {
                customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1720
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8' }}>
d.arizona's avatar
d.arizona committed
1721
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
1722 1723 1724 1725 1726
                    </TableCell>
                ),
                setCellProps: () => ({ style }),
                customBodyRender: (val, tableMeta) => {
                    return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1727
                        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
1728
                            <div style={{ textAlign: 'left', paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
d.arizona's avatar
d.arizona committed
1729
                                {!this.state.loading && <FormControlLabel
Deni Rinaldi's avatar
Deni Rinaldi committed
1730 1731 1732 1733 1734 1735 1736 1737 1738 1739
                                    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
1740
                                                // // // // console.log(event.target.value)
Deni Rinaldi's avatar
Deni Rinaldi committed
1741
                                                handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1742
                                                // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1743 1744 1745
                                            }}
                                        />
                                    }
d.arizona's avatar
d.arizona committed
1746
                                />}
Deni Rinaldi's avatar
Deni Rinaldi committed
1747 1748 1749
                            </div>
                            :
                            <div style={{ width: 300 }}>
d.arizona's avatar
d.arizona committed
1750 1751
                                {tableMeta.rowData[32] ?
                                    tableMeta.rowData[32].length > 0 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768
                                        <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
1769 1770 1771 1772
                                    :
                                    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
1773 1774
                                        tableMeta.rowData[1] == null ?
                                            <div style={{ paddingLeft: 20 }}>
d.arizona's avatar
d.arizona committed
1775 1776
                                                <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1777
                                            :
d.arizona's avatar
d.arizona committed
1778 1779 1780
                                            <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
1781 1782
                                }
                            </div>
1783 1784 1785 1786 1787 1788 1789
                    )
                }
            }
        }, {
            name: "Weight",
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1790
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1791 1792 1793
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1794 1795 1796 1797
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1798
                            {tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1799
                                null :
Deni Rinaldi's avatar
Deni Rinaldi committed
1800
                                tableMeta.rowData[0] === 1 ?
d.arizona's avatar
d.arizona committed
1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814
                                    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
1815
                                                    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
1816 1817 1818 1819 1820 1821 1822 1823 1824
                                                    maxLength={4}
                                                    onBlur={(event) => {
                                                        // updateValue(some)
                                                        handleChangePercentage(event.target.value, tableMeta)
                                                    }}
                                                />
                                            }
                                        />
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
1825 1826 1827 1828
                            }
                        </div>
                    )
                }
1829 1830 1831 1832 1833
            }
        }, {
            name: "UOM",
            options: {
                customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1834
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8' }}>
1835 1836 1837 1838 1839 1840
                        <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
1841
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1842 1843 1844
                                null :
                                <FormControlLabel
                                    style={{ margin: 0 }}
d.arizona's avatar
d.arizona committed
1845
                                    // value={value}
d.arizona's avatar
d.arizona committed
1846
                                    control={
d.arizona's avatar
d.arizona committed
1847
                                        !handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) ?
d.arizona's avatar
d.arizona committed
1848 1849
                                            <Input
                                                disableUnderline={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1850
                                                style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginTop: -10 }}
d.arizona's avatar
d.arizona committed
1851 1852 1853 1854
                                                type="text"
                                                placeholder=""
                                                defaultValue={value}
                                                color={"#5198ea"}
d.arizona's avatar
d.arizona committed
1855
                                                disabled={true}
d.arizona's avatar
d.arizona committed
1856
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
1857
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
1858 1859
                                                    // updateValue(event.target.value)
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1860
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
1861
                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1862 1863 1864 1865 1866 1867 1868 1869 1870
                                            /> :
                                            <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
1871
                                                    // 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
1872
                                                    onBlur={(event) => {
d.arizona's avatar
d.arizona committed
1873
                                                        // // // // console.log(event.target.value)
Deni Rinaldi's avatar
Deni Rinaldi committed
1874 1875
                                                        // updateValue(event.target.value)
                                                        handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
1876
                                                        // // // // console.log(dataTable2)
Deni Rinaldi's avatar
Deni Rinaldi committed
1877 1878 1879
                                                    }}
                                                />
                                            </ThemeProvider>
d.arizona's avatar
d.arizona committed
1880
                                    }
d.arizona's avatar
d.arizona committed
1881
                                />
1882 1883 1884 1885 1886 1887
                            }
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
1888
            name: "KPI Type",
1889 1890
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
1891
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1892 1893 1894
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
1895
                customBodyRender: (val, tableMeta) => {
1896 1897
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1898
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1899 1900 1901 1902 1903 1904 1905
                                null :
                                <Autocomplete
                                    {...this.state.kpiTypeList}
                                    id="kpiType"
                                    onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
                                    debug
                                    disableClearable
d.arizona's avatar
d.arizona committed
1906
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
d.arizona's avatar
d.arizona committed
1907
                                    value={handleValueDropdown(val, 'KPI', tableMeta)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1908
                                    style={{ padding: 0, margin: 0 }}
d.arizona's avatar
d.arizona committed
1909
                                    renderInput={(params) =>
Deni Rinaldi's avatar
Deni Rinaldi committed
1910
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
d.arizona's avatar
d.arizona committed
1911
                                            <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
1912 1913 1914 1915
                                        </div>
                                    }
                                />
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1916

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

d.arizona's avatar
d.arizona committed
3754 3755
                                    }
                                />
d.arizona's avatar
d.arizona committed
3756
                            }
3757 3758 3759 3760 3761
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
3762
            name: "PIC",
3763 3764
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
3765
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
3766 3767 3768
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
3769
                customBodyRender: (value, tableMeta) => {
3770
                    return (
d.arizona's avatar
d.arizona committed
3771
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3772
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
3773 3774 3775 3776 3777 3778 3779 3780 3781
                                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
3782 3783
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
3784
                                                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
3785
                                                defaultValue={value}
d.arizona's avatar
d.arizona committed
3786
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
3787
                                                    // // // // console.log(event.target.value)
d.arizona's avatar
d.arizona committed
3788
                                                    // updateValue(event.target.value)
d.arizona's avatar
d.arizona committed
3789
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
3790
                                                    // // // // console.log(dataTable2)
d.arizona's avatar
d.arizona committed
3791 3792
                                                }}
                                            />
d.arizona's avatar
d.arizona committed
3793
                                        </ThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
3794

d.arizona's avatar
d.arizona committed
3795 3796
                                    }
                                />
d.arizona's avatar
d.arizona committed
3797
                            }
3798 3799 3800 3801
                        </div>
                    )
                }
            }
d.arizona's avatar
d.arizona committed
3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        },
3813
        ]
faisalhamdi's avatar
faisalhamdi committed
3814
        const loadingComponent = (
d.arizona's avatar
d.arizona committed
3815
            <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
3816 3817 3818 3819 3820 3821 3822 3823
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );
3824 3825 3826 3827

        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
3828
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
3829
                </div>
faisalhamdi's avatar
faisalhamdi committed
3830
                {/* {this.state.loading && loadingComponent} */}
d.arizona's avatar
d.arizona committed
3831
                <Snackbar open={this.state.alert} autoHideDuration={3000} onClose={() => this.closeAlert()}>
d.arizona's avatar
d.arizona committed
3832 3833 3834 3835
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
3836
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3837
                    {this.state.visibleCAT ? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
qorri_di's avatar
qorri_di committed
3838 3839 3840 3841 3842 3843 3844 3845
                        <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                            <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Corporate Annual Target</Typography>
                        </div>
                        <div style={{ padding: 20 }}>
                            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
3846 3847 3848 3849 3850
                                    {this.props.defaultCurrency.id === 1 ?
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                        :
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                    }
qorri_di's avatar
qorri_di committed
3851 3852
                                </div>
                                <div style={{ width: '50%' }}>
3853 3854 3855 3856 3857
                                    {this.state.dataTable.length == 0 ? null : this.props.isApprover == true ?
                                        null
                                        :
                                        <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">
Riri Novita's avatar
Riri Novita committed
3858 3859 3860 3861 3862 3863 3864
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
3865
                                                    onClick={() => this.downloadTemplate()}
Riri Novita's avatar
Riri Novita committed
3866
                                                >
3867
                                                    <img src={Images.template} />
Riri Novita's avatar
Riri Novita committed
3868
                                                </button>
3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885
                                            </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
3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902
                                                <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
3903
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
3904 3905
                                        </div>
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
3906
                                </div>
qorri_di's avatar
qorri_di committed
3907
                            </div>
3908

qorri_di's avatar
qorri_di committed
3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929
                            <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
3930
                                </div>
qorri_di's avatar
qorri_di committed
3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951
                            </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>
3952
                                    </div>
qorri_di's avatar
qorri_di committed
3953
                                </button>
3954
                            </div>
qorri_di's avatar
qorri_di committed
3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009
                            {!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' })
                                                :
4010 4011
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
qorri_di's avatar
qorri_di committed
4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027
                                                        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
4028 4029
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
d.arizona's avatar
d.arizona committed
4030 4031 4032 4033
                            <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
4034
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
Riri Novita's avatar
Riri Novita committed
4035 4036 4037 4038 4039
                                        {this.props.defaultCurrency.id === 1 ?
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                            :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                        }
d.arizona's avatar
d.arizona committed
4040 4041
                                    </div>
                                    {this.state.dataLoaded && (
d.arizona's avatar
d.arizona committed
4042
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
d.arizona's avatar
d.arizona committed
4043
                                            {this.state.loading && loadingComponent}
d.arizona's avatar
d.arizona committed
4044
                                            <MuiThemeProvider theme={getMuiTheme()}>
d.arizona's avatar
d.arizona committed
4045 4046 4047 4048 4049
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
d.arizona's avatar
d.arizona committed
4050
                                            </MuiThemeProvider>
d.arizona's avatar
d.arizona committed
4051 4052 4053
                                        </div>
                                    )}
                                </div>
d.arizona's avatar
d.arizona committed
4054 4055 4056 4057 4058 4059 4060 4061 4062 4063
                                <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
4064
                                            onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
4065
                                                this.setState({ loading: true, visibleCAT: true, dataTable: [] }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
4066 4067 4068 4069
                                                    setTimeout(() => {
                                                        this.getItemHierarki()
                                                    }, 100)
                                                })}
d.arizona's avatar
d.arizona committed
4070 4071
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
4072
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
d.arizona's avatar
d.arizona committed
4073 4074 4075
                                            </div>
                                        </button>
                                    </div>
d.arizona's avatar
d.arizona committed
4076
                                    {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
d.arizona's avatar
d.arizona committed
4077
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4078
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
4079
                                            onClick={() =>
d.arizona's avatar
d.arizona committed
4080
                                                this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
d.arizona's avatar
d.arizona committed
4081
                                                    setTimeout(() => {
d.arizona's avatar
d.arizona committed
4082
                                                        this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
4083
                                                        this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
d.arizona's avatar
d.arizona committed
4084
                                                    }, 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
4085
                                                })
d.arizona's avatar
d.arizona committed
4086 4087 4088 4089 4090 4091
                                            }
                                            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
4092
                                        </button>}
d.arizona's avatar
d.arizona committed
4093
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4094 4095
                                            className="button"
                                            type="button"
d.arizona's avatar
d.arizona committed
4096
                                            disabled={this.state.buttonDraft ? true : this.state.handleDataSalah ? true : false}
d.arizona's avatar
d.arizona committed
4097 4098
                                            style={{
                                                backgroundColor: 'transparent',
d.arizona's avatar
d.arizona committed
4099
                                                cursor: this.state.editable === true ? 'default' : this.state.handleDataSalah ? 'default' : 'pointer',
d.arizona's avatar
d.arizona committed
4100 4101 4102 4103
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
4104
                                            onClick={() => this.state.editable ?
d.arizona's avatar
d.arizona committed
4105
                                                this.setState({ alert: true }) : (this.state.handleDataSalah ? null : this.setState({ loading: true }, () =>
4106 4107
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
4108 4109 4110 4111
                                                            setTimeout(() => {
                                                                this.uploadCAT("draft")
                                                            }, 100);
                                                        })
d.arizona's avatar
d.arizona committed
4112
                                                ))
Deni Rinaldi's avatar
Deni Rinaldi committed
4113
                                            }
d.arizona's avatar
d.arizona committed
4114 4115 4116 4117
                                        >
                                            <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
4118
                                        </button>}
d.arizona's avatar
d.arizona committed
4119
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
4120
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
4121 4122
                                            style={{
                                                backgroundColor: 'transparent',
d.arizona's avatar
d.arizona committed
4123
                                                cursor: this.state.editable === true ? 'default' : this.state.handleDataSalah ? 'default' : 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
4124 4125 4126
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
d.arizona's avatar
d.arizona committed
4127
                                            disabled={this.state.buttonDraft ? true : this.state.handleDataSalah ? true : false}
Deni Rinaldi's avatar
Deni Rinaldi committed
4128
                                            onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
4129 4130
                                                this.state.editable ? this.setState({ alert: true }) :
                                                    this.state.buttonError === true ?
d.arizona's avatar
d.arizona committed
4131
                                                        this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) : (this.state.handleDataSalah ? null : this.setState({ loading: true }, () =>
4132 4133
                                                            this.state.handleDoubleClick == 1 ? null :
                                                                this.setState({ handleDoubleClick: 1 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
4134 4135 4136 4137
                                                                    setTimeout(() => {
                                                                        this.uploadCAT("submitted")
                                                                    }, 100);
                                                                })
d.arizona's avatar
d.arizona committed
4138
                                                        ))
Deni Rinaldi's avatar
Deni Rinaldi committed
4139
                                            }
d.arizona's avatar
d.arizona committed
4140 4141 4142 4143
                                        >
                                            <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
4144
                                        </button>}
d.arizona's avatar
d.arizona committed
4145
                                    </div>}
d.arizona's avatar
d.arizona committed
4146 4147 4148
                                </div>
                            </div>
                        </Paper>}
4149
                </div>
d.arizona's avatar
d.arizona committed
4150

Riri Novita's avatar
Riri Novita committed
4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168
                {
                    this.state.visibleUpload && (
                        <div className="test app-popup-show">
                            <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                                <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                    <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                        <div className="popup-title">
                                            <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                        </div>
                                    </div>
                                    <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                        <button
                                            type="button"
                                            className="btn btn-circle btn-white"
                                            onClick={() => this.setState({ visibleUpload: false })}
                                        >
                                            <img src={Images.close} />
                                        </button>
d.arizona's avatar
d.arizona committed
4169 4170
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186
                                <div style={{ padding: '25px 30px' }}>
                                    <UploadFile
                                        type={this.state.uploadStatus}
                                        percentage={this.state.percentage}
                                        result={this.state.result}
                                        acceptedFiles={["xlsx"]}
                                        onHandle={(dt) => {
                                            this.fileHandler(dt)
                                            this.setState({ uploadStatus: 'idle', percentage: '0' })
                                        }}
                                        onUpload={() => {
                                            String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("CAT") ?
                                                this.checkUpload() :
                                                this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                        }}
                                    />
d.arizona's avatar
d.arizona committed
4187
                                </div>
4188
                                <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data in <b>{this.props.defaultCurrency.id == 1 ? "IDR mn" : "thousand USD"}</b></div>
Riri Novita's avatar
Riri Novita committed
4189

Riri Novita's avatar
Riri Novita committed
4190
                            </div>
Riri Novita's avatar
Riri Novita committed
4191
                        </div>
Riri Novita's avatar
Riri Novita committed
4192 4193
                    )
                }
Riri Novita's avatar
Riri Novita committed
4194

Riri Novita's avatar
Riri Novita committed
4195 4196 4197 4198 4199 4200 4201 4202
                {
                    this.state.visibleAlertSave && (
                        <div className="test app-popup-show">
                            <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
                                <div style={{ margin: 30 }}>
                                    <div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
                                        <div style={{ alignSelf: 'center', marginRight: 25 }}>
                                            <img src={Images.warning} />
Riri Novita's avatar
Riri Novita committed
4203
                                        </div>
Riri Novita's avatar
Riri Novita committed
4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219
                                        <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
                                            }}
4220
                                            onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0, loading: false })}
Riri Novita's avatar
Riri Novita committed
4221 4222 4223 4224 4225 4226
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 9, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
                                                <Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
                                            </div>
                                        </button>
                                    </div>
Riri Novita's avatar
Riri Novita committed
4227 4228
                                </div>
                            </div>
d.arizona's avatar
d.arizona committed
4229
                        </div>
Riri Novita's avatar
Riri Novita committed
4230 4231 4232
                    )
                }
            </div >
4233 4234 4235
        );
    }
}