OperatingIndicatorMR.js 140 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
    getSettingControl() {
        let body = {
            group: 'THRESHOLD_VARIANCE',
            company_id: this.props.company.company_id,
Riri Novita's avatar
Riri Novita committed
145 146
            type: 'BALANCE_SHEET',
            currency_id: this.props.defaultCurrency.id,
Riri Novita's avatar
Riri Novita committed
147 148 149
        }

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

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

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

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

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

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

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

    uploadOI(type) {
        let data = []
Riri Novita's avatar
Riri Novita committed
504
        // console.log(this.state.dataTable)
Riri Novita's avatar
Riri Novita committed
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
        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
521
            })
Riri Novita's avatar
Riri Novita committed
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
        } 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
541 542
        let body = {
            company_id: this.props.data.company.company_id,
Riri Novita's avatar
Riri Novita committed
543
            operating_indicator_id: this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
544 545 546
            periode: this.props.data.periode,
            report_id: this.props.data.report_id,
            status: type,
Riri Novita's avatar
Riri Novita committed
547
            months: this.props.months,
Riri Novita's avatar
Riri Novita committed
548
            currency_id: this.props.defaultCurrency.id,
Riri Novita's avatar
Riri Novita committed
549 550
            monthly_report: data
        }
Riri Novita's avatar
Riri Novita committed
551 552
        // console.log(body);
        // console.log(JSON.stringify(body))
Riri Novita's avatar
Riri Novita committed
553 554 555 556 557 558 559 560
        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
561 562 563 564 565 566 567 568 569 570 571 572
                    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
573
                }
Riri Novita's avatar
Riri Novita committed
574 575
            } else {
                alert(response.problem)
Riri Novita's avatar
Riri Novita committed
576 577 578 579
            }
        })
    }

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

        // console.log(JSON.stringify(data))
        let payload = {
Riri Novita's avatar
Riri Novita committed
611
            "operating_indicator_id": this.state.operatingIndIDMonthly,
Riri Novita's avatar
Riri Novita committed
612 613 614 615
            "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
616
            "months": this.props.months,
Riri Novita's avatar
Riri Novita committed
617
            "currency_id": this.props.defaultCurrency.id,
Riri Novita's avatar
Riri Novita committed
618 619 620 621 622 623 624 625 626 627 628 629 630 631
            "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
632
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
633 634 635 636 637 638 639 640 641 642 643 644 645
                            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
646 647 648 649
    closeAlert() {
        this.setState({ alert: false })
    }

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

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

Riri Novita's avatar
Riri Novita committed
657 658 659 660 661 662 663 664 665
        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
666
            dataTable2[data.rowIndex][data.columnIndex + type] = this.props.defaultCurrency == 1 ? fixNumber(Number(total), 1) : Number(total)
Riri Novita's avatar
Riri Novita committed
667 668 669 670 671 672 673 674
            // 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
675
                dataTable2[tableMeta.rowIndex][10] = this.props.defaultCurrency == 1 ? fixNumber(Number(val), 1) : Number(val)
Riri Novita's avatar
Riri Novita committed
676 677 678
            } else {
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
Riri Novita's avatar
Riri Novita committed
679 680 681
                    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
682

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

        const handleVariance = (tableMeta, dex, type) => {
            let total = 0
            if (dex === 1) {
Riri Novita's avatar
Riri Novita committed
692 693
                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
694
            } else if (dex === 2) {
Riri Novita's avatar
Riri Novita committed
695 696
                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
697
            }
Riri Novita's avatar
Riri Novita committed
698 699 700 701 702 703
            return total
        }

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

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

        }

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

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

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

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

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

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

                {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
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075
                            <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>
2076
                            <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
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 2104
                        </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
                                        }}
2105
                                        onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0, loading: false })}
Riri Novita's avatar
Riri Novita committed
2106 2107 2108 2109 2110 2111 2112
                                    >
                                        <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
2113 2114 2115
                        </div>
                    </div>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
2116
            </div>
Riri Novita's avatar
Riri Novita committed
2117
        );
Deni Rinaldi's avatar
Deni Rinaldi committed
2118 2119
    }
}