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

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

const options = ct.customOptionsFixedColumn();
const style = {
    position: "sticky",
    left: 0,
    background: "white",
faisalhamdi's avatar
faisalhamdi committed
33
    zIndex: 101,
faisalhamdi's avatar
faisalhamdi committed
34 35 36 37 38 39 40
};
const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100
};

faisalhamdi's avatar
faisalhamdi committed
41 42 43 44 45 46 47 48 49 50 51
const theme = createMuiTheme({
    overrides: {
        // Style sheet name ⚛️
        MuiInputBase: {
            input: {
                color: '#5198ea'
            }
        }
    },
});

faisalhamdi's avatar
faisalhamdi committed
52
export default class CorporateAnnualTargetRO extends Component {
faisalhamdi's avatar
faisalhamdi committed
53 54 55 56 57 58 59
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
            loading: true,
            uomList: [],
            formulaYtdList: {
Deni Rinaldi's avatar
Deni Rinaldi committed
60
                options: [{ value: 'SUM' }, { value: 'AVG' }, { value: 'LAST' }, { value: 'FORMULA' }],
faisalhamdi's avatar
faisalhamdi committed
61 62 63 64
                getOptionLabel: (option) => titleCase(option.value),
            },
            kpiTypeList: [],
            maxAchList: [],
faisalhamdi's avatar
faisalhamdi committed
65
            visibleCATRO: true,
faisalhamdi's avatar
faisalhamdi committed
66 67 68 69
            buttonError: true,
            dataDelete: [],
            dataReal: [],
            buttonDraft: true,
Riri Novita's avatar
Riri Novita committed
70
            updateBy: [],
71
            handleDoubleClick: 0,
faisalhamdi's avatar
faisalhamdi committed
72
            editable: false,
faisalhamdi's avatar
faisalhamdi committed
73
            get_for: 'view',
faisalhamdi's avatar
faisalhamdi committed
74
            viewOnly: true,
Riri Novita's avatar
Riri Novita committed
75 76
            defaultCurrencyUpload: this.props.defaultCurrency,
            visibleAlertSave: false
faisalhamdi's avatar
faisalhamdi committed
77
        }
faisalhamdi's avatar
faisalhamdi committed
78
        this.fileHandler = this.fileHandler.bind(this);
faisalhamdi's avatar
faisalhamdi committed
79 80 81 82 83 84
    }

    componentDidMount() {
        this.getKPIType()
        this.getMaxAch()
        this.getLatestUpdate()
faisalhamdi's avatar
faisalhamdi committed
85 86 87 88 89 90 91 92
        this.handleViewOnly()
    }

    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
        let checkPrevRev = false
d.arizona's avatar
d.arizona committed
93
        console.log('skuy');
d.arizona's avatar
d.arizona committed
94
        // console.log(this.props.isApprover)
faisalhamdi's avatar
faisalhamdi committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }

        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
        }

        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }

        if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
            checkStatus = true
        } else {
            checkStatus = false
        }

d.arizona's avatar
d.arizona committed
119
        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
d.arizona's avatar
d.arizona committed
120
        // this.setState({ viewOnly: true })
