ProfitLoss.js 151 KB
Newer Older
EKSAD's avatar
EKSAD committed
1
import React, { Component } from 'react';
d.arizona's avatar
d.arizona committed
2
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, Tooltip, withStyles, Snackbar } from '@material-ui/core';
EKSAD's avatar
EKSAD committed
3 4
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
EKSAD's avatar
EKSAD committed
5
import api from '../../api';
EKSAD's avatar
EKSAD committed
6 7 8
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
EKSAD's avatar
EKSAD committed
9 10
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
d.arizona's avatar
d.arizona committed
11
import { Alert } from '@material-ui/lab';
EKSAD's avatar
EKSAD committed
12
import * as R from 'ramda';
EKSAD's avatar
EKSAD committed
13

EKSAD's avatar
EKSAD committed
14 15 16 17 18 19 20 21 22
const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);

EKSAD's avatar
EKSAD committed
23
var ct = require("../../library/CustomTable");
EKSAD's avatar
EKSAD committed
24
const getMuiTheme = () => createMuiTheme(ct.customTable3());
EKSAD's avatar
EKSAD committed
25 26 27 28 29 30

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

export default class ProfitLoss extends Component {
EKSAD's avatar
EKSAD committed
40 41 42
    constructor(props) {
        super(props)
        this.state = {
EKSAD's avatar
EKSAD committed
43
            dataTable: [],
EKSAD's avatar
EKSAD committed
44
            visibleProfitLoss: true,
EKSAD's avatar
EKSAD committed
45
            disabledSave: true,
EKSAD's avatar
EKSAD committed
46
            editable: false,
EKSAD's avatar
EKSAD committed
47
            buttonError: false,
EKSAD's avatar
EKSAD committed
48
            judulColumn: null,
EKSAD's avatar
EKSAD committed
49 50 51
            updateBy: '-',
            buttonDraft: true,
            handleTekTekTek: 0
EKSAD's avatar
EKSAD committed
52
        }
EKSAD's avatar
EKSAD committed
53
        this.handleValue = this.handleValue.bind(this)
EKSAD's avatar
EKSAD committed
54
        this.fileHandler = this.fileHandler.bind(this);
EKSAD's avatar
EKSAD committed
55 56 57 58
    }

    componentDidMount() {
        this.getItemHierarki()
EKSAD's avatar
EKSAD committed
59
        this.getLatestUpdate()
EKSAD's avatar
EKSAD committed
60 61 62
        console.log(this.props);
    }

EKSAD's avatar
EKSAD committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
    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,
            "submission_id": this.props.submissionID
        }
        api.create().getLastestUpdateMB(payload).then(response => {
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update
                    })
                }
            }
        })
    }

EKSAD's avatar
EKSAD committed
82
    getItemHierarki() {
EKSAD's avatar
EKSAD committed
83
        this.setState({ loading: true, judulColumn: null })
EKSAD's avatar
EKSAD committed
84 85
        let payload = {
            "report_id": this.props.report_id,
EKSAD's avatar
EKSAD committed
86 87
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
EKSAD's avatar
EKSAD committed
88 89
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID
EKSAD's avatar
EKSAD committed
90
        }
EKSAD's avatar
EKSAD committed
91
        api.create().getDetailReportMB(payload).then(response => {
EKSAD's avatar
EKSAD committed
92
            console.log(response);
EKSAD's avatar
EKSAD committed
93
            let dataTable = []
Deni Rinaldi's avatar
Deni Rinaldi committed
94
            this.setState({ visibleProfitLoss: true })
EKSAD's avatar
EKSAD committed
95 96 97 98 99 100 101 102 103 104 105 106 107
            if (response.data) {
                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,
                            item.profit_loss.notes === "" ? null : item.profit_loss.notes,
EKSAD's avatar
EKSAD committed
108
                            item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
EKSAD's avatar
EKSAD committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122
                            item.profit_loss.january,
                            item.profit_loss.february,
                            item.profit_loss.march,
                            item.profit_loss.april,
                            item.profit_loss.may,
                            item.profit_loss.june,
                            item.profit_loss.july,
                            item.profit_loss.august,
                            item.profit_loss.september,
                            item.profit_loss.october,
                            item.profit_loss.november,
                            item.profit_loss.december,
                            item.profit_loss.total_current_year,
                            item.profit_loss.total_next_year,
Deni Rinaldi's avatar
Deni Rinaldi committed
123 124
                            item.profit_loss.total_more_year,
                            item.order
EKSAD's avatar
EKSAD committed
125 126 127 128 129 130 131 132 133 134 135
                        ])
                    }
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                }
                res.map((item, index) => {
EKSAD's avatar
EKSAD committed
136 137 138 139 140 141 142 143
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
                        item.profit_loss.notes === "" ? null : item.profit_loss.notes,
EKSAD's avatar
EKSAD committed
144
                        item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
EKSAD's avatar
EKSAD committed
145 146 147 148 149 150 151 152 153 154 155 156 157 158
                        item.profit_loss.january,
                        item.profit_loss.february,
                        item.profit_loss.march,
                        item.profit_loss.april,
                        item.profit_loss.may,
                        item.profit_loss.june,
                        item.profit_loss.july,
                        item.profit_loss.august,
                        item.profit_loss.september,
                        item.profit_loss.october,
                        item.profit_loss.november,
                        item.profit_loss.december,
                        item.profit_loss.total_current_year,
                        item.profit_loss.total_next_year,
Deni Rinaldi's avatar
Deni Rinaldi committed
159 160
                        item.profit_loss.total_more_year,
                        item.order
EKSAD's avatar
EKSAD committed
161
                    ])
EKSAD's avatar
EKSAD committed
162 163 164 165 166 167
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
EKSAD's avatar
EKSAD committed
168
                    }
EKSAD's avatar
EKSAD committed
169
                })
EKSAD's avatar
EKSAD committed
170
                console.log(dataTable)
EKSAD's avatar
EKSAD committed
171
                this.setState({ dataTable, loading: false, buttonError: true, editable: true })
EKSAD's avatar
EKSAD committed
172
            } else {
EKSAD's avatar
EKSAD committed
173
                this.setState({ dataTable, loading: false, buttonError: true, editable: true })
EKSAD's avatar
EKSAD committed
174
            }
EKSAD's avatar
EKSAD committed
175

EKSAD's avatar
EKSAD committed
176 177 178
        })
    }

EKSAD's avatar
EKSAD committed
179 180
    handleValue(data) {
        let total = 0
EKSAD's avatar
EKSAD committed
181
        this.state.dataTable.map((item, index) => {
EKSAD's avatar
EKSAD committed
182
            if (data.rowData[1] == item[2]) {
EKSAD's avatar
EKSAD committed
183
                total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
EKSAD's avatar
EKSAD committed
184 185 186 187 188 189 190 191
            }
        })
        let indexParent = this.state.dataTable.findIndex((val) => val[1] == this.state.dataTable[data.rowIndex][2])
        let a = this.state.dataTable[data.rowIndex][data.columnIndex] = total
        // console.log(indexParent);
        return a
    }

