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

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

Deni Rinaldi's avatar
Deni Rinaldi committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());

const options = ct.customOptionsFixedColumn();

const style = {
    position: "sticky",
    left: 0,
    zIndex: 101,
    background: "white",
};
const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100,
    top: 0
};

export default class BalanceSheetMR extends Component {
Deni Rinaldi's avatar
Deni Rinaldi committed
44 45 46 47
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
d.arizona's avatar
d.arizona committed
48
            loading: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
49 50 51
            visibleBSMR: true,
            valueThreshold: 0,
            minValue: 0,
Deni Rinaldi's avatar
Deni Rinaldi committed
52
            maxValue: 0,
Deni Rinaldi's avatar
Deni Rinaldi committed
53
            updateBy: '-',
rifkaki's avatar
rifkaki committed
54 55
            notes: "",
            judulColumn: null,
d.arizona's avatar
d.arizona committed
56
            get_for: "view",
Riri Novita's avatar
Riri Novita committed
57
            viewOnly : true,
d.arizona's avatar
d.arizona committed
58
            kansas: 0
Deni Rinaldi's avatar
Deni Rinaldi committed
59
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
60
        this.fileHandler = this.fileHandler.bind(this);
Deni Rinaldi's avatar
Deni Rinaldi committed
61
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
62

Deni Rinaldi's avatar
Deni Rinaldi committed
63
    componentDidMount() {
Deni Rinaldi's avatar
Deni Rinaldi committed
64
        this.getSettingControl()
Deni Rinaldi's avatar
Deni Rinaldi committed
65
        this.getLatestUpdate()
Riri Novita's avatar
Riri Novita committed
66 67 68 69 70 71 72
        this.handleViewOnly()
    }

    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
d.arizona's avatar
d.arizona committed
73
        let checkPrevRev = false
Riri Novita's avatar
Riri Novita committed
74 75 76 77 78 79 80 81 82 83 84 85

        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }
        
        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
        } 
d.arizona's avatar
d.arizona committed
86 87 88 89 90 91
        
        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }
Riri Novita's avatar
Riri Novita committed
92 93 94 95 96 97 98
        
        if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
            checkStatus = true
        } else {
            checkStatus = false
        }

d.arizona's avatar
d.arizona committed
99
        this.setState({viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev})
