import React, { Component } from 'react';
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, Tooltip, withStyles, Snackbar } from '@material-ui/core';
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
import api from '../../api';
import AddIcon from '@material-ui/icons/Add';
import { values } from 'ramda';
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
import { Alert } from '@material-ui/lab';
import * as R from 'ramda';

const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);

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

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

export default class Historical extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
            loading: false,
        }
    }

    componentDidMount() {
        // this.getItemHierarki()
    }

    getItemHierarki() {
        this.setState({ loading: true, judulColumn: null })
        let payload = {
            "report_id": 5,
            "revision": 0,
            "periode": 2021,
            "company_id": 2193390,
            "submission_id": 3275722
        }
        api.create().getDetailReportMB(payload).then(response => {
            // console.log(response);
            let dataTable = []
            if (response.data) {
                let res = response.data.data
                const handlePushChild = (item) => {
                    let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                    if (indexIDzz === -1) {
                        dataTable.push([
                            item.type_report_id,
                            item.type_report_tax.value_tbc.type_report_id,
                            item.type_report_tax.value_fc.type_report_id,
                            item.type_report_tax.value_tbf.type_report_id,
                            item.id,
                            item.parent,
                            { tbc: item.formula_tax.value_tbc, fcp: item.formula_tax.value_fc, tbf: item.formula_tax.value_tbf },
                            item.level,
                            item.description,
                            { tbc: item.type_report_tax.value_tbc.type_report_id == 5 || item.type_report_tax.value_tbc.type_report_id == 6 || item.type_report_tax.value_tbc.type_report_id == 7 ? { value: item.tax_planning.january.tbc, formula: item.tax_planning.january_formula } : item.tax_planning.january.tbc, fcp: item.type_report_tax.value_fc.type_report_id == 5 || item.type_report_tax.value_fc.type_report_id == 6 || item.type_report_tax.value_fc.type_report_id == 7 ? { value: item.tax_planning.january.fcp, formula: item.tax_planning.january_formula } : item.tax_planning.january.fcp, tbf: item.type_report_tax.value_tbf.type_report_id == 5 || item.type_report_tax.value_tbf.type_report_id == 6 || item.type_report_tax.value_tbf.type_report_id == 7 ? { value: item.tax_planning.january.tbf, formula: item.tax_planning.january_formula } : item.tax_planning.january.tbf },
                            item.tax_planning.total_current_year,
                            item.tax_planning.total_current_year,
                            item.order,
                            { tbc: item.condition_it_should_be_tax.value_tbc, fcp: item.condition_it_should_be_tax.value_fc, tbf: item.condition_it_should_be_tax.value_tbf },
                            { tbc: item.condition_if_wrong_tax.value_tbc, fcp: item.condition_if_wrong_tax.value_fc, tbf: item.condition_if_wrong_tax.value_tbf },
                            item.tax_planning.forecast_tbc_formula,
                            item.tax_planning.forecast_fcp_formula,
                            item.tax_planning.forecast_tbf_formula,
                        ])
                    }
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                }
                res.map((item, index) => {
                    dataTable.push([
                        item.type_report_id,
                        item.type_report_tax.value_tbc.type_report_id,
                        item.type_report_tax.value_fc.type_report_id,
                        item.type_report_tax.value_tbf.type_report_id,
                        item.id,
                        item.parent,
                        { tbc: item.formula_tax.value_tbc, fcp: item.formula_tax.value_fc, tbf: item.formula_tax.value_tbf },
                        item.level,
                        item.description,
                        { tbc: item.type_report_tax.value_tbc.type_report_id == 5 || item.type_report_tax.value_tbc.type_report_id == 6 || item.type_report_tax.value_tbc.type_report_id == 7 ? { value: item.tax_planning.january.tbc, formula: item.tax_planning.january_formula } : item.tax_planning.january.tbc, fcp: item.type_report_tax.value_fc.type_report_id == 5 || item.type_report_tax.value_fc.type_report_id == 6 || item.type_report_tax.value_fc.type_report_id == 7 ? { value: item.tax_planning.january.fcp, formula: item.tax_planning.january_formula } : item.tax_planning.january.fcp, tbf: item.type_report_tax.value_tbf.type_report_id == 5 || item.type_report_tax.value_tbf.type_report_id == 6 || item.type_report_tax.value_tbf.type_report_id == 7 ? { value: item.tax_planning.january.tbf, formula: item.tax_planning.january_formula } : item.tax_planning.january.tbf },
                        item.tax_planning.total_current_year,
                        item.tax_planning.total_current_year,
                        item.order,
                        { tbc: item.condition_it_should_be_tax.value_tbc, fcp: item.condition_it_should_be_tax.value_fc, tbf: item.condition_it_should_be_tax.value_tbf },
                        { tbc: item.condition_if_wrong_tax.value_tbc, fcp: item.condition_if_wrong_tax.value_fc, tbf: item.condition_if_wrong_tax.value_tbf },
                        item.tax_planning.forecast_tbc_formula,
                        item.tax_planning.forecast_fcp_formula,
                        item.tax_planning.forecast_tbf_formula
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
                this.setState({ dataTable, loading: false, buttonError: true, editable: true })
            } else {
                this.setState({ dataTable, loading: false, buttonError: true, editable: true })
            }
        })
    }

    backToMasterBudget(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[4],
                january: {
                    tbc: i[1] === 3 && i[9].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[9].tbc.value) : String(i[9].tbc),
                    fcp: i[2] === 3 && i[9].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[9].fcp.value) : String(i[9].fcp),
                    tbf: i[3] === 3 && i[9].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[9].tbf.value) : String(i[9].tbf)
                },
                february: {
                    tbc: i[1] === 3 && i[10].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[10].tbc.value) : String(i[10].tbc),
                    fcp: i[2] === 3 && i[10].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[10].fcp.value) : String(i[10].fcp),
                    tbf: i[3] === 3 && i[10].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[10].tbf.value) : String(i[10].tbf)
                },
                march: {
                    tbc: i[1] === 3 && i[11].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[11].tbc.value) : String(i[11].tbc),
                    fcp: i[2] === 3 && i[11].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[11].fcp.value) : String(i[11].fcp),
                    tbf: i[3] === 3 && i[11].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[11].tbf.value) : String(i[11].tbf)
                },
                april: {
                    tbc: i[1] === 3 && i[12].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[12].tbc.value) : String(i[12].tbc),
                    fcp: i[2] === 3 && i[12].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[12].fcp.value) : String(i[12].fcp),
                    tbf: i[3] === 3 && i[12].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[12].tbf.value) : String(i[12].tbf)
                },
                may: {
                    tbc: i[1] === 3 && i[13].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[13].tbc.value) : String(i[13].tbc),
                    fcp: i[2] === 3 && i[13].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[13].fcp.value) : String(i[13].fcp),
                    tbf: i[3] === 3 && i[13].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[13].tbf.value) : String(i[13].tbf)
                },
                june: {
                    tbc: i[1] === 3 && i[14].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[14].tbc.value) : String(i[14].tbc),
                    fcp: i[2] === 3 && i[14].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[14].fcp.value) : String(i[14].fcp),
                    tbf: i[3] === 3 && i[14].tbc === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[14].tbf.value) : String(i[14].tbf)
                },
                july: {
                    tbc: i[1] === 3 && i[15].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[15].tbc.value) : String(i[15].tbc),
                    fcp: i[2] === 3 && i[15].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[15].fcp.value) : String(i[15].fcp),
                    tbf: i[3] === 3 && i[15].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[15].tbf.value) : String(i[15].tbf)
                },
                august: {
                    tbc: i[1] === 3 && i[16].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[16].tbc.value) : String(i[16].tbc),
                    fcp: i[2] === 3 && i[16].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[16].fcp.value) : String(i[16].fcp),
                    tbf: i[3] === 3 && i[16].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[16].tbf.value) : String(i[16].tbf)
                },
                september: {
                    tbc: i[1] === 3 && i[17].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[17].tbc.value) : String(i[17].tbc),
                    fcp: i[2] === 3 && i[17].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[17].fcp.value) : String(i[17].fcp),
                    tbf: i[3] === 3 && i[17].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[17].tbf.value) : String(i[17].tbf)
                },
                october: {
                    tbc: i[1] === 3 && i[18].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[18].tbc.value) : String(i[18].tbc),
                    fcp: i[2] === 3 && i[18].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[18].fcp.value) : String(i[18].fcp),
                    tbf: i[3] === 3 && i[18].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[18].tbf.value) : String(i[18].tbf)
                },
                november: {
                    tbc: i[1] === 3 && i[19].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[19].tbc.value) : String(i[19].tbc),
                    fcp: i[2] === 3 && i[19].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[19].fcp.value) : String(i[19].fcp),
                    tbf: i[3] === 3 && i[19].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[19].tbf.value) : String(i[19].tbf)
                },
                december: {
                    tbc: i[1] === 3 && i[20].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[20].tbc.value) : String(i[20].tbc),
                    fcp: i[2] === 3 && i[20].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[20].fcp.value) : String(i[20].fcp),
                    tbf: i[3] === 3 && i[20].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[20].tbf.value) : String(i[20].tbf)
                },
                total_current_year: String(Number(i[21]).toFixed(1)),
                total_next_year: {
                    tbc: String(Number(i[22].tbc).toFixed(1)),
                    fcp: String(Number(i[22].fcp).toFixed(1)),
                    tbf: String(Number(i[22].tbf).toFixed(1))
                },
                total_more_year: {
                    tbc: String(Number(i[23].tbc).toFixed(1)),
                    fcp: String(Number(i[23].fcp).toFixed(1)),
                    tbf: String(Number(i[23].tbf).toFixed(1))
                }
            })
        })
        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,
            "tax_planning": data
        }
        // console.log(JSON.stringify(payload));
        this.props.saveToMasterBudget(payload)
        this.props.onClickClose()
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                // console.log(err);
            }
            else {
                let isi = resp.rows.slice(4)
                // console.log(resp.rows[2]);
                // console.log(resp.rows);
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                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(),
                            january: {
                                tbc: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
                                fcp: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
                                tbf: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
                            },
                            february: {
                                tbc: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
                                fcp: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
                                tbf: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
                            },
                            march: {
                                tbc: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
                                fcp: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
                                tbf: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
                            },
                            april: {
                                tbc: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
                                fcp: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
                                tbf: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
                            },
                            may: {
                                tbc: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
                                fcp: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
                                tbf: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
                            },
                            june: {
                                tbc: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim(),
                                fcp: i[18] === undefined ? "0" : reg.test(String(i[18])) === false ? "0" : String(i[18]).trim(),
                                tbf: i[19] === undefined ? "0" : reg.test(String(i[19])) === false ? "0" : String(i[19]).trim(),
                            },
                            july: {
                                tbc: i[20] === undefined ? "0" : reg.test(String(i[20])) === false ? "0" : String(i[20]).trim(),
                                fcp: i[21] === undefined ? "0" : reg.test(String(i[21])) === false ? "0" : String(i[21]).trim(),
                                tbf: i[22] === undefined ? "0" : reg.test(String(i[22])) === false ? "0" : String(i[22]).trim(),
                            },
                            august: {
                                tbc: i[23] === undefined ? "0" : reg.test(String(i[23])) === false ? "0" : String(i[23]).trim(),
                                fcp: i[24] === undefined ? "0" : reg.test(String(i[24])) === false ? "0" : String(i[24]).trim(),
                                tbf: i[25] === undefined ? "0" : reg.test(String(i[25])) === false ? "0" : String(i[25]).trim(),
                            },
                            september: {
                                tbc: i[26] === undefined ? "0" : reg.test(String(i[26])) === false ? "0" : String(i[26]).trim(),
                                fcp: i[27] === undefined ? "0" : reg.test(String(i[27])) === false ? "0" : String(i[27]).trim(),
                                tbf: i[28] === undefined ? "0" : reg.test(String(i[28])) === false ? "0" : String(i[28]).trim(),
                            },
                            october: {
                                tbc: i[29] === undefined ? "0" : reg.test(String(i[29])) === false ? "0" : String(i[29]).trim(),
                                fcp: i[30] === undefined ? "0" : reg.test(String(i[30])) === false ? "0" : String(i[30]).trim(),
                                tbf: i[31] === undefined ? "0" : reg.test(String(i[31])) === false ? "0" : String(i[31]).trim(),
                            },
                            november: {
                                tbc: i[32] === undefined ? "0" : reg.test(String(i[32])) === false ? "0" : String(i[32]).trim(),
                                fcp: i[33] === undefined ? "0" : reg.test(String(i[33])) === false ? "0" : String(i[33]).trim(),
                                tbf: i[34] === undefined ? "0" : reg.test(String(i[34])) === false ? "0" : String(i[34]).trim(),
                            },
                            december: {
                                tbc: i[35] === undefined ? "0" : reg.test(String(i[35])) === false ? "0" : String(i[35]).trim(),
                                fcp: i[36] === undefined ? "0" : reg.test(String(i[36])) === false ? "0" : String(i[36]).trim(),
                                tbf: i[37] === undefined ? "0" : reg.test(String(i[37])) === false ? "0" : String(i[37]).trim(),
                            },
                            total_current_year: i[38] === undefined ? "" : String(i[38]).trim(),
                            total_next_year: {
                                tbc: i[39] === undefined ? "0" : reg.test(String(i[39])) === false ? "0" : String(i[39]).trim(),
                                fcp: i[40] === undefined ? "0" : reg.test(String(i[40])) === false ? "0" : String(i[40]).trim(),
                                tbf: i[41] === undefined ? "0" : reg.test(String(i[41])) === false ? "0" : String(i[41]).trim(),
                            },
                            total_more_year: {
                                tbc: i[42] === undefined ? "0" : reg.test(String(i[42])) === false ? "0" : String(i[42]).trim(),
                                fcp: i[43] === undefined ? "0" : reg.test(String(i[43])) === false ? "0" : String(i[43]).trim(),
                                tbf: i[44] === undefined ? "0" : reg.test(String(i[44])) === false ? "0" : String(i[44]).trim(),
                            }
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    tax_planning: payload
                }
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
                // console.log(this.state.judulColumn)
            }
        });
    }

    checkUpload() {
        api.create().checkUploadMB(this.state.payload).then(response => {
            // console.log(JSON.stringify(this.state.payload));
            // console.log(response)
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, visibleTP: false, loading: true })
                    let dataTable = response.data.data.map((item, index) => {
                        return [
                            // item.type_report_id,
                            0,
                            Number(item.type_report_id.tbc),
                            Number(item.type_report_id.fcp),
                            Number(item.type_report_id.tbf),
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            // {tbc: item.formula.tbc, fcp: item.formula.fcp, tbf: item.formula.tbf},
                            item.level,
                            item.item_report,
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.january.tbc, formula: item.january_formula } : item.january.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 || item.type_report_id.fcp == 7 ? { value: item.january.fcp, formula: item.january_formula } : item.january.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 || item.type_report_id.tbf == 7 ? { value: item.january.tbf, formula: item.january_formula } : item.january.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.february.tbc, formula: item.february_formula } : item.february.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.february.fcp, formula: item.february_formula } : item.february.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.february.tbf, formula: item.february_formula } : item.february.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.march.tbc, formula: item.march_formula } : item.march.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.march.fcp, formula: item.march_formula } : item.march.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.march.tbf, formula: item.march_formula } : item.march.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.april.tbc, formula: item.april_formula } : item.april.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.april.fcp, formula: item.april_formula } : item.april.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.april.tbf, formula: item.april_formula } : item.april.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.may.tbc, formula: item.may_formula } : item.may.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.may.fcp, formula: item.may_formula } : item.may.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.may.tbf, formula: item.may_formula } : item.may.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.june.tbc, formula: item.june_formula } : item.june.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.june.fcp, formula: item.june_formula } : item.june.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.june.tbf, formula: item.june_formula } : item.june.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.july.tbc, formula: item.july_formula } : item.july.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.july.fcp, formula: item.july_formula } : item.july.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.july.tbf, formula: item.july_formula } : item.july.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.august.tbc, formula: item.august_formula } : item.august.tbc === null ? "0" : item.august.tbc === "" ? "0" : item.august.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.august.fcp, formula: item.august_formula } : item.august.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.august.tbf, formula: item.august_formula } : item.august.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.september.tbc, formula: item.september_formula } : item.september.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.september.fcp, formula: item.september_formula } : item.september.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.september.tbf, formula: item.september_formula } : item.september.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.october.tbc, formula: item.october_formula } : item.october.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.october.fcp, formula: item.october_formula } : item.october.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.october.tbf, formula: item.october_formula } : item.october.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.november.tbc, formula: item.november_formula } : item.november.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.november.fcp, formula: item.november_formula } : item.november.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.november.tbf, formula: item.november_formula } : item.november.tbf },
                            { tbc: item.type_report_id.tbc == 5 || item.type_report_id.tbc == 6 || item.type_report_id.tbc == 7 ? { value: item.december.tbc, formula: item.december_formula } : item.december.tbc, fcp: item.type_report_id.fcp == 5 || item.type_report_id.fcp == 6 || item.type_report_id.fcp == 7 ? { value: item.december.fcp, formula: item.december_formula } : item.december.fcp, tbf: item.type_report_id.tbf == 5 || item.type_report_id.tbf == 6 || item.type_report_id.tbf == 7 ? { value: item.december.tbf, formula: item.december_formula } : item.december.tbf },
                            item.total_current_year,
                            {
                                tbc: Number(item.type_report_id.tbc) === 3 && item.total_next_year.tbc === "" ? "0" : item.total_next_year.tbc,
                                fcp: Number(item.type_report_id.fcp) === 3 && item.total_next_year.fcp === "" ? "0" : item.total_next_year.fcp,
                                tbf: Number(item.type_report_id.tbf) === 3 && item.total_next_year.tbf === "" ? "0" : item.total_next_year.tbf
                            },
                            {
                                tbc: Number(item.type_report_id.tbc) === 3 && item.total_more_year.tbc === "" ? "0" : item.total_more_year.tbc,
                                fcp: Number(item.type_report_id.fcp) === 3 && item.total_more_year.fcp === "" ? "0" : item.total_more_year.fcp,
                                tbf: Number(item.type_report_id.tbf) === 3 && item.total_more_year.tbf === "" ? "0" : item.total_more_year.tbf
                            },
                            item.orders,
                            { tbc: item.condition_it_should_be.tbc, fcp: item.condition_it_should_be.fcp, tbf: item.condition_it_should_be.tbf },
                            { tbc: item.condition_if_wrong.tbc, fcp: item.condition_if_wrong.fcp, tbf: item.condition_if_wrong.tbf },
                            item.forecast_tbc_formula,
                            item.forecast_fcp_formula,
                            item.forecast_tbf_formula,
                            item.error
                        ]
                    })
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, saveDraft: true }, () => {
                        this.state.dataTable.map(item => {
                            if (item[27].length > 0) {
                                // console.log('masuk')
                                this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true })
                            }
                        })
                        // console.log(this.state.dataTable);
                    })
                }
            }
        })
    }

    uploadTP(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[4],
                january: {
                    tbc: i[1] === 3 && i[9].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[9].tbc.value) : String(i[9].tbc),
                    fcp: i[2] === 3 && i[9].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[9].fcp.value) : String(i[9].fcp),
                    tbf: i[3] === 3 && i[9].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[9].tbf.value) : String(i[9].tbf)
                },
                february: {
                    tbc: i[1] === 3 && i[10].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[10].tbc.value) : String(i[10].tbc),
                    fcp: i[2] === 3 && i[10].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[10].fcp.value) : String(i[10].fcp),
                    tbf: i[3] === 3 && i[10].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[10].tbf.value) : String(i[10].tbf)
                },
                march: {
                    tbc: i[1] === 3 && i[11].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[11].tbc.value) : String(i[11].tbc),
                    fcp: i[2] === 3 && i[11].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[11].fcp.value) : String(i[11].fcp),
                    tbf: i[3] === 3 && i[11].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[11].tbf.value) : String(i[11].tbf)
                },
                april: {
                    tbc: i[1] === 3 && i[12].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[12].tbc.value) : String(i[12].tbc),
                    fcp: i[2] === 3 && i[12].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[12].fcp.value) : String(i[12].fcp),
                    tbf: i[3] === 3 && i[12].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[12].tbf.value) : String(i[12].tbf)
                },
                may: {
                    tbc: i[1] === 3 && i[13].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[13].tbc.value) : String(i[13].tbc),
                    fcp: i[2] === 3 && i[13].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[13].fcp.value) : String(i[13].fcp),
                    tbf: i[3] === 3 && i[13].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[13].tbf.value) : String(i[13].tbf)
                },
                june: {
                    tbc: i[1] === 3 && i[14].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[14].tbc.value) : String(i[14].tbc),
                    fcp: i[2] === 3 && i[14].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[14].fcp.value) : String(i[14].fcp),
                    tbf: i[3] === 3 && i[14].tbc === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[14].tbf.value) : String(i[14].tbf)
                },
                july: {
                    tbc: i[1] === 3 && i[15].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[15].tbc.value) : String(i[15].tbc),
                    fcp: i[2] === 3 && i[15].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[15].fcp.value) : String(i[15].fcp),
                    tbf: i[3] === 3 && i[15].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[15].tbf.value) : String(i[15].tbf)
                },
                august: {
                    tbc: i[1] === 3 && i[16].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[16].tbc.value) : String(i[16].tbc),
                    fcp: i[2] === 3 && i[16].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[16].fcp.value) : String(i[16].fcp),
                    tbf: i[3] === 3 && i[16].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[16].tbf.value) : String(i[16].tbf)
                },
                september: {
                    tbc: i[1] === 3 && i[17].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[17].tbc.value) : String(i[17].tbc),
                    fcp: i[2] === 3 && i[17].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[17].fcp.value) : String(i[17].fcp),
                    tbf: i[3] === 3 && i[17].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[17].tbf.value) : String(i[17].tbf)
                },
                october: {
                    tbc: i[1] === 3 && i[18].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[18].tbc.value) : String(i[18].tbc),
                    fcp: i[2] === 3 && i[18].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[18].fcp.value) : String(i[18].fcp),
                    tbf: i[3] === 3 && i[18].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[18].tbf.value) : String(i[18].tbf)
                },
                november: {
                    tbc: i[1] === 3 && i[19].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[19].tbc.value) : String(i[19].tbc),
                    fcp: i[2] === 3 && i[19].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[19].fcp.value) : String(i[19].fcp),
                    tbf: i[3] === 3 && i[19].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[19].tbf.value) : String(i[19].tbf)
                },
                december: {
                    tbc: i[1] === 3 && i[20].tbc === "" ? "0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(i[20].tbc.value) : String(i[20].tbc),
                    fcp: i[2] === 3 && i[20].fcp === "" ? "0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(i[20].fcp.value) : String(i[20].fcp),
                    tbf: i[3] === 3 && i[20].tbf === "" ? "0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(i[20].tbf.value) : String(i[20].tbf)
                },
                total_current_year: String(Number(i[21]).toFixed(1)),
                total_next_year: {
                    tbc: String(Number(i[22].tbc).toFixed(1)),
                    fcp: String(Number(i[22].fcp).toFixed(1)),
                    tbf: String(Number(i[22].tbf).toFixed(1))
                },
                total_more_year: {
                    tbc: String(Number(i[23].tbc).toFixed(1)),
                    fcp: String(Number(i[23].fcp).toFixed(1)),
                    tbf: String(Number(i[23].tbf).toFixed(1))
                }
            })
        })
        let body = {
            submission_id: this.props.submissionID,
            company_id: this.props.company.company_id,
            periode: this.props.periode,
            report_id: this.props.report_id,
            tax_planning: data,
            status: type
        }
        // console.log(data);
        api.create('UPLOAD').uploadMasterBudget(body).then(response => {
            // console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
                    this.props.onClickClose()
                    this.props.getReport()
                } else {
                    alert(response.data.status)
                }
            } else {
                this.setState({ loading: false })
                alert(response.problem)
            }
        })
    }

    handleValidate() {
        let data = []
        // console.log(this.state.dataTable)
        this.state.dataTable.map(i => {
            // console.log(i[0])
            data.push({
                item_report_id: i[4],
                january: {
                    tbc: i[1] === 3 && i[9].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[9].tbc.value).toFixed(1)) : String(Number(i[9].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[9].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[9].fcp.value).toFixed(1)) : String(Number(i[9].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[9].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[9].tbf.value).toFixed(1)) : String(Number(i[9].tbf).toFixed(1))
                },
                february: {
                    tbc: i[1] === 3 && i[10].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[10].tbc.value).toFixed(1)) : String(Number(i[10].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[10].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[10].fcp.value).toFixed(1)) : String(Number(i[10].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[10].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[10].tbf.value).toFixed(1)) : String(Number(i[10].tbf).toFixed(1))
                },
                march: {
                    tbc: i[1] === 3 && i[11].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[11].tbc.value).toFixed(1)) : String(Number(i[11].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[11].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[11].fcp.value).toFixed(1)) : String(Number(i[11].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[11].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[11].tbf.value).toFixed(1)) : String(Number(i[11].tbf).toFixed(1))
                },
                april: {
                    tbc: i[1] === 3 && i[12].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[12].tbc.value).toFixed(1)) : String(Number(i[12].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[12].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[12].fcp.value).toFixed(1)) : String(Number(i[12].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[12].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[12].tbf.value).toFixed(1)) : String(Number(i[12].tbf).toFixed(1))
                },
                may: {
                    tbc: i[1] === 3 && i[13].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[13].tbc.value).toFixed(1)) : String(Number(i[13].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[13].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[13].fcp.value).toFixed(1)) : String(Number(i[13].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[13].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[13].tbf.value).toFixed(1)) : String(Number(i[13].tbf).toFixed(1))
                },
                june: {
                    tbc: i[1] === 3 && i[14].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[14].tbc.value).toFixed(1)) : String(Number(i[14].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[14].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[14].fcp.value).toFixed(1)) : String(Number(i[14].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[14].tbc === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[14].tbf.value).toFixed(1)) : String(Number(i[14].tbf).toFixed(1))
                },
                july: {
                    tbc: i[1] === 3 && i[15].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[15].tbc.value).toFixed(1)) : String(Number(i[15].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[15].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[15].fcp.value).toFixed(1)) : String(Number(i[15].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[15].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[15].tbf.value).toFixed(1)) : String(Number(i[15].tbf).toFixed(1))
                },
                august: {
                    tbc: i[1] === 3 && i[16].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[16].tbc.value).toFixed(1)) : String(Number(i[16].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[16].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[16].fcp.value).toFixed(1)) : String(Number(i[16].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[16].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[16].tbf.value).toFixed(1)) : String(Number(i[16].tbf).toFixed(1))
                },
                september: {
                    tbc: i[1] === 3 && i[17].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[17].tbc.value).toFixed(1)) : String(Number(i[17].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[17].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[17].fcp.value).toFixed(1)) : String(Number(i[17].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[17].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[17].tbf.value).toFixed(1)) : String(Number(i[17].tbf).toFixed(1))
                },
                october: {
                    tbc: i[1] === 3 && i[18].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[18].tbc.value).toFixed(1)) : String(Number(i[18].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[18].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[18].fcp.value).toFixed(1)) : String(Number(i[18].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[18].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[18].tbf.value).toFixed(1)) : String(Number(i[18].tbf).toFixed(1))
                },
                november: {
                    tbc: i[1] === 3 && i[19].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[19].tbc.value).toFixed(1)) : String(Number(i[19].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[19].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[19].fcp.value).toFixed(1)) : String(Number(i[19].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[19].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[19].tbf.value).toFixed(1)) : String(Number(i[19].tbf).toFixed(1))
                },
                december: {
                    tbc: i[1] === 3 && i[20].tbc === "" ? "0.0" : i[1] === 5 || i[1] === 6 || i[1] === 7 ? String(Number(i[20].tbc.value).toFixed(1)) : String(Number(i[20].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[20].fcp === "" ? "0.0" : i[2] === 5 || i[2] === 6 || i[2] === 7 ? String(Number(i[20].fcp.value).toFixed(1)) : String(Number(i[20].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[20].tbf === "" ? "0.0" : i[3] === 5 || i[3] === 6 || i[3] === 7 ? String(Number(i[20].tbf.value).toFixed(1)) : String(Number(i[20].tbf).toFixed(1))
                },
                total_current_year: i[2] === 3 && i[21] === "" ? "0.0" : String(Number(i[21]).toFixed(1)),
                total_next_year: {
                    tbc: i[1] === 3 && i[22].tbc === "" ? "0.0" : String(Number(i[22].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[22].fcp === "" ? "0.0" : String(Number(i[22].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[22].tbf === "" ? "0.0" : String(Number(i[22].tbf).toFixed(1))
                },
                total_more_year: {
                    tbc: i[1] === 3 && i[23].tbc === "" ? "0.0" : String(Number(i[23].tbc).toFixed(1)),
                    fcp: i[2] === 3 && i[23].fcp === "" ? "0.0" : String(Number(i[23].fcp).toFixed(1)),
                    tbf: i[3] === 3 && i[23].tbf === "" ? "0.0" : String(Number(i[23].tbf).toFixed(1))
                }
            })
        })
        let payload = {
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "tax_planning": data,
            "status": "submitted"
        }
        // console.log(JSON.stringify(payload));
        api.create().validateSubmitReport(payload).then((response) => {
            // console.log(response)
            if (response.data.data.result) {
                this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
                // alert("Type Input Can't be Empty")
            } else {
                this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
            }
        })
    }

    downloadTemplate = async () => {
        let res = await fetch(
            `${process.env.REACT_APP_URL_MAIN_BE}/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;
            a.download = 'Template Master Budget Tax Planning.xlsx';
            a.click();
        }
    }

    async downloadAllData() {
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/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}`
        let sub_null = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
        // console.log(url);
        let res = await fetch(
            this.props.submissionID == null ? sub_null : url
        )
        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;
            a.download = 'Master Budget Tax Planning.xlsx';
            a.click();
        }
    }

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

    render() {
        let columns = [
        {
            name: "Company",
            options: {
                customHeadRender: (columnMeta) => (
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300 }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style }),
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ width: 300 }}>
                           { val }
                        </div>
                    )
                }
            }
        }, {
            name: `Revenue`,
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ borderBottom: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
                        <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                            <div className="column-1 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2010"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2011"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2012"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2013"}</span>
                                    </div>
                                </div>
                                <div className="column-2 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2014"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2015"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2016"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2017"}</span>
                                    </div>

                                </div>
                                <div className="column-3 grid grid-3x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2018"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2019"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2020"}</span>
                                    </div>
                                    {/* <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                        <span>{"2021"}</span>
                                    </div> */}
                                </div>
                        </div>
                    </th>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (val, tableMeta, updateValue) => {
                    return (
                        <div>
                            <div className="grid grid-3x content-center">
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    {/* <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div> */}
                                </div>
                            </div>
                        </div>
                    )
                }
            }
        }, {
            name: `EBITDA`,
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ borderBottom: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
                        <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                            <div className="column-1 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2010"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2011"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2012"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2013"}</span>
                                    </div>
                                </div>
                                <div className="column-2 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2014"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2015"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2016"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2017"}</span>
                                    </div>

                                </div>
                                <div className="column-3 grid grid-3x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2018"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2019"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2020"}</span>
                                    </div>
                                    {/* <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                        <span>{"2021"}</span>
                                    </div> */}
                                </div>
                        </div>
                    </th>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (val, tableMeta, updateValue) => {
                    return (
                        <div>
                            <div className="grid grid-3x content-center">
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    {/* <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div> */}
                                </div>
                            </div>
                        </div>
                    )
                }
            }
        }, {
            name: `TPAT`,
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ borderBottom: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
                        <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                            <div className="column-1 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2010"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2011"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2012"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2013"}</span>
                                    </div>
                                </div>
                                <div className="column-2 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2014"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2015"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2016"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2017"}</span>
                                    </div>

                                </div>
                                <div className="column-3 grid grid-3x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2018"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2019"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2020"}</span>
                                    </div>
                                    {/* <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                        <span>{"2021"}</span>
                                    </div> */}
                                </div>
                        </div>
                    </th>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (val, tableMeta, updateValue) => {
                    return (
                        <div>
                            <div className="grid grid-3x content-center">
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    {/* <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div> */}
                                </div>
                            </div>
                        </div>
                    )
                }
            }
        }, {
            name: `NPAT`,
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ borderBottom: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
                        <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                            <div className="column-1 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2010"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2011"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2012"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2013"}</span>
                                    </div>
                                </div>
                                <div className="column-2 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2014"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2015"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2016"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2017"}</span>
                                    </div>

                                </div>
                                <div className="column-3 grid grid-3x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2018"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2019"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2020"}</span>
                                    </div>
                                    {/* <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                        <span>{"2021"}</span>
                                    </div> */}
                                </div>
                        </div>
                    </th>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (val, tableMeta, updateValue) => {
                    return (
                        <div>
                            <div className="grid grid-3x content-center">
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    {/* <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div> */}
                                </div>
                            </div>
                        </div>
                    )
                }
            }
        }, {
            name: `Total Asset`,
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ borderBottom: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
                        <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                            <div className="column-1 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2010"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2011"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2012"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2013"}</span>
                                    </div>
                                </div>
                                <div className="column-2 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2014"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2015"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2016"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2017"}</span>
                                    </div>

                                </div>
                                <div className="column-3 grid grid-3x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2018"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2019"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2020"}</span>
                                    </div>
                                    {/* <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                        <span>{"2021"}</span>
                                    </div> */}
                                </div>
                        </div>
                    </th>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (val, tableMeta, updateValue) => {
                    return (
                        <div>
                            <div className="grid grid-3x content-center">
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    {/* <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div> */}
                                </div>
                            </div>
                        </div>
                    )
                }
            }
        }, {
            name: `Total Equility`,
            options: {
                customHeadRender: (columnMeta) => (
                    <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                        <div style={{ borderBottom: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
                        <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                            <div className="column-1 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2010"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2011"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2012"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2013"}</span>
                                    </div>
                                </div>
                                <div className="column-2 grid grid-4x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2014"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2015"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2016"}</span>
                                    </div>
                                    <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2017"}</span>
                                    </div>

                                </div>
                                <div className="column-3 grid grid-3x" style={{ placeSelf: 'center', textAlign: 'center' }}>
                                    <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2018"}</span>
                                    </div>
                                    <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2019"}</span>
                                    </div>
                                    <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid" }}>
                                        <span>{"2020"}</span>
                                    </div>
                                    {/* <div className="column-4" style={{ placeSelf: 'center', textAlign: 'center', padding: 5 }}>
                                        <span>{"2021"}</span>
                                    </div> */}
                                </div>
                        </div>
                    </th>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (val, tableMeta, updateValue) => {
                    return (
                        <div>
                            <div className="grid grid-3x content-center">
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-4x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div>
                                </div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.a}
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.b}
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.c}
                                        </div>
                                    </div>
                                    {/* <div className="col-4">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {val.d}
                                        </div>
                                    </div> */}
                                </div>
                            </div>
                        </div>
                    )
                }
            }
        }
        ]
        let datas = [
            ["ABCD", { a: "2", b: "3", c: "4", d: "5" }, { a: "2", b: "3", c: "4", d: "5" }, { a: "2", b: "3", c: "4", d: "5" }, { a: "2", b: "3", c: "4", d: "5" }, { a: "2", b: "3", c: "4", d: "5" }, { a: "2", b: "3", c: "4", d: "5" }],
            ["Total Assets", { a: "6", b: "7", c: "8", d: "9" }, { a: "6", b: "7", c: "8", d: "9" }, { a: "6", b: "7", c: "8", d: "9" }, { a: "6", b: "7", c: "8", d: "9" }, { a: "6", b: "7", c: "8", d: "9" }, { a: "6", b: "7", c: "8", d: "9" }]
        ]
        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>
        );

        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                    <Typography style={{ fontSize: '16px', color: 'white' }}>FINANCIAL SUMMARY OF TRIPUTRA GROUP</Typography>
                </div>
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
                {/* {this.state.loading && loadingComponent} */}
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
                    {/* {this.state.visibleTP === true ? */}
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Historical</Typography>
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Historical</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : 2021 </Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
                                        {this.state.dataTable.length == 0 ? null : this.props.isApprover == true ?
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            </div> :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                {((this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && (
                                                    <div>
                                                        <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" />
                                                    </div>
                                                )}
                                                {((this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted')) && (
                                                    <div>
                                                        <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" />
                                                    </div>
                                                )}
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            </div>
                                        }
                                    </div>
                                </div>

                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {this.state.loading && loadingComponent}
                                    <MuiThemeProvider theme={getMuiTheme()}>
                                        <MUIDataTable
                                            data={datas}
                                            columns={columns}
                                            options={options}
                                        />
                                    </MuiThemeProvider>
                                </div>
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
                            </div>
                            <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                <div className="col-1">
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none'
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
                                        </div>
                                    </button>
                                </div>
                                {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
                                    (this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ?
                                <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                        onClick={() => {
                                            // this.forceUpdate()
                                            this.setState({ loading: true, buttonDraft: false }, () => {
                                                setTimeout(() => {
                                                    // this.setState({ loading: false, buttonError: false, editable: true })
                                                    this.handleValidate()
                                                }, 100);
                                            })
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                            <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                        </div>
                                    </button>
                                    <button
                                        className="button"
                                        type="button"
                                        onClick={() =>
                                            this.state.saveDraft === true ?
                                                null :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.backToMasterBudget('draft')
                                                        }, 100);
                                                    })
                                        }
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: this.state.saveDraft !== true ? 'pointer' : 'default',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                        </div>
                                    </button>
                                    <button
                                        type="button"
                                        disabled={this.state.buttonError}
                                        onClick={() => this.state.buttonError ?
                                            this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                            :
                                            this.state.handleTekTekTek == 1 ? null :
                                                this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                    setTimeout(() => {
                                                        this.backToMasterBudget('submitted')
                                                    }, 100);
                                                })}
                                        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', marginRight: 20 }}>
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                        </div>
                                    </button>
                                </div>
                                : null }
                            </div>
                        </Paper>
                        {/* :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div>
                                <div style={{ padding: 25 }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Historical</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : 2021 </Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    {this.state.dataLoaded && (
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                            {this.state.loading && loadingComponent}
                                            <MuiThemeProvider theme={getMuiTheme()}>
                                                <MUIDataTable
                                                    data={datas}
                                                    columns={columns}
                                                    options={options}
                                                />
                                            </MuiThemeProvider>
                                        </div>
                                    )}
                                </div>
                                <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                    <div className="col-1">
                                        <button
                                            type="button"
                                            onClick={() => this.setState({ loading: true, visibleTP: true }, () => {
                                                setTimeout(() => {
                                                    this.getItemHierarki()
                                                }, 100);
                                            })}
                                            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"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                // this.forceUpdate()
                                                this.setState({ loading: true, buttonDraft: false }, () => {
                                                    setTimeout(() => {
                                                        this.handleValidate()
                                                    }, 100);
                                                })
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
                                        </button>
                                        <button
                                            type="button"
                                            // disabled={this.state.buttonError}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.saveDraft !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => this.state.saveDraft === true ?
                                                null
                                                :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.uploadTP('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}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                            onClick={() => this.state.editable === true ?
                                                null
                                                :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1, loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.uploadTP('submitted')
                                                        }, 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 & Complete</Typography>
                                            </div>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </Paper> */}
                    {/* } */}
                </div>
                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                    </div>
                                </div>
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
                                acceptedFiles={["xlsx"]}
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
                                onUpload={() => {
                                    this.state.judul === "MASTER BUDGET - TAX PLANNING" ?
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
            </div>
        );
    }
}