OperatingIndicatorMR.js 126 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 60 61
            maxValue: 0,
            updateBy: '-',
            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

Riri Novita's avatar
Riri Novita committed
85
        this.setState({viewOnly: checkCreate && checkEdit})
Riri Novita's avatar
Riri Novita committed
86 87
    }

d.arizona's avatar
d.arizona committed
88 89 90
    handleGetFor(type) {
        this.setState({get_for: type}, () => {
            this.getSettingControl()
Riri Novita's avatar
Riri Novita committed
91
            // this.getLatestUpdate()
d.arizona's avatar
d.arizona committed
92 93 94
        })
    }

Riri Novita's avatar
Riri Novita committed
95 96
    getLatestUpdate() {
        let payload = {
Riri Novita's avatar
Riri Novita committed
97
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
98 99 100
            "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
101
            "months": this.props.months
Riri Novita's avatar
Riri Novita committed
102
        }
Riri Novita's avatar
Riri Novita committed
103
        // console.log(payload);
Riri Novita's avatar
Riri Novita committed
104
        api.create().getLastestUpdateMROI(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
105
            // console.log(response.data)
Riri Novita's avatar
Riri Novita committed
106 107 108
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
109 110
                        updateBy: response.data.data.latest_update === null ? '-' : response.data.data.latest_update,
                        notesUpdate: response.data.data.notes_update === null ? '-' : response.data.data.notes_update
Riri Novita's avatar
Riri Novita committed
111
                    })
Riri Novita's avatar
Riri Novita committed
112 113 114 115 116 117 118 119 120
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Riri Novita's avatar
Riri Novita committed
121
                }
Riri Novita's avatar
Riri Novita committed
122 123
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
Riri Novita's avatar
Riri Novita committed
124 125 126 127
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
128 129 130 131 132 133 134 135
    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
136
            console.log(response);
Riri Novita's avatar
Riri Novita committed
137 138 139
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
140 141
                        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
142
                    }, () => {
Riri Novita's avatar
Riri Novita committed
143
                        this.getOperatingIDMonthly()
Riri Novita's avatar
Riri Novita committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
159 160
    }

Riri Novita's avatar
Riri Novita committed
161
    getOperatingIDMonthly() {
Riri Novita's avatar
Riri Novita committed
162
        // console.log(this.props.data.operatingIndID);
Riri Novita's avatar
Riri Novita committed
163 164
        let payload = {
            "company_id": this.props.data.company.company_id,
Riri Novita's avatar
Riri Novita committed
165
            "periode": this.props.data.periode,
Riri Novita's avatar
Riri Novita committed
166
            "months": this.props.months
Riri Novita's avatar
Riri Novita committed
167
        }
Riri Novita's avatar
Riri Novita committed
168
        console.log(payload);
Riri Novita's avatar
Riri Novita committed
169
        api.create().getMonthlyOI(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
170
            console.log(response);
Riri Novita's avatar
Riri Novita committed
171 172 173 174
            if (response) {
                if (response.data.data) {
                    this.setState({ operatingIndIDMonthly: response.data.data.operating_indicator_id } , () => {
                        this.getItemHierarki()
Riri Novita's avatar
Riri Novita committed
175
                        this.getLatestUpdate()
Riri Novita's avatar
Riri Novita committed
176 177 178 179
                    })
                } else {
                    this.setState({ operatingIndIDMonthly: null }, () => {
                        this.getItemHierarki()
Riri Novita's avatar
Riri Novita committed
180
                        this.getLatestUpdate()
Riri Novita's avatar
Riri Novita committed
181 182 183 184 185 186
                    })
                }
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
187
    getItemHierarki() {
Riri Novita's avatar
Riri Novita committed
188
        this.setState({ loading: true })
Riri Novita's avatar
Riri Novita committed
189
        let payload = {
Riri Novita's avatar
Riri Novita committed
190
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
191 192 193
            "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
194
            "months": this.props.months,
d.arizona's avatar
d.arizona committed
195
            "get_for": this.state.get_for 
Deni Rinaldi's avatar
Deni Rinaldi committed
196
        }
Riri Novita's avatar
Riri Novita committed
197
        console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
198
        api.create().getHierarkiMontlyReportOI(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
199
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
200
            let dataTable = []
Riri Novita's avatar
Riri Novita committed
201 202
            let err = false

Deni Rinaldi's avatar
Deni Rinaldi committed
203 204 205 206
            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
207 208 209 210 211 212 213 214 215 216
                    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
217 218 219 220 221 222 223 224
                    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
225
                            item.uom  === "" ? null : item.uom,
Riri Novita's avatar
Riri Novita committed
226
                            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
227
                            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
228 229 230 231 232 233
                            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
234 235
                            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
236
                            item.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
237 238 239 240 241 242 243 244 245 246 247
                        ])
                    }
                    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
248 249 250 251 252 253 254 255 256 257
                    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
258 259 260 261 262 263 264
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
Riri Novita's avatar
Riri Novita committed
265
                        item.uom  === "" ? null : item.uom,
Riri Novita's avatar
Riri Novita committed
266
                        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
267
                        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
268 269 270 271 272 273
                        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
274 275
                        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
276
                        item.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
277 278 279 280 281 282 283 284 285
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
Riri Novita's avatar
Riri Novita committed
286 287 288 289
                if (err === true) {
                    this.setState({ bebas: true })
                }
                this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true }, () => {
Riri Novita's avatar
Riri Novita committed
290 291 292 293
                    if (this.state.dataTable.length == 0) {
                        this.setState({ emptyData: true })
                    }
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
294
            }
Riri Novita's avatar
Riri Novita committed
295
            console.log(dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
296 297
        })
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
298

