CorporateAnnualTargetOLPA.js 153 KB
Newer Older
r.kurnia's avatar
r.kurnia committed
1
import React, { Component } from 'react'
syadziy's avatar
syadziy committed
2
import { Typography, Paper, createMuiTheme, ThemeProvider, MuiThemeProvider, TableCell, FormControlLabel, Input, withStyles, makeStyles, Snackbar } from '@material-ui/core';
r.kurnia's avatar
r.kurnia committed
3
import MUIDataTable from 'mui-datatables'
faisalhamdi's avatar
faisalhamdi committed
4
import api from '../../api';
r.kurnia's avatar
r.kurnia committed
5 6 7 8 9 10 11
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 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
import Tooltip from '@material-ui/core/Tooltip';

const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());

const options = ct.customOptionsFixedColumn();
const style = {
    position: "sticky",
    left: 0,
    background: "white",
    zIndex: 101,
};
const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100
};

const theme = createMuiTheme({
    overrides: {
        // Style sheet name ⚛️
        MuiInputBase: {
            input: {
                color: '#5198ea'
            }
        }
    },
});

r.kurnia's avatar
r.kurnia committed
52
export default class CorporateAnnualTargetRO extends Component {
faisalhamdi's avatar
faisalhamdi committed
53 54 55
    constructor(props) {
        super(props)
        this.state = {
r.kurnia's avatar
r.kurnia committed
56 57
            dataTable: [],
            loading: true,
faisalhamdi's avatar
faisalhamdi committed
58 59 60 61 62 63 64
            uomList: [],
            formulaYtdList: {
                options: [{ value: 'SUM' }, { value: 'AVG' }, { value: 'LAST' }, { value: 'FORMULA' }],
                getOptionLabel: (option) => titleCase(option.value),
            },
            kpiTypeList: [],
            maxAchList: [],
r.kurnia's avatar
r.kurnia committed
65
            visibleCATRO: true,
faisalhamdi's avatar
faisalhamdi committed
66 67 68 69 70
            buttonError: true,
            dataDelete: [],
            dataReal: [],
            buttonDraft: true,
            updateBy: [],
71
            handleDoubleClick: 0,
faisalhamdi's avatar
faisalhamdi committed
72
            editable: false,
r.kurnia's avatar
r.kurnia committed
73
            get_for: 'view',
r.kurnia's avatar
r.kurnia committed
74
            viewOnly: true,
r.kurnia's avatar
r.kurnia committed
75

faisalhamdi's avatar
faisalhamdi committed
76 77 78 79 80
        }
        this.fileHandler = this.fileHandler.bind(this);
    }

    componentDidMount() {
r.kurnia's avatar
r.kurnia committed
81 82 83
        this.getKPIType()
        this.getMaxAch()
        this.getLatestUpdate()
r.kurnia's avatar
r.kurnia committed
84
        this.handleViewOnly()
r.kurnia's avatar
r.kurnia committed
85 86 87 88 89 90 91
    }

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

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

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

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

        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
r.kurnia's avatar
r.kurnia committed
119
        // this.setState({viewOnly: true})
faisalhamdi's avatar
faisalhamdi committed
120 121 122 123 124
    }

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


        })
    }

