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

const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);
Deni Rinaldi's avatar
Deni Rinaldi committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());

const options = ct.customOptionsFixedColumn();

const style = {
    position: "sticky",
    left: 0,
    zIndex: 101,
    background: "white",
};
const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100
};

export default class BalanceSheetRO extends Component {
42 43 44 45 46 47
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
            loading: true,
            get_for: "view",
faisalhamdi's avatar
faisalhamdi committed
48
            viewOnly: true,
Riri Novita's avatar
Riri Novita committed
49
            updateBy: [],
50
            editable: false,
51
            handleDoubleClick: 0,
52 53 54 55 56 57
            saveDraft: true,
            minValue: 0,
            maxValue: 0,
            alert: false,
            tipeAlert: '',
            messageAlert: '',
d.arizona's avatar
d.arizona committed
58
            visibleUpload: false,
faisalhamdi's avatar
faisalhamdi committed
59 60
            visibleBSRO: true,
            kansas: 0
61 62 63 64
        }
    }

    componentDidMount() {
Deni Rinaldi's avatar
Deni Rinaldi committed
65
        console.log(this.props);
66
        // this.getItemHierarki()
d.arizona's avatar
d.arizona committed
67
        this.getLatestUpdate()
68
        this.getSettingControl()
d.arizona's avatar
d.arizona committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
        this.handleViewOnly()
    }

    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
        let checkPrevRev = false

        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
        }
Riri Novita's avatar
Riri Novita committed
101 102 103 104
        // console.log(this.props.isApprover);
        // console.log(this.props.lastStatus);
        // console.log(this.props.prevRevision);
        // console.log(this.props.status);
faisalhamdi's avatar
faisalhamdi committed
105

Riri Novita's avatar
Riri Novita committed
106 107 108 109
        // console.log(!checkApprover);
        // console.log(checkLastStatus);
        // console.log(checkStatus);
        // console.log(checkPrevRev);
d.arizona's avatar
d.arizona committed
110
        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
    }

    getSettingControl() {
        let body = {
            group: 'THRESHOLD_CONTROL',
            company_id: this.props.company.company_id,
            type: 'BALANCE_SHEET'
        }

        api.create().getAllSettingByType(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({
                        minValue: response.data.data[0] ? response.data.data[0].min_value : null,
                        maxValue: response.data.data[0] ? response.data.data[0].max_value : null,
                    }, () => {
                        this.getItemHierarki()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
132
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
133 134 135 136 137 138 139 140 141 142 143
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
144 145
    }

d.arizona's avatar
d.arizona committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159
    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,
            "rolling_outlook_id": this.props.rollingOutlookID,
            "quartal": this.props.quarter
        }
        api.create().getRollingOutlookLastUpdate(payload).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
160
                        updateBy: response.data.data.detail === null ? [] : response.data.data.detail,
d.arizona's avatar
d.arizona committed
161 162 163 164
                        notes: response.data.data.notes_update === null ? "" : response.data.data.notes_update
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
165
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
166 167 168 169 170 171 172 173 174 175 176 177 178
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

179 180 181 182 183 184 185 186 187
    getItemHierarki() {
        this.setState({ loading: true, judulColumn: null })
        let payload = {
            "company_id": this.props.company.company_id,
            "get_for": this.state.get_for,
            "months": 0,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
d.arizona's avatar
d.arizona committed
188
            "quartal": this.props.quarter,
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
            "rolling_outlook_id": this.props.rollingOutlookID
        }
        api.create().getRollingOutlookBS(payload).then(response => {
            console.log(response);
            let dataTable = []
            if (response.data) {
                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) {
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
d.arizona's avatar
d.arizona committed
207
                                item.balance_sheet.total_last_year === "" ? "0" : item.balance_sheet.total_last_year,
Riri Novita's avatar
Riri Novita committed
208 209 210 211 212 213 214 215 216 217 218 219
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.january).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.january, formula: item.balance_sheet.january_formula } : Number(item.balance_sheet.january).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.february).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.february, formula: item.balance_sheet.february_formula } : Number(item.balance_sheet.february).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.march).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.march, formula: item.balance_sheet.march_formula } : Number(item.balance_sheet.march).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.april).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.april, formula: item.balance_sheet.april_formula } : Number(item.balance_sheet.april).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.may).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.may, formula: item.balance_sheet.may_formula } : Number(item.balance_sheet.may).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.june).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.june, formula: item.balance_sheet.june_formula } : Number(item.balance_sheet.june).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.july).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.july, formula: item.balance_sheet.july_formula } : Number(item.balance_sheet.july).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.august).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.august, formula: item.balance_sheet.august_formula } : Number(item.balance_sheet.august).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.september).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.september, formula: item.balance_sheet.september_formula } : Number(item.balance_sheet.september).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.october).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.october, formula: item.balance_sheet.october_formula } : Number(item.balance_sheet.october).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.november).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.november, formula: item.balance_sheet.november_formula } : Number(item.balance_sheet.november).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.balance_sheet.december).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.december, formula: item.balance_sheet.december_formula } : Number(item.balance_sheet.december).toFixed(1),
d.arizona's avatar
d.arizona committed
220
                                item.balance_sheet.total_current_year === "" ? "0" : item.balance_sheet.total_current_year,
221 222
                                item.order,
                                item.condition_it_should_be,
Riri Novita's avatar
Riri Novita committed
223 224
                                item.condition_if_wrong,
                                item.balance_sheet.forecast_formula == null ? [] : item.balance_sheet.forecast_formula
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
                            ])
                        }
                        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,
d.arizona's avatar
d.arizona committed
243
                            item.balance_sheet.total_last_year === "" ? "0" : item.balance_sheet.total_last_year,
Riri Novita's avatar
Riri Novita committed
244 245 246 247 248 249 250 251 252 253 254 255
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.january).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.january, formula: item.balance_sheet.january_formula } : Number(item.balance_sheet.january).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.february).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.february, formula: item.balance_sheet.february_formula } : Number(item.balance_sheet.february).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.march).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.march, formula: item.balance_sheet.march_formula } : Number(item.balance_sheet.march).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.april).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.april, formula: item.balance_sheet.april_formula } : Number(item.balance_sheet.april).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.may).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.may, formula: item.balance_sheet.may_formula } : Number(item.balance_sheet.may).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.june).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.june, formula: item.balance_sheet.june_formula } : Number(item.balance_sheet.june).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.july).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.july, formula: item.balance_sheet.july_formula } : Number(item.balance_sheet.july).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.august).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.august, formula: item.balance_sheet.august_formula } : Number(item.balance_sheet.august).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.september).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.september, formula: item.balance_sheet.september_formula } : Number(item.balance_sheet.september).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.october).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.october, formula: item.balance_sheet.october_formula } : Number(item.balance_sheet.october).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.november).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.november, formula: item.balance_sheet.november_formula } : Number(item.balance_sheet.november).toFixed(1),
                            this.props.status === 'CLOSED' ? Number(item.balance_sheet.december).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.balance_sheet.december, formula: item.balance_sheet.december_formula } : Number(item.balance_sheet.december).toFixed(1),
d.arizona's avatar
d.arizona committed
256
                            item.balance_sheet.total_current_year === "" ? "0" : item.balance_sheet.total_current_year,
257 258
                            item.order,
                            item.condition_it_should_be,
Riri Novita's avatar
Riri Novita committed
259 260
                            item.condition_if_wrong,
                            item.balance_sheet.forecast_formula == null ? [] : item.balance_sheet.forecast_formula