faisalhamdi's avatar
faisalhamdi committed
121 122 123 124 125 126 127 128 129 130
    }

    getItemHierarki() {
        let payload = {
            "company_id": this.props.company.company_id,
            "get_for": this.state.get_for,
            "quartal": this.props.quarter,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
Riri Novita's avatar
Riri Novita committed
131
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145
            "rolling_outlook_id": this.props.rollingOutlookID
        }
        console.log(payload);
        api.create().getRollingOutlookCAT(payload).then(response => {
            let dataTable = []
            console.log(response)
            if (response.data) {
                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'
qorri_di's avatar
qorri_di committed
146 147
                                let weight = String(item.weight).includes('%') ? String(item.weight).substr(0, String(item.weight).length - 1) : String(item.weight)
                                let weightTB = String(item.corporate_annual_target.weight).includes('%') ? String(item.corporate_annual_target.weight).substr(0, String(item.corporate_annual_target.weight).length - 1) : String(item.corporate_annual_target.weight)
faisalhamdi's avatar
faisalhamdi committed
148 149 150 151 152 153 154
                                dataTable.push([
                                    item.type_report_id,
                                    item.id,
                                    item.parent,
                                    item.formula,
                                    item.level,
                                    item.description,
syadziy's avatar
syadziy committed
155 156
                                    // item.parent == null ? Number(weight).toFixed(1) : (item.corporate_annual_target.weight == "" ? Number(0).toFixed(1) : Number(weight).toFixed(1)),
                                    parentTrue ? weight : weightTB,
faisalhamdi's avatar
faisalhamdi committed
157
                                    parentTrue ? item.corporate_annual_target.uom : item.uom,
faisalhamdi's avatar
faisalhamdi committed
158
                                    parentTrue ? item.corporate_annual_target.kpi == "" ? null : { value: item.corporate_annual_target.kpi } : item.kpi_type == "" ? null : { value: item.kpi_type },
faisalhamdi's avatar
faisalhamdi committed
159
                                    parentTrue ? item.corporate_annual_target.max_ach == "" ? null : { value: titleCase(item.corporate_annual_target.max_ach) } : item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
faisalhamdi's avatar
faisalhamdi committed
160
                                    parentTrue ? item.corporate_annual_target.formula_ytd == "" ? null : { value: item.corporate_annual_target.formula_ytd } : item.formula_ytd == "" ? null : { value: item.formula_ytd },
faisalhamdi's avatar
faisalhamdi committed
161 162 163 164 165
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.january == "" ? item.corporate_annual_target.january : String(item.corporate_annual_target.january).indexOf(".") == -1 ? Number(item.corporate_annual_target.january) : Number(item.corporate_annual_target.january).toFixed(1)) : { value: item.corporate_annual_target.january, formula: item.corporate_annual_target.january_formula } : (item.corporate_annual_target.january == "" ? item.corporate_annual_target.january : String(item.corporate_annual_target.january).indexOf(".") == -1 ? Number(item.corporate_annual_target.january) : Number(item.corporate_annual_target.january).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.february == "" ? item.corporate_annual_target.february : String(item.corporate_annual_target.february).indexOf(".") == -1 ? Number(item.corporate_annual_target.february) : Number(item.corporate_annual_target.february).toFixed(1)) : { value: item.corporate_annual_target.february, formula: item.corporate_annual_target.february_formula } : (item.corporate_annual_target.february == "" ? item.corporate_annual_target.february : String(item.corporate_annual_target.february).indexOf(".") == -1 ? Number(item.corporate_annual_target.february) : Number(item.corporate_annual_target.february).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.march == "" ? item.corporate_annual_target.march : String(item.corporate_annual_target.march).indexOf(".") == -1 ? Number(item.corporate_annual_target.march) : Number(item.corporate_annual_target.march).toFixed(1)) : { value: item.corporate_annual_target.march, formula: item.corporate_annual_target.march_formula } : (item.corporate_annual_target.march == "" ? item.corporate_annual_target.march : String(item.corporate_annual_target.march).indexOf(".") == -1 ? Number(item.corporate_annual_target.march) : Number(item.corporate_annual_target.march).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.april == "" ? item.corporate_annual_target.april : String(item.corporate_annual_target.april).indexOf(".") == -1 ? Number(item.corporate_annual_target.april) : Number(item.corporate_annual_target.april).toFixed(1)) : { value: item.corporate_annual_target.april, formula: item.corporate_annual_target.april_formula } : (item.corporate_annual_target.april == "" ? item.corporate_annual_target.april : String(item.corporate_annual_target.april).indexOf(".") == -1 ? Number(item.corporate_annual_target.april) : Number(item.corporate_annual_target.april).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.may == "" ? item.corporate_annual_target.may : String(item.corporate_annual_target.may).indexOf(".") == -1 ? Number(item.corporate_annual_target.may) : Number(item.corporate_annual_target.may).toFixed(1)) : { value: item.corporate_annual_target.may, formula: item.corporate_annual_target.may_formula } : (item.corporate_annual_target.may == "" ? item.corporate_annual_target.may : String(item.corporate_annual_target.may).indexOf(".") == -1 ? Number(item.corporate_annual_target.may) : Number(item.corporate_annual_target.may).toFixed(1)),
faisalhamdi's avatar
faisalhamdi committed
166 167
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.june == "" ? item.corporate_annual_target.june : String(item.corporate_annual_target.june).indexOf(".") == -1 ? Number(item.corporate_annual_target.june) : Number(item.corporate_annual_target.june).toFixed(1)) : { value: item.corporate_annual_target.june, formula: item.corporate_annual_target.june_formula } : (item.corporate_annual_target.june == "" ? item.corporate_annual_target.june : String(item.corporate_annual_target.june).indexOf(".") == -1 ? Number(item.corporate_annual_target.june) : Number(item.corporate_annual_target.june).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.july == "" ? item.corporate_annual_target.july : String(item.corporate_annual_target.july).indexOf(".") == -1 ? Number(item.corporate_annual_target.july) : Number(item.corporate_annual_target.july).toFixed(1)) : { value: item.corporate_annual_target.july, formula: item.corporate_annual_target.july_formula } : (item.corporate_annual_target.july == "" ? item.corporate_annual_target.july : String(item.corporate_annual_target.july).indexOf(".") == -1 ? Number(item.corporate_annual_target.july) : Number(item.corporate_annual_target.july).toFixed(1)),
faisalhamdi's avatar
faisalhamdi committed
168 169 170 171 172 173
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.august == "" ? item.corporate_annual_target.august : String(item.corporate_annual_target.august).indexOf(".") == -1 ? Number(item.corporate_annual_target.august) : Number(item.corporate_annual_target.august).toFixed(1)) : { value: item.corporate_annual_target.august, formula: item.corporate_annual_target.august_formula } : (item.corporate_annual_target.august == "" ? item.corporate_annual_target.august : String(item.corporate_annual_target.august).indexOf(".") == -1 ? Number(item.corporate_annual_target.august) : Number(item.corporate_annual_target.august).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.september == "" ? item.corporate_annual_target.september : String(item.corporate_annual_target.september).indexOf(".") == -1 ? Number(item.corporate_annual_target.september) : Number(item.corporate_annual_target.september).toFixed(1)) : { value: item.corporate_annual_target.september, formula: item.corporate_annual_target.september_formula } : (item.corporate_annual_target.september == "" ? item.corporate_annual_target.september : String(item.corporate_annual_target.september).indexOf(".") == -1 ? Number(item.corporate_annual_target.september) : Number(item.corporate_annual_target.september).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.october == "" ? item.corporate_annual_target.october : String(item.corporate_annual_target.october).indexOf(".") == -1 ? Number(item.corporate_annual_target.october) : Number(item.corporate_annual_target.october).toFixed(1)) : { value: item.corporate_annual_target.october, formula: item.corporate_annual_target.october_formula } : (item.corporate_annual_target.october == "" ? item.corporate_annual_target.october : String(item.corporate_annual_target.october).indexOf(".") == -1 ? Number(item.corporate_annual_target.october) : Number(item.corporate_annual_target.october).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.november == "" ? item.corporate_annual_target.november : String(item.corporate_annual_target.november).indexOf(".") == -1 ? Number(item.corporate_annual_target.november) : Number(item.corporate_annual_target.november).toFixed(1)) : { value: item.corporate_annual_target.november, formula: item.corporate_annual_target.november_formula } : (item.corporate_annual_target.november == "" ? item.corporate_annual_target.november : String(item.corporate_annual_target.november).indexOf(".") == -1 ? Number(item.corporate_annual_target.november) : Number(item.corporate_annual_target.november).toFixed(1)),
                                    item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? (item.corporate_annual_target.december == "" ? item.corporate_annual_target.december : String(item.corporate_annual_target.december).indexOf(".") == -1 ? Number(item.corporate_annual_target.december) : Number(item.corporate_annual_target.december).toFixed(1)) : { value: item.corporate_annual_target.december, formula: item.corporate_annual_target.december_formula } : (item.corporate_annual_target.december == "" ? item.corporate_annual_target.december : String(item.corporate_annual_target.december).indexOf(".") == -1 ? Number(item.corporate_annual_target.december) : Number(item.corporate_annual_target.december).toFixed(1)),
                                    item.corporate_annual_target.total_current_year == "" ? "0" : String(item.corporate_annual_target.total_current_year).indexOf(".") == -1 ? Number(item.corporate_annual_target.total_current_year) : Number(item.corporate_annual_target.total_current_year).toFixed(1),
faisalhamdi's avatar
faisalhamdi committed
174 175 176 177 178 179 180 181 182 183 184 185 186 187
                                    item.corporate_annual_target.strategic,
                                    item.corporate_annual_target.pic,
                                    item.order
                                ])
                            }
                            if (item.children !== null) {
                                if (item.children.length > 0) {
                                    item.children.map((items, indexs) => {
                                        handlePushChild(items)
                                    })
                                }
                            }
                        }
                        res.map((item, index) => {
qorri_di's avatar
qorri_di committed
188
                            let weight = String(item.weight).includes('%') ? String(item.weight).substr(0, String(item.weight).length - 1) : item.weight
faisalhamdi's avatar
faisalhamdi committed
189 190 191 192 193 194 195
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
syadziy's avatar
syadziy committed
196 197
                                item.weight == '' ? Number(0).toFixed(1) : Number(Number(item.weight) * 100).toFixed(1),
                                // item.parent == null ? Number(weight * 100).toFixed(1) : (item.corporate_annual_target.weight == '' ? Number(item.weight * 100).toFixed(1) : (item.parent == null ? Number(weight * 100).toFixed(1) : Number(weight).toFixed(1))),
d.arizona's avatar
d.arizona committed
198
                                // item.corporate_annual_target.weight == "" ? Number(0).toFixed(1) : Number(Number(weight * 100)).toFixed(1),
faisalhamdi's avatar
faisalhamdi committed
199 200 201 202
                                item.corporate_annual_target.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 },
faisalhamdi's avatar
faisalhamdi committed
203 204 205 206 207
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.january, formula: item.corporate_annual_target.january_formula } : (item.corporate_annual_target.january == "" ? item.corporate_annual_target.january : String(item.corporate_annual_target.january).indexOf(".") == -1 ? Number(item.corporate_annual_target.january) : Number(item.corporate_annual_target.january).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.february, formula: item.corporate_annual_target.february_formula } : (item.corporate_annual_target.february == "" ? item.corporate_annual_target.february : String(item.corporate_annual_target.february).indexOf(".") == -1 ? Number(item.corporate_annual_target.february) : Number(item.corporate_annual_target.february).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.march, formula: item.corporate_annual_target.march_formula } : (item.corporate_annual_target.march == "" ? item.corporate_annual_target.march : String(item.corporate_annual_target.march).indexOf(".") == -1 ? Number(item.corporate_annual_target.march) : Number(item.corporate_annual_target.march).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.april, formula: item.corporate_annual_target.april_formula } : (item.corporate_annual_target.april == "" ? item.corporate_annual_target.april : String(item.corporate_annual_target.april).indexOf(".") == -1 ? Number(item.corporate_annual_target.april) : Number(item.corporate_annual_target.april).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.may, formula: item.corporate_annual_target.may_formula } : (item.corporate_annual_target.may == "" ? item.corporate_annual_target.may : String(item.corporate_annual_target.may).indexOf(".") == -1 ? Number(item.corporate_annual_target.may) : Number(item.corporate_annual_target.may).toFixed(1)),
faisalhamdi's avatar
faisalhamdi committed
208 209
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.june, formula: item.corporate_annual_target.june_formula } : (item.corporate_annual_target.june == "" ? item.corporate_annual_target.june : String(item.corporate_annual_target.june).indexOf(".") == -1 ? Number(item.corporate_annual_target.june) : Number(item.corporate_annual_target.june).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.july, formula: item.corporate_annual_target.july_formula } : (item.corporate_annual_target.july == "" ? item.corporate_annual_target.july : String(item.corporate_annual_target.july).indexOf(".") == -1 ? Number(item.corporate_annual_target.july) : Number(item.corporate_annual_target.july).toFixed(1)),
faisalhamdi's avatar
faisalhamdi committed
210 211 212 213 214 215
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.august, formula: item.corporate_annual_target.august_formula } : (item.corporate_annual_target.august == "" ? item.corporate_annual_target.august : String(item.corporate_annual_target.august).indexOf(".") == -1 ? Number(item.corporate_annual_target.august) : Number(item.corporate_annual_target.august).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.september, formula: item.corporate_annual_target.september_formula } : (item.corporate_annual_target.september == "" ? item.corporate_annual_target.september : String(item.corporate_annual_target.september).indexOf(".") == -1 ? Number(item.corporate_annual_target.september) : Number(item.corporate_annual_target.september).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.october, formula: item.corporate_annual_target.october_formula } : (item.corporate_annual_target.october == "" ? item.corporate_annual_target.october : String(item.corporate_annual_target.october).indexOf(".") == -1 ? Number(item.corporate_annual_target.october) : Number(item.corporate_annual_target.october).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.november, formula: item.corporate_annual_target.november_formula } : (item.corporate_annual_target.november == "" ? item.corporate_annual_target.november : String(item.corporate_annual_target.november).indexOf(".") == -1 ? Number(item.corporate_annual_target.november) : Number(item.corporate_annual_target.november).toFixed(1)),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? { value: item.corporate_annual_target.december, formula: item.corporate_annual_target.december_formula } : (item.corporate_annual_target.december == "" ? item.corporate_annual_target.december : String(item.corporate_annual_target.december).indexOf(".") == -1 ? Number(item.corporate_annual_target.december) : Number(item.corporate_annual_target.december).toFixed(1)),
                                item.corporate_annual_target.total_current_year == "" ? 0 : String(item.corporate_annual_target.total_current_year).indexOf(".") == -1 ? Number(item.corporate_annual_target.total_current_year) : Number(item.corporate_annual_target.total_current_year).toFixed(1),
faisalhamdi's avatar
faisalhamdi committed
216 217 218 219 220 221 222 223 224 225 226 227 228
                                item.corporate_annual_target.strategic,
                                item.corporate_annual_target.pic,
                                item.order
                            ])
                            if (item.children !== null) {
                                if (item.children.length > 0) {
                                    item.children.map((items, indexs) => {
                                        handlePushChild(items)
                                    })
                                }
                            }
                        })
                        console.log(dataTable)
faisalhamdi's avatar
faisalhamdi committed
229
                        this.setState({ dataTable, loading: false, dataReal: res, editable: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
230 231 232
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
233
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    };
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
                }
            } else {
                this.setState({ alert: true, messageAlert: 'Connection Timeout, please check your Connection', tipeAlert: 'error', loading: false })
            }


        })
    }

faisalhamdi's avatar
faisalhamdi committed
252
    handleGetFor(type) {
faisalhamdi's avatar
faisalhamdi committed
253
        this.setState({ get_for: type }, () => {
faisalhamdi's avatar
faisalhamdi committed
254
            this.getLatestUpdate()
faisalhamdi's avatar
faisalhamdi committed
255 256 257 258
            this.getItemHierarki()
        })
    }

faisalhamdi's avatar
faisalhamdi committed
259 260 261 262 263 264 265
    getKPIType() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'KPI_TYPE'
        }
        api.create().getAllSettingByType(body).then(response => {
faisalhamdi's avatar
faisalhamdi committed
266
            // console.log(response)
faisalhamdi's avatar
faisalhamdi committed
267 268 269 270
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
faisalhamdi's avatar
faisalhamdi committed
271
                        // console.log(data)
faisalhamdi's avatar
faisalhamdi committed
272 273 274 275 276 277 278 279 280 281 282
                        let inputKPI = []

                        data.map((item) => {
                            inputKPI.push({
                                value: item.value
                            })
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
faisalhamdi's avatar
faisalhamdi committed
283
                        // console.log(defaultProps)
faisalhamdi's avatar
faisalhamdi committed
284 285 286
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
287
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
                                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),
                        };
                        this.setState({ maxAchList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
327
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
                                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' })
            }
            this.getItemHierarki()
        })
    }