EKSAD's avatar
EKSAD committed
192
    handleChange(value, tableMeta) {
EKSAD's avatar
EKSAD committed
193
        let val = String(value).split(",").join("")
EKSAD's avatar
EKSAD committed
194
        let data = this.state.dataTable
EKSAD's avatar
EKSAD committed
195 196
        let indexParent = data.findIndex((val) => val[1] == data[tableMeta.rowIndex][2])
        if (indexParent > 0) {
EKSAD's avatar
EKSAD committed
197
            // console.log(indexParent)
EKSAD's avatar
EKSAD committed
198
            let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
EKSAD's avatar
EKSAD committed
199
            let jagain = data[indexParent][tableMeta.columnIndex]
EKSAD's avatar
EKSAD committed
200
            a = data[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
EKSAD's avatar
EKSAD committed
201
        } else {
EKSAD's avatar
EKSAD committed
202
            data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
EKSAD's avatar
EKSAD committed
203
        }
EKSAD's avatar
EKSAD committed
204 205
    }

EKSAD's avatar
EKSAD committed
206 207 208 209 210
    backToMasterBudget(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
d.arizona's avatar
d.arizona committed
211
                notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
EKSAD's avatar
EKSAD committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
                total_actual_before: String(Number(i[7]).toFixed(1)),
                january: String(Number(i[8]).toFixed(1)),
                february: String(Number(i[9]).toFixed(1)),
                march: String(Number(i[10]).toFixed(1)),
                april: String(Number(i[11]).toFixed(1)),
                may: String(Number(i[12]).toFixed(1)),
                june: String(Number(i[13]).toFixed(1)),
                july: String(Number(i[14]).toFixed(1)),
                august: String(Number(i[15]).toFixed(1)),
                september: String(Number(i[16]).toFixed(1)),
                october: String(Number(i[17]).toFixed(1)),
                november: String(Number(i[18]).toFixed(1)),
                december: String(Number(i[19]).toFixed(1)),
                total_current_year: String(Number(i[20]).toFixed(1)),
                total_next_year: String(Number(i[21]).toFixed(1)),
                total_more_year: String(Number(i[22]).toFixed(1))
EKSAD's avatar
EKSAD committed
228 229 230 231 232 233 234 235 236 237
            })
        })
        let payload = {
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
            "profit_loss": data
        }
EKSAD's avatar
EKSAD committed
238
        console.log(data);
EKSAD's avatar
EKSAD committed
239
        this.setState({ loading: false })