261 262 263 264 265 266 267 268 269
                        ])
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
                        }
                    })
rifkaki's avatar
rifkaki committed
270
                    console.log(dataTable)
271 272 273
                    this.setState({ dataTable, loading: false, buttonError: true, editable: true })
                } else {
                    this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
274
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
275 276 277 278 279 280 281 282 283 284 285 286 287
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ dataTable, loading: false, buttonError: true, editable: true })
            }
        })
    }

rifkaki's avatar
rifkaki committed
288
    downloadTemplate = async () => {
d.arizona's avatar
d.arizona committed
289 290 291 292 293
        // alert('Coming Soon ...')
        let res = await fetch(
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/rolling_outlook/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&quartal=${this.props.quarter}`
        )
        res = await res.blob()
d.arizona's avatar
d.arizona committed
294
        console.log(`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/rolling_outlook/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&quartal=${this.props.quarter}`)
d.arizona's avatar
d.arizona committed
295 296 297 298 299 300 301
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Template Rolling Outlook Balance Sheet.xlsx';
            a.click();
        }
d.arizona's avatar
d.arizona committed
302
        setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
303
            this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
304
        }, 500);
rifkaki's avatar
rifkaki committed
305 306 307
    }

    async downloadAllData() {
d.arizona's avatar
d.arizona committed
308 309 310 311 312 313 314 315 316 317 318 319 320 321
        // alert('Coming Soon ...')
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/rolling_outlook/export_rolling_outlook?rolling_outlook_id=${this.props.rollingOutlookID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&quartal=${this.props.quarter}`
        console.log(url);
        let res = await fetch(
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/rolling_outlook/export_rolling_outlook?rolling_outlook_id=${this.props.rollingOutlookID === null ? "" : this.props.rollingOutlookID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&quartal=${this.props.quarter}`
        )
        res = await res.blob()
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Rolling Outlook Balance Sheet.xlsx';
            a.click();
        }
d.arizona's avatar
d.arizona committed
322
        setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
323
            this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
324
        }, 500);
rifkaki's avatar
rifkaki committed
325 326 327
    }

    handleGetFor(type) {
rifkaki's avatar
rifkaki committed
328
        console.log(type)
faisalhamdi's avatar
faisalhamdi committed
329
        this.setState({ get_for: type }, () => {
rifkaki's avatar
rifkaki committed
330
            // this.getSettingControl()
d.arizona's avatar
d.arizona committed
331
            this.getLatestUpdate()
rifkaki's avatar
rifkaki committed
332 333 334 335
            this.getItemHierarki()
        })
    }

rifkaki's avatar
rifkaki committed
336 337 338 339 340 341 342 343

    backToRollingOutlook(type) {
        this.setState({ loading: true })
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                "item_report_id": i[1],
                "total_december_last_year": String(Number(i[6]).toFixed(1)),
d.arizona's avatar
d.arizona committed
344 345 346 347 348 349 350 351 352 353 354 355
                "january": i[7].value !== undefined ? String(Number(i[7].value).toFixed(1)) : String(Number(i[7]).toFixed(1)),
                "february": i[8].value !== undefined ? String(Number(i[8].value).toFixed(1)) : String(Number(i[8]).toFixed(1)),
                "march": i[9].value !== undefined ? String(Number(i[9].value).toFixed(1)) : String(Number(i[9]).toFixed(1)),
                "april": i[10].value !== undefined ? String(Number(i[10].value).toFixed(1)) : String(Number(i[10]).toFixed(1)),
                "may": i[11].value !== undefined ? String(Number(i[11].value).toFixed(1)) : String(Number(i[11]).toFixed(1)),
                "june": i[12].value !== undefined ? String(Number(i[12].value).toFixed(1)) : String(Number(i[12]).toFixed(1)),
                "july": i[13].value !== undefined ? String(Number(i[13].value).toFixed(1)) : String(Number(i[13]).toFixed(1)),
                "august": i[14].value !== undefined ? String(Number(i[14].value).toFixed(1)) : String(Number(i[14]).toFixed(1)),
                "september": i[15].value !== undefined ? String(Number(i[15].value).toFixed(1)) : String(Number(i[15]).toFixed(1)),
                "october": i[16].value !== undefined ? String(Number(i[16].value).toFixed(1)) : String(Number(i[16]).toFixed(1)),
                "november": i[17].value !== undefined ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1)),
                "december": i[18].value !== undefined ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1)),
rifkaki's avatar
rifkaki committed
356 357 358 359 360 361 362 363
                "total_december_year": String(Number(i[19]).toFixed(1))
            })
        })
        let payload = {
            "rolling_outlook_id": this.props.rollingOutlookID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
d.arizona's avatar
d.arizona committed
364
            "quartal": this.props.quarter,
rifkaki's avatar
rifkaki committed
365 366 367 368 369 370 371 372 373
            "status": type,
            "balance_sheet": data
        }
        api.create('UPLOAD').createRollingOutlookBS(payload).then(response => {
            console.log(payload);
            console.log(response);
            // console.log(JSON.stringify(payload))
            if (response.data) {
                if (response.data.status === "success") {
Faisal Hamdi's avatar
Faisal Hamdi committed
374 375
                    if (type == 'submitted') {
                        this.props.onClickClose()
d.arizona's avatar
d.arizona committed
376 377 378 379 380 381 382 383 384 385 386 387
                        this.props.refresh('BS')
                    // let bodyRatioRO = {
                    //     "report": 'ratio',
                    //     "rollingOutlookId": this.props.rollingOutlookID,
                    //     "periode": this.props.periode,
                    //     "companyId": this.props.company.company_id,
                    //     "quartal": this.props.quarter
                    // }
                    // api.create().triggerRatioRO(bodyRatioRO).then((res) => {
                    //     console.log(res)
                    //     this.setState({ loading: false })
                    // })
Faisal Hamdi's avatar
Faisal Hamdi committed
388 389 390
                    } else {
                        this.props.onClickClose()
                        this.props.refresh()
Faisal Hamdi's avatar
Faisal Hamdi committed
391
                    }
rifkaki's avatar
rifkaki committed
392
                } else {
393
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
Riri Novita's avatar
Riri Novita committed
394
                        document.body.style.overflow = 'unset';
d.arizona's avatar
d.arizona committed
395
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
396 397 398 399 400
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
rifkaki's avatar
rifkaki committed
401
                        this.props.onClickClose()
d.arizona's avatar
d.arizona committed
402
                        this.props.refresh()
rifkaki's avatar
rifkaki committed
403 404
                    })
                }
Riri Novita's avatar
Riri Novita committed
405
                // else {
406
                //     this.setState({ loading: false, handleDoubleClick: 0 }, () => {
Riri Novita's avatar
Riri Novita committed
407 408 409 410 411
                //         // this.props.saveToMonthlyReport()
                //         this.props.onClickClose()
                //         this.props.refresh()
                //     })
                // }
rifkaki's avatar
rifkaki committed
412
            } else {
413
                this.setState({ loading: false, handleDoubleClick: 0 })
rifkaki's avatar
rifkaki committed
414 415 416 417 418 419
            }
        })
    }
    handleValidate() {
        let err = false
        let kansas = this.state.kansas
faisalhamdi's avatar
faisalhamdi committed
420 421 422 423 424 425 426
        let dataTable = this.state.dataTable
        // console.log(this.state.dataTable)
        dataTable.map((i, index) => {
            if (String(i[5]) == "Control (should be nil)") {
                this.setState({ loading: true })
                let n = 0
                for (n = (this.props.quarter == 'q1' ? 10 : (this.props.quarter == 'q2' ? 13 : 16)); n <= 18; n++) {
427
                    if ((Number(i[n]).toFixed(2) < Number(this.state.minValue) || Number(i[n]).toFixed(2) > Number(this.state.maxValue))) {
faisalhamdi's avatar
faisalhamdi committed
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
                        err = true
                    }
                }
            }
        })
        console.log(err)
        if (err === false) {
            this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
            if (kansas == 0) {
                this.setState({ kansas: 1, loading: true }, () => {
                    this.handleValidate()
                })
            } else {
                this.setState({ kansas: 0 })
            }
        } else {
            this.setState({ loading: false, buttonError: true, editable: true, saveDraft: true })
            if (kansas == 0) {
                this.setState({ kansas: 1, loading: true }, () => {
                    this.handleValidate()
                })
            } else {
                this.setState({ kansas: 0 })
            }
        }
rifkaki's avatar
rifkaki committed
453 454 455 456 457 458
    }

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

d.arizona's avatar
d.arizona committed
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                // console.log(resp.rows[2]);
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
                            orders: i[0] === undefined ? "" : String(i[0]).trim(),
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
d.arizona's avatar
d.arizona committed
477 478 479 480 481 482 483 484 485 486 487 488 489
                            "january": i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
                            "february": i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
                            "march": i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
                            "april": i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
                            "may": i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
                            "june": i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
                            "july": i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
                            "august": i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
                            "september": i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
                            "october": i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
                            "november": i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
                            "december": i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
                            "total_december_year": i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
d.arizona's avatar
d.arizona committed
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    balance_sheet: payload,
                    rolling_outlook_id: this.props.rollingOutlookID,
                    quartal: this.props.quarter,
                    status: 'submitted'
                }
                console.log(body)
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
            }
        });
    }

    checkUpload() {
        api.create().checkImportRollingOutlookBS(this.state.payload).then(response => {
            // console.log(JSON.stringify(this.state.payload));
            console.log(response)
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, visibleBSRO: false, loading: true })
                    let err = false
                    let dataTable = response.data.data.map((item, index) => {
                        // if (item.type_report_id === 3) {    
                        //     if (item.mtd_vs_mb == "" &&  Number(item.percent_act_vs_mb) < this.state.minValue || Number(item.percent_act_vs_mb) > this.state.maxValue) {
                        //         err = true
                        //     }
                        // }
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.item_report,
                            item.total_december_last_year === "" ? "0" : item.total_december_last_year,
faisalhamdi's avatar
faisalhamdi committed
530 531 532 533 534 535 536 537 538 539 540 541
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.january, formula: item.january_formula } : Number(item.january).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.february, formula: item.february_formula } : Number(item.february).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.march, formula: item.march_formula } : Number(item.march).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.april, formula: item.april_formula } : Number(item.april).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.may, formula: item.may_formula } : Number(item.may).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.june, formula: item.june_formula } : Number(item.june).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.july, formula: item.july_formula } : Number(item.july).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.august, formula: item.august_formula } : Number(item.august).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.september, formula: item.september_formula } : Number(item.september).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.october, formula: item.october_formula } : Number(item.october).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.november, formula: item.november_formula } : Number(item.november).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.december, formula: item.december_formula } : Number(item.december).toFixed(1),
d.arizona's avatar
d.arizona committed
542 543 544
                            item.total_december_year === "" ? "0" : item.total_december_year,
                            item.order,
                            item.condition_it_should_be,
faisalhamdi's avatar
faisalhamdi committed
545 546
                            item.condition_if_wrong,
                            item.forecast_formula == null ? [] : item.forecast_formula
d.arizona's avatar
d.arizona committed
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
                        ]
                    })
                    console.log(dataTable)
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: true, isUpload: true }, () => {
                        this.state.dataTable.map(item => {
                            // if (item[24].length > 0) {
                            //     // console.log('masuk')
                            //     this.setState({ buttonError: true, errorPreview: true })
                            // }
                        })
                        // console.log(this.state.buttonError)
                    })
                }
            }
        })
    }

    uploadBSRO(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                "item_report_id": i[1],
                "total_december_last_year": String(Number(i[6]).toFixed(1)),
d.arizona's avatar
d.arizona committed
570 571 572 573 574 575 576 577 578 579 580 581
                "january": i[7].value !== undefined ? String(Number(i[7].value).toFixed(1)) : String(Number(i[7]).toFixed(1)),
                "february": i[8].value !== undefined ? String(Number(i[8].value).toFixed(1)) : String(Number(i[8]).toFixed(1)),
                "march": i[9].value !== undefined ? String(Number(i[9].value).toFixed(1)) : String(Number(i[9]).toFixed(1)),
                "april": i[10].value !== undefined ? String(Number(i[10].value).toFixed(1)) : String(Number(i[10]).toFixed(1)),
                "may": i[11].value !== undefined ? String(Number(i[11].value).toFixed(1)) : String(Number(i[11]).toFixed(1)),
                "june": i[12].value !== undefined ? String(Number(i[12].value).toFixed(1)) : String(Number(i[12]).toFixed(1)),
                "july": i[13].value !== undefined ? String(Number(i[13].value).toFixed(1)) : String(Number(i[13]).toFixed(1)),
                "august": i[14].value !== undefined ? String(Number(i[14].value).toFixed(1)) : String(Number(i[14]).toFixed(1)),
                "september": i[15].value !== undefined ? String(Number(i[15].value).toFixed(1)) : String(Number(i[15]).toFixed(1)),
                "october": i[16].value !== undefined ? String(Number(i[16].value).toFixed(1)) : String(Number(i[16]).toFixed(1)),
                "november": i[17].value !== undefined ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1)),
                "december": i[18].value !== undefined ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1)),
d.arizona's avatar
d.arizona committed
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
                "total_december_year": String(Number(i[19]).toFixed(1))
            })
        })
        let payload = {
            "rolling_outlook_id": this.props.rollingOutlookID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "quartal": this.props.quarter,
            "status": type,
            "balance_sheet": data
        }
        api.create('UPLOAD').importRollingOutlookBS(payload).then(response => {
            console.log(payload);
            console.log(response);
            // console.log(JSON.stringify(payload))
            if (response.data) {
                if (response.data.status === "success") {
Faisal Hamdi's avatar
Faisal Hamdi committed
600 601
                    if (type == 'submitted') {
                        this.props.onClickClose()
d.arizona's avatar
d.arizona committed
602 603 604 605 606 607 608 609 610 611 612 613
                        this.props.refresh('BS')
                        // let bodyRatioRO = {
                        //     "report": 'ratio',
                        //     "rollingOutlookId": this.props.rollingOutlookID,
                        //     "periode": this.props.periode,
                        //     "companyId": this.props.company.company_id,
                        //     "quartal": this.props.quarter
                        // }
                        // api.create().triggerRatioRO(bodyRatioRO).then((res) => {
                        //     console.log(res)
                        //     this.setState({ loading: false })
                        // })
Faisal Hamdi's avatar
Faisal Hamdi committed
614 615 616
                    } else {
                        this.props.onClickClose()
                        this.props.refresh()
Faisal Hamdi's avatar
Faisal Hamdi committed
617
                    }
d.arizona's avatar
d.arizona committed
618
                } else {
619
                    this.setState({ loading: false, handleDoubleClick: 0 }, () => {
d.arizona's avatar
d.arizona committed
620 621 622 623 624 625
                        // this.props.saveToMonthlyReport()
                        this.props.onClickClose()
                        this.props.refresh()
                    })
                }
            } else {
626
                this.setState({ loading: false, handleDoubleClick: 0 })
d.arizona's avatar
d.arizona committed
627 628 629 630
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
631
    render() {
rifkaki's avatar
rifkaki committed
632
        let dataTable2 = this.state.dataTable
rifkaki's avatar
rifkaki committed
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666

        const handleChange = (value, tableMeta, type) => {
            let val = String(value).split(",").join("")
            if (type === "actual") {
                console.log('masuk')
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val).toFixed(1)
            } else {
                console.log('masuk2')
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
                    // console.log(indexParent)
                    let a = 0
                    if (type == 'r/e') {
                        // console.log('masuk8')
                        a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = Number(val).toFixed(1)
                    } else {
                        // console.log('masuk9')
                        a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val).toFixed(1)
                    }
                    let jagain = dataTable2[indexParent][tableMeta.columnIndex]
                    a = dataTable2[indexParent][tableMeta.columnIndex] = jagain === undefined ? (0 + Number(val)).toFixed(1) : Number(jagain + Number(val)).toFixed(1)
                } else {
                    // console.log('masuk3')
                    if (type == 'r/e') {
                        // console.log('masuk4')
                        dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = Number(val).toFixed(1)
                    } else {
                        // console.log('masuk5')
                        dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val).toFixed(1)
                    }
                }
            }
        }

faisalhamdi's avatar
faisalhamdi committed
667
        const handleValue = (data) => {
rifkaki's avatar
rifkaki committed
668 669
            let total = 0
            dataTable2.map((item, index) => {
faisalhamdi's avatar
faisalhamdi committed
670 671 672
                // if (data.rowData[5] == 'Retained Earnings') {
                //     console.log(item[data.columnIndex].value)
                // }
rifkaki's avatar
rifkaki committed
673
                if (data.rowData[1] === item[2]) {
faisalhamdi's avatar
faisalhamdi committed
674 675
                    let itemVal = item[data.columnIndex].value !== undefined ? Number(item[data.columnIndex].value) : Number(item[data.columnIndex])
                    total = item[data.columnIndex] === undefined ? Number(total) + 0 : Number(total) + itemVal
rifkaki's avatar
rifkaki committed
676 677 678
                }
            })
            let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
faisalhamdi's avatar
faisalhamdi committed
679
            let a = dataTable2[data.rowIndex][data.columnIndex] = Number(total).toFixed(1)
rifkaki's avatar
rifkaki committed
680
            // console.log(indexParent);
faisalhamdi's avatar
faisalhamdi committed
681 682 683 684 685 686
            return a
        }

        const handleValidation = (data, tableMeta) => {
            let a = handleValueFormula(data, tableMeta)
            return a
rifkaki's avatar
rifkaki committed
687 688
        }

689
        const handleTotal = (tableMeta) => {
d.arizona's avatar
d.arizona committed
690 691
            let total = 0
            tableMeta.rowData.map((item, index) => {
faisalhamdi's avatar
faisalhamdi committed
692 693 694 695
                if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "r/e (cummulative)") {
                    total = String(Number(tableMeta.rowData[7]).toFixed(1))
                    dataTable2[tableMeta.rowIndex][19] = total
                } else if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd") {
d.arizona's avatar
d.arizona committed
696
                    if (index >= 7 && index <= 18) {
faisalhamdi's avatar
faisalhamdi committed
697 698 699
                        total += Number(item.value)
                    }
                } else if (index == 18) {
700
                    total = isNaN(item) ? Number(item.value) : Number(item)
faisalhamdi's avatar
faisalhamdi committed
701 702 703 704 705 706
                }
            })
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
            return total
        }

Riri Novita's avatar
Riri Novita committed
707 708 709 710
        const handleForecast = (tableMeta, periode, column) => {
            let total = 0
            // console.log(tableMeta.rowData)

Riri Novita's avatar
Riri Novita committed
711
            // console.log( dataTable2[tableMeta.rowIndex][23])
Riri Novita's avatar
Riri Novita committed
712 713 714 715 716 717 718 719 720 721 722 723
            // console.log(total)
            // dataTable2[tableMeta.rowIndex][column] = total
            if (column == 19 && String(tableMeta.rowData[5]).toLocaleLowerCase() == "r/e (cummulative)") {
                total = tableMeta.rowData[7].value
                dataTable2[tableMeta.rowIndex][column] = tableMeta.rowData[7].value
            } else {
                total = handleValueFormula(dataTable2[tableMeta.rowIndex][column], tableMeta, column, periode, dataTable2[tableMeta.rowIndex][23])
            }
            // console.log(total)
            return total
        }

d.arizona's avatar
d.arizona committed
724
        const handleValueFormula = (value, tableMeta, colIdx, periode, forecast) => {
rifkaki's avatar
rifkaki committed
725 726 727 728 729 730 731 732
            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 re = /^[a-zA-Z0-9_]+$/;
                if (item !== "") {
faisalhamdi's avatar
faisalhamdi committed
733 734 735 736 737 738 739
                    if (!re.test(items)) {
                        if (String(item).substr(Number(String(item).length) - 1, 1) === ']') {
                            baru.push(String(item))
                        } else {
                            baru.push(String(item).substr(0, Number(String(item).length) - 1))
                            baru.push(String(item).substr(Number(String(item).length) - 1, 1))
                        }
rifkaki's avatar
rifkaki committed
740 741 742 743 744 745
                    } else {
                        baru.push(String(item))
                    }
                }
            })

faisalhamdi's avatar
faisalhamdi committed
746 747 748 749 750 751
            // if (tableMeta.columnIndex == 7) {
            //     console.log(splitFormula)
            //     console.log(baru)
            // }
            // console.log(baru)

rifkaki's avatar
rifkaki committed
752
            baru.map((item, index) => {
faisalhamdi's avatar
faisalhamdi committed
753
                if (item == '-' || item == '+' || item == '/' || item == '*') {
rifkaki's avatar
rifkaki committed
754 755 756
                    anjay.push(item)
                } else {
                    if (String(item).includes('#')) {
d.arizona's avatar
d.arizona committed
757 758 759 760 761 762 763 764 765
                        if (forecast !== undefined) {
                            let forecastt = 0
                            forecast.map((items, index) => {
                                if (items.periode == periode) {
                                    forecastt += Number(items.value)
                                }
                            })
                            anjay.push(forecastt)
                        } else if (String(item).includes('[M-1]')) {
rifkaki's avatar
rifkaki committed
766
                            let tst = String(item).replace('[M-1]', '')
faisalhamdi's avatar
faisalhamdi committed
767 768 769 770 771
                            let data = tableMeta.columnIndex == 7 ? 18 : tableMeta.columnIndex - 1
                            let period = data == 18 ? Number(this.props.periode) - 1 : this.props.periode
                            // console.log(tableMeta.columnIndex)
                            let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
                            // console.log(indexID)
rifkaki's avatar
rifkaki committed
772
                            if (indexID !== -1) {
faisalhamdi's avatar
faisalhamdi committed
773 774
                                let valuezz = tableMeta.rowData[data].formula[indexID].value
                                // baru.push(valuezz)
rifkaki's avatar
rifkaki committed
775
                                anjay.push(valuezz == "" ? 0 : valuezz)
faisalhamdi's avatar
faisalhamdi committed
776
                                // console.log(valuezz)
rifkaki's avatar
rifkaki committed
777 778
                            }
                        } else {
faisalhamdi's avatar
faisalhamdi committed
779
                            let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
Riri Novita's avatar
Riri Novita committed
780
                            // console.log(indexID)
rifkaki's avatar
rifkaki committed
781
                            if (indexID !== -1) {
faisalhamdi's avatar
faisalhamdi committed
782 783
                                // console.log(value.formula[indexID].value)
                                let valuezz = value.formula[indexID].value
rifkaki's avatar
rifkaki committed
784 785 786
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        }
faisalhamdi's avatar
faisalhamdi committed
787 788 789
                    } else if (String(item).includes('[M-1]')) {
                        let tst = String(item).replace('[M-1]', '')
                        if (tableMeta.columnIndex === 7) {
faisalhamdi's avatar
faisalhamdi committed
790
                            let indexID = dataTable2.findIndex((val) => val[20] == tst)
rifkaki's avatar
rifkaki committed
791
                            if (indexID !== -1) {
faisalhamdi's avatar
faisalhamdi committed
792 793
                                let valuezz = dataTable2[indexID][6]
                                anjay.push(valuezz == "" ? 0 : valuezz)
rifkaki's avatar
rifkaki committed
794 795
                            }
                        } else {
faisalhamdi's avatar
faisalhamdi committed
796 797
                            let data = tableMeta.columnIndex - 1
                            let indexID = dataTable2.findIndex((val) => val[20] == tst)
rifkaki's avatar
rifkaki committed
798
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
799
                                let valuezz = dataTable2[indexID][data].value !== undefined ? dataTable2[indexID][data].value : dataTable2[indexID][data]
faisalhamdi's avatar
faisalhamdi committed
800
                                anjay.push(valuezz == "" ? 0 : valuezz)
rifkaki's avatar
rifkaki committed
801
                            }
faisalhamdi's avatar
faisalhamdi committed
802
                            // console.log(tst, data, tableMeta.rowData[data]);
rifkaki's avatar
rifkaki committed
803 804
                        }
                    } else {
faisalhamdi's avatar
faisalhamdi committed
805 806 807 808 809 810 811 812 813 814 815 816
                        let indexID = dataTable2.findIndex((val) => val[20] == item)
                        // console.log(dataTable2[indexID])
                        if (indexID !== -1) {
                            let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
                            anjay.push(valuezz == "" ? 0 : valuezz)
                        } else {
                            if (item === '(-1)') {
                                anjay.push(-1)
                            }
                            // console.log(item);

                        }
rifkaki's avatar
rifkaki committed
817 818 819
                    }
                }
            })
faisalhamdi's avatar
faisalhamdi committed
820
            // console.log(anjay)
rifkaki's avatar
rifkaki committed
821 822 823

            let total = 0
            let opt = ""
faisalhamdi's avatar
faisalhamdi committed
824 825 826 827 828 829 830 831 832
            anjay.map((item, index) => {
                if (item == "+") {
                    opt = "tambah"
                } else if (item == "-") {
                    opt = "kurang"
                } else if (item == "*") {
                    opt = "kali"
                } else if (item == "/") {
                    opt = "bagi"
rifkaki's avatar
rifkaki committed
833
                } else {
faisalhamdi's avatar
faisalhamdi committed
834 835 836 837 838 839 840 841 842
                    item = item == "" ? 0 : item
                    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)
rifkaki's avatar
rifkaki committed
843
                    } else {
faisalhamdi's avatar
faisalhamdi committed
844
                        total += Number(item)
rifkaki's avatar
rifkaki committed
845 846 847 848
                    }
                }
            })
            total = R.equals(total, NaN) ? "0.0" : total
faisalhamdi's avatar
faisalhamdi committed
849 850
            // console.log(dataTable2[tableMeta.rowIndex][22])
            // console.log(tableMeta.rowData[5])
d.arizona's avatar
d.arizona committed
851 852 853 854
            // if (tableMeta.rowData[5] == 'R/E (Cummulative)' && tableMeta.columnIndex == 10) {
            //     console.log(baru)
            //     console.log(anjay)
            //     console.log(total)
faisalhamdi's avatar
faisalhamdi committed
855 856 857 858 859 860 861 862
            // }

            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
                // console.log([tableMeta.rowIndex][tableMeta.columnIndex])
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
            }
rifkaki's avatar
rifkaki committed
863 864 865

            return total
        }
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
        let columns = [
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
faisalhamdi's avatar
faisalhamdi committed
898 899 900 901 902 903 904 905 906 907 908 909 910
                name: "Account",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style }),
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ width: 300 }}>
                                {tableMeta.rowData[0] === null ?
                                    tableMeta.rowData[4] == 0 ?
911
                                        <LightTooltip title={"Report Items Not Registered"} arrow>
faisalhamdi's avatar
faisalhamdi committed
912 913 914 915 916 917 918
                                            <span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(val).toUpperCase()}</span>
                                        </LightTooltip> :
                                        <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>
919
                                    :
faisalhamdi's avatar
faisalhamdi committed
920 921 922 923 924 925 926 927 928 929
                                    tableMeta.rowData[4] == 0 ?
                                        <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                        :
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                            <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
930
                }
faisalhamdi's avatar
faisalhamdi committed
931 932 933 934 935 936 937 938 939 940 941 942 943 944 945
            }, {
                name: `31 Dec ${Number(this.props.periode) - 1} Actual`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
946 947 948 949 950 951
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
952
                                            value={Number(val).toFixed(1)}
953
                                        />
faisalhamdi's avatar
faisalhamdi committed
954
                                        :
955 956 957 958 959 960 961
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={val}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
d.arizona's avatar
d.arizona committed
962
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
963 964
                                                        type="text"
                                                        placeholder=""
d.arizona's avatar
d.arizona committed
965
                                                        disabled={true}
faisalhamdi's avatar
faisalhamdi committed
966
                                                        value={Number(val).toFixed(1)}
967 968
                                                    />
                                                }
969
                                            />
faisalhamdi's avatar
faisalhamdi committed
970 971 972 973 974 975 976
                                        </div>
                                }
                            </div>
                        )
                    }
                }
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
977
                name: `Jan ${this.props.periode} Actual`,
faisalhamdi's avatar
faisalhamdi committed
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    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}
d.arizona's avatar
d.arizona committed
997
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
998 999
                                        />
                                        :
faisalhamdi's avatar
faisalhamdi committed
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={val}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
d.arizona's avatar
d.arizona committed
1010 1011
                                                        // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                                        value={Number(val.value == undefined ? val : val.value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1012
                                                        disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1013
                                                    />
faisalhamdi's avatar
faisalhamdi committed
1014 1015 1016
                                                }
                                            />
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1017 1018 1019 1020
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1021
                }
faisalhamdi's avatar
faisalhamdi committed
1022
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1023
                name: `Feb ${this.props.periode} Actual`,
faisalhamdi's avatar
faisalhamdi committed
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1037 1038 1039 1040 1041 1042
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1043 1044
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1045
                                        />
faisalhamdi's avatar
faisalhamdi committed
1046
                                        :
faisalhamdi's avatar
faisalhamdi committed
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={val}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
d.arizona's avatar
d.arizona committed
1057 1058
                                                        // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                                        value={Number(val.value == undefined ? val : val.value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1059
                                                        disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1060
                                                    />
faisalhamdi's avatar
faisalhamdi committed
1061 1062 1063
                                                }
                                            />
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1064 1065 1066 1067
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1068
                }
faisalhamdi's avatar
faisalhamdi committed
1069
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1070
                name: `Mar ${this.props.periode} Actual`,
faisalhamdi's avatar
faisalhamdi committed
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1084 1085 1086 1087 1088 1089
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1090 1091
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1092
                                        />
faisalhamdi's avatar
faisalhamdi committed
1093
                                        :
faisalhamdi's avatar
faisalhamdi committed
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={val}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
d.arizona's avatar
d.arizona committed
1104 1105
                                                        // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                                        value={Number(val.value == undefined ? val : val.value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1106
                                                        disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1107
                                                    />
faisalhamdi's avatar
faisalhamdi committed
1108 1109 1110
                                                }
                                            />
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1111 1112 1113 1114
                                }
                            </div>
                        )
                    }
1115
                }
faisalhamdi's avatar
faisalhamdi committed
1116
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1117
                name: this.props.quarter == 'q2' || this.props.quarter == 'q3' ? `Apr ${this.props.periode} Actual` : `Apr ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1131 1132 1133 1134 1135 1136
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1137 1138
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1139
                                        />
faisalhamdi's avatar
faisalhamdi committed
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
1150
                                                />
faisalhamdi's avatar
faisalhamdi committed
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={this.props.quarter == 'q1' ? false : true}
                                                                value={this.props.quarter == 'q2' || this.props.quarter == 'q3' ? (val == "" ? "" : Number(val).toFixed(1)) : Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1186
                                                                    value={this.props.quarter == 'q2' || this.props.quarter == 'q3' ? (val == "" ? "" : Number(handleValueFormula(val, tableMeta)).toFixed(1)) : Number(handleValueFormula(val, tableMeta)).toFixed(1)}
1187 1188 1189
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        this.props.quarter === 'q2' || this.props.quarter === 'q3' ? null :
                                                            (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                /> :
                                                                <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
                                                                            backgroundColor: 'transparent',
                                                                            color: 'red'
                                                                        }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                    />
                                                                </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
1248
                }
faisalhamdi's avatar
faisalhamdi committed
1249
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1250
                name: this.props.quarter == 'q2' || this.props.quarter == 'q3' ? `May ${this.props.periode} Actual` : `May ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1264 1265 1266 1267 1268 1269
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1270 1271
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1272
                                        />
faisalhamdi's avatar
faisalhamdi committed
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
1283
                                                />
faisalhamdi's avatar
faisalhamdi committed
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={this.props.quarter == 'q1' ? false : true}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1319
                                                                    value={Number(handleValueFormula(val, tableMeta)).toFixed(1)}
1320 1321 1322
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        this.props.quarter === 'q2' || this.props.quarter === 'q3' ? null :
                                                            (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                /> :
                                                                <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
                                                                            backgroundColor: 'transparent',
                                                                            color: 'red'
                                                                        }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                    />
                                                                </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1381
                }
faisalhamdi's avatar
faisalhamdi committed
1382
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1383
                name: this.props.quarter == 'q2' || this.props.quarter == 'q3' ? `Jun ${this.props.periode} Actual` : `Jun ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1397 1398 1399 1400 1401 1402
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1403 1404
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1405
                                        />
faisalhamdi's avatar
faisalhamdi committed
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
1416
                                                />
faisalhamdi's avatar
faisalhamdi committed
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={this.props.quarter == 'q1' ? false : true}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1452
                                                                    value={Number(handleValueFormula(val, tableMeta)).toFixed(1)}
1453 1454 1455
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        this.props.quarter === 'q2' || this.props.quarter === 'q3' ? null :
                                                            (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                /> :
                                                                <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
                                                                            backgroundColor: 'transparent',
                                                                            color: 'red'
                                                                        }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                    />
                                                                </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1514
                }
faisalhamdi's avatar
faisalhamdi committed
1515
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1516
                name: this.props.quarter == 'q3' ? `Jul ${this.props.periode} Actual` : `Jul ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1530 1531 1532 1533 1534 1535
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1536 1537
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1538
                                        />
faisalhamdi's avatar
faisalhamdi committed
1539 1540 1541 1542 1543 1544 1545 1546 1547 1548
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
1549
                                                />
faisalhamdi's avatar
faisalhamdi committed
1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2' ? false : true}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1585
                                                                    value={Number(handleValueFormula(val, tableMeta)).toFixed(1)}
1586 1587 1588
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        this.props.quarter === 'q3' ? null :
                                                            (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                /> :
                                                                <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
                                                                            backgroundColor: 'transparent',
                                                                            color: 'red'
                                                                        }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                    />
                                                                </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1647
                }
faisalhamdi's avatar
faisalhamdi committed
1648
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1649
                name: this.props.quarter == 'q3' ? `Aug ${this.props.periode} Actual` : `Aug ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1663 1664 1665 1666 1667 1668
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1669 1670
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1671
                                        />
faisalhamdi's avatar
faisalhamdi committed
1672 1673 1674 1675 1676 1677 1678 1679 1680 1681
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
1682
                                                />
faisalhamdi's avatar
faisalhamdi committed
1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2' ? false : true}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1718
                                                                    value={Number(handleValueFormula(val, tableMeta)).toFixed(1)}
1719 1720 1721
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        this.props.quarter === 'q3' ? null :
                                                            (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                /> :
                                                                <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
                                                                            backgroundColor: 'transparent',
                                                                            color: 'red'
                                                                        }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                    />
                                                                </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1780
                }
faisalhamdi's avatar
faisalhamdi committed
1781
            }, {
Faisal Hamdi's avatar
Faisal Hamdi committed
1782
                name: this.props.quarter == 'q3' ? `Sep ${this.props.periode} Actual` : `Sep ${this.props.periode}`,
faisalhamdi's avatar
faisalhamdi committed
1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1796 1797 1798 1799 1800 1801
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1802 1803
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1804
                                        />
faisalhamdi's avatar
faisalhamdi committed
1805 1806 1807 1808 1809 1810 1811 1812 1813 1814
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
1815
                                                />
faisalhamdi's avatar
faisalhamdi committed
1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: this.props.quarter == 'q1' || this.props.quarter == 'q2' ? "#5198ea" : '#555252', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={this.props.quarter == 'q1' || this.props.quarter == 'q2' ? false : true}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1851
                                                                    value={Number(handleValueFormula(val, tableMeta)).toFixed(1)}
1852 1853 1854
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 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 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        this.props.quarter === 'q3' ? null :
                                                            (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                /> :
                                                                <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
                                                                            backgroundColor: 'transparent',
                                                                            color: 'red'
                                                                        }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                    />
                                                                </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1913
                }
faisalhamdi's avatar
faisalhamdi committed
1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928
            }, {
                name: `Oct ${this.props.periode}`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
1929 1930 1931 1932 1933 1934
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
1935 1936
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
1937
                                        />
faisalhamdi's avatar
faisalhamdi committed
1938 1939 1940 1941 1942 1943 1944 1945 1946 1947
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
1948
                                                />
faisalhamdi's avatar
faisalhamdi committed
1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={false}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1984
                                                                    value={Number(handleValueFormula(val, tableMeta)).toFixed(1)}
1985 1986 1987
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{
                                                                    fontSize: 12,
                                                                    textAlign: 'right',
                                                                    borderColor: 'transparent',
                                                                    margin: 0,
                                                                    width: 96,
                                                                    backgroundColor: 'transparent'
                                                                }}
                                                                type="text"
                                                                placeholder=""
                                                                disabled={true}
                                                                value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                            /> :
                                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent',
                                                                        color: 'red'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                />
                                                            </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2045
                }