faisalhamdi's avatar
faisalhamdi committed
346 347
    downloadTemplate = async () => {
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
348
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/rolling_outlook/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&quartal=${this.props.quarter}&&currency_id=${this.props.defaultCurrency.id}`
faisalhamdi's avatar
faisalhamdi committed
349 350 351 352 353 354
        )
        res = await res.blob()
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
faisalhamdi's avatar
faisalhamdi committed
355
            a.download = 'Template ROLLING OUTLOOK & CAT REVISION - Corporate Annual Target.xlsx';
faisalhamdi's avatar
faisalhamdi committed
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
            a.click();
        }
    }

    async downloadAllData() {
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/rolling_outlook/export_rolling_outlook?rolling_outlook_id=${this.props.rollingOutlookID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&quartal=${this.props.quarter}`
        console.log(url);
        let res = await fetch(
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/rolling_outlook/export_rolling_outlook?rolling_outlook_id=${this.props.rollingOutlookID === null ? "" : this.props.rollingOutlookID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&quartal=${this.props.quarter}`
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
faisalhamdi's avatar
faisalhamdi committed
372
            a.download = 'ROLLING OUTLOOK & CAT REVISION - Corporate Annual Target.xlsx';
faisalhamdi's avatar
faisalhamdi committed
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
            a.click();
        }
    }

    backToRollingOutlook(type) {
        let data = []
        let stateFR = false
        console.log(this.state.dataTable)
        this.state.dataTable.map(i => {
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
                // console.log(indexID)
                // console.log(i[2])
                if (indexID !== -1) {
                    // console.log(dataTableBaru[indexID][6])
                    if (this.state.dataTable[indexID][5] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
            } else {
                stateFR = false
            }
            // console.log(i[9] == null? "" : i[9].value)
            data.push({
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
                "item_name": String(i[5]),
                "parent": i[2] == "" ? null : i[2],
                "weight": String(i[6]),
                "uom": String(i[7]),
                "kpi_type": i[8] == null ? "" : i[8].value,
                "max_ach": i[9] == null ? "" : i[9].value,
d.arizona's avatar
d.arizona committed
406
                "formula_ytd": i[10] == null ? "" : i[10].value,
Deni Rinaldi's avatar
Deni Rinaldi committed
407 408 409 410 411 412 413 414 415 416 417 418 419
                "january": stateFR ? i[0] == 3 ? String(i[11]) : String(Number(i[11].value).toFixed(1)) : String(i[11]),
                "february": stateFR ? i[0] == 3 ? String(i[12]) : String(Number(i[12].value).toFixed(1)) : String(i[12]),
                "march": stateFR ? i[0] == 3 ? String(i[13]) : String(Number(i[13].value).toFixed(1)) : String(i[13]),
                "april": stateFR ? i[0] == 3 ? String(i[14]) : String(Number(i[14].value).toFixed(1)) : String(i[14]),
                "may": stateFR ? i[0] == 3 ? String(i[15]) : String(Number(i[15].value).toFixed(1)) : String(i[15]),
                "june": stateFR ? i[0] == 3 ? String(i[16]) : String(Number(i[16].value).toFixed(1)) : String(i[16]),
                "july": stateFR ? i[0] == 3 ? String(i[17]) : String(Number(i[17].value).toFixed(1)) : String(i[17]),
                "august": stateFR ? i[0] == 3 ? String(i[18]) : String(Number(i[18].value).toFixed(1)) : String(i[18]),
                "september": stateFR ? i[0] == 3 ? String(i[19]) : String(Number(i[19].value).toFixed(1)) : String(i[19]),
                "october": stateFR ? i[0] == 3 ? String(i[20]) : String(Number(i[20].value).toFixed(1)) : String(i[20]),
                "november": stateFR ? i[0] == 3 ? String(i[21]) : String(Number(i[21].value).toFixed(1)) : String(i[21]),
                "december": stateFR ? i[0] == 3 ? String(i[22]) : String(Number(i[22].value).toFixed(1)) : String(i[22]),
                "current_year_total": String(Number(i[23]).toFixed(1)) == "" ? "0.0" : String(Number(i[23]).toFixed(1)),
faisalhamdi's avatar
faisalhamdi committed
420
                "strategic_initiative": String(i[24]),
faisalhamdi's avatar
faisalhamdi committed
421 422 423 424 425 426 427 428 429 430
                "pic": String(i[25])
            })
        })
        // console.log(JSON.stringify(data))
        let payload = {
            "rolling_outlook_id": this.props.rollingOutlookID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "quartal": this.props.quarter,
Riri Novita's avatar
Riri Novita committed
431
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
432 433 434
            "status": type,
            "cat": data
        }
faisalhamdi's avatar
faisalhamdi committed
435
        // console.log(JSON.stringify(payload));
faisalhamdi's avatar
faisalhamdi committed
436 437 438 439 440 441
        api.create('UPLOAD').createRollingOutlookCAT(payload).then(response => {
            console.log(payload);
            console.log(response);
            // console.log(JSON.stringify(payload))
            if (response.data) {
                if (response.data.status === "success") {
faisalhamdi's avatar
faisalhamdi committed
442 443
                    this.props.onClickClose()
                    this.props.refresh()
faisalhamdi's avatar
faisalhamdi committed
444
                } else {
Riri Novita's avatar
Riri Novita committed
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
                    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, handleDoubleClick: 0 }, () => {
                            document.body.style.overflow = 'unset';
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                            // this.props.onClickClose()
                            this.props.refresh()
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
460
                }
Riri Novita's avatar
Riri Novita committed
461
                // else {
462
                //     this.setState({ loading: false, handleDoubleClick: 0 }, () => {
Riri Novita's avatar
Riri Novita committed
463 464 465 466
                //         this.props.onClickClose()
                //         this.props.refresh()
                //     })
                // }
faisalhamdi's avatar
faisalhamdi committed
467
            } else {
468
                this.setState({ loading: false, handleDoubleClick: 0 })
faisalhamdi's avatar
faisalhamdi committed
469 470 471 472 473 474 475
            }
        })
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
faisalhamdi's avatar
faisalhamdi committed
476
            // console.log(resp)
faisalhamdi's avatar
faisalhamdi committed
477
            if (err) {
faisalhamdi's avatar
faisalhamdi committed
478
                // console.log(err);
faisalhamdi's avatar
faisalhamdi committed
479 480 481
            }
            else {
                let isi = resp.rows.slice(3)
faisalhamdi's avatar
faisalhamdi committed
482
                // console.log(isi);
faisalhamdi's avatar
faisalhamdi committed
483 484 485 486
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
faisalhamdi's avatar
faisalhamdi committed
487 488 489
                        payload.push({
                            item_report_id: i[1] === undefined ? 0 : reg.test(String(i[1])) === false ? 0 : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
faisalhamdi's avatar
faisalhamdi committed
490
                            weight: i[3] === undefined ? "" : String(i[3]).trim(),
faisalhamdi's avatar
faisalhamdi committed
491 492 493
                            uom: i[4] === undefined ? "" : String(i[4]).trim(),
                            kpi_type: i[5] === undefined ? "" : String(i[5]).trim(),
                            max_ach: i[6] === undefined ? "" : String(i[6]).toLocaleLowerCase() !== 'unlimited' ? (String(i[6]).includes('%') ? String(i[6].trim()) : String(Number(i[6] * 100) + '%')) : String(i[6]).trim(),
syadziy's avatar
syadziy committed
494 495 496 497 498 499 500 501 502 503 504 505
                            january: i[7] === undefined ? "0.0" : reg.test(String(i[7])) === false ? "0.0" : String(roundMath(Number(i[7]), 1)).trim(),
                            february: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(roundMath(Number(i[8]), 1)).trim(),
                            march: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(roundMath(Number(i[9]), 1)).trim(),
                            april: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(roundMath(Number(i[10]), 1)).trim(),
                            may: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(roundMath(Number(i[11]), 1)).trim(),
                            june: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(roundMath(Number(i[12]), 1)).trim(),
                            july: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(roundMath(Number(i[13]), 1)).trim(),
                            august: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(roundMath(Number(i[14]), 1)).trim(),
                            september: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(roundMath(Number(i[15]), 1)).trim(),
                            october: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(roundMath(Number(i[16]), 1)).trim(),
                            november: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(roundMath(Number(i[17]), 1)).trim(),
                            december: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(roundMath(Number(i[18]), 1)).trim(),
faisalhamdi's avatar
faisalhamdi committed
506
                            strategic_initiative: i[20] === undefined ? "" : String(i[20]).trim(),
faisalhamdi's avatar
faisalhamdi committed
507 508
                            pic: i[21] === undefined ? "" : String(i[21]).trim()
                        })
faisalhamdi's avatar
faisalhamdi committed
509 510
                    }
                })
faisalhamdi's avatar
faisalhamdi committed
511
                // console.log(payload)
faisalhamdi's avatar
faisalhamdi committed
512 513 514 515 516
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    cat: payload,
faisalhamdi's avatar
faisalhamdi committed
517 518
                    rolling_outlook_id: this.props.rollingOutlookID,
                    quartal: this.props.quarter,
faisalhamdi's avatar
faisalhamdi committed
519 520
                    status: 'submitted'
                }
faisalhamdi's avatar
faisalhamdi committed
521 522
                console.log(body)
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
faisalhamdi's avatar
faisalhamdi committed
523 524 525 526 527 528
            }
        });
    }

    checkUpload() {
        this.setState({ loading: true, dataTable: [] })
Riri Novita's avatar
Riri Novita committed
529 530 531 532 533
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        api.create().checkImportRollingOutlookCAT(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
534 535
            // console.log(JSON.stringify(this.state.payload));
            console.log(response)
faisalhamdi's avatar
faisalhamdi committed
536 537 538
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
faisalhamdi's avatar
faisalhamdi committed
539
                        this.setState({ visibleUpload: false, visibleCATRO: false })
faisalhamdi's avatar
faisalhamdi committed
540 541 542 543 544 545 546
                        let dataTable = []
                        response.data.data.map((item, index) => {
                            dataTable.push([
                                item.type_report_id,
                                item.item_report_id,
                                item.parent,
                                item.formula,
faisalhamdi's avatar
faisalhamdi committed
547
                                item.level,
faisalhamdi's avatar
faisalhamdi committed
548
                                item.item_report,
d.arizona's avatar
d.arizona committed
549
                                Number(String(item.weight).substr(0, String(item.weight).length - 1)),
faisalhamdi's avatar
faisalhamdi committed
550
                                item.uom,
faisalhamdi's avatar
faisalhamdi committed
551
                                item.kpi == "" || item.kpi == null ? null : { value: item.kpi },
faisalhamdi's avatar
faisalhamdi committed
552
                                item.max_ach == "" || item.max_ach == null ? null : { value: titleCase(item.max_ach) },
faisalhamdi's avatar
faisalhamdi committed
553
                                item.formula_ytd == "" || item.formula_ytd == null ? null : { value: item.formula_ytd },
Deni Rinaldi's avatar
Deni Rinaldi committed
554 555 556 557 558 559 560 561 562 563 564 565
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.january).toFixed(1) : { value: item.january, formula: item.january_formula } : item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.february).toFixed(1) : { value: item.february, formula: item.february_formula } : item.february == "" ? item.february : String(item.february).indexOf(".") == -1 ? Number(item.february) : Number(item.february).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.march).toFixed(1) : { value: item.march, formula: item.march_formula } : item.march == "" ? item.march : String(item.march).indexOf(".") == -1 ? Number(item.march) : Number(item.march).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.april).toFixed(1) : { value: item.april, formula: item.april_formula } : item.april == "" ? item.april : String(item.april).indexOf(".") == -1 ? Number(item.april) : Number(item.april).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.may).toFixed(1) : { value: item.may, formula: item.may_formula } : item.may == "" ? item.may : String(item.may).indexOf(".") == -1 ? Number(item.may) : Number(item.may).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.june).toFixed(1) : { value: item.june, formula: item.june_formula } : item.june == "" ? item.june : String(item.june).indexOf(".") == -1 ? Number(item.june) : Number(item.june).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.july).toFixed(1) : { value: item.july, formula: item.july_formula } : item.july == "" ? item.july : String(item.july).indexOf(".") == -1 ? Number(item.july) : Number(item.july).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.august).toFixed(1) : { value: item.august, formula: item.august_formula } : item.august == "" ? item.august : String(item.august).indexOf(".") == -1 ? Number(item.august) : Number(item.august).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.september).toFixed(1) : { value: item.september, formula: item.september_formula } : item.september == "" ? item.september : String(item.september).indexOf(".") == -1 ? Number(item.september) : Number(item.september).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.october).toFixed(1) : { value: item.october, formula: item.october_formula } : item.october == "" ? item.october : String(item.october).indexOf(".") == -1 ? Number(item.october) : Number(item.october).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.november).toFixed(1) : { value: item.november, formula: item.november_formula } : item.november == "" ? item.november : String(item.november).indexOf(".") == -1 ? Number(item.november) : Number(item.november).toFixed(1),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.december).toFixed(1) : { value: item.december, formula: item.december_formula } : item.december == "" ? item.december : String(item.december).indexOf(".") == -1 ? Number(item.december) : Number(item.december).toFixed(1),
faisalhamdi's avatar
faisalhamdi committed
566 567
                                item.current_year_total == "" ? item.current_year_total : String(item.current_year_total).indexOf(".") == -1 ? Number(item.current_year_total) : Number(item.total_current_year).toFixed(1),
                                item.strategic_initiative,
faisalhamdi's avatar
faisalhamdi committed
568 569 570 571 572
                                item.pic,
                                item.order,
                                item.error
                            ])
                        })
faisalhamdi's avatar
faisalhamdi committed
573
                        // console.log(this.state.buttonError)
faisalhamdi's avatar
faisalhamdi committed
574
                        console.log(dataTable)
faisalhamdi's avatar
faisalhamdi committed
575
                        this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
576
                            this.state.dataTable.map(item => {
faisalhamdi's avatar
faisalhamdi committed
577
                                if (item[27].length > 0) {
faisalhamdi's avatar
faisalhamdi committed
578
                                    console.log('masuk')
faisalhamdi's avatar
faisalhamdi committed
579 580 581
                                    this.setState({ buttonError: true, errorPreview: true, editable: true })
                                }
                            })
faisalhamdi's avatar
faisalhamdi committed
582
                            // console.log(this.state.dataTable);
faisalhamdi's avatar
faisalhamdi committed
583 584 585
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
586
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
603 604 605 606 607 608 609 610
    uploadCATRO(type) {
        let data = []
        let stateFR = false
        console.log(this.state.dataTable)
        this.state.dataTable.map(i => {
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
                if (indexID !== -1) {
faisalhamdi's avatar
faisalhamdi committed
611
                    if (this.state.dataTable[indexID][5] === 'FINANCIAL PERSPECTIVE') {
faisalhamdi's avatar
faisalhamdi committed
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
            } else {
                stateFR = false
            }

            data.push({
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
                "item_report": String(i[5]),
                "weight": String(i[6]),
                "uom": String(i[7]),
                "kpi_type": i[8] == null ? "" : i[8].value,
                "max_ach": i[9] == null ? "" : i[9].value,
d.arizona's avatar
d.arizona committed
628
                "formula_ytd": i[10] == null ? "" : i[10].value,
Deni Rinaldi's avatar
Deni Rinaldi committed
629 630 631 632 633 634 635 636 637 638 639 640
                "january": stateFR ? i[0] == 3 ? String(i[11]) : String(Number(i[11].value).toFixed(1)) : String(i[11]),
                "february": stateFR ? i[0] == 3 ? String(i[12]) : String(Number(i[12].value).toFixed(1)) : String(i[12]),
                "march": stateFR ? i[0] == 3 ? String(i[13]) : String(Number(i[13].value).toFixed(1)) : String(i[13]),
                "april": stateFR ? i[0] == 3 ? String(i[14]) : String(Number(i[14].value).toFixed(1)) : String(i[14]),
                "may": stateFR ? i[0] == 3 ? String(i[15]) : String(Number(i[15].value).toFixed(1)) : String(i[15]),
                "june": stateFR ? i[0] == 3 ? String(i[16]) : String(Number(i[16].value).toFixed(1)) : String(i[16]),
                "july": stateFR ? i[0] == 3 ? String(i[17]) : String(Number(i[17].value).toFixed(1)) : String(i[17]),
                "august": stateFR ? i[0] == 3 ? String(i[18]) : String(Number(i[18].value).toFixed(1)) : String(i[18]),
                "september": stateFR ? i[0] == 3 ? String(i[19]) : String(Number(i[19].value).toFixed(1)) : String(i[19]),
                "october": stateFR ? i[0] == 3 ? String(i[20]) : String(Number(i[20].value).toFixed(1)) : String(i[20]),
                "november": stateFR ? i[0] == 3 ? String(i[21]) : String(Number(i[21].value).toFixed(1)) : String(i[21]),
                "december": stateFR ? i[0] == 3 ? String(i[22]) : String(Number(i[22].value).toFixed(1)) : String(i[22]),
d.arizona's avatar
d.arizona committed
641
                "current_year_total": String(Number(i[23]).toFixed(1)) == "" ? "0.0" : String(Number(i[23]).toFixed(1)),
faisalhamdi's avatar
faisalhamdi committed
642 643
                "strategic": String(i[24]),
                "pic": String(i[25])
faisalhamdi's avatar
faisalhamdi committed
644
            })
faisalhamdi's avatar
faisalhamdi committed
645 646 647 648 649 650 651
        })
        let payload = {
            "rolling_outlook_id": this.props.rollingOutlookID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "quartal": this.props.quarter,
Riri Novita's avatar
Riri Novita committed
652
            "currency_id": this.state.defaultCurrencyUpload?.id,
faisalhamdi's avatar
faisalhamdi committed
653 654
            "status": type,
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
655
        }
faisalhamdi's avatar
faisalhamdi committed
656 657 658 659 660 661 662 663 664
        // console.log(data);
        // console.log(JSON.stringify(body))
        api.create('UPLOAD').importRollingOutlookCAT(payload).then(response => {
            console.log(payload);
            console.log(response);
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === "success") {
                        this.props.onClickClose()
faisalhamdi's avatar
faisalhamdi committed
665
                        this.props.refresh()
faisalhamdi's avatar
faisalhamdi committed
666
                    } else {
Riri Novita's avatar
Riri Novita committed
667 668 669 670 671 672 673 674 675 676 677 678
                        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, handleDoubleClick: 0 }, () => {
                                if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                    setTimeout(() => {
                                        localStorage.removeItem(Constant.TOKEN)
                                        window.location.reload();
                                    }, 1000);
                                }
                            })
                        }
faisalhamdi's avatar
faisalhamdi committed
679 680
                    }
                } else {
681
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
faisalhamdi's avatar
faisalhamdi committed
682 683
                }
            } else {
684
                this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
faisalhamdi's avatar
faisalhamdi committed
685 686
            }
        })
faisalhamdi's avatar
faisalhamdi committed
687 688 689
    }

    handleValidate() {
faisalhamdi's avatar
faisalhamdi committed
690
        this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false })
faisalhamdi's avatar
faisalhamdi committed
691 692
    }

faisalhamdi's avatar
faisalhamdi committed
693 694 695 696 697 698
    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,
faisalhamdi's avatar
faisalhamdi committed
699 700
            "rolling_outlook_id": this.props.rollingOutlookID,
            "quartal": this.props.quarter
faisalhamdi's avatar
faisalhamdi committed
701
        }
faisalhamdi's avatar
faisalhamdi committed
702 703
        api.create().getRollingOutlookLastUpdate(payload).then(response => {
            // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
704 705 706
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
707
                        updateBy: response.data.data.detail === null ? '-' : response.data.data.detail,
faisalhamdi's avatar
faisalhamdi committed
708 709 710 711
                        notes: response.data.data.notes_update === null ? "" : response.data.data.notes_update
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
712
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
713 714 715 716 717
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
faisalhamdi's avatar
faisalhamdi committed
718 719
                    })
                }
faisalhamdi's avatar
faisalhamdi committed
720 721
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
722 723 724 725
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
726 727 728 729
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
730
    render() {
faisalhamdi's avatar
faisalhamdi committed
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
        let dataTable2 = this.state.dataTable
        const handleChange = (value, tableMeta) => {
            let val = String(value).split(",").join("")
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
        }

        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
756

faisalhamdi's avatar
faisalhamdi committed
757 758 759 760 761 762 763 764
            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')) {
faisalhamdi's avatar
faisalhamdi committed
765
                    let columnStart = 13
faisalhamdi's avatar
faisalhamdi committed
766 767
                    let indexX = String(item).indexOf('[')
                    let formulaAwal = String(item).substr(0, indexX)
faisalhamdi's avatar
faisalhamdi committed
768
                    let columnEnd = 24
faisalhamdi's avatar
faisalhamdi committed
769 770
                    let month = column - 1
                    let total = 0
faisalhamdi's avatar
faisalhamdi committed
771 772 773 774 775 776 777 778 779 780 781 782
                    // // // console.log(formulaAwal)
                    if (forecast == undefined) {
                        dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
                            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 {
faisalhamdi's avatar
faisalhamdi committed
783

faisalhamdi's avatar
faisalhamdi committed
784
                    }
faisalhamdi's avatar
faisalhamdi committed
785 786 787 788 789 790 791 792
                    anjay.push(String(total))
                } else if (item.includes('[CM]AVG')) {
                    if (forecast == undefined) {
                        anjay.push('/')
                        anjay.push(column)
                    }
                } else if (item.includes('X')) {
                    let indexX = String(item).indexOf('X')
faisalhamdi's avatar
faisalhamdi committed
793
                    // console.log(item)
faisalhamdi's avatar
faisalhamdi committed
794 795 796 797 798 799 800
                    if (indexX == 0) {
                        anjay.push(String(item).substr(1, String(item).length))
                    } else {
                        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)

Deni Rinaldi's avatar
Deni Rinaldi committed
801 802
                        if (forecast == undefined) {
                            let convertID = -1
Riri Novita's avatar
Riri Novita committed
803
                            if (tableMeta.rowData[10]?.value == 'FORMULA') {
faisalhamdi's avatar
faisalhamdi committed
804 805 806 807 808
                                // 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
                                // anjay.push(valuezz == "" ? 0 : valuezz)
faisalhamdi's avatar
faisalhamdi committed
809 810 811 812 813 814
                            } 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)
                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
815
                            }
faisalhamdi's avatar
faisalhamdi committed
816 817 818 819 820 821 822 823 824
                        } else {
                            // // // console.log(dataTable2[tableMeta.rowIndex][30])
                            let array = dataTable2[tableMeta.rowIndex][30].filter((val) => val.periode == Number(column))
                            let valuezz = array[0].value
                            // // // console.log(valuezz)
                            anjay.push(valuezz == "" ? 0 : valuezz)
                            // let indexID = dataTable2[tableMeta.rowIndex][30].findIndex((val) => val.periode == Number(this.props.periode))
                            // if (indexID !== -1) {
                            //     let valuezz = value.formula[indexID].value
Deni Rinaldi's avatar
Deni Rinaldi committed
825
                            //     anjay.push(valuezz == "" ? 0 : valuezz)
faisalhamdi's avatar
faisalhamdi committed
826
                            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
827
                        }
faisalhamdi's avatar
faisalhamdi committed
828 829 830 831 832 833

                        anjay.push(operatorX)
                        anjay.push(nilaiX)
                    }
                } else {
                    if (String(item).includes('#')) {
faisalhamdi's avatar
faisalhamdi committed
834 835 836 837 838 839 840 841
                        // console.log(item)
                        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
                                anjay.push(valuezz == "" || valuezz == null ? "0" : valuezz)
                            }
                        }
faisalhamdi's avatar
faisalhamdi committed
842 843

                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
844
                        let convertID = -1
syadziy's avatar
syadziy committed
845
                        if (tableMeta.rowData[10].value == 'FORMULA') {
Deni Rinaldi's avatar
Deni Rinaldi committed
846
                            let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
syadziy's avatar
syadziy committed
847
                            convertID = dataTable2[indexIDReport][26]
faisalhamdi's avatar
faisalhamdi committed
848
                        }
syadziy's avatar
syadziy committed
849
                        let indexID = dataTable2.findIndex((val) => val[26] == (convertID == -1 ? item : convertID))
faisalhamdi's avatar
faisalhamdi committed
850 851
                        if (indexID !== -1) {
                            let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
syadziy's avatar
syadziy committed
852
                            if (item == dataTable2[tableMeta.rowIndex][26]) {
faisalhamdi's avatar
faisalhamdi committed
853
                                anjay.push(0)
Deni Rinaldi's avatar
Deni Rinaldi committed
854
                            } else {
faisalhamdi's avatar
faisalhamdi committed
855 856 857 858 859
                                anjay.push(valuezz == "" ? "0" : valuezz)
                            }
                        } else {
                            if (item === '(-1)') {
                                anjay.push(-1)
faisalhamdi's avatar
faisalhamdi committed
860 861 862 863 864
                            }
                        }
                    }
                }
            })
faisalhamdi's avatar
faisalhamdi committed
865
            // if (tableMeta.rowData[11].value == 'FORMULA') {
qorri_di's avatar
qorri_di committed
866 867
            // console.log(anjay)
            // console.log(column)
faisalhamdi's avatar
faisalhamdi committed
868 869

            // }
faisalhamdi's avatar
faisalhamdi committed
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 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 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988

            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) {
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
                    // }
                } 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)
                        }
                    }
                }
            })

faisalhamdi's avatar
faisalhamdi committed
989 990 991 992 993 994 995 996
            total = R.equals(total, NaN) ? "0.0" : total
            // if (dataTable2[tableMeta.rowIndex][6] == "ROIC") {
            //     if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
            //         dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = "0"
            //     } else {
            //         dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = "0"
            //     }
            // } else {
faisalhamdi's avatar
faisalhamdi committed
997 998
            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
faisalhamdi's avatar
faisalhamdi committed
999
            } else {
faisalhamdi's avatar
faisalhamdi committed
1000
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
faisalhamdi's avatar
faisalhamdi committed
1001
            }
faisalhamdi's avatar
faisalhamdi committed
1002
            // }
faisalhamdi's avatar
faisalhamdi committed
1003 1004 1005 1006

            return total
        }

faisalhamdi's avatar
faisalhamdi committed
1007 1008 1009
        // const handleValueForecast = (value, tableMeta, periode) => {
        //     return handleValueFormula(value, tableMeta, periode, periode, 'forecast')
        // }
faisalhamdi's avatar
faisalhamdi committed
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 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 1085 1086 1087 1088 1089
        const handleChangeDropdown = (value, tableMeta) => {
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
            let valz = value.value
            let total = 0
            let lastValz = 0
            if (valz == 'SUM' || valz == 'AVG' || valz == 'LAST') {
                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)
                        }
                    }
                })
                dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
            }
        }
        const handleValueDropdown = (value, type, tableMeta) => {
            let data = type == 'KPI' ? this.state.kpiTypeList.options : (type == 'MAX' ? this.state.maxAchList.options : this.state.formulaYtdList.options)
            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
            }
        }

        const handleChangePercentage = (value, tableMeta) => {
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value

        }

        const handleChangeText = (value, tableMeta) => {
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
        }

        const handleAction = (idParent, typeReport, tableMeta) => {
            if (this.props.isApprover) {
                return false
            } else {
                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
                        }
                    } else {
                        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
                        }
                    }
                } else {
                    return false
                }
            }

        }

        const handleReturnFormula = (idParent, tableMeta) => {
            if (idParent !== null) {
                let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
faisalhamdi's avatar
faisalhamdi committed
1090 1091
                // console.log(indexsss);
                if (dataTable2[indexsss][5] == 'FINANCIAL PERSPECTIVE') {
faisalhamdi's avatar
faisalhamdi committed
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
                    if (tableMeta.rowData[0] == 3) {
                        return false
                    } else {
                        return true
                    }
                } else {
                    return false
                }
            } else {
                return false
            }
        }

        const handleTotal = (tableMeta, type) => {
            // let val = String(value).split(",").join("")
            let total = 0
            let lastValz = 0
faisalhamdi's avatar
faisalhamdi committed
1109 1110 1111 1112 1113 1114
            let valItem = 0
            dataTable2[tableMeta.rowIndex].map((item, index) => {
                if (index >= 11 && index <= 22) {
                    // console.log(item.value);
                    if (item.value !== undefined) {
                        valItem = item.value == "" ? 0 : item.value
faisalhamdi's avatar
faisalhamdi committed
1115
                        total += Number(valItem)
faisalhamdi's avatar
faisalhamdi committed
1116
                        if (index == 22) {
faisalhamdi's avatar
faisalhamdi committed
1117 1118
                            lastValz += Number(valItem)
                        }
faisalhamdi's avatar
faisalhamdi committed
1119 1120
                    } else {
                        valItem = item == undefined || item == "" ? 0 : item
faisalhamdi's avatar
faisalhamdi committed
1121
                        total += Number(valItem)
faisalhamdi's avatar
faisalhamdi committed
1122
                        if (index == 22) {
faisalhamdi's avatar
faisalhamdi committed
1123 1124 1125
                            lastValz += Number(valItem)
                        }
                    }
faisalhamdi's avatar
faisalhamdi committed
1126
                }
faisalhamdi's avatar
faisalhamdi committed
1127 1128 1129 1130 1131
            })
            let valz = dataTable2[tableMeta.rowIndex][10] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][10].value
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
            return (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
            // }
faisalhamdi's avatar
faisalhamdi committed
1132
        }
faisalhamdi's avatar
faisalhamdi committed
1133

faisalhamdi's avatar
faisalhamdi committed
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
        const columns = [{
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1160 1161 1162
            name: "Key Performance Indicator",
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1163
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8' }}>
faisalhamdi's avatar
faisalhamdi committed
1164 1165 1166 1167 1168 1169
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style }),
                customBodyRender: (val, tableMeta) => {
                    return (
faisalhamdi's avatar
faisalhamdi committed
1170 1171 1172 1173 1174 1175 1176 1177
                        <div style={{ width: 300 }}>
                            {tableMeta.rowData[32] ?
                                tableMeta.rowData[32].length > 0 ?
                                    <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>
faisalhamdi's avatar
faisalhamdi committed
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189
                                    :
                                    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>
faisalhamdi's avatar
faisalhamdi committed
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203
                                :
                                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>
                            }
                        </div>
faisalhamdi's avatar
faisalhamdi committed
1204 1205 1206 1207
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1208
            name: "Weight",
faisalhamdi's avatar
faisalhamdi committed
1209 1210
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1211
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1212 1213 1214 1215 1216 1217
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
faisalhamdi's avatar
faisalhamdi committed
1218
                        <div style={{ textAlign: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
1219 1220
                            {tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
faisalhamdi's avatar
faisalhamdi committed
1221 1222 1223 1224 1225 1226 1227
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1228
                                                suffix={"%"}
faisalhamdi's avatar
faisalhamdi committed
1229
                                                style={{ color: 'black', fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
faisalhamdi's avatar
faisalhamdi committed
1230 1231
                                                type="text"
                                                placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1232
                                                value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1233
                                                disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1234
                                                decimalScale={1}
faisalhamdi's avatar
faisalhamdi committed
1235 1236 1237 1238
                                            />
                                        }
                                    />
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1239
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1240
                        </div>
faisalhamdi's avatar
faisalhamdi committed
1241 1242 1243 1244
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1245
            name: "UOM",
faisalhamdi's avatar
faisalhamdi committed
1246 1247
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1248
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1249 1250 1251 1252 1253
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
faisalhamdi's avatar
faisalhamdi committed
1254
                        <div style={{ textAlign: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
1255 1256 1257
                            <div style={{ textAlign: 'center', width: 60 }}>
                                {value}
                            </div>
faisalhamdi's avatar
faisalhamdi committed
1258 1259 1260 1261 1262
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1263
            name: "KPI Type",
faisalhamdi's avatar
faisalhamdi committed
1264 1265
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1266
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1267 1268 1269
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1270
                customBodyRender: (val, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1271
                    return (
faisalhamdi's avatar
faisalhamdi committed
1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291
                        <div style={{ width: 96 }}>
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
                                <Autocomplete
                                    {...this.state.kpiTypeList}
                                    id="kpiType"
                                    onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
                                    debug
                                    disableClearable
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
                                    value={handleValueDropdown(val, 'KPI', tableMeta)}
                                    style={{ padding: 0, margin: 0 }}
                                    renderInput={(params) =>
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
                                            <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} />
                                        </div>
                                    }
                                />
                            }

faisalhamdi's avatar
faisalhamdi committed
1292 1293 1294 1295 1296
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1297
            name: "Max Ach.",
faisalhamdi's avatar
faisalhamdi committed
1298 1299
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1300
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1301 1302 1303
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1304
                customBodyRender: (val, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1305
                    return (
faisalhamdi's avatar
faisalhamdi committed
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322
                        <div style={{ width: 96 }}>
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
                                <Autocomplete
                                    {...this.state.maxAchList}
                                    id="maxAchList"
                                    onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
                                    debug
                                    disableClearable
                                    value={handleValueDropdown(val, 'MAX', tableMeta)}
                                    style={{ padding: 0, margin: 0 }}
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
                                    renderInput={(params) =>
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
                                            <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} />
                                        </div>
                                    }
qorri_di's avatar
qorri_di committed
1323
                                // value={this.state.parent}
faisalhamdi's avatar
faisalhamdi committed
1324 1325
                                />
                            }
faisalhamdi's avatar
faisalhamdi committed
1326 1327 1328 1329 1330
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1331
            name: "Formula YTD",
faisalhamdi's avatar
faisalhamdi committed
1332 1333
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1334
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1335 1336 1337
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1338
                customBodyRender: (val, tableMeta, updateValue) => {
faisalhamdi's avatar
faisalhamdi committed
1339
                    return (
faisalhamdi's avatar
faisalhamdi committed
1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360
                        <div style={{ width: 96 }}>
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
                                <Autocomplete
                                    {...this.state.formulaYtdList}
                                    id="formulaYtdList"
                                    onChange={(event, newInputValue) => {
                                        // updateValue(newInputValue)
                                        handleChangeDropdown(newInputValue, tableMeta)
                                    }
                                    }
                                    debug
                                    disableClearable
                                    value={handleValueDropdown(val, 'FORMULA', tableMeta)}
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
                                    style={{ padding: 0, margin: 0 }}
                                    renderInput={(params) =>
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
                                            <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} />
                                        </div>
                                    }
qorri_di's avatar
qorri_di committed
1361
                                // value={this.state.parent}
faisalhamdi's avatar
faisalhamdi committed
1362 1363
                                />
                            }
faisalhamdi's avatar
faisalhamdi committed
1364 1365 1366 1367 1368
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1369
            name: `Jan ${this.props.periode} Actual`,
faisalhamdi's avatar
faisalhamdi committed
1370 1371
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1372
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1373 1374 1375
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1376
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1377
                    // console.log(tableMeta.rowData[0])
faisalhamdi's avatar
faisalhamdi committed
1378
                    return (
faisalhamdi's avatar
faisalhamdi committed
1379 1380
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
1381 1382
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
faisalhamdi's avatar
faisalhamdi committed
1383 1384 1385 1386 1387 1388 1389 1390
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1391
                            }
faisalhamdi's avatar
faisalhamdi committed
1392 1393 1394 1395 1396
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1397
            name: `Feb ${this.props.periode} Actual`,
faisalhamdi's avatar
faisalhamdi committed
1398 1399
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1400
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1401 1402 1403 1404 1405 1406 1407 1408 1409
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
                    return (
                        <div style={{ width: 96 }}>
                            {
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
faisalhamdi's avatar
faisalhamdi committed
1410 1411 1412 1413 1414 1415 1416 1417
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1418
                            }
faisalhamdi's avatar
faisalhamdi committed
1419 1420 1421 1422 1423
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1424
            name: `Mar ${this.props.periode} Actual`,
faisalhamdi's avatar
faisalhamdi committed
1425 1426
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1427
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1428 1429 1430
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1431
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1432
                    return (
faisalhamdi's avatar
faisalhamdi committed
1433 1434
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
1435 1436
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
faisalhamdi's avatar
faisalhamdi committed
1437 1438 1439 1440 1441 1442 1443 1444
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1445 1446 1447 1448 1449 1450
                            }
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1451
            name: this.props.quarter == 'q2' || this.props.quarter == 'q3' ? `Apr ${this.props.periode} Actual` : `Apr ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1452 1453
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1454
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1455 1456 1457 1458 1459 1460 1461 1462 1463
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
                    return (
                        <div style={{ width: 96 }}>
                            {
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
syadziy's avatar
syadziy committed
1464
                                    this.state.get_for == "view" || this.props.quartal == "q2" || this.props.quartal == "q3" ?
faisalhamdi's avatar
faisalhamdi committed
1465 1466 1467 1468 1469 1470
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1471
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1472
                                        />
faisalhamdi's avatar
faisalhamdi committed
1473
                                        :
faisalhamdi's avatar
faisalhamdi committed
1474
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 4)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 4)).toFixed(1)}
qorri_di's avatar
qorri_di committed
1510
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1511 1512 1513 1514 1515 1516 1517
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1518
                                                            />
faisalhamdi's avatar
faisalhamdi committed
1519 1520
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={this.props.quarter == 'q1' ? false : true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
1544
                                        )
faisalhamdi's avatar
faisalhamdi committed
1545
                            }
