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

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

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

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

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

    componentDidMount() {
faisalhamdi's avatar
faisalhamdi committed
56
        this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
57
        this.getLatestUpdate()
faisalhamdi's avatar
faisalhamdi committed
58 59 60
        console.log(this.props);
    }

faisalhamdi's avatar
faisalhamdi committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    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
                    })
                }
            }
        })
    }

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

    handleValue(data) {
        let total = 0
        this.state.dataTable.map((item, index) => {
            if (data.rowData[1] == item[2]) {
faisalhamdi's avatar
faisalhamdi committed
176
                total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
faisalhamdi's avatar
faisalhamdi committed
177 178 179 180 181 182 183 184
            }
        })
        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
    }

faisalhamdi's avatar
faisalhamdi committed
185
    handleChange(value, tableMeta) {
faisalhamdi's avatar
faisalhamdi committed
186
        let val = String(value).split(",").join("")
faisalhamdi's avatar
faisalhamdi committed
187
        let data = this.state.dataTable
faisalhamdi's avatar
faisalhamdi committed
188 189
        let indexParent = data.findIndex((val) => val[1] == data[tableMeta.rowIndex][2])
        if (indexParent > 0) {
faisalhamdi's avatar
faisalhamdi committed
190
            // console.log(indexParent)
faisalhamdi's avatar
faisalhamdi committed
191 192 193 194 195 196
            let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
            let jagain = data[indexParent][tableMeta.columnIndex]
            a = data[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
        } else {
            data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
        }
faisalhamdi's avatar
faisalhamdi committed
197 198
    }

faisalhamdi's avatar
faisalhamdi committed
199 200 201 202 203
    backToMasterBudget(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
faisalhamdi's avatar
faisalhamdi committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
                total_actual_before: String(Number(i[6]).toFixed(1)),
                january: String(Number(i[7]).toFixed(1)),
                february: String(Number(i[8]).toFixed(1)),
                march: String(Number(i[9]).toFixed(1)),
                april: String(Number(i[10]).toFixed(1)),
                may: String(Number(i[11]).toFixed(1)),
                june: String(Number(i[12]).toFixed(1)),
                july: String(Number(i[13]).toFixed(1)),
                august: String(Number(i[14]).toFixed(1)),
                september: String(Number(i[15]).toFixed(1)),
                october: String(Number(i[16]).toFixed(1)),
                november: String(Number(i[17]).toFixed(1)),
                december: String(Number(i[18]).toFixed(1)),
                total_current_year: String(Number(i[19]).toFixed(1)),
                total_next_year: String(Number(i[20]).toFixed(1)),
                total_more_year: String(Number(i[21]).toFixed(1))
faisalhamdi's avatar
faisalhamdi committed
220 221 222 223 224 225 226 227 228 229
            })
        })
        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,
            "fixed_asset_movement": data
        }
faisalhamdi's avatar
faisalhamdi committed
230
        // console.log(data);
faisalhamdi's avatar
faisalhamdi committed
231 232 233 234
        this.props.saveToMasterBudget(payload)
        this.props.onClickClose()
    }

faisalhamdi's avatar
faisalhamdi committed
235 236 237 238 239 240 241 242 243 244
    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;
faisalhamdi's avatar
faisalhamdi committed
245
            a.download = 'Template Master Budget Fixed Assets Movement.xlsx';
faisalhamdi's avatar
faisalhamdi committed
246 247 248 249 250 251 252 253 254 255 256 257 258
            a.click();
        }
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
faisalhamdi's avatar
faisalhamdi committed
259
                console.log(resp.rows[2]);
faisalhamdi's avatar
faisalhamdi committed
260
                let payload = []
faisalhamdi's avatar
faisalhamdi committed
261
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
faisalhamdi's avatar
faisalhamdi committed
262 263 264 265 266
                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(),
faisalhamdi's avatar
faisalhamdi committed
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
                            total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
                            january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
                            february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
                            march: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
                            april: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
                            may: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
                            june: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
                            july: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
                            august: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
                            september: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
                            october: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
                            november: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
                            december: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
                            total_current_year: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
                            total_next_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
                            total_more_year: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()