r.kurnia's avatar
r.kurnia committed
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
    handleGetFor(type) {
        this.setState({ get_for: type }, () => {
            this.getLatestUpdate()
            this.getItemHierarki()
        })
    }

    getKPIType() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'KPI_TYPE'
        }
        api.create().getAllSettingByType(body).then(response => {
            // console.log(response)
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        // console.log(data)
                        let inputKPI = []

                        data.map((item) => {
                            inputKPI.push({
                                value: item.value
                            })
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
                        // console.log(defaultProps)
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

    getMaxAch() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'MAX_ACHIEVEMENT'
        }
        api.create().getAllSettingByType(body).then(response => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let inputMaxAch = data.map((item) => {
                            return {
                                value: item.value
                            }
                        })
                        let defaultProps = {
                            options: inputMaxAch,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
                        this.setState({ maxAchList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                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
340 341
    downloadTemplate = async () => {
        let res = await fetch(
r.kurnia's avatar
r.kurnia committed
342
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/outlook_pa/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
faisalhamdi's avatar
faisalhamdi committed
343 344 345 346 347 348
        )
        res = await res.blob()
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
r.kurnia's avatar
r.kurnia committed
349
            a.download = 'Template Outlook Performance Appraisal - Corporate Annual Target.xlsx';
faisalhamdi's avatar
faisalhamdi committed
350 351 352 353 354
            a.click();
        }
    }

    async downloadAllData() {
r.kurnia's avatar
r.kurnia committed
355
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/outlook_pa/export_outlook_pa?outlook_pa_id=${this.props.outlook_pa_id}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
r.kurnia's avatar
r.kurnia committed
356
        console.log(url);
faisalhamdi's avatar
faisalhamdi committed
357
        let res = await fetch(
r.kurnia's avatar
r.kurnia committed
358
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/outlook_pa/export_outlook_pa?outlook_pa_id=${this.props.outlook_pa_id}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
faisalhamdi's avatar
faisalhamdi committed
359 360 361 362 363 364 365
        )
        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;
r.kurnia's avatar
r.kurnia committed
366
            a.download = 'Outlook Performance Appraisal - Corporate Annual Target.xlsx';
faisalhamdi's avatar
faisalhamdi committed
367 368 369 370
            a.click();
        }
    }

r.kurnia's avatar
r.kurnia committed
371
    backToOutlookPA(type) {
r.kurnia's avatar
r.kurnia committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
        let data = []
        let stateFR = false
        console.log(this.state.dataTable)
        this.state.dataTable.map(i => {
            if (i[2] !== null) {
                let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
                // console.log(indexID)
                // console.log(i[2])
                if (indexID !== -1) {
                    // console.log(dataTableBaru[indexID][6])
                    if (this.state.dataTable[indexID][5] === 'FINANCIAL PERSPECTIVE') {
                        stateFR = true
                    } else {
                        stateFR = false
                    }
                }
            } else {
                stateFR = false
            }
            // console.log(i[9] == null? "" : i[9].value)
            data.push({
                "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
r.kurnia's avatar
r.kurnia committed
394 395
                // "item_name": String(i[5]),
                // "parent": i[2] == "" ? null : i[2],
r.kurnia's avatar
r.kurnia committed
396 397 398 399
                "weight": String(i[6]),
                "uom": String(i[7]),
                "kpi_type": i[8] == null ? "" : i[8].value,
                "max_ach": i[9] == null ? "" : i[9].value,
r.kurnia's avatar
r.kurnia committed
400
                "formula": i[10] == null ? "" : i[10].value,
r.kurnia's avatar
r.kurnia committed
401 402 403 404 405 406 407 408 409 410 411 412
                "january": stateFR ? i[0] == 3 ? String(i[11]) : String(Number(i[11].value).toFixed(1)) : String(i[11]),
                "february": stateFR ? i[0] == 3 ? String(i[12]) : String(Number(i[12].value).toFixed(1)) : String(i[12]),
                "march": stateFR ? i[0] == 3 ? String(i[13]) : String(Number(i[13].value).toFixed(1)) : String(i[13]),
                "april": stateFR ? i[0] == 3 ? String(i[14]) : String(Number(i[14].value).toFixed(1)) : String(i[14]),
                "may": stateFR ? i[0] == 3 ? String(i[15]) : String(Number(i[15].value).toFixed(1)) : String(i[15]),
                "june": stateFR ? i[0] == 3 ? String(i[16]) : String(Number(i[16].value).toFixed(1)) : String(i[16]),
                "july": stateFR ? i[0] == 3 ? String(i[17]) : String(Number(i[17].value).toFixed(1)) : String(i[17]),
                "august": stateFR ? i[0] == 3 ? String(i[18]) : String(Number(i[18].value).toFixed(1)) : String(i[18]),
                "september": stateFR ? i[0] == 3 ? String(i[19]) : String(Number(i[19].value).toFixed(1)) : String(i[19]),
                "october": stateFR ? i[0] == 3 ? String(i[20]) : String(Number(i[20].value).toFixed(1)) : String(i[20]),
                "november": stateFR ? i[0] == 3 ? String(i[21]) : String(Number(i[21].value).toFixed(1)) : String(i[21]),
                "december": stateFR ? i[0] == 3 ? String(i[22]) : String(Number(i[22].value).toFixed(1)) : String(i[22]),
r.kurnia's avatar
r.kurnia committed
413 414
                "total_current_year": String(Number(i[23]).toFixed(1)) == "" ? "0.0" : String(Number(i[23]).toFixed(1)),
                "strategic": String(i[24]),
r.kurnia's avatar
r.kurnia committed
415 416 417 418 419 420 421 422 423 424
                "pic": String(i[25])
            })
        })
        // console.log(JSON.stringify(data))
        let payload = {
            // "rolling_outlook_id": this.props.rollingOutlookID,
            "outlook_pa_id": this.props.outlook_pa_id,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
r.kurnia's avatar
r.kurnia committed
425
            "quartal": 'q1',
r.kurnia's avatar
r.kurnia committed
426
            "status": type,
r.kurnia's avatar
r.kurnia committed
427 428 429 430
            "cat": data,
            "balance_sheet": [],
            "profit_loss": [],
            "tax_planning": [],
r.kurnia's avatar
r.kurnia committed
431 432
        }
        // console.log(JSON.stringify(payload));
r.kurnia's avatar
r.kurnia committed
433
        api.create('UPLOAD').createReportOLPA(payload).then(response => {
r.kurnia's avatar
r.kurnia committed
434 435
            console.log(payload);
            console.log(response);
r.kurnia's avatar
r.kurnia committed
436
            console.log(JSON.stringify(payload))
r.kurnia's avatar
r.kurnia committed
437 438 439
            if (response.data) {
                if (response.data.status === "success") {
                    this.props.onClickClose()
r.kurnia's avatar
r.kurnia committed
440
                    // this.props.refresh()
r.kurnia's avatar
r.kurnia committed
441
                    this.props.getReport()
r.kurnia's avatar
r.kurnia committed
442
                } else {
443
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
r.kurnia's avatar
r.kurnia committed
444 445 446 447 448 449 450 451
                        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()
r.kurnia's avatar
r.kurnia committed
452
                        // this.props.refresh()
r.kurnia's avatar
r.kurnia committed
453
                        this.props.getReport()
r.kurnia's avatar
r.kurnia committed
454 455 456
                    })
                }
                // else {
457
                //     this.setState({ loading: false, handleDoubleClick: 0 }, () => {
r.kurnia's avatar
r.kurnia committed
458 459 460 461 462
                //         this.props.onClickClose()
                //         this.props.refresh()
                //     })
                // }
            } else {
463
                this.setState({ loading: false, handleDoubleClick: 0 })
r.kurnia's avatar
r.kurnia committed
464 465 466 467
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
468 469 470
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
r.kurnia's avatar
r.kurnia committed
471
            console.log(resp)
faisalhamdi's avatar
faisalhamdi committed
472
            if (err) {
r.kurnia's avatar
r.kurnia committed
473
                // console.log(err);
faisalhamdi's avatar
faisalhamdi committed
474 475 476
            }
            else {
                let isi = resp.rows.slice(3)
r.kurnia's avatar
r.kurnia committed
477
                // console.log(isi);
faisalhamdi's avatar
faisalhamdi committed
478 479 480 481
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
r.kurnia's avatar
r.kurnia committed
482
                        payload.push({
r.kurnia's avatar
r.kurnia committed
483 484 485 486 487 488 489
                            item_report_id: i[0] === undefined ? 0 : reg.test(String(i[0])) === false ? 0 : String(i[0]).trim(),
                            item_report: i[1] === undefined ? "" : String(i[1]).trim(),
                            weight: i[2] === undefined ? "" : String(i[2]).trim(),
                            uom: i[3] === undefined ? "" : String(i[3]).trim(),
                            kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
                            max_ach: i[5] === undefined ? "" : String(i[5]).toLocaleLowerCase() !== 'unlimited' ? (String(i[5]).includes('%') ? String(i[5].trim()) : String(Number(i[5] * 100) + '%')) : String(i[5]).trim(),
                            formula_ytd: i[6] === undefined ? "" : String(i[6]).trim(),
syadziy's avatar
syadziy committed
490 491 492 493 494 495 496 497 498 499 500 501
                            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(),
r.kurnia's avatar
r.kurnia committed
502 503 504
                            strategic_initiative: i[20] === undefined ? "" : String(i[20]).trim(),
                            pic: i[21] === undefined ? "" : String(i[21]).trim()
                        })
faisalhamdi's avatar
faisalhamdi committed
505 506
                    }
                })
r.kurnia's avatar
r.kurnia committed
507
                // console.log(payload)
faisalhamdi's avatar
faisalhamdi committed
508 509 510 511 512
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    cat: payload,
r.kurnia's avatar
r.kurnia committed
513 514
                    outlook_pa_id: this.props.outlook_pa_id,
                    quartal: 'q1',
r.kurnia's avatar
r.kurnia committed
515 516 517 518
                    status: 'submitted',
                    balance_sheet: [],
                    profit_loss: [],
                    tax_planning: [],
faisalhamdi's avatar
faisalhamdi committed
519
                }
r.kurnia's avatar
r.kurnia committed
520
                // console.log(body)
r.kurnia's avatar
r.kurnia committed
521
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
faisalhamdi's avatar
faisalhamdi committed
522 523 524 525 526 527
            }
        });
    }

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

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

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

    handleValidate() {
r.kurnia's avatar
r.kurnia committed
691 692
        this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false })
    }