faisalhamdi's avatar
faisalhamdi committed
2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060
            }, {
                name: `Nov ${this.props.periode}`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
2061 2062 2063 2064 2065 2066
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
2067 2068
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
2069
                                        />
faisalhamdi's avatar
faisalhamdi committed
2070 2071 2072 2073 2074 2075 2076 2077 2078 2079
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
2080
                                                />
faisalhamdi's avatar
faisalhamdi committed
2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={false}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
2116
                                                                    value={Number(handleValueFormula(val, tableMeta)).toFixed(1)}
2117 2118 2119
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
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 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{
                                                                    fontSize: 12,
                                                                    textAlign: 'right',
                                                                    borderColor: 'transparent',
                                                                    margin: 0,
                                                                    width: 96,
                                                                    backgroundColor: 'transparent'
                                                                }}
                                                                type="text"
                                                                placeholder=""
                                                                disabled={true}
                                                                value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                            /> :
                                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent',
                                                                        color: 'red'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                />
                                                            </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2177
                }
faisalhamdi's avatar
faisalhamdi committed
2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192
            }, {
                name: `Dec ${this.props.periode}`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
2193 2194 2195 2196 2197 2198
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
d.arizona's avatar
d.arizona committed
2199 2200
                                            // value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(val.value).toFixed(1) : Number(val).toFixed(1)}
                                            value={Number(val.value == undefined ? val : val.value).toFixed(1)}
2201
                                        />
faisalhamdi's avatar
faisalhamdi committed
2202 2203 2204 2205 2206 2207 2208 2209 2210 2211
                                        :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
2212
                                                />
faisalhamdi's avatar
faisalhamdi committed
2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={false}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
                                                            />
                                                        }
                                                    />
                                                </div> :
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
2248
                                                                    value={Number(handleValueFormula(val, tableMeta)).toFixed(1)}