faisalhamdi's avatar
faisalhamdi committed
283 284 285 286 287 288 289
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
290
                    fixed_asset_movement: payload                    
faisalhamdi's avatar
faisalhamdi committed
291
                }
faisalhamdi's avatar
faisalhamdi committed
292 293
                console.log(body)
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
faisalhamdi's avatar
faisalhamdi committed
294 295 296 297 298 299
            }
        });
    }

    checkUpload() {
        api.create().checkUploadMB(this.state.payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
300
            // console.log(JSON.stringify(this.state.payload));
faisalhamdi's avatar
faisalhamdi committed
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
            console.log(response)
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, visibleFixedAssetsMovement: 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.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,
faisalhamdi's avatar
faisalhamdi committed
329
                            item.order,
faisalhamdi's avatar
faisalhamdi committed
330 331 332
                            item.error
                        ]
                    })
faisalhamdi's avatar
faisalhamdi committed
333 334
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
                        this.state.dataTable.map(item => {
335
                            if (item[23].length > 0) {
faisalhamdi's avatar
faisalhamdi committed
336 337 338 339 340 341
                                console.log('masuk')
                                this.setState({ buttonError: true, errorPreview: true })
                            }
                        })
                        // console.log(this.state.dataTable);
                    })
faisalhamdi's avatar
faisalhamdi committed
342 343 344 345 346
                }
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
347
    uploadFAM(type) {
faisalhamdi's avatar
faisalhamdi committed
348 349 350 351
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
                total_actual_before: String(Number(i[6]).toFixed(1)),
                january: String(Number(i[7]).toFixed(1)),
                february: String(Number(i[8]).toFixed(1)),
                march: String(Number(i[9]).toFixed(1)),
                april: String(Number(i[10]).toFixed(1)),
                may: String(Number(i[11]).toFixed(1)),
                june: String(Number(i[12]).toFixed(1)),
                july: String(Number(i[13]).toFixed(1)),
                august: String(Number(i[14]).toFixed(1)),
                september: String(Number(i[15]).toFixed(1)),
                october: String(Number(i[16]).toFixed(1)),
                november: String(Number(i[17]).toFixed(1)),
                december: String(Number(i[18]).toFixed(1)),
                total_current_year: String(Number(i[19]).toFixed(1)),
                total_next_year: String(Number(i[20]).toFixed(1)),
                total_more_year: String(Number(i[21]).toFixed(1))
faisalhamdi's avatar
faisalhamdi committed
368 369 370
            })
        })
        let body = {
faisalhamdi's avatar
faisalhamdi committed
371
            submission_id: this.props.submissionID,
faisalhamdi's avatar
faisalhamdi committed
372 373 374
            company_id: this.props.company.company_id,
            periode: this.props.periode,
            report_id: this.props.report_id,
faisalhamdi's avatar
faisalhamdi committed
375 376
            fixed_asset_movement: data,
            status: type
faisalhamdi's avatar
faisalhamdi committed
377
        }
378
        // console.log(data);
