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

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

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

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
37
    zIndex: 100
faisalhamdi's avatar
faisalhamdi committed
38 39 40
};

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

    componentDidMount() {
faisalhamdi's avatar
faisalhamdi committed
58
        this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
59
        this.getLatestUpdate()
faisalhamdi's avatar
faisalhamdi committed
60 61
    }

faisalhamdi's avatar
faisalhamdi committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75
    getLatestUpdate() {
        let payload = {
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID
        }
        api.create().getLastestUpdateMB(payload).then(response => {
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update
                    })
faisalhamdi's avatar
faisalhamdi committed
76 77 78 79 80 81 82 83 84
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, typeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
faisalhamdi's avatar
faisalhamdi committed
85
                }
faisalhamdi's avatar
faisalhamdi committed
86 87
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
88 89 90 91
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
92
    getItemHierarki() {
faisalhamdi's avatar
faisalhamdi committed
93
        this.setState({ loading: true })
faisalhamdi's avatar
faisalhamdi committed
94 95
        let payload = {
            "report_id": this.props.report_id,
faisalhamdi's avatar
faisalhamdi committed
96 97
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
faisalhamdi's avatar
faisalhamdi committed
98 99
            "company_id": this.props.company.company_id,
            "submission_id": this.props.submissionID
faisalhamdi's avatar
faisalhamdi committed
100
        }
faisalhamdi's avatar
faisalhamdi committed
101
        api.create().getDetailReportMB(payload).then(response => {
Dida Adams Arizona's avatar
Dida Adams Arizona committed
102
            // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
103
            let dataTable = []
faisalhamdi's avatar
faisalhamdi committed
104
            if (response.data) {
faisalhamdi's avatar
faisalhamdi committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let res = response.data.data
                        const handlePushChild = (item) => {
                            let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                            if (indexIDzz === -1) {
                                dataTable.push([
                                    item.type_report_id,
                                    item.id,
                                    item.parent,
                                    item.formula,
                                    item.level,
                                    item.description,
                                    item.fixed_asset_movement.total_actual_before === null ? "0" : item.fixed_asset_movement.total_actual_before === "" ? "0" : item.fixed_asset_movement.total_actual_before,
Deni Rinaldi's avatar
Deni Rinaldi committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.january).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.january, formula: item.fixed_asset_movement.january_formula } : Number(item.fixed_asset_movement.january).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.february).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.february, formula: item.fixed_asset_movement.february_formula } : Number(item.fixed_asset_movement.february).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.march).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.march, formula: item.fixed_asset_movement.march_formula } : Number(item.fixed_asset_movement.march).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.april).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.april, formula: item.fixed_asset_movement.april_formula } : Number(item.fixed_asset_movement.april).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.may).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.may, formula: item.fixed_asset_movement.may_formula } : Number(item.fixed_asset_movement.may).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.june).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.june, formula: item.fixed_asset_movement.june_formula } : Number(item.fixed_asset_movement.june).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.july).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.july, formula: item.fixed_asset_movement.july_formula } : Number(item.fixed_asset_movement.july).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.august).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.august, formula: item.fixed_asset_movement.august_formula } : Number(item.fixed_asset_movement.august).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.september).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.september, formula: item.fixed_asset_movement.september_formula } : Number(item.fixed_asset_movement.september).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.october).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.october, formula: item.fixed_asset_movement.october_formula } : Number(item.fixed_asset_movement.october).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.november).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.november, formula: item.fixed_asset_movement.november_formula } : Number(item.fixed_asset_movement.november).toFixed(1),
                                    this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.december).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.december, formula: item.fixed_asset_movement.december_formula } : Number(item.fixed_asset_movement.december).toFixed(1),
                                    Number(item.fixed_asset_movement.total_current_year).toFixed(1),
                                    Number(item.fixed_asset_movement.total_next_year).toFixed(1),
                                    Number(item.fixed_asset_movement.total_more_year).toFixed(1),
faisalhamdi's avatar
faisalhamdi committed
134 135 136 137 138 139 140 141 142 143 144 145
                                    item.order,
                                    item.fixed_asset_movement.forecast_formula,
                                    item.fixed_asset_movement.before_formula
                                ])
                            }
                            if (item.children !== null) {
                                if (item.children.length > 0) {
                                    item.children.map((items, indexs) => {
                                        handlePushChild(items)
                                    })
                                }
                            }
faisalhamdi's avatar
faisalhamdi committed
146
                        }
faisalhamdi's avatar
faisalhamdi committed
147 148 149 150 151 152 153 154 155
                        res.map((item, index) => {
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
                                item.fixed_asset_movement.total_actual_before === null ? "0" : item.fixed_asset_movement.total_actual_before === "" ? "0" : item.fixed_asset_movement.total_actual_before,
Deni Rinaldi's avatar
Deni Rinaldi committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.january).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.january, formula: item.fixed_asset_movement.january_formula } : Number(item.fixed_asset_movement.january).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.february).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.february, formula: item.fixed_asset_movement.february_formula } : Number(item.fixed_asset_movement.february).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.march).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.march, formula: item.fixed_asset_movement.march_formula } : Number(item.fixed_asset_movement.march).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.april).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.april, formula: item.fixed_asset_movement.april_formula } : Number(item.fixed_asset_movement.april).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.may).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.may, formula: item.fixed_asset_movement.may_formula } : Number(item.fixed_asset_movement.may).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.june).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.june, formula: item.fixed_asset_movement.june_formula } : Number(item.fixed_asset_movement.june).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.july).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.july, formula: item.fixed_asset_movement.july_formula } : Number(item.fixed_asset_movement.july).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.august).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.august, formula: item.fixed_asset_movement.august_formula } : Number(item.fixed_asset_movement.august).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.september).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.september, formula: item.fixed_asset_movement.september_formula } : Number(item.fixed_asset_movement.september).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.october).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.october, formula: item.fixed_asset_movement.october_formula } : Number(item.fixed_asset_movement.october).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.november).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.november, formula: item.fixed_asset_movement.november_formula } : Number(item.fixed_asset_movement.november).toFixed(1),
                                this.props.status === 'CLOSED' ? Number(item.fixed_asset_movement.december).toFixed(1) : item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.december, formula: item.fixed_asset_movement.december_formula } : Number(item.fixed_asset_movement.december).toFixed(1),
                                Number(item.fixed_asset_movement.total_current_year).toFixed(1),
                                Number(item.fixed_asset_movement.total_next_year).toFixed(1),
                                Number(item.fixed_asset_movement.total_more_year).toFixed(1),