faisalhamdi's avatar
faisalhamdi committed
693 694 695 696 697 698 699

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

r.kurnia's avatar
r.kurnia committed
728 729 730 731
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804
    render() {
        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))
                    }
                }
            })

            baru.map((item, index) => {
                if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
                    anjay.push(item)
                } else if (item == '' || item == '@') {

                } else if (item == "CurrMonth") {
                    anjay.push(String(column))
                } else if (item.includes('[CM]SUM')) {
                    let columnStart = 13
                    let indexX = String(item).indexOf('[')
                    let formulaAwal = String(item).substr(0, indexX)
                    let columnEnd = 24
                    let month = column - 1
                    let total = 0
                    // // // 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 {

                    }
                    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')
                    // console.log(item)
                    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)

                        if (forecast == undefined) {
                            let convertID = -1
r.kurnia's avatar
r.kurnia committed
805
                            // console.log(tableMeta)
r.kurnia's avatar
r.kurnia committed
806 807 808 809 810 811
                            if (tableMeta.rowData[10].value == 'FORMULA') {
                                // let indexIDReport = dataTable2.findIndex((val) => val[1] == formulaAwal)
                                // convertID = dataTable2[indexIDReport][31]
                                // let indexID = dataTable2.findIndex((val) => val[31] == (convertID == -1 ? item : convertID))
                                // let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
                                // anjay.push(valuezz == "" ? 0 : valuezz)
faisalhamdi's avatar
faisalhamdi committed
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
                            } 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)
                                }
                            }
                        } 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
                            //     anjay.push(valuezz == "" ? 0 : valuezz)
                            // }
                        }

                        anjay.push(operatorX)
                        anjay.push(nilaiX)
                    }
                } else {
                    if (String(item).includes('#')) {
r.kurnia's avatar
r.kurnia committed
837
                        // console.log(item)
faisalhamdi's avatar
faisalhamdi committed
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
                        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)
                            }
                        }

                    } else {
                        let convertID = -1
                        if (tableMeta.rowData[11].value == 'FORMULA') {
                            let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
                            convertID = dataTable2[indexIDReport][31]
                        }
                        let indexID = dataTable2.findIndex((val) => val[31] == (convertID == -1 ? item : convertID))
                        if (indexID !== -1) {
                            let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
                            if (item == dataTable2[tableMeta.rowIndex][31]) {
                                anjay.push(0)
                            } else {
                                anjay.push(valuezz == "" ? "0" : valuezz)
                            }
                        } else {
                            if (item === '(-1)') {
                                anjay.push(-1)
                            }
                        }
                    }
                }
            })
            // if (tableMeta.rowData[11].value == 'FORMULA') {
            //     console.log(anjay)
            //     console.log(column)

            // }

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

            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 {
r.kurnia's avatar
r.kurnia committed
1000 1001 1002 1003 1004
            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
            }