faisalhamdi's avatar
faisalhamdi committed
379 380 381 382 383 384 385 386 387 388
        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)
                }
            } else {
389
                this.setState({ loading: false })
faisalhamdi's avatar
faisalhamdi committed
390 391 392 393 394
                alert(response.problem)
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
395
    async downloadAllData() {
faisalhamdi's avatar
faisalhamdi committed
396 397
        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}`
        console.log(url);
faisalhamdi's avatar
faisalhamdi committed
398 399 400 401 402 403 404 405 406
        let res = await fetch(
            `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}`
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
faisalhamdi's avatar
faisalhamdi committed
407
            a.download = 'Master Budget Fixed Assets Movement.xlsx';
faisalhamdi's avatar
faisalhamdi committed
408 409 410 411
            a.click();
        }
    }

faisalhamdi's avatar
faisalhamdi committed
412 413
    handleValidate() {
        let data = []
414
        // console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
415 416 417 418
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
                total_actual_before: String(i[6]),
faisalhamdi's avatar
faisalhamdi committed
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
                january: i[0] === 3 && i[7] === "" ? "0" : String(i[7]),
                february: i[0] === 3 && i[8] === "" ? "0" : String(i[8]),
                march: i[0] === 3 && i[9] === "" ? "0" : String(i[9]),
                april: i[0] === 3 && i[10] === "" ? "0" : String(i[10]),
                may: i[0] === 3 && i[11] === "" ? "0" : String(i[11]),
                june: i[0] === 3 && i[12] === "" ? "0" : String(i[12]),
                july: i[0] === 3 && i[13] === "" ? "0" : String(i[13]),
                august: i[0] === 3 && i[14] === "" ? "0" : String(i[14]),
                september: i[0] === 3 && i[15] === "" ? "0" : String(i[15]),
                october: i[0] === 3 && i[16] === "" ? "0" : String(i[16]),
                november: i[0] === 3 && i[17] === "" ? "0" : String(i[17]),
                december: i[0] === 3 && i[18] === "" ? "0" : String(i[18]),
                total_current_year: i[0] === 3 && i[19] === "" ? "0" : String(i[19]),
                total_next_year: i[0] === 3 && i[20] === "" ? "0" : String(i[20]),
                total_more_year: i[0] === 3 && i[21] === "" ? "0" : String(i[21])
faisalhamdi's avatar
faisalhamdi committed
434 435 436 437
            })
        })
        // console.log(JSON.stringify(data))
        let payload = {
faisalhamdi's avatar
faisalhamdi committed
438 439 440 441 442 443
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "fixed_asset_movement": data,
            "status": "submitted"
faisalhamdi's avatar
faisalhamdi committed
444 445 446 447
        }
        api.create().validateSubmitReport(payload).then((response) => {
            console.log(response)
            if (response.data.data.result) {
faisalhamdi's avatar
faisalhamdi committed
448
                this.setState({ loading: false, buttonError: false, editable: false })
faisalhamdi's avatar
faisalhamdi committed
449 450 451 452 453 454
            } else {
                this.setState({ loading: false, buttonError: true, editable: true })
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
455 456 457 458
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
459
    render() {
faisalhamdi's avatar
faisalhamdi committed
460
        let dataTable2 = this.state.dataTable
faisalhamdi's avatar
faisalhamdi committed
461
        const handleChange = (value, tableMeta, type) => {
faisalhamdi's avatar
faisalhamdi committed
462
            let val = String(value).split(",").join("")
faisalhamdi's avatar
faisalhamdi committed
463 464
            if (type === "actual") {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)            
faisalhamdi's avatar
faisalhamdi committed
465
            } else {
faisalhamdi's avatar
faisalhamdi committed
466 467 468 469 470 471 472 473 474
                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)) : (jagain + Number(val))
                } else {
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
                }
faisalhamdi's avatar
faisalhamdi committed
475 476
            }
        }
faisalhamdi's avatar
faisalhamdi committed
477 478 479 480 481 482 483 484 485 486 487 488
        const handleTotal = (tableMeta) => {
            let total = 0
            dataTable2[tableMeta.rowIndex].map((item, index) => {
                if (index >= 7 && index <= 18) {
                    let valItem = item == undefined || item == "" ? 0 : item
                    total += Number(valItem)
                }
            })
            dataTable2[tableMeta.rowIndex][19] = total
            return total
            // console.log(total);
        }
faisalhamdi's avatar
faisalhamdi committed
489 490 491 492 493 494 495 496 497 498 499 500
        const handleValue = (data) => {
            let total = 0
            dataTable2.map((item, index) => {
                if (data.rowData[1] == item[2]) {
                    total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
                }
            })
            let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[data.rowIndex][2])
            let a = dataTable2[data.rowIndex][data.columnIndex] = Number(total)
            // console.log(indexParent);
            return a
        }
faisalhamdi's avatar
faisalhamdi committed
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
        const handleFormula = (data, tableMeta, month) => {
            let rilFormula = String(tableMeta.rowData[3])
            if (rilFormula.includes("#")) {
                if (this.props.status === "not-yet") {
                    let splitOrder = String(tableMeta.rowData[3]).split('@')
                    for (let index = 0; index < splitOrder.length; index++) {
                        if (splitOrder[index] === "") {
                        } else {
                            if (splitOrder[index].includes('#')) {

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

faisalhamdi's avatar
faisalhamdi committed
2003 2004 2005
        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 }}>
faisalhamdi's avatar
faisalhamdi committed
2006
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
faisalhamdi's avatar
faisalhamdi committed
2007
                </div>
faisalhamdi's avatar
faisalhamdi committed
2008 2009 2010 2011 2012
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
faisalhamdi's avatar
faisalhamdi committed
2013
                {/* {this.state.loading && loadingComponent} */}
faisalhamdi's avatar
faisalhamdi committed
2014
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
faisalhamdi's avatar
faisalhamdi committed
2015 2016 2017
                    {this.state.visibleFixedAssetsMovement === true ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
faisalhamdi's avatar
faisalhamdi committed
2018
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Fixed Assets Movement</Typography>
faisalhamdi's avatar
faisalhamdi committed
2019 2020 2021 2022 2023
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2024
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
faisalhamdi's avatar
faisalhamdi committed
2025 2026 2027
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
faisalhamdi's avatar
faisalhamdi committed
2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078
                                        {this.props.isApprover === true ? null :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                <a data-tip={'Download Template'} data-for="template">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.downloadTemplate()}
                                                    >
                                                        <img src={Images.template} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                                <a data-tip={'Upload'} data-for="upload">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.setState({ visibleUpload: true })}
                                                    >
                                                        <img src={Images.upload} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            </div>
                                        }
faisalhamdi's avatar
faisalhamdi committed
2079
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2080
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2081

faisalhamdi's avatar
faisalhamdi committed
2082
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
faisalhamdi's avatar
faisalhamdi committed
2083 2084
                                    {this.state.loading && loadingComponent} 
                                    <MuiThemeProvider theme={getMuiTheme()}>
faisalhamdi's avatar
faisalhamdi committed
2085 2086 2087 2088 2089
                                        <MUIDataTable
                                            data={dataTable2}
                                            columns={columns}
                                            options={options}
                                        />
faisalhamdi's avatar
faisalhamdi committed
2090
                                    </MuiThemeProvider>
faisalhamdi's avatar
faisalhamdi committed
2091
                                </div> 
faisalhamdi's avatar
faisalhamdi committed
2092
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2093
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2094
                            <div className="grid grid-2x" style={{ marginTop: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105
                                <div className="col-1">
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
faisalhamdi's avatar
faisalhamdi committed
2106 2107 2108 2109 2110
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
faisalhamdi's avatar
faisalhamdi committed
2111
                                    >
faisalhamdi's avatar
faisalhamdi committed
2112
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
2113
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
faisalhamdi's avatar
faisalhamdi committed
2114 2115
                                        </div>
                                    </button>
faisalhamdi's avatar
faisalhamdi committed
2116
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129
                                {this.props.isApprover === true ? null :
                                    <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={() => {
faisalhamdi's avatar
faisalhamdi committed
2130 2131
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
2132 2133
                                                        // this.setState({ loading: false, buttonError: false, editable: true })
                                                        this.handleValidate()
faisalhamdi's avatar
faisalhamdi committed
2134 2135
                                                    }, 100);
                                                })
faisalhamdi's avatar
faisalhamdi committed
2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153
                                            }}
                                        >
                                            <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
                                            }}
                                            onClick={() => this.state.editable === true ?
                                                null :
faisalhamdi's avatar
faisalhamdi committed
2154 2155
                                                this.state.handleTekTekTek == 1 ? null :
                                                this.setState({ loading: true, handleTekTekTek: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167
                                                    setTimeout(() => {
                                                        this.backToMasterBudget('draft')
                                                    }, 100);
                                                })}
                                        >
                                            <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}
faisalhamdi's avatar
faisalhamdi committed
2168
                                            onClick={() => 
faisalhamdi's avatar
faisalhamdi committed
2169 2170 2171 2172 2173 2174
                                                this.state.buttonError ?
                                                    this.setState({ loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning', loading: false })
                                                        }, 100);
                                                    })
faisalhamdi's avatar
faisalhamdi committed
2175 2176 2177
                                                    : 
                                                    this.state.handleTekTekTek == 1 ? null :   
                                                    this.setState({ loading: true, handleTekTekTek: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2178
                                                        this.backToMasterBudget('submitted')
faisalhamdi's avatar
faisalhamdi committed
2179
                                                    })}
faisalhamdi's avatar
faisalhamdi committed
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192
                                            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>
                                }
faisalhamdi's avatar
faisalhamdi committed
2193 2194 2195 2196 2197 2198 2199 2200
                            </div>
                        </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>
faisalhamdi's avatar
faisalhamdi committed
2201
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2202
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
faisalhamdi's avatar
faisalhamdi committed
2203
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2204
                                    {this.state.dataLoaded && (
faisalhamdi's avatar
faisalhamdi committed
2205
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
faisalhamdi's avatar
faisalhamdi committed
2206 2207
                                            {this.state.loading && loadingComponent}
                                            <MuiThemeProvider theme={getMuiTheme()}>
faisalhamdi's avatar
faisalhamdi committed
2208 2209 2210 2211 2212
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
faisalhamdi's avatar
faisalhamdi committed
2213
                                            </MuiThemeProvider>
faisalhamdi's avatar
faisalhamdi committed
2214 2215 2216
                                        </div>
                                    )}
                                </div>
2217 2218 2219 2220 2221 2222

                                <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                    <div className="col-1">
                                        <button
                                            type="button"
                                            onClick={() => this.setState({ loading: true, visibleFixedAssetsMovement: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2223
                                                setTimeout(() => {
2224
                                                    this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
2225
                                                }, 100);
2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258
                                            })}
                                            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%' }}>
                                        <button
                                            className="button"
                                            type="button"
                                            disabled={this.state.buttonError}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.buttonError === true ? 'default' : 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
                                                        this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
                                                    }, 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
faisalhamdi's avatar
faisalhamdi committed
2259
                                            className="button"
2260 2261
                                            type="button"
                                            disabled={this.state.buttonError}
faisalhamdi's avatar
faisalhamdi committed
2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.buttonError === true ? 'default' : 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => this.setState({ loading: true }, () =>
                                                this.state.handleTekTekTek == 1 ? null : 
                                                this.setState({handleTekTekTek: 1}, () => {
                                                    setTimeout(() => {
                                                        this.uploadFAM('draft')
                                                    }, 100);
                                                })
                                            )}
2277 2278 2279 2280 2281 2282 2283 2284
                                        >
                                            <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}
faisalhamdi's avatar
faisalhamdi committed
2285 2286 2287 2288 2289 2290 2291 2292
                                            onClick={() => this.setState({ loading: true }, () => 
                                                this.state.handleTekTekTek == 1? null :
                                                this.setState({handleTekTekTek: 1}, () => {
                                                    setTimeout(() => {
                                                        this.uploadFAM('submitted')
                                                    }, 100);
                                                })
                                            )}
2293 2294 2295 2296 2297 2298
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
                                        </button>
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2299
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2300
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2301 2302
                        </Paper>}
                </div>
faisalhamdi's avatar
faisalhamdi committed
2303

faisalhamdi's avatar
faisalhamdi committed
2304 2305 2306 2307 2308 2309 2310
                {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>
faisalhamdi's avatar
faisalhamdi committed
2311
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2312
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2313 2314 2315 2316 2317 2318 2319 2320
                                <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>
faisalhamdi's avatar
faisalhamdi committed
2321 2322
                                </div>
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337
                            <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 - FIXED ASSETS MOVEMENT" ?
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
faisalhamdi's avatar
faisalhamdi committed
2338
                        </div>
faisalhamdi's avatar
faisalhamdi committed
2339 2340
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
2341 2342 2343 2344
            </div>
        );
    }
}