CorporateAnnualTarget.js 140 KB
Newer Older
1
import React, { Component } from 'react';
d.arizona's avatar
d.arizona committed
2
import { Typography, Paper, createMuiTheme, ThemeProvider, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, withStyles, makeStyles, Snackbar } from '@material-ui/core';
3 4
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
faisalhamdi's avatar
faisalhamdi committed
5
import api from '../../api';
faisalhamdi's avatar
faisalhamdi committed
6 7 8 9 10
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';
d.arizona's avatar
d.arizona committed
11 12 13
import Tooltip from '@material-ui/core/Tooltip';
import { titleCase } from '../../library/Utils';
import Constant from '../../library/Constant';
d.arizona's avatar
d.arizona committed
14
import { Alert, Autocomplete } from '@material-ui/lab';
d.arizona's avatar
d.arizona committed
15 16
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
17

d.arizona's avatar
d.arizona committed
18
const LightTooltip = withStyles((theme) => ({
Deni Rinaldi's avatar
Deni Rinaldi committed
19 20 21 22 23 24
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
d.arizona's avatar
d.arizona committed
25
}))(Tooltip);
26
var ct = require("../../library/CustomTable");
d.arizona's avatar
d.arizona committed
27
const getMuiTheme = () => createMuiTheme(ct.customTable3());
28 29 30 31 32 33 34 35 36 37 38

const options = ct.customOptionsFixedColumn();
const style = {
    position: "sticky",
    left: 0,
    background: "white",
    zIndex: 101,
};
const style2 = {
    position: "sticky",
    background: "white",
faisalhamdi's avatar
faisalhamdi committed
39
    zIndex: 100
40
};
d.arizona's avatar
d.arizona committed
41 42 43

const theme = createMuiTheme({
    overrides: {
Deni Rinaldi's avatar
Deni Rinaldi committed
44 45 46 47 48 49
        // Style sheet name ⚛️
        MuiInputBase: {
            input: {
                color: '#5198ea'
            }
        }
d.arizona's avatar
d.arizona committed
50
    },
Deni Rinaldi's avatar
Deni Rinaldi committed
51
});
d.arizona's avatar
d.arizona committed
52

53 54 55 56 57
export default class CorporateAnnualTarget extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [
faisalhamdi's avatar
faisalhamdi committed
58 59 60 61 62 63
                // ["FINANCIAL PERSPECTIVE", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181"],
                // ["Control", "-", "-"],
                // ["Accumulated Depreciation (negative value)", "2,647,647", "2,058,898"],
                // ["Control", "-", "-"],
                // ["Gain / (Loss) on Fixed Assets", "-", "-"],
                // ["Control", "-", "-"]
d.arizona's avatar
d.arizona committed
64 65 66 67
            ],
            loading: false,
            uomList: [],
            formulaYtdList: {
Deni Rinaldi's avatar
Deni Rinaldi committed
68
                options: [{ value: 'SUM' }, { value: 'AVG' }, { value: 'LAST' }],
d.arizona's avatar
d.arizona committed
69 70 71 72
                getOptionLabel: (option) => titleCase(option.value),
            },
            kpiTypeList: [],
            maxAchList: [],
d.arizona's avatar
d.arizona committed
73
            visibleCAT: true,
d.arizona's avatar
d.arizona committed
74
            buttonError: true,
d.arizona's avatar
d.arizona committed
75
            // formulaYTDList: null,,
d.arizona's avatar
d.arizona committed
76
            dataDelete: [],
d.arizona's avatar
d.arizona committed
77
            dataReal: [],
d.arizona's avatar
d.arizona committed
78
            buttonDraft: true,
d.arizona's avatar
d.arizona committed
79
            updateBy: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
80 81
            handleTekTekTek: 0,
            editable: false
82
        }
d.arizona's avatar
d.arizona committed
83 84
        this.fileHandler = this.fileHandler.bind(this);

85 86 87
    }

    componentDidMount() {
d.arizona's avatar
d.arizona committed
88
        this.getKPIType()
d.arizona's avatar
d.arizona committed
89
        this.getMaxAch()
d.arizona's avatar
d.arizona committed
90 91
        this.getLatestUpdate()
        console.log(this.props.lastStatus);
Deni Rinaldi's avatar
Deni Rinaldi committed
92

93 94
    }