2249 2250 2251
                                                                />
                                                            }
                                                        />
faisalhamdi's avatar
faisalhamdi committed
2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{
                                                                    fontSize: 12,
                                                                    textAlign: 'right',
                                                                    borderColor: 'transparent',
                                                                    margin: 0,
                                                                    width: 96,
                                                                    backgroundColor: 'transparent'
                                                                }}
                                                                type="text"
                                                                placeholder=""
                                                                disabled={true}
                                                                value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                            /> :
                                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent',
                                                                        color: 'red'
                                                                    }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
                                                                />
                                                            </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
                                }
                            </div>
                        )
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2309
                }
faisalhamdi's avatar
faisalhamdi committed
2310
            }, {
d.arizona's avatar
d.arizona committed
2311
                name: `31 Dec ${this.props.periode} Total Outlook`,
faisalhamdi's avatar
faisalhamdi committed
2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right' }}>
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                    null :
                                    this.state.get_for == 'view' ?
2325 2326 2327 2328 2329 2330
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            disabled={true}
faisalhamdi's avatar
faisalhamdi committed
2331
                                            value={Number(val).toFixed(1)}
2332
                                        />
faisalhamdi's avatar
faisalhamdi committed
2333
                                        :
Riri Novita's avatar
Riri Novita committed
2334
                                        tableMeta.rowData[0] === 2 ?
d.arizona's avatar
d.arizona committed
2335 2336 2337 2338 2339 2340 2341 2342
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
2343
                                                />
d.arizona's avatar
d.arizona committed
2344 2345 2346
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 3 ?
Riri Novita's avatar
Riri Novita committed
2347 2348 2349 2350 2351 2352 2353
                                                <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={val}
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
d.arizona's avatar
d.arizona committed
2354
                                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Riri Novita's avatar
Riri Novita committed
2355 2356
                                                                type="text"
                                                                placeholder=""
d.arizona's avatar
d.arizona committed
2357 2358 2359 2360 2361 2362
                                                                // disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                disabled={false}
                                                                value={Number(val).toFixed(1)}
                                                                onBlur={(event) => {
                                                                    handleChange(event.target.value, tableMeta)
                                                                }}
Riri Novita's avatar
Riri Novita committed
2363 2364 2365 2366
                                                            />
                                                        }
                                                    />
                                                </div> :