faisalhamdi's avatar
faisalhamdi committed
1546 1547 1548 1549 1550
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1551
            name: this.props.quarter == 'q2' || this.props.quarter == 'q3' ? `May ${this.props.periode} Actual` : `May ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1552 1553
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1554
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1555 1556 1557
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1558
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1559
                    return (
faisalhamdi's avatar
faisalhamdi committed
1560 1561
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
1562 1563
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
syadziy's avatar
syadziy committed
1564
                                    this.state.get_for == "view" || this.props.quartal == "q2" || this.props.quartal == "q3" ?
faisalhamdi's avatar
faisalhamdi committed
1565 1566 1567 1568 1569 1570
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1571
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1572
                                        />
faisalhamdi's avatar
faisalhamdi committed
1573
                                        :
faisalhamdi's avatar
faisalhamdi committed
1574
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 5)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
1600 1601 1602 1603 1604 1605 1606 1607 1608 1609
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 5)).toFixed(1)}
qorri_di's avatar
qorri_di committed
1610
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1611 1612 1613 1614 1615 1616 1617
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1618
                                                            />
faisalhamdi's avatar
faisalhamdi committed
1619 1620
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={this.props.quarter == 'q1' ? false : true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
1644
                                        )
faisalhamdi's avatar
faisalhamdi committed
1645
                            }
faisalhamdi's avatar
faisalhamdi committed
1646 1647 1648 1649 1650
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1651
            name: this.props.quarter == 'q2' || this.props.quarter == 'q3' ? `Jun ${this.props.periode} Actual` : `Jun ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1652 1653
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1654
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1655 1656 1657
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1658
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1659
                    return (
faisalhamdi's avatar
faisalhamdi committed
1660 1661
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
1662 1663
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
syadziy's avatar
syadziy committed
1664
                                    this.state.get_for == "view" || this.props.quartal == "q2" || this.props.quartal == "q3" ?
faisalhamdi's avatar
faisalhamdi committed
1665 1666 1667 1668 1669 1670
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1671
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1672
                                        />
faisalhamdi's avatar
faisalhamdi committed
1673
                                        :
faisalhamdi's avatar
faisalhamdi committed
1674
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 6)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
1700 1701 1702 1703 1704 1705 1706 1707 1708 1709
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 6)).toFixed(1)}
qorri_di's avatar
qorri_di committed
1710
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1711 1712 1713 1714 1715 1716 1717
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1718
                                                            />