Riri Novita's avatar
Riri Novita committed
299 300
    downloadTemplate = async () => {
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
301
            `${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
302 303
        )
        res = await res.blob()
Riri Novita's avatar
Riri Novita committed
304
        // // console.log(res)
Riri Novita's avatar
Riri Novita committed
305 306 307 308 309 310 311 312 313 314
        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
315
        // console.log(this.props.months);
Riri Novita's avatar
Riri Novita committed
316
        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
317 318
        console.log(url);
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
319
            `${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
320 321 322 323 324 325 326 327 328 329 330 331
        )
        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
332
    createData(type) {
Riri Novita's avatar
Riri Novita committed
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
        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
351
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
352 353 354
            "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
355
            "status": type,
Riri Novita's avatar
Riri Novita committed
356
            "months": this.props.months,
Riri Novita's avatar
Riri Novita committed
357
            "monthly_report": data
Riri Novita's avatar
Riri Novita committed
358
        }
Riri Novita's avatar
Riri Novita committed
359 360
        console.log(payload);
        // // console.log('=========================')
Riri Novita's avatar
Riri Novita committed
361
        console.log(JSON.stringify(payload))
Riri Novita's avatar
Riri Novita committed
362 363
        this.props.saveMonthlyOI(payload)
        this.props.onClickClose()
Riri Novita's avatar
Riri Novita committed
364 365
    }

Riri Novita's avatar
Riri Novita committed
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
    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
386 387
                            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
388 389 390 391 392 393 394
                        })
                    }
                })
                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
395
                    months: this.props.months,
Riri Novita's avatar
Riri Novita committed
396
                    status: 'submitted',
Riri Novita's avatar
Riri Novita committed
397 398 399
                    monthly_report: payload
                }
                console.log(body)
Riri Novita's avatar
Riri Novita committed
400
                console.log(JSON.stringify(body));
Riri Novita's avatar
Riri Novita committed
401
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
Riri Novita's avatar
Riri Novita committed
402 403 404 405 406 407 408 409 410 411 412 413
            }
        });
    }

    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
414
                    let err = false
Riri Novita's avatar
Riri Novita committed
415 416
                    let dataTable = response.data.data.map((item, index) => {
                        console.log(item);
Riri Novita's avatar
Riri Novita committed
417 418 419
                        if (item.type_report_id != null) {
                            total += 1
                        }
Riri Novita's avatar
Riri Novita committed
420 421 422 423 424 425 426 427 428 429
                        // 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
430 431 432 433 434 435 436 437 438 439 440 441
                        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
442 443 444 445 446 447 448 449
                            // 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
450 451 452 453 454
                            item.mtd_vs_mb,
                            item.mtd_vs_rb,
                            item.order,
                            item.error
                        ]
Riri Novita's avatar
Riri Novita committed
455
                    })
Riri Novita's avatar
Riri Novita committed
456
                    console.log(dataTable);
Riri Novita's avatar
Riri Novita committed
457
                    this.setState({ dataTable, dataLoaded: true, loading: false,  buttonError: false, templateNull : total > 0 ? true : false })
Riri Novita's avatar
Riri Novita committed
458 459 460 461 462 463 464
                }
            }
        })
    }

    uploadOI(type) {
        let data = []
Riri Novita's avatar
Riri Novita committed
465
        // console.log(this.state.dataTable)
Riri Novita's avatar
Riri Novita committed
466 467 468 469 470 471 472 473 474 475 476 477
        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
478 479
                mtd_vs_mb: String(i[15]),
                mtd_vs_rb: String(i[16]),
Riri Novita's avatar
Riri Novita committed
480 481 482 483
            })
        })
        let body = {
            company_id: this.props.data.company.company_id,
Riri Novita's avatar
Riri Novita committed
484
            operating_indicator_id: this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
485 486 487
            periode: this.props.data.periode,
            report_id: this.props.data.report_id,
            status: type,
Riri Novita's avatar
Riri Novita committed
488
            months: this.props.months,
Riri Novita's avatar
Riri Novita committed
489 490
            monthly_report: data
        }