d.arizona's avatar
d.arizona committed
2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378
                                                tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={val}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
d.arizona's avatar
d.arizona committed
2379
                                                                    value={Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1)}
Faisal Hamdi's avatar
Faisal Hamdi committed
2380
                                                                // value={Number(val).toFixed(1)}
d.arizona's avatar
d.arizona committed
2381 2382 2383 2384 2385 2386
                                                                />
                                                            }
                                                        />
                                                    </div> :
                                                    tableMeta.rowData[0] === 7 ?
                                                        (Number(handleValidation(val, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(val, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
Riri Novita's avatar
Riri Novita committed
2387 2388 2389 2390 2391 2392 2393 2394
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{
                                                                    fontSize: 12,
                                                                    textAlign: 'right',
                                                                    borderColor: 'transparent',
                                                                    margin: 0,
                                                                    width: 96,
d.arizona's avatar
d.arizona committed
2395
                                                                    backgroundColor: 'transparent'
Riri Novita's avatar
Riri Novita committed
2396 2397 2398 2399 2400
                                                                }}
                                                                type="text"
                                                                placeholder=""
                                                                disabled={true}
                                                                value={Number(handleValidation(val, tableMeta)).toFixed(1)}
d.arizona's avatar
d.arizona committed
2401 2402
                                                            /> :
                                                            <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[21]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
Riri Novita's avatar
Riri Novita committed
2403 2404
                                                                <NumberFormat
                                                                    thousandSeparator={true}
d.arizona's avatar
d.arizona committed
2405 2406 2407 2408 2409 2410 2411 2412 2413
                                                                    style={{
                                                                        fontSize: 12,
                                                                        textAlign: 'right',
                                                                        borderColor: 'transparent',
                                                                        margin: 0,
                                                                        width: 96,
                                                                        backgroundColor: 'transparent',
                                                                        color: 'red'
                                                                    }}
Riri Novita's avatar
Riri Novita committed
2414 2415 2416
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
d.arizona's avatar
d.arizona committed
2417
                                                                    value={Number(handleValidation(val, tableMeta)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
2418
                                                                />
d.arizona's avatar
d.arizona committed
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436
                                                            </LightTooltip>
                                                        :
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(val).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                        </div>
faisalhamdi's avatar
faisalhamdi committed
2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454
                                }
                            </div>
                        )
                    }
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
Riri Novita's avatar
Riri Novita committed
2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
faisalhamdi's avatar
faisalhamdi committed
2473 2474 2475 2476
            {
                name: "",
                options: {
                    display: false
Deni Rinaldi's avatar
Deni Rinaldi committed
2477 2478 2479
                }
            }
        ]
2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491

        const loadingComponent = (
            <div style={{ position: 'fixed', zIndex: 110, 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>
        );

Deni Rinaldi's avatar
Deni Rinaldi committed
2492 2493
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
2494
                {this.state.loading && loadingComponent}
Deni Rinaldi's avatar
Deni Rinaldi committed
2495 2496 2497
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Rolling Outlook & Revision CAT</Typography>
                </div>
rifkaki's avatar
rifkaki committed
2498 2499 2500 2501 2502
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
Deni Rinaldi's avatar
Deni Rinaldi committed
2503
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
d.arizona's avatar
d.arizona committed
2504
                    {this.state.visibleBSRO ? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2505 2506 2507 2508 2509 2510
                        <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                            <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Rolling Outlook - Balance Sheet</Typography>
                        </div>
                        <div style={{ padding: 20 }}>
                            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                <div>
2511
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2512
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} {String(this.props.quarter).toLocaleUpperCase()} (rev.{this.props.revision})</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2513 2514
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                </div>
rifkaki's avatar
rifkaki committed
2515
                                <div style={{ width: '50%' }}>
faisalhamdi's avatar
faisalhamdi committed
2516
                                    {this.props.isApprover === true || this.state.get_for == 'view' ?
rifkaki's avatar
rifkaki committed
2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527
                                        <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 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2528
                                                            this.downloadAllData()
rifkaki's avatar
rifkaki committed
2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544
                                                        })}
                                                >
                                                    <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
                                                    }}