faisalhamdi's avatar
faisalhamdi committed
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
                                item.order,
                                item.fixed_asset_movement.forecast_formula,
                                item.fixed_asset_movement.before_formula
                            ])
                            if (item.children !== null) {
                                if (item.children.length > 0) {
                                    item.children.map((items, indexs) => {
                                        handlePushChild(items)
                                    })
                                }
                            }
                        })
                        this.setState({ dataTable, loading: false, buttonError: true, editable: true })
                    } else {
                        this.setState({ 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);
                            }
                        })
faisalhamdi's avatar
faisalhamdi committed
193
                    }
faisalhamdi's avatar
faisalhamdi committed
194
                } else {
faisalhamdi's avatar
faisalhamdi committed
195
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false})
faisalhamdi's avatar
faisalhamdi committed
196
                }
faisalhamdi's avatar
faisalhamdi committed
197
            } else {
d.arizona's avatar
d.arizona committed
198
                this.setState({ alert: true, messageAlert: 'Connection Timeout, please check your Connection', tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
199 200 201 202 203 204 205 206
            }
        })
    }

    handleValue(data) {
        let total = 0
        this.state.dataTable.map((item, index) => {
            if (data.rowData[1] == item[2]) {
faisalhamdi's avatar
faisalhamdi committed
207
                total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
faisalhamdi's avatar
faisalhamdi committed
208 209 210 211
            }
        })
        let indexParent = this.state.dataTable.findIndex((val) => val[1] == this.state.dataTable[data.rowIndex][2])
        let a = this.state.dataTable[data.rowIndex][data.columnIndex] = total
d.arizona's avatar
d.arizona committed
212
        // // console.log(indexParent);
faisalhamdi's avatar
faisalhamdi committed
213 214 215
        return a
    }

faisalhamdi's avatar
faisalhamdi committed
216
    handleChange(value, tableMeta) {
faisalhamdi's avatar
faisalhamdi committed
217
        let val = String(value).split(",").join("")
faisalhamdi's avatar
faisalhamdi committed
218
        let data = this.state.dataTable
faisalhamdi's avatar
faisalhamdi committed
219 220
        let indexParent = data.findIndex((val) => val[1] == data[tableMeta.rowIndex][2])
        if (indexParent > 0) {
d.arizona's avatar
d.arizona committed
221
            // // console.log(indexParent)
faisalhamdi's avatar
faisalhamdi committed
222 223 224 225 226 227
            let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
            let jagain = data[indexParent][tableMeta.columnIndex]
            a = data[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
        } else {
            data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
        }
faisalhamdi's avatar
faisalhamdi committed
228 229
    }

faisalhamdi's avatar
faisalhamdi committed
230 231 232 233 234
    backToMasterBudget(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
Deni Rinaldi's avatar
Deni Rinaldi committed
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
                total_actual_before: String(Number(i[6]).toFixed(1)),
                january: i[0] === 5 || i[0] === 6 ? String(Number(i[7].value).toFixed(1)) : String(Number(i[7]).toFixed(1)),
                february: i[0] === 5 || i[0] === 6 ? String(Number(i[8].value).toFixed(1)) : String(Number(i[8]).toFixed(1)),
                march: i[0] === 5 || i[0] === 6 ? String(Number(i[9].value).toFixed(1)) : String(Number(i[9]).toFixed(1)),
                april: i[0] === 5 || i[0] === 6 ? String(Number(i[10].value).toFixed(1)) : String(Number(i[10]).toFixed(1)),
                may: i[0] === 5 || i[0] === 6 ? String(Number(i[11].value).toFixed(1)) : String(Number(i[11]).toFixed(1)),
                june: i[0] === 5 || i[0] === 6 ? String(Number(i[12].value).toFixed(1)) : String(Number(i[12]).toFixed(1)),
                july: i[0] === 5 || i[0] === 6 ? String(Number(i[13].value).toFixed(1)) : String(Number(i[13]).toFixed(1)),
                august: i[0] === 5 || i[0] === 6 ? String(Number(i[14].value).toFixed(1)) : String(Number(i[14]).toFixed(1)),
                september: i[0] === 5 || i[0] === 6 ? String(Number(i[15].value).toFixed(1)) : String(Number(i[15]).toFixed(1)),
                october: i[0] === 5 || i[0] === 6 ? String(Number(i[16].value).toFixed(1)) : String(Number(i[16]).toFixed(1)),
                november: i[0] === 5 || i[0] === 6 ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1)),
                december: i[0] === 5 || i[0] === 6 ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1)),
                total_current_year: String(Number(i[19]).toFixed(1)),
                total_next_year: String(Number(i[20]).toFixed(1)),
                total_more_year: String(Number(i[21]).toFixed(1))
faisalhamdi's avatar
faisalhamdi committed
251 252 253 254 255 256 257 258 259 260
            })
        })
        let payload = {
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
            "fixed_asset_movement": data
        }
d.arizona's avatar
d.arizona committed
261
        // // console.log(data);
d.arizona's avatar
d.arizona committed
262 263 264 265 266
        if (type == 'submitted') {
            this.props.saveToMasterBudget(payload, 'FAM')
        } else {
            this.props.saveToMasterBudget(payload)
        }
faisalhamdi's avatar
faisalhamdi committed
267 268 269
        this.props.onClickClose()
    }

faisalhamdi's avatar
faisalhamdi committed
270 271
    downloadTemplate = async () => {
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
272
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
faisalhamdi's avatar
faisalhamdi committed
273 274
        )
        res = await res.blob()
d.arizona's avatar
d.arizona committed
275
        // // console.log(res)
faisalhamdi's avatar
faisalhamdi committed
276 277 278 279
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
faisalhamdi's avatar
faisalhamdi committed
280
            a.download = 'Template Master Budget Fixed Assets Movement.xlsx';
faisalhamdi's avatar
faisalhamdi committed
281 282 283 284 285 286 287
            a.click();
        }
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
d.arizona's avatar
d.arizona committed
288
            // // console.log(resp)