EKSAD's avatar
EKSAD committed
240 241 242 243
        this.props.saveToMasterBudget(payload)
        this.props.onClickClose()
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
244 245 246 247 248 249 250 251 252 253
    downloadTemplate = async () => {
        let res = await fetch(
            `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
        )
        res = await res.blob()
        console.log(res)
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
EKSAD's avatar
EKSAD committed
254
            a.download = 'Template Master Budget Profit & Loss.xlsx';
Deni Rinaldi's avatar
Deni Rinaldi committed
255 256 257 258
            a.click();
        }
    }

EKSAD's avatar
EKSAD committed
259 260 261
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
EKSAD's avatar
EKSAD committed
262
            // console.log(resp)
EKSAD's avatar
EKSAD committed
263 264 265 266 267
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
EKSAD's avatar
EKSAD committed
268
                console.log(resp.rows[2]);
EKSAD's avatar
EKSAD committed
269
                let payload = []
EKSAD's avatar
EKSAD committed
270
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
EKSAD's avatar
EKSAD committed
271 272 273 274 275
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
                            item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
                            item_report: i[1] === undefined ? "" : String(i[1]).trim(),
EKSAD's avatar
EKSAD committed
276
                            notes: i[2] === undefined ? "" : String(i[2]).trim(),
EKSAD's avatar
EKSAD committed
277
                            total_actual_before: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
EKSAD's avatar
EKSAD committed
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
                            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_current_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
                            total_next_year: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim(),
                            total_more_year: i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim()
EKSAD's avatar
EKSAD committed
293 294 295 296 297 298 299 300 301
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    profit_loss: payload
                }
EKSAD's avatar
EKSAD committed
302 303
                console.log(body)
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
EKSAD's avatar
EKSAD committed
304 305 306 307 308 309
            }
        });
    }

    checkUpload() {
        api.create().checkUploadMB(this.state.payload).then(response => {
EKSAD's avatar
EKSAD committed
310
            // console.log(JSON.stringify(this.state.payload));
EKSAD's avatar
EKSAD committed
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
            console.log(response)
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, visibleProfitLoss: false, loading: true })
                    let dataTable = response.data.data.map((item, index) => {
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.item_report,
                            item.notes,
                            item.total_actual_before,
                            item.january,
                            item.february,
                            item.march,
                            item.april,
                            item.may,
                            item.june,
                            item.july,
                            item.august,
                            item.september,
                            item.october,
                            item.november,
                            item.december,
                            item.total_current_year,
                            item.total_next_year,
                            item.total_more_year,
EKSAD's avatar
EKSAD committed
340
                            item.orders,
EKSAD's avatar
EKSAD committed
341 342 343
                            item.error
                        ]
                    })
EKSAD's avatar
EKSAD committed
344
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
EKSAD's avatar
EKSAD committed
345
                        this.state.dataTable.map(item => {
Deni Rinaldi's avatar
Deni Rinaldi committed
346
                            if (item[24].length > 0) {
EKSAD's avatar
EKSAD committed
347
                                console.log('masuk')
EKSAD's avatar
EKSAD committed
348
                                this.setState({ buttonError: true, errorPreview: true, editable: true })
EKSAD's avatar
EKSAD committed
349 350
                            }
                        })
EKSAD's avatar
EKSAD committed
351
                        // console.log(this.state.buttonError)
EKSAD's avatar
EKSAD committed
352
                    })
EKSAD's avatar
EKSAD committed
353 354 355 356 357
                }
            }
        })
    }

EKSAD's avatar
EKSAD committed
358
    uploadProfitLoss(type) {
EKSAD's avatar
EKSAD committed
359 360 361 362
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
EKSAD's avatar
EKSAD committed
363
                notes: String(i[6]),
EKSAD's avatar
EKSAD committed
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
                total_actual_before: String(Number(i[7]).toFixed(1)),
                january: String(Number(i[8]).toFixed(1)),
                february: String(Number(i[9]).toFixed(1)),
                march: String(Number(i[10]).toFixed(1)),
                april: String(Number(i[11]).toFixed(1)),
                may: String(Number(i[12]).toFixed(1)),
                june: String(Number(i[13]).toFixed(1)),
                july: String(Number(i[14]).toFixed(1)),
                august: String(Number(i[15]).toFixed(1)),
                september: String(Number(i[16]).toFixed(1)),
                october: String(Number(i[17]).toFixed(1)),
                november: String(Number(i[18]).toFixed(1)),
                december: String(Number(i[19]).toFixed(1)),
                total_current_year: String(Number(i[20]).toFixed(1)),
                total_next_year: String(Number(i[21]).toFixed(1)),
                total_more_year: String(Number(i[22]).toFixed(1)),
EKSAD's avatar
EKSAD committed
380 381 382
            })
        })
        let body = {
EKSAD's avatar
EKSAD committed
383
            submission_id: this.props.submissionID,
EKSAD's avatar
EKSAD committed
384 385 386
            company_id: this.props.company.company_id,
            periode: this.props.periode,
            report_id: this.props.report_id,
EKSAD's avatar
EKSAD committed
387 388
            profit_loss: data,
            status: type
EKSAD's avatar
EKSAD committed
389 390 391 392 393 394 395 396 397 398
        }
        console.log(data);
        api.create('UPLOAD').uploadMasterBudget(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
                    this.props.onClickClose()
                    this.props.getReport()
                } else {
                    alert(response.data.status)
EKSAD's avatar
EKSAD committed
399
                }
EKSAD's avatar
EKSAD committed
400
            } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
401
                this.setState({ loading: false })
EKSAD's avatar
EKSAD committed
402 403 404
                alert(response.problem)
                // this.props.onClickClose()
                // this.props.getReport()
EKSAD's avatar
EKSAD committed
405 406 407 408
            }
        })
    }

EKSAD's avatar
EKSAD committed
409
    async downloadAllData() {
EKSAD's avatar
EKSAD committed
410
        let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
EKSAD's avatar
EKSAD committed
411
        let sub_null = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
EKSAD's avatar
EKSAD committed
412
        console.log(url);
EKSAD's avatar
EKSAD committed
413
        let res = await fetch(
EKSAD's avatar
EKSAD committed
414
            this.props.submissionID == null ? sub_null : url
EKSAD's avatar
EKSAD committed
415 416 417 418 419 420 421
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
EKSAD's avatar
EKSAD committed
422
            a.download = 'Master Budget Profit & Loss.xlsx';
EKSAD's avatar
EKSAD committed
423 424 425 426
            a.click();
        }
    }

d.arizona's avatar
d.arizona committed
427 428
    handleValidate() {
        let data = []
EKSAD's avatar
EKSAD committed
429
        // console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
430 431 432 433 434
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
                notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
                total_actual_before: String(i[7]),
EKSAD's avatar
EKSAD committed
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
                january: i[0] === 3 && i[8] === "" ? "0" : String(i[8]),
                february: i[0] === 3 && i[9] === "" ? "0" : String(i[9]),
                march: i[0] === 3 && i[10] === "" ? "0" : String(i[10]),
                april: i[0] === 3 && i[11] === "" ? "0" : String(i[11]),
                may: i[0] === 3 && i[12] === "" ? "0" : String(i[12]),
                june: i[0] === 3 && i[13] === "" ? "0" : String(i[13]),
                july: i[0] === 3 && i[14] === "" ? "0" : String(i[14]),
                august: i[0] === 3 && i[15] === "" ? "0" : String(i[15]),
                september: i[0] === 3 && i[16] === "" ? "0" : String(i[16]),
                october: i[0] === 3 && i[17] === "" ? "0" : String(i[17]),
                november: i[0] === 3 && i[18] === "" ? "0" : String(i[18]),
                december: i[0] === 3 && i[19] === "" ? "0" : String(i[19]),
                total_current_year: i[0] === 3 && i[20] === "" ? "0" : String(i[20]),
                total_next_year: i[0] === 3 && i[21] === "" ? "0" : String(i[21]),
                total_more_year: i[0] === 3 && i[22] === "" ? "0" : String(i[22])
d.arizona's avatar
d.arizona committed
450 451 452 453 454 455 456
            })
        })
        let payload = {
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
EKSAD's avatar
EKSAD committed
457 458
            "profit_loss": data,
            "status": "submitted"
d.arizona's avatar
d.arizona committed
459
        }
EKSAD's avatar
EKSAD committed
460
        console.log(payload)
d.arizona's avatar
d.arizona committed
461 462 463
        api.create().validateSubmitReport(payload).then((response) => {
            console.log(response)
            if (response.data.data.result) {
EKSAD's avatar
EKSAD committed
464
                this.setState({ loading: false, buttonError: false, editable: false })
d.arizona's avatar
d.arizona committed
465 466
            } else {
                this.setState({ loading: false, buttonError: true, editable: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
467
            }
d.arizona's avatar
d.arizona committed
468 469 470
        })
    }

EKSAD's avatar
EKSAD committed
471 472 473 474
    closeAlert() {
        this.setState({ alert: false })
    }

EKSAD's avatar
EKSAD committed
475
    render() {
EKSAD's avatar
EKSAD committed
476
        let dataTable2 = this.state.dataTable
EKSAD's avatar
EKSAD committed
477
        const handleChange = (value, tableMeta, type) => {
EKSAD's avatar
EKSAD committed
478
            let val = String(value).split(",").join("")
EKSAD's avatar
EKSAD committed
479
            if (type === "actual") {
EKSAD's avatar
EKSAD committed
480
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
EKSAD's avatar
EKSAD committed
481
            } else {
d.arizona's avatar
d.arizona committed
482 483 484 485 486 487 488
                // let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[tableMeta.rowIndex][2])
                // if (indexParent > 0) {
                //     // console.log(indexParent)
                //     let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
                //     let jagain = dataTable2[indexParent][tableMeta.columnIndex]
                //     a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (Number(jagain) + Number(val))
                // } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
489
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
d.arizona's avatar
d.arizona committed
490
                // }
Deni Rinaldi's avatar
Deni Rinaldi committed
491

EKSAD's avatar
EKSAD committed
492 493
            }
        }
EKSAD's avatar
EKSAD committed
494 495 496
        const handleTotal = (tableMeta) => {
            let total = 0
            dataTable2[tableMeta.rowIndex].map((item, index) => {
EKSAD's avatar
EKSAD committed
497
                if (index >= 8 && index <= 19) {
EKSAD's avatar
EKSAD committed
498 499 500 501
                    let valItem = item == undefined || item == "" ? 0 : item
                    total += Number(valItem)
                }
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
502
            let indexParent = dataTable2.findIndex((val) => val[1] == tableMeta.rowData[2])
Deni Rinaldi's avatar
Deni Rinaldi committed
503
            if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "sales price") {
EKSAD's avatar
EKSAD committed
504
                let value = Number(dataTable2[tableMeta.rowIndex - 2][20]) / Number(dataTable2[tableMeta.rowIndex - 1][20])
EKSAD's avatar
EKSAD committed
505 506
                dataTable2[tableMeta.rowIndex][20] = R.equals(value, NaN) ? "0.0" : value
                return R.equals(value, NaN) ? "0.0" : value
EKSAD's avatar
EKSAD committed
507 508 509 510
            } else if (indexParent !== -1 && String(dataTable2[indexParent][5]).toLocaleUpperCase() == "GROSS PROFIT MARGIN (% OF REVENUE)") {
                return handleFormula(0, tableMeta, 0)
            }
            else {
EKSAD's avatar
EKSAD committed
511 512 513 514

                dataTable2[tableMeta.rowIndex][20] = total
                return total
            }
EKSAD's avatar
EKSAD committed
515 516
            // console.log(total);
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
517
        const handleNotes = (value, tableMeta) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
518 519 520
            console.log(value)
            let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
            console.log(dataTable2[tableMeta.rowIndex]);
Deni Rinaldi's avatar
Deni Rinaldi committed
521
        }
EKSAD's avatar
EKSAD committed
522 523 524 525
        const handleValue = (data) => {
            let total = 0
            dataTable2.map((item, index) => {
                if (data.rowData[1] == item[2]) {
EKSAD's avatar
EKSAD committed
526
                    total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
EKSAD's avatar
EKSAD committed
527 528 529
                }
            })
            let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[data.rowIndex][2])
EKSAD's avatar
EKSAD committed
530
            let a = dataTable2[data.rowIndex][data.columnIndex] = Number(total)
EKSAD's avatar
EKSAD committed
531 532 533
            // console.log(indexParent);
            return a
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
534
        const handleFormula = (data, tableMeta, month) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
535 536 537 538 539 540
            let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
            let arrayJumlah = []
            arrayFormula.map((item, indexs) => {
                let index = dataTable2.findIndex((val) => val[23] == item)
                if (index > 0) {
                    arrayJumlah.push(dataTable2[index][tableMeta.columnIndex])
EKSAD's avatar
EKSAD committed
541
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
542
                    arrayJumlah.push(item)
EKSAD's avatar
EKSAD committed
543
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
                // if (indexs % 2 !== 0) {
                //     operator.push(item)
                // }
            })
            let array = arrayJumlah
            let total = 0
            let opt = ""
            array.map((item, index) => {
                if (item == "+") {
                    opt = "tambah"
                } else if (item == "-") {
                    opt = "kurang"
                } else if (item == "*") {
                    opt = "kali"
                } else if (item == "/") {
                    opt = "bagi"
                } else {
                    if (opt == "tambah") {
                        total = Number(total) + Number(item)
                    } else if (opt == "kurang") {
                        total = Number(total) - Number(item)
                    } else if (opt == "kali") {
                        total = Number(total) * Number(item)
                    } else if (opt == "bagi") {
EKSAD's avatar
EKSAD committed
568
                        total = R.equals((Number(total) / Number(item)), NaN) ? '0' : Number(total) / Number(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
569
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
570
                        total += item
Deni Rinaldi's avatar
Deni Rinaldi committed
571
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
572 573 574 575
                }
            })
            let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
            return a
Deni Rinaldi's avatar
Deni Rinaldi committed
576

EKSAD's avatar
EKSAD committed
577
        }
EKSAD's avatar
EKSAD committed
578

EKSAD's avatar
EKSAD committed
579
        const columns = [{
EKSAD's avatar
EKSAD committed
580 581 582 583
            name: "",
            options: {
                display: false
            }
EKSAD's avatar
EKSAD committed
584
        }, {
EKSAD's avatar
EKSAD committed
585 586 587 588
            name: "",
            options: {
                display: false
            }
EKSAD's avatar
EKSAD committed
589
        }, {
EKSAD's avatar
EKSAD committed
590 591 592 593
            name: "",
            options: {
                display: false
            }
EKSAD's avatar
EKSAD committed
594
        }, {
EKSAD's avatar
EKSAD committed
595 596 597 598
            name: "",
            options: {
                display: false
            }
EKSAD's avatar
EKSAD committed
599 600 601 602 603
        }, {
            name: "",
            options: {
                display: false
            }
EKSAD's avatar
EKSAD committed
604
        }, {
EKSAD's avatar
EKSAD committed
605
            name: "Account",
EKSAD's avatar
EKSAD committed
606 607
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
608
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300 }}>
EKSAD's avatar
EKSAD committed
609 610 611 612 613 614
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style }),
                customBodyRender: (val, tableMeta) => {
                    return (
EKSAD's avatar
EKSAD committed
615
                        <div style={{ width: 300 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
616 617
                            {tableMeta.rowData[24] ?
                                tableMeta.rowData[24].length > 0 ?
EKSAD's avatar
EKSAD committed
618 619 620 621 622
                                    <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>
EKSAD's avatar
EKSAD committed
623 624 625 626 627 628 629
                                    :
                                    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>
EKSAD's avatar
EKSAD committed
630
                                :
EKSAD's avatar
EKSAD committed
631 632 633 634 635 636
                                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>
EKSAD's avatar
EKSAD committed
637 638 639 640
                            }
                        </div>
                    )
                }
EKSAD's avatar
EKSAD committed
641 642
            }
        }, {
EKSAD's avatar
EKSAD committed
643
            name: "Notes",
EKSAD's avatar
EKSAD committed
644 645 646 647 648 649 650 651 652 653
            options: {
                customHeadRender: (columnMeta) => (
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
654
                            <div style={{ flex: 1 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
655
                                {tableMeta.rowData[0] === 4 ? null : tableMeta.rowData[4] === 0 ? null : tableMeta.rowData[4] === 1 ? null :
EKSAD's avatar
EKSAD committed
656 657
                                    <FormControlLabel
                                        style={{ margin: 0 }}
EKSAD's avatar
EKSAD committed
658
                                        // value={value}
EKSAD's avatar
EKSAD committed
659 660
                                        control={
                                            <Input
Deni Rinaldi's avatar
Deni Rinaldi committed
661
                                                disableUnderline={true}
EKSAD's avatar
EKSAD committed
662 663 664
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
665
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
666
                                                defaultValue={value}
EKSAD's avatar
EKSAD committed
667 668
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
Deni Rinaldi's avatar
Deni Rinaldi committed
669
                                                    handleNotes(event.target.value, tableMeta)
EKSAD's avatar
EKSAD committed
670 671 672 673
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
674
                                    />}
Deni Rinaldi's avatar
Deni Rinaldi committed
675
                            </div>
EKSAD's avatar
EKSAD committed
676 677 678 679 680
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
681
            name: `31 Dec ${Number(this.props.periode) - 1} Actual`,
EKSAD's avatar
EKSAD committed
682 683
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
684 685
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
EKSAD's avatar
EKSAD committed
686 687
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
688
                setCellProps: () => ({ style2 }),
EKSAD's avatar
EKSAD committed
689 690 691
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
EKSAD's avatar
EKSAD committed
692 693
                            {tableMeta.rowData[0] === 4 ?
                                null
EKSAD's avatar
EKSAD committed
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711
                                : tableMeta.rowData[0] === 1 ?
                                    null :
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(value).toFixed(1)}
                                                />
                                            }
                                        />
                                    </div>
EKSAD's avatar
EKSAD committed
712 713 714 715 716
                            }
                        </div>
                    )
                }
            }
EKSAD's avatar
EKSAD committed
717
        }, {
EKSAD's avatar
EKSAD committed
718
            name: `Jan ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
719 720
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
721
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
722 723 724
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
725
                setCellProps: () => ({ style2 }),
EKSAD's avatar
EKSAD committed
726 727 728
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
EKSAD's avatar
EKSAD committed
729
                            {tableMeta.rowData[0] === 3 ?
EKSAD's avatar
EKSAD committed
730 731 732 733 734 735 736 737 738 739
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
740
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
741
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
742 743
                                                onBlur={(event) => {
                                                    handleChange(event.target.value, tableMeta)
EKSAD's avatar
EKSAD committed
744
                                                    // console.log(dataTable2)
EKSAD's avatar
EKSAD committed
745 746 747 748 749 750 751 752 753 754 755 756 757
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
758
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
759 760 761
                                        />
                                    </span>
                                    :
EKSAD's avatar
EKSAD committed
762 763
                                    tableMeta.rowData[0] === 4 ?
                                        null
EKSAD's avatar
EKSAD committed
764
                                        :
EKSAD's avatar
EKSAD committed
765
                                        tableMeta.rowData[0] === 6 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
766 767 768 769 770 771 772 773 774
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
                                                value={Number(handleFormula(value, tableMeta, 1)).toFixed(1)}
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
775 776
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
777 778 779 780 781 782 783 784 785
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 1)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
786 787
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
788 789 790 791 792 793 794 795 796 797 798
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
799
                                                    :
EKSAD's avatar
EKSAD committed
800
                                                    null
EKSAD's avatar
EKSAD committed
801 802 803 804
                            }
                        </div>
                    )
                }
EKSAD's avatar
EKSAD committed
805
            }