Deni Rinaldi's avatar
Deni Rinaldi committed
100 101 102 103 104 105 106 107 108 109 110
    }

    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,
            "monthly_report_id": this.props.monthlyReportId,
            "months": this.props.month.month_id
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
111 112
        api.create().getLastestUpdateMR(payload).then(response => {
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
113 114 115
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
116 117
                        updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update,
                        notes: response.data.data.notes_update === null ? "" : response.data.data.notes_update
Deni Rinaldi's avatar
Deni Rinaldi committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
133 134 135 136
    }

    getSettingControl() {
        let body = {
rifkaki's avatar
rifkaki committed
137
            group: 'THRESHOLD_CONTROL',
Deni Rinaldi's avatar
Deni Rinaldi committed
138 139 140 141 142 143 144 145 146
            company_id: this.props.company.company_id,
            type: 'BALANCE_SHEET'
        }

        api.create().getAllSettingByType(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
147 148
                        minValue: response.data.data[0] ? Number(response.data.data[0].min_value) : -5,
                        maxValue: response.data.data[0] ? Number(response.data.data[0].max_value) : 5,
Deni Rinaldi's avatar
Deni Rinaldi committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
                    }, () => {
                        this.getItemHierarki()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
166 167
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
168
    getItemHierarki() {
Deni Rinaldi's avatar
Deni Rinaldi committed
169
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
170
            "report_id": this.props.report_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
171 172 173
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
174
            "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
175 176
            "months": this.props.month.month_id,
            "get_for" : this.state.get_for
Deni Rinaldi's avatar
Deni Rinaldi committed
177
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
178
        api.create().getHierarkiMontlyReportBS(payload).then(response => {
rifkaki's avatar
rifkaki committed
179
            console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
180
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
181
            let dataTable = []
d.arizona's avatar
d.arizona committed
182 183
            let err = false

Deni Rinaldi's avatar
Deni Rinaldi committed
184 185 186 187
            if (response.data) {
                let res = response.data.data
                const handlePushChild = (item) => {
                    let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
rifkaki's avatar
rifkaki committed
188
                    if (item.type_report_id === 3) {    
d.arizona's avatar
d.arizona committed
189 190 191
                        // if (item.balance_sheet.mtd_vs_previous_month == "" &&  Number(item.balance_sheet.percent_act_vs_previous_month) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_previous_month) > this.state.maxValue) {
                        //     err = true
                        // } 
d.arizona's avatar
d.arizona committed
192 193 194
                        if (item.balance_sheet.mtd_vs_mb == "" &&  Number(item.balance_sheet.percent_act_vs_mb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_mb) > this.state.maxValue) {
                            err = true
                        }
d.arizona's avatar
d.arizona committed
195 196 197
                        // if (item.balance_sheet.mtd_vs_rb == "" &&  Number(item.balance_sheet.percent_act_vs_rb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_rb) > this.state.maxValue) {
                        //     err = true
                        // }
d.arizona's avatar
d.arizona committed
198
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
199 200 201 202 203 204 205 206
                    if (indexIDzz === -1) {
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.description,
Deni Rinaldi's avatar
Deni Rinaldi committed
207 208 209 210
                            item.balance_sheet.rolling_outlook === null ? "0" : item.balance_sheet.rolling_outlook === "" ? "0" : item.balance_sheet.rolling_outlook,
                            item.balance_sheet.master_budget === "" ? "0" : item.balance_sheet.master_budget,
                            item.balance_sheet.rolling_budget === "" ? "0" : item.balance_sheet.rolling_budget,
                            item.balance_sheet.actual === "" ? "0" : item.balance_sheet.actual,
Deni Rinaldi's avatar
Deni Rinaldi committed
211
                            item.balance_sheet.actual_previous_month === null ? "0.0" : item.balance_sheet.actual_previous_month === "" ? "0.0" : item.balance_sheet.actual_previous_month,
Deni Rinaldi's avatar
Deni Rinaldi committed
212 213 214 215 216 217
                            item.balance_sheet.amount_act_vs_previous_month === "" ? "0" : item.balance_sheet.amount_act_vs_previous_month,
                            item.balance_sheet.percent_act_vs_previous_month === "" ? "0" : item.balance_sheet.percent_act_vs_previous_month,
                            item.balance_sheet.amount_act_vs_mb === "" ? "0" : item.balance_sheet.amount_act_vs_mb,
                            item.balance_sheet.percent_act_vs_mb === "" ? "0" : item.balance_sheet.percent_act_vs_mb,
                            item.balance_sheet.amount_act_vs_rb === "" ? "0" : item.balance_sheet.amount_act_vs_rb,
                            item.balance_sheet.percent_act_vs_rb === "" ? "0" : item.balance_sheet.percent_act_vs_rb,
Deni Rinaldi's avatar
Deni Rinaldi committed
218 219 220
                            item.balance_sheet.mtd_vs_previous_month === null ? "" : item.balance_sheet.mtd_vs_previous_month,
                            item.balance_sheet.mtd_vs_mb === null ? "" : item.balance_sheet.mtd_vs_mb,
                            item.balance_sheet.mtd_vs_rb === null ? "" : item.balance_sheet.mtd_vs_rb,
d.arizona's avatar
d.arizona committed
221
                            item.balance_sheet.actual_formula,
rifkaki's avatar
rifkaki committed
222 223 224
                            item.order,
                            item.condition_it_should_be,
                            item.condition_if_wrong
Deni Rinaldi's avatar
Deni Rinaldi committed
225 226 227 228 229 230 231 232 233 234 235
                        ])
                    }
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                }
                res.map((item, index) => {
rifkaki's avatar
rifkaki committed
236
                    if (item.type_report_id === 3) {    
d.arizona's avatar
d.arizona committed
237 238 239
                        // if (item.balance_sheet.mtd_vs_previous_month == "" &&  Number(item.balance_sheet.percent_act_vs_previous_month) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_previous_month) > this.state.maxValue) {
                        //     err = true
                        // } 
d.arizona's avatar
d.arizona committed
240 241 242
                        if (item.balance_sheet.mtd_vs_mb == "" &&  Number(item.balance_sheet.percent_act_vs_mb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_mb) > this.state.maxValue) {
                            err = true
                        }
d.arizona's avatar
d.arizona committed
243 244 245
                        // if (item.balance_sheet.mtd_vs_rb == "" &&  Number(item.balance_sheet.percent_act_vs_rb) < this.state.minValue || Number(item.balance_sheet.percent_act_vs_rb) > this.state.maxValue) {
                        //     err = true
                        // }
d.arizona's avatar
d.arizona committed
246
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
247 248 249 250 251 252 253
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
Deni Rinaldi's avatar
Deni Rinaldi committed
254 255 256 257
                        item.balance_sheet.rolling_outlook === null ? "0" : item.balance_sheet.rolling_outlook === "" ? "0" : item.balance_sheet.rolling_outlook,
                        item.balance_sheet.master_budget === "" ? "0" : item.balance_sheet.master_budget,
                        item.balance_sheet.rolling_budget === "" ? "0" : item.balance_sheet.rolling_budget,
                        item.balance_sheet.actual === "" ? "0" : item.balance_sheet.actual,
Deni Rinaldi's avatar
Deni Rinaldi committed
258
                        item.balance_sheet.actual_previous_month === null ? "0.0" : item.balance_sheet.actual_previous_month === "" ? "0.0" : item.balance_sheet.actual_previous_month,
Deni Rinaldi's avatar
Deni Rinaldi committed
259 260 261 262 263 264
                        item.balance_sheet.amount_act_vs_previous_month === "" ? "0" : item.balance_sheet.amount_act_vs_previous_month,
                        item.balance_sheet.percent_act_vs_previous_month === "" ? "0" : item.balance_sheet.percent_act_vs_previous_month,
                        item.balance_sheet.amount_act_vs_mb === "" ? "0" : item.balance_sheet.amount_act_vs_mb,
                        item.balance_sheet.percent_act_vs_mb === "" ? "0" : item.balance_sheet.percent_act_vs_mb,
                        item.balance_sheet.amount_act_vs_rb === "" ? "0" : item.balance_sheet.amount_act_vs_rb,
                        item.balance_sheet.percent_act_vs_rb === "" ? "0" : item.balance_sheet.percent_act_vs_rb,
Deni Rinaldi's avatar
Deni Rinaldi committed
265 266 267
                        item.balance_sheet.mtd_vs_previous_month === null ? "" : item.balance_sheet.mtd_vs_previous_month,
                        item.balance_sheet.mtd_vs_mb === null ? "" : item.balance_sheet.mtd_vs_mb,
                        item.balance_sheet.mtd_vs_rb === null ? "" : item.balance_sheet.mtd_vs_rb,
d.arizona's avatar
d.arizona committed
268
                        item.balance_sheet.actual_formula,
rifkaki's avatar
rifkaki committed
269 270 271
                        item.order,
                        item.condition_it_should_be,
                        item.condition_if_wrong
Deni Rinaldi's avatar
Deni Rinaldi committed
272 273 274 275 276 277 278 279 280
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
d.arizona's avatar
d.arizona committed
281 282 283
                if (err === true) {
                    this.setState({ bebas: true })
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
284
                this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
285
            }
Riri Novita's avatar
Riri Novita committed
286
            console.log(dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
287 288 289
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
290 291
    downloadTemplate = async () => {
        let res = await fetch(
292
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}`
Deni Rinaldi's avatar
Deni Rinaldi committed
293 294 295 296 297 298 299 300 301 302 303 304 305
        )
        res = await res.blob()
        // console.log(res)
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Template Monthly Report Balance Sheet.xlsx';
            a.click();
        }
    }

    async downloadAllData() {
rifkaki's avatar
rifkaki committed
306
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
Deni Rinaldi's avatar
Deni Rinaldi committed
307 308
        console.log(url);
        let res = await fetch(
rifkaki's avatar
rifkaki committed
309
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId === null ? "" : this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
Deni Rinaldi's avatar
Deni Rinaldi committed
310 311 312 313 314 315 316 317 318 319 320 321
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Monthly Report Balance Sheet.xlsx';
            a.click();
        }
    }

d.arizona's avatar
d.arizona committed
322 323 324 325 326 327 328
    handleGetFor(type) {
        this.setState({get_for: type}, () => {
            this.getSettingControl()
            this.getLatestUpdate()
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                // console.log(resp.rows[2]);
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
d.arizona's avatar
d.arizona committed
344
                            orders: i[0] === undefined ? "" : String(i[0]).trim(),
Deni Rinaldi's avatar
Deni Rinaldi committed
345 346
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
rifkaki's avatar
rifkaki committed
347
                            actual: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
Riri Novita's avatar
Riri Novita committed
348 349 350
                            mtd_vs_previous_month: i[4] === undefined ? "" : String(i[4]).trim(),
                            mtd_vs_mb: i[5] === undefined ? "" : String(i[5]).trim(),
                            mtd_vs_rb: i[6] === undefined ? "" : String(i[6]).trim(),
Deni Rinaldi's avatar
Deni Rinaldi committed
351 352 353 354 355 356 357 358
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    balance_sheet: payload,
d.arizona's avatar
d.arizona committed
359 360
                    months: this.props.month.month_id,
                    status: 'submitted'
Deni Rinaldi's avatar
Deni Rinaldi committed
361
                }
d.arizona's avatar
d.arizona committed
362
                console.log(body)
rifkaki's avatar
rifkaki committed
363
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
Deni Rinaldi's avatar
Deni Rinaldi committed
364 365 366 367
            }
        });
    }

d.arizona's avatar
d.arizona committed
368 369 370 371 372 373 374
    checkUpload() {
        api.create().checkUploadMonthlyReportBS(this.state.payload).then(response => {
            // console.log(JSON.stringify(this.state.payload));
            console.log(response)
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, visibleBSMR: false, loading: true })
d.arizona's avatar
d.arizona committed
375
                    let err = false
d.arizona's avatar
d.arizona committed
376
                    let dataTable = response.data.data.map((item, index) => {
d.arizona's avatar
d.arizona committed
377 378 379 380 381
                        if (item.type_report_id === 3) {    
                            if (item.mtd_vs_mb == "" &&  Number(item.percent_act_vs_mb) < this.state.minValue || Number(item.percent_act_vs_mb) > this.state.maxValue) {
                                err = true
                            }
                        }
d.arizona's avatar
d.arizona committed
382 383 384 385 386 387 388 389 390 391 392
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.item_report,
                            item.rolling_outlook === null ? "" : item.rolling_outlook === "" ? "" : item.rolling_outlook,
                            item.master_budget === "" ? "" : item.master_budget,
                            item.rolling_budget === "" ? "" : item.rolling_budget,
                            item.actual === "" ? "" : item.actual,
d.arizona's avatar
d.arizona committed
393 394 395 396 397 398 399 400 401 402 403 404 405
                            item.actual_previous_month === null ? "0.0" : item.actual_previous_month === "" ? "0.0" : item.actual_previous_month,
                            item.amount_act_vs_previous_month === "" ? "0.0" : item.amount_act_vs_previous_month,
                            item.percent_act_vs_previous_month === "" ? "0.0" : item.percent_act_vs_previous_month,
                            item.amount_act_vs_mb === "" ? "0.0" : item.amount_act_vs_mb,
                            item.percent_act_vs_mb === "" ? "0.0" : item.percent_act_vs_mb,
                            item.amount_act_vs_rb === "" ? "0.0" : item.amount_act_vs_rb,
                            item.percent_act_vs_rb === "" ? "0.0" : item.percent_act_vs_rb,
                            // 0,
                            // 0,
                            // 0,
                            // 0,
                            // 0,
                            // 0,
rifkaki's avatar
rifkaki committed
406 407 408
                            item.mtd_vs_previous_month === null ? "" : item.mtd_vs_previous_month === undefined ? "" : item.mtd_vs_previous_month,
                            item.mtd_vs_mb === null ? "" : item.mtd_vs_mb === undefined ? "" : item.mtd_vs_mb,
                            item.mtd_vs_rb === null ? "" : item.mtd_vs_rb === undefined ? "" : item.mtd_vs_rb,
d.arizona's avatar
d.arizona committed
409
                            item.actual_formula,
Deni Rinaldi's avatar
Deni Rinaldi committed
410
                            item.order,
rifkaki's avatar
rifkaki committed
411 412
                            item.condition_it_should_be,
                            item.condition_if_wrong,
d.arizona's avatar
d.arizona committed
413 414 415 416
                            item.error
                        ]
                    })
                    console.log(dataTable)
Deni Rinaldi's avatar
Deni Rinaldi committed
417
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: true, isUpload: true }, () => {
d.arizona's avatar
d.arizona committed
418
                        this.state.dataTable.map(item => {
rifkaki's avatar
rifkaki committed
419
                            if (item[24].length > 0) {
d.arizona's avatar
d.arizona committed
420
                                // console.log('masuk')
Deni Rinaldi's avatar
Deni Rinaldi committed
421
                                this.setState({ buttonError: true, errorPreview: true })
d.arizona's avatar
d.arizona committed
422 423 424 425 426 427 428 429 430 431 432
                            }
                        })
                        // console.log(this.state.buttonError)
                    })
                }
            }
        })
    }

    uploadBalanceSheet(type) {
        let data = []
d.arizona's avatar
d.arizona committed
433
        this.setState({loading: true})
d.arizona's avatar
d.arizona committed
434 435 436
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
d.arizona's avatar
d.arizona committed
437
                item_report: String(i[5]),
d.arizona's avatar
d.arizona committed
438 439 440 441 442 443 444 445 446 447 448
                rolling_outlook: i[0] === 5 || i[0] === 6 ? String(Number(i[6]).toFixed(1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6]).toFixed(1)),
                master_budget: i[0] === 5 || i[0] === 6 ? String(Number(i[7]).toFixed(1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
                rolling_budget: i[0] === 5 || i[0] === 6 ? String(Number(i[8]).toFixed(1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
                actual: i[0] === 5 || i[0] === 6 ? String(Number(i[9]).toFixed(1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
                actual_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[10]).toFixed(1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
                amount_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[11]).toFixed(1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
                percent_act_vs_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[12]).toFixed(1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
                amount_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[13]).toFixed(1)) : i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
                percent_act_vs_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[14]).toFixed(1)) : i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
                amount_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[15]).toFixed(1)) : i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
                percent_act_vs_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[16]).toFixed(1)) : i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)),
Riri Novita's avatar
Riri Novita committed
449 450 451
                mtd_vs_previous_month: String(i[17]),
                mtd_vs_mb: String(i[18]),
                mtd_vs_rb: String(i[19])
d.arizona's avatar
d.arizona committed
452 453 454
            })
        })
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
455
            "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
456 457 458 459 460 461 462
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
Riri Novita's avatar
Riri Novita committed
463
        console.log(body);
d.arizona's avatar
d.arizona committed
464
        console.log(JSON.stringify(body));
rifkaki's avatar
rifkaki committed
465
        console.log(body)
d.arizona's avatar
d.arizona committed
466 467 468 469
        api.create('UPLOAD').uploadMonthlyReportBS(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
470
                    // this.props.onClickClose()
d.arizona's avatar
d.arizona committed
471 472 473 474 475
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('BS')
                    } else {
                        this.props.saveToMonthlyReport()
                    }
d.arizona's avatar
d.arizona committed
476
                    this.setState({loading: false, handleTekTekTek: 0})
d.arizona's avatar
d.arizona committed
477
                    // this.props.getReport()
d.arizona's avatar
d.arizona committed
478
                } else {
Riri Novita's avatar
Riri Novita committed
479
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleTekTekTek: 0 }, () => {
d.arizona's avatar
d.arizona committed
480 481 482 483 484 485 486 487 488
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
Riri Novita's avatar
Riri Novita committed
489
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, handleTekTekTek: 0 })
d.arizona's avatar
d.arizona committed
490 491 492 493
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
494
    backToMonthlyReport(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
495
        this.setState({ loading: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
496 497 498
        let data = []
        this.state.dataTable.map(i => {
            data.push({
Deni Rinaldi's avatar
Deni Rinaldi committed
499
                "item_report_id": i[1],
d.arizona's avatar
d.arizona committed
500 501 502 503 504 505 506 507
                "rolling_outlook": String(Number(i[6]).toFixed(1)),
                "master_budget": String(Number(i[7]).toFixed(1)),
                "rolling_budget": String(Number(i[8]).toFixed(1)),
                "actual": String(Number(i[9]).toFixed(1)),
                "actual_previous_month": String(Number(i[10]).toFixed(1)),
                "amount_act_vs_previous_month": String(Number(i[11]).toFixed(1)),
                "percent_act_vs_previous_month": String(Number(i[12]).toFixed(1)),
                "amount_act_vs_mb": String(Number(i[13]).toFixed(1)),
Deni Rinaldi's avatar
Deni Rinaldi committed
508
                "percent_act_vs_mb": i[14],
d.arizona's avatar
d.arizona committed
509
                "amount_act_vs_rb": String(Number(i[15]).toFixed(1)),
Deni Rinaldi's avatar
Deni Rinaldi committed
510 511 512 513 514 515 516
                "percent_act_vs_rb": i[16],
                "mtd_vs_previous_month": i[17],
                "mtd_vs_mb": i[18],
                "mtd_vs_rb": i[19]
            })
        })
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
517
            "monthly_report_id": this.props.monthlyReportId,
Deni Rinaldi's avatar
Deni Rinaldi committed
518 519 520 521 522 523 524 525
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
        api.create('UPLOAD').createMonthlyReportBS(payload).then(response => {
rifkaki's avatar
rifkaki committed
526
            console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
527
            console.log(response);
d.arizona's avatar
d.arizona committed
528
            console.log(JSON.stringify(payload))
Deni Rinaldi's avatar
Deni Rinaldi committed
529 530
            if (response.data) {
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
531 532 533 534 535
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('BS')
                    } else {
                        this.props.saveToMonthlyReport()
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
536
                } else {
Riri Novita's avatar
Riri Novita committed
537
                    this.setState({ loading: false, handleTekTekTek: 0 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
538 539 540 541
                        this.props.saveToMonthlyReport()
                    })
                }
            } else {
Riri Novita's avatar
Riri Novita committed
542
                this.setState({ loading: false, handleTekTekTek: 0 })
Deni Rinaldi's avatar
Deni Rinaldi committed
543 544 545 546
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
547 548
    handleValidate() {
        let data = []
Deni Rinaldi's avatar
Deni Rinaldi committed
549
        let err = false
d.arizona's avatar
d.arizona committed
550
        let errorContrl = false
rifkaki's avatar
rifkaki committed
551
        let editAble = this.state.editAble
d.arizona's avatar
d.arizona committed
552 553 554 555
        let dataTable = this.state.dataTable
        let kansas = this.state.kansas
        console.log(dataTable[dataTable.length-1])
        dataTable.map((i, index) => {
rifkaki's avatar
rifkaki committed
556 557
            if(i[0] === 3) {
                // console.log(i);
d.arizona's avatar
d.arizona committed
558 559 560 561 562 563
                // if ( i[17] === "" && (Number(i[12]) < this.state.minValue || Number(i[12]) > this.state.maxValue)) {
                //     console.log('msk 1');
                //     // console.log(i);
                //     err = true
                // } else 
                if ( i[18] === "" && (Number(i[14]) < this.state.minValue || Number(i[14]) > this.state.maxValue)) {
d.arizona's avatar
d.arizona committed
564 565
                    console.log('msk 2');
                    err = true
d.arizona's avatar
d.arizona committed
566
                }
d.arizona's avatar
d.arizona committed
567
            }
rifkaki's avatar
rifkaki committed
568 569

            if (String(i[5]) == "Control (should be nil)") {
d.arizona's avatar
d.arizona committed
570 571 572 573
                if (Number(i[9]) < this.state.minValue || Number(i[9]) > this.state.maxValue ) { 
                    errorContrl = true
                    editAble = true
                }
rifkaki's avatar
rifkaki committed
574 575
            }

Deni Rinaldi's avatar
Deni Rinaldi committed
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
            data.push({
                "item_report_id": i[1],
                "rolling_outlook": i[6],
                "master_budget": i[7],
                "rolling_budget": i[8],
                "actual": i[9],
                "actual_previous_month": i[10],
                "amount_act_vs_previous_month": i[11],
                "percent_act_vs_previous_month": i[12],
                "amount_act_vs_mb": i[13],
                "percent_act_vs_mb": i[14],
                "amount_act_vs_rb": i[15],
                "percent_act_vs_rb": i[16],
                "mtd_vs_previous_month": i[17],
                "mtd_vs_mb": i[18],
                "mtd_vs_rb": i[19]
            })
        })
rifkaki's avatar
rifkaki committed
594
        // console.log(JSON.stringify(data));
d.arizona's avatar
d.arizona committed
595 596 597 598 599 600 601 602 603 604 605 606 607
        // data.map(i => {
        //     if (i.mtd_vs_previous_month === "" && (Number(i.percent_act_vs_previous_month) < this.state.minValue || Number(i.percent_act_vs_previous_month) > this.state.maxValue)) {
        //         console.log('msk 1');
        //         console.log(i);
        //         err = true
        //     } else if (i.mtd_vs_mb === "" && (Number(i.percent_act_vs_mb) < this.state.minValue || Number(i.percent_act_vs_mb) > this.state.maxValue)) {
        //         console.log('msk 2');
        //         err = true
        //     } else if (i.mtd_vs_rb === "" && (Number(i.percent_act_vs_rb) < this.state.minValue || Number(i.percent_act_vs_rb) > this.state.maxValue)) {
        //         console.log('msk 3');
        //         err = true
        //     }
        // })
Deni Rinaldi's avatar
Deni Rinaldi committed
608 609 610 611 612 613 614
        // if (err === true) {
        //     console.log('error');
        //     this.setState({ loading: false, buttonError: true, saveDraft: false })
        // } else {
        //     console.log('g error');
        //     this.setState({ loading: false, buttonError: false, saveDraft: false })
        // }
Deni Rinaldi's avatar
Deni Rinaldi committed
615

Deni Rinaldi's avatar
Deni Rinaldi committed
616 617 618 619 620 621 622 623 624 625
        // console.log(JSON.stringify(data))
        let payload = {
            "monthly_report_id": this.props.monthlyReportId,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": "submitted",
            "months": this.props.month.month_id,
            "balance_sheet": data
        }
rifkaki's avatar
rifkaki committed
626
        // console.log(JSON.stringify(payload));
rifkaki's avatar
rifkaki committed
627
        // console.log(this.state.dataTable)
628
        api.create().validateSubmitReportBS(payload).then((response) => {
Riri Novita's avatar
Riri Novita committed
629 630
            console.log(response.data.data.result)
            console.log(err);
rifkaki's avatar
rifkaki committed
631
            console.log(errorContrl);
Deni Rinaldi's avatar
Deni Rinaldi committed
632 633
            if (response.data) {
                if (response.data.status === "success") {
rifkaki's avatar
rifkaki committed
634
                    if (response.data.data.result && err === false && errorContrl === false ) {
Deni Rinaldi's avatar
Deni Rinaldi committed
635
                        this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
d.arizona's avatar
d.arizona committed
636 637 638 639 640 641 642
                        if (kansas == 0) {
                            this.setState({kansas: 1, loading: true}, () => {
                                this.handleValidate()
                            })
                        } else {
                            this.setState({kansas: 0})
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
643
                    } else {
d.arizona's avatar
d.arizona committed
644
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
d.arizona's avatar
d.arizona committed
645 646 647 648 649 650 651
                        if (kansas == 0) {
                            this.setState({kansas: 1, loading: true}, () => {
                                this.handleValidate()
                            })
                        } else {
                            this.setState({kansas: 0})
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
669 670 671 672
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
673
    render() {
Deni Rinaldi's avatar
Deni Rinaldi committed
674
        let dataTable2 = this.state.dataTable
Riri Novita's avatar
Riri Novita committed
675
        const handleText = (value, tableMeta, type) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
676
            dataTable2[tableMeta.rowIndex][type] = value
Riri Novita's avatar
Riri Novita committed
677 678
            // console.log(dataTable2[tableMeta.rowIndex]);
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
679 680 681
        const handleChange = (value, tableMeta, type) => {
            let val = String(value).split(",").join("")
            if (type === "actual") {
Deni Rinaldi's avatar
Deni Rinaldi committed
682
                dataTable2[tableMeta.rowIndex][9] = Number(val).toFixed(1)
d.arizona's avatar
d.arizona committed
683
                console.log(dataTable2);
Deni Rinaldi's avatar
Deni Rinaldi committed
684 685 686 687
            } else {
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
                    // console.log(indexParent)
Deni Rinaldi's avatar
Deni Rinaldi committed
688 689 690
                    dataTable2[tableMeta.rowIndex][9] = Number(val).toFixed(1)
                    let jagain = Number(dataTable2[indexParent][9]).toFixed(1)
                    dataTable2[indexParent][9] = jagain === undefined ? (0 + Number(val)).toFixed(1) : Number(Number(jagain) + Number(val)).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
691 692 693 694 695 696 697
                    // if (tableMeta.rowData[5] === 'Cash & Bank Balance') {
                    //     console.log(value);
                    //     console.log(a);
                    //     console.log(jagain);
                    //     console.log(dataTable2[indexParent]);
                    // }
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
698
                    dataTable2[tableMeta.rowIndex][9] = Number(val).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
699 700
                }
            }
d.arizona's avatar
d.arizona committed
701
            console.log(dataTable2);
Deni Rinaldi's avatar
Deni Rinaldi committed
702 703 704 705 706
        }

        const handleValue = (data, type) => {
            let total = 0
            dataTable2.map((item, index) => {
d.arizona's avatar
d.arizona committed
707
                // if (item[2] !== null) {
Deni Rinaldi's avatar
Deni Rinaldi committed
708 709 710 711 712
                if (data.rowData[1] === item[2]) {
                    // console.log(item[data.columnIndex + type])
                    let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type])
                    total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal
                }
d.arizona's avatar
d.arizona committed
713
                // }
Deni Rinaldi's avatar
Deni Rinaldi committed
714

Deni Rinaldi's avatar
Deni Rinaldi committed
715 716
            })
            let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
Deni Rinaldi's avatar
Deni Rinaldi committed
717
            dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
718
            // console.log(indexParent);
Deni Rinaldi's avatar
Deni Rinaldi committed
719 720 721 722 723 724 725
            return total
        }

        const handleVariance = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[10])
Deni Rinaldi's avatar
Deni Rinaldi committed
726
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
727 728
            } else if (dex === 2) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[7])
Deni Rinaldi's avatar
Deni Rinaldi committed
729
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
730 731
            } else if (dex === 3) {
                total = Number(tableMeta.rowData[9]) - Number(tableMeta.rowData[8])
Deni Rinaldi's avatar
Deni Rinaldi committed
732
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
733 734 735 736 737 738 739 740 741 742 743
            }
            return total
        }

        const handleVariancePercent = (tableMeta, dex, type) => {
            let total = 0
            // if (tableMeta.rowData[5] === "Cash and cash equivalent") {
            //     console.log(dataTable2);
            //     console.log(tableMeta);
            // }
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
744
                total = R.equals(Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])) * 100), NaN) ? '0' : R.equals(Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])) * 100), Infinity) ? '0' : Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])) * 100 == "-Infinity" ? '0' : (Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])) * 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
745
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
746 747 748 749 750
                // if (tableMeta.rowData[5] === "Cash and cash equivalent") {
                // console.log(total);
                // console.log(Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10]));
                //     console.log(dataTable2[tableMeta.rowIndex]);
                // }
Deni Rinaldi's avatar
Deni Rinaldi committed
751
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
752
                total = R.equals(Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])) * 100), NaN) ? '0' : R.equals(Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])) * 100), Infinity) ? '0' : Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])) * 100 == "-Infinity" ? '0' : (Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][7])) * 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
753
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
754
            } else if (dex === 3) {
Deni Rinaldi's avatar
Deni Rinaldi committed
755
                total = R.equals((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])), Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])
Riri Novita's avatar
Riri Novita committed
756
                total = R.equals(Number((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100), NaN) ? '0' : R.equals(Number((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100), Infinity) ? '0' : Number((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100 == "-Infinity" ? '0' : (Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
757
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
758
                // console.log(total);
Deni Rinaldi's avatar
Deni Rinaldi committed
759 760
            }
            return total
Deni Rinaldi's avatar
Deni Rinaldi committed
761 762
        }

d.arizona's avatar
d.arizona committed
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791
        const handleValueFormula = (tableMeta, colIdx) => {
            // loading = true
            let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
            let baru = []
            let anjay = []

            splitFormula.map((item, index) => {
                let items = String(item).substr(Number(String(item).length) - 1, 1)
                let subForm = String(item).substr(0, Number(String(item).length) - 1)
                let re = /^[a-zA-Z0-9_]+$/;
                if (item !== "") {
                    if (items == ']') {
                        baru.push(String(item))
                    } else if (!re.test(items)) {
                        baru.push(subForm)
                        baru.push(items)
                    } else {
                        baru.push(String(item))
                    }
                }
            })

            baru.map((item, index) => {
                if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
                    anjay.push(item)
                } else {
                    if (String(item).includes('#')) {
                        if (String(item).includes('[M-1]')) {
                            let tst = String(item).replace('[M-1]', '')
d.arizona's avatar
d.arizona committed
792
                            // let indexID = dataTable2.findIndex((val) => val[21] == tst)
d.arizona's avatar
d.arizona committed
793
                            let data = tableMeta.rowData[20] == null? [] : tableMeta.rowData[20]
d.arizona's avatar
d.arizona committed
794
                            let indexID = data.findIndex((val) => val.item_formula == String(`${item}`))
d.arizona's avatar
d.arizona committed
795
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
796
                                let valuezz = data[indexID].value
d.arizona's avatar
d.arizona committed
797 798 799
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        } else {
d.arizona's avatar
d.arizona committed
800
                            let data = tableMeta.rowData[20] == null? [] : tableMeta.rowData[20]
d.arizona's avatar
d.arizona committed
801
                            let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
d.arizona's avatar
d.arizona committed
802
                            if (indexID !== -1) {
rifkaki's avatar
rifkaki committed
803
                                // console.log(tableMeta)
d.arizona's avatar
d.arizona committed
804 805 806 807 808 809 810 811 812
                                let valuezz = data[indexID].value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        }
                    } else {
                        if (String(item).includes('[M-1]')) {
                            let tst = String(item).replace('[M-1]', '')
                            let indexID = dataTable2.findIndex((val) => val[21] == tst)
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
813 814 815 816 817 818
                                let valuezz = dataTable2[indexID][10]
                                if (item == dataTable2[tableMeta.rowIndex][21]) {
                                    anjay.push(0)
                                } else {
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
d.arizona's avatar
d.arizona committed
819 820 821 822 823
                            }
                        } else {
                            let indexID = dataTable2.findIndex((val) => val[21] == item)
                            if (indexID !== -1) {
                                let valuezz = dataTable2[indexID][colIdx]
d.arizona's avatar
d.arizona committed
824
                                if (item == dataTable2[tableMeta.rowIndex][21]) {
d.arizona's avatar
d.arizona committed
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 852 853 854 855 856 857 858 859 860 861 862
                                    anjay.push(0)
                                } else {
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                            } else {
                                if (item === '(-1)') {
                                    anjay.push(-1)
                                }
                            }
                        }
                    }
                }
            })

            let anjay2 = []
            let kurung = false
            let item1 = []
            anjay.map((item, index) => {
                if (item == "(") {
                    kurung = true
                } else if (item == ")") {
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
                } else {
                    if (kurung) {
                        item1.push(item)
                    } else {
                        anjay2.push(item)
                    }
                }
            })

            let total = 0
            let opt = ""
            let totalPrio = 0
            let optPrio = ""
            let prio = false
d.arizona's avatar
d.arizona committed
863
            let optPrev = ""
d.arizona's avatar
d.arizona committed
864 865 866
            anjay2.map((item, index) => {
                if (Array.isArray(item)) {
                    prio = true
d.arizona's avatar
d.arizona committed
867
                    optPrev = opt
d.arizona's avatar
d.arizona committed
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
                    item.map((items, indexs) => {
                        if (items == "+") {
                            optPrio = "tambah"
                        } else if (items == "-") {
                            optPrio = "kurang"
                        } else if (items == "*") {
                            optPrio = "kali"
                        } else if (items == "/") {
                            optPrio = "bagi"
                        } else {
                            if (optPrio == "tambah") {
                                totalPrio = Number(totalPrio) + Number(items)
                            } else if (optPrio == "kurang") {
                                totalPrio = Number(totalPrio) - Number(items)
                            } else if (optPrio == "kali") {
                                totalPrio = Number(totalPrio) * Number(items)
                            } else if (optPrio == "bagi") {
                                totalPrio = Number(totalPrio) / Number(items) == NaN ? 0 : Number(totalPrio) / Number(items)
                            } else {
                                totalPrio += Number(items)
                            }
                        }
                    })

                    if (index == anjay2.length - 1) {
                        if (opt == "tambah") {
                            total = Number(total) + Number(totalPrio)
                        } else if (opt == "kurang") {
                            total = Number(total) - Number(totalPrio)
                        } else if (opt == "kali") {
                            total = Number(total) * Number(totalPrio)
                        } else if (opt == "bagi") {
                            total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                        } else {
                            total += Number(totalPrio)
                        }
                    }
                } else {
                    if (item == "+") {
                        opt = "tambah"
                        if (prio) {
d.arizona's avatar
d.arizona committed
909 910 911 912 913 914 915 916 917 918 919
                            if (optPrev == "tambah") {
                                total = Number(total) + Number(totalPrio)
                            } else if (optPrev == "kurang") {
                                total = Number(total) - Number(totalPrio)
                            } else if (optPrev == "kali") {
                                total = Number(total) * Number(totalPrio)
                            } else if (optPrev == "bagi") {
                                total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                            } else {
                                total += Number(totalPrio)
                            }
d.arizona's avatar
d.arizona committed
920 921 922 923 924 925 926
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "-") {
                        opt = "kurang"
                        if (prio) {
d.arizona's avatar
d.arizona committed
927 928 929 930 931 932 933 934 935 936 937
                            if (optPrev == "tambah") {
                                total = Number(total) + Number(totalPrio)
                            } else if (optPrev == "kurang") {
                                total = Number(total) - Number(totalPrio)
                            } else if (optPrev == "kali") {
                                total = Number(total) * Number(totalPrio)
                            } else if (optPrev == "bagi") {
                                total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                            } else {
                                total += Number(totalPrio)
                            }
d.arizona's avatar
d.arizona committed
938 939 940 941 942 943 944
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "*") {
                        opt = "kali"
                        if (prio) {
d.arizona's avatar
d.arizona committed
945 946 947 948 949 950 951 952 953 954 955
                            if (optPrev == "tambah") {
                                total = Number(total) + Number(totalPrio)
                            } else if (optPrev == "kurang") {
                                total = Number(total) - Number(totalPrio)
                            } else if (optPrev == "kali") {
                                total = Number(total) * Number(totalPrio)
                            } else if (optPrev == "bagi") {
                                total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                            } else {
                                total += Number(totalPrio)
                            }
d.arizona's avatar
d.arizona committed
956 957 958 959 960 961 962
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "/") {
                        opt = "bagi"
                        if (prio) {
d.arizona's avatar
d.arizona committed
963 964 965 966 967 968 969 970 971 972 973
                            if (optPrev == "tambah") {
                                total = Number(total) + Number(totalPrio)
                            } else if (optPrev == "kurang") {
                                total = Number(total) - Number(totalPrio)
                            } else if (optPrev == "kali") {
                                total = Number(total) * Number(totalPrio)
                            } else if (optPrev == "bagi") {
                                total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                            } else {
                                total += Number(totalPrio)
                            }
d.arizona's avatar
d.arizona committed
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } 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) == NaN ? 0 : Number(total) / Number(item)
                        } else {
                            total += Number(item)
                        }
                    }
                }
            })

            total = R.equals(total, NaN) ? "0.0" : total
            // // // total = R.equals(total, NaN) ? "0.0" : total
            // // // console.log(dataTable2[tableMeta.rowIndex][22])
            // // // console.log(tableMeta.rowData[5])
            // // if (tableMeta.rowData[5] == "1.5 Other non-current assets") {
            // // if (forecast !== undefined) {
            // //     if (String(tableMeta.rowData[5]) == "Depreciation & amortisation") {
Deni Rinaldi's avatar
Deni Rinaldi committed
1001 1002 1003 1004 1005
            // console.log(splitFormula)
            // console.log(baru)
            // console.log(anjay)
            // console.log(anjay2)
            // console.log(total)
d.arizona's avatar
d.arizona committed
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018
            // //         console.log(dataTable2[tableMeta.rowIndex])
            // //     }
            // // }

            // if (dataTable2[tableMeta.rowIndex][colIdx].value == undefined) {
            dataTable2[tableMeta.rowIndex][colIdx] = total
            // } else {
            //     dataTable2[tableMeta.rowIndex][column].value = total
            // }
            // loading = false
            return total
        }

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

Deni Rinaldi's avatar
Deni Rinaldi committed
2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517
        const loadingComponent = (
            <div style={{ position: 'fixed', 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>
        );

Deni Rinaldi's avatar
Deni Rinaldi committed
2518 2519
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2520
                {this.state.loading && loadingComponent}
Deni Rinaldi's avatar
Deni Rinaldi committed
2521 2522 2523
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
                </div>
Riri Novita's avatar
Riri Novita committed
2524 2525 2526 2527 2528
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
Deni Rinaldi's avatar
Deni Rinaldi committed
2529
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2530
                    {this.state.visibleBSMR ? <Paper style={{ paddingTop: 10 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2531 2532 2533 2534 2535 2536 2537
                        <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                            <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
                        </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>
d.arizona's avatar
d.arizona committed
2538
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2539 2540 2541
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                </div>
                                <div style={{ width: '50%' }}>
d.arizona's avatar
d.arizona committed
2542
                                    {this.props.isApprover === true || this.state.get_for == 'view'?
Deni Rinaldi's avatar
Deni Rinaldi committed
2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613
                                        <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            <a data-tip={'Download'} data-for="download">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() =>
                                                        this.setState({ loading: true }, () => {
                                                            setTimeout(() => {
                                                                this.downloadAllData()
                                                            }, 100);
                                                        })}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                        </div> :
                                        <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            <a data-tip={'Download Template'} data-for="template">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.downloadTemplate()}
                                                >
                                                    <img src={Images.template} />
                                                </button>
                                            </a>
                                            <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                            <a data-tip={'Upload'} data-for="upload">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.setState({ visibleUpload: true })}
                                                >
                                                    <img src={Images.upload} />
                                                </button>
                                            </a>
                                            <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                            <a data-tip={'Download'} data-for="download">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() =>
                                                        this.setState({ loading: true }, () => {
                                                            setTimeout(() => {
                                                                this.downloadAllData()
                                                            }, 100);
                                                        })}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                        </div>
                                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2614 2615 2616 2617
                                </div>
                            </div>

                            <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
rifkaki's avatar
rifkaki committed
2618
                                {!this.state.loading && (
Deni Rinaldi's avatar
Deni Rinaldi committed
2619 2620
                                    <MuiThemeProvider theme={getMuiTheme()}>
                                        <MUIDataTable
d.arizona's avatar
d.arizona committed
2621
                                            data={dataTable2}
Deni Rinaldi's avatar
Deni Rinaldi committed
2622 2623 2624 2625
                                            columns={columns}
                                            options={options}
                                        />
                                    </MuiThemeProvider>
rifkaki's avatar
rifkaki committed
2626
                                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2627
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2628 2629

                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2630
                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Notes : {this.state.notes}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2631 2632 2633

                        </div>
                        {/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
Deni Rinaldi's avatar
Deni Rinaldi committed
2634
                                (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
2635
                        <div className="grid grid-2x" style={{ padding: 20 }}>
Riri Novita's avatar
Riri Novita committed
2636
                            <div className="col-1" style={{ paddingLeft: 0 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647
                                <button
                                    type="button"
                                    onClick={() => this.setState({ loading: true }, () => {
                                        setTimeout(() => {
                                            this.props.onClickClose()
                                        }, 100);
                                    })}
                                    style={{
                                        backgroundColor: 'transparent',
                                        cursor: 'pointer',
                                        borderColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2648
                                        outline: 'none',
Deni Rinaldi's avatar
Deni Rinaldi committed
2649 2650 2651 2652 2653 2654 2655
                                    }}
                                >
                                    <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
                                    </div>
                                </button>
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2656 2657 2658
                            {this.props.isApprover === true ?
                                <div className="col-2">
                                </div> :
Riri Novita's avatar
Riri Novita committed
2659
                                <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
Riri Novita's avatar
Riri Novita committed
2660
                                    {this.state.get_for == 'view' && this.state.viewOnly && <button
d.arizona's avatar
d.arizona committed
2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                        onClick={() => {
                                            this.setState({loading: true}, () => {
                                                this.handleGetFor('edit')
                                            })
                                        }}
                                    >
                                        <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' }}>Edit</Typography>
                                        </div>
                                    </button>}
                                    {this.state.get_for == 'edit' && <button
Deni Rinaldi's avatar
Deni Rinaldi committed
2681 2682 2683 2684 2685 2686 2687 2688 2689 2690
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                        onClick={() => {
d.arizona's avatar
d.arizona committed
2691
                                            this.setState({ loading: true, dataTable: dataTable2 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2692
                                                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2693
                                                    this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
2694 2695 2696 2697 2698 2699 2700
                                                }, 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>
d.arizona's avatar
d.arizona committed
2701 2702
                                    </button>}
                                    {this.state.get_for === 'edit' && <button
Deni Rinaldi's avatar
Deni Rinaldi committed
2703 2704 2705 2706
                                        className="button"
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
rifkaki's avatar
rifkaki committed
2707
                                            cursor: 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2708 2709 2710 2711 2712
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
                                        onClick={() =>
d.arizona's avatar
d.arizona committed
2713 2714 2715
                                            this.state.saveDraft ?
                                                this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' }) 
                                                :
Deni Rinaldi's avatar
Deni Rinaldi committed
2716
                                                this.state.handleTekTekTek == 1 ? null :
rifkaki's avatar
rifkaki committed
2717
                                                    this.setState({ handleTekTekTek: 1, loading: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2718 2719 2720 2721 2722
                                                        this.backToMonthlyReport('draft')
                                                    })
                                        }
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
rifkaki's avatar
rifkaki committed
2723
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2724
                                        </div>
d.arizona's avatar
d.arizona committed
2725 2726
                                    </button>}
                                    {this.state.get_for === 'edit' && <button
Deni Rinaldi's avatar
Deni Rinaldi committed
2727
                                        type="button"
rifkaki's avatar
rifkaki committed
2728
                                        // disabled={this.state.buttonError}
Deni Rinaldi's avatar
Deni Rinaldi committed
2729 2730
                                        onClick={() =>
                                            this.state.buttonError ?
rifkaki's avatar
rifkaki committed
2731
                                                this.setState({ alert: true, messageAlert: 'Data incomplete !', tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
2732 2733 2734 2735 2736 2737 2738
                                                :
                                                this.state.handleTekTekTek == 1 ? null :
                                                    this.setState({ handleTekTekTek: 1 }, () => {
                                                        this.backToMonthlyReport('submitted')
                                                    })}
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2739
                                            cursor: 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2740 2741 2742 2743 2744
                                            borderColor: 'transparent',
                                            outline: 'none',
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
rifkaki's avatar
rifkaki committed
2745
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2746
                                        </div>
d.arizona's avatar
d.arizona committed
2747
                                    </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
2748 2749
                                </div>
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
2750
                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2751 2752
                        {/* : null
                            } */}
Deni Rinaldi's avatar
Deni Rinaldi committed
2753 2754 2755 2756
                    </Paper> :
                        <Paper style={{ paddingTop: 10 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Balance Sheet</Typography>
d.arizona's avatar
d.arizona committed
2757
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2758 2759 2760
                            <div style={{ padding: 20 }}>
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
2761
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2762
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
d.arizona's avatar
d.arizona committed
2763
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2764
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
rifkaki's avatar
rifkaki committed
2765
                                    {this.state.dataLoaded && !this.state.loading && (
Deni Rinaldi's avatar
Deni Rinaldi committed
2766 2767 2768 2769 2770 2771 2772
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
Riri Novita's avatar
Riri Novita committed
2773
                                     )} 
Deni Rinaldi's avatar
Deni Rinaldi committed
2774
                                </div>
d.arizona's avatar
d.arizona committed
2775 2776 2777
                            </div>
                            <div className="grid grid-2x" style={{ marginTop: 10, padding: 20}}>
                                    <div className="col-1" style={{paddingLeft: 0}}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2778 2779
                                        <button
                                            type="button"
d.arizona's avatar
d.arizona committed
2780
                                            onClick={() => this.setState({ loading: true, visibleBSMR: true }, () => {
d.arizona's avatar
d.arizona committed
2781
                                                setTimeout(() => {
Riri Novita's avatar
Riri Novita committed
2782
                                                    this.getItemHierarki()
d.arizona's avatar
d.arizona committed
2783
                                                }, 100);
Deni Rinaldi's avatar
Deni Rinaldi committed
2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796
                                            })}
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none'
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
                                            </div>
                                        </button>
                                    </div>
d.arizona's avatar
d.arizona committed
2797
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
d.arizona's avatar
d.arizona committed
2809
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2810
                                                    setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2811
                                                        this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824
                                                    }, 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',
rifkaki's avatar
rifkaki committed
2825
                                                cursor: 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2826 2827 2828 2829 2830 2831
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
                                                this.state.saveDraft === true ?
rifkaki's avatar
rifkaki committed
2832
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
2833
                                                    :
Deni Rinaldi's avatar
Deni Rinaldi committed
2834 2835 2836 2837 2838 2839 2840
                                                    this.state.handleTekTekTek == 1 ? null :
                                                        this.setState({ handleTekTekTek: 1 }, () => {
                                                            this.uploadBalanceSheet('draft')
                                                        })
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
2841
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2842 2843 2844 2845
                                            </div>
                                        </button>
                                        <button
                                            type="button"
rifkaki's avatar
rifkaki committed
2846
                                            // disabled={this.state.buttonError}
Deni Rinaldi's avatar
Deni Rinaldi committed
2847 2848
                                            onClick={() =>
                                                this.state.buttonError ?
rifkaki's avatar
rifkaki committed
2849
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
2850 2851 2852 2853 2854 2855 2856
                                                    :
                                                    this.state.handleTekTekTek == 1 ? null :
                                                        this.setState({ handleTekTekTek: 1 }, () => {
                                                            this.uploadBalanceSheet('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
rifkaki's avatar
rifkaki committed
2857
                                                cursor: 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2858 2859 2860 2861 2862
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
2863
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2864 2865 2866
                                            </div>
                                        </button>
                                    </div>
d.arizona's avatar
d.arizona committed
2867
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2868
                        </Paper>
d.arizona's avatar
d.arizona committed
2869
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
2870
                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899
                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                    </div>
                                </div>
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
                                acceptedFiles={["xlsx"]}
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
                                onUpload={() => {
rifkaki's avatar
rifkaki committed
2900
                                    String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") && String(this.state.judul).includes("BALANCE") && String(this.state.judul).includes("SHEET") ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2901 2902 2903 2904 2905 2906 2907
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2908 2909 2910 2911
            </div>
        )
    }
}