faisalhamdi's avatar
faisalhamdi committed
289
            if (err) {
d.arizona's avatar
d.arizona committed
290
                // console.log(err);
faisalhamdi's avatar
faisalhamdi committed
291 292 293
            }
            else {
                let isi = resp.rows.slice(3)
d.arizona's avatar
d.arizona committed
294
                // // console.log(resp.rows[2]);
faisalhamdi's avatar
faisalhamdi committed
295
                let payload = []
faisalhamdi's avatar
faisalhamdi committed
296
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
faisalhamdi's avatar
faisalhamdi committed
297 298 299 300 301
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
                            item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
                            item_report: i[1] === undefined ? "" : String(i[1]).trim(),
faisalhamdi's avatar
faisalhamdi committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
                            total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
                            january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
                            february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
                            march: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
                            april: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
                            may: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
                            june: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
                            july: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
                            august: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
                            september: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
                            october: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
                            november: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
                            december: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
                            total_current_year: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
                            total_next_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
                            total_more_year: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()
faisalhamdi's avatar
faisalhamdi committed
318 319 320 321 322 323 324
                        })
                    }
                })
                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
325 326
                    fixed_asset_movement: payload,
                    status: 'submitted'
faisalhamdi's avatar
faisalhamdi committed
327
                }
d.arizona's avatar
d.arizona committed
328
                // // console.log(body)
faisalhamdi's avatar
faisalhamdi committed
329
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
faisalhamdi's avatar
faisalhamdi committed
330 331 332 333 334 335
            }
        });
    }

    checkUpload() {
        api.create().checkUploadMB(this.state.payload).then(response => {
d.arizona's avatar
d.arizona committed
336 337
            // // console.log(JSON.stringify(this.state.payload));
            // // console.log(response)
faisalhamdi's avatar
faisalhamdi committed
338
            if (response.data) {
faisalhamdi's avatar
faisalhamdi committed
339 340 341 342 343 344 345 346 347 348 349 350
                if (response.ok) {
                    if (response.data.status === 'success') {
                        this.setState({ visibleUpload: false, visibleFixedAssetsMovement: false, loading: true })
                        let dataTable = response.data.data.map((item, index) => {
                            return [
                                item.type_report_id,
                                item.item_report_id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.item_report,
                                item.total_actual_before,
Deni Rinaldi's avatar
Deni Rinaldi committed
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.january, formula: item.january_formula } : Number(item.january).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.february, formula: item.february_formula } : Number(item.february).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.march, formula: item.march_formula } : Number(item.march).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.april, formula: item.april_formula } : Number(item.april).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.may, formula: item.may_formula } : Number(item.may).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.june, formula: item.june_formula } : Number(item.june).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.july, formula: item.july_formula } : Number(item.july).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.august, formula: item.august_formula } : Number(item.august).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.september, formula: item.september_formula } : Number(item.september).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.october, formula: item.october_formula } : Number(item.october).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.november, formula: item.november_formula } : Number(item.november).toFixed(1),
                                item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.december, formula: item.december_formula } : Number(item.december).toFixed(1),
                                Number(item.total_current_year).toFixed(1),
                                Number(item.total_next_year).toFixed(1),
                                Number(item.total_more_year).toFixed(1),
faisalhamdi's avatar
faisalhamdi committed
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
                                item.orders,
                                item.forecast_formula,
                                item.before_formula,
                                item.error
                            ]
                        })
                        this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
                            this.state.dataTable.map(item => {
                                if (item[24].length > 0) {
                                    // // console.log('masuk')
                                    this.setState({ buttonError: true, errorPreview: true, editable: true })
                                }
                            })
                            // // console.log(this.state.dataTable);
                        })
                    } 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);
faisalhamdi's avatar
faisalhamdi committed
388 389
                            }
                        })
faisalhamdi's avatar
faisalhamdi committed
390 391 392
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
393
                }
faisalhamdi's avatar
faisalhamdi committed
394 395
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
396 397 398 399
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
400
    uploadFAM(type) {
faisalhamdi's avatar
faisalhamdi committed
401 402 403 404
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
Deni Rinaldi's avatar
Deni Rinaldi committed
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
                total_actual_before: String(Number(i[6]).toFixed(1)),
                january: i[0] === 5 || i[0] === 6 ? String(Number(i[7].value).toFixed(1)) : String(Number(i[7]).toFixed(1)),
                february: i[0] === 5 || i[0] === 6 ? String(Number(i[8].value).toFixed(1)) : String(Number(i[8]).toFixed(1)),
                march: i[0] === 5 || i[0] === 6 ? String(Number(i[9].value).toFixed(1)) : String(Number(i[9]).toFixed(1)),
                april: i[0] === 5 || i[0] === 6 ? String(Number(i[10].value).toFixed(1)) : String(Number(i[10]).toFixed(1)),
                may: i[0] === 5 || i[0] === 6 ? String(Number(i[11].value).toFixed(1)) : String(Number(i[11]).toFixed(1)),
                june: i[0] === 5 || i[0] === 6 ? String(Number(i[12].value).toFixed(1)) : String(Number(i[12]).toFixed(1)),
                july: i[0] === 5 || i[0] === 6 ? String(Number(i[13].value).toFixed(1)) : String(Number(i[13]).toFixed(1)),
                august: i[0] === 5 || i[0] === 6 ? String(Number(i[14].value).toFixed(1)) : String(Number(i[14]).toFixed(1)),
                september: i[0] === 5 || i[0] === 6 ? String(Number(i[15].value).toFixed(1)) : String(Number(i[15]).toFixed(1)),
                october: i[0] === 5 || i[0] === 6 ? String(Number(i[16].value).toFixed(1)) : String(Number(i[16]).toFixed(1)),
                november: i[0] === 5 || i[0] === 6 ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1)),
                december: i[0] === 5 || i[0] === 6 ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1)),
                total_current_year: String(Number(i[19]).toFixed(1)),
                total_next_year: String(Number(i[20]).toFixed(1)),
                total_more_year: String(Number(i[21]).toFixed(1))
faisalhamdi's avatar
faisalhamdi committed
421 422 423
            })
        })
        let body = {
faisalhamdi's avatar
faisalhamdi committed
424
            submission_id: this.props.submissionID,
faisalhamdi's avatar
faisalhamdi committed
425 426 427
            company_id: this.props.company.company_id,
            periode: this.props.periode,
            report_id: this.props.report_id,
faisalhamdi's avatar
faisalhamdi committed
428 429
            fixed_asset_movement: data,
            status: type
faisalhamdi's avatar
faisalhamdi committed
430
        }