faisalhamdi's avatar
faisalhamdi committed
1719 1720
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={this.props.quarter == 'q1' ? false : true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
1744
                                        )
faisalhamdi's avatar
faisalhamdi committed
1745
                            }
faisalhamdi's avatar
faisalhamdi committed
1746 1747 1748 1749 1750
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1751
            name: this.props.quarter == 'q3' ? `Jul ${this.props.periode} Actual` : `Jul ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1752 1753
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1754
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1755 1756 1757
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1758
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1759
                    return (
faisalhamdi's avatar
faisalhamdi committed
1760 1761
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
1762 1763
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
syadziy's avatar
syadziy committed
1764
                                    this.state.get_for == "view" || this.props.quartal == "q3" ?
faisalhamdi's avatar
faisalhamdi committed
1765 1766 1767 1768 1769 1770
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1771
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1772
                                        />
faisalhamdi's avatar
faisalhamdi committed
1773
                                        :
faisalhamdi's avatar
faisalhamdi committed
1774
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 7)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
1800 1801 1802 1803 1804 1805 1806 1807 1808 1809
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 7)).toFixed(1)}
qorri_di's avatar
qorri_di committed
1810
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1811 1812 1813 1814 1815 1816 1817
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1818
                                                            />
faisalhamdi's avatar
faisalhamdi committed
1819 1820
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2' ? false : true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
1844
                                        )
faisalhamdi's avatar
faisalhamdi committed
1845
                            }
faisalhamdi's avatar
faisalhamdi committed
1846 1847 1848 1849 1850
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1851
            name: this.props.quarter == 'q3' ? `Aug ${this.props.periode} Actual` : `Aug ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1852 1853
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1854
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1855 1856 1857
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1858
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1859
                    return (
faisalhamdi's avatar
faisalhamdi committed
1860 1861
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
1862 1863
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
syadziy's avatar
syadziy committed
1864
                                    this.state.get_for == "view" || this.props.quartal == "q3" ?
faisalhamdi's avatar
faisalhamdi committed
1865 1866 1867 1868 1869 1870
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1871
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1872
                                        />
faisalhamdi's avatar
faisalhamdi committed
1873
                                        :
faisalhamdi's avatar
faisalhamdi committed
1874
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 8)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 8)).toFixed(1)}
qorri_di's avatar
qorri_di committed
1910
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1911 1912 1913 1914 1915 1916 1917
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1918
                                                            />