Riri Novita's avatar
Riri Novita committed
491 492
        // console.log(body);
        // console.log(JSON.stringify(body))
Riri Novita's avatar
Riri Novita committed
493 494 495 496 497 498 499 500 501
        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 {
                    alert(response.data.status)
Riri Novita's avatar
Riri Novita committed
502
                }
Riri Novita's avatar
Riri Novita committed
503 504
            } else {
                alert(response.problem)
Riri Novita's avatar
Riri Novita committed
505 506 507 508
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
509 510 511 512
    handleValidate() {
        let data = []
        let err = false
        this.state.dataTable.map((i, index) => {
Riri Novita's avatar
Riri Novita committed
513 514 515 516 517 518 519 520 521
            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
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
            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
540
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
541 542 543 544
            "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
545
            "months": this.props.months,
Riri Novita's avatar
Riri Novita committed
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
            "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 }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
574 575 576 577
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
578
    render() {
Riri Novita's avatar
Riri Novita committed
579
        let dataTable2 = this.state.dataTable
Riri Novita's avatar
Riri Novita committed
580 581 582 583 584

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

Riri Novita's avatar
Riri Novita committed
585 586 587 588 589 590 591 592 593
        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
594
            dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
595 596 597 598 599 600 601 602
            // 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
603
                dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
Riri Novita's avatar
Riri Novita committed
604 605 606
            } else {
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
607 608 609
                    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
610 611
                    
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
612
                    dataTable2[tableMeta.rowIndex][10] = Number(val).toFixed(1)
Riri Novita's avatar
Riri Novita committed
613 614 615 616 617 618 619
                }
            }
        }

        const handleVariance = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
620
                total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[8]).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
621
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
622
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
623
                total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[9]).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
624
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
625 626 627 628 629 630 631
            } 
            return total
        }

        const handleVariancePercent = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
632
                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
633
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
634
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
635
                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
636
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
637 638 639 640
            } 
            return total
        }

Riri Novita's avatar
Riri Novita committed
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
        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
705
            console.log(tableMeta.columnIndex + type)
Riri Novita's avatar
Riri Novita committed
706 707 708 709
            return a

        }

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

Riri Novita's avatar
Riri Novita committed
1601 1602 1603 1604 1605 1606 1607 1608 1609 1610
        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
1611

Deni Rinaldi's avatar
Deni Rinaldi committed
1612 1613 1614
        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
1615
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report Submission</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1616
                </div>
Riri Novita's avatar
Riri Novita committed
1617 1618 1619 1620 1621
                <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
1622
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Riri Novita's avatar
Riri Novita committed
1623 1624 1625 1626
                    {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
1627
                            </div>
Riri Novita's avatar
Riri Novita committed
1628 1629 1630 1631 1632 1633
                            <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
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645
                                                        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
1646 1647 1648 1649 1650
                                        </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
1651
                                            {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
1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664
                                                <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
1665
                                            {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
1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695
                                                <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" />
                                            <a data-tip={'Download'} data-for="download">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.downloadAllData()}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                        </div>
                                    </div>
                                </div>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1696

Riri Novita's avatar
Riri Novita committed
1697 1698
                                <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
1699 1700 1701
                                    {!this.state.loading &&
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                        
Deni Rinaldi's avatar
Deni Rinaldi committed
1702
                                        <MUIDataTable
Riri Novita's avatar
Riri Novita committed
1703
                                            data={dataTable2}
Deni Rinaldi's avatar
Deni Rinaldi committed
1704 1705 1706 1707
                                            columns={columns}
                                            options={options}
                                        />
                                    </MuiThemeProvider>
Riri Novita's avatar
Riri Novita committed
1708
                                    }
Riri Novita's avatar
Riri Novita committed
1709 1710
                                </div>
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
Riri Novita's avatar
Riri Novita committed
1711
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notesUpdate}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1712
                            </div>
Riri Novita's avatar
Riri Novita committed
1713
                            <div className="grid grid-2x">
Riri Novita's avatar
Riri Novita committed
1714
                                <div className="col-1" style={{ paddingLeft: 20 }}>
Riri Novita's avatar
Riri Novita committed
1715
                                    <button
Riri Novita's avatar
Riri Novita committed
1716
                                        className="button"
Riri Novita's avatar
Riri Novita committed
1717 1718 1719 1720 1721 1722
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                        }}
Riri Novita's avatar
Riri Novita committed
1723 1724 1725 1726 1727 1728
                                        onClick={() => this.setState({ loading: true }, () => { 
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                                this.props.getReport()
                                            }, 100);
                                        })}
Riri Novita's avatar
Riri Novita committed
1729 1730 1731 1732 1733 1734
                                    >
                                        <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