faisalhamdi's avatar
faisalhamdi committed
1005 1006 1007 1008 1009
            // }

            return total
        }

r.kurnia's avatar
r.kurnia committed
1010 1011 1012
        // const handleValueForecast = (value, tableMeta, periode) => {
        //     return handleValueFormula(value, tableMeta, periode, periode, 'forecast')
        // }
faisalhamdi's avatar
faisalhamdi committed
1013 1014 1015 1016 1017
        const handleChangeDropdown = (value, tableMeta) => {
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
            let valz = value.value
            let total = 0
            let lastValz = 0
r.kurnia's avatar
r.kurnia committed
1018
            if (valz == 'SUM' || valz == 'AVG' || valz == 'LAST') {
faisalhamdi's avatar
faisalhamdi committed
1019 1020 1021 1022 1023 1024 1025 1026 1027
                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)
                        }
                    }
                })
r.kurnia's avatar
r.kurnia committed
1028
                dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
faisalhamdi's avatar
faisalhamdi committed
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
            }
        }
        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)
r.kurnia's avatar
r.kurnia committed
1093 1094
                // console.log(indexsss);
                if (dataTable2[indexsss][5] == 'FINANCIAL PERSPECTIVE') {
faisalhamdi's avatar
faisalhamdi committed
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111
                    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
r.kurnia's avatar
r.kurnia committed
1112 1113 1114 1115 1116 1117
            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
1118
                        total += Number(valItem)
r.kurnia's avatar
r.kurnia committed
1119 1120 1121 1122 1123 1124 1125
                        if (index == 22) {
                            lastValz += Number(valItem)
                        }
                    } else {
                        valItem = item == undefined || item == "" ? 0 : item
                        total += Number(valItem)
                        if (index == 22) {
faisalhamdi's avatar
faisalhamdi committed
1126 1127 1128
                            lastValz += Number(valItem)
                        }
                    }
r.kurnia's avatar
r.kurnia committed
1129 1130 1131 1132 1133
                }
            })
            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
