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

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

Riri Novita's avatar
Riri Novita committed
24 25 26 27 28 29 30 31 32
const LightTooltipError = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(255, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);

Deni Rinaldi's avatar
Deni Rinaldi committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
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 OperatingIndicatorMR extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
Deni Rinaldi's avatar
Deni Rinaldi committed
56
            loading: true,
Riri Novita's avatar
Riri Novita committed
57
            visibleOI: true,
Riri Novita's avatar
Riri Novita committed
58
            minValue: 0,
Riri Novita's avatar
Riri Novita committed
59
            maxValue: 0,
Riri Novita's avatar
Riri Novita committed
60
            updateBy: [],
Riri Novita's avatar
Riri Novita committed
61
            notesUpdate: '-',
Riri Novita's avatar
Riri Novita committed
62 63 64
            disabledSave: true,
            editable: true,
            emptyData: false,
d.arizona's avatar
d.arizona committed
65
            templateNull: true,
Riri Novita's avatar
Riri Novita committed
66
            judulColumn: null,
Riri Novita's avatar
Riri Novita committed
67
            saveDraft: true,
Riri Novita's avatar
Riri Novita committed
68
            viewOnly : true,
d.arizona's avatar
d.arizona committed
69
            get_for: 'view'
Deni Rinaldi's avatar
Deni Rinaldi committed
70
        }
Riri Novita's avatar
Riri Novita committed
71 72 73 74 75 76
        this.fileHandler = this.fileHandler.bind(this);
    }

    componentDidMount() {
        // this.getItemHierarki()
        this.getSettingControl()
Riri Novita's avatar
Riri Novita committed
77
        this.handleViewOnly()
Riri Novita's avatar
Riri Novita committed
78
        // this.getLatestUpdate()
Deni Rinaldi's avatar
Deni Rinaldi committed
79 80
    }

Riri Novita's avatar
Riri Novita committed
81
    handleViewOnly() {
Riri Novita's avatar
Riri Novita committed
82 83
        let checkCreate = this.props.permission.create
        let checkEdit = this.props.permission.edit
Riri Novita's avatar
Riri Novita committed
84
        let checkStatus = true
Riri Novita's avatar
Riri Novita committed
85

Riri Novita's avatar
Riri Novita committed
86 87 88 89 90
        if (String(this.props.data.status).toLocaleUpperCase() === 'CLOSED') {
            checkStatus = false
        }

        this.setState({viewOnly: checkCreate && checkEdit && checkStatus})
Riri Novita's avatar
Riri Novita committed
91 92
    }

d.arizona's avatar
d.arizona committed
93 94 95
    handleGetFor(type) {
        this.setState({get_for: type}, () => {
            this.getSettingControl()
Riri Novita's avatar
Riri Novita committed
96
            // this.getLatestUpdate()
d.arizona's avatar
d.arizona committed
97 98 99
        })
    }

Riri Novita's avatar
Riri Novita committed
100 101
    getLatestUpdate() {
        let payload = {
Riri Novita's avatar
Riri Novita committed
102
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
103 104 105
            "report_id": this.props.data.report_id,
            "company_id": this.props.data.company.company_id,
            "periode": this.props.data.periode,
Riri Novita's avatar
Riri Novita committed
106
            "months": this.props.months
Riri Novita's avatar
Riri Novita committed
107
        }
Riri Novita's avatar
Riri Novita committed
108
        // console.log(payload);
Riri Novita's avatar
Riri Novita committed
109
        api.create().getLastestUpdateMROI(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
110
            // console.log(response.data)
Riri Novita's avatar
Riri Novita committed
111 112 113
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
114
                        updateBy: response.data.data.detail === null ? [] : response.data.data.detail,
Riri Novita's avatar
Riri Novita committed
115
                        notesUpdate: response.data.data.notes_update === null ? '-' : response.data.data.notes_update
Riri Novita's avatar
Riri Novita committed
116
                    })
Riri Novita's avatar
Riri Novita committed
117 118
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
119
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
120 121 122 123 124 125
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Riri Novita's avatar
Riri Novita committed
126
                }