d.arizona's avatar
d.arizona committed
431
        // // console.log(JSON.stringify(body));
faisalhamdi's avatar
faisalhamdi committed
432
        api.create('UPLOAD').uploadMasterBudget(body).then(response => {
d.arizona's avatar
d.arizona committed
433
            // // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
434
            if (response.data) {
faisalhamdi's avatar
faisalhamdi committed
435 436 437
                if (response.ok) {
                    if (response.data.status === "success") {
                        this.props.onClickClose()
d.arizona's avatar
d.arizona committed
438 439 440 441 442
                        if (type == 'submitted') {
                            this.props.getReport('FAM')
                        } else {
                            this.props.getReport()
                        }
faisalhamdi's avatar
faisalhamdi committed
443 444 445 446 447 448 449 450 451 452
                    } 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);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
453
                } else {
faisalhamdi's avatar
faisalhamdi committed
454
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
455 456
                }
            } else {
faisalhamdi's avatar
faisalhamdi committed
457 458
                // this.setState({ loading: false })
                // alert(response.problem)
d.arizona's avatar
d.arizona committed
459
                this.setState({ alert: true, messageAlert: 'Error saving data. Please try again', tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
460 461 462 463
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
464
    async downloadAllData() {
faisalhamdi's avatar
faisalhamdi committed
465
        // let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
d.arizona's avatar
d.arizona committed
466
        // // console.log(url);
faisalhamdi's avatar
faisalhamdi committed
467 468
        let resReal = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
        let resNull = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
faisalhamdi's avatar
faisalhamdi committed
469
        let res = await fetch(
d.arizona's avatar
d.arizona committed
470
            this.props.submissionID == null ? resNull : resReal
faisalhamdi's avatar
faisalhamdi committed
471 472 473 474 475 476 477
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
faisalhamdi's avatar
faisalhamdi committed
478
            a.download = 'Master Budget Fixed Assets Movement.xlsx';
faisalhamdi's avatar
faisalhamdi committed
479 480 481 482
            a.click();
        }
    }

faisalhamdi's avatar
faisalhamdi committed
483 484
    handleValidate() {
        let data = []
d.arizona's avatar
d.arizona committed
485
        // // console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
486 487 488 489
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
                total_actual_before: String(i[6]),
Deni Rinaldi's avatar
Deni Rinaldi committed
490 491 492 493 494 495 496 497 498 499 500 501
                january: i[0] === 3 && i[7] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[7].value) : String(i[7]),
                february: i[0] === 3 && i[8] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[8].value) : String(i[8]),
                march: i[0] === 3 && i[9] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[9].value) : String(i[9]),
                april: i[0] === 3 && i[10] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[10].value) : String(i[10]),
                may: i[0] === 3 && i[11] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[11].value) : String(i[11]),
                june: i[0] === 3 && i[12] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[12].value) : String(i[12]),
                july: i[0] === 3 && i[13] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[13].value) : String(i[13]),
                august: i[0] === 3 && i[14] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[14].value) : String(i[14]),
                september: i[0] === 3 && i[15] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[15].value) : String(i[15]),
                october: i[0] === 3 && i[16] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[16].value) : String(i[16]),
                november: i[0] === 3 && i[17] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[17].value) : String(i[17]),
                december: i[0] === 3 && i[18] === "" ? "0" : i[0] === 5 || i[0] === 6 ? String(i[18].value) : String(i[18]),
faisalhamdi's avatar
faisalhamdi committed
502 503 504
                total_current_year: i[0] === 3 && i[19] === "" ? "0" : String(i[19]),
                total_next_year: i[0] === 3 && i[20] === "" ? "0" : String(i[20]),
                total_more_year: i[0] === 3 && i[21] === "" ? "0" : String(i[21])
faisalhamdi's avatar
faisalhamdi committed
505 506
            })
        })
d.arizona's avatar
d.arizona committed
507
        // // console.log(JSON.stringify(data))