1735 1736
                                {!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
1737 1738 1739 1740 1741 1742
                                        type="button"
                                        onClick={() => {
                                            this.setState({loading: true}, () => {
                                                this.handleGetFor('edit')
                                            })
                                        }}
Riri Novita's avatar
Riri Novita committed
1743
                                        style={{ marginRight: 21 }}
d.arizona's avatar
d.arizona committed
1744 1745 1746 1747 1748 1749
                                    >
                                        <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
1750
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1751 1752
                                        onClick={() =>
                                            this.setState({ loading: true, editable: false }, () => {
Riri Novita's avatar
Riri Novita committed
1753
                                                setTimeout(() => {
Riri Novita's avatar
Riri Novita committed
1754
                                                    this.handleValidate()
Riri Novita's avatar
Riri Novita committed
1755
                                                    // this.setState({ loading: false, buttonError: false })
Riri Novita's avatar
Riri Novita committed
1756 1757
                                                }, 100);
                                            })
Riri Novita's avatar
Riri Novita committed
1758 1759
                                        }
                                        style={{ marginRight: 20 }}
Riri Novita's avatar
Riri Novita committed
1760 1761 1762 1763
                                    >
                                        <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
1764 1765
                                    </button>}
                                    {this.state.get_for == 'edit' && <button
Riri Novita's avatar
Riri Novita committed
1766 1767
                                        className="button"
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1768
                                        // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1769 1770
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1771
                                            cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1772 1773 1774 1775
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
Riri Novita's avatar
Riri Novita committed
1776
                                        onClick={() =>
Riri Novita's avatar
Riri Novita committed
1777
                                            this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1778 1779 1780 1781 1782 1783 1784
                                                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
1785 1786
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1787
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
Riri Novita's avatar
Riri Novita committed
1788
                                        </div>
d.arizona's avatar
d.arizona committed
1789 1790
                                    </button>}
                                    {this.state.get_for == 'edit' && <button
Riri Novita's avatar
Riri Novita committed
1791
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1792 1793 1794 1795 1796 1797 1798 1799 1800 1801
                                        // 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
1802 1803
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1804
                                            cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1805 1806
                                            borderColor: 'transparent',
                                            outline: 'none',
Riri Novita's avatar
Riri Novita committed
1807
                                            marginRight: 20
Riri Novita's avatar
Riri Novita committed
1808 1809 1810
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1811
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
Riri Novita's avatar
Riri Novita committed
1812
                                        </div>
d.arizona's avatar
d.arizona committed
1813
                                    </button>}
Riri Novita's avatar
Riri Novita committed
1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824
                                </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
1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836
                                                        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
1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852
                                        </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
1853
                                <div className="grid grid-2x" style={{ marginLeft: 10 }}>
Riri Novita's avatar
Riri Novita committed
1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865
                                    <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
1866
                                                        this.getItemHierarki()
Riri Novita's avatar
Riri Novita committed
1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880
                                                    }, 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
1881 1882
                                                        this.handleValidate()
                                                        // this.setState({ loading: false, buttonError: false })
Riri Novita's avatar
Riri Novita committed
1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896
                                                    }, 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
1897
                                                cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1898 1899 1900 1901
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Riri Novita's avatar
Riri Novita committed
1902
                                            // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1903
                                            onClick={() =>
Riri Novita's avatar
Riri Novita committed
1904 1905 1906 1907
                                                this.state.saveDraft === true ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    : 
                                                    this.setState({ loading: true }, () => {
Riri Novita's avatar
Riri Novita committed
1908 1909 1910 1911 1912 1913
                                                        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
1914
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
Riri Novita's avatar
Riri Novita committed
1915 1916 1917
                                            </div>
                                        </button>
                                        <button
Riri Novita's avatar
Riri Novita committed
1918
                                            className="button"
Riri Novita's avatar
Riri Novita committed
1919
                                            type="button"
Riri Novita's avatar
Riri Novita committed
1920
                                            // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1921 1922
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1923
                                                cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1924 1925 1926 1927
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Riri Novita's avatar
Riri Novita committed
1928 1929 1930 1931 1932 1933 1934 1935 1936 1937
                                            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
1938 1939
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1940
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
Riri Novita's avatar
Riri Novita committed
1941 1942 1943
                                            </div>
                                        </button>
                                    </div>}
Riri Novita's avatar
Riri Novita committed
1944 1945
                                </div>
                            </div>
Riri Novita's avatar
Riri Novita committed
1946
                        </Paper>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1947
                </div>
Riri Novita's avatar
Riri Novita committed
1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977

                {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
1978
                                    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
1979 1980 1981 1982 1983 1984 1985
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
1986
            </div>
Riri Novita's avatar
Riri Novita committed
1987
        );
Deni Rinaldi's avatar
Deni Rinaldi committed
1988 1989
    }
}