faisalhamdi's avatar
faisalhamdi committed
2545
                                                    onClick={() => this.setState({ loading: true }, () => {
d.arizona's avatar
d.arizona committed
2546 2547
                                                        this.downloadTemplate()
                                                    })}
rifkaki's avatar
rifkaki committed
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560
                                                >
                                                    <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
                                                    }}
d.arizona's avatar
d.arizona committed
2561 2562 2563 2564 2565 2566 2567 2568
                                                    onClick={() => this.setState({ loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.setState({
                                                                loading: false,
                                                                visibleUpload: true
                                                            })
                                                        }, 300);
                                                    })}
rifkaki's avatar
rifkaki committed
2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595
                                                >
                                                    <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>
Deni Rinaldi's avatar
Deni Rinaldi committed
2596
                            </div>
rifkaki's avatar
rifkaki committed
2597

Deni Rinaldi's avatar
Deni Rinaldi committed
2598
                            <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
faisalhamdi's avatar
faisalhamdi committed
2599 2600 2601 2602 2603 2604 2605 2606 2607
                                {!this.state.loading && (
                                    <MuiThemeProvider theme={getMuiTheme()}>
                                        <MUIDataTable
                                            data={dataTable2}
                                            columns={columns}
                                            options={options}
                                        />
                                    </MuiThemeProvider>
                                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2608
                            </div>
rifkaki's avatar
rifkaki committed
2609

Riri Novita's avatar
Riri Novita committed
2610 2611 2612 2613 2614 2615 2616 2617 2618
                            <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>
                                            )
                                        }) :