Riri Novita's avatar
Riri Novita committed
127 128
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
Riri Novita's avatar
Riri Novita committed
129 130 131 132
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
133 134 135 136 137 138 139 140
    getSettingControl() {
        let body = {
            group: 'THRESHOLD_VARIANCE',
            company_id: this.props.company.company_id,
            type: 'BALANCE_SHEET'
        }

        api.create().getAllSettingByType(body).then(response => {
Riri Novita's avatar
Riri Novita committed
141
            console.log(response);
Riri Novita's avatar
Riri Novita committed
142 143 144
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
145 146
                        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,
Riri Novita's avatar
Riri Novita committed
147
                    }, () => {
Riri Novita's avatar
Riri Novita committed
148
                        this.getOperatingIDMonthly()
Riri Novita's avatar
Riri Novita committed
149 150 151
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
152
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
153 154 155 156 157 158 159 160 161 162 163
                            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
164 165
    }

Riri Novita's avatar
Riri Novita committed
166
    getOperatingIDMonthly() {
Riri Novita's avatar
Riri Novita committed
167
        // console.log(this.props.data.operatingIndID);
Riri Novita's avatar
Riri Novita committed
168 169
        let payload = {
            "company_id": this.props.data.company.company_id,
Riri Novita's avatar
Riri Novita committed
170
            "periode": this.props.data.periode,
Riri Novita's avatar
Riri Novita committed
171
            "months": this.props.months
Riri Novita's avatar
Riri Novita committed
172
        }
Riri Novita's avatar
Riri Novita committed
173
        console.log(payload);
Riri Novita's avatar
Riri Novita committed
174
        api.create().getMonthlyOI(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
175
            console.log(response);
Riri Novita's avatar
Riri Novita committed
176 177 178 179
            if (response) {
                if (response.data.data) {
                    this.setState({ operatingIndIDMonthly: response.data.data.operating_indicator_id } , () => {
                        this.getItemHierarki()
Riri Novita's avatar
Riri Novita committed
180
                        this.getLatestUpdate()
Riri Novita's avatar
Riri Novita committed
181 182 183 184
                    })
                } else {
                    this.setState({ operatingIndIDMonthly: null }, () => {
                        this.getItemHierarki()
Riri Novita's avatar
Riri Novita committed
185
                        this.getLatestUpdate()
Riri Novita's avatar
Riri Novita committed
186 187
                    })
                }
Riri Novita's avatar
Riri Novita committed
188 189
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
190
                    if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
191 192 193 194 195 196
                        setTimeout(() => {
                            localStorage.removeItem(Constant.TOKEN)
                            window.location.reload();
                        }, 1000);
                    }
                })
Riri Novita's avatar
Riri Novita committed
197 198 199 200
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
201
    getItemHierarki() {
Riri Novita's avatar
Riri Novita committed
202
        this.setState({ loading: true })
Riri Novita's avatar
Riri Novita committed
203
        let payload = {
Riri Novita's avatar
Riri Novita committed
204
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
205 206 207
            "report_id": this.props.data.report_id,
            "company_id": this.props.data.company.company_id,
            "periode": this.props.data.periode,
Riri Novita's avatar
Riri Novita committed
208
            "months": this.props.months,
d.arizona's avatar
d.arizona committed
209
            "get_for": this.state.get_for 
Deni Rinaldi's avatar
Deni Rinaldi committed
210
        }
Riri Novita's avatar
Riri Novita committed
211
        console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
212
        api.create().getHierarkiMontlyReportOI(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
213
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
214
            let dataTable = []
Riri Novita's avatar
Riri Novita committed
215 216
            let err = false

Deni Rinaldi's avatar
Deni Rinaldi committed
217 218 219 220
            if (response.data) {
                let res = response.data.data
                const handlePushChild = (item) => {
                    let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
Riri Novita's avatar
Riri Novita committed
221 222 223 224 225 226 227 228 229 230
                    if (item.type_report_id === 3) {

                        if (item.monthly_report.mtd_vs_mb === "" && (Number(item.monthly_report.percent_act_vs_mb) < this.state.minValue || Number(item.monthly_report.percent_act_vs_mb) > this.state.maxValue)) {
                            err = true
                        } 
                        if (item.monthly_report.mtd_vs_rb === "" && (Number(item.monthly_report.percent_act_vs_rb) < this.state.minValue || Number(item.monthly_report.percent_act_vs_rb) > this.state.maxValue)) {
                            console.log('msk 2');
                            err = true
                        }
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
231 232 233 234 235 236 237 238
                    if (indexIDzz === -1) {
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.description,
Riri Novita's avatar
Riri Novita committed
239
                            item.uom  === "" ? null : item.uom,
Riri Novita's avatar
Riri Novita committed
240
                            item.monthly_report.rolling_outlook === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_outlook,
Riri Novita's avatar
Riri Novita committed
241
                            item.monthly_report.master_budget === null ? "0.0" : item.monthly_report.master_budget === "" ? "0.0" : item.monthly_report.master_budget,
Riri Novita's avatar
Riri Novita committed
242 243 244 245 246 247
                            item.monthly_report.rolling_budget === null ? "0.0" : item.monthly_report.rolling_budget === "" ? "0.0" : item.monthly_report.rolling_budget,
                            item.monthly_report.actual === null ? "0.0" : item.monthly_report.actual === "" ? "0.0" : item.monthly_report.actual,
                            item.monthly_report.amount_act_vs_mb === null ? "0.0" : item.monthly_report.amount_act_vs_mb === "" ? "0.0" : item.monthly_report.amount_act_vs_mb,
                            item.monthly_report.percent_act_vs_mb === null ? "0.0" : item.monthly_report.percent_act_vs_mb === "" ? "0.0" : item.monthly_report.percent_act_vs_mb,
                            item.monthly_report.amount_act_vs_rb === null ? "0.0" : item.monthly_report.amount_act_vs_rb === "" ? "0.0" : item.monthly_report.amount_act_vs_rb,
                            item.monthly_report.percent_act_vs_rb === null ? "0.0" : item.monthly_report.percent_act_vs_rb === "" ? "0.0" : item.monthly_report.percent_act_vs_rb,
Riri Novita's avatar
Riri Novita committed
248 249
                            item.monthly_report.mtd_vs_mb === null ? "" : item.monthly_report.mtd_vs_mb,
                            item.monthly_report.mtd_vs_rb === null ? "" : item.monthly_report.mtd_vs_rb,
Riri Novita's avatar
Riri Novita committed
250
                            item.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
251 252 253 254 255 256 257 258 259 260 261
                        ])
                    }
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                }
                res.map((item, index) => {
Riri Novita's avatar
Riri Novita committed
262 263 264 265 266 267 268 269 270 271
                    if (item.type_report_id === 3) {

                        if (item.monthly_report.mtd_vs_mb === "" && (Number(item.monthly_report.percent_act_vs_mb) < this.state.minValue || Number(item.monthly_report.percent_act_vs_mb) > this.state.maxValue)) {
                            err = true
                        } 
                        if (item.monthly_report.mtd_vs_rb === "" && (Number(item.monthly_report.percent_act_vs_rb) < this.state.minValue || Number(item.monthly_report.percent_act_vs_rb) > this.state.maxValue)) {
                            console.log('msk 2');
                            err = true
                        }
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
272 273 274 275 276 277 278
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
Riri Novita's avatar
Riri Novita committed
279
                        item.uom  === "" ? null : item.uom,
Riri Novita's avatar
Riri Novita committed
280
                        item.monthly_report.rolling_outlook === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_outlook,
Riri Novita's avatar
Riri Novita committed
281
                        item.monthly_report.master_budget === null ? "0.0" : item.monthly_report.master_budget === "" ? "0.0" : item.monthly_report.master_budget,
Riri Novita's avatar
Riri Novita committed
282 283 284 285 286 287
                        item.monthly_report.rolling_budget === null ? "0.0" : item.monthly_report.rolling_budget === "" ? "0.0" : item.monthly_report.rolling_budget,
                        item.monthly_report.actual === null ? "0.0" : item.monthly_report.actual === "" ? "0.0" : item.monthly_report.actual,
                        item.monthly_report.amount_act_vs_mb === null ? "0.0" : item.monthly_report.amount_act_vs_mb === "" ? "0.0" : item.monthly_report.amount_act_vs_mb,
                        item.monthly_report.percent_act_vs_mb === null ? "0.0" : item.monthly_report.percent_act_vs_mb === "" ? "0.0" : item.monthly_report.percent_act_vs_mb,
                        item.monthly_report.amount_act_vs_rb === null ? "0.0" : item.monthly_report.amount_act_vs_rb === "" ? "0.0" : item.monthly_report.amount_act_vs_rb,
                        item.monthly_report.percent_act_vs_rb === null ? "0.0" : item.monthly_report.percent_act_vs_rb === "" ? "0.0" : item.monthly_report.percent_act_vs_rb,
Riri Novita's avatar
Riri Novita committed
288 289
                        item.monthly_report.mtd_vs_mb === null ? "" : item.monthly_report.mtd_vs_mb,
                        item.monthly_report.mtd_vs_rb === null ? "" : item.monthly_report.mtd_vs_rb,
Riri Novita's avatar
Riri Novita committed
290
                        item.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
291 292 293 294 295 296 297 298 299
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
Riri Novita's avatar
Riri Novita committed
300 301 302 303
                if (err === true) {
                    this.setState({ bebas: true })
                }
                this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true }, () => {
Riri Novita's avatar
Riri Novita committed
304 305 306 307
                    if (this.state.dataTable.length == 0) {
                        this.setState({ emptyData: true })
                    }
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
308
            }
Riri Novita's avatar
Riri Novita committed
309
            console.log(dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
310 311
        })
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
312

Riri Novita's avatar
Riri Novita committed
313 314
    downloadTemplate = async () => {
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
315
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/monthly_report/download_template?report_id=${this.props.data.report_id}&&company_id=${this.props.data.company.company_id}&&year=${this.props.data.periode}`
Riri Novita's avatar
Riri Novita committed
316 317
        )
        res = await res.blob()
Riri Novita's avatar
Riri Novita committed
318
        // // console.log(res)
Riri Novita's avatar
Riri Novita committed
319 320 321 322 323 324 325 326 327 328
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Template Monthly Report Operating Indicator.xlsx';
            a.click();
        }
    }

    async downloadAllData() {
Riri Novita's avatar
Riri Novita committed
329
        // console.log(this.props.months);
Riri Novita's avatar
Riri Novita committed
330
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/monthly_report/export_monthly_report?operating_indicator_id=${this.props.data.operatingIndID == null ? "" : this.props.data.operatingIndID}&&report_id=${this.props.data.report_id}&&company_id=${this.props.data.company.company_id}&&year=${this.props.data.periode}&&months=${this.props.months}`
Riri Novita's avatar
Riri Novita committed
331 332
        console.log(url);
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
333
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/monthly_report/export_monthly_report?operating_indicator_id=${this.props.data.operatingIndID === null ? "" : this.props.data.operatingIndID}&&report_id=${this.props.data.report_id}&&company_id=${this.props.data.company.company_id}&&year=${this.props.data.periode}&&months=${this.props.months}`
Riri Novita's avatar
Riri Novita committed
334 335 336 337 338 339 340 341 342 343 344 345
        )
        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 Operating Indicator.xlsx';
            a.click();
        }
    }

Riri Novita's avatar
Riri Novita committed
346
    createData(type) {
Riri Novita's avatar
Riri Novita committed
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                "item_report_id": i[1],
                "uom": i[6],
                "rolling_outlook": i[7],
                "master_budget": i[8],
                "rolling_budget": i[9],
                "actual": i[10],
                "amount_act_vs_mb": i[11],
                "percent_act_vs_mb": i[12],
                "amount_act_vs_rb": i[13],
                "percent_act_vs_rb": i[14],
                "mtd_vs_mb": i[15],
                "mtd_vs_rb": i[16]
            })
        })
        let payload = {
Riri Novita's avatar
Riri Novita committed
365
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
366 367 368
            "report_id": this.props.data.report_id,
            "company_id": this.props.data.company.company_id,
            "periode": this.props.data.periode,
Riri Novita's avatar
Riri Novita committed
369
            "status": type,
Riri Novita's avatar
Riri Novita committed
370
            "months": this.props.months,
Riri Novita's avatar
Riri Novita committed
371
            "monthly_report": data
Riri Novita's avatar
Riri Novita committed
372
        }
Riri Novita's avatar
Riri Novita committed
373 374
        console.log(payload);
        // // console.log('=========================')
Riri Novita's avatar
Riri Novita committed
375
        console.log(JSON.stringify(payload))
Riri Novita's avatar
Riri Novita committed
376 377
        this.props.saveMonthlyOI(payload)
        this.props.onClickClose()
Riri Novita's avatar
Riri Novita committed
378 379
    }

Riri Novita's avatar
Riri Novita committed
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            console.log(resp)
            if (err) {
                // // console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                // // console.log(isi);
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
                            order: i[0] === undefined ? "" : String(i[0]).trim(),
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
                            uom: i[3] === undefined ? "" : String(i[3]).trim(),
                            actual: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
Riri Novita's avatar
Riri Novita committed
400 401
                            mtd_vs_mb: i[5] === undefined ? "" : String(i[5]).trim(),
                            mtd_vs_rb: i[6] === undefined ? "" : String(i[6]).trim(),
Riri Novita's avatar
Riri Novita committed
402 403 404 405 406 407 408
                        })
                    }
                })
                let body = {
                    company_id: this.props.data.company.company_id,
                    periode: this.props.data.periode,
                    report_id: this.props.data.report_id,
Riri Novita's avatar
Riri Novita committed
409
                    months: this.props.months,
Riri Novita's avatar
Riri Novita committed
410
                    status: 'submitted',
Riri Novita's avatar
Riri Novita committed
411 412 413
                    monthly_report: payload
                }
                console.log(body)
Riri Novita's avatar
Riri Novita committed
414
                console.log(JSON.stringify(body));
Riri Novita's avatar
Riri Novita committed
415
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
Riri Novita's avatar
Riri Novita committed
416 417 418 419 420 421 422 423 424 425 426 427
            }
        });
    }

    checkUpload() {
        api.create().checkUploadMonthlyReportOI(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, visibleOI: false, loading: true })
                    let total = 0
Riri Novita's avatar
Riri Novita committed
428
                    let err = false
Riri Novita's avatar
Riri Novita committed
429 430
                    let dataTable = response.data.data.map((item, index) => {
                        console.log(item);
Riri Novita's avatar
Riri Novita committed
431 432 433
                        if (item.type_report_id != null) {
                            total += 1
                        }
Riri Novita's avatar
Riri Novita committed
434 435 436 437 438 439 440 441 442 443
                        // 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
                        //     } 
                        //     if (item.mtd_vs_rb === "" && (Number(item.percent_act_vs_rb) < this.state.minValue || Number(item.percent_act_vs_rb) > this.state.maxValue)) {
                        //         console.log('msk 2');
                        //         err = true
                        //     }
                        // }
Riri Novita's avatar
Riri Novita committed
444 445 446 447 448 449 450 451 452 453 454 455
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.item_report,
                            item.uom,
                            item.rolling_outlook,
                            item.master_budget,
                            item.rolling_budget,
                            item.actual,
Riri Novita's avatar
Riri Novita committed
456 457 458 459 460 461 462 463
                            // 0,
                            // 0,
                            // 0,
                            // 0,
                            item.amount_act_vs_mb,
                            item.percent_act_vs_mb,
                            item.amount_act_vs_rb,
                            item.percent_act_vs_rb,
Riri Novita's avatar
Riri Novita committed
464 465 466 467 468
                            item.mtd_vs_mb,
                            item.mtd_vs_rb,
                            item.order,
                            item.error
                        ]
Riri Novita's avatar
Riri Novita committed
469
                    })
Riri Novita's avatar
Riri Novita committed
470
                    console.log(dataTable);
Riri Novita's avatar
Riri Novita committed
471
                    this.setState({ dataTable, dataLoaded: true, loading: false,  buttonError: false, templateNull : total > 0 ? true : false })
Riri Novita's avatar
Riri Novita committed
472 473
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
474
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
475 476 477 478 479 480
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Riri Novita's avatar
Riri Novita committed
481 482 483 484 485 486 487
                }
            }
        })
    }

    uploadOI(type) {
        let data = []
Riri Novita's avatar
Riri Novita committed
488
        // console.log(this.state.dataTable)
Riri Novita's avatar
Riri Novita committed
489 490 491 492 493 494 495 496 497 498 499 500
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
                uom: String(i[6]),
                rolling_outlook: String(Number(i[7]).toFixed(1)),
                master_budget: String(Number(i[8]).toFixed(1)),
                rolling_budget: String(Number(i[9]).toFixed(1)),
                actual: String(Number(i[10]).toFixed(1)),
                amount_act_vs_mb: String(Number(i[11]).toFixed(1)),
                percent_act_vs_mb: String(Number(i[12]).toFixed(1)),
                amount_act_vs_rb: String(Number(i[13]).toFixed(1)),
                percent_act_vs_rb: String(Number(i[14]).toFixed(1)),
Riri Novita's avatar
Riri Novita committed
501 502
                mtd_vs_mb: String(i[15]),
                mtd_vs_rb: String(i[16]),
Riri Novita's avatar
Riri Novita committed
503 504 505 506
            })
        })
        let body = {
            company_id: this.props.data.company.company_id,
Riri Novita's avatar
Riri Novita committed
507
            operating_indicator_id: this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
508 509 510
            periode: this.props.data.periode,
            report_id: this.props.data.report_id,
            status: type,
Riri Novita's avatar
Riri Novita committed
511
            months: this.props.months,
Riri Novita's avatar
Riri Novita committed
512 513
            monthly_report: data
        }
Riri Novita's avatar
Riri Novita committed
514 515
        // console.log(body);
        // console.log(JSON.stringify(body))
Riri Novita's avatar
Riri Novita committed
516 517 518 519 520 521 522 523
        api.create('UPLOAD').uploadMonthlyReportOI(body).then(response => {
            // // console.log(response);
            this.setState({ loading: false })
            if (response.data) {
                if (response.data.status === "success") {
                    this.props.onClickClose()
                    this.props.getReport()
                } else {
Riri Novita's avatar
Riri Novita committed
524
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
525
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
526 527 528 529 530 531
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Riri Novita's avatar
Riri Novita committed
532
                }
Riri Novita's avatar
Riri Novita committed
533 534
            } else {
                alert(response.problem)
Riri Novita's avatar
Riri Novita committed
535 536 537 538
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
539 540 541 542
    handleValidate() {
        let data = []
        let err = false
        this.state.dataTable.map((i, index) => {
Riri Novita's avatar
Riri Novita committed
543 544 545 546 547 548 549 550 551
            if (i[0] === 3) {
                if (i[15] === "" && (Number(i[12]) < this.state.minValue || Number(i[12]) > this.state.maxValue)) {
                    console.log('msk 1');
                    err = true
                } else if (i[16] === "" && (Number(i[14]) < this.state.minValue || Number(i[14]) > this.state.maxValue)) {
                    console.log('msk 2');
                    err = true
                }
            }
Riri Novita's avatar
Riri Novita committed
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
            data.push({
                    "item_report_id": i[1],
                    "uom": i[6],
                    "rolling_outlook": i[7],
                    "master_budget": i[8],
                    "rolling_budget": i[9],
                    "actual": i[10],
                    "amount_act_vs_mb": i[11],
                    "percent_act_vs_mb": i[12],
                    "amount_act_vs_rb": i[13],
                    "percent_act_vs_rb": i[14],
                    "mtd_vs_mb": i[15],
                    "mtd_vs_rb": i[16]
            })
        })

        // console.log(JSON.stringify(data))
        let payload = {
Riri Novita's avatar
Riri Novita committed
570
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
571 572 573 574
            "report_id": this.props.data.report_id,
            "company_id": this.props.data.company.company_id,
            "periode": this.props.data.periode,
            "status": "submitted",
Riri Novita's avatar
Riri Novita committed
575
            "months": this.props.months,
Riri Novita's avatar
Riri Novita committed
576 577 578 579 580 581 582 583 584 585 586 587 588 589
            "monthly_report": data
        }
        // console.log(JSON.stringify(payload));
        api.create().validateSubmitReportOI(payload).then((response) => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    if (response.data.data.result && err === false) {
                        this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
                    } else {
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
590
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
591 592 593 594 595 596 597 598 599 600 601 602 603
                            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
604 605 606 607
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
608
    render() {
Riri Novita's avatar
Riri Novita committed
609
        let dataTable2 = this.state.dataTable
Riri Novita's avatar
Riri Novita committed
610 611 612 613 614

        const handleText = (value, tableMeta, type) => {
            let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = value
        }

Riri Novita's avatar
Riri Novita committed
615 616 617 618 619 620 621 622 623
        const handleValue = (data, type) => {
            let total = 0
            dataTable2.map((item, index) => {
                if (data.rowData[1] === item[2]) {
                    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
                }
            })
            let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
Deni Rinaldi's avatar
Deni Rinaldi committed
624
            dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
625 626 627 628 629 630 631 632
            // console.log(indexParent);
            return total
        }

        const handleChange = (value, tableMeta, type) => {
            console.log(dataTable2);
            let val = String(value).split(",").join("")
            if (type === "actual") {
Deni Rinaldi's avatar
Deni Rinaldi committed
633
                dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
Riri Novita's avatar
Riri Novita committed
634 635 636
            } else {
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
637 638 639
                    dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
                    let jagain = Number(dataTable2[indexParent][10]).toFixed(1)
                    dataTable2[indexParent][10] = jagain === undefined ? (0 + Number(val)).toFixed(1) : Number(Number(jagain) + Number(val)).toFixed(1)
Riri Novita's avatar
Riri Novita committed
640 641
                    
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
642
                    dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
Riri Novita's avatar
Riri Novita committed
643 644 645 646 647 648 649
                }
            }
        }

        const handleVariance = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
650
                total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[8]).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
651
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
652
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
653
                total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[9]).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
654
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
655 656 657 658 659 660 661
            } 
            return total
        }

        const handleVariancePercent = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
662
                total = R.equals(Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100), NaN) ? '0' : R.equals(Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100), Infinity) ? '0' : Number((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100 == "-Infinity" ? '0' : (Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][8])) * 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
663
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
664
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
665
                total = R.equals(Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][9])) * 100), NaN) ? '0' : R.equals(Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][9]))* 100), Infinity) ? '0' : Number((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][9])) * 100 == "-Infinity" ? '0' : (Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][9])) * 100)
Deni Rinaldi's avatar
Deni Rinaldi committed
666
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
667 668 669 670
            } 
            return total
        }

Riri Novita's avatar
Riri Novita committed
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
        const handleFormula = (data, tableMeta, type) => {
            let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
            let arrayJumlah = []
            let tambahan = false
            let opet = ""

            arrayFormula.map((item, indexs) => {
                if (item == 'X') {
                    tambahan = true 
                } else if (item == '-' || item == '+' || item == '/' || item == '*') {
                    arrayJumlah.push(item)
                } else {
                    let index = dataTable2.findIndex((val) => val[17] == item)
                    if (tambahan) {
                        if (item == '-' || item == '+' || item == '/' || item == '*') {
                            opet = item
                        } else {
                            arrayJumlah.push(opet == '' ? Number(item) : Number(String(opet + String(item))))
                            tambahan = false
                            opet = ""
                        }
                    } else {
                        if (index != -1) {
                            arrayJumlah.push(dataTable2[index][tableMeta.columnIndex + type])
                        }
                    }
                }
            })

            let array = arrayJumlah
            let total = 0
            let opt = ""

            array.map((item, index) => {
                if (item == "+") {
                    opt = "tambah"
                } else if (item == "-") {
                    opt = "kurang"
                } else if (item == "*") {
                    opt = "kali"
                } else if (item == "/") {
                    opt = "bagi"
                } else {
                    if (opt == "tambah") {
                        total = Number(total) + Number(item)
                    } else if (opt == "kurang") {
                        total = Number(total) - Number(item)
                    } else if (opt == "kali") {
                        total = Number(total) * Number(item)
                        // if (tableMeta.rowData[22] === 3) {
                        //     console.log(dataTable2[tableMeta.rowIndex]);
                        //     console.log(total);
                        //     console.log(item);
                        //     console.log(arrayJumlah);
                        // }
                    } else if (opt == "bagi") {
                        total = R.equals((Number(total) / Number(item)), NaN) ? '0' : Number(total) / Number(item)
                    } else {
                        total += Number(item)
                    }
                }
            })

            let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total)
d.arizona's avatar
d.arizona committed
735
            console.log(tableMeta.columnIndex + type)
Riri Novita's avatar
Riri Novita committed
736 737 738 739
            return a

        }

Deni Rinaldi's avatar
Deni Rinaldi committed
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804
        let columns = [
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                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 }}>
                                {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>
                                }
                            </div>
                        )
                    }
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
805 806 807 808 809 810 811 812 813 814 815 816
            }, {
                name: "UOM",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#07a7d0', width: 96, borderLeft: '1px #fff solid', borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
817
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
818
                                    null :
Riri Novita's avatar
Riri Novita committed
819
                                    this.state.get_for == 'view' ? val :
Riri Novita's avatar
Riri Novita committed
820 821 822 823 824 825 826
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                        style={{ margin: 0 }}
                                        // value={val}
                                        control={
                                            <Input
                                                disableUnderline={true}
Riri Novita's avatar
Riri Novita committed
827
                                                style={{ color: "#000", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Riri Novita's avatar
Riri Novita committed
828 829 830
                                                type="text"
                                                placeholder=""
                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
831
                                                defaultValue={val}
Riri Novita's avatar
Riri Novita committed
832 833 834 835 836 837 838 839 840
                                                // onBlur={(event) => {
                                                //     // updateValue(event.target.value)
                                                //     handleNotes(event.target.value, tableMeta)
                                                //     // console.log(dataTable2)
                                                // }}
                                            />
                                        }
                                    />
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
841 842 843 844 845 846
                                }
                            </div>
                        )
                    }
                }
            }, {
rifkaki's avatar
rifkaki committed
847
                name: `Rolling Outlook (FY${this.props.data.periode})`,
Deni Rinaldi's avatar
Deni Rinaldi committed
848 849 850 851 852 853 854 855 856 857
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#07a7d0', width: 96, borderLeft: '1px #fff solid', borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
858
                                {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
859
                                    null :
Riri Novita's avatar
Riri Novita committed
860 861 862 863 864 865 866
                                    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}
Riri Novita's avatar
Riri Novita committed
867
                                            decimalScale={1}
Riri Novita's avatar
Riri Novita committed
868 869 870
                                            value={Number(val).toFixed(1)}
                                        />
                                    :
Riri Novita's avatar
Riri Novita committed
871 872 873 874 875 876 877 878
                                    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}
Riri Novita's avatar
Riri Novita committed
879
                                            decimalScale={1}
Deni Rinaldi's avatar
Deni Rinaldi committed
880
                                            value={Number(handleValue(tableMeta, 0)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
881 882
                                        />
                                    </span> :
d.arizona's avatar
d.arizona committed
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
                                    // tableMeta.rowData[0] === 6 ?
                                    // <div style={{ flex: 1 }}>
                                    //     <FormControlLabel
                                    //         style={{ margin: 0 }}
                                    //         value={tableMeta.rowData[7]}
                                    //         decimalScale={1}
                                    //         control={
                                    //             <NumberFormat
                                    //                 thousandSeparator={true}
                                    //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                    //                 type="text"
                                    //                 placeholder=""
                                    //                 disabled={true}
                                    //                 value={Number(handleFormula(val, tableMeta, 0)).toFixed(1)}
                                    //             />
                                    //         }
                                    //     />
                                    // </div> 
                                    // :
Riri Novita's avatar
Riri Novita committed
902 903 904 905 906 907 908 909 910 911 912
                                    <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}
Deni Rinaldi's avatar
Deni Rinaldi committed
913
                                                    value={Number(val).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
914
                                                    decimalScale={1}
Riri Novita's avatar
Riri Novita committed
915 916 917 918
                                                />
                                            }
                                        />
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
919 920 921 922 923 924 925 926 927 928 929 930 931 932
                                }
                            </div>
                        )
                    }
                }
            },
            {
                name: `Month To Date (MTD)`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <th style={{ ...style2, color: '#fff', backgroundColor: '#1c71b8', 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> */}
Riri Novita's avatar
Riri Novita committed
933
                            <div style={{ borderBottom: "1px #fff solid", backgroundColor: '#1c71b8', justifyContent: 'center', display: 'flex', alignItems: 'center', height: 40, fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
Deni Rinaldi's avatar
Deni Rinaldi committed
934
                            <div className="grid grid-3x" style={{ ...style2, color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
Riri Novita's avatar
Riri Novita committed
935
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
936 937
                                    <span>{"Master Budget (MB)"}</span>
                                </div>
Riri Novita's avatar
Riri Novita committed
938
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
939 940
                                    <span>{"Rolling Budget (RB)"}</span>
                                </div>
Riri Novita's avatar
Riri Novita committed
941
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, backgroundColor: '#37b5e6', justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
942 943 944 945 946 947 948 949 950 951 952 953
                                    <span>{"Actual"}</span>
                                </div>
                            </div>
                        </th>
                    ),
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
                    customBodyRender: (val, tableMeta, updateValue) => {
Riri Novita's avatar
Riri Novita committed
954
                        // console.log(tableMeta);
Deni Rinaldi's avatar
Deni Rinaldi committed
955 956 957 958 959
                        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
960
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
961
                                                null :
Riri Novita's avatar
Riri Novita committed
962 963 964 965 966 967 968 969
                                                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(tableMeta.rowData[8]).toFixed(1) }
Riri Novita's avatar
Riri Novita committed
970
                                                        decimalScale={1}
Riri Novita's avatar
Riri Novita committed
971 972
                                                    />
                                                :
Riri Novita's avatar
Riri Novita committed
973 974 975 976 977 978 979 980
                                                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
981
                                                            value={Number(handleValue(tableMeta, 0)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
982
                                                            decimalScale={1}
Riri Novita's avatar
Riri Novita committed
983 984
                                                        />
                                                    </span> 
d.arizona's avatar
d.arizona committed
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
                                                    // :
                                                    // tableMeta.rowData[0] === 6 ?
                                                    // <div style={{ flex: 1 }}>
                                                    //     <FormControlLabel
                                                    //         style={{ margin: 0 }}
                                                    //         value={ Number(tableMeta.rowData[8]).toFixed(1)}
                                                    //         control={
                                                    //             <NumberFormat
                                                    //                 thousandSeparator={true}
                                                    //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //                 type="text"
                                                    //                 placeholder=""
                                                    //                 disabled={true}
                                                    //                 value={Number(handleFormula(val, tableMeta, 1)).toFixed(1)}
                                                    //                 decimalScale={1}
                                                    //             />
                                                    //         }
                                                    //     />
                                                    // </div> 
Riri Novita's avatar
Riri Novita committed
1004
                                                    :
Riri Novita's avatar
Riri Novita committed
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={tableMeta.rowData[8]}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1016
                                                                    value={Number(tableMeta.rowData[8]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1017
                                                                    decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1018 1019 1020 1021
                                                                />
                                                            }
                                                        />
                                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1022 1023 1024 1025 1026
                                            }
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
1027
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1028
                                                null :
Riri Novita's avatar
Riri Novita committed
1029 1030 1031 1032 1033 1034 1035 1036
                                                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(tableMeta.rowData[9]).toFixed(1) }
Riri Novita's avatar
Riri Novita committed
1037
                                                        decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1038 1039
                                                    />
                                                :
Riri Novita's avatar
Riri Novita committed
1040 1041 1042 1043 1044 1045 1046 1047
                                                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
1048
                                                            value={Number(handleValue(tableMeta, 1)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1049
                                                            decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1050 1051
                                                        />
                                                    </span> 
d.arizona's avatar
d.arizona committed
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070
                                                    // :
                                                    // tableMeta.rowData[0] === 6 ?
                                                    // <div style={{ flex: 1 }}>
                                                    //     <FormControlLabel
                                                    //         style={{ margin: 0 }}
                                                    //         value={tableMeta.rowData[9]}
                                                    //         control={
                                                    //             <NumberFormat
                                                    //                 thousandSeparator={true}
                                                    //                 style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    //                 type="text"
                                                    //                 placeholder=""
                                                    //                 disabled={true}
                                                    //                 value={Number(handleFormula(val, tableMeta, 1)).toFixed(1)}
                                                    //                 decimalScale={1}
                                                    //             />
                                                    //         }
                                                    //     />
                                                    // </div> 
Riri Novita's avatar
Riri Novita committed
1071
                                                    :
Riri Novita's avatar
Riri Novita committed
1072 1073 1074
                                                    <div style={{ flex: 1 }}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
Riri Novita's avatar
Riri Novita committed
1075
                                                        value={ Number(tableMeta.rowData[9]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1076 1077 1078 1079 1080 1081 1082
                                                        control={
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
                                                                disabled={true}
Riri Novita's avatar
Riri Novita committed
1083
                                                                value={ Number(tableMeta.rowData[9]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1084
                                                                decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1085 1086 1087 1088
                                                            />
                                                        }
                                                    />
                                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1089 1090 1091 1092 1093
                                            }
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
1094 1095 1096
                                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                null 
                                                :
Riri Novita's avatar
Riri Novita committed
1097 1098 1099 1100 1101 1102 1103 1104
                                                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(tableMeta.rowData[10]).toFixed(1) }
Riri Novita's avatar
Riri Novita committed
1105
                                                        decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1106 1107
                                                    />
                                                :
Riri Novita's avatar
Riri Novita committed
1108 1109 1110 1111 1112 1113 1114 1115
                                                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
1116
                                                            value={Number(handleValue(tableMeta, 2)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1117
                                                            decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1118 1119 1120 1121 1122 1123 1124
                                                        />
                                                    </span> 
                                                    :
                                                    tableMeta.rowData[0] === 3 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
Riri Novita's avatar
Riri Novita committed
1125
                                                            value={Number(tableMeta.rowData[10]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1126 1127 1128
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
d.arizona's avatar
d.arizona committed
1129
                                                                    style={{ color: this.state.get_for == 'view'? "black" : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Riri Novita's avatar
Riri Novita committed
1130 1131
                                                                    type="text"
                                                                    placeholder=""
Riri Novita's avatar
Riri Novita committed
1132 1133
                                                                    decimalScale={1}
                                                                    fixedDecimalScale={1}
Riri Novita's avatar
Riri Novita committed
1134
                                                                    disabled={!this.props.permission.create || !this.props.permission.edit || this.state.get_for == 'view'}
Deni Rinaldi's avatar
Deni Rinaldi committed
1135
                                                                    value={Number(tableMeta.rowData[10]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1136
                                                                    decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1137 1138 1139 1140 1141 1142 1143 1144
                                                                    onBlur={(event) => {
                                                                        handleChange(event.target.value, tableMeta)
                                                                    }}
                                                                />
                                                            }
                                                        />
                                                    </div> 
                                                    :
Riri Novita's avatar
Riri Novita committed
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156
                                                    tableMeta.rowData[0] === 6 ?
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={ Number(tableMeta.rowData[8]).toFixed(1)}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1157
                                                                    decimalScale={1}
d.arizona's avatar
d.arizona committed
1158
                                                                    value={Number(handleFormula(val, tableMeta, 2)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1159
                                                                    decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1160 1161 1162 1163 1164
                                                                />
                                                            }
                                                        />
                                                    </div> 
                                                    :
Riri Novita's avatar
Riri Novita committed
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174
                                                    <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={tableMeta.rowData[10]}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
1175
                                                                        value={Number(tableMeta.rowData[10]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1176
                                                                        decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1177 1178 1179 1180
                                                                    />
                                                                }
                                                            />
                                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1181 1182 1183 1184 1185 1186 1187 1188 1189
                                            }
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
Riri Novita's avatar
Riri Novita committed
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
Deni Rinaldi's avatar
Deni Rinaldi committed
1202 1203 1204 1205 1206 1207
            {
                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)" }} >
                            <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
1208 1209
                            <div className="grid grid-2x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
                                    <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
1222
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246
                                    <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>
                    ),
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1247
                                <div className="grid grid-2x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
1248 1249 1250
                                    <div className="column-1">
                                        <div className="grid grid-2x content-center">
                                            <div className="column-1">
Riri Novita's avatar
Riri Novita committed
1251 1252 1253 1254
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null 
                                                        :
Riri Novita's avatar
Riri Novita committed
1255 1256 1257 1258 1259 1260 1261 1262
                                                        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(tableMeta.rowData[11]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1263
                                                                decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1264 1265
                                                            />
                                                        :
Riri Novita's avatar
Riri Novita committed
1266 1267 1268
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
Riri Novita's avatar
Riri Novita committed
1269
                                                                value={Number(tableMeta.rowData[11]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1270 1271 1272 1273 1274 1275 1276
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1277
                                                                        value={Number(handleVariance(tableMeta, 1, 0)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1278
                                                                        decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1279 1280 1281 1282
                                                                    />
                                                                }
                                                            />
                                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1283 1284 1285 1286
                                                    }
                                                </div>
                                            </div>
                                            <div className="column-2">
Riri Novita's avatar
Riri Novita committed
1287 1288 1289 1290
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null 
                                                        :
Riri Novita's avatar
Riri Novita committed
1291 1292 1293 1294 1295 1296
                                                        this.state.get_for == 'view' ? 
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
Riri Novita's avatar
Riri Novita committed
1297
                                                                suffix={'%'}
Riri Novita's avatar
Riri Novita committed
1298 1299
                                                                disabled={true}
                                                                value={Number(tableMeta.rowData[12]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1300
                                                                decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1301 1302
                                                            />
                                                        :
Riri Novita's avatar
Riri Novita committed
1303 1304 1305
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
Riri Novita's avatar
Riri Novita committed
1306
                                                                value={val}
Riri Novita's avatar
Riri Novita committed
1307 1308 1309
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
Riri Novita's avatar
Riri Novita committed
1310
                                                                        style={{ color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? 'red' : '#000000b0', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Riri Novita's avatar
Riri Novita committed
1311 1312 1313 1314
                                                                        type="text"
                                                                        placeholder=""
                                                                        suffix={'%'}
                                                                        disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1315
                                                                        value={Number(handleVariancePercent(tableMeta, 1, 1)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1316
                                                                        decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1317 1318 1319 1320
                                                                    />
                                                                }
                                                            />
                                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1321 1322 1323 1324 1325
                                                    }
                                                </div>
                                            </div>
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1326
                                    <div className="column-2">
Deni Rinaldi's avatar
Deni Rinaldi committed
1327 1328
                                        <div className="grid grid-2x content-center">
                                            <div className="column-1">
Riri Novita's avatar
Riri Novita committed
1329
                                                <div style={{ textAlign: 'right', width: 120 }}>
Riri Novita's avatar
Riri Novita committed
1330
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
Riri Novita's avatar
Riri Novita committed
1331 1332
                                                        null 
                                                        :
Riri Novita's avatar
Riri Novita committed
1333 1334 1335 1336 1337 1338 1339 1340
                                                        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(tableMeta.rowData[13]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1341
                                                                decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1342 1343
                                                            />
                                                        :
Riri Novita's avatar
Riri Novita committed
1344 1345 1346
                                                        <div style={{ flex: 1 }}>
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
Riri Novita's avatar
Riri Novita committed
1347
                                                                value={Number(tableMeta.rowData[13]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1348 1349 1350 1351 1352 1353 1354
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1355
                                                                        value={Number(handleVariance(tableMeta, 2, 2)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1356
                                                                        decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1357 1358 1359 1360
                                                                    />
                                                                }
                                                            />
                                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1361 1362 1363 1364
                                                    }
                                                </div>
                                            </div>
                                            <div className="column-2">
Riri Novita's avatar
Riri Novita committed
1365
                                                <div style={{ textAlign: 'right', width: 120 }}>
Riri Novita's avatar
Riri Novita committed
1366
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
Riri Novita's avatar
Riri Novita committed
1367 1368
                                                        null 
                                                        :
Riri Novita's avatar
Riri Novita committed
1369 1370 1371 1372 1373 1374
                                                        this.state.get_for == 'view' ? 
                                                            <NumberFormat
                                                                thousandSeparator={true}
                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                type="text"
                                                                placeholder=""
Riri Novita's avatar
Riri Novita committed
1375
                                                                suffix={'%'}
Riri Novita's avatar
Riri Novita committed
1376 1377
                                                                disabled={true}
                                                                value={Number(tableMeta.rowData[14]).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1378
                                                                decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1379 1380
                                                            />
                                                        :
Riri Novita's avatar
Riri Novita committed
1381
                                                        <div style={{ flex: 1, width: 120 }}>
Riri Novita's avatar
Riri Novita committed
1382 1383
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
Riri Novita's avatar
Riri Novita committed
1384
                                                                value={val}
Riri Novita's avatar
Riri Novita committed
1385 1386 1387
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
Riri Novita's avatar
Riri Novita committed
1388
                                                                        style={{ color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? 'red' : '#000000b0', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Riri Novita's avatar
Riri Novita committed
1389 1390 1391 1392
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        suffix={'%'}
Deni Rinaldi's avatar
Deni Rinaldi committed
1393
                                                                        value={Number(handleVariancePercent(tableMeta, 2, 3)).toFixed(1)}
Riri Novita's avatar
Riri Novita committed
1394
                                                                        decimalScale={1}
Riri Novita's avatar
Riri Novita committed
1395 1396 1397 1398
                                                                    />
                                                                }
                                                            />
                                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409
                                                    }
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
Riri Novita's avatar
Riri Novita committed
1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
Deni Rinaldi's avatar
Deni Rinaldi committed
1428 1429 1430 1431 1432 1433 1434 1435 1436
            {
                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> */}
                            <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
1437
                            <div className="grid grid-2x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1438 1439 1440
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
                                    <span>{"vs MB"}</span>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1441
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455
                                    <span>{"vs RB"}</span>
                                </div>
                            </div>
                        </th>
                    ),
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1456
                                <div className="grid grid-2x content-center">
Deni Rinaldi's avatar
Deni Rinaldi committed
1457
                                    <div className="col-1">
Riri Novita's avatar
Riri Novita committed
1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471
                                        <div style={{ textAlign: 'left', width: 90 }}>
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 3 ?
                                                    this.state.get_for == 'view' ? 
                                                    <Input
                                                        disableUnderline={true}
                                                        style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        multiline={true}
                                                        disabled={true}
                                                        defaultValue={tableMeta.rowData[15]}
                                                        inputProps={{
                                                            style: {
Riri Novita's avatar
Riri Novita committed
1472
                                                                color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? "#000000b0" : '#000000b0',
Riri Novita's avatar
Riri Novita committed
1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
                                                                textAlign: 'left'
                                                            }
                                                        }}
                                                        onBlur={(event) => {
                                                            handleText(event.target.value, tableMeta, 0)
                                                        }}
                                                    />
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        // value={tableMeta.rowData[15]}
                                                        control={
                                                            tableMeta.rowData[15] === "" &&  (Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue) ? 
                                                                <LightTooltipError title={"MTD Explanation vs MB is Reqiured"} arrow>
                                                                    <Input
                                                                        disableUnderline={true}
                                                                        style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', minHeight: 30 , padding: 0 }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        multiline={true}
                                                                        disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                        // value={tableMeta.rowData[15]}
                                                                        defaultValue={tableMeta.rowData[15]}
                                                                        inputProps={{
                                                                            style: {
                                                                                color: "#5198ea",
                                                                                textAlign: 'left',
                                                                                backgroundColor: '#ffac99',
                                                                                minHeight: 30,
                                                                                padding: 0
                                                                            }
                                                                        }}
                                                                        onBlur={(event) => {
                                                                            handleText(event.target.value, tableMeta, 0)
                                                                        }}
                                                                    />
                                                                </LightTooltipError> 
                                                                :
Riri Novita's avatar
Riri Novita committed
1511 1512
                                                                <Input
                                                                    disableUnderline={true}
Riri Novita's avatar
Riri Novita committed
1513
                                                                    style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Riri Novita's avatar
Riri Novita committed
1514 1515
                                                                    type="text"
                                                                    placeholder=""
Riri Novita's avatar
Riri Novita committed
1516 1517
                                                                    multiline={true}
                                                                    disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
Riri Novita's avatar
Riri Novita committed
1518 1519 1520
                                                                    defaultValue={tableMeta.rowData[15]}
                                                                    inputProps={{
                                                                        style: {
Riri Novita's avatar
Riri Novita committed
1521 1522
                                                                            color: Number(tableMeta.rowData[12]) < this.state.minValue || Number(tableMeta.rowData[12]) > this.state.maxValue ? "#5198ea" : '#5198ea',
                                                                            textAlign: 'left'
Riri Novita's avatar
Riri Novita committed
1523 1524
                                                                        }
                                                                    }}
Riri Novita's avatar
Riri Novita committed
1525
                                                                    onBlur={(event) => {
Riri Novita's avatar
Riri Novita committed
1526
                                                                        handleText(event.target.value, tableMeta, 0)
Riri Novita's avatar
Riri Novita committed
1527 1528
                                                                    }}
                                                                />
Riri Novita's avatar
Riri Novita committed
1529 1530 1531 1532 1533 1534
                                                        }
                                                    />
                                                    :
                                                    null
                                                }
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1535 1536
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1537
                                    <div className="col-2">
Riri Novita's avatar
Riri Novita committed
1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551
                                        <div style={{ textAlign: 'left', width: 90 }}>
                                            <div style={{ flex: 1 }}>
                                                {tableMeta.rowData[0] === 3 ?
                                                    this.state.get_for == 'view' ? 
                                                    <Input
                                                        disableUnderline={true}
                                                        style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        multiline={true}
                                                        disabled={true}
                                                        defaultValue={tableMeta.rowData[16]}
                                                        inputProps={{
                                                            style: {
Riri Novita's avatar
Riri Novita committed
1552
                                                                color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#000000b0" : '#000000b0',
Riri Novita's avatar
Riri Novita committed
1553 1554 1555 1556
                                                                textAlign: 'left'
                                                            }
                                                        }}
                                                        onBlur={(event) => {
Riri Novita's avatar
Riri Novita committed
1557
                                                            handleText(event.target.value, tableMeta, 1)
Riri Novita's avatar
Riri Novita committed
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585
                                                        }}
                                                    />
                                                    :
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        // value={tableMeta.rowData[16]}
                                                        control={
                                                            tableMeta.rowData[16] === "" &&  (Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue) ? 
                                                                <LightTooltipError title={"MTD Explanation vs RB is Reqiured"} arrow>
                                                                    <Input
                                                                        disableUnderline={true}
                                                                        style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', minHeight: 30 , padding: 0 }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        multiline={true}
                                                                        disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
                                                                        // value={tableMeta.rowData[16]}
                                                                        defaultValue={tableMeta.rowData[16]}
                                                                        inputProps={{
                                                                            style: {
                                                                                color: "#5198ea",
                                                                                textAlign: 'left',
                                                                                backgroundColor: '#ffac99',
                                                                                minHeight: 30,
                                                                                padding: 0
                                                                            }
                                                                        }}
                                                                        onBlur={(event) => {
Riri Novita's avatar
Riri Novita committed
1586
                                                                            handleText(event.target.value, tableMeta, 1)
Riri Novita's avatar
Riri Novita committed
1587 1588 1589 1590
                                                                        }}
                                                                    />
                                                                </LightTooltipError> 
                                                                :
Riri Novita's avatar
Riri Novita committed
1591 1592
                                                                <Input
                                                                    disableUnderline={true}
Riri Novita's avatar
Riri Novita committed
1593
                                                                    style={{ fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Riri Novita's avatar
Riri Novita committed
1594 1595
                                                                    type="text"
                                                                    placeholder=""
Riri Novita's avatar
Riri Novita committed
1596 1597
                                                                    multiline={true}
                                                                    disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)}
Riri Novita's avatar
Riri Novita committed
1598 1599 1600
                                                                    defaultValue={tableMeta.rowData[16]}
                                                                    inputProps={{
                                                                        style: {
Riri Novita's avatar
Riri Novita committed
1601 1602
                                                                            color: Number(tableMeta.rowData[14]) < this.state.minValue || Number(tableMeta.rowData[14]) > this.state.maxValue ? "#5198ea" : '#5198ea',
                                                                            textAlign: 'left'
Riri Novita's avatar
Riri Novita committed
1603 1604 1605
                                                                        }
                                                                    }}
                                                                    onBlur={(event) => {
Riri Novita's avatar
Riri Novita committed
1606
                                                                        handleText(event.target.value, tableMeta, 1)
Riri Novita's avatar
Riri Novita committed
1607 1608
                                                                    }}
                                                                />
Riri Novita's avatar
Riri Novita committed
1609 1610 1611 1612 1613 1614
                                                        }
                                                    />
                                                    :
                                                    null
                                                }
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1615 1616 1617 1618 1619 1620 1621 1622
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
Riri Novita's avatar
Riri Novita committed
1623 1624 1625 1626 1627 1628
            {
                name: "",
                options: {
                    display: false
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1629 1630
        ]

Riri Novita's avatar
Riri Novita committed
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640
        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
1641

Deni Rinaldi's avatar
Deni Rinaldi committed
1642 1643 1644
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
Riri Novita's avatar
Riri Novita committed
1645
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report Submission</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1646
                </div>
Riri Novita's avatar
Riri Novita committed
1647 1648 1649 1650 1651
                <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
1652
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Riri Novita's avatar
Riri Novita committed
1653 1654 1655 1656
                    {this.state.visibleOI === true ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Operating Indicator</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1657
                            </div>
Riri Novita's avatar
Riri Novita committed
1658 1659 1660 1661 1662 1663
                            <div style={{ padding: 20 }}>
                                {!this.state.emptyData && <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>
                                            Period : {
Riri Novita's avatar
Riri Novita committed
1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675
                                                        this.props.months === 1 ? 'JAN' : 
                                                        this.props.months === 2 ? 'FEB' :
                                                        this.props.months === 3 ? 'MAR' :
                                                        this.props.months === 4 ? 'APR' :
                                                        this.props.months === 5 ? 'MAY' :
                                                        this.props.months === 6 ? 'JUN' :
                                                        this.props.months === 7 ? 'JUL' :
                                                        this.props.months === 8 ? 'AUG' :
                                                        this.props.months === 9 ? 'SEP' :
                                                        this.props.months === 10 ? 'OCT' :
                                                        this.props.months === 11 ? 'NOV' :
                                                        this.props.months === 12 ? 'DEC' : "" } {this.props.data.periode}
Riri Novita's avatar
Riri Novita committed
1676 1677 1678 1679 1680
                                        </Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
                                        <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
Riri Novita's avatar
Riri Novita committed
1681
                                            {this.state.get_for == 'edit' && (this.props.permission.create || this.props.permission.edit) && <a data-tip={'Download Template'} data-for="template">
Riri Novita's avatar
Riri Novita committed
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694
                                                <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" />
Riri Novita's avatar
Riri Novita committed
1695
                                            {this.state.get_for == 'edit' && (this.props.permission.create || this.props.permission.edit) && <a data-tip={'Upload'} data-for="upload">
Riri Novita's avatar
Riri Novita committed
1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.setState({ visibleUpload: true, editable: true })}
                                                >
                                                    <img src={Images.upload} />
                                                </button>
                                            </a>}
                                            <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
1709
                                            <a data-tip={'Download'} data-for="download">
Riri Novita's avatar
Riri Novita committed
1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.downloadAllData()}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
1722
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
Riri Novita's avatar
Riri Novita committed
1723 1724 1725
                                        </div>
                                    </div>
                                </div>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1726

Riri Novita's avatar
Riri Novita committed
1727 1728
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {this.state.loading && loadingComponent}
Riri Novita's avatar
Riri Novita committed
1729 1730 1731
                                    {!this.state.loading &&
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                        
Deni Rinaldi's avatar
Deni Rinaldi committed
1732
                                        <MUIDataTable
Riri Novita's avatar
Riri Novita committed
1733
                                            data={dataTable2}
Deni Rinaldi's avatar
Deni Rinaldi committed
1734 1735 1736 1737
                                            columns={columns}
                                            options={options}
                                        />
                                    </MuiThemeProvider>
Riri Novita's avatar
Riri Novita committed
1738
                                    }
Riri Novita's avatar
Riri Novita committed
1739
                                </div>
Riri Novita's avatar
Riri Novita committed
1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
                                        {
                                            this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
                                        }
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
1753
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notesUpdate}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1754
                            </div>
Riri Novita's avatar
Riri Novita committed
1755
                            <div className="grid grid-2x">
Riri Novita's avatar
Riri Novita committed
1756
                                <div className="col-1" style={{ paddingLeft: 20 }}>
Riri Novita's avatar
Riri Novita committed
1757
                                    <button
Riri Novita's avatar
Riri Novita committed
1758
                                        className="button"
Riri Novita's avatar
Riri Novita committed
1759 1760 1761 1762 1763 1764
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                        }}
Riri Novita's avatar
Riri Novita committed
1765 1766 1767 1768 1769 1770
                                        onClick={() => this.setState({ loading: true }, () => { 
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                                this.props.getReport()
                                            }, 100);
                                        })}
Riri Novita's avatar
Riri Novita committed
1771 1772 1773 1774 1775 1776
                                    >
                                        <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>
Riri Novita's avatar
Riri Novita committed
1777 1778
                                {!this.state.emptyData && (this.props.permission.create || this.props.permission.edit) && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 2 }}>
                                    {this.state.get_for == 'view' && this.state.viewOnly && <button
d.arizona's avatar
d.arizona committed
1779 1780 1781 1782 1783 1784
                                        type="button"
                                        onClick={() => {
                                            this.setState({loading: true}, () => {
                                                this.handleGetFor('edit')
                                            })
                                        }}
Riri Novita's avatar
Riri Novita committed
1785
                                        style={{ marginRight: 21 }}
d.arizona's avatar
d.arizona committed
1786 1787 1788 1789 1790 1791
                                    >
                                        <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
Riri Novita's avatar
Riri Novita committed
1792
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1793 1794
                                        onClick={() =>
                                            this.setState({ loading: true, editable: false }, () => {
Riri Novita's avatar
Riri Novita committed
1795
                                                setTimeout(() => {
Riri Novita's avatar
Riri Novita committed
1796
                                                    this.handleValidate()
Riri Novita's avatar
Riri Novita committed
1797
                                                    // this.setState({ loading: false, buttonError: false })
Riri Novita's avatar
Riri Novita committed
1798 1799
                                                }, 100);
                                            })
Riri Novita's avatar
Riri Novita committed
1800 1801
                                        }
                                        style={{ marginRight: 20 }}
Riri Novita's avatar
Riri Novita committed
1802 1803 1804 1805
                                    >
                                        <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
1806 1807
                                    </button>}
                                    {this.state.get_for == 'edit' && <button
Riri Novita's avatar
Riri Novita committed
1808 1809
                                        className="button"
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1810
                                        // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1811 1812
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1813
                                            cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1814 1815 1816 1817
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
Riri Novita's avatar
Riri Novita committed
1818
                                        onClick={() =>
Riri Novita's avatar
Riri Novita committed
1819
                                            this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1820 1821 1822 1823 1824 1825 1826
                                                this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                :
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
                                                        this.createData("draft")
                                                    }, 100);
                                                })}
Riri Novita's avatar
Riri Novita committed
1827 1828
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1829
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
Riri Novita's avatar
Riri Novita committed
1830
                                        </div>
d.arizona's avatar
d.arizona committed
1831 1832
                                    </button>}
                                    {this.state.get_for == 'edit' && <button
Riri Novita's avatar
Riri Novita committed
1833
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1834 1835 1836 1837 1838 1839 1840 1841 1842 1843
                                        // disabled={this.state.editable}
                                        onClick={() => 
                                            this.state.editable === true ?
                                                this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                :
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
                                                        this.createData("submitted")
                                                    }, 100);
                                            })}
Riri Novita's avatar
Riri Novita committed
1844 1845
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1846
                                            cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1847 1848
                                            borderColor: 'transparent',
                                            outline: 'none',
Riri Novita's avatar
Riri Novita committed
1849
                                            marginRight: 20
Riri Novita's avatar
Riri Novita committed
1850 1851 1852
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1853
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
Riri Novita's avatar
Riri Novita committed
1854
                                        </div>
d.arizona's avatar
d.arizona committed
1855
                                    </button>}
Riri Novita's avatar
Riri Novita committed
1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866
                                </div>}
                            </div>
                        </Paper>
                        :
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div>
                                <div style={{ padding: 25 }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>
                                            Period : {
Riri Novita's avatar
Riri Novita committed
1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878
                                                        this.props.months === 1 ? 'JAN' : 
                                                        this.props.months === 2 ? 'FEB' :
                                                        this.props.months === 3 ? 'MAR' :
                                                        this.props.months === 4 ? 'APR' :
                                                        this.props.months === 5 ? 'MAY' :
                                                        this.props.months === 6 ? 'JUN' :
                                                        this.props.months === 7 ? 'JUL' :
                                                        this.props.months === 8 ? 'AUG' :
                                                        this.props.months === 9 ? 'SEP' :
                                                        this.props.months === 10 ? 'OCT' :
                                                        this.props.months === 11 ? 'NOV' :
                                                        this.props.months === 12 ? 'DEC' : "" } {this.props.data.periode}
Riri Novita's avatar
Riri Novita committed
1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894
                                        </Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    {this.state.dataLoaded && (
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                            {this.state.loading && loadingComponent}
                                            <MuiThemeProvider theme={getMuiTheme()}>
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
                                            </MuiThemeProvider>
                                        </div>
                                    )}
                                </div>
rifkaki's avatar
rifkaki committed
1895
                                <div className="grid grid-2x" style={{ marginLeft: 10 }}>
Riri Novita's avatar
Riri Novita committed
1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907
                                    <div className="col-1">
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                            }}
                                            onClick={() =>
                                                this.setState({ loading: true, visibleOI: true }, () => {
                                                    setTimeout(() => {
Riri Novita's avatar
Riri Novita committed
1908
                                                        this.getItemHierarki()
Riri Novita's avatar
Riri Novita committed
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922
                                                    }, 100)
                                                })}
                                        >
                                            <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>
                                    {!this.state.emptyData && this.state.templateNull && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                        <button
                                            type="button"
                                            onClick={() =>
                                                this.setState({ loading: true, editable: false }, () => {
                                                    setTimeout(() => {
Riri Novita's avatar
Riri Novita committed
1923 1924
                                                        this.handleValidate()
                                                        // this.setState({ loading: false, buttonError: false })
Riri Novita's avatar
Riri Novita committed
1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938
                                                    }, 100);
                                                })
                                            }
                                            style={{ marginRight: 20 }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
                                        </button>
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1939
                                                cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1940 1941 1942 1943
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Riri Novita's avatar
Riri Novita committed
1944
                                            // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1945
                                            onClick={() =>
Riri Novita's avatar
Riri Novita committed
1946 1947 1948 1949
                                                this.state.saveDraft === true ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    : 
                                                    this.setState({ loading: true }, () => {
Riri Novita's avatar
Riri Novita committed
1950 1951 1952 1953 1954 1955
                                                        setTimeout(() => {
                                                            this.uploadOI("draft")
                                                        }, 100);
                                                    })}
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1956
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
Riri Novita's avatar
Riri Novita committed
1957 1958 1959
                                            </div>
                                        </button>
                                        <button
Riri Novita's avatar
Riri Novita committed
1960
                                            className="button"
Riri Novita's avatar
Riri Novita committed
1961
                                            type="button"
Riri Novita's avatar
Riri Novita committed
1962
                                            // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1963 1964
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1965
                                                cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1966 1967 1968 1969
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Riri Novita's avatar
Riri Novita committed
1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
                                            onClick={() =>
                                                this.state.editable === true ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' }) 
                                                    :
                                                    this.setState({ loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.uploadOI("submitted")
                                                        }, 100);
                                                    })}
                                           
Riri Novita's avatar
Riri Novita committed
1980 1981
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1982
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
Riri Novita's avatar
Riri Novita committed
1983 1984 1985
                                            </div>
                                        </button>
                                    </div>}
Riri Novita's avatar
Riri Novita committed
1986 1987
                                </div>
                            </div>
Riri Novita's avatar
Riri Novita committed
1988
                        </Paper>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1989
                </div>
Riri Novita's avatar
Riri Novita committed
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019

                {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
2020
                                    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("OPERATING") && String(this.state.judul).includes("INDICATOR") ?
Riri Novita's avatar
Riri Novita committed
2021 2022 2023 2024 2025 2026 2027
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2028
            </div>
Riri Novita's avatar
Riri Novita committed
2029
        );
Deni Rinaldi's avatar
Deni Rinaldi committed
2030 2031
    }
}