EKSAD's avatar
EKSAD committed
806
        }, {
EKSAD's avatar
EKSAD committed
807
            name: `Feb ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
808 809
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
810
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
811 812 813
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
814
                setCellProps: () => ({ style2 }),
EKSAD's avatar
EKSAD committed
815
                customBodyRender: (value, tableMeta, updateValue) => {
EKSAD's avatar
EKSAD committed
816
                    return (
EKSAD's avatar
EKSAD committed
817
                        <div style={{ textAlign: 'right' }}>
EKSAD's avatar
EKSAD committed
818
                            {tableMeta.rowData[0] === 3 ?
EKSAD's avatar
EKSAD committed
819 820 821 822 823 824 825 826 827 828
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
829
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
830
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
831 832 833
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
EKSAD's avatar
EKSAD committed
834
                                                    // console.log(dataTable2)
EKSAD's avatar
EKSAD committed
835 836 837 838 839 840 841 842 843 844 845 846 847
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
848
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
849 850 851
                                        />
                                    </span>
                                    :
EKSAD's avatar
EKSAD committed
852 853
                                    tableMeta.rowData[0] === 4 ?
                                        null
EKSAD's avatar
EKSAD committed
854
                                        :
EKSAD's avatar
EKSAD committed
855
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
856 857 858 859 860 861
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
862
                                                value={Number(handleFormula(value, tableMeta, 2)).toFixed(1)}
EKSAD's avatar
EKSAD committed
863 864
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
865 866
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
867 868 869 870 871 872 873 874 875
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 2)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
876 877
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
878 879 880 881 882 883 884 885 886 887 888
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
889
                                                    :
EKSAD's avatar
EKSAD committed
890
                                                    null
EKSAD's avatar
EKSAD committed
891
                            }
EKSAD's avatar
EKSAD committed
892 893 894 895 896
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
897
            name: `Mar ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
898 899
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
900
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
901 902 903
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
904
                setCellProps: () => ({ style2 }),
EKSAD's avatar
EKSAD committed
905
                customBodyRender: (value, tableMeta, updateValue) => {
EKSAD's avatar
EKSAD committed
906
                    return (
EKSAD's avatar
EKSAD committed
907
                        <div style={{ textAlign: 'right' }}>
EKSAD's avatar
EKSAD committed
908
                            {tableMeta.rowData[0] === 3 ?
EKSAD's avatar
EKSAD committed
909 910 911 912 913 914 915 916 917 918
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
919
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
920
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
921 922 923 924
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
EKSAD's avatar
EKSAD committed
925 926 927 928 929 930 931 932 933 934 935 936 937
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
938
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
939 940 941
                                        />
                                    </span>
                                    :
EKSAD's avatar
EKSAD committed
942 943
                                    tableMeta.rowData[0] === 4 ?
                                        null
EKSAD's avatar
EKSAD committed
944
                                        :
EKSAD's avatar
EKSAD committed
945
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
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}
EKSAD's avatar
EKSAD committed
952
                                                value={Number(handleFormula(value, tableMeta, 3)).toFixed(1)}
EKSAD's avatar
EKSAD committed
953 954
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
955 956
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
957 958 959 960 961 962 963 964 965
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 3)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
966 967
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
968 969 970 971 972 973 974 975 976 977 978
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
979
                                                    :
EKSAD's avatar
EKSAD committed
980
                                                    null
EKSAD's avatar
EKSAD committed
981
                            }
EKSAD's avatar
EKSAD committed
982 983 984 985 986
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
987
            name: `Apr ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
988 989
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
990
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
991 992 993
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
994
                setCellProps: () => ({ style2 }),
EKSAD's avatar
EKSAD committed
995
                customBodyRender: (value, tableMeta, updateValue) => {
EKSAD's avatar
EKSAD committed
996
                    return (
EKSAD's avatar
EKSAD committed
997
                        <div style={{ textAlign: 'right' }}>
EKSAD's avatar
EKSAD committed
998
                            {tableMeta.rowData[0] === 3 ?
EKSAD's avatar
EKSAD committed
999 1000 1001 1002 1003 1004 1005 1006 1007 1008
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1009
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1010
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1011 1012 1013 1014
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
EKSAD's avatar
EKSAD committed
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1028
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1029 1030 1031
                                        />
                                    </span>
                                    :
EKSAD's avatar
EKSAD committed
1032 1033
                                    tableMeta.rowData[0] === 4 ?
                                        null
EKSAD's avatar
EKSAD committed
1034
                                        :
EKSAD's avatar
EKSAD committed
1035
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1036 1037 1038 1039 1040 1041
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1042
                                                value={Number(handleFormula(value, tableMeta, 4)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1043 1044
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1045 1046
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1047 1048 1049 1050 1051 1052 1053 1054 1055
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 4)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1056 1057
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1069
                                                    :
EKSAD's avatar
EKSAD committed
1070
                                                    null
EKSAD's avatar
EKSAD committed
1071
                            }
EKSAD's avatar
EKSAD committed
1072 1073 1074 1075 1076
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1077
            name: `May ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
1078 1079
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1080
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
1081 1082 1083
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
1084
                setCellProps: () => ({ style2 }),
EKSAD's avatar
EKSAD committed
1085
                customBodyRender: (value, tableMeta, updateValue) => {
EKSAD's avatar
EKSAD committed
1086
                    return (
EKSAD's avatar
EKSAD committed
1087
                        <div style={{ textAlign: 'right' }}>
EKSAD's avatar
EKSAD committed
1088
                            {tableMeta.rowData[0] === 3 ?
EKSAD's avatar
EKSAD committed
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1099
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1100
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1101 1102 1103 1104
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
EKSAD's avatar
EKSAD committed
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1118
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1119 1120 1121
                                        />
                                    </span>
                                    :
EKSAD's avatar
EKSAD committed
1122 1123
                                    tableMeta.rowData[0] === 4 ?
                                        null
EKSAD's avatar
EKSAD committed
1124
                                        :
EKSAD's avatar
EKSAD committed
1125
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1126 1127 1128 1129 1130 1131
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1132
                                                value={Number(handleFormula(value, tableMeta, 5)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1133 1134
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1135 1136
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1137 1138 1139 1140 1141 1142 1143 1144 1145
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 5)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1146 1147
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1159
                                                    :
EKSAD's avatar
EKSAD committed
1160
                                                    null
EKSAD's avatar
EKSAD committed
1161
                            }
EKSAD's avatar
EKSAD committed
1162 1163 1164 1165 1166
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1167
            name: `Jun ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
1168 1169
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1170
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 3 ?
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1189
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1190
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1208
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1209 1210 1211 1212 1213 1214 1215
                                        />
                                    </span>
                                    :
                                    tableMeta.rowData[0] === 4 ?
                                        null
                                        :
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1216 1217 1218 1219 1220 1221
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1222
                                                value={Number(handleFormula(value, tableMeta, 6)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1223 1224
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1225 1226
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1227 1228 1229 1230 1231 1232 1233 1234 1235
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 6)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1236 1237
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1249
                                                    :
EKSAD's avatar
EKSAD committed
1250
                                                    null
EKSAD's avatar
EKSAD committed
1251 1252 1253 1254 1255 1256
                            }
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1257
            name: `Jul ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
1258 1259
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1260
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 3 ?
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1279
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1280
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1298
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1299 1300 1301 1302 1303 1304 1305
                                        />
                                    </span>
                                    :
                                    tableMeta.rowData[0] === 4 ?
                                        null
                                        :
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1306 1307 1308 1309 1310 1311
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1312
                                                value={Number(handleFormula(value, tableMeta, 7)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1313 1314
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1315 1316
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1317 1318 1319 1320 1321 1322 1323 1324 1325
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 7)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1326 1327
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1339
                                                    :
EKSAD's avatar
EKSAD committed
1340
                                                    null
EKSAD's avatar
EKSAD committed
1341 1342 1343 1344 1345 1346
                            }
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1347
            name: `Aug ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
1348 1349
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1350
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 3 ?
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1369
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1370
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1388
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1389 1390 1391 1392 1393 1394 1395
                                        />
                                    </span>
                                    :
                                    tableMeta.rowData[0] === 4 ?
                                        null
                                        :
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1396 1397 1398 1399 1400 1401
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1402
                                                value={Number(handleFormula(value, tableMeta, 8)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1403 1404
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1405 1406
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1407 1408 1409 1410 1411 1412 1413 1414 1415
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 8)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1416 1417
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1429
                                                    :
EKSAD's avatar
EKSAD committed
1430
                                                    null
EKSAD's avatar
EKSAD committed
1431 1432 1433 1434 1435 1436
                            }
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1437
            name: `Sep ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
1438 1439
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1440
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 3 ?
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1459
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1460
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1478
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1479 1480 1481 1482 1483 1484 1485
                                        />
                                    </span>
                                    :
                                    tableMeta.rowData[0] === 4 ?
                                        null
                                        :
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1486 1487 1488 1489 1490 1491
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1492
                                                value={Number(handleFormula(value, tableMeta, 9)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1493 1494
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1495 1496
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1497 1498 1499 1500 1501 1502 1503 1504 1505
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 9)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1506 1507
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1519
                                                    :
EKSAD's avatar
EKSAD committed
1520
                                                    null
EKSAD's avatar
EKSAD committed
1521 1522 1523 1524 1525 1526
                            }
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1527
            name: `Oct ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
1528 1529
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1530
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 3 ?
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1549
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1550
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1568
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1569 1570 1571 1572 1573 1574 1575
                                        />
                                    </span>
                                    :
                                    tableMeta.rowData[0] === 4 ?
                                        null
                                        :
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1576 1577 1578 1579 1580 1581
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1582
                                                value={Number(handleFormula(value, tableMeta, 10)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1583 1584
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1585 1586
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1587 1588 1589 1590 1591 1592 1593 1594 1595
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 10)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1596 1597
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1609
                                                    :
EKSAD's avatar
EKSAD committed
1610
                                                    null
EKSAD's avatar
EKSAD committed
1611 1612 1613 1614 1615 1616
                            }
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1617
            name: `Nov ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
1618 1619
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1620
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
1621 1622 1623
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
1624
                setCellProps: () => ({ style2 }),
EKSAD's avatar
EKSAD committed
1625
                customBodyRender: (value, tableMeta, updateValue) => {
EKSAD's avatar
EKSAD committed
1626
                    return (
EKSAD's avatar
EKSAD committed
1627
                        <div style={{ textAlign: 'right' }}>
EKSAD's avatar
EKSAD committed
1628
                            {tableMeta.rowData[0] === 3 ?
EKSAD's avatar
EKSAD committed
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1639
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1640
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1641 1642 1643 1644
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
EKSAD's avatar
EKSAD committed
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1658
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1659 1660 1661
                                        />
                                    </span>
                                    :
EKSAD's avatar
EKSAD committed
1662 1663
                                    tableMeta.rowData[0] === 4 ?
                                        null
EKSAD's avatar
EKSAD committed
1664
                                        :
EKSAD's avatar
EKSAD committed
1665
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1666 1667 1668 1669 1670 1671
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1672
                                                value={Number(handleFormula(value, tableMeta, 11)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1673 1674
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1675 1676
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1677 1678 1679 1680 1681 1682 1683 1684 1685
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 11)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1686 1687
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1699
                                                    :
EKSAD's avatar
EKSAD committed
1700
                                                    null
EKSAD's avatar
EKSAD committed
1701
                            }
EKSAD's avatar
EKSAD committed
1702 1703 1704 1705 1706
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1707
            name: `Dec ${this.props.periode}`,
EKSAD's avatar
EKSAD committed
1708 1709
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1710
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
1711 1712 1713
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
1714 1715
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
EKSAD's avatar
EKSAD committed
1716
                    return (
EKSAD's avatar
EKSAD committed
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 3 ?
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1729
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1730
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1748
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1749 1750 1751 1752 1753 1754 1755
                                        />
                                    </span>
                                    :
                                    tableMeta.rowData[0] === 4 ?
                                        null
                                        :
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1756 1757 1758 1759 1760 1761
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
EKSAD's avatar
EKSAD committed
1762
                                                value={Number(handleFormula(value, tableMeta, 12)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1763 1764
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1765 1766
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1767 1768 1769 1770 1771 1772 1773 1774 1775
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
                                                    value={Number(handleFormula(value, tableMeta, 12)).toFixed(1)}
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1776 1777
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1789
                                                    :
EKSAD's avatar
EKSAD committed
1790
                                                    null
EKSAD's avatar
EKSAD committed
1791 1792 1793 1794 1795 1796
                            }
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1797
            name: "Current Total",
EKSAD's avatar
EKSAD committed
1798 1799
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1800 1801
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
EKSAD's avatar
EKSAD committed
1802 1803 1804 1805 1806
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
EKSAD's avatar
EKSAD committed
1807 1808 1809
                        <div style={{ width: 96, textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
                                null : tableMeta.rowData[0] === 2 ?
EKSAD's avatar
EKSAD committed
1810 1811 1812 1813 1814 1815 1816
                                    <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}
EKSAD's avatar
EKSAD committed
1817
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1818
                                        />
EKSAD's avatar
EKSAD committed
1819
                                    </span> :
EKSAD's avatar
EKSAD committed
1820 1821 1822 1823 1824 1825 1826 1827 1828
                                    // tableMeta.rowData[0] === 6 ?
                                    //     <NumberFormat
                                    //         thousandSeparator={true}
                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                    //         type="text"
                                    //         placeholder=""
                                    //         disabled={true}
                                    //         value={Number(handleFormula(value, tableMeta, 12)).toFixed(1)}
                                    //     /> :
EKSAD's avatar
EKSAD committed
1829 1830 1831 1832 1833 1834 1835
                                    <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}
EKSAD's avatar
EKSAD committed
1836
                                            value={Number(handleTotal(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1837 1838
                                        />
                                    </span>}
EKSAD's avatar
EKSAD committed
1839 1840 1841 1842 1843
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1844
            name: `31 Dec ${Number(this.props.periode) + 1} Total`,
EKSAD's avatar
EKSAD committed
1845 1846
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1847 1848
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
EKSAD's avatar
EKSAD committed
1849 1850
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
1851 1852
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
EKSAD's avatar
EKSAD committed
1853
                    return (
EKSAD's avatar
EKSAD committed
1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 3 ?
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1866
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1867
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1885
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1886 1887 1888 1889 1890 1891 1892
                                        />
                                    </span>
                                    :
                                    tableMeta.rowData[0] === 4 ?
                                        null
                                        :
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1893 1894 1895 1896 1897 1898
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1899
                                                value={Number(handleFormula(value, tableMeta, 13)).toFixed(1)} ue={handleFormula(value, tableMeta)}
EKSAD's avatar
EKSAD committed
1900 1901
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1902 1903
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1904 1905 1906 1907 1908 1909
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1910
                                                    value={Number(handleFormula(value, tableMeta, 13)).toFixed(1)} ue={handleFormula(value, tableMeta)}
EKSAD's avatar
EKSAD committed
1911 1912
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
1913 1914
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
1926
                                                    :
EKSAD's avatar
EKSAD committed
1927
                                                    null
EKSAD's avatar
EKSAD committed
1928
                            }
EKSAD's avatar
EKSAD committed
1929 1930 1931 1932 1933
                        </div>
                    )
                }
            }
        }, {
EKSAD's avatar
EKSAD committed
1934
            name: `31 Dec ${Number(this.props.periode) + 2} Total`,
EKSAD's avatar
EKSAD committed
1935 1936
            options: {
                customHeadRender: (columnMeta) => (
EKSAD's avatar
EKSAD committed
1937 1938
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
EKSAD's avatar
EKSAD committed
1939 1940
                    </TableCell>
                ),
EKSAD's avatar
EKSAD committed
1941 1942
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
EKSAD's avatar
EKSAD committed
1943
                    return (
EKSAD's avatar
EKSAD committed
1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 3 ?
                                <div style={{ flex: 1 }}>
                                    <FormControlLabel
                                        style={{ margin: 0 }}
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1956
                                                disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
EKSAD's avatar
EKSAD committed
1957
                                                value={Number(value).toFixed(1)}
EKSAD's avatar
EKSAD committed
1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
                                                onBlur={(event) => {
                                                    // updateValue(event.target.value)
                                                    handleChange(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />
                                </div> :
                                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}
EKSAD's avatar
EKSAD committed
1975
                                            value={Number(handleValue(tableMeta)).toFixed(1)}
EKSAD's avatar
EKSAD committed
1976 1977 1978 1979 1980 1981 1982
                                        />
                                    </span>
                                    :
                                    tableMeta.rowData[0] === 4 ?
                                        null
                                        :
                                        tableMeta.rowData[0] === 6 ?
EKSAD's avatar
EKSAD committed
1983 1984 1985 1986 1987 1988
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1989
                                                value={Number(handleFormula(value, tableMeta, 14)).toFixed(1)} ue={handleFormula(value, tableMeta)}
EKSAD's avatar
EKSAD committed
1990 1991
                                            />
                                            // null
EKSAD's avatar
EKSAD committed
1992 1993
                                            :
                                            tableMeta.rowData[0] === 5 ?
EKSAD's avatar
EKSAD committed
1994 1995 1996 1997 1998 1999
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
2000
                                                    value={Number(handleFormula(value, tableMeta, 14)).toFixed(1)} ue={handleFormula(value, tableMeta)}
EKSAD's avatar
EKSAD committed
2001 2002
                                                />
                                                // null
EKSAD's avatar
EKSAD committed
2003 2004
                                                :
                                                tableMeta.rowData[0] === 1 ?
EKSAD's avatar
EKSAD committed
2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015
                                                    // value === "" ?
                                                    //     null :
                                                    //     <NumberFormat
                                                    //         thousandSeparator={true}
                                                    //         style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //         type="text"
                                                    //         placeholder=""
                                                    //         disabled={true}
                                                    //         value={Number(value)}
                                                    //     />
                                                    null
EKSAD's avatar
EKSAD committed
2016
                                                    :
EKSAD's avatar
EKSAD committed
2017
                                                    null
EKSAD's avatar
EKSAD committed
2018
                            }
EKSAD's avatar
EKSAD committed
2019 2020 2021 2022
                        </div>
                    )
                }
            }
EKSAD's avatar
EKSAD committed
2023
        },
Deni Rinaldi's avatar
Deni Rinaldi committed
2024 2025 2026 2027 2028 2029
        {
            name: "",
            options: {
                display: false
            }
        },
EKSAD's avatar
EKSAD committed
2030 2031 2032 2033 2034
        {
            name: "",
            options: {
                display: false
            }
EKSAD's avatar
EKSAD committed
2035 2036
        }
        ]
EKSAD's avatar
EKSAD committed
2037 2038 2039 2040 2041 2042 2043 2044 2045 2046
        const loadingComponent = (
            <div style={{ position: 'absolute', 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>
        );
EKSAD's avatar
EKSAD committed
2047

EKSAD's avatar
EKSAD committed
2048 2049 2050
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
EKSAD's avatar
EKSAD committed
2051
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
EKSAD's avatar
EKSAD committed
2052
                </div>
d.arizona's avatar
d.arizona committed
2053 2054 2055 2056 2057
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
EKSAD's avatar
EKSAD committed
2058
                {/* {this.state.loading && loadingComponent} */}
EKSAD's avatar
EKSAD committed
2059
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
EKSAD's avatar
EKSAD committed
2060 2061 2062
                    {this.state.visibleProfitLoss === true ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
EKSAD's avatar
EKSAD committed
2063
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Profit & Loss </Typography>
EKSAD's avatar
EKSAD committed
2064 2065 2066 2067 2068
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
EKSAD's avatar
EKSAD committed
2069
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
EKSAD's avatar
EKSAD committed
2070 2071 2072
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2073
                                        {this.state.dataTable.length == 0 ? null : this.props.isApprover == true ?
EKSAD's avatar
EKSAD committed
2074
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            </div> :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && <a data-tip={'Download Template'} data-for="template">
EKSAD's avatar
EKSAD committed
2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.downloadTemplate()}
                                                    >
                                                        <img src={Images.template} />
                                                    </button>
EKSAD's avatar
EKSAD committed
2108
                                                </a>}
EKSAD's avatar
EKSAD committed
2109
                                                <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
Deni Rinaldi's avatar
Deni Rinaldi committed
2110
                                                {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && <a data-tip={'Upload'} data-for="upload">
EKSAD's avatar
EKSAD committed
2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.setState({ visibleUpload: true })}
                                                    >
                                                        <img src={Images.upload} />
                                                    </button>
EKSAD's avatar
EKSAD committed
2122
                                                </a>}
EKSAD's avatar
EKSAD committed
2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144
                                                <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>
                                        }
EKSAD's avatar
EKSAD committed
2145 2146
                                    </div>
                                </div>
EKSAD's avatar
EKSAD committed
2147

EKSAD's avatar
EKSAD committed
2148
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
EKSAD's avatar
EKSAD committed
2149 2150
                                    {this.state.loading && loadingComponent}
                                    <MuiThemeProvider theme={getMuiTheme()}>
EKSAD's avatar
EKSAD committed
2151 2152 2153 2154 2155
                                        <MUIDataTable
                                            data={dataTable2}
                                            columns={columns}
                                            options={options}
                                        />
EKSAD's avatar
EKSAD committed
2156
                                    </MuiThemeProvider>
EKSAD's avatar
EKSAD committed
2157
                                </div>
EKSAD's avatar
EKSAD committed
2158
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
EKSAD's avatar
EKSAD committed
2159
                            </div>
EKSAD's avatar
EKSAD committed
2160 2161 2162 2163
                            <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                <div className="col-1">
                                    <button
                                        type="button"
EKSAD's avatar
EKSAD committed
2164 2165 2166 2167 2168
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
EKSAD's avatar
EKSAD committed
2169 2170 2171 2172 2173 2174 2175 2176
                                        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' }}>
EKSAD's avatar
EKSAD committed
2177
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
EKSAD's avatar
EKSAD committed
2178 2179 2180
                                        </div>
                                    </button>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2181 2182
                                {this.state.dataTable.length == 0 ? null : this.props.isApprover === true ? null : 
                                    (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249
                                        <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                            <button
                                                className="button"
                                                type="button"
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                    marginRight: 20
                                                }}
                                                onClick={() => {
                                                    this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
                                                        setTimeout(() => {
                                                            this.handleValidate()
                                                        }, 100);
                                                    })
                                                }}
                                            >
                                                <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                                </div>
                                            </button>
                                            <button
                                                className="button"
                                                type="button"
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                    marginRight: 20
                                                }}
                                                disabled={this.state.buttonDraft}
                                                onClick={() =>
                                                    this.state.handleTekTekTek == 1 ? null :
                                                        this.setState({ handleTekTekTek: 1 }, () => {
                                                            this.backToMasterBudget('draft')
                                                        })
                                                }
                                            >
                                                <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                                </div>
                                            </button>
                                            <button
                                                type="button"
                                                disabled={this.state.buttonError}
                                                onClick={() => this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                    :
                                                    this.state.handleTekTekTek == 1 ? null :
                                                        this.setState({ handleTekTekTek: 1 }, () => {
                                                            this.backToMasterBudget('submitted')
                                                        })}
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: this.state.buttonError === true ? 'default' : 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                }}
                                            >
                                                <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                                </div>
                                            </button>
                                        </div> : null