faisalhamdi's avatar
faisalhamdi committed
2619
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
Riri Novita's avatar
Riri Novita committed
2620 2621 2622
                                    }
                                </div>
                            </div>
rifkaki's avatar
rifkaki committed
2623 2624
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>

Deni Rinaldi's avatar
Deni Rinaldi committed
2625
                        </div>
rifkaki's avatar
rifkaki committed
2626 2627
                        <div className="grid grid-2x" style={{ padding: 20 }}>
                            <div className="col-1" style={{ paddingLeft: 0 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638
                                <button
                                    type="button"
                                    onClick={() => this.setState({ loading: true }, () => {
                                        setTimeout(() => {
                                            this.props.onClickClose()
                                        }, 100);
                                    })}
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
rifkaki's avatar
rifkaki committed
2639
                                        outline: 'none',
Deni Rinaldi's avatar
Deni Rinaldi committed
2640 2641 2642
                                    }}
                                >
                                    <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
rifkaki's avatar
rifkaki committed
2643
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2644 2645 2646
                                    </div>
                                </button>
                            </div>
rifkaki's avatar
rifkaki committed
2647 2648 2649
                            {this.props.isApprover === true ?
                                <div className="col-2">
                                </div> :
rifkaki's avatar
rifkaki committed
2650
                                <div className="" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671
                                    {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>
rifkaki's avatar
rifkaki committed
2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706
                                    }
                                    {this.state.get_for == 'edit' && <button
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                        onClick={() => {
                                            this.setState({ loading: true, dataTable: dataTable2 }, () => {
                                                setTimeout(() => {
                                                    this.handleValidate()
                                                }, 100);
                                            })
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                            <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                        </div>
                                    </button>}
                                    {this.state.get_for === 'edit' && <button
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                        onClick={() =>
                                            this.state.saveDraft ?
faisalhamdi's avatar
faisalhamdi committed
2707
                                                this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
rifkaki's avatar
rifkaki committed
2708
                                                :
2709 2710
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1, loading: true }, () => {
rifkaki's avatar
rifkaki committed
2711
                                                        this.backToRollingOutlook('draft')
rifkaki's avatar
rifkaki committed
2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725
                                                    })
                                        }
                                    >
                                        <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' })
                                                :
2726 2727
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
rifkaki's avatar
rifkaki committed
2728
                                                        this.backToRollingOutlook('submitted')
rifkaki's avatar
rifkaki committed
2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742
                                                    })}
                                        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>
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
2743
                        </div>