faisalhamdi's avatar
faisalhamdi committed
1919 1920
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2' ? false : true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
1944
                                        )
faisalhamdi's avatar
faisalhamdi committed
1945
                            }
faisalhamdi's avatar
faisalhamdi committed
1946 1947 1948 1949 1950
                        </div>
                    )
                }
            }
        }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1951
            name: this.props.quarter == 'q3' ? `Sep ${this.props.periode} Actual` : `Sep ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1952 1953
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1954
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1955 1956 1957
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1958
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1959
                    return (
faisalhamdi's avatar
faisalhamdi committed
1960 1961
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
1962 1963
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
syadziy's avatar
syadziy committed
1964
                                    this.state.get_for == "view" || this.props.quartal == "q3" ?
faisalhamdi's avatar
faisalhamdi committed
1965 1966 1967 1968 1969 1970
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1971
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1972
                                        />
faisalhamdi's avatar
faisalhamdi committed
1973
                                        :
faisalhamdi's avatar
faisalhamdi committed
1974
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 9)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 9)).toFixed(1)}
qorri_di's avatar
qorri_di committed
2010
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
2011 2012 2013 2014 2015 2016 2017
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2018
                                                            />
faisalhamdi's avatar
faisalhamdi committed
2019 2020
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2' ? false : true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
2044
                                        )
faisalhamdi's avatar
faisalhamdi committed
2045
                            }
faisalhamdi's avatar
faisalhamdi committed
2046 2047 2048 2049 2050
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
2051
            name: `Oct ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2052 2053
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
2054
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
2055 2056 2057
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
2058
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2059
                    return (
faisalhamdi's avatar
faisalhamdi committed
2060 2061
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
2062 2063 2064 2065 2066 2067 2068 2069 2070
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
                                    this.state.get_for == "view" ?
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
2071
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
2072
                                        />
faisalhamdi's avatar
faisalhamdi committed
2073
                                        :
faisalhamdi's avatar
faisalhamdi committed
2074
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 10)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
2100 2101 2102 2103 2104 2105 2106 2107 2108 2109
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 10)).toFixed(1)}
qorri_di's avatar
qorri_di committed
2110
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
2111 2112 2113 2114 2115 2116 2117
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2118
                                                            />