EKSAD's avatar
EKSAD committed
2250
                                }
EKSAD's avatar
EKSAD committed
2251
                            </div>
EKSAD's avatar
EKSAD committed
2252 2253 2254 2255 2256 2257 2258
                        </Paper>
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div>
                                <div style={{ padding: 25 }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
EKSAD's avatar
EKSAD committed
2259
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
EKSAD's avatar
EKSAD committed
2260
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
EKSAD's avatar
EKSAD committed
2261
                                    </div>
EKSAD's avatar
EKSAD committed
2262
                                    {this.state.dataLoaded && (
EKSAD's avatar
EKSAD committed
2263
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
EKSAD's avatar
EKSAD committed
2264 2265
                                            {this.state.loading && loadingComponent}
                                            <MuiThemeProvider theme={getMuiTheme()}>
EKSAD's avatar
EKSAD committed
2266 2267 2268 2269 2270
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
EKSAD's avatar
EKSAD committed
2271
                                            </MuiThemeProvider>
EKSAD's avatar
EKSAD committed
2272 2273 2274
                                        </div>
                                    )}
                                </div>
EKSAD's avatar
EKSAD committed
2275 2276 2277

                                <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                    <div className="col-1">
Deni Rinaldi's avatar
Deni Rinaldi committed
2278
                                        <button
EKSAD's avatar
EKSAD committed
2279
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
2280
                                            onClick={() => this.setState({ loading: true, dataTable: [] }, () => {
EKSAD's avatar
EKSAD committed
2281
                                                setTimeout(() => {
EKSAD's avatar
EKSAD committed
2282
                                                    this.getItemHierarki()
EKSAD's avatar
EKSAD committed
2283
                                                }, 100);
EKSAD's avatar
EKSAD committed
2284 2285 2286 2287 2288 2289 2290 2291 2292
                                            })}
                                            style={{ marginRight: 20 }}
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
                                            </div>
                                        </button>
                                    </div>
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2293
                                        <button
EKSAD's avatar
EKSAD committed
2294 2295
                                            className="button"
                                            type="button"
EKSAD's avatar
EKSAD committed
2296
                                            disabled={this.state.buttonError}
EKSAD's avatar
EKSAD committed
2297 2298 2299 2300 2301 2302 2303 2304 2305 2306
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.buttonError === true ? 'default' : 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
EKSAD's avatar
EKSAD committed
2307
                                                        this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false, editable: false })