faisalhamdi's avatar
faisalhamdi committed
2744 2745 2746 2747
                    </Paper> :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Rolling Outlook - Balance Sheet</Typography>
d.arizona's avatar
d.arizona committed
2748
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2749 2750 2751 2752 2753 2754 2755 2756 2757 2758
                            <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} {String(this.props.quarter).toLocaleUpperCase()} (rev.{this.props.revision})</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }} />
                                    {/* </div> */}
                                </div>
d.arizona's avatar
d.arizona committed
2759

faisalhamdi's avatar
faisalhamdi committed
2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {!this.state.loading && (
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
                                </div>
d.arizona's avatar
d.arizona committed
2771

faisalhamdi's avatar
faisalhamdi committed
2772 2773 2774 2775 2776 2777
                            </div>
                            <div className="grid grid-2x" style={{ padding: 20 }}>
                                <div className="col-1" style={{ paddingLeft: 0 }}>
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ loading: true }, () => {
d.arizona's avatar
d.arizona committed
2778
                                            setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
2779 2780 2781
                                                this.setState({ visibleBSRO: true, visibleUpload: false }, () => {
                                                    this.handleGetFor('edit')
                                                })
d.arizona's avatar
d.arizona committed
2782
                                            }, 100);
faisalhamdi's avatar
faisalhamdi committed
2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814
                                        })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
                                        </div>
                                    </button>
                                </div>
                                {this.props.isApprover === true ?
                                    <div className="col-2">
                                    </div> :
                                    <div className="" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
                                        {this.state.get_for == 'edit' && <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
                                                    setTimeout(() => {
                                                        this.handleValidate()
                                                    }, 100);
d.arizona's avatar
d.arizona committed
2815
                                                })
faisalhamdi's avatar
faisalhamdi committed
2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835
                                            }}
                                        >
                                            <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' })
                                                    :
2836 2837
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852
                                                            this.uploadBSRO('draft')
                                                        })
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                            </div>
                                        </button>}
                                        {this.state.get_for === 'edit' && <button
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            onClick={() =>
                                                this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data incomplete !', tipeAlert: 'error' })
                                                    :
2853 2854
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867
                                                            this.uploadBSRO('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
                                        </button>}
d.arizona's avatar
d.arizona committed
2868
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2869
                                }
d.arizona's avatar
d.arizona committed
2870
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2871
                        </Paper>}
Deni Rinaldi's avatar
Deni Rinaldi committed
2872
                </div>
d.arizona's avatar
d.arizona committed
2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909
                {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={() => {
                                    String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("ROLLING") && String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("BALANCE") && String(this.state.judul).includes("SHEET") ?
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2910 2911 2912 2913
            </div>
        )
    }
}