CorporateAnnualTargetRO.js 216 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';
Riri Novita's avatar
Riri Novita committed
16
import { fixNumber } from '../../library/Utils';
faisalhamdi's avatar
faisalhamdi committed
17

faisalhamdi's avatar
faisalhamdi committed
18 19 20 21 22 23 24 25
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
26 27 28 29 30 31 32 33
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
34
    zIndex: 101,
faisalhamdi's avatar
faisalhamdi committed
35 36 37 38 39 40 41
};
const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100
};

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

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

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

    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
        let checkPrevRev = false
d.arizona's avatar
d.arizona committed
94
        console.log('skuy');
d.arizona's avatar
d.arizona committed
95
        // console.log(this.props.isApprover)
faisalhamdi's avatar
faisalhamdi committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
        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
120
        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
d.arizona's avatar
d.arizona committed
121
        // this.setState({ viewOnly: true })
faisalhamdi's avatar
faisalhamdi committed
122 123 124 125 126 127 128 129 130 131
    }

    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
132
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
133 134 135 136 137 138 139 140 141 142 143 144 145 146
            "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
147 148
                                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
149 150 151 152 153 154 155
                                dataTable.push([
                                    item.type_report_id,
                                    item.id,
                                    item.parent,
                                    item.formula,
                                    item.level,
                                    item.description,
syadziy's avatar
syadziy committed
156 157
                                    // 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
158
                                    parentTrue ? item.corporate_annual_target.uom : item.uom,
faisalhamdi's avatar
faisalhamdi committed
159
                                    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
160
                                    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
161
                                    parentTrue ? item.corporate_annual_target.formula_ytd == "" ? null : { value: item.corporate_annual_target.formula_ytd } : item.formula_ytd == "" ? null : { value: item.formula_ytd },
Riri Novita's avatar
Riri Novita committed
162 163 164 165 166 167 168 169 170 171 172 173 174
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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)) : { 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)),
                                    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),
faisalhamdi's avatar
faisalhamdi committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188
                                    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
189
                            let weight = String(item.weight).includes('%') ? String(item.weight).substr(0, String(item.weight).length - 1) : item.weight
faisalhamdi's avatar
faisalhamdi committed
190 191 192 193 194 195 196
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
Riri Novita's avatar
Riri Novita committed
197
                                item.weight == '' ? fixNumber(Number(0), 1) : fixNumber(Number(Number(item.weight) * 100), 1),
syadziy's avatar
syadziy committed
198
                                // 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
199
                                // item.corporate_annual_target.weight == "" ? Number(0).toFixed(1) : Number(Number(weight * 100)).toFixed(1),
faisalhamdi's avatar
faisalhamdi committed
200 201 202 203
                                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 },
Riri Novita's avatar
Riri Novita committed
204 205 206 207 208 209 210 211 212 213 214 215 216
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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)),
                                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),
faisalhamdi's avatar
faisalhamdi committed
217 218 219 220 221 222 223 224 225 226 227 228 229
                                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