1134 1135 1136
            // }
        }

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

                        </div>
                    )
                }
            }
        }, {
            name: "Max Ach.",
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1303
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1304 1305 1306
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
r.kurnia's avatar
r.kurnia committed
1307
                customBodyRender: (val, tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1308 1309 1310 1311
                    return (
                        <div style={{ width: 96 }}>
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
r.kurnia's avatar
r.kurnia committed
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327
                                <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>
                                    }
                                // value={this.state.parent}
                                />
faisalhamdi's avatar
faisalhamdi committed
1328 1329 1330 1331 1332 1333 1334 1335 1336
                            }
                        </div>
                    )
                }
            }
        }, {
            name: "Formula YTD",
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1337
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1338 1339 1340
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
r.kurnia's avatar
r.kurnia committed
1341
                customBodyRender: (val, tableMeta, updateValue) => {
faisalhamdi's avatar
faisalhamdi committed
1342
                    return (
r.kurnia's avatar
r.kurnia committed
1343
                        <div style={{ width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
1344 1345
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
r.kurnia's avatar
r.kurnia committed
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360
                                <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 }}>
r.kurnia's avatar
r.kurnia committed
1361
                                            <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} />
r.kurnia's avatar
r.kurnia committed
1362 1363 1364 1365
                                        </div>
                                    }
                                // value={this.state.parent}
                                />
faisalhamdi's avatar
faisalhamdi committed
1366 1367 1368 1369 1370 1371
                            }
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1372
            name: `Jan ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1373 1374
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1375 1376
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
faisalhamdi's avatar
faisalhamdi committed
1377 1378 1379
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
r.kurnia's avatar
r.kurnia committed
1380
                    // console.log(tableMeta.rowData[0])
faisalhamdi's avatar
faisalhamdi committed
1381 1382
                    return (
                        <div style={{ width: 96 }}>
r.kurnia's avatar
r.kurnia committed
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393
                            {
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1394 1395 1396 1397 1398 1399
                            }
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1400
            name: `Feb ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1401 1402
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1403
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1404 1405 1406 1407 1408 1409 1410 1411
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1412 1413 1414 1415 1416 1417 1418 1419 1420
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1421 1422 1423 1424 1425 1426
                            }
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1427
            name: `Mar ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1428 1429
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1430
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1431 1432 1433 1434 1435 1436 1437 1438
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1439 1440 1441 1442 1443 1444 1445 1446 1447
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1448 1449 1450 1451 1452 1453
                            }
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1454
            name: `Apr ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1455 1456
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1457
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1458 1459 1460 1461 1462 1463 1464 1465
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1466 1467 1468 1469 1470 1471 1472 1473 1474
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
r.kurnia's avatar
r.kurnia committed
1475 1476 1477 1478 1479 1480
                            }
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1481
            name: `May ${this.props.periode}`,
r.kurnia's avatar
r.kurnia committed
1482 1483
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1484
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
r.kurnia's avatar
r.kurnia committed
1485 1486 1487
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1488 1489 1490 1491 1492
                customBodyRender: (value, tableMeta) => {
                    return (
                        <div style={{ width: 96 }}>
                            {
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
r.kurnia's avatar
r.kurnia committed
1493 1494 1495 1496 1497 1498 1499 1500 1501
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
r.kurnia's avatar
r.kurnia committed
1502 1503 1504 1505 1506 1507 1508 1509 1510
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jun ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1511
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
r.kurnia's avatar
r.kurnia committed
1512 1513 1514 1515 1516 1517 1518 1519
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1520 1521 1522 1523 1524 1525 1526 1527 1528
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1529 1530 1531 1532 1533 1534 1535 1536 1537
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jul ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1538
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1539 1540 1541 1542 1543 1544 1545 1546
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1547 1548 1549 1550 1551 1552 1553 1554 1555
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
r.kurnia's avatar
r.kurnia committed
1556 1557 1558 1559 1560 1561 1562 1563 1564
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Aug ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1565
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
r.kurnia's avatar
r.kurnia committed
1566 1567 1568 1569 1570 1571 1572
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
                    return (
                        <div style={{ width: 96 }}>
                            {
faisalhamdi's avatar
faisalhamdi committed
1573
                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
r.kurnia's avatar
r.kurnia committed
1574 1575 1576 1577 1578 1579 1580 1581 1582
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1583 1584 1585 1586 1587 1588 1589 1590 1591
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Sep ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1592
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1593 1594 1595 1596 1597 1598 1599 1600
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1601 1602 1603 1604 1605 1606 1607 1608 1609
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1610 1611 1612 1613 1614 1615 1616 1617 1618
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Oct ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1619
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1620 1621 1622 1623 1624 1625 1626 1627
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1628 1629 1630 1631 1632 1633 1634 1635 1636
                                    null :
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                    />
faisalhamdi's avatar
faisalhamdi committed
1637 1638 1639 1640 1641 1642 1643 1644 1645
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Nov ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1646
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1647 1648 1649 1650 1651 1652 1653 1654
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1655 1656 1657 1658 1659 1660 1661 1662 1663 1664
                                    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}
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                        />
r.kurnia's avatar
r.kurnia committed
1665
                                        :
r.kurnia's avatar
r.kurnia committed
1666 1667
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                            <div style={{ flex: 1 }}>
r.kurnia's avatar
r.kurnia committed
1668 1669 1670 1671 1672 1673 1674 1675 1676 1677
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 11)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1678
                                                            disabled={true}
r.kurnia's avatar
r.kurnia committed
1679 1680 1681 1682
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
r.kurnia's avatar
r.kurnia committed
1683
                                                                // console.log(tableMeta.rowData[0])
r.kurnia's avatar
r.kurnia committed
1684 1685 1686 1687
                                                            }}
                                                        />
                                                    }
                                                />