faisalhamdi's avatar
faisalhamdi committed
95
    getItemHierarki() {
faisalhamdi's avatar
faisalhamdi committed
96
        this.setState({ loading: true })
faisalhamdi's avatar
faisalhamdi committed
97 98
        let payload = {
            "report_id": this.props.report_id,
faisalhamdi's avatar
faisalhamdi committed
99 100
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
faisalhamdi's avatar
faisalhamdi committed
101 102
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID
faisalhamdi's avatar
faisalhamdi committed
103
        }
d.arizona's avatar
d.arizona committed
104
        console.log(JSON.stringify(payload))
faisalhamdi's avatar
faisalhamdi committed
105
        api.create().getDetailReportMB(payload).then(response => {
d.arizona's avatar
d.arizona committed
106
            let dataTable = []
d.arizona's avatar
d.arizona committed
107
            console.log(response)
d.arizona's avatar
d.arizona committed
108 109 110 111
            let res = response.data.data
            const handlePushChild = (item) => {
                let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                if (indexIDzz === -1) {
d.arizona's avatar
d.arizona committed
112
                    let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE'
d.arizona's avatar
d.arizona committed
113 114 115 116 117 118 119 120
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        "",
                        item.description,
d.arizona's avatar
d.arizona committed
121
                        item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.cat.weight).indexOf(".") == -1 ? item.cat.weight : `${Number(item.weight) * 100}%`),
d.arizona's avatar
d.arizona committed
122
                        parentTrue? item.cat.uom : item.uom,
d.arizona's avatar
d.arizona committed
123 124 125
                        parentTrue? item.cat.kpi_type == "" ? null : { value: item.cat.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
                        parentTrue? item.cat.max_ach == "" ? null : { value: item.cat.max_ach } : item.max_ach == "" ? null : { value: item.max_ach },
                        parentTrue? item.cat.formula == "" ? null : { value: item.cat.formula }: item.formula_ytd == "" ? null : { value: item.formula_ytd },
Deni Rinaldi's avatar
Deni Rinaldi committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
                        item.cat.total_actual_before == "" ? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1 ? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1),
                        item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1),
                        item.cat.february == "" ? item.cat.february : String(item.cat.february).indexOf(".") == -1 ? Number(item.cat.february) : Number(item.cat.february).toFixed(1),
                        item.cat.march == "" ? item.cat.march : String(item.cat.march).indexOf(".") == -1 ? Number(item.cat.march) : Number(item.cat.march).toFixed(1),
                        item.cat.april == "" ? item.cat.april : String(item.cat.april).indexOf(".") == -1 ? Number(item.cat.april) : Number(item.cat.april).toFixed(1),
                        item.cat.may == "" ? item.cat.may : String(item.cat.may).indexOf(".") == -1 ? Number(item.cat.may) : Number(item.cat.may).toFixed(1),
                        item.cat.june == "" ? item.cat.june : String(item.cat.june).indexOf(".") == -1 ? Number(item.cat.june) : Number(item.cat.june).toFixed(1),
                        item.cat.july == "" ? item.cat.july : String(item.cat.july).indexOf(".") == -1 ? Number(item.cat.july) : Number(item.cat.july).toFixed(1),
                        item.cat.august == "" ? item.cat.august : String(item.cat.august).indexOf(".") == -1 ? Number(item.cat.august) : Number(item.cat.august).toFixed(1),
                        item.cat.september == "" ? item.cat.september : String(item.cat.september).indexOf(".") == -1 ? Number(item.cat.september) : Number(item.cat.september).toFixed(1),
                        item.cat.october == "" ? item.cat.october : String(item.cat.october).indexOf(".") == -1 ? Number(item.cat.october) : Number(item.cat.october).toFixed(1),
                        item.cat.november == "" ? item.cat.november : String(item.cat.november).indexOf(".") == -1 ? Number(item.cat.november) : Number(item.cat.november).toFixed(1),
                        item.cat.december == "" ? item.cat.december : String(item.cat.december).indexOf(".") == -1 ? Number(item.cat.december) : Number(item.cat.december).toFixed(1),
                        item.cat.total_current_year == "" ? item.cat.total_current_year : String(item.cat.total_current_year).indexOf(".") == -1 ? Number(item.cat.total_current_year) : Number(item.cat.total_current_year).toFixed(1),
                        item.cat.total_next_year == "" ? item.cat.total_next_year : String(item.cat.total_next_year).indexOf(".") == -1 ? Number(item.cat.total_next_year) : Number(item.cat.total_next_year).toFixed(1),
                        item.cat.total_more_year == "" ? item.cat.total_more_year : String(item.cat.total_more_year).indexOf(".") == -1 ? Number(item.cat.total_more_year) : Number(item.cat.total_more_year).toFixed(1),
d.arizona's avatar
d.arizona committed
142 143 144 145 146 147
                        item.cat.strategic,
                        item.cat.pic
                    ])
                }
                if (item.children !== null) {
                    if (item.children.length > 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
148
                        item.children.map((items, indexs) => {
d.arizona's avatar
d.arizona committed
149 150 151
                            handlePushChild(items)
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
152 153
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
154
            res.map((item, index) => {
d.arizona's avatar
d.arizona committed
155 156 157 158 159 160 161 162
                dataTable.push([
                    item.type_report_id,
                    item.id,
                    item.parent,
                    item.formula,
                    item.level,
                    "",
                    item.description,
Deni Rinaldi's avatar
Deni Rinaldi committed
163
                    item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : item.cat.weight,
d.arizona's avatar
d.arizona committed
164
                    item.cat.uom,
d.arizona's avatar
d.arizona committed
165 166 167
                    item.kpi_type == "" ? null : { value: item.kpi_type },
                    item.max_ach == "" ? null : { value: item.max_ach },
                    item.formula == "" ? null : { value: item.formula_ytd },
Deni Rinaldi's avatar
Deni Rinaldi committed
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
                    item.cat.total_actual_before == "" ? item.cat.total_actual_before : String(item.cat.total_actual_before).indexOf(".") == -1 ? Number(item.cat.total_actual_before) : Number(item.cat.total_actual_before).toFixed(1),
                    item.cat.january == "" ? item.cat.january : String(item.cat.january).indexOf(".") == -1 ? Number(item.cat.january) : Number(item.cat.january).toFixed(1),
                    item.cat.february == "" ? item.cat.february : String(item.cat.february).indexOf(".") == -1 ? Number(item.cat.february) : Number(item.cat.february).toFixed(1),
                    item.cat.march == "" ? item.cat.march : String(item.cat.march).indexOf(".") == -1 ? Number(item.cat.march) : Number(item.cat.march).toFixed(1),
                    item.cat.april == "" ? item.cat.april : String(item.cat.april).indexOf(".") == -1 ? Number(item.cat.april) : Number(item.cat.april).toFixed(1),
                    item.cat.may == "" ? item.cat.may : String(item.cat.may).indexOf(".") == -1 ? Number(item.cat.may) : Number(item.cat.may).toFixed(1),
                    item.cat.june == "" ? item.cat.june : String(item.cat.june).indexOf(".") == -1 ? Number(item.cat.june) : Number(item.cat.june).toFixed(1),
                    item.cat.july == "" ? item.cat.july : String(item.cat.july).indexOf(".") == -1 ? Number(item.cat.july) : Number(item.cat.july).toFixed(1),
                    item.cat.august == "" ? item.cat.august : String(item.cat.august).indexOf(".") == -1 ? Number(item.cat.august) : Number(item.cat.august).toFixed(1),
                    item.cat.september == "" ? item.cat.september : String(item.cat.september).indexOf(".") == -1 ? Number(item.cat.september) : Number(item.cat.september).toFixed(1),
                    item.cat.october == "" ? item.cat.october : String(item.cat.october).indexOf(".") == -1 ? Number(item.cat.october) : Number(item.cat.october).toFixed(1),
                    item.cat.november == "" ? item.cat.november : String(item.cat.november).indexOf(".") == -1 ? Number(item.cat.november) : Number(item.cat.november).toFixed(1),
                    item.cat.december == "" ? item.cat.december : String(item.cat.december).indexOf(".") == -1 ? Number(item.cat.december) : Number(item.cat.december).toFixed(1),
                    item.cat.total_current_year == "" ? item.cat.total_current_year : String(item.cat.total_current_year).indexOf(".") == -1 ? Number(item.cat.total_current_year) : Number(item.cat.total_current_year).toFixed(1),
                    item.cat.total_next_year == "" ? item.cat.total_next_year : String(item.cat.total_next_year).indexOf(".") == -1 ? Number(item.cat.total_next_year) : Number(item.cat.total_next_year).toFixed(1),
                    item.cat.total_more_year == "" ? item.cat.total_more_year : String(item.cat.total_more_year).indexOf(".") == -1 ? Number(item.cat.total_more_year) : Number(item.cat.total_more_year).toFixed(1),
d.arizona's avatar
d.arizona committed
184 185 186 187 188
                    item.cat.strategic,
                    item.cat.pic
                ])
                if (item.children !== null) {
                    if (item.children.length > 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
189
                        item.children.map((items, indexs) => {
d.arizona's avatar
d.arizona committed
190 191 192 193 194
                            handlePushChild(items)
                        })
                    }
                }
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
195
            this.setState({ dataTable, loading: false, dataReal: res, editable: true })
faisalhamdi's avatar
faisalhamdi committed
196 197 198
        })
    }

d.arizona's avatar
d.arizona committed
199 200 201 202 203 204 205 206 207 208
    downloadTemplate = async () => {
        let res = await fetch(
            `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
        )
        res = await res.blob()
        console.log(res)
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
d.arizona's avatar
d.arizona committed
209
            a.download = 'Template Master Budget CAT.xlsx';
d.arizona's avatar
d.arizona committed
210 211 212 213 214 215
            a.click();
        }
    }

    async downloadAllData() {
        console.log('masuk')
Deni Rinaldi's avatar
Deni Rinaldi committed
216
        let bram = [this.props.submissionID, this.props.report_id, this.props.company.company_id, this.props.periode, this.props.revision]
d.arizona's avatar
d.arizona committed
217
        console.log(bram)
d.arizona's avatar
d.arizona committed
218 219
        let resReal = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
        let resNull = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
d.arizona's avatar
d.arizona committed
220
        let res = await fetch(
d.arizona's avatar
d.arizona committed
221
            this.props.submissionID == null? resNull : resReal
d.arizona's avatar
d.arizona committed
222 223 224 225 226 227 228 229
        )
        res = await res.blob()
        console.log(res)
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
d.arizona's avatar
d.arizona committed
230
            a.download = 'Master Budget CAT.xlsx';
d.arizona's avatar
d.arizona committed
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
            a.click();
        }
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                console.log(isi);
                let payload = []
d.arizona's avatar
d.arizona committed
246
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
d.arizona's avatar
d.arizona committed
247 248
                isi.map((i, index) => {
                    if (i.length > 0) {
d.arizona's avatar
d.arizona committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
                        let total = 0
                        let lastValz = 0
                        let nilaiTotal = 0
                        if (i[6] !== undefined) {
                            if (i[6] == 'SUM' || i[6] == 'AVG' || i[6] == 'LAST') {
                                i.map((items, indexs) => {
                                    if (indexs >= 8 && indexs <= 19) {
                                        let valItem = items == undefined || items == "" ? 0 : items
                                        total += Number(valItem)
                                        if (index == 19) {
                                            lastValz += Number(valItem)
                                        }
                                    }
                                })
                            }
                            nilaiTotal = i[6] == 'SUM'? total : i[6] == 'AVG'? total/12 : lastValz
                        }
                        console.log(nilaiTotal)
d.arizona's avatar
d.arizona committed
267
                        // console.log(i[2] === undefined ? "" : String(Number(i[2]*100)).length > 3? String(Number(i[2]*100).toFixed(0) + '%') : String(Number(i[2]*100)) + '%')
d.arizona's avatar
d.arizona committed
268
                        payload.push({
d.arizona's avatar
d.arizona committed
269
                            item_report_id: i[0] === undefined ? "" : reg.test(String(i[0])) === false ? "" : String(i[0]).trim(),
d.arizona's avatar
d.arizona committed
270
                            item_report: i[1] === undefined ? "" : String(i[1]).trim(),
d.arizona's avatar
d.arizona committed
271
                            weight: i[2] === undefined ? "" : String(Number(i[2]*100)).length > 3? String(Number(i[2]*100).toFixed(0) + '%') : String(Number(i[2]*100)) + '%',
d.arizona's avatar
d.arizona committed
272 273 274 275
                            uom: i[3] === undefined ? "" : String(i[3]).trim(),
                            kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
                            max_ach: i[5] === undefined ? "" : String(i[5]).toLocaleLowerCase() !== 'unlimited' ? String(Number(i[5]*100) + '%') : String(i[5]).trim(),
                            formula: i[6] === undefined ? "" : String(i[6]).trim(),
d.arizona's avatar
d.arizona committed
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
                            total_actual_before: i[7] === undefined ? "0.0" : reg.test(String(i[7])) === false ? "0.0" : String(Number(i[7]).toFixed(1)).trim(),
                            january: i[8] === undefined ? "0.0" : reg.test(String(i[8])) === false ? "0.0" : String(Number(i[8]).toFixed(1)).trim(),
                            february: i[9] === undefined ? "0.0" : reg.test(String(i[9])) === false ? "0.0" : String(Number(i[9]).toFixed(1)).trim(),
                            march: i[10] === undefined ? "0.0" : reg.test(String(i[10])) === false ? "0.0" : String(Number(i[10].toFixed(1))).trim(),
                            april: i[11] === undefined ? "0.0" : reg.test(String(i[11])) === false ? "0.0" : String(Number(i[11]).toFixed(1)).trim(),
                            may: i[12] === undefined ? "0.0" : reg.test(String(i[12])) === false ? "0.0" : String(Number(i[12].toFixed(1))).trim(),
                            june: i[13] === undefined ? "0.0" : reg.test(String(i[13])) === false ? "0.0" : String(Number(i[13].toFixed(1))).trim(),
                            july: i[14] === undefined ? "0.0" : reg.test(String(i[14])) === false ? "0.0" : String(Number(i[14].toFixed(1))).trim(),
                            august: i[15] === undefined ? "0.0" : reg.test(String(i[15])) === false ? "0.0" : String(Number(i[15]).toFixed(1)).trim(),
                            september: i[16] === undefined ? "0.0" : reg.test(String(i[16])) === false ? "0.0" : String(Number(i[16]).toFixed(1)).trim(),
                            october: i[17] === undefined ? "0.0" : reg.test(String(i[17])) === false ? "0.0" : String(Number(i[17]).toFixed(1)).trim(),
                            november: i[18] === undefined ? "0.0" : reg.test(String(i[18])) === false ? "0.0" : String(Number(i[18]).toFixed(1)).trim(),
                            december: i[19] === undefined ? "0.0" : reg.test(String(i[19])) === false ? "0.0" : String(Number(i[19]).toFixed(1)).trim(),
                            total_current_year: i[20] == 0? "0.0" : String(Number(nilaiTotal).toFixed(1)).trim(),
                            total_next_year: i[21] === undefined ? "0.0" : reg.test(String(i[21])) === false ? "0.0" : String(Number(i[21]).toFixed(1)).trim(),
                            total_more_year: i[22] === undefined ? "0.0" : reg.test(String(i[22])) === false ? "0.0" : String(Number(i[22]).toFixed(1)).trim(),
d.arizona's avatar
d.arizona committed
292 293
                            strategic: i[23] === undefined ? "" : String(i[23]).trim(),
                            pic: i[24] === undefined ? "" : String(i[24]).trim()
d.arizona's avatar
d.arizona committed
294 295 296 297 298 299 300
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
d.arizona's avatar
d.arizona committed
301
                    status: '',
d.arizona's avatar
d.arizona committed
302 303 304 305 306 307 308 309 310
                    cat: payload
                }
                console.log(body)
                this.setState({ payload: body, judul: resp.rows[1][0] })
            }
        });
    }

    checkUpload() {
d.arizona's avatar
d.arizona committed
311
        this.setState({loading: true})
d.arizona's avatar
d.arizona committed
312 313 314
        let dataDelete = this.state.dataDelete
        api.create().getIdDeleteFromExcel(this.state.payload).then((response) => {
            if (response.data) {
d.arizona's avatar
d.arizona committed
315
                // console.log(response.data)
d.arizona's avatar
d.arizona committed
316 317
                let idDelete = response.data.data.item_report_id
                if (idDelete.length > 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
318
                    idDelete.map((item, index) => {
d.arizona's avatar
d.arizona committed
319 320
                        dataDelete.push(item)
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
321
                    this.setState({ dataDelete })
d.arizona's avatar
d.arizona committed
322 323 324
                }
            }
        })
d.arizona's avatar
d.arizona committed
325
        console.log(JSON.stringify(this.state.payload))
d.arizona's avatar
d.arizona committed
326 327 328 329 330
        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') {
d.arizona's avatar
d.arizona committed
331
                    // this.setState({ visibleUpload: false, visibleCAT: false })
d.arizona's avatar
d.arizona committed
332
                    this.setState({ visibleUpload: false, visibleCAT: false })
d.arizona's avatar
d.arizona committed
333 334 335 336 337 338
                    let dataTable = response.data.data.map((item, index) => {
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
d.arizona's avatar
d.arizona committed
339
                            item.level == null? 1 : item.level,
d.arizona's avatar
d.arizona committed
340 341
                            "",
                            item.item_report,
d.arizona's avatar
d.arizona committed
342
                            item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.weight).indexOf(".") == -1 ? item.weight : `${Number(item.weight) * 100}%`),
d.arizona's avatar
d.arizona committed
343
                            item.uom,
Deni Rinaldi's avatar
Deni Rinaldi committed
344 345
                            item.kpi_type == "" || item.kpi_type == null ? null : { value: item.kpi_type },
                            item.max_ach == "" || item.max_ach == null ? null : { value: item.max_ach },
d.arizona's avatar
d.arizona committed
346
                            item.formula_ytd == "" || item.formula_ytd == null ? null : { value: item.formula_ytd },
Deni Rinaldi's avatar
Deni Rinaldi committed
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
                            item.total_actual_before == "" ? item.total_actual_before : String(item.total_actual_before).indexOf(".") == -1 ? Number(item.total_actual_before) : Number(item.total_actual_before).toFixed(1),
                            item.january == "" ? item.january : String(item.january).indexOf(".") == -1 ? Number(item.january) : Number(item.january).toFixed(1),
                            item.february == "" ? item.february : String(item.february).indexOf(".") == -1 ? Number(item.february) : Number(item.february).toFixed(1),
                            item.march == "" ? item.march : String(item.march).indexOf(".") == -1 ? Number(item.march) : Number(item.march).toFixed(1),
                            item.april == "" ? item.april : String(item.april).indexOf(".") == -1 ? Number(item.april) : Number(item.april).toFixed(1),
                            item.may == "" ? item.may : String(item.may).indexOf(".") == -1 ? Number(item.may) : Number(item.may).toFixed(1),
                            item.june == "" ? item.june : String(item.june).indexOf(".") == -1 ? Number(item.june) : Number(item.june).toFixed(1),
                            item.july == "" ? item.july : String(item.july).indexOf(".") == -1 ? Number(item.july) : Number(item.july).toFixed(1),
                            item.august == "" ? item.august : String(item.august).indexOf(".") == -1 ? Number(item.august) : Number(item.august).toFixed(1),
                            item.september == "" ? item.september : String(item.september).indexOf(".") == -1 ? Number(item.september) : Number(item.september).toFixed(1),
                            item.october == "" ? item.october : String(item.october).indexOf(".") == -1 ? Number(item.october) : Number(item.october).toFixed(1),
                            item.november == "" ? item.november : String(item.november).indexOf(".") == -1 ? Number(item.november) : Number(item.november).toFixed(1),
                            item.december == "" ? item.december : String(item.december).indexOf(".") == -1 ? Number(item.december) : Number(item.december).toFixed(1),
                            item.total_current_year == "" ? item.total_current_year : String(item.total_current_year).indexOf(".") == -1 ? Number(item.total_current_year) : Number(item.total_current_year).toFixed(1),
                            item.total_next_year == "" ? item.total_next_year : String(item.total_next_year).indexOf(".") == -1 ? Number(item.total_next_year) : Number(item.total_next_year).toFixed(1),
                            item.total_more_year == "" ? item.total_more_year : String(item.total_more_year).indexOf(".") == -1 ? Number(item.total_more_year) : Number(item.total_more_year).toFixed(1),
d.arizona's avatar
d.arizona committed
363 364 365 366 367 368 369
                            item.strategic,
                            item.pic,
                            item.error
                        ]
                    })
                    console.log(dataTable)
                    console.log(this.state.buttonError)
Deni Rinaldi's avatar
Deni Rinaldi committed
370
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
d.arizona's avatar
d.arizona committed
371 372 373
                        this.state.dataTable.map(item => {
                            if (item[30].length > 0) {
                                console.log('masuk')
Deni Rinaldi's avatar
Deni Rinaldi committed
374
                                this.setState({ buttonError: true, errorPreview: true, editable: true })
d.arizona's avatar
d.arizona committed
375 376 377 378
                            }
                        })
                        // console.log(this.state.dataTable);
                    })
d.arizona's avatar
d.arizona committed
379
                }
faisalhamdi's avatar
faisalhamdi committed
380 381 382 383
            }
        })
    }

d.arizona's avatar
d.arizona committed
384
    uploadCAT(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
385 386
        let payload = { "item_report_id": this.state.dataDelete }

d.arizona's avatar
d.arizona committed
387 388 389 390 391 392 393
        if (this.state.dataDelete.length > 0) {
            api.create().deleteAllItemReport(payload).then((response) => {
                this.functionUpload(type)
            })
        } else {
            this.functionUpload(type)
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
394

d.arizona's avatar
d.arizona committed
395 396 397
    }

    functionUpload(type) {
d.arizona's avatar
d.arizona committed
398
        let data = []
d.arizona's avatar
d.arizona committed
399
        console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
400 401
        this.state.dataTable.map(i => {
            data.push({
d.arizona's avatar
d.arizona committed
402
                "item_report_id": i[1] == "" || i[1] == null? 0 : i[1],
d.arizona's avatar
d.arizona committed
403 404 405
                "item_report": String(i[6]),
                "weight": String(i[7]),
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
                "kpi_type": i[9] == null ? "" : i[9].value,
                "max_ach": i[10] == null ? "" : i[10].value,
                "formula": i[11] == null ? "" : i[11].value,
                "total_actual_before": String(i[12]) == "" ? "0.0" : String(i[12]),
                "january": String(i[13]) == "" ? "0.0" : String(i[13]),
                "february": String(i[14]) == "" ? "0.0" : String(i[14]),
                "march": String(i[15]) == "" ? "0.0" : String(i[15]),
                "april": String(i[16]) == "" ? "0.0" : String(i[16]),
                "may": String(i[17]) == "" ? "0.0" : String(i[17]),
                "june": String(i[18]) == "" ? "0.0" : String(i[18]),
                "july": String(i[19]) == "" ? "0.0" : String(i[19]),
                "august": String(i[20]) == "" ? "0.0" : String(i[20]),
                "september": String(i[21]) == "" ? "0.0" : String(i[21]),
                "october": String(i[22]) == "" ? "0.0" : String(i[22]),
                "november": String(i[23]) == "" ? "0.0" : String(i[23]),
                "december": String(i[24]) == "" ? "0.0" : String(i[24]),
                "total_current_year": String(i[25]) == "" ? "0.0" : String(i[25]),
                "total_next_year": String(i[26]) == "" ? "0.0" : String(i[26]),
                "total_more_year": String(i[27]) == "" ? "0.0" : String(i[27]),
d.arizona's avatar
d.arizona committed
425 426
                "strategic": String(i[28]),
                "pic": String(i[29])
d.arizona's avatar
d.arizona committed
427 428 429 430
            })
        })
        let body = {
            "report_id": this.props.report_id,
d.arizona's avatar
d.arizona committed
431 432 433 434
            // "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID,
d.arizona's avatar
d.arizona committed
435
            "status": type,
d.arizona's avatar
d.arizona committed
436
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
437
        }
d.arizona's avatar
d.arizona committed
438
        console.log(data);
d.arizona's avatar
d.arizona committed
439
        console.log(JSON.stringify(body))
d.arizona's avatar
d.arizona committed
440 441 442 443 444 445 446 447 448 449 450 451 452
        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 {
                alert(response.problem)
            }
        })
453 454
    }

d.arizona's avatar
d.arizona committed
455 456 457
    handleValidate() {
        let data = []
        console.log(this.state.dataTable)
d.arizona's avatar
d.arizona committed
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
        let totalWeight = 0
        let dataTableBaru = this.state.dataTable
        let dataTampung = []
        let weightReal = null
        this.state.dataTable.map((i, index) => {
            if (i[0] ==1) {
                dataTampung.push({
                    id: i[1],
                    maxValue: i[7],
                    valChild: 0
                })
            }

            if (i[0] !== 1 && i[0] !== 4) {
                totalWeight += Number(i[7] == "" || i[7] == undefined? 0 : i[7].replace('%', ''))
            }
            
            if (i[2] !== null) {
                let indexID = dataTampung.findIndex((val) => val.id == i[2])
                if (indexID !== -1) {
                    let weightParent = Number(dataTampung[indexID].maxValue == "" || dataTampung[indexID].maxValue == undefined? 0 : dataTampung[indexID].maxValue.replace('%', ''))
                    let valChild = Number(dataTampung[indexID].valChild)
                    let valReal = Number(i[7] == "" || i[7] == undefined? 0 : i[7].replace('%', ''))
                    let totalBaru = valChild + valReal
                    if (totalBaru > weightParent) {
                        dataTableBaru[index][7] = `${(weightParent - valChild)}%`
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + weightParent - valChild
                        weightReal = `${(weightParent - valChild)}%`
                    } else {
                        dataTableBaru[index][7] = i[7]
                        weightReal = i[7]
                        dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined? 0 : i[7].replace('%', ''))
                    }
                }
            }

d.arizona's avatar
d.arizona committed
494
            data.push({
d.arizona's avatar
d.arizona committed
495 496
                "item_report_id":  i[1] == "" ? null : i[1],
                "item_name": String(i[6]),
d.arizona's avatar
d.arizona committed
497 498
                "parent": i[2] == "" ? null : i[2],
                "weight": weightReal == null? String(i[7]) : weightReal,
d.arizona's avatar
d.arizona committed
499
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
                "kpi_type": i[9] == null ? "" : i[9].value,
                "max_ach": i[10] == null ? "" : i[10].value,
                "formula": i[11] == null ? "" : i[11].value,
                "total_actual_before": String(i[12]) == "" ? "0.0" : String(i[12]),
                "january": String(i[13]) == "" ? "0.0" : String(i[13]),
                "february": String(i[14]) == "" ? "0.0" : String(i[14]),
                "march": String(i[15]) == "" ? "0.0" : String(i[15]),
                "april": String(i[16]) == "" ? "0.0" : String(i[16]),
                "may": String(i[17]) == "" ? "0.0" : String(i[17]),
                "june": String(i[18]) == "" ? "0.0" : String(i[18]),
                "july": String(i[19]) == "" ? "0.0" : String(i[19]),
                "august": String(i[20]) == "" ? "0.0" : String(i[20]),
                "september": String(i[21]) == "" ? "0.0" : String(i[21]),
                "october": String(i[22]) == "" ? "0.0" : String(i[22]),
                "november": String(i[23]) == "" ? "0.0" : String(i[23]),
                "december": String(i[24]) == "" ? "0.0" : String(i[24]),
                "total_current_year": String(i[25]) == "" ? "0.0" : String(i[25]),
                "total_next_year": String(i[26]) == "" ? "0.0" : String(i[26]),
                "total_more_year": String(i[27]) == "" ? "0.0" : String(i[27]),
d.arizona's avatar
d.arizona committed
519 520 521 522
                "strategic": String(i[28]),
                "pic": String(i[29])
            })
        })
d.arizona's avatar
d.arizona committed
523 524

        console.log(dataTableBaru)
d.arizona's avatar
d.arizona committed
525 526 527 528 529 530 531 532 533
        console.log(JSON.stringify(data))
        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": "submitted",
            "cat": data
        }
d.arizona's avatar
d.arizona committed
534
        console.log(totalWeight)
d.arizona's avatar
d.arizona committed
535
        // this.setState({dataTable: dataTampung})
d.arizona's avatar
d.arizona committed
536
        if (totalWeight < 100) {
d.arizona's avatar
d.arizona committed
537
            this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, buttonError: true, editable: true})
d.arizona's avatar
d.arizona committed
538 539 540 541
        } else {
            api.create().validateSubmitReport(payload).then((response) => {
                console.log(response)
                if (response.data.data.result) {
Deni Rinaldi's avatar
Deni Rinaldi committed
542
                    this.setState({ loading: false, buttonError: false, editable: false })
d.arizona's avatar
d.arizona committed
543 544
                } else {
                    this.setState({ loading: false, buttonError: true, editable: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
545
                }
d.arizona's avatar
d.arizona committed
546 547
            })
        }
d.arizona's avatar
d.arizona committed
548 549 550 551 552 553
    }

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

faisalhamdi's avatar
faisalhamdi committed
554 555
    backToMasterBudget(type) {
        let data = []
d.arizona's avatar
d.arizona committed
556
        console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
557
        this.state.dataTable.map(i => {
d.arizona's avatar
d.arizona committed
558
            // console.log(i[9] == null? "" : i[9].value)
faisalhamdi's avatar
faisalhamdi committed
559
            data.push({
d.arizona's avatar
d.arizona committed
560 561 562
                "item_report_id": i[1] == "" ? null : i[1],
                "item_name": String(i[6]),
                "parent": i[2] == "" ? null : i[2],
d.arizona's avatar
d.arizona committed
563 564
                "weight": String(i[7]),
                "uom": String(i[8]),
Deni Rinaldi's avatar
Deni Rinaldi committed
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
                "kpi_type": i[9] == null ? "" : i[9].value,
                "max_ach": i[10] == null ? "" : i[10].value,
                "formula": i[11] == null ? "" : i[11].value,
                "total_actual_before": String(i[12]) == "" ? "0.0" : String(i[12]),
                "january": String(i[13]) == "" ? "0.0" : String(i[13]),
                "february": String(i[14]) == "" ? "0.0" : String(i[14]),
                "march": String(i[15]) == "" ? "0.0" : String(i[15]),
                "april": String(i[16]) == "" ? "0.0" : String(i[16]),
                "may": String(i[17]) == "" ? "0.0" : String(i[17]),
                "june": String(i[18]) == "" ? "0.0" : String(i[18]),
                "july": String(i[19]) == "" ? "0.0" : String(i[19]),
                "august": String(i[20]) == "" ? "0.0" : String(i[20]),
                "september": String(i[21]) == "" ? "0.0" : String(i[21]),
                "october": String(i[22]) == "" ? "0.0" : String(i[22]),
                "november": String(i[23]) == "" ? "0.0" : String(i[23]),
                "december": String(i[24]) == "" ? "0.0" : String(i[24]),
                "total_current_year": String(i[25]) == "" ? "0.0" : String(i[25]),
                "total_next_year": String(i[26]) == "" ? "0.0" : String(i[26]),
                "total_more_year": String(i[27]) == "" ? "0.0" : String(i[27]),
d.arizona's avatar
d.arizona committed
584 585
                "strategic": String(i[28]),
                "pic": String(i[29])
faisalhamdi's avatar
faisalhamdi committed
586 587
            })
        })
d.arizona's avatar
d.arizona committed
588
        console.log(JSON.stringify(data))
faisalhamdi's avatar
faisalhamdi committed
589 590 591 592 593 594
        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,
d.arizona's avatar
d.arizona committed
595
            "cat": data
faisalhamdi's avatar
faisalhamdi committed
596
        }
d.arizona's avatar
d.arizona committed
597
        console.log(JSON.stringify(payload));
d.arizona's avatar
d.arizona committed
598
        this.deleteReport(payload)
d.arizona's avatar
d.arizona committed
599 600
    }

d.arizona's avatar
d.arizona committed
601
    deleteReport(payloadBro) {
Deni Rinaldi's avatar
Deni Rinaldi committed
602 603
        let payload = { "item_report_id": this.state.dataDelete }

d.arizona's avatar
d.arizona committed
604 605 606
        if (this.state.dataDelete.length > 0) {
            api.create().deleteAllItemReport(payload).then((response) => {
                console.log(response)
d.arizona's avatar
d.arizona committed
607

d.arizona's avatar
d.arizona committed
608 609 610
                // api.create().validateSubmitReport(payloadBro).then((response) => {
                //     console.log(response)
                //     if (response.data.data.result) {
Deni Rinaldi's avatar
Deni Rinaldi committed
611 612
                this.props.saveToMasterBudget(payloadBro)
                this.props.onClickClose()
d.arizona's avatar
d.arizona committed
613
                //     } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
614

d.arizona's avatar
d.arizona committed
615 616 617 618
                //     }
                // })
            })
        } else {
d.arizona's avatar
d.arizona committed
619
            // console.log('sini jing')
d.arizona's avatar
d.arizona committed
620 621 622
            // api.create().validateSubmitReport(payloadBro).then((response) => {
            //     console.log(response)
            //     if (response.data.data.result) {
Deni Rinaldi's avatar
Deni Rinaldi committed
623 624
            this.props.saveToMasterBudget(payloadBro)
            this.props.onClickClose()
d.arizona's avatar
d.arizona committed
625
            //     } else {
d.arizona's avatar
d.arizona committed
626

d.arizona's avatar
d.arizona committed
627 628 629
            //     }
            // })
        }
faisalhamdi's avatar
faisalhamdi committed
630 631
    }

d.arizona's avatar
d.arizona committed
632

d.arizona's avatar
d.arizona committed
633 634 635 636 637 638 639
    getKPIType() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'KPI_TYPE'
        }
        api.create().getAllSettingByType(body).then(response => {
d.arizona's avatar
d.arizona committed
640
            // console.log(response)
d.arizona's avatar
d.arizona committed
641 642 643 644 645
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        console.log(data)
d.arizona's avatar
d.arizona committed
646 647 648 649
                        let inputKPI = []
                        
                        data.map((item) => {
                            inputKPI.push({
d.arizona's avatar
d.arizona committed
650
                                value: item.value
d.arizona's avatar
d.arizona committed
651
                            })
d.arizona's avatar
d.arizona committed
652 653 654 655 656
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
d.arizona's avatar
d.arizona committed
657
                        console.log(defaultProps)
d.arizona's avatar
d.arizona committed
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                        // alert(response.data.message)
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

    getMaxAch() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'MAX_ACHIEVEMENT'
        }
        api.create().getAllSettingByType(body).then(response => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let inputMaxAch = data.map((item) => {
                            return {
                                value: item.value
                            }
                        })
                        let defaultProps = {
                            options: inputMaxAch,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
d.arizona's avatar
d.arizona committed
699 700 701
                        // setTimeout(() => {
                            this.setState({ maxAchList: defaultProps })
                        // }, 300);
d.arizona's avatar
d.arizona committed
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                        // alert(response.data.message)
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
d.arizona's avatar
d.arizona committed
719
            this.getItemHierarki()
d.arizona's avatar
d.arizona committed
720 721 722
        })
    }

d.arizona's avatar
d.arizona committed
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
    getLatestUpdate() {
        let payload = {
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID
        }
        api.create().getLastestUpdateMB(payload).then(response => {
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update
                    })
                }
            }
        })
    }

742
    render() {
faisalhamdi's avatar
faisalhamdi committed
743
        let dataTable2 = this.state.dataTable
d.arizona's avatar
d.arizona committed
744
        let dataDelete = this.state.dataDelete
faisalhamdi's avatar
faisalhamdi committed
745 746
        const handleChange = (value, tableMeta) => {
            let val = String(value).split(",").join("")
d.arizona's avatar
d.arizona committed
747 748
            // let total = 0
            // let lastValz = 0
d.arizona's avatar
d.arizona committed
749
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
d.arizona's avatar
d.arizona committed
750 751 752 753 754 755 756 757 758 759 760 761
            // dataTable2[tableMeta.rowIndex].map((item, index) => {
            //     if (index >= 13 && index <= 24) {
            //         let valItem = item == undefined || item == "" ? 0 : item
            //         total += Number(valItem)
            //         if (index == 24) {
            //             lastValz += Number(valItem)
            //         }
            //     }
            // })
            // let valz = dataTable2[tableMeta.rowIndex][11] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][11].value
            // dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
            // console.log(dataTable2[tableMeta.rowIndex])
d.arizona's avatar
d.arizona committed
762 763 764
        }

        const handleChangeDropdown = (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
765
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
d.arizona's avatar
d.arizona committed
766 767 768 769
            let valz = value.value
            let total = 0
            let lastValz = 0
            if (valz == 'SUM' || valz == 'AVG' || valz == 'LAST') {
Deni Rinaldi's avatar
Deni Rinaldi committed
770
                dataTable2[tableMeta.rowIndex].map((item, index) => {
d.arizona's avatar
d.arizona committed
771
                    if (index >= 13 && index <= 24) {
Deni Rinaldi's avatar
Deni Rinaldi committed
772
                        let valItem = item == undefined || item == "" ? 0 : item
d.arizona's avatar
d.arizona committed
773 774 775 776 777 778
                        total += Number(valItem)
                        if (index == 24) {
                            lastValz += Number(valItem)
                        }
                    }
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
779
                dataTable2[tableMeta.rowIndex][25] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
d.arizona's avatar
d.arizona committed
780
            }
d.arizona's avatar
d.arizona committed
781 782 783
        }

        const handleChangePercentage = (value, tableMeta) => {
d.arizona's avatar
d.arizona committed
784 785 786 787 788 789
            // let valueReal = value.replace('%', '')
            // let indexParentDatatable = dataTable2.findIndex((val) => val[1] == tableMeta.rowData[2])
            // let indexParentReal = this.state.dataReal.findIndex((val) => val.id == tableMeta.rowData[2])
            // let valParent = dataTable2[indexParentDatatable][7]
            // valParent.replace('%', '')
            // let valChild = 0
Deni Rinaldi's avatar
Deni Rinaldi committed
790

d.arizona's avatar
d.arizona committed
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
            // dataTable2.map((item, index) => {
            //     if (item[2] == dataTable2[indexParentDatatable][1] && item[1] !== tableMeta.rowData[1]) {
            //         let weightItem = item[7] == "" ? 0 : item[7].replace('%', '')
            //         console.log(weightItem)
            //         valChild += Number(weightItem)
            //     }
            // })

            // let endVal = ''
            // if ((Number(valueReal) + Number(valChild)) > Number(valParent.replace('%', ''))) {
            //     endVal = `${Number(valParent.replace('%', '')) - (Number(valChild))}%`
            //     console.log(endVal)
            // } else {
            //     endVal = `${Number(valueReal)}%`
            //     console.log(endVal)
            // }
            // // console.log(endVal)
            // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = endVal
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
d.arizona's avatar
d.arizona committed
810

d.arizona's avatar
d.arizona committed
811 812 813 814 815
        }

        const handleChangeText = (value, tableMeta) => {
            console.log(value)
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
d.arizona's avatar
d.arizona committed
816
            // this.setState({dataTable: dataTable2})
faisalhamdi's avatar
faisalhamdi committed
817
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
818

d.arizona's avatar
d.arizona committed
819
        const handleAction = (idParent, typeReport, tableMeta) => {
d.arizona's avatar
d.arizona committed
820 821
            if (idParent !== null) {
                let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
d.arizona's avatar
d.arizona committed
822
                if (dataTable2[indexsss][6] == 'CUSTOMER PERSPECTIVE' || dataTable2[indexsss][6] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
d.arizona's avatar
d.arizona committed
823 824 825 826 827
                    return true
                } else {
                    return false
                }
            } else {
d.arizona's avatar
d.arizona committed
828 829
                if (typeReport == null) {
                    return true
d.arizona's avatar
d.arizona committed
830 831 832 833 834 835 836
                } else if (tableMeta !== undefined && tableMeta.rowData[0] == 1) {
                    let indexID = dataTable2.findIndex((val) => val[2] == tableMeta.rowData[1])
                    if (indexID !== -1) {
                        return false
                    } else {
                        return true
                    }
d.arizona's avatar
d.arizona committed
837 838 839
                } else {
                    return false
                }
d.arizona's avatar
d.arizona committed
840 841 842
            }
        }

d.arizona's avatar
d.arizona committed
843
        const handleTambah = (data, rowIndex) => {
d.arizona's avatar
d.arizona committed
844
            console.log(dataTable2)
d.arizona's avatar
d.arizona committed
845 846 847
            let newData = []
            dataTable2.map((item, index) => {
                newData.push(item)
d.arizona's avatar
d.arizona committed
848
                if (index == rowIndex) {
d.arizona's avatar
d.arizona committed
849
                    newData.push([
d.arizona's avatar
d.arizona committed
850
                        3,
d.arizona's avatar
d.arizona committed
851
                        "",
d.arizona's avatar
d.arizona committed
852
                        item[2] == null? item[1] : item[2],
d.arizona's avatar
d.arizona committed
853 854 855 856 857 858
                        item[3],
                        item[4],
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
859 860 861
                        null,
                        null,
                        null,
d.arizona's avatar
d.arizona committed
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
d.arizona's avatar
d.arizona committed
878
                        "",
d.arizona's avatar
d.arizona committed
879 880
                        ""
                    ])
Deni Rinaldi's avatar
Deni Rinaldi committed
881

d.arizona's avatar
d.arizona committed
882 883 884
                }
            })
            dataTable2 = newData
Deni Rinaldi's avatar
Deni Rinaldi committed
885
            this.setState({ dataTable: dataTable2 }, () => {
d.arizona's avatar
d.arizona committed
886
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
887 888
                    this.setState({ loading: false })
                }, 500)
d.arizona's avatar
d.arizona committed
889 890 891 892
            })
        }

        const handleDelete = (index) => {
d.arizona's avatar
d.arizona committed
893 894 895
            if (dataTable2[index][1] !== "") {
                dataDelete.push(dataTable2[index][1])
            }
d.arizona's avatar
d.arizona committed
896
            dataTable2.splice(index, 1)
Deni Rinaldi's avatar
Deni Rinaldi committed
897
            this.setState({ dataTable: dataTable2, dataDelete }, () => {
d.arizona's avatar
d.arizona committed
898
                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
899
                    this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
900
                }, 100)
d.arizona's avatar
d.arizona committed
901 902
            })
        }
d.arizona's avatar
d.arizona committed
903

d.arizona's avatar
d.arizona committed
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921
        const handleTotal = (tableMeta) => {
            // let val = String(value).split(",").join("")
            let total = 0
            let lastValz = 0
            dataTable2[tableMeta.rowIndex].map((item, index) => {
                if (index >= 13 && index <= 24) {
                    let valItem = item == undefined || item == "" ? 0 : item
                    total += Number(valItem)
                    if (index == 24) {
                        lastValz += Number(valItem)
                    }
                }
            })
            let valz = dataTable2[tableMeta.rowIndex][11] == null ? 'SUM' : dataTable2[tableMeta.rowIndex][11].value
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
            return (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
        }

922
        const columns = [{
faisalhamdi's avatar
faisalhamdi committed
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
            name: "",
            options: {
                display: false
            }
        }, {
d.arizona's avatar
d.arizona committed
948 949
            name: "",
            options: {
Deni Rinaldi's avatar
Deni Rinaldi committed
950 951 952 953 954 955
                filter: false,
                display: this.props.isApprover ? false : true,
                customHeadRender: (columnMeta) => (
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#dbdbdb' }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                    </TableCell>
d.arizona's avatar
d.arizona committed
956
                ),
Deni Rinaldi's avatar
Deni Rinaldi committed
957 958 959
                customBodyRender: (val, tableMeta) => {
                    return (
                        // handleAction(tableMeta.rowData[2]) && 
d.arizona's avatar
d.arizona committed
960
                        handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && <div style={{ display: 'flex' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989
                            {/* {tableMeta.rowData[6] === "Active" ? */}
                            {<span>
                                <LightTooltip title={'Add'} arrow>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                        }}
                                        // onClick={() => console.log(tableMeta.rowData[1])}
                                        onClick={() => {
                                            this.setState({ loading: true })
                                            handleTambah(tableMeta.rowData[1], tableMeta.rowIndex)
                                        }}
                                    >
                                        <img src={Images.add} />
                                    </button>
                                </LightTooltip>
                            </span>}
                            <span>
                                <LightTooltip title={'Delete'} arrow>
                                    <button
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            marginLeft: 5
                                        }}
                                        onClick={() => {
d.arizona's avatar
d.arizona committed
990 991
                                            this.setState({ loading: true })
                                            handleDelete(tableMeta.rowIndex)
Deni Rinaldi's avatar
Deni Rinaldi committed
992 993 994 995 996 997 998 999 1000
                                        }}
                                    >
                                        <img src={Images.delete} />
                                    </button>
                                </LightTooltip>
                            </span>
                        </div >
                    );
                }
d.arizona's avatar
d.arizona committed
1001
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1002
        }, {
1003 1004 1005
            name: "Key Performance Indicator",
            options: {
                customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1006
                    <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8' }}>
d.arizona's avatar
d.arizona committed
1007
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
1008 1009 1010 1011 1012
                    </TableCell>
                ),
                setCellProps: () => ({ style }),
                customBodyRender: (val, tableMeta) => {
                    return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
                        tableMeta.rowData[1] == "" ?
                            <div style={{ textAlign: 'left', paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                <FormControlLabel
                                    style={{ margin: 0 }}
                                    control={
                                        <Input
                                            disableUnderline={true}
                                            style={{ color: tableMeta.rowData[1] == "" ? "#5198ea" : "black", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
                                            defaultValue={val}
                                            // disabled={!handleAction(tableMeta.rowData[2])}
                                            onBlur={(event) => {
                                                console.log(event.target.value)
                                                handleChangeText(event.target.value, tableMeta)
                                                console.log(dataTable2)
                                            }}
                                        />
                                    }
                                />
                            </div>
                            :
                            <div style={{ width: 300 }}>
d.arizona's avatar
d.arizona committed
1036 1037
                                {tableMeta.rowData[30] ?
                                    tableMeta.rowData[30].length > 0 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                            <LightTooltip title={"Report Items Not Registered"} arrow>
                                                <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </LightTooltip>
                                        </div>
                                        :
                                        tableMeta.rowData[4] == 0 ?
                                            <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                            :
                                            tableMeta.rowData[1] == null ?
                                                <div style={{ paddingLeft: 20 }}>
                                                    <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                </div>
                                                :
                                                <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                    <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                </div>
d.arizona's avatar
d.arizona committed
1055 1056 1057 1058
                                    :
                                    tableMeta.rowData[4] == 0 ?
                                        <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                        :
Deni Rinaldi's avatar
Deni Rinaldi committed
1059 1060
                                        tableMeta.rowData[1] == null ?
                                            <div style={{ paddingLeft: 20 }}>
d.arizona's avatar
d.arizona committed
1061 1062
                                                <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1063
                                            :
d.arizona's avatar
d.arizona committed
1064 1065 1066
                                            <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1067 1068
                                }
                            </div>
1069 1070 1071 1072 1073 1074 1075
                    )
                }
            }
        }, {
            name: "Weight",
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1076
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1077 1078 1079
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
faisalhamdi's avatar
faisalhamdi committed
1080 1081 1082 1083
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1084
                            {tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1085
                                null :
Deni Rinaldi's avatar
Deni Rinaldi committed
1086
                                tableMeta.rowData[0] === 1 ?
d.arizona's avatar
d.arizona committed
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
                                    value
                                    :
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    suffix="%"
                                                    style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    value={value}
d.arizona's avatar
d.arizona committed
1101
                                                    disabled={this.props.isApprover? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' ||  this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
d.arizona's avatar
d.arizona committed
1102 1103 1104 1105 1106 1107 1108 1109 1110
                                                    maxLength={4}
                                                    onBlur={(event) => {
                                                        // updateValue(some)
                                                        handleChangePercentage(event.target.value, tableMeta)
                                                    }}
                                                />
                                            }
                                        />
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
1111 1112 1113 1114
                            }
                        </div>
                    )
                }
1115 1116 1117 1118 1119
            }
        }, {
            name: "UOM",
            options: {
                customHeadRender: (columnMeta) => (
Deni Rinaldi's avatar
Deni Rinaldi committed
1120
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8' }}>
1121 1122 1123 1124 1125 1126
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1127
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1128 1129 1130
                                null :
                                <FormControlLabel
                                    style={{ margin: 0 }}
d.arizona's avatar
d.arizona committed
1131
                                    // value={value}
d.arizona's avatar
d.arizona committed
1132
                                    control={
d.arizona's avatar
d.arizona committed
1133
                                        !handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) ?
d.arizona's avatar
d.arizona committed
1134 1135
                                            <Input
                                                disableUnderline={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1136
                                                style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginTop: -10 }}
d.arizona's avatar
d.arizona committed
1137 1138 1139 1140
                                                type="text"
                                                placeholder=""
                                                defaultValue={value}
                                                color={"#5198ea"}
d.arizona's avatar
d.arizona committed
1141
                                                disabled={true}
d.arizona's avatar
d.arizona committed
1142 1143 1144 1145 1146 1147
                                                onBlur={(event) => {
                                                    console.log(event.target.value)
                                                    // updateValue(event.target.value)
                                                    handleChangeText(event.target.value, tableMeta)
                                                    console.log(dataTable2)
                                                }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1148 1149 1150 1151 1152 1153 1154 1155 1156
                                            /> :
                                            <ThemeProvider theme={theme}>
                                                <Input
                                                    disableUnderline={true}
                                                    style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginBottom: -5 }}
                                                    type="text"
                                                    placeholder=""
                                                    defaultValue={value}
                                                    color={"#5198ea"}
d.arizona's avatar
d.arizona committed
1157
                                                    // disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))}
Deni Rinaldi's avatar
Deni Rinaldi committed
1158 1159 1160 1161 1162 1163 1164 1165
                                                    onBlur={(event) => {
                                                        console.log(event.target.value)
                                                        // updateValue(event.target.value)
                                                        handleChangeText(event.target.value, tableMeta)
                                                        console.log(dataTable2)
                                                    }}
                                                />
                                            </ThemeProvider>
d.arizona's avatar
d.arizona committed
1166
                                    }
d.arizona's avatar
d.arizona committed
1167
                                />
1168 1169 1170 1171 1172 1173
                            }
                        </div>
                    )
                }
            }
        }, {
d.arizona's avatar
d.arizona committed
1174
            name: "KPI Type",
1175 1176
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
1177
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1178 1179 1180
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
1181
                customBodyRender: (val, tableMeta) => {
1182 1183
                    return (
                        <div style={{ width: 96 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1184
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1185 1186 1187 1188 1189 1190 1191
                                null :
                                <Autocomplete
                                    {...this.state.kpiTypeList}
                                    id="kpiType"
                                    onChange={(event, newInputValue) => handleChangeDropdown(newInputValue, tableMeta)}
                                    debug
                                    disableClearable
d.arizona's avatar
d.arizona committed
1192
                                    disabled={!handleAction(tableMeta.rowData[2], tableMeta.rowData[0])}
d.arizona's avatar
d.arizona committed
1193
                                    value={val}
Deni Rinaldi's avatar
Deni Rinaldi committed
1194
                                    style={{ padding: 0, margin: 0 }}
d.arizona's avatar
d.arizona committed
1195
                                    renderInput={(params) =>
Deni Rinaldi's avatar
Deni Rinaldi committed
1196
                                        <div ref={params.InputProps.ref} style={{ padding: 0, margin: 0 }}>
d.arizona's avatar
d.arizona committed
1197
                                            <input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0, color: handleAction(tableMeta.rowData[2], tableMeta.rowData[0]) ? "#5198ea" : "black" }} type="text" {...params.inputProps} />
d.arizona's avatar
d.arizona committed
1198 1199 1200 1201
                                        </div>
                                    }
                                />
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1202

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

d.arizona's avatar
d.arizona committed
1964 1965
                                    }
                                />
d.arizona's avatar
d.arizona committed
1966
                            }
1967 1968 1969 1970 1971
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1972
            name: "PIC",
1973 1974
            options: {
                customHeadRender: (columnMeta) => (
d.arizona's avatar
d.arizona committed
1975
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
1976 1977 1978
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
d.arizona's avatar
d.arizona committed
1979
                customBodyRender: (value, tableMeta) => {
1980
                    return (
d.arizona's avatar
d.arizona committed
1981
                        <div style={{ textAlign: 'right' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1982
                            {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
d.arizona's avatar
d.arizona committed
1983 1984 1985 1986 1987 1988 1989 1990 1991
                                null :
                                <FormControlLabel
                                    style={{ margin: 0 }}
                                    // value={value}
                                    control={
                                        <ThemeProvider theme={theme}>
                                            <Input
                                                disableUnderline={true}
                                                style={{ color: "#5198ea", fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginBottom: -5 }}
d.arizona's avatar
d.arizona committed
1992 1993
                                                type="text"
                                                placeholder=""
d.arizona's avatar
d.arizona committed
1994
                                                disabled={this.props.isApprover? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' ||  this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
d.arizona's avatar
d.arizona committed
1995
                                                defaultValue={value}
d.arizona's avatar
d.arizona committed
1996
                                                onBlur={(event) => {
d.arizona's avatar
d.arizona committed
1997
                                                    console.log(event.target.value)
d.arizona's avatar
d.arizona committed
1998
                                                    // updateValue(event.target.value)
d.arizona's avatar
d.arizona committed
1999
                                                    handleChangeText(event.target.value, tableMeta)
d.arizona's avatar
d.arizona committed
2000 2001 2002
                                                    console.log(dataTable2)
                                                }}
                                            />
d.arizona's avatar
d.arizona committed
2003
                                        </ThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
2004

d.arizona's avatar
d.arizona committed
2005 2006
                                    }
                                />
d.arizona's avatar
d.arizona committed
2007
                            }
2008 2009 2010 2011 2012 2013
                        </div>
                    )
                }
            }
        }
        ]
faisalhamdi's avatar
faisalhamdi committed
2014 2015 2016 2017 2018 2019 2020 2021 2022 2023
        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>
        );
2024 2025 2026 2027

        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 }}>
d.arizona's avatar
d.arizona committed
2028
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
2029
                </div>
faisalhamdi's avatar
faisalhamdi committed
2030
                {/* {this.state.loading && loadingComponent} */}
d.arizona's avatar
d.arizona committed
2031 2032 2033 2034 2035
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
2036
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2037
                    {this.state.visibleCAT ? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
2038
                        <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
d.arizona's avatar
d.arizona committed
2039
                            <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Corporate Annual Target</Typography>
2040 2041
                        </div>
                        <div style={{ padding: 20 }}>
d.arizona's avatar
d.arizona committed
2042 2043 2044
                            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
2045
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
d.arizona's avatar
d.arizona committed
2046 2047
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                </div>
d.arizona's avatar
d.arizona committed
2048
                                {!this.props.isApprover && <div style={{ width: '50%' }}>
d.arizona's avatar
d.arizona committed
2049
                                    <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
d.arizona's avatar
d.arizona committed
2050
                                        {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' ||  this.props.status === 'draft' || this.props.status === 'submitted') ) && <a data-tip={'Download Template'} data-for="template">
d.arizona's avatar
d.arizona committed
2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() => this.downloadTemplate()}
                                            >
                                                <img src={Images.template} />
                                            </button>
d.arizona's avatar
d.arizona committed
2062
                                        </a>}
d.arizona's avatar
d.arizona committed
2063
                                        <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
d.arizona's avatar
d.arizona committed
2064
                                        {((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' ||  this.props.status === 'draft' || this.props.status === 'submitted') ) && <a data-tip={'Upload'} data-for="upload">
d.arizona's avatar
d.arizona committed
2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() => this.setState({ visibleUpload: true })}
                                            >
                                                <img src={Images.upload} />
                                            </button>
d.arizona's avatar
d.arizona committed
2076
                                        </a>}
d.arizona's avatar
d.arizona committed
2077 2078 2079 2080 2081 2082 2083 2084 2085 2086
                                        <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                        <a data-tip={'Download'} data-for="download">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() =>
d.arizona's avatar
d.arizona committed
2087 2088
                                                    // this.setState({ loading: true }, () => {
                                                    //     setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2089 2090 2091
                                                    this.downloadAllData()}
                                            //     }, 100);
                                            // })}
d.arizona's avatar
d.arizona committed
2092 2093 2094 2095 2096 2097
                                            >
                                                <img src={Images.download} />
                                            </button>
                                        </a>
                                        <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                    </div>
d.arizona's avatar
d.arizona committed
2098
                                </div>}
2099 2100
                            </div>

d.arizona's avatar
d.arizona committed
2101 2102
                            <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                {this.state.loading && loadingComponent}
2103 2104
                                <MuiThemeProvider theme={getMuiTheme()}>
                                    <MUIDataTable
d.arizona's avatar
d.arizona committed
2105
                                        data={dataTable2}
2106 2107 2108 2109 2110
                                        columns={columns}
                                        options={options}
                                    />
                                </MuiThemeProvider>
                            </div>
d.arizona's avatar
d.arizona committed
2111
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122
                        </div>
                        <div className="grid grid-2x">
                            <div className="col-1">
                                <button
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2123
                                    onClick={() =>
d.arizona's avatar
d.arizona committed
2124
                                        this.setState({ loading: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2125 2126 2127 2128
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100)
                                        })}
2129 2130
                                >
                                    <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
2131
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
2132 2133 2134
                                    </div>
                                </button>
                            </div>
d.arizona's avatar
d.arizona committed
2135
                            {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
d.arizona's avatar
d.arizona committed
2136
                                {((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') ) && <button
d.arizona's avatar
d.arizona committed
2137 2138 2139 2140 2141 2142 2143 2144 2145
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
                                        outline: 'none',
                                        marginRight: 20
                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2146 2147
                                    onClick={() =>
                                        this.setState({ loading: true, dataTable: dataTable2, buttonDraft: false }, () => {
d.arizona's avatar
d.arizona committed
2148 2149 2150 2151 2152
                                            setTimeout(() => {
                                                this.handleValidate()
                                            }, 100);
                                        })
                                    }
d.arizona's avatar
d.arizona committed
2153 2154
                                >
                                    <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
d.arizona's avatar
d.arizona committed
2155
                                        <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
d.arizona's avatar
d.arizona committed
2156
                                    </div>
d.arizona's avatar
d.arizona committed
2157
                                </button>}
d.arizona's avatar
d.arizona committed
2158
                                {((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') ) && <button
d.arizona's avatar
d.arizona committed
2159 2160 2161 2162
                                    className="button"
                                    type="button"
                                    style={{
                                        backgroundColor: 'transparent',
Deni Rinaldi's avatar
Deni Rinaldi committed
2163
                                        cursor: this.state.editable !== true ? 'pointer' : 'default',
d.arizona's avatar
d.arizona committed
2164 2165 2166 2167
                                        borderColor: 'transparent',
                                        outline: 'none',
                                        marginRight: 20
                                    }}
d.arizona's avatar
d.arizona committed
2168
                                    disabled={this.state.buttonDraft}
Deni Rinaldi's avatar
Deni Rinaldi committed
2169 2170 2171 2172 2173 2174 2175
                                    onClick={() =>
                                        this.state.editable === true ?
                                            null :
                                            this.state.handleTekTekTek == 1 ? null :
                                                this.setState({ handleTekTekTek: 1 }, () => {
                                                    this.backToMasterBudget('draft')
                                                })
d.arizona's avatar
d.arizona committed
2176
                                    }
d.arizona's avatar
d.arizona committed
2177 2178
                                >
                                    <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
2179
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
d.arizona's avatar
d.arizona committed
2180
                                    </div>
d.arizona's avatar
d.arizona committed
2181
                                </button>}
d.arizona's avatar
d.arizona committed
2182
                                {((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') ) && <button
d.arizona's avatar
d.arizona committed
2183
                                    type="button"
d.arizona's avatar
d.arizona committed
2184
                                    // disabled={this.state.buttonError}
Deni Rinaldi's avatar
Deni Rinaldi committed
2185 2186 2187 2188 2189 2190 2191
                                    onClick={() => this.state.buttonError ?
                                        this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                        :
                                        this.state.handleTekTekTek == 1 ? null :
                                            this.setState({ handleTekTekTek: 1 }, () => {
                                                this.backToMasterBudget('submitted')
                                            })}
d.arizona's avatar
d.arizona committed
2192 2193 2194 2195 2196 2197 2198 2199
                                    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' }}>
d.arizona's avatar
d.arizona committed
2200
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
d.arizona's avatar
d.arizona committed
2201
                                    </div>
d.arizona's avatar
d.arizona committed
2202
                                </button>}
d.arizona's avatar
d.arizona committed
2203
                            </div>}
2204 2205
                        </div>
                    </Paper>
Deni Rinaldi's avatar
Deni Rinaldi committed
2206 2207
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
d.arizona's avatar
d.arizona committed
2208 2209 2210 2211
                            <div>
                                <div style={{ padding: 25 }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
2212
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
d.arizona's avatar
d.arizona committed
2213 2214 2215
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    {this.state.dataLoaded && (
d.arizona's avatar
d.arizona committed
2216
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
d.arizona's avatar
d.arizona committed
2217
                                            {this.state.loading && loadingComponent}
d.arizona's avatar
d.arizona committed
2218
                                            <MuiThemeProvider theme={getMuiTheme()}>
d.arizona's avatar
d.arizona committed
2219 2220 2221 2222 2223
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
d.arizona's avatar
d.arizona committed
2224
                                            </MuiThemeProvider>
d.arizona's avatar
d.arizona committed
2225 2226 2227
                                        </div>
                                    )}
                                </div>
d.arizona's avatar
d.arizona committed
2228 2229 2230 2231 2232 2233 2234 2235 2236 2237
                                <div className="grid grid-2x">
                                    <div className="col-1">
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2238
                                            onClick={() =>
d.arizona's avatar
d.arizona committed
2239
                                                this.setState({ loading: true, visibleCAT: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2240 2241 2242 2243
                                                    setTimeout(() => {
                                                        this.getItemHierarki()
                                                    }, 100)
                                                })}
d.arizona's avatar
d.arizona committed
2244 2245 2246 2247 2248 2249
                                        >
                                            <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>
d.arizona's avatar
d.arizona committed
2250
                                    {!this.props.isApprover && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
d.arizona's avatar
d.arizona committed
2251
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
2252
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
2253
                                            onClick={() =>
d.arizona's avatar
d.arizona committed
2254 2255
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2256
                                                        this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false, editable: false })
d.arizona's avatar
d.arizona committed
2257
                                                    }, 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
2258
                                                })
d.arizona's avatar
d.arizona committed
2259 2260 2261 2262 2263 2264
                                            }
                                            style={{ marginRight: 20 }}
                                        >
                                            <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>
d.arizona's avatar
d.arizona committed
2265
                                        </button>}
d.arizona's avatar
d.arizona committed
2266
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
2267 2268 2269 2270 2271
                                            className="button"
                                            type="button"
                                            disabled={this.state.buttonError}
                                            style={{
                                                backgroundColor: 'transparent',
Deni Rinaldi's avatar
Deni Rinaldi committed
2272
                                                cursor: this.state.editable === true ? 'default' : 'pointer',
d.arizona's avatar
d.arizona committed
2273 2274 2275 2276
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2277
                                            onClick={() => this.state.editable === true ?
EKSAD's avatar
EKSAD committed
2278
                                                null : this.setState({ loading: true}, () =>
Deni Rinaldi's avatar
Deni Rinaldi committed
2279 2280 2281 2282 2283 2284
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1 }, () => {
                                                        setTimeout(() => {
                                                            this.uploadCAT("draft")
                                                        }, 100);
                                                    })
EKSAD's avatar
EKSAD committed
2285
                                                )
Deni Rinaldi's avatar
Deni Rinaldi committed
2286
                                            }
d.arizona's avatar
d.arizona committed
2287 2288 2289 2290
                                        >
                                            <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>
d.arizona's avatar
d.arizona committed
2291
                                        </button>}
d.arizona's avatar
d.arizona committed
2292
                                        {(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && <button
d.arizona's avatar
d.arizona committed
2293
                                            type="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
2294 2295 2296 2297 2298 2299 2300 2301
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
                                            onClick={() =>
                                                this.state.editable === true ?
EKSAD's avatar
EKSAD committed
2302
                                                    null : this.setState({ loading: true}, () =>
Deni Rinaldi's avatar
Deni Rinaldi committed
2303 2304 2305 2306 2307 2308
                                                    this.state.handleTekTekTek == 1 ? null :
                                                        this.setState({ handleTekTekTek: 1 }, () => {
                                                            setTimeout(() => {
                                                                this.uploadCAT("submitted")
                                                            }, 100);
                                                        })
EKSAD's avatar
EKSAD committed
2309
                                                    )
Deni Rinaldi's avatar
Deni Rinaldi committed
2310
                                            }
d.arizona's avatar
d.arizona committed
2311 2312 2313 2314
                                        >
                                            <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>
d.arizona's avatar
d.arizona committed
2315
                                        </button>}
d.arizona's avatar
d.arizona committed
2316
                                    </div>}
d.arizona's avatar
d.arizona committed
2317 2318 2319
                                </div>
                            </div>
                        </Paper>}
2320
                </div>
d.arizona's avatar
d.arizona committed
2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358

                {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 - CAT" ?
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
2359 2360 2361 2362
            </div>
        );
    }
}