faisalhamdi's avatar
faisalhamdi committed
508
        let payload = {
faisalhamdi's avatar
faisalhamdi committed
509 510 511 512 513 514
            "submission_id": this.props.submissionID,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "fixed_asset_movement": data,
            "status": "submitted"
faisalhamdi's avatar
faisalhamdi committed
515 516
        }
        api.create().validateSubmitReport(payload).then((response) => {
d.arizona's avatar
d.arizona committed
517
            // // console.log(response)
faisalhamdi's avatar
faisalhamdi committed
518
            if (response.data.data.result) {
faisalhamdi's avatar
faisalhamdi committed
519
                this.setState({ loading: false, buttonError: false, editable: false })
faisalhamdi's avatar
faisalhamdi committed
520 521 522 523 524 525
            } else {
                this.setState({ loading: false, buttonError: true, editable: true })
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
526 527 528 529
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
530
    render() {
faisalhamdi's avatar
faisalhamdi committed
531
        let dataTable2 = this.state.dataTable
Dida Adams Arizona's avatar
Dida Adams Arizona committed
532
        const handleValueFormula = (value, tableMeta, Bfr) => {
d.arizona's avatar
d.arizona committed
533 534 535
            let splitFormula = String(tableMeta.rowData[3]).split('@')
            let baru = []
            let anjay = []
Deni Rinaldi's avatar
Deni Rinaldi committed
536 537
            splitFormula.map((item, index) => {
                let items = String(item).substr(Number(String(item).length) - 1, 1)
d.arizona's avatar
d.arizona committed
538 539 540 541
                let re = /^[a-zA-Z0-9_]+$/;
                let asd = ''
                if (item !== "") {
                    if (!re.test(items)) {
Deni Rinaldi's avatar
Deni Rinaldi committed
542 543
                        baru.push(String(item).substr(0, Number(String(item).length) - 1))
                        baru.push(String(item).substr(Number(String(item).length) - 1, 1))
d.arizona's avatar
d.arizona committed
544 545 546 547 548 549
                    } else {
                        baru.push(String(item))
                    }
                }
            })

d.arizona's avatar
d.arizona committed
550
            // if (tableMeta.columnIndex == 18) {
d.arizona's avatar
d.arizona committed
551 552
            //     // console.log(splitFormula)
            //     // console.log(baru)
d.arizona's avatar
d.arizona committed
553
            // }
d.arizona's avatar
d.arizona committed
554 555 556
            // // console.log(baru)
            let tambahan = false
            let opet = ""
Deni Rinaldi's avatar
Deni Rinaldi committed
557
            baru.map((item, index) => {
d.arizona's avatar
d.arizona committed
558 559 560
                if (item == 'X') {
                    tambahan = true
                } else if (item == '-' || item == '+' || item == '/' || item == '*') {
d.arizona's avatar
d.arizona committed
561 562 563
                    anjay.push(item)
                } else {
                    if (String(item).includes('#')) {
Dida Adams Arizona's avatar
Dida Adams Arizona committed
564 565 566
                        if (Bfr !== undefined) {
                            let data = 24
                            let period = Number(this.props.periode) - 1
faisalhamdi's avatar
faisalhamdi committed
567
                            // console.log(dataTable2[tableMeta.rowIndex][data])
Dida Adams Arizona's avatar
Dida Adams Arizona committed
568 569 570 571 572 573 574
                            anjay.push(0)
                            let indexID = dataTable2[tableMeta.rowIndex][data].findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == period)
                            if (indexID !== -1) {
                                let valuezz = dataTable2[tableMeta.rowIndex][data][indexID].value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        } else if (String(item).includes('[M-1]')) {
d.arizona's avatar
d.arizona committed
575
                            let tst = String(item).replace('[M-1]', '')
Deni Rinaldi's avatar
Deni Rinaldi committed
576 577
                            let data = tableMeta.columnIndex == 7 ? 18 : tableMeta.columnIndex - 1
                            let period = data == 18 ? Number(this.props.periode) - 1 : this.props.periode
d.arizona's avatar
d.arizona committed
578
                            let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
d.arizona's avatar
d.arizona committed
579
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
580
                                let valuezz = tableMeta.rowData[data].formula[indexID].value
Deni Rinaldi's avatar
Deni Rinaldi committed
581
                                anjay.push(valuezz == "" ? 0 : valuezz)
d.arizona's avatar
d.arizona committed
582 583
                            }
                        } else {
d.arizona's avatar
d.arizona committed
584
                            let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
d.arizona's avatar
d.arizona committed
585
                            // // console.log(indexID)
d.arizona's avatar
d.arizona committed
586
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
587
                                // // console.log(value.formula[indexID].value)
d.arizona's avatar
d.arizona committed
588
                                let valuezz = value.formula[indexID].value
Deni Rinaldi's avatar
Deni Rinaldi committed
589
                                anjay.push(valuezz == "" ? 0 : valuezz)
d.arizona's avatar
d.arizona committed
590 591 592
                            }
                        }
                    } else {
d.arizona's avatar
d.arizona committed
593
                        // // console.log(item)
d.arizona's avatar
d.arizona committed
594
                        let indexID = dataTable2.findIndex((val) => val[22] == item)
d.arizona's avatar
d.arizona committed
595 596 597 598 599 600 601 602 603 604
                        if (item == 'X-1') {
                            anjay.push(-1)
                        } else if (tambahan) {
                            if (item == '-' || item == '+' || item == '/' || item == '*') {
                                opet = item
                            } else {
                                anjay.push(opet == ''? Number(item) : Number(String(opet + String(item))))
                                tambahan = false
                                opet = ""
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
605
                        } else {
d.arizona's avatar
d.arizona committed
606 607 608 609 610 611 612 613
                            if (indexID !== -1) {
                                let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            } else {
                                if (item === '(-1)') {
                                    anjay.push(-1)
                                }
                                // // console.log(item);
Deni Rinaldi's avatar
Deni Rinaldi committed
614
                            }
d.arizona's avatar
d.arizona committed
615 616 617 618
                        }
                    }
                }
            })
d.arizona's avatar
d.arizona committed
619 620
            // // console.log(baru)
            // // console.log(anjay)
d.arizona's avatar
d.arizona committed
621 622 623 624 625 626 627 628 629 630 631 632 633

            let total = 0
            let opt = ""
            anjay.map((item, index) => {
                if (item == "+") {
                    opt = "tambah"
                } else if (item == "-") {
                    opt = "kurang"
                } else if (item == "*") {
                    opt = "kali"
                } else if (item == "/") {
                    opt = "bagi"
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
634
                    item = item == "" ? 0 : item
d.arizona's avatar
d.arizona committed
635 636 637 638 639 640 641
                    if (opt == "tambah") {
                        total = Number(total) + Number(item)
                    } else if (opt == "kurang") {
                        total = Number(total) - Number(item)
                    } else if (opt == "kali") {
                        total = Number(total) * Number(item)
                    } else if (opt == "bagi") {
Deni Rinaldi's avatar
Deni Rinaldi committed
642
                        total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
d.arizona's avatar
d.arizona committed
643 644 645 646 647
                    } else {
                        total += Number(item)
                    }
                }
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
648
            total = R.equals(total, NaN) ? "0.0" : total
d.arizona's avatar
d.arizona committed
649
            // // console.log(dataTable2[tableMeta.rowIndex][22])
Deni Rinaldi's avatar
Deni Rinaldi committed
650
            // // console.log(tableMeta.rowData[5])
d.arizona's avatar
d.arizona committed
651
            // if (tableMeta.rowData[5] == 'Beginning Balance') {
Deni Rinaldi's avatar
Deni Rinaldi committed
652 653
            // console.log(baru)
            // console.log(anjay)
Deni Rinaldi's avatar
Deni Rinaldi committed
654
            // console.log(total)
d.arizona's avatar
d.arizona committed
655
            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
656

d.arizona's avatar
d.arizona committed
657
            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
d.arizona's avatar
d.arizona committed
658
                // // console.log([tableMeta.rowIndex][tableMeta.columnIndex])
d.arizona's avatar
d.arizona committed
659 660 661 662 663 664 665 666
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
            }

            return total
        }

faisalhamdi's avatar
faisalhamdi committed
667
        const handleChange = (value, tableMeta, type) => {
faisalhamdi's avatar
faisalhamdi committed
668
            let val = String(value).split(",").join("")
faisalhamdi's avatar
faisalhamdi committed
669
            if (type === "actual") {
Deni Rinaldi's avatar
Deni Rinaldi committed
670
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
faisalhamdi's avatar
faisalhamdi committed
671
            } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
672
                let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[tableMeta.rowIndex][2])
faisalhamdi's avatar
faisalhamdi committed
673
                if (indexParent > 0) {
d.arizona's avatar
d.arizona committed
674
                    // // console.log(indexParent)
faisalhamdi's avatar
faisalhamdi committed
675 676 677 678 679 680
                    let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
                    let jagain = dataTable2[indexParent][tableMeta.columnIndex]
                    a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
                } else {
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
                }
faisalhamdi's avatar
faisalhamdi committed
681 682
            }
        }
d.arizona's avatar
d.arizona committed
683
        const handleForecast = (tableMeta, periode) => {
d.arizona's avatar
d.arizona committed
684
            let total = 0
d.arizona's avatar
d.arizona committed
685
            if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'gain/ (loss) on fixed assets' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'ending balance' || String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') {
d.arizona's avatar
d.arizona committed
686 687 688
                if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') {
                    let indexID = dataTable2.findIndex((val, index) => String(val[5]).toLocaleLowerCase() == 'ending balance' && dataTable2[index-1][2] == tableMeta.rowData[2])
                    if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
689 690
                        // console.log(dataTable2)
                        total = tableMeta.columnIndex == 21? dataTable2[indexID][20] : dataTable2[indexID][18].value
d.arizona's avatar
d.arizona committed
691 692 693 694 695 696
                    }
                } else {
                    let indexID = dataTable2[tableMeta.rowIndex][23].findIndex((val) => val.periode == periode)
                    if (indexID !== -1) {
                        total = dataTable2[tableMeta.rowIndex][23][indexID].value
                    }
d.arizona's avatar
d.arizona committed
697 698
                }
            } else {
d.arizona's avatar
d.arizona committed
699
                total = handleValueFormula(tableMeta.columnIndex, tableMeta)
d.arizona's avatar
d.arizona committed
700
            }