r.kurnia's avatar
r.kurnia committed
1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 11)).toFixed(1)}
                                                                // value={Number(value).toFixed(1)}
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={false}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
                                        )
faisalhamdi's avatar
faisalhamdi committed
1737 1738 1739 1740 1741 1742 1743 1744 1745
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Dec ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1746
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1747 1748 1749 1750 1751 1752 1753 1754
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
                                    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}
                                            value={tableMeta.rowData[0] === 6 ? Number(value.value).toFixed(1) : Number(value).toFixed(1)}
                                        />
r.kurnia's avatar
r.kurnia committed
1765
                                        :
r.kurnia's avatar
r.kurnia committed
1766 1767
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                            <div style={{ flex: 1 }}>
r.kurnia's avatar
r.kurnia committed
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleValueFormula(value, tableMeta, 12)).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1778
                                                            disabled={true}
r.kurnia's avatar
r.kurnia committed
1779 1780 1781 1782
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
r.kurnia's avatar
r.kurnia committed
1783
                                                                // console.log(tableMeta.rowData[0])
faisalhamdi's avatar
faisalhamdi committed
1784 1785 1786 1787
                                                            }}
                                                        />
                                                    }
                                                />
r.kurnia's avatar
r.kurnia committed
1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleValueFormula(value, tableMeta, 12)).toFixed(1)}
                                                                // value={Number(value).toFixed(1)}
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(value).toFixed(1)}
                                                                disabled={false}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                }
                                            </div>
                                        )
faisalhamdi's avatar
faisalhamdi committed
1837 1838 1839 1840 1841 1842
                            }
                        </div>
                    )
                }
            }
        }, {
r.kurnia's avatar
r.kurnia committed
1843
            name: `${this.props.periode} Total`,
faisalhamdi's avatar
faisalhamdi committed
1844 1845
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1846
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1847 1848 1849 1850 1851 1852 1853 1854
                        <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 ?
r.kurnia's avatar
r.kurnia committed
1855 1856 1857 1858 1859 1860 1861 1862 1863
                                    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}
                                            value={Number(value).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1864
                                        />
r.kurnia's avatar
r.kurnia committed
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901
                                        :
                                        (handleReturnFormula(tableMeta.rowData[2], tableMeta) ?
                                            <div style={{ flex: 1 }}>
                                                <FormControlLabel
                                                    style={{ margin: 0 }}
                                                    value={value}
                                                    control={
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            value={Number(handleTotal(tableMeta)).toFixed(1)}
                                                            disabled={true}
                                                            decimalScale={1}
                                                            onBlur={(event) => {
                                                                // updateValue(event.target.value)
                                                                handleChange(event.target.value, tableMeta)
                                                                // console.log(tableMeta.rowData[0])
                                                            }}
                                                        />
                                                    }
                                                />
                                            </div>
                                            :
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ?
                                                    // null
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
r.kurnia's avatar
r.kurnia committed
1902 1903
                                                                // value={Number(handleValueFormula(value, tableMeta, 13)).toFixed(1)}
                                                                value={Number(value).toFixed(1)}
r.kurnia's avatar
r.kurnia committed
1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936
                                                                disabled
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={value}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                value={Number(handleTotal(tableMeta)).toFixed(1)}
                                                                disabled={true}
                                                                decimalScale={1}
                                                                onBlur={(event) => {
                                                                    // updateValue(event.target.value)
                                                                    handleChange(event.target.value, tableMeta)
                                                                    // console.log(tableMeta.rowData[0])
                                                                }}
                                                            />
                                                        }
                                                    />}
                                            </div>
                                        )