EKSAD's avatar
EKSAD committed
2308 2309 2310 2311 2312 2313 2314 2315 2316 2317
                                                    }, 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>
                                        <button
                                            type="button"
EKSAD's avatar
EKSAD committed
2318
                                            style={{
EKSAD's avatar
EKSAD committed
2319 2320 2321 2322
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
EKSAD's avatar
EKSAD committed
2323 2324
                                                marginRight: 20
                                            }}
EKSAD's avatar
EKSAD committed
2325
                                            onClick={() =>
EKSAD's avatar
EKSAD committed
2326
                                                this.state.editable === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2327 2328
                                                    null :
                                                    this.setState({ loading: true }, () =>
EKSAD's avatar
EKSAD committed
2329 2330 2331 2332 2333 2334 2335
                                                        this.state.handleTekTekTek == 1 ? null :
                                                            this.setState({ handleTekTekTek: 1 }, () => {
                                                                setTimeout(() => {
                                                                    this.uploadProfitLoss('draft')
                                                                }, 100);
                                                            })
                                                    )
EKSAD's avatar
EKSAD committed
2336
                                            }
EKSAD's avatar
EKSAD committed
2337 2338 2339 2340 2341 2342 2343
                                        >
                                            <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>
                                        <button
                                            type="button"
EKSAD's avatar
EKSAD committed
2344 2345 2346 2347 2348 2349
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2350
                                            onClick={() =>
EKSAD's avatar
EKSAD committed
2351
                                                this.state.editable === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2352 2353
                                                    null :
                                                    this.setState({ loading: true }, () =>
EKSAD's avatar
EKSAD committed
2354 2355 2356 2357 2358 2359 2360
                                                        this.state.handleTekTekTek == 1 ? null :
                                                            this.setState({ handleTekTekTek: 1 }, () => {
                                                                setTimeout(() => {
                                                                    this.uploadProfitLoss('submitted')
                                                                }, 100);
                                                            })
                                                    )
EKSAD's avatar
EKSAD committed
2361
                                            }
EKSAD's avatar
EKSAD committed
2362 2363 2364 2365 2366 2367
                                        >
                                            <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>
EKSAD's avatar
EKSAD committed
2368 2369
                                </div>
                            </div>
EKSAD's avatar
EKSAD committed
2370
                        </Paper>}
EKSAD's avatar
EKSAD committed
2371 2372 2373 2374 2375 2376 2377 2378 2379
                </div>

                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
EKSAD's avatar
EKSAD committed
2380
                                    </div>
EKSAD's avatar
EKSAD committed
2381 2382 2383 2384 2385 2386 2387 2388 2389 2390
                                </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>
EKSAD's avatar
EKSAD committed
2391
                            </div>
EKSAD's avatar
EKSAD committed
2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406
                            <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={() => {
                                    this.state.judul === "MASTER BUDGET - PROFIT LOSS" ?
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
EKSAD's avatar
EKSAD committed
2407
                        </div>
EKSAD's avatar
EKSAD committed
2408 2409
                    </div>
                )}
EKSAD's avatar
EKSAD committed
2410
            </div>
EKSAD's avatar
EKSAD committed
2411 2412 2413
        );
    }
}