d.arizona's avatar
d.arizona committed
701
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
d.arizona's avatar
d.arizona committed
702 703
            return total
        }
faisalhamdi's avatar
faisalhamdi committed
704 705
        const handleTotal = (tableMeta) => {
            let total = 0
faisalhamdi's avatar
faisalhamdi committed
706
            // console.log(tableMeta)            
faisalhamdi's avatar
faisalhamdi committed
707 708 709
            // if (tableMeta.rowData[5] == 'Beginning balance') {
            //     console.log(tableMeta.rowData)
            // }
d.arizona's avatar
d.arizona committed
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
            if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'ending balance') {
                total = dataTable2[tableMeta.rowIndex][18].value
                dataTable2[tableMeta.rowIndex][19] = total
            } else if (String(tableMeta.rowData[5]).toLocaleLowerCase() == 'beginning balance') {
                total = dataTable2[tableMeta.rowIndex][7].value
                dataTable2[tableMeta.rowIndex][19] = total
            } else {
                dataTable2[tableMeta.rowIndex].map((item, index) => {
                    if (index >= 7 && index <= 18) {
                        let valItem = item.value == undefined ? item == undefined || item == "" ? 0 : item : item.value == "" ? 0 : item.value
                        total += Number(valItem)
                    }
                })
                dataTable2[tableMeta.rowIndex][19] = total
            }
faisalhamdi's avatar
faisalhamdi committed
725
            return total
d.arizona's avatar
d.arizona committed
726
            // // console.log(total);
faisalhamdi's avatar
faisalhamdi committed
727
        }
faisalhamdi's avatar
faisalhamdi committed
728 729 730 731 732 733 734 735 736
        const handleValue = (data) => {
            let total = 0
            dataTable2.map((item, index) => {
                if (data.rowData[1] == item[2]) {
                    total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
                }
            })
            let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[data.rowIndex][2])
            let a = dataTable2[data.rowIndex][data.columnIndex] = Number(total)
d.arizona's avatar
d.arizona committed
737
            // // console.log(indexParent);
faisalhamdi's avatar
faisalhamdi committed
738 739
            return a
        }
Dida Adams Arizona's avatar
Dida Adams Arizona committed
740 741

        const handleBfr = (value,tableMeta) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
742
            let total = 0
Dida Adams Arizona's avatar
Dida Adams Arizona committed
743 744 745 746
            total = handleValueFormula(value, tableMeta, 'before')
            return total
        }

faisalhamdi's avatar
faisalhamdi committed
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
        const handleFormula = (data, tableMeta, month) => {
            let rilFormula = String(tableMeta.rowData[3])
            if (rilFormula.includes("#")) {
                if (this.props.status === "not-yet") {
                    let splitOrder = String(tableMeta.rowData[3]).split('@')
                    for (let index = 0; index < splitOrder.length; index++) {
                        if (splitOrder[index] === "") {
                        } else {
                            if (splitOrder[index].includes('#')) {

                            } else {
                                let splitOperator = splitOrder[index].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
                                let reg = /^\d+$/
                                splitOperator.map((item) => {
                                    if (reg.test(item) === true) {
                                        let i = dataTable2.findIndex((val) => val[23] == item)
                                        if (i > 0) {
                                            rilFormula = rilFormula.replace(item, dataTable2[i][tableMeta.columnIndex] === "" ? "0" : dataTable2[i][tableMeta.columnIndex])
                                        }
                                    }
                                })
                            }
                        }
                    }
                    let body = {
                        "submission_id": null,
                        "company_id": this.props.company.company_id,
                        "report_id": this.props.report_id,
                        "year": this.props.periode,
                        "month": month,
                        "formula": rilFormula
                    }
                    api.create().countingFormula(body).then(response => {
d.arizona's avatar
d.arizona committed
780
                        // // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
781 782 783
                        if (response.data) {
                            if (response.data.status === "success") {
                                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
784
                                    return response.data.data.result
faisalhamdi's avatar
faisalhamdi committed
785 786 787
                                }, 2000);
                            }
                        }
faisalhamdi's avatar
faisalhamdi committed
788
                    })
faisalhamdi's avatar
faisalhamdi committed
789
                } else {
faisalhamdi's avatar
faisalhamdi committed
790 791 792 793 794 795 796 797 798
                    let body = {
                        "submission_id": this.props.submissionID,
                        "company_id": this.props.company.company_id,
                        "report_id": this.props.report_id,
                        "year": this.props.periode,
                        "month": month,
                        "formula": rilFormula
                    }
                    api.create().countingFormula(body).then(response => {
d.arizona's avatar
d.arizona committed
799
                        // // console.log(response)
faisalhamdi's avatar
faisalhamdi committed
800 801
                        if (response.data) {
                            if (response.data.status === "success") {
faisalhamdi's avatar
faisalhamdi committed
802
                                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
803
                                    return response.data.data.result
faisalhamdi's avatar
faisalhamdi committed
804
                                }, 2000);
faisalhamdi's avatar
faisalhamdi committed
805 806 807
                            }
                        }
                    })