faisalhamdi's avatar
faisalhamdi committed
1937 1938 1939 1940 1941 1942 1943 1944 1945
                            }
                        </div>
                    )
                }
            }
        }, {
            name: "Strategic Initiative",
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1946
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1947 1948 1949 1950 1951 1952 1953 1954
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
r.kurnia's avatar
r.kurnia committed
1955
                                this.state.get_for == "view" ?
r.kurnia's avatar
r.kurnia committed
1956 1957 1958 1959 1960 1961 1962 1963
                                    <Input
                                        disableUnderline={true}
                                        style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        defaultValue={value}
                                    />
r.kurnia's avatar
r.kurnia committed
1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
                                    :
                                    <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=""
r.kurnia's avatar
r.kurnia committed
1975
                                                    disabled={false}
r.kurnia's avatar
r.kurnia committed
1976 1977 1978 1979 1980 1981 1982 1983 1984
                                                    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
1985

r.kurnia's avatar
r.kurnia committed
1986 1987
                                        }
                                    />
faisalhamdi's avatar
faisalhamdi committed
1988 1989 1990 1991 1992 1993 1994 1995 1996
                            }
                        </div>
                    )
                }
            }
        }, {
            name: "PIC",
            options: {
                customHeadRender: (columnMeta) => (
r.kurnia's avatar
r.kurnia committed
1997
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1998 1999 2000 2001 2002 2003 2004 2005
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                null :
r.kurnia's avatar
r.kurnia committed
2006
                                this.state.get_for == "view" ?
r.kurnia's avatar
r.kurnia committed
2007 2008 2009 2010 2011 2012 2013 2014
                                    <Input
                                        disableUnderline={true}
                                        style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
                                        defaultValue={value}
                                    />
r.kurnia's avatar
r.kurnia committed
2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025
                                    :
                                    <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=""
r.kurnia's avatar
r.kurnia committed
2026
                                                    disabled={false}
r.kurnia's avatar
r.kurnia committed
2027 2028 2029 2030 2031 2032 2033 2034 2035
                                                    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
2036

r.kurnia's avatar
r.kurnia committed
2037 2038
                                        }
                                    />
faisalhamdi's avatar
faisalhamdi committed
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064
                            }
                        </div>
                    )
                }
            }
        }, {
            name: "",
            options: {
                display: false
            }
        },
        ]
        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>
        );

        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 }}>
r.kurnia's avatar
r.kurnia committed
2065
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Outlook Performance Appraisal & Revision CAT</Typography>
faisalhamdi's avatar
faisalhamdi committed
2066
                </div>
r.kurnia's avatar
r.kurnia committed
2067
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
faisalhamdi's avatar
faisalhamdi committed
2068 2069 2070 2071 2072
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
r.kurnia's avatar
r.kurnia committed
2073 2074 2075 2076
                    {this.state.visibleCATRO ?
                        <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>
faisalhamdi's avatar
faisalhamdi committed
2077
                            </div>
r.kurnia's avatar
r.kurnia committed
2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
                                        {this.props.isApprover === true || this.state.get_for == 'view' ?
                                            <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">
                                                    <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>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2160

r.kurnia's avatar
r.kurnia committed
2161 2162 2163 2164 2165 2166 2167 2168 2169
                                <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>
faisalhamdi's avatar
faisalhamdi committed
2170
                                </div>
r.kurnia's avatar
r.kurnia committed
2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182

                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
                                        {
                                            this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
                                        }
faisalhamdi's avatar
faisalhamdi committed
2183
                                    </div>
r.kurnia's avatar
r.kurnia committed
2184 2185
                                </div>
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2186
                            </div>
r.kurnia's avatar
r.kurnia committed
2187 2188
                            <div className="grid grid-2x" style={{ padding: 20 }}>
                                <div className="col-1" style={{ paddingLeft: 0 }}>
r.kurnia's avatar
r.kurnia committed
2189 2190
                                    <button
                                        type="button"
r.kurnia's avatar
r.kurnia committed
2191 2192 2193 2194 2195
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
r.kurnia's avatar
r.kurnia committed
2196 2197 2198 2199 2200 2201 2202
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
r.kurnia's avatar
r.kurnia committed
2203 2204
                                        <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>
r.kurnia's avatar
r.kurnia committed
2205 2206
                                        </div>
                                    </button>
r.kurnia's avatar
r.kurnia committed
2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269
                                </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 == 'view' && this.state.viewOnly &&
                                            <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>
                                        }
                                        {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 ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    :
2270 2271
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
r.kurnia's avatar
r.kurnia committed
2272
                                                            this.backToOutlookPA('draft')
r.kurnia's avatar
r.kurnia committed
2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286
                                                        })
                                            }
                                        >
                                            <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' })
                                                    :
2287 2288
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
r.kurnia's avatar
r.kurnia committed
2289
                                                            this.backToOutlookPA('submitted')
r.kurnia's avatar
r.kurnia committed
2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321
                                                        })}
                                            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>
                        :
                        <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>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }} />
                                </div>

                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
r.kurnia's avatar
r.kurnia committed
2322 2323 2324 2325 2326 2327 2328 2329
                                    {this.state.loading && loadingComponent}
                                    <MuiThemeProvider theme={getMuiTheme()}>
                                        <MUIDataTable
                                            data={dataTable2}
                                            columns={columns}
                                            options={options}
                                        />
                                    </MuiThemeProvider>
