OperatingIndicatorMR.js 139 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';
Riri Novita's avatar
Riri Novita committed
14
import { fixNumber, titleCase } from '../../library/Utils';
Deni Rinaldi's avatar
Deni Rinaldi committed
15 16 17 18 19 20 21 22 23 24

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

Riri Novita's avatar
Riri Novita committed
25 26 27 28 29 30 31 32 33
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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
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
57
            loading: true,
Riri Novita's avatar
Riri Novita committed
58
            visibleOI: true,
Riri Novita's avatar
Riri Novita committed
59
            minValue: 0,
Riri Novita's avatar
Riri Novita committed
60
            maxValue: 0,
Riri Novita's avatar
Riri Novita committed
61
            updateBy: [],
Riri Novita's avatar
Riri Novita committed
62
            notesUpdate: '-',
Riri Novita's avatar
Riri Novita committed
63 64 65
            disabledSave: true,
            editable: true,
            emptyData: false,
d.arizona's avatar
d.arizona committed
66
            templateNull: true,
Riri Novita's avatar
Riri Novita committed
67
            judulColumn: null,
Riri Novita's avatar
Riri Novita committed
68
            saveDraft: true,
Riri Novita's avatar
Riri Novita committed
69 70 71 72 73 74 75
            viewOnly: true,
            get_for: 'view',
            defaultCurrencyUpload: this.props.defaultCurrency,
            visibleAlertSave: false,
            alert: false,
            tipeAlert: '',
            messageAlert: '',
Riri Novita's avatar
Riri Novita committed
76 77
            defaultCurrencyUpload: this.props.defaultCurrency,
            visibleAlertSave: false
Deni Rinaldi's avatar
Deni Rinaldi committed
78
        }
Riri Novita's avatar
Riri Novita committed
79 80 81 82 83 84
        this.fileHandler = this.fileHandler.bind(this);
    }

    componentDidMount() {
        // this.getItemHierarki()
        this.getSettingControl()
Riri Novita's avatar
Riri Novita committed
85
        this.handleViewOnly()
Riri Novita's avatar
Riri Novita committed
86
        // this.getLatestUpdate()
Deni Rinaldi's avatar
Deni Rinaldi committed
87 88
    }

Riri Novita's avatar
Riri Novita committed
89
    handleViewOnly() {
Riri Novita's avatar
Riri Novita committed
90 91
        let checkCreate = this.props.permission.create
        let checkEdit = this.props.permission.edit
Riri Novita's avatar
Riri Novita committed
92
        let checkStatus = true
Riri Novita's avatar
Riri Novita committed
93

Riri Novita's avatar
Riri Novita committed
94 95 96 97
        if (String(this.props.data.status).toLocaleUpperCase() === 'CLOSED') {
            checkStatus = false
        }

Riri Novita's avatar
Riri Novita committed
98
        this.setState({ viewOnly: checkCreate && checkEdit && checkStatus })
Riri Novita's avatar
Riri Novita committed
99 100
    }

d.arizona's avatar
d.arizona committed
101
    handleGetFor(type) {
Riri Novita's avatar
Riri Novita committed
102
        this.setState({ get_for: type }, () => {
d.arizona's avatar
d.arizona committed
103
            this.getSettingControl()
Riri Novita's avatar
Riri Novita committed
104
            // this.getLatestUpdate()
d.arizona's avatar
d.arizona committed
105 106 107
        })
    }

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

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

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

Deni Rinaldi's avatar
Deni Rinaldi committed
210
    getItemHierarki() {
Riri Novita's avatar
Riri Novita committed
211
        this.setState({ loading: true })
Riri Novita's avatar
Riri Novita committed
212
        let payload = {
Riri Novita's avatar
Riri Novita committed
213
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
214 215 216
            "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
217
            "months": this.props.months,
Riri Novita's avatar
Riri Novita committed
218 219
            "get_for": this.state.get_for,
            "currency_id": this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
220
        }
Riri Novita's avatar
Riri Novita committed
221
        console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
222
        api.create().getHierarkiMontlyReportOI(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
223
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
224
            let dataTable = []
Riri Novita's avatar
Riri Novita committed
225 226
            let err = false

Deni Rinaldi's avatar
Deni Rinaldi committed
227 228 229 230
            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
231 232 233 234
                    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
Riri Novita's avatar
Riri Novita committed
235
                        }
Riri Novita's avatar
Riri Novita committed
236 237 238 239 240
                        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
241 242 243 244 245 246 247 248
                    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
249
                            item.uom === "" ? null : item.uom,
Riri Novita's avatar
Riri Novita committed
250
                            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
251
                            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
252 253 254 255 256 257
                            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
258 259
                            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
260
                            item.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
261 262 263 264 265 266 267 268 269 270 271
                        ])
                    }
                    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