faisalhamdi's avatar
faisalhamdi committed
808
                }
faisalhamdi's avatar
faisalhamdi committed
809 810 811 812 813 814 815
            } else {
                let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
                let arrayJumlah = []
                arrayFormula.map((item, indexs) => {
                    let index = dataTable2.findIndex((val) => val[1] == item)
                    if (index > 0) {
                        arrayJumlah.push(dataTable2[index][tableMeta.columnIndex])
faisalhamdi's avatar
faisalhamdi committed
816
                    } else {
faisalhamdi's avatar
faisalhamdi committed
817
                        arrayJumlah.push(item)
faisalhamdi's avatar
faisalhamdi committed
818
                    }
faisalhamdi's avatar
faisalhamdi committed
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
                    // if (indexs % 2 !== 0) {
                    //     operator.push(item)
                    // }
                })
                let array = arrayJumlah
                let total = 0
                let opt = ""
                array.map((item, index) => {
                    if (item == "+") {
                        opt = "tambah"
                    } else if (item == "-") {
                        opt = "kurang"
                    } else if (item == "*") {
                        opt = "kali"
                    } else if (item == "/") {
                        opt = "bagi"
                    } else {
                        if (opt == "tambah") {
                            total = Number(total) + Number(item)
                        } else if (opt == "kurang") {
                            total = Number(total) - Number(item)
                        } else if (opt == "kali") {
                            total = Number(total) * Number(item)
                        } else if (opt == "bagi") {
                            total = Number(total) / Number(item)
                        } else {
                            total += item
                        }
                    }
                })
                let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
                return a
            }
faisalhamdi's avatar
faisalhamdi committed
852
        }
Dida Adams Arizona's avatar
Dida Adams Arizona committed
853

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

faisalhamdi's avatar
faisalhamdi committed
2588 2589 2590
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
2591
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Master Budget Submission</Typography>
faisalhamdi's avatar
faisalhamdi committed
2592
                </div>
faisalhamdi's avatar
faisalhamdi committed
2593 2594 2595 2596 2597
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
faisalhamdi's avatar
faisalhamdi committed
2598
                {/* {this.state.loading && loadingComponent} */}
faisalhamdi's avatar
faisalhamdi committed
2599
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
faisalhamdi's avatar
faisalhamdi committed
2600 2601 2602
                    {this.state.visibleFixedAssetsMovement === true ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
faisalhamdi's avatar
faisalhamdi committed
2603
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Fixed Assets Movement</Typography>
faisalhamdi's avatar
faisalhamdi committed
2604 2605 2606 2607 2608
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2609
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
faisalhamdi's avatar
faisalhamdi committed
2610 2611 2612
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2613
                                        {this.state.dataTable.length == 0 ? null : this.props.isApprover == true ?
faisalhamdi's avatar
faisalhamdi committed
2614
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2615
                                                <a data-tip={'Download'} data-for="download">
faisalhamdi's avatar
faisalhamdi committed
2616 2617 2618 2619 2620 2621 2622
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2623 2624 2625 2626 2627 2628
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
faisalhamdi's avatar
faisalhamdi committed
2629
                                                    >
Deni Rinaldi's avatar
Deni Rinaldi committed
2630
                                                        <img src={Images.download} />
faisalhamdi's avatar
faisalhamdi committed
2631 2632
                                                    </button>
                                                </a>
Deni Rinaldi's avatar
Deni Rinaldi committed
2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            </div> :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                {((this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === "draft" || this.props.status === 'submitted')) && (
                                                    <div>
                                                        <a data-tip={'Download Template'} data-for="template">
                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    margin: 5
                                                                }}
                                                                onClick={() => this.downloadTemplate()}
                                                            >
                                                                <img src={Images.template} />
                                                            </button>
                                                        </a>
                                                        <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                                    </div>
a.bairuha's avatar
a.bairuha committed
2653
                                                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670
                                                {((this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === "draft" || this.props.status === 'submitted')) && (
                                                    <div>
                                                        <a data-tip={'Upload'} data-for="upload">
                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    margin: 5
                                                                }}
                                                                onClick={() => this.setState({ visibleUpload: true })}
                                                            >
                                                                <img src={Images.upload} />
                                                            </button>
                                                        </a>
                                                        <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                                    </div>
a.bairuha's avatar
a.bairuha committed
2671
                                                )}
faisalhamdi's avatar
faisalhamdi committed
2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            </div>
                                        }
faisalhamdi's avatar
faisalhamdi committed
2693
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2694
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2695

faisalhamdi's avatar
faisalhamdi committed
2696
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2697
                                    {this.state.loading && loadingComponent}
faisalhamdi's avatar
faisalhamdi committed
2698
                                    <MuiThemeProvider theme={getMuiTheme()}>
faisalhamdi's avatar
faisalhamdi committed
2699 2700 2701 2702 2703
                                        <MUIDataTable
                                            data={dataTable2}
                                            columns={columns}
                                            options={options}
                                        />
faisalhamdi's avatar
faisalhamdi committed
2704
                                    </MuiThemeProvider>