faisalhamdi's avatar
faisalhamdi committed
2119 2120
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={false}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
2144
                                        )
faisalhamdi's avatar
faisalhamdi committed
2145
                            }
faisalhamdi's avatar
faisalhamdi committed
2146 2147 2148 2149 2150
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
2151
            name: `Nov ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2152 2153
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
2154
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
2155 2156 2157
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
2158
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170
                    return (
                        <div style={{ width: 96 }}>
                            {
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
                                    this.state.get_for == "view" ?
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
2171
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
2172 2173
                                        />
                                        :
faisalhamdi's avatar
faisalhamdi committed
2174
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 11)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
2200 2201 2202 2203 2204 2205 2206 2207 2208 2209
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 11)).toFixed(1)}
qorri_di's avatar
qorri_di committed
2210
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
2211 2212 2213 2214 2215 2216 2217
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2218
                                                            />
faisalhamdi's avatar
faisalhamdi committed
2219 2220
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={false}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
2244
                                        )
faisalhamdi's avatar
faisalhamdi committed
2245
                            }
faisalhamdi's avatar
faisalhamdi committed
2246 2247 2248 2249 2250
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
2251
            name: `Dec ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
2252 2253
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
2254
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
2255 2256 2257
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
2258
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2259
                    return (
faisalhamdi's avatar
faisalhamdi committed
2260 2261
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
2262
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
faisalhamdi's avatar
faisalhamdi committed
2263
                                    null :
faisalhamdi's avatar
faisalhamdi committed
2264 2265 2266 2267 2268 2269 2270
                                    this.state.get_for == "view" ?
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
2271
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
2272
                                        />
faisalhamdi's avatar
faisalhamdi committed
2273
                                        :
faisalhamdi's avatar
faisalhamdi committed
2274
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 12)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
2300 2301 2302 2303 2304 2305 2306 2307 2308 2309
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 12)).toFixed(1)}
qorri_di's avatar
qorri_di committed
2310
                                                                // value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
2311 2312 2313 2314 2315 2316 2317
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2318
                                                            />
faisalhamdi's avatar
faisalhamdi committed
2319 2320
                                                        }
                                                    />
qorri_di's avatar
qorri_di committed
2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={false}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
2344
                                        )
faisalhamdi's avatar
faisalhamdi committed
2345
                            }
faisalhamdi's avatar
faisalhamdi committed
2346 2347 2348 2349 2350
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
2351
            name: `${this.props.periode} Total`,
faisalhamdi's avatar
faisalhamdi committed
2352 2353
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
2354
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
2355 2356 2357
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
2358 2359 2360 2361
                customBodyRender: (value, tableMeta) => {
                    return (
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
2362
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
faisalhamdi's avatar
faisalhamdi committed
2363
                                    null :
faisalhamdi's avatar
faisalhamdi committed
2364 2365 2366 2367 2368 2369 2370 2371
                                    this.state.get_for == "view" ?
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
                                            value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
2372
                                        />
faisalhamdi's avatar
faisalhamdi committed
2373
                                        :
faisalhamdi's avatar
faisalhamdi committed
2374
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
qorri_di's avatar
qorri_di committed
2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421
                                            <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)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                    // null
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 13)).toFixed(1)}
                                                                disabled
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                    :
faisalhamdi's avatar
faisalhamdi committed
2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438
                                                    <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)).toFixed(1)}
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2439
                                                            />
faisalhamdi's avatar
faisalhamdi committed
2440
                                                        }
qorri_di's avatar
qorri_di committed
2441 2442
                                                    />}
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
2443
                                        )
faisalhamdi's avatar
faisalhamdi committed
2444 2445 2446 2447 2448 2449 2450 2451 2452
                            }
                        </div>
                    )
                }
            }
        }, {
            name: "Strategic Initiative",
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
2453
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
2454 2455 2456 2457
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2458 2459
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
2460 2461
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
faisalhamdi's avatar
faisalhamdi committed
2462
                                this.state.get_for == "view" ?
d.arizona's avatar
d.arizona committed
2463 2464 2465
                                    <Input
                                        disableUnderline={true}
                                        style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
faisalhamdi's avatar
faisalhamdi committed
2466 2467 2468
                                        type="text"
                                        placeholder=""
                                        disabled={true}
d.arizona's avatar
d.arizona committed
2469
                                        defaultValue={value}
faisalhamdi's avatar
faisalhamdi committed
2470 2471
                                    />
                                    :
d.arizona's avatar
d.arizona committed
2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494
                                    <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 }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={this.props.quarter == 'q1' ? false : true}
                                                    defaultValue={value}
                                                    onBlur={(event) => {
                                                        // console.log(event.target.value)
                                                        // updateValue(event.target.value)
                                                        handleChangeText(event.target.value, tableMeta)
                                                        // console.log(dataTable2)
                                                    }}
                                                />
                                            </ThemeProvider>

                                        }
                                    />
faisalhamdi's avatar
faisalhamdi committed
2495
                            }
faisalhamdi's avatar
faisalhamdi committed
2496 2497 2498 2499 2500
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
2501
            name: "PIC",