272 273 274 275
                    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
Riri Novita's avatar
Riri Novita committed
276
                        }
Riri Novita's avatar
Riri Novita committed
277 278 279 280 281
                        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
282 283 284 285 286 287 288
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
Riri Novita's avatar
Riri Novita committed
289
                        item.uom === "" ? null : item.uom,
Riri Novita's avatar
Riri Novita committed
290
                        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
291
                        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
292 293 294 295 296 297
                        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
298 299
                        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
300
                        item.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
301 302 303 304 305 306 307 308 309
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
Riri Novita's avatar
Riri Novita committed
310 311 312 313
                if (err === true) {
                    this.setState({ bebas: true })
                }
                this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true }, () => {
Riri Novita's avatar
Riri Novita committed
314 315 316 317
                    if (this.state.dataTable.length == 0) {
                        this.setState({ emptyData: true })
                    }
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
318
            }
Riri Novita's avatar
Riri Novita committed
319
            console.log(dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
320 321
        })
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
322

Riri Novita's avatar
Riri Novita committed
323 324
    downloadTemplate = async () => {
        let res = await fetch(
325
            `${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}&&months=${this.props.months}&&currency_id=${this.props.defaultCurrency.id}`
Riri Novita's avatar
Riri Novita committed
326 327
        )
        res = await res.blob()
Riri Novita's avatar
Riri Novita committed
328
        // // console.log(res)
Riri Novita's avatar
Riri Novita committed
329 330 331 332 333 334 335 336 337 338
        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
339
        // console.log(this.props.months);
Riri Novita's avatar
Riri Novita committed
340
        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
341 342
        console.log(url);
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
343
            `${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
344 345 346 347 348 349 350 351 352 353 354 355
        )
        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
356
    createData(type) {
Riri Novita's avatar
Riri Novita committed
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
        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
375
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
376 377
            "report_id": this.props.data.report_id,
            "company_id": this.props.data.company.company_id,
Riri Novita's avatar
Riri Novita committed
378
            "currency_id": this.props.defaultCurrency.id,
Riri Novita's avatar
Riri Novita committed
379
            "periode": this.props.data.periode,
Riri Novita's avatar
Riri Novita committed
380
            "status": type,
Riri Novita's avatar
Riri Novita committed
381
            "months": this.props.months,
Riri Novita's avatar
Riri Novita committed
382
            "monthly_report": data
Riri Novita's avatar
Riri Novita committed
383
        }
Riri Novita's avatar
Riri Novita committed
384 385
        console.log(payload);
        // // console.log('=========================')
Riri Novita's avatar
Riri Novita committed
386
        console.log(JSON.stringify(payload))
Riri Novita's avatar
Riri Novita committed
387
        this.props.saveMonthlyOI(payload)
Riri Novita's avatar
Riri Novita committed
388
        // this.props.onClickClose()
Riri Novita's avatar
Riri Novita committed
389 390
    }

Riri Novita's avatar
Riri Novita committed
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
    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
411 412
                            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
413 414 415 416 417 418 419
                        })
                    }
                })
                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
420
                    months: this.props.months,
Riri Novita's avatar
Riri Novita committed
421
                    status: 'submitted',
Riri Novita's avatar
Riri Novita committed
422 423 424
                    monthly_report: payload
                }
                console.log(body)
Riri Novita's avatar
Riri Novita committed
425
                console.log(JSON.stringify(body));
Riri Novita's avatar
Riri Novita committed
426
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
Riri Novita's avatar
Riri Novita committed
427 428 429 430 431
            }
        });
    }

    checkUpload() {
Riri Novita's avatar
Riri Novita committed
432 433 434 435 436
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        api.create().checkUploadMonthlyReportOI(payload).then(response => {
Riri Novita's avatar
Riri Novita committed
437 438 439 440 441 442
            // 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
443
                    let err = false
Riri Novita's avatar
Riri Novita committed
444 445
                    let dataTable = response.data.data.map((item, index) => {
                        console.log(item);
Riri Novita's avatar
Riri Novita committed
446 447 448
                        if (item.type_report_id != null) {
                            total += 1
                        }
Riri Novita's avatar
Riri Novita committed
449 450 451 452
                        // 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
qorri_di's avatar
qorri_di committed
453
                        //     } 
Riri Novita's avatar
Riri Novita committed
454 455 456 457 458
                        //     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
459 460 461 462 463 464 465 466 467 468 469 470
                        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
471 472 473 474 475 476 477 478
                            // 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
479 480 481 482 483
                            item.mtd_vs_mb,
                            item.mtd_vs_rb,
                            item.order,
                            item.error
                        ]
Riri Novita's avatar
Riri Novita committed
484
                    })
Riri Novita's avatar
Riri Novita committed
485
                    console.log(dataTable);
Riri Novita's avatar
Riri Novita committed
486
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, templateNull: total > 0 ? true : false })
Riri Novita's avatar
Riri Novita committed
487 488
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
489
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
490 491 492 493 494 495
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Riri Novita's avatar
Riri Novita committed
496 497 498 499 500 501 502
                }
            }
        })
    }

    uploadOI(type) {
        let data = []
Riri Novita's avatar
Riri Novita committed
503
        // console.log(this.state.dataTable)
Riri Novita's avatar
Riri Novita committed
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    uom: String(i[6]),
                    rolling_outlook: String(Number(i[7])),
                    master_budget: String(Number(i[8])),
                    rolling_budget: String(Number(i[9])),
                    actual: String(Number(i[10])),
                    amount_act_vs_mb: String(Number(i[11])),
                    percent_act_vs_mb: String(Number(i[12])),
                    amount_act_vs_rb: String(Number(i[13])),
                    percent_act_vs_rb: String(Number(i[14])),
                    mtd_vs_mb: String(i[15]),
                    mtd_vs_rb: String(i[16]),
                })
Riri Novita's avatar
Riri Novita committed
520
            })
Riri Novita's avatar
Riri Novita committed
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    uom: String(i[6]),
                    rolling_outlook: String(fixNumber(Number(i[7]), 1)),
                    master_budget: String(fixNumber(Number(i[8]), 1)),
                    rolling_budget: String(fixNumber(Number(i[9]), 1)),
                    actual: String(fixNumber(Number(i[10]), 1)),
                    amount_act_vs_mb: String(fixNumber(Number(i[11]), 1)),
                    percent_act_vs_mb: String(fixNumber(Number(i[12]), 1)),
                    amount_act_vs_rb: String(fixNumber(Number(i[13]), 1)),
                    percent_act_vs_rb: String(fixNumber(Number(i[14]), 1)),
                    mtd_vs_mb: String(i[15]),
                    mtd_vs_rb: String(i[16]),
                })
            })
        }

Riri Novita's avatar
Riri Novita committed
540 541
        let body = {
            company_id: this.props.data.company.company_id,
Riri Novita's avatar
Riri Novita committed
542
            operating_indicator_id: this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
543 544 545
            periode: this.props.data.periode,
            report_id: this.props.data.report_id,
            status: type,
Riri Novita's avatar
Riri Novita committed
546
            months: this.props.months,
Riri Novita's avatar
Riri Novita committed
547
            currency_id: this.props.defaultCurrency.id,
Riri Novita's avatar
Riri Novita committed
548 549
            monthly_report: data
        }
Riri Novita's avatar
Riri Novita committed
550 551
        // console.log(body);
        // console.log(JSON.stringify(body))
Riri Novita's avatar
Riri Novita committed
552 553 554 555 556 557 558 559
        api.create('UPLOAD').uploadMonthlyReportOI(body).then(response => {
            // // console.log(response);
            this.setState({ loading: false })
            if (response.data) {
                if (response.data.status === "success") {
                    this.props.onClickClose()
                    this.props.getReport()
                } else {
Riri Novita's avatar
Riri Novita committed
560 561 562 563 564 565 566 567 568 569 570 571
                    if (response.data.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true, loading: false })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
Riri Novita's avatar
Riri Novita committed
572
                }
Riri Novita's avatar
Riri Novita committed
573 574
            } else {
                alert(response.problem)
Riri Novita's avatar
Riri Novita committed
575 576 577 578
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
579 580 581 582
    handleValidate() {
        let data = []
        let err = false
        this.state.dataTable.map((i, index) => {
Riri Novita's avatar
Riri Novita committed
583 584 585 586 587 588 589 590 591
            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
592
            data.push({
Riri Novita's avatar
Riri Novita committed
593 594 595 596 597 598 599 600 601 602 603 604
                "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]
Riri Novita's avatar
Riri Novita committed
605 606 607 608 609
            })
        })

        // console.log(JSON.stringify(data))
        let payload = {
Riri Novita's avatar
Riri Novita committed
610
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
611 612 613 614
            "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
615
            "months": this.props.months,
Riri Novita's avatar
Riri Novita committed
616
            "currency_id": this.props.defaultCurrency.id,
Riri Novita's avatar
Riri Novita committed
617 618 619 620 621 622 623 624 625 626 627 628 629 630
            "monthly_report": data
        }
        // console.log(JSON.stringify(payload));
        api.create().validateSubmitReportOI(payload).then((response) => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    if (response.data.data.result && err === false) {
                        this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
                    } else {
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
631
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
632 633 634 635 636 637 638 639 640 641 642 643 644
                            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
645 646 647 648
    closeAlert() {
        this.setState({ alert: false })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
649
    render() {
Riri Novita's avatar
Riri Novita committed
650
        let dataTable2 = this.state.dataTable
Riri Novita's avatar
Riri Novita committed
651 652 653 654 655

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

Riri Novita's avatar
Riri Novita committed
656 657 658 659 660 661 662 663 664
        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])
Riri Novita's avatar
Riri Novita committed
665
            dataTable2[data.rowIndex][data.columnIndex + type] = this.props.defaultCurrency == 1 ? fixNumber(Number(total), 1) : Number(total)
Riri Novita's avatar
Riri Novita committed
666 667 668 669 670 671 672 673
            // console.log(indexParent);
            return total
        }

        const handleChange = (value, tableMeta, type) => {
            console.log(dataTable2);
            let val = String(value).split(",").join("")
            if (type === "actual") {
Riri Novita's avatar
Riri Novita committed
674
                dataTable2[tableMeta.rowIndex][10] = this.props.defaultCurrency == 1 ? fixNumber(Number(val), 1) : Number(val)
Riri Novita's avatar
Riri Novita committed
675 676 677
            } else {
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
Riri Novita's avatar
Riri Novita committed
678 679 680
                    dataTable2[tableMeta.rowIndex][10] = this.props.defaultCurrency == 1 ? fixNumber(Number(val), 1) : Number(val)
                    let jagain = this.props.defaultCurrency == 1 ? fixNumber(Number(dataTable2[indexParent][10]), 1) : Number(dataTable2[indexParent][10])
                    dataTable2[indexParent][10] = this.props.defaultCurrency == 1 ? (jagain === undefined ? fixNumber((0 + Number(val)), 1) : Number(Number(jagain) + fixNumber(Number(val)), 1)) : (jagain === undefined ? (0 + Number(val)) : Number(Number(jagain) + Number(val)))
Riri Novita's avatar
Riri Novita committed
681

Riri Novita's avatar
Riri Novita committed
682
                } else {
Riri Novita's avatar
Riri Novita committed
683
                    dataTable2[tableMeta.rowIndex][10] = this.props.defaultCurrency == 1 ? fixNumber(Number(val), 1) : Number(val)
Riri Novita's avatar
Riri Novita committed
684 685 686 687 688 689 690
                }
            }
        }

        const handleVariance = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
691 692
                total = Number(tableMeta.rowData[10]) - (this.props.defaultCurrency == 1 ? fixNumber(Number(tableMeta.rowData[8]), 1) : Number(tableMeta.rowData[8]))
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency == 1 ? fixNumber(Number(total), 1) : Number(total)
Riri Novita's avatar
Riri Novita committed
693
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
694 695
                total = Number(tableMeta.rowData[10]) - (this.props.defaultCurrency == 1 ? fixNumber(Number(tableMeta.rowData[9]), 1) : Number(tableMeta.rowData[9]))
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency == 1 ? fixNumber(Number(total), 1) : Number(total)
Riri Novita's avatar
Riri Novita committed
696
            }
Riri Novita's avatar
Riri Novita committed
697 698 699 700 701 702
            return total
        }

        const handleVariancePercent = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
703
                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)
Riri Novita's avatar
Riri Novita committed
704
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency == 1 ? fixNumber(Number(total), 1) : Number(total)
Riri Novita's avatar
Riri Novita committed
705
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
706
                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)
Riri Novita's avatar
Riri Novita committed
707
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = this.props.defaultCurrency == 1 ? fixNumber(Number(total), 1) : Number(total)
Riri Novita's avatar
Riri Novita committed
708
            }
Riri Novita's avatar
Riri Novita committed
709 710 711
            return total
        }

Riri Novita's avatar
Riri Novita committed
712 713 714 715 716 717 718 719
        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') {
Riri Novita's avatar
Riri Novita committed
720
                    tambahan = true
Riri Novita's avatar
Riri Novita committed
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 775
                } 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
776
            console.log(tableMeta.columnIndex + type)
Riri Novita's avatar
Riri Novita committed
777 778 779 780
            return a

        }

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

Riri Novita's avatar
Riri Novita committed
1670 1671 1672 1673 1674 1675 1676 1677 1678 1679
        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
1680

Deni Rinaldi's avatar
Deni Rinaldi committed
1681 1682 1683
        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
1684
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report Submission</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1685
                </div>
Riri Novita's avatar
Riri Novita committed
1686 1687 1688 1689 1690
                <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
1691
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
Riri Novita's avatar
Riri Novita committed
1692 1693 1694 1695
                    {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
1696
                            </div>
Riri Novita's avatar
Riri Novita committed
1697 1698 1699 1700 1701 1702
                            <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
1703 1704
                                                this.props.months === 1 ? 'JAN' :
                                                    this.props.months === 2 ? 'FEB' :
qorri_di's avatar
qorri_di committed
1705
                                                        this.props.months === 3 ? 'MAR' :
Riri Novita's avatar
Riri Novita committed
1706 1707 1708 1709 1710 1711 1712 1713 1714
                                                            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
1715
                                        </Typography>
Riri Novita's avatar
Riri Novita committed
1716 1717 1718 1719 1720
                                        {this.props.defaultCurrency.id === 1 ?
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                            :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                        }
Riri Novita's avatar
Riri Novita committed
1721 1722 1723
                                    </div>
                                    <div style={{ width: '50%' }}>
                                        <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
Riri Novita's avatar
Riri Novita committed
1724
                                            {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
1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737
                                                <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
1738
                                            {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
1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751
                                                <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" />
qorri_di's avatar
qorri_di committed
1752
                                            {/* <a data-tip={'Download'} data-for="download">
Riri Novita's avatar
Riri Novita committed
1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.downloadAllData()}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
qorri_di's avatar
qorri_di committed
1765
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
Riri Novita's avatar
Riri Novita committed
1766 1767 1768
                                        </div>
                                    </div>
                                </div>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1769

Riri Novita's avatar
Riri Novita committed
1770 1771
                                <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
1772 1773
                                    {!this.state.loading &&
                                        <MuiThemeProvider theme={getMuiTheme()}>
Riri Novita's avatar
Riri Novita committed
1774 1775 1776 1777 1778 1779 1780

                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
Riri Novita's avatar
Riri Novita committed
1781
                                    }
1782
                                    {this.state.get_for == 'view' && this.state.viewOnly && <div style={{ color: '#000', marginTop: 10, fontSize: 12 }}>(*) There may be discrepancies in amount due to rounding</div>}
Riri Novita's avatar
Riri Novita committed
1783
                                </div>
Riri Novita's avatar
Riri Novita committed
1784 1785 1786 1787 1788
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
                                        {
                                            this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
qorri_di's avatar
qorri_di committed
1789 1790 1791 1792
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
Riri Novita's avatar
Riri Novita committed
1793
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
Riri Novita's avatar
Riri Novita committed
1794 1795 1796
                                        }
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
1797
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notesUpdate}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1798
                            </div>
Riri Novita's avatar
Riri Novita committed
1799
                            <div className="grid grid-2x">
Riri Novita's avatar
Riri Novita committed
1800
                                <div className="col-1" style={{ paddingLeft: 20 }}>
Riri Novita's avatar
Riri Novita committed
1801
                                    <button
Riri Novita's avatar
Riri Novita committed
1802
                                        className="button"
Riri Novita's avatar
Riri Novita committed
1803 1804 1805 1806 1807 1808
                                        type="button"
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                        }}
Riri Novita's avatar
Riri Novita committed
1809
                                        onClick={() => this.setState({ loading: true }, () => {
Riri Novita's avatar
Riri Novita committed
1810 1811 1812 1813 1814
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                                this.props.getReport()
                                            }, 100);
                                        })}
Riri Novita's avatar
Riri Novita committed
1815 1816 1817 1818 1819 1820
                                    >
                                        <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
1821 1822
                                {!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
1823 1824
                                        type="button"
                                        onClick={() => {
Riri Novita's avatar
Riri Novita committed
1825
                                            this.setState({ loading: true }, () => {
d.arizona's avatar
d.arizona committed
1826 1827 1828
                                                this.handleGetFor('edit')
                                            })
                                        }}
Riri Novita's avatar
Riri Novita committed
1829
                                        style={{ marginRight: 21 }}
d.arizona's avatar
d.arizona committed
1830 1831 1832 1833 1834 1835
                                    >
                                        <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
1836
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1837 1838
                                        onClick={() =>
                                            this.setState({ loading: true, editable: false }, () => {
Riri Novita's avatar
Riri Novita committed
1839
                                                setTimeout(() => {
Riri Novita's avatar
Riri Novita committed
1840
                                                    this.handleValidate()
Riri Novita's avatar
Riri Novita committed
1841
                                                    // this.setState({ loading: false, buttonError: false })
Riri Novita's avatar
Riri Novita committed
1842 1843
                                                }, 100);
                                            })
Riri Novita's avatar
Riri Novita committed
1844 1845
                                        }
                                        style={{ marginRight: 20 }}
Riri Novita's avatar
Riri Novita committed
1846 1847 1848 1849
                                    >
                                        <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
1850 1851
                                    </button>}
                                    {this.state.get_for == 'edit' && <button
Riri Novita's avatar
Riri Novita committed
1852 1853
                                        className="button"
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1854
                                        // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1855 1856
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1857
                                            cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1858 1859 1860 1861
                                            borderColor: 'transparent',
                                            outline: 'none',
                                            marginRight: 20
                                        }}
Riri Novita's avatar
Riri Novita committed
1862
                                        onClick={() =>
Riri Novita's avatar
Riri Novita committed
1863
                                            this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1864 1865 1866 1867 1868 1869 1870
                                                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
1871 1872
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1873
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
Riri Novita's avatar
Riri Novita committed
1874
                                        </div>
d.arizona's avatar
d.arizona committed
1875 1876
                                    </button>}
                                    {this.state.get_for == 'edit' && <button
Riri Novita's avatar
Riri Novita committed
1877
                                        type="button"
Riri Novita's avatar
Riri Novita committed
1878
                                        // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1879
                                        onClick={() =>
Riri Novita's avatar
Riri Novita committed
1880 1881 1882 1883 1884 1885 1886
                                            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
1887
                                                })}
Riri Novita's avatar
Riri Novita committed
1888 1889
                                        style={{
                                            backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1890
                                            cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1891 1892
                                            borderColor: 'transparent',
                                            outline: 'none',
Riri Novita's avatar
Riri Novita committed
1893
                                            marginRight: 20
Riri Novita's avatar
Riri Novita committed
1894 1895 1896
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
1897
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
Riri Novita's avatar
Riri Novita committed
1898
                                        </div>
d.arizona's avatar
d.arizona committed
1899
                                    </button>}
Riri Novita's avatar
Riri Novita committed
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910
                                </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
1911 1912
                                                this.props.months === 1 ? 'JAN' :
                                                    this.props.months === 2 ? 'FEB' :
qorri_di's avatar
qorri_di committed
1913
                                                        this.props.months === 3 ? 'MAR' :
Riri Novita's avatar
Riri Novita committed
1914 1915 1916 1917 1918 1919 1920 1921 1922
                                                            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
1923
                                        </Typography>
Riri Novita's avatar
Riri Novita committed
1924 1925 1926 1927 1928
                                        {this.props.defaultCurrency.id === 1 ?
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                            :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                        }
Riri Novita's avatar
Riri Novita committed
1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942
                                    </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
1943
                                <div className="grid grid-2x" style={{ marginLeft: 10 }}>
Riri Novita's avatar
Riri Novita committed
1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955
                                    <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
1956
                                                        this.getItemHierarki()
Riri Novita's avatar
Riri Novita committed
1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970
                                                    }, 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
1971 1972
                                                        this.handleValidate()
                                                        // this.setState({ loading: false, buttonError: false })
Riri Novita's avatar
Riri Novita committed
1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986
                                                    }, 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
1987
                                                cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
1988 1989 1990 1991
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Riri Novita's avatar
Riri Novita committed
1992
                                            // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
1993
                                            onClick={() =>
Riri Novita's avatar
Riri Novita committed
1994 1995
                                                this.state.saveDraft === true ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
Riri Novita's avatar
Riri Novita committed
1996
                                                    :
Riri Novita's avatar
Riri Novita committed
1997
                                                    this.setState({ loading: true }, () => {
Riri Novita's avatar
Riri Novita committed
1998 1999 2000 2001 2002 2003
                                                        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
2004
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
Riri Novita's avatar
Riri Novita committed
2005 2006 2007
                                            </div>
                                        </button>
                                        <button
Riri Novita's avatar
Riri Novita committed
2008
                                            className="button"
Riri Novita's avatar
Riri Novita committed
2009
                                            type="button"
Riri Novita's avatar
Riri Novita committed
2010
                                            // disabled={this.state.editable}
Riri Novita's avatar
Riri Novita committed
2011 2012
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2013
                                                cursor: 'pointer',
Riri Novita's avatar
Riri Novita committed
2014 2015 2016 2017
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
Riri Novita's avatar
Riri Novita committed
2018 2019
                                            onClick={() =>
                                                this.state.editable === true ?
Riri Novita's avatar
Riri Novita committed
2020
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
Riri Novita's avatar
Riri Novita committed
2021 2022 2023 2024 2025 2026
                                                    :
                                                    this.setState({ loading: true }, () => {
                                                        setTimeout(() => {
                                                            this.uploadOI("submitted")
                                                        }, 100);
                                                    })}
Riri Novita's avatar
Riri Novita committed
2027

Riri Novita's avatar
Riri Novita committed
2028 2029
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
Riri Novita's avatar
Riri Novita committed
2030
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
Riri Novita's avatar
Riri Novita committed
2031 2032 2033
                                            </div>
                                        </button>
                                    </div>}
Riri Novita's avatar
Riri Novita committed
2034 2035
                                </div>
                            </div>
Riri Novita's avatar
Riri Novita committed
2036
                        </Paper>}
Deni Rinaldi's avatar
Deni Rinaldi committed
2037
                </div>
Riri Novita's avatar
Riri Novita committed
2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057

                {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>
Riri Novita's avatar
Riri Novita committed
2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074
                            <div style={{ padding: '25px 30px' }}>
                                <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={() => {
                                        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") ?
                                            this.checkUpload() :
                                            this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                    }}
                                />
                            </div>
2075
                            <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data in <b>{this.props.defaultCurrency.id == 1 ? "IDR mn" : "thousand USD"}</b></div>
Riri Novita's avatar
Riri Novita committed
2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103
                        </div>
                    </div>
                )}

                {this.state.visibleAlertSave && (
                    <div className="test app-popup-show">
                        <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
                            <div style={{ margin: 30 }}>
                                <div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
                                    <div style={{ alignSelf: 'center', marginRight: 25 }}>
                                        <img src={Images.warning} />
                                    </div>
                                    <div style={{ justifyContent: 'center', fontSize: 20, color: '#1D2995', marginTop: 10 }}>
                                        <b>Rate Currency USD</b> pada periode yang dipilih <b>belum</b> diatur.<br /> Silahkan menghubungi Superadmin
                                    </div>
                                </div>
                                <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            background: '#F6F7F9',
                                            cursor: 'pointer',
                                            border: '1px solid #3549609e',
                                            outline: 'none',
                                            marginRight: 20,
                                            borderRadius: 9
                                        }}
2104
                                        onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0, loading: false })}
Riri Novita's avatar
Riri Novita committed
2105 2106 2107 2108 2109 2110 2111
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 9, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
                                            <Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
                                        </div>
                                    </button>
                                </div>
                            </div>
Riri Novita's avatar
Riri Novita committed
2112 2113 2114
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2115
            </div>
Riri Novita's avatar
Riri Novita committed
2116
        );
Deni Rinaldi's avatar
Deni Rinaldi committed
2117 2118
    }
}