Deni Rinaldi's avatar
Deni Rinaldi committed
2705
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2706
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2707
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2708
                            <div className="grid grid-2x" style={{ marginTop: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719
                                <div className="col-1">
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
faisalhamdi's avatar
faisalhamdi committed
2720 2721 2722 2723 2724
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
faisalhamdi's avatar
faisalhamdi committed
2725
                                    >
faisalhamdi's avatar
faisalhamdi committed
2726
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
2727
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
faisalhamdi's avatar
faisalhamdi committed
2728 2729
                                        </div>
                                    </button>
faisalhamdi's avatar
faisalhamdi committed
2730
                                </div>
a.bairuha's avatar
a.bairuha committed
2731
                                {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
faisalhamdi's avatar
faisalhamdi committed
2732
                                    (this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === "draft" || this.props.status === 'submitted') ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768
                                        <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                            <button
                                                className="button"
                                                type="button"
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                    marginRight: 20
                                                }}
                                                onClick={() => {
                                                    this.setState({ loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.handleValidate()
                                                        }, 100);
                                                    })
                                                }}
                                            >
                                                <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                                </div>
                                            </button>
                                            <button
                                                className="button"
                                                type="button"
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                    marginRight: 20
                                                }}
                                                onClick={() =>
                                                    this.state.editable === true ?
                                                        null :
faisalhamdi's avatar
faisalhamdi committed
2769
                                                        this.state.handleTekTekTek == 1 ? null :
Deni Rinaldi's avatar
Deni Rinaldi committed
2770
                                                            this.setState({ handleTekTekTek: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2771
                                                                this.backToMasterBudget('draft')
Deni Rinaldi's avatar
Deni Rinaldi committed
2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801
                                                            })
                                                }
                                            >
                                                <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                                </div>
                                            </button>
                                            <button
                                                type="button"
                                                disabled={this.state.buttonError}
                                                onClick={() =>
                                                    this.state.buttonError ?
                                                        this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                        :
                                                        this.state.handleTekTekTek == 1 ? null :
                                                            this.setState({ handleTekTekTek: 1 }, () => {
                                                                this.backToMasterBudget('submitted')
                                                            })}
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: this.state.buttonError === true ? 'default' : 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                }}
                                            >
                                                <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                                </div>
                                            </button>
                                        </div> : null
faisalhamdi's avatar
faisalhamdi committed
2802
                                }
faisalhamdi's avatar
faisalhamdi committed
2803 2804 2805 2806 2807 2808 2809 2810
                            </div>
                        </Paper>
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div>
                                <div style={{ padding: 25 }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2811
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2812
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
faisalhamdi's avatar
faisalhamdi committed
2813
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2814
                                    {this.state.dataLoaded && (
faisalhamdi's avatar
faisalhamdi committed
2815
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
faisalhamdi's avatar
faisalhamdi committed
2816 2817
                                            {this.state.loading && loadingComponent}
                                            <MuiThemeProvider theme={getMuiTheme()}>
faisalhamdi's avatar
faisalhamdi committed
2818 2819 2820 2821 2822
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
faisalhamdi's avatar
faisalhamdi committed
2823
                                            </MuiThemeProvider>
faisalhamdi's avatar
faisalhamdi committed
2824 2825 2826
                                        </div>
                                    )}
                                </div>
2827 2828 2829 2830 2831 2832

                                <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                    <div className="col-1">
                                        <button
                                            type="button"
                                            onClick={() => this.setState({ loading: true, visibleFixedAssetsMovement: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2833
                                                setTimeout(() => {
2834
                                                    this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
2835
                                                }, 100);
2836 2837 2838 2839
                                            })}
                                            style={{ marginRight: 20 }}
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
2840
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
2841 2842 2843 2844 2845 2846 2847
                                            </div>
                                        </button>
                                    </div>
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                        <button
                                            className="button"
                                            type="button"
d.arizona's avatar
d.arizona committed
2848
                                            // disabled={this.state.buttonError}
2849 2850
                                            style={{
                                                backgroundColor: 'transparent',
Deni Rinaldi's avatar
Deni Rinaldi committed
2851
                                                cursor: 'pointer',
2852 2853 2854 2855 2856 2857 2858
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2859
                                                        this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false, editable: false })
2860 2861 2862 2863 2864 2865 2866 2867 2868
                                                    }, 100);
                                                })
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
                                        </button>
                                        <button
faisalhamdi's avatar
faisalhamdi committed
2869
                                            className="button"
2870 2871
                                            type="button"
                                            disabled={this.state.buttonError}
faisalhamdi's avatar
faisalhamdi committed
2872 2873
                                            style={{
                                                backgroundColor: 'transparent',
faisalhamdi's avatar
faisalhamdi committed
2874
                                                cursor: this.state.editable === true ? 'default' : 'pointer',
faisalhamdi's avatar
faisalhamdi committed
2875 2876 2877 2878
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
faisalhamdi's avatar
faisalhamdi committed
2879
                                            onClick={() => this.state.editable === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2880 2881 2882 2883 2884 2885 2886
                                                null : this.setState({ loading: true }, () =>
                                                    this.state.handleTekTekTek == 1 ? null :
                                                        this.setState({ handleTekTekTek: 1 }, () => {
                                                            setTimeout(() => {
                                                                this.uploadFAM('draft')
                                                            }, 100);
                                                        }))}
2887 2888 2889 2890 2891 2892 2893
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                            </div>
                                        </button>
                                        <button
                                            type="button"
faisalhamdi's avatar
faisalhamdi committed
2894 2895 2896 2897 2898 2899
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2900
                                            onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
2901
                                                this.state.editable === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2902 2903 2904 2905 2906 2907 2908
                                                    null : this.setState({ loading: true }, () =>
                                                        this.state.handleTekTekTek == 1 ? null :
                                                            this.setState({ handleTekTekTek: 1 }, () => {
                                                                setTimeout(() => {
                                                                    this.uploadFAM('submitted')
                                                                }, 100);
                                                            })
EKSAD's avatar
EKSAD committed
2909
                                                    )
faisalhamdi's avatar
faisalhamdi committed
2910
                                            }
2911 2912 2913 2914 2915 2916
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
                                        </button>
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2917
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2918
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2919 2920
                        </Paper>}
                </div>
faisalhamdi's avatar
faisalhamdi committed
2921

faisalhamdi's avatar
faisalhamdi committed
2922 2923 2924 2925 2926 2927 2928
                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
faisalhamdi's avatar
faisalhamdi committed
2929
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2930
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2931 2932 2933 2934 2935 2936 2937 2938
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
faisalhamdi's avatar
faisalhamdi committed
2939 2940
                                </div>
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2941 2942 2943 2944 2945 2946 2947 2948 2949 2950
                            <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={() => {
r.kurnia's avatar
r.kurnia committed
2951
                                    String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("FIXED") && String(this.state.judul).includes("ASSETS") && String(this.state.judul).includes("MOVEMENT") ?
faisalhamdi's avatar
faisalhamdi committed
2952 2953 2954 2955
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
faisalhamdi's avatar
faisalhamdi committed
2956
                        </div>
faisalhamdi's avatar
faisalhamdi committed
2957 2958
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
2959 2960 2961 2962
            </div>
        );
    }
}