faisalhamdi's avatar
faisalhamdi committed
2502 2503
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
2504
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
2505 2506 2507
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
2508
                customBodyRender: (value, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
2509 2510
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
2511 2512
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
faisalhamdi's avatar
faisalhamdi committed
2513
                                this.state.get_for == "view" ?
faisalhamdi's avatar
faisalhamdi committed
2514 2515 2516
                                    <Input
                                        disableUnderline={true}
                                        style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
faisalhamdi's avatar
faisalhamdi committed
2517 2518 2519
                                        type="text"
                                        placeholder=""
                                        disabled={true}
faisalhamdi's avatar
faisalhamdi committed
2520
                                        defaultValue={value}
faisalhamdi's avatar
faisalhamdi committed
2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532
                                    />
                                    :
                                    <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 }}
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
2533
                                                    disabled={this.props.quarter == 'q1' ? false : true}
faisalhamdi's avatar
faisalhamdi committed
2534 2535
                                                    defaultValue={value}
                                                    onBlur={(event) => {
faisalhamdi's avatar
faisalhamdi committed
2536
                                                        // console.log(event.target.value)
faisalhamdi's avatar
faisalhamdi committed
2537 2538
                                                        // updateValue(event.target.value)
                                                        handleChangeText(event.target.value, tableMeta)
faisalhamdi's avatar
faisalhamdi committed
2539
                                                        // console.log(dataTable2)
faisalhamdi's avatar
faisalhamdi committed
2540 2541 2542
                                                    }}
                                                />
                                            </ThemeProvider>
faisalhamdi's avatar
faisalhamdi committed
2543

faisalhamdi's avatar
faisalhamdi committed
2544 2545
                                        }
                                    />
faisalhamdi's avatar
faisalhamdi committed
2546
                            }
faisalhamdi's avatar
faisalhamdi committed
2547 2548 2549 2550
                        </div>
                    )
                }
            }
faisalhamdi's avatar
faisalhamdi committed
2551 2552 2553 2554 2555
        }, {
            name: "",
            options: {
                display: false
            }
faisalhamdi's avatar
faisalhamdi committed
2556 2557
        },
        ]
faisalhamdi's avatar
faisalhamdi committed
2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568
        const loadingComponent = (
            <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)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );

faisalhamdi's avatar
faisalhamdi committed
2569 2570 2571 2572 2573
        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 }}>
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Rolling Outlook & Revision CAT</Typography>
                </div>
faisalhamdi's avatar
faisalhamdi committed
2574 2575 2576 2577 2578
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
faisalhamdi's avatar
faisalhamdi committed
2579
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
faisalhamdi's avatar
faisalhamdi committed
2580
                    {this.state.visibleCATRO ?
faisalhamdi's avatar
faisalhamdi committed
2581 2582 2583 2584 2585 2586 2587 2588
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Corporate Annual Target - Revision</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>
faisalhamdi's avatar
faisalhamdi committed
2589
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} {String(this.props.quarter).toLocaleUpperCase()} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
2590 2591 2592 2593 2594
                                        {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>
                                        }
faisalhamdi's avatar
faisalhamdi committed
2595 2596
                                    </div>
                                    <div style={{ width: '50%' }}>
Riri Novita's avatar
Riri Novita committed
2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650
                                        {this.props.isApprover === true || this.state.get_for == 'view' ?
                                            null
                                            // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            //     <a data-tip={'Download'} data-for="download">
                                            //         <button
                                            //             style={{
                                            //                 backgroundColor: 'transparent',
                                            //                 cursor: 'pointer',
                                            //                 borderColor: 'transparent',
                                            //                 margin: 5
                                            //             }}
                                            //             onClick={() =>
                                            //                 this.setState({ loading: true }, () => {
                                            //                     setTimeout(() => {
                                            //                         this.downloadAllData()
                                            //                     }, 100);
                                            //                 })}
                                            //         >
                                            //             <img src={Images.download} />
                                            //         </button>
                                            //     </a>
                                            //     <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            // </div> 
                                            :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                <a data-tip={'Download Template'} data-for="template">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.downloadTemplate()}
                                                    >
                                                        <img src={Images.template} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                                <a data-tip={'Upload'} data-for="upload">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.setState({ visibleUpload: 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">
faisalhamdi's avatar
faisalhamdi committed
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667
                                                    <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
2668
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
Riri Novita's avatar
Riri Novita committed
2669 2670
                                            </div>
                                        }
faisalhamdi's avatar
faisalhamdi committed
2671
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2672
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684

                                <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>

Riri Novita's avatar
Riri Novita committed
2685 2686 2687 2688 2689
                                <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) => {
qorri_di's avatar
qorri_di committed
2690 2691 2692 2693
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
faisalhamdi's avatar
faisalhamdi committed
2694
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
Riri Novita's avatar
Riri Novita committed
2695 2696 2697
                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2698
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2699
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724
                            <div className="grid grid-2x" style={{ padding: 20 }}>
                                <div className="col-1" style={{ paddingLeft: 0 }}>
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
                                        <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>
                                        </div>
                                    </button>
                                </div>
                                {this.props.isApprover === true ?
                                    <div className="col-2">
                                    </div> :
                                    <div className="" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
2725
                                        {this.state.get_for == 'view' && this.state.viewOnly &&
faisalhamdi's avatar
faisalhamdi committed
2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745
                                            <button
                                                className="button"
                                                type="button"
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                    // marginRight: 20
                                                }}
                                                onClick={() => {
                                                    this.setState({ loading: true }, () => {
                                                        this.handleGetFor('edit')
                                                    })
                                                }}
                                            >
                                                <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' }}>Edit</Typography>
                                                </div>
                                            </button>
faisalhamdi's avatar
faisalhamdi committed
2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780
                                        }
                                        {this.state.get_for == 'edit' && <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
                                                    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.state.get_for === 'edit' && <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
                                                this.state.saveDraft ?
faisalhamdi's avatar
faisalhamdi committed
2781
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
2782
                                                    :
2783 2784
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799
                                                            this.backToRollingOutlook('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.state.get_for === 'edit' && <button
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            onClick={() =>
                                                this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data incomplete !', tipeAlert: 'error' })
                                                    :
2800 2801
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816
                                                            this.backToRollingOutlook('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: '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>
                                }
faisalhamdi's avatar
faisalhamdi committed
2817
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2818
                        </Paper>
faisalhamdi's avatar
faisalhamdi committed
2819 2820
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
2821
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
faisalhamdi's avatar
faisalhamdi committed
2822 2823 2824 2825 2826 2827
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Corporate Annual Target - Revision</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>
faisalhamdi's avatar
faisalhamdi committed
2828
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} {String(this.props.quarter).toLocaleUpperCase()} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
2829 2830 2831 2832 2833
                                        {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>
                                        }
faisalhamdi's avatar
faisalhamdi committed
2834
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2835
                                    <div style={{ width: '50%' }} />
faisalhamdi's avatar
faisalhamdi committed
2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848
                                </div>

                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {this.state.dataLoaded && (
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
                                </div>
Riri Novita's avatar
Riri Novita committed
2849 2850 2851 2852 2853
                                <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) => {
qorri_di's avatar
qorri_di committed
2854 2855 2856 2857
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
faisalhamdi's avatar
faisalhamdi committed
2858
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
Riri Novita's avatar
Riri Novita committed
2859 2860 2861
                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2862
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2863
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2864 2865 2866 2867 2868 2869
                            <div className="grid grid-2x" style={{ padding: 20 }}>
                                <div className="col-1" style={{ paddingLeft: 0 }}>
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
2870 2871 2872
                                                this.setState({ visibleCATRO: true, visibleUpload: false }, () => {
                                                    this.handleGetFor('edit')
                                                })
faisalhamdi's avatar
faisalhamdi committed
2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924
                                            }, 100);
                                        })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
                                        <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>
                                        </div>
                                    </button>
                                </div>
                                {this.props.isApprover === true ?
                                    <div className="col-2">
                                    </div> :
                                    <div className="" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
                                        {this.state.get_for == 'edit' && <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
                                                    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.state.get_for === 'edit' && <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
                                                this.state.saveDraft ?
faisalhamdi's avatar
faisalhamdi committed
2925
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
2926
                                                    :
2927 2928
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943
                                                            this.uploadCATRO('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.state.get_for === 'edit' && <button
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            onClick={() =>
                                                this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data incomplete !', tipeAlert: 'error' })
                                                    :
2944 2945
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962
                                                            this.uploadCATRO('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: '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>
faisalhamdi's avatar
faisalhamdi committed
2963
                    }
faisalhamdi's avatar
faisalhamdi committed
2964
                </div>
faisalhamdi's avatar
faisalhamdi committed
2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983
                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                    </div>
                                </div>
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
                                </div>
                            </div>
Riri Novita's avatar
Riri Novita committed
2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000
                            <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.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("ROLLING") && String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("CAT") ?
                                            this.checkUpload() :
                                            this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                    }}
                                />
                            </div>
3001
                            <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
3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037
                        </div>
                    </div>
                )}

                {this.state.visibleAlertSave && (
                    <div className="test app-popup-show">
                        <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
                            <div style={{ margin: 30 }}>
                                <div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
                                    <div style={{ alignSelf: 'center', marginRight: 25 }}>
                                        <img src={Images.warning} />
                                    </div>
                                    <div style={{ justifyContent: 'center', fontSize: 20, color: '#1D2995', marginTop: 10 }}>
                                        <b>Rate Currency USD</b> pada periode yang dipilih <b>belum</b> diatur.<br /> Silahkan menghubungi Superadmin
                                    </div>
                                </div>
                                <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            background: '#F6F7F9',
                                            cursor: 'pointer',
                                            border: '1px solid #3549609e',
                                            outline: 'none',
                                            marginRight: 20,
                                            borderRadius: 9
                                        }}
                                        onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0 })}
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 9, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
                                            <Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
                                        </div>
                                    </button>
                                </div>
                            </div>
faisalhamdi's avatar
faisalhamdi committed
3038 3039 3040
                        </div>
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
3041 3042 3043 3044
            </div>
        )
    }
}