r.kurnia's avatar
r.kurnia committed
2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347
                                </div>
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
                                        {
                                            this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
                                        }
                                    </div>
                                </div>
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
                            </div>
                            <div className="grid grid-2x" style={{ padding: 20 }}>
                                <div className="col-1" style={{ paddingLeft: 0 }}>
r.kurnia's avatar
r.kurnia committed
2348 2349
                                    <button
                                        type="button"
r.kurnia's avatar
r.kurnia committed
2350 2351 2352 2353 2354 2355 2356
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.setState({ visibleCATRO: true, visibleUpload: false }, () => {
                                                    this.handleGetFor('edit')
                                                })
                                            }, 100);
                                        })}
r.kurnia's avatar
r.kurnia committed
2357 2358 2359 2360 2361 2362 2363
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
r.kurnia's avatar
r.kurnia committed
2364 2365
                                        <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>
r.kurnia's avatar
r.kurnia committed
2366 2367
                                        </div>
                                    </button>
faisalhamdi's avatar
faisalhamdi committed
2368
                                </div>
r.kurnia's avatar
r.kurnia committed
2369 2370 2371 2372 2373
                                {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
faisalhamdi's avatar
faisalhamdi committed
2374 2375 2376 2377 2378 2379
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
r.kurnia's avatar
r.kurnia committed
2380 2381
                                                outline: 'none',
                                                marginRight: 20
faisalhamdi's avatar
faisalhamdi committed
2382
                                            }}
r.kurnia's avatar
r.kurnia committed
2383 2384
                                            onClick={() => {
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2385 2386
                                                    setTimeout(() => {
                                                        this.handleValidate()
r.kurnia's avatar
r.kurnia committed
2387
                                                    }, 100);
faisalhamdi's avatar
faisalhamdi committed
2388
                                                })
r.kurnia's avatar
r.kurnia committed
2389
                                            }}
faisalhamdi's avatar
faisalhamdi committed
2390 2391 2392 2393 2394
                                        >
                                            <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>}
r.kurnia's avatar
r.kurnia committed
2395
                                        {this.state.get_for === 'edit' && <button
faisalhamdi's avatar
faisalhamdi committed
2396 2397 2398 2399
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
r.kurnia's avatar
r.kurnia committed
2400
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
2401 2402 2403 2404
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
r.kurnia's avatar
r.kurnia committed
2405 2406 2407 2408
                                            onClick={() =>
                                                this.state.saveDraft ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    :
2409 2410
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
r.kurnia's avatar
r.kurnia committed
2411
                                                            this.uploadCATOLPA('draft')
faisalhamdi's avatar
faisalhamdi committed
2412 2413 2414 2415 2416 2417 2418
                                                        })
                                            }
                                        >
                                            <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>}
r.kurnia's avatar
r.kurnia committed
2419
                                        {this.state.get_for === 'edit' && <button
faisalhamdi's avatar
faisalhamdi committed
2420
                                            type="button"
r.kurnia's avatar
r.kurnia committed
2421 2422 2423 2424 2425
                                            // disabled={this.state.buttonError}
                                            onClick={() =>
                                                this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data incomplete !', tipeAlert: 'error' })
                                                    :
2426 2427
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
r.kurnia's avatar
r.kurnia committed
2428
                                                            this.uploadCATOLPA('submitted')
r.kurnia's avatar
r.kurnia committed
2429
                                                        })}
faisalhamdi's avatar
faisalhamdi committed
2430 2431
                                            style={{
                                                backgroundColor: 'transparent',
r.kurnia's avatar
r.kurnia committed
2432
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
2433
                                                borderColor: 'transparent',
r.kurnia's avatar
r.kurnia committed
2434
                                                outline: 'none',
faisalhamdi's avatar
faisalhamdi committed
2435 2436 2437 2438 2439 2440
                                            }}
                                        >
                                            <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>}
r.kurnia's avatar
r.kurnia committed
2441 2442
                                    </div>
                                }
faisalhamdi's avatar
faisalhamdi committed
2443
                            </div>
r.kurnia's avatar
r.kurnia committed
2444 2445
                        </Paper>
                    }
faisalhamdi's avatar
faisalhamdi committed
2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475
                </div>
                {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>
                            <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={() => {
r.kurnia's avatar
r.kurnia committed
2476
                                    String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("PA") && String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("CAT") ?
faisalhamdi's avatar
faisalhamdi committed
2477 2478 2479 2480 2481 2482 2483 2484
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
            </div>
r.kurnia's avatar
r.kurnia committed
2485
        )
faisalhamdi's avatar
faisalhamdi committed
2486 2487
    }
}