230
                        this.setState({ dataTable, loading: false, dataReal: res, editable: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
231 232 233
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
234
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
                                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
253
    handleGetFor(type) {
faisalhamdi's avatar
faisalhamdi committed
254
        this.setState({ get_for: type }, () => {
faisalhamdi's avatar
faisalhamdi committed
255
            this.getLatestUpdate()
faisalhamdi's avatar
faisalhamdi committed
256 257 258 259
            this.getItemHierarki()
        })
    }

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

                        data.map((item) => {
                            inputKPI.push({
                                value: item.value
                            })
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
faisalhamdi's avatar
faisalhamdi committed
285
                        // console.log(defaultProps)
faisalhamdi's avatar
faisalhamdi committed
286 287 288
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
289
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
                                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,
Riri Novita's avatar
Riri Novita committed
310 311
            type: 'MAX_ACHIEVEMENT',
            currency_id: this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
        }
        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
330
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
                                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
349 350
    downloadTemplate = async () => {
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
351
            `${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
352 353 354 355 356 357
        )
        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
358
            a.download = 'Template ROLLING OUTLOOK & CAT REVISION - Corporate Annual Target.xlsx';
faisalhamdi's avatar
faisalhamdi committed
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
            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
375
            a.download = 'ROLLING OUTLOOK & CAT REVISION - Corporate Annual Target.xlsx';
faisalhamdi's avatar
faisalhamdi committed
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
            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)
Riri Novita's avatar
Riri Novita committed
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
            if (this.props.defaultCurrency.id == 2) {
                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,
                    "formula_ytd": i[10] == null ? "" : i[10].value,
                    "january": stateFR ? i[0] == 3 ? String(i[11]) : String(Number(i[11].value)) : String(i[11]),
                    "february": stateFR ? i[0] == 3 ? String(i[12]) : String(Number(i[12].value)) : String(i[12]),
                    "march": stateFR ? i[0] == 3 ? String(i[13]) : String(Number(i[13].value)) : String(i[13]),
                    "april": stateFR ? i[0] == 3 ? String(i[14]) : String(Number(i[14].value)) : String(i[14]),
                    "may": stateFR ? i[0] == 3 ? String(i[15]) : String(Number(i[15].value)) : String(i[15]),
                    "june": stateFR ? i[0] == 3 ? String(i[16]) : String(Number(i[16].value)) : String(i[16]),
                    "july": stateFR ? i[0] == 3 ? String(i[17]) : String(Number(i[17].value)) : String(i[17]),
                    "august": stateFR ? i[0] == 3 ? String(i[18]) : String(Number(i[18].value)) : String(i[18]),
                    "september": stateFR ? i[0] == 3 ? String(i[19]) : String(Number(i[19].value)) : String(i[19]),
                    "october": stateFR ? i[0] == 3 ? String(i[20]) : String(Number(i[20].value)) : String(i[20]),
                    "november": stateFR ? i[0] == 3 ? String(i[21]) : String(Number(i[21].value)) : String(i[21]),
                    "december": stateFR ? i[0] == 3 ? String(i[22]) : String(Number(i[22].value)) : String(i[22]),
                    "current_year_total": String(Number(i[23])) == "" ? "0.0" : String(Number(i[23])),
                    "strategic_initiative": String(i[24]),
                    "pic": String(i[25])
                })
            } else {
                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,
                    "formula_ytd": i[10] == null ? "" : i[10].value,
                    "january": stateFR ? i[0] == 3 ? String(i[11]) : String(fixNumber(Number(i[11].value), 1)) : String(i[11]),
                    "february": stateFR ? i[0] == 3 ? String(i[12]) : String(fixNumber(Number(i[12].value), 1)) : String(i[12]),
                    "march": stateFR ? i[0] == 3 ? String(i[13]) : String(fixNumber(Number(i[13].value), 1)) : String(i[13]),
                    "april": stateFR ? i[0] == 3 ? String(i[14]) : String(fixNumber(Number(i[14].value), 1)) : String(i[14]),
                    "may": stateFR ? i[0] == 3 ? String(i[15]) : String(fixNumber(Number(i[15].value), 1)) : String(i[15]),
                    "june": stateFR ? i[0] == 3 ? String(i[16]) : String(fixNumber(Number(i[16].value), 1)) : String(i[16]),
                    "july": stateFR ? i[0] == 3 ? String(i[17]) : String(fixNumber(Number(i[17].value), 1)) : String(i[17]),
                    "august": stateFR ? i[0] == 3 ? String(i[18]) : String(fixNumber(Number(i[18].value), 1)) : String(i[18]),
                    "september": stateFR ? i[0] == 3 ? String(i[19]) : String(fixNumber(Number(i[19].value), 1)) : String(i[19]),
                    "october": stateFR ? i[0] == 3 ? String(i[20]) : String(fixNumber(Number(i[20].value), 1)) : String(i[20]),
                    "november": stateFR ? i[0] == 3 ? String(i[21]) : String(fixNumber(Number(i[21].value), 1)) : String(i[21]),
                    "december": stateFR ? i[0] == 3 ? String(i[22]) : String(fixNumber(Number(i[22].value), 1)) : String(i[22]),
                    "current_year_total": String(fixNumber(Number(i[23]), 1)) == "" ? "0.0" : String(fixNumber(Number(i[23]), 1)),
                    "strategic_initiative": String(i[24]),
                    "pic": String(i[25])
                })
            }

faisalhamdi's avatar
faisalhamdi committed
455 456 457 458 459 460 461 462
        })
        // 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
463
            "currency_id": this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
464 465 466
            "status": type,
            "cat": data
        }
faisalhamdi's avatar
faisalhamdi committed
467
        // console.log(JSON.stringify(payload));
faisalhamdi's avatar
faisalhamdi committed
468 469 470 471 472 473
        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
474 475
                    this.props.onClickClose()
                    this.props.refresh()
faisalhamdi's avatar
faisalhamdi committed
476
                } else {
Riri Novita's avatar
Riri Novita committed
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
                    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
492
                }
Riri Novita's avatar
Riri Novita committed
493
                // else {
494
                //     this.setState({ loading: false, handleDoubleClick: 0 }, () => {
Riri Novita's avatar
Riri Novita committed
495 496 497 498
                //         this.props.onClickClose()
                //         this.props.refresh()
                //     })
                // }
faisalhamdi's avatar
faisalhamdi committed
499
            } else {
500
                this.setState({ loading: false, handleDoubleClick: 0 })
faisalhamdi's avatar
faisalhamdi committed
501 502 503 504 505 506 507
            }
        })
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
faisalhamdi's avatar
faisalhamdi committed
508
            // console.log(resp)
faisalhamdi's avatar
faisalhamdi committed
509
            if (err) {
faisalhamdi's avatar
faisalhamdi committed
510
                // console.log(err);
faisalhamdi's avatar
faisalhamdi committed
511 512 513
            }
            else {
                let isi = resp.rows.slice(3)
faisalhamdi's avatar
faisalhamdi committed
514
                // console.log(isi);
faisalhamdi's avatar
faisalhamdi committed
515 516 517 518
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
faisalhamdi's avatar
faisalhamdi committed
519 520 521
                        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
522
                            weight: i[3] === undefined ? "" : String(i[3]).trim(),
faisalhamdi's avatar
faisalhamdi committed
523 524 525
                            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
526 527 528 529 530 531 532 533 534 535 536 537
                            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
538
                            strategic_initiative: i[20] === undefined ? "" : String(i[20]).trim(),
faisalhamdi's avatar
faisalhamdi committed
539 540
                            pic: i[21] === undefined ? "" : String(i[21]).trim()
                        })
faisalhamdi's avatar
faisalhamdi committed
541 542
                    }
                })
faisalhamdi's avatar
faisalhamdi committed
543
                // console.log(payload)
faisalhamdi's avatar
faisalhamdi committed
544 545 546 547 548
                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
549 550
                    rolling_outlook_id: this.props.rollingOutlookID,
                    quartal: this.props.quarter,
faisalhamdi's avatar
faisalhamdi committed
551 552
                    status: 'submitted'
                }
faisalhamdi's avatar
faisalhamdi committed
553 554
                console.log(body)
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
faisalhamdi's avatar
faisalhamdi committed
555 556 557 558 559 560
            }
        });
    }

    checkUpload() {
        this.setState({ loading: true, dataTable: [] })
Riri Novita's avatar
Riri Novita committed
561 562 563 564 565
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        api.create().checkImportRollingOutlookCAT(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
566 567
            // console.log(JSON.stringify(this.state.payload));
            console.log(response)
faisalhamdi's avatar
faisalhamdi committed
568 569 570
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
faisalhamdi's avatar
faisalhamdi committed
571
                        this.setState({ visibleUpload: false, visibleCATRO: false })
faisalhamdi's avatar
faisalhamdi committed
572 573 574 575 576 577 578
                        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
579
                                item.level,
faisalhamdi's avatar
faisalhamdi committed
580
                                item.item_report,
d.arizona's avatar
d.arizona committed
581
                                Number(String(item.weight).substr(0, String(item.weight).length - 1)),
faisalhamdi's avatar
faisalhamdi committed
582
                                item.uom,
faisalhamdi's avatar
faisalhamdi committed
583
                                item.kpi == "" || item.kpi == null ? null : { value: item.kpi },
faisalhamdi's avatar
faisalhamdi committed
584
                                item.max_ach == "" || item.max_ach == null ? null : { value: titleCase(item.max_ach) },
faisalhamdi's avatar
faisalhamdi committed
585
                                item.formula_ytd == "" || item.formula_ytd == null ? null : { value: item.formula_ytd },
Riri Novita's avatar
Riri Novita committed
586 587 588 589 590 591 592 593 594 595 596 597 598
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.january) : { value: item.january, formula: item.january_formula } : item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.february) : { value: item.february, formula: item.february_formula } : item.february == "" ? item.february : String(item.february).indexOf(".") == -1 ? Number(item.february) : Number(item.february),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.march) : { value: item.march, formula: item.march_formula } : item.march == "" ? item.march : String(item.march).indexOf(".") == -1 ? Number(item.march) : Number(item.march),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.april) : { value: item.april, formula: item.april_formula } : item.april == "" ? item.april : String(item.april).indexOf(".") == -1 ? Number(item.april) : Number(item.april),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.may) : { value: item.may, formula: item.may_formula } : item.may == "" ? item.may : String(item.may).indexOf(".") == -1 ? Number(item.may) : Number(item.may),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.june) : { value: item.june, formula: item.june_formula } : item.june == "" ? item.june : String(item.june).indexOf(".") == -1 ? Number(item.june) : Number(item.june),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.july) : { value: item.july, formula: item.july_formula } : item.july == "" ? item.july : String(item.july).indexOf(".") == -1 ? Number(item.july) : Number(item.july),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.august) : { value: item.august, formula: item.august_formula } : item.august == "" ? item.august : String(item.august).indexOf(".") == -1 ? Number(item.august) : Number(item.august),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.september) : { value: item.september, formula: item.september_formula } : item.september == "" ? item.september : String(item.september).indexOf(".") == -1 ? Number(item.september) : Number(item.september),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.october) : { value: item.october, formula: item.october_formula } : item.october == "" ? item.october : String(item.october).indexOf(".") == -1 ? Number(item.october) : Number(item.october),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.november) : { value: item.november, formula: item.november_formula } : item.november == "" ? item.november : String(item.november).indexOf(".") == -1 ? Number(item.november) : Number(item.november),
                                item.parent_name == "FINANCIAL PERSPECTIVE" ? item.type_report_id == 3 ? Number(item.december) : { value: item.december, formula: item.december_formula } : item.december == "" ? item.december : String(item.december).indexOf(".") == -1 ? Number(item.december) : Number(item.december),
                                item.current_year_total == "" ? item.current_year_total : String(item.current_year_total).indexOf(".") == -1 ? Number(item.current_year_total) : Number(item.total_current_year),
faisalhamdi's avatar
faisalhamdi committed
599
                                item.strategic_initiative,
faisalhamdi's avatar
faisalhamdi committed
600 601 602 603 604
                                item.pic,
                                item.order,
                                item.error
                            ])
                        })
faisalhamdi's avatar
faisalhamdi committed
605
                        // console.log(this.state.buttonError)
faisalhamdi's avatar
faisalhamdi committed
606
                        console.log(dataTable)
faisalhamdi's avatar
faisalhamdi committed
607
                        this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
608
                            this.state.dataTable.map(item => {
faisalhamdi's avatar
faisalhamdi committed
609
                                if (item[27].length > 0) {
faisalhamdi's avatar
faisalhamdi committed
610
                                    console.log('masuk')
faisalhamdi's avatar
faisalhamdi committed
611 612 613
                                    this.setState({ buttonError: true, errorPreview: true, editable: true })
                                }
                            })
faisalhamdi's avatar
faisalhamdi committed
614
                            // console.log(this.state.dataTable);
faisalhamdi's avatar
faisalhamdi committed
615 616 617
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
618
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
                                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
635 636 637 638 639 640 641 642
    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
643
                    if (this.state.dataTable[indexID][5] === 'FINANCIAL PERSPECTIVE') {
faisalhamdi's avatar
faisalhamdi committed
644 645 646 647 648 649 650 651 652
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
            } else {
                stateFR = false
            }

Riri Novita's avatar
Riri Novita committed
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
            if (this.state.defaultCurrencyUpload?.id == 2) {
                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,
                    "formula_ytd": i[10] == null ? "" : i[10].value,
                    "january": stateFR ? i[0] == 3 ? String(i[11]) : String(Number(i[11].value)) : String(i[11]),
                    "february": stateFR ? i[0] == 3 ? String(i[12]) : String(Number(i[12].value)) : String(i[12]),
                    "march": stateFR ? i[0] == 3 ? String(i[13]) : String(Number(i[13].value)) : String(i[13]),
                    "april": stateFR ? i[0] == 3 ? String(i[14]) : String(Number(i[14].value)) : String(i[14]),
                    "may": stateFR ? i[0] == 3 ? String(i[15]) : String(Number(i[15].value)) : String(i[15]),
                    "june": stateFR ? i[0] == 3 ? String(i[16]) : String(Number(i[16].value)) : String(i[16]),
                    "july": stateFR ? i[0] == 3 ? String(i[17]) : String(Number(i[17].value)) : String(i[17]),
                    "august": stateFR ? i[0] == 3 ? String(i[18]) : String(Number(i[18].value)) : String(i[18]),
                    "september": stateFR ? i[0] == 3 ? String(i[19]) : String(Number(i[19].value)) : String(i[19]),
                    "october": stateFR ? i[0] == 3 ? String(i[20]) : String(Number(i[20].value)) : String(i[20]),
                    "november": stateFR ? i[0] == 3 ? String(i[21]) : String(Number(i[21].value)) : String(i[21]),
                    "december": stateFR ? i[0] == 3 ? String(i[22]) : String(Number(i[22].value)) : String(i[22]),
                    "current_year_total": String(Number(i[23])) == "" ? "0.0" : String(Number(i[23])),
                    "strategic": String(i[24]),
                    "pic": String(i[25])
                })
            } else {
                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,
                    "formula_ytd": i[10] == null ? "" : i[10].value,
                    "january": stateFR ? i[0] == 3 ? String(i[11]) : String(fixNumber(Number(i[11].value), 1)) : String(i[11]),
                    "february": stateFR ? i[0] == 3 ? String(i[12]) : String(fixNumber(Number(i[12].value), 1)) : String(i[12]),
                    "march": stateFR ? i[0] == 3 ? String(i[13]) : String(fixNumber(Number(i[13].value), 1)) : String(i[13]),
                    "april": stateFR ? i[0] == 3 ? String(i[14]) : String(fixNumber(Number(i[14].value), 1)) : String(i[14]),
                    "may": stateFR ? i[0] == 3 ? String(i[15]) : String(fixNumber(Number(i[15].value), 1)) : String(i[15]),
                    "june": stateFR ? i[0] == 3 ? String(i[16]) : String(fixNumber(Number(i[16].value), 1)) : String(i[16]),
                    "july": stateFR ? i[0] == 3 ? String(i[17]) : String(fixNumber(Number(i[17].value), 1)) : String(i[17]),
                    "august": stateFR ? i[0] == 3 ? String(i[18]) : String(fixNumber(Number(i[18].value), 1)) : String(i[18]),
                    "september": stateFR ? i[0] == 3 ? String(i[19]) : String(fixNumber(Number(i[19].value), 1)) : String(i[19]),
                    "october": stateFR ? i[0] == 3 ? String(i[20]) : String(fixNumber(Number(i[20].value), 1)) : String(i[20]),
                    "november": stateFR ? i[0] == 3 ? String(i[21]) : String(fixNumber(Number(i[21].value), 1)) : String(i[21]),
                    "december": stateFR ? i[0] == 3 ? String(i[22]) : String(fixNumber(Number(i[22].value), 1)) : String(i[22]),
                    "current_year_total": String(fixNumber(Number(i[23]), 1)) == "" ? "0.0" : String(fixNumber(Number(i[23]), 1)),
                    "strategic": String(i[24]),
                    "pic": String(i[25])
                })
            }

faisalhamdi's avatar
faisalhamdi committed
705 706 707 708 709 710 711
        })
        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
712
            "currency_id": this.state.defaultCurrencyUpload?.id,
faisalhamdi's avatar
faisalhamdi committed
713 714
            "status": type,
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
715
        }
faisalhamdi's avatar
faisalhamdi committed
716 717 718 719 720 721 722 723 724
        // 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
725
                        this.props.refresh()
faisalhamdi's avatar
faisalhamdi committed
726
                    } else {
Riri Novita's avatar
Riri Novita committed
727 728 729 730 731 732 733 734 735 736 737 738
                        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
739 740
                    }
                } else {
741
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
faisalhamdi's avatar
faisalhamdi committed
742 743
                }
            } else {
744
                this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false, handleDoubleClick: 0 })
faisalhamdi's avatar
faisalhamdi committed
745 746
            }
        })
faisalhamdi's avatar
faisalhamdi committed
747 748 749
    }

    handleValidate() {
faisalhamdi's avatar
faisalhamdi committed
750
        this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false })
faisalhamdi's avatar
faisalhamdi committed
751 752
    }

faisalhamdi's avatar
faisalhamdi committed
753 754 755 756 757 758
    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
759 760
            "rolling_outlook_id": this.props.rollingOutlookID,
            "quartal": this.props.quarter
faisalhamdi's avatar
faisalhamdi committed
761
        }
faisalhamdi's avatar
faisalhamdi committed
762 763
        api.create().getRollingOutlookLastUpdate(payload).then(response => {
            // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
764 765 766
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
767
                        updateBy: response.data.data.detail === null ? '-' : response.data.data.detail,
faisalhamdi's avatar
faisalhamdi committed
768 769 770 771
                        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
772
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
773 774 775 776 777
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
faisalhamdi's avatar
faisalhamdi committed
778 779
                    })
                }
faisalhamdi's avatar
faisalhamdi committed
780 781
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
782 783 784 785
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
786 787 788 789
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
790
    render() {
faisalhamdi's avatar
faisalhamdi committed
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815
        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
816

faisalhamdi's avatar
faisalhamdi committed
817 818 819 820 821 822 823 824
            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
825
                    let columnStart = 13
faisalhamdi's avatar
faisalhamdi committed
826 827
                    let indexX = String(item).indexOf('[')
                    let formulaAwal = String(item).substr(0, indexX)
faisalhamdi's avatar
faisalhamdi committed
828
                    let columnEnd = 24
faisalhamdi's avatar
faisalhamdi committed
829 830
                    let month = column - 1
                    let total = 0
faisalhamdi's avatar
faisalhamdi committed
831 832 833 834 835 836 837 838 839 840 841 842
                    // // // 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
843

faisalhamdi's avatar
faisalhamdi committed
844
                    }
faisalhamdi's avatar
faisalhamdi committed
845 846 847 848 849 850 851 852
                    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
853
                    // console.log(item)
faisalhamdi's avatar
faisalhamdi committed
854 855 856 857 858 859 860
                    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
861 862
                        if (forecast == undefined) {
                            let convertID = -1
Riri Novita's avatar
Riri Novita committed
863
                            if (tableMeta.rowData[10]?.value == 'FORMULA') {
faisalhamdi's avatar
faisalhamdi committed
864 865 866 867 868
                                // 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
869 870 871 872 873 874
                            } 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
875
                            }
faisalhamdi's avatar
faisalhamdi committed
876 877 878 879 880 881 882 883 884
                        } 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
885
                            //     anjay.push(valuezz == "" ? 0 : valuezz)
faisalhamdi's avatar
faisalhamdi committed
886
                            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
887
                        }
faisalhamdi's avatar
faisalhamdi committed
888 889 890 891 892 893

                        anjay.push(operatorX)
                        anjay.push(nilaiX)
                    }
                } else {
                    if (String(item).includes('#')) {
faisalhamdi's avatar
faisalhamdi committed
894 895 896 897 898 899 900 901
                        // 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
902 903

                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
904
                        let convertID = -1
syadziy's avatar
syadziy committed
905
                        if (tableMeta.rowData[10].value == 'FORMULA') {
Deni Rinaldi's avatar
Deni Rinaldi committed
906
                            let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
syadziy's avatar
syadziy committed
907
                            convertID = dataTable2[indexIDReport][26]
faisalhamdi's avatar
faisalhamdi committed
908
                        }
syadziy's avatar
syadziy committed
909
                        let indexID = dataTable2.findIndex((val) => val[26] == (convertID == -1 ? item : convertID))
faisalhamdi's avatar
faisalhamdi committed
910 911
                        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
912
                            if (item == dataTable2[tableMeta.rowIndex][26]) {
faisalhamdi's avatar
faisalhamdi committed
913
                                anjay.push(0)
Deni Rinaldi's avatar
Deni Rinaldi committed
914
                            } else {
faisalhamdi's avatar
faisalhamdi committed
915 916 917 918 919
                                anjay.push(valuezz == "" ? "0" : valuezz)
                            }
                        } else {
                            if (item === '(-1)') {
                                anjay.push(-1)
faisalhamdi's avatar
faisalhamdi committed
920 921 922 923 924
                            }
                        }
                    }
                }
            })
faisalhamdi's avatar
faisalhamdi committed
925
            // if (tableMeta.rowData[11].value == 'FORMULA') {
qorri_di's avatar
qorri_di committed
926 927
            // console.log(anjay)
            // console.log(column)
faisalhamdi's avatar
faisalhamdi committed
928 929

            // }
faisalhamdi's avatar
faisalhamdi committed
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 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 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

            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
1049 1050 1051 1052 1053 1054 1055 1056
            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
1057 1058
            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
faisalhamdi's avatar
faisalhamdi committed
1059
            } else {
faisalhamdi's avatar
faisalhamdi committed
1060
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
faisalhamdi's avatar
faisalhamdi committed
1061
            }
faisalhamdi's avatar
faisalhamdi committed
1062
            // }
faisalhamdi's avatar
faisalhamdi committed
1063 1064 1065 1066

            return total
        }

faisalhamdi's avatar
faisalhamdi committed
1067 1068 1069
        // const handleValueForecast = (value, tableMeta, periode) => {
        //     return handleValueFormula(value, tableMeta, periode, periode, 'forecast')
        // }
faisalhamdi's avatar
faisalhamdi committed
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149
        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
1150 1151
                // console.log(indexsss);
                if (dataTable2[indexsss][5] == 'FINANCIAL PERSPECTIVE') {
faisalhamdi's avatar
faisalhamdi committed
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168
                    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
1169 1170 1171 1172 1173 1174
            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
1175
                        total += Number(valItem)
faisalhamdi's avatar
faisalhamdi committed
1176
                        if (index == 22) {
faisalhamdi's avatar
faisalhamdi committed
1177 1178
                            lastValz += Number(valItem)
                        }
faisalhamdi's avatar
faisalhamdi committed
1179 1180
                    } else {
                        valItem = item == undefined || item == "" ? 0 : item
faisalhamdi's avatar
faisalhamdi committed
1181
                        total += Number(valItem)
faisalhamdi's avatar
faisalhamdi committed
1182
                        if (index == 22) {
faisalhamdi's avatar
faisalhamdi committed
1183 1184 1185
                            lastValz += Number(valItem)
                        }
                    }
faisalhamdi's avatar
faisalhamdi committed
1186
                }
faisalhamdi's avatar
faisalhamdi committed
1187 1188 1189 1190 1191
            })
            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
1192
        }
faisalhamdi's avatar
faisalhamdi committed
1193

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

faisalhamdi's avatar
faisalhamdi committed
2604 2605
                                        }
                                    />
faisalhamdi's avatar
faisalhamdi committed
2606
                            }
faisalhamdi's avatar
faisalhamdi committed
2607 2608 2609 2610
                        </div>
                    )
                }
            }
faisalhamdi's avatar
faisalhamdi committed
2611 2612 2613 2614 2615
        }, {
            name: "",
            options: {
                display: false
            }
faisalhamdi's avatar
faisalhamdi committed
2616 2617
        },
        ]
faisalhamdi's avatar
faisalhamdi committed
2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628
        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
2629 2630 2631 2632 2633
        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
2634 2635 2636 2637 2638
                <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
2639
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
faisalhamdi's avatar
faisalhamdi committed
2640
                    {this.state.visibleCATRO ?
faisalhamdi's avatar
faisalhamdi committed
2641 2642 2643 2644 2645 2646 2647 2648
                        <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
2649
                                        <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
2650 2651 2652 2653 2654
                                        {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
2655 2656
                                    </div>
                                    <div style={{ width: '50%' }}>
Riri Novita's avatar
Riri Novita committed
2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710
                                        {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
2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727
                                                    <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
2728
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
Riri Novita's avatar
Riri Novita committed
2729 2730
                                            </div>
                                        }
faisalhamdi's avatar
faisalhamdi committed
2731
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2732
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744

                                <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
2745 2746 2747 2748 2749
                                <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
2750 2751 2752 2753
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
faisalhamdi's avatar
faisalhamdi committed
2754
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
Riri Novita's avatar
Riri Novita committed
2755 2756 2757
                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2758
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2759
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784
                            <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
2785
                                        {this.state.get_for == 'view' && this.state.viewOnly &&
faisalhamdi's avatar
faisalhamdi committed
2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805
                                            <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
2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840
                                        }
                                        {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
2841
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
2842
                                                    :
2843 2844
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859
                                                            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' })
                                                    :
2860 2861
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876
                                                            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
2877
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2878
                        </Paper>
faisalhamdi's avatar
faisalhamdi committed
2879 2880
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
2881
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
faisalhamdi's avatar
faisalhamdi committed
2882 2883 2884 2885 2886 2887
                                <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
2888
                                        <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
2889 2890 2891 2892 2893
                                        {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
2894
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2895
                                    <div style={{ width: '50%' }} />
faisalhamdi's avatar
faisalhamdi committed
2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908
                                </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
2909 2910 2911 2912 2913
                                <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
2914 2915 2916 2917
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
faisalhamdi's avatar
faisalhamdi committed
2918
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
Riri Novita's avatar
Riri Novita committed
2919 2920 2921
                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2922
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2923
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2924 2925 2926 2927 2928 2929
                            <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
2930 2931 2932
                                                this.setState({ visibleCATRO: true, visibleUpload: false }, () => {
                                                    this.handleGetFor('edit')
                                                })
faisalhamdi's avatar
faisalhamdi committed
2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984
                                            }, 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
2985
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
2986
                                                    :
2987 2988
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003
                                                            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' })
                                                    :
3004 3005
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022
                                                            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
3023
                    }
faisalhamdi's avatar
faisalhamdi committed
3024
                </div>
faisalhamdi's avatar
faisalhamdi committed
3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043
                {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
3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060
                            <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>
3061
                            <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
3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089
                        </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
                                        }}
3090
                                        onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0, loading: false })}
Riri Novita's avatar
Riri Novita committed
3091 3092 3093 3094 3095 3096 3097
                                    >
                                        <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
3098 3099 3100
                        </div>
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
3101 3102 3103 3104
            </div>
        )
    }
}