BalanceSheetOLPA.js 158 KB
Newer Older
Deni Rinaldi's avatar
Deni Rinaldi committed
1 2 3 4 5 6 7 8 9 10 11
import { createMuiTheme, MuiThemeProvider, Paper, TableCell, Tooltip, Typography, FormControlLabel, withStyles, Snackbar } from '@material-ui/core'
import { Alert } from '@material-ui/lab';
import MUIDataTable from 'mui-datatables'
import React, { Component } from 'react'
import NumberFormat from 'react-number-format';
import { PropagateLoader } from 'react-spinners';
import ReactTooltip from 'react-tooltip';
import api from '../../api';
import Images from '../../assets/Images';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
faisalhamdi's avatar
faisalhamdi committed
12 13
import * as R from 'ramda';
import Constant from '../../library/Constant';
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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

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

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
};

export default class BalanceSheetOLPA extends Component {
    constructor(props) {
        super(props)
        this.state = {
            dataTable: [],
            visibleBalanceSheet: true,
            disabledSave: true,
            editable: false,
            buttonError: false,
            judulColumn: null,
Riri Novita's avatar
Riri Novita committed
52
            updateBy: [],
53
            handleDoubleClick: 0,
faisalhamdi's avatar
faisalhamdi committed
54
            viewOnly: true,
faisalhamdi's avatar
faisalhamdi committed
55 56 57
            get_for: 'view',
            minValue: "0",
            maxValue: "0",
58 59 60
            kansas: 0,
            defaultCurrencyUpload: this.props.defaultCurrency,
            visibleAlertSave: false
Deni Rinaldi's avatar
Deni Rinaldi committed
61
        }
faisalhamdi's avatar
faisalhamdi committed
62 63
        this.handleValue = this.handleValue.bind(this)
        this.fileHandler = this.fileHandler.bind(this);
Deni Rinaldi's avatar
Deni Rinaldi committed
64 65 66
    }

    componentDidMount() {
faisalhamdi's avatar
faisalhamdi committed
67 68
        this.getLatestUpdate()
        this.handleViewOnly()
faisalhamdi's avatar
faisalhamdi committed
69
        this.getSettingControl()
Deni Rinaldi's avatar
Deni Rinaldi committed
70 71
    }

faisalhamdi's avatar
faisalhamdi committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
        let checkPrevRev = false

        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }

        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
        }

        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }

        if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
            checkStatus = true
        } else {
            checkStatus = false
        }

        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
    }

    handleGetFor(type) {
        this.setState({ get_for: type }, () => {
            this.getLatestUpdate()
faisalhamdi's avatar
faisalhamdi committed
108 109 110 111 112 113 114 115
            this.getSettingControl()
        })
    }

    getSettingControl() {
        let body = {
            group: 'THRESHOLD_CONTROL',
            company_id: this.props.company.company_id,
Riri Novita's avatar
Riri Novita committed
116 117
            type: 'BALANCE_SHEET',
            currency_id: this.props.defaultCurrency.id,
faisalhamdi's avatar
faisalhamdi committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131
        }

        api.create().getAllSettingByType(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({
                        minValue: response.data.data[0] ? response.data.data[0].min_value : null,
                        maxValue: response.data.data[0] ? response.data.data[0].max_value : null,
                    }, () => {
                        this.getItemHierarki()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
132
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
133 134 135 136 137 138 139 140 141 142
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
faisalhamdi's avatar
faisalhamdi committed
143 144 145 146
        })
    }

    getLatestUpdate() {
Deni Rinaldi's avatar
Deni Rinaldi committed
147 148 149 150
        let payload = {
            "outlook_pa_id": this.props.outlook_pa_id,
            "report_id": this.props.report_id,
            "revision": this.props.revision,
d.arizona's avatar
d.arizona committed
151
            "get_for": this.state.get_for,
Deni Rinaldi's avatar
Deni Rinaldi committed
152
            "periode": this.props.periode,
Riri Novita's avatar
Riri Novita committed
153 154
            "company_id": this.props.company.company_id,
            "currency_id": this.props.defaultCurrency.id
Deni Rinaldi's avatar
Deni Rinaldi committed
155 156
        }
        api.create().getLastestUpdateOLPA(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
157
            // console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
158 159 160
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Riri Novita's avatar
Riri Novita committed
161
                        updateBy: response.data.data.detail === null ? '-' : response.data.data.detail
Deni Rinaldi's avatar
Deni Rinaldi committed
162
                    })
faisalhamdi's avatar
faisalhamdi committed
163 164
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
165
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
166 167 168 169 170 171
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
172
                }
faisalhamdi's avatar
faisalhamdi committed
173 174
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
Deni Rinaldi's avatar
Deni Rinaldi committed
175 176 177 178
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
179 180 181
    async getItemHierarki() {
        this.setState({ loading: true, judulColumn: null })
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
182
            "outlook_pa_id": this.props.outlook_pa_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
183
            "report_id": this.props.report_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
184
            "revision": this.props.revision,
Deni Rinaldi's avatar
Deni Rinaldi committed
185
            "periode": this.props.periode,
faisalhamdi's avatar
faisalhamdi committed
186
            "company_id": this.props.company.company_id,
187 188
            "get_for": this.state.get_for,
            "currency_id": this.props.defaultCurrency.id
Deni Rinaldi's avatar
Deni Rinaldi committed
189
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
190
        let response = await api.create().getDetailReportOLPA(payload)
faisalhamdi's avatar
faisalhamdi committed
191
        console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
192
        console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
193 194 195 196 197 198 199 200 201 202 203 204 205 206
        let dataTable = []
        if (response.data) {
            let res = response.data.data
            const handlePushChild = (item) => {
                let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                if (indexIDzz === -1) {
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
                        item.balance_sheet.total_actual_before === null ? "0" : item.balance_sheet.total_actual_before === "" ? "0" : item.balance_sheet.total_actual_before,
Riri Novita's avatar
Riri Novita committed
207 208 209 210 211 212 213 214 215 216 217 218 219
                        Number(item.balance_sheet.january),
                        Number(item.balance_sheet.february),
                        Number(item.balance_sheet.march),
                        Number(item.balance_sheet.april),
                        Number(item.balance_sheet.may),
                        Number(item.balance_sheet.june),
                        Number(item.balance_sheet.july),
                        Number(item.balance_sheet.august),
                        Number(item.balance_sheet.september),
                        Number(item.balance_sheet.october),
                        this.props.status === 'CLOSED' ? Number(item.balance_sheet.november) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.november), formula: item.balance_sheet.november_formula } : Number(item.balance_sheet.november),
                        this.props.status === 'CLOSED' ? Number(item.balance_sheet.december) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.december), formula: item.balance_sheet.december_formula } : Number(item.balance_sheet.december),
                        Number(item.balance_sheet.total_current_year),
Deni Rinaldi's avatar
Deni Rinaldi committed
220
                        item.order,
Deni Rinaldi's avatar
Deni Rinaldi committed
221
                        item.condition_it_should_be,
Deni Rinaldi's avatar
Deni Rinaldi committed
222 223
                        item.condition_if_wrong,
                        item.balance_sheet.forecast_formula == null ? [] : item.balance_sheet.forecast_formula
Deni Rinaldi's avatar
Deni Rinaldi committed
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
                    ])
                }
                if (item.children !== null) {
                    if (item.children.length > 0) {
                        item.children.map((items, indexs) => {
                            handlePushChild(items)
                        })
                    }
                }
            }
            res.map((item, index) => {
                dataTable.push([
                    item.type_report_id,
                    item.id,
                    item.parent,
                    item.formula,
                    item.level,
                    item.description,
                    item.balance_sheet.total_actual_before === null ? "0" : item.balance_sheet.total_actual_before === "" ? "0" : item.balance_sheet.total_actual_before,
Riri Novita's avatar
Riri Novita committed
243 244 245 246 247 248 249 250 251 252 253 254 255
                    Number(item.balance_sheet.january),
                    Number(item.balance_sheet.february),
                    Number(item.balance_sheet.march),
                    Number(item.balance_sheet.april),
                    Number(item.balance_sheet.may),
                    Number(item.balance_sheet.june),
                    Number(item.balance_sheet.july),
                    Number(item.balance_sheet.august),
                    Number(item.balance_sheet.september),
                    Number(item.balance_sheet.october),
                    this.props.status === 'CLOSED' ? Number(item.balance_sheet.november) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.november), formula: item.balance_sheet.november_formula } : Number(item.balance_sheet.november),
                    this.props.status === 'CLOSED' ? Number(item.balance_sheet.december) : item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.balance_sheet.december), formula: item.balance_sheet.december_formula } : Number(item.balance_sheet.december),
                    Number(item.balance_sheet.total_current_year),
Deni Rinaldi's avatar
Deni Rinaldi committed
256 257
                    item.order,
                    item.condition_it_should_be,
Deni Rinaldi's avatar
Deni Rinaldi committed
258 259
                    item.condition_if_wrong,
                    item.balance_sheet.forecast_formula == null ? [] : item.balance_sheet.forecast_formula
Deni Rinaldi's avatar
Deni Rinaldi committed
260 261 262 263 264 265 266 267 268
                ])
                if (item.children !== null) {
                    if (item.children.length > 0) {
                        item.children.map((items, indexs) => {
                            handlePushChild(items)
                        })
                    }
                }
            })
faisalhamdi's avatar
faisalhamdi committed
269
            console.log(dataTable);
faisalhamdi's avatar
faisalhamdi committed
270
            this.setState({ dataTable, loading: false, buttonError: true, editable: true, saveDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
271
        } else {
faisalhamdi's avatar
faisalhamdi committed
272
            this.setState({ dataTable, loading: false, buttonError: true, editable: true, saveDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
273 274 275
        }
    }

faisalhamdi's avatar
faisalhamdi committed
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
    handleValue(data) {
        let total = 0
        this.state.dataTable.map((item, index) => {
            if (data.rowData[1] == item[2]) {
                total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
            }
        })
        let indexParent = this.state.dataTable.findIndex((val) => val[1] == this.state.dataTable[data.rowIndex][2])
        let a = this.state.dataTable[data.rowIndex][data.columnIndex] = total
        // console.log(indexParent);
        return a
    }

    handleChange(value, tableMeta) {
        let val = String(value).split(",").join("")
        let data = this.state.dataTable
        let indexParent = data.findIndex((val) => val[1] == data[tableMeta.rowIndex][2])
        if (indexParent > 0) {
            // console.log(indexParent)
            let a = data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
            let jagain = data[indexParent][tableMeta.columnIndex]
            a = data[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
        } else {
            data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
        }
    }

    backToOLPA(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
304
        let data = []
Riri Novita's avatar
Riri Novita committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    total_actual_before: String(Number(i[6])),
                    january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7])),
                    february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8])),
                    march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9])),
                    april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10])),
                    may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11])),
                    june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12])),
                    july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13])),
                    august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14])),
                    september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15])),
                    october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16])),
                    november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[17].value)) : String(Number(i[17]))),
                    december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[18].value)) : String(Number(i[18]))),
                    total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19])),
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
324
            })
Riri Novita's avatar
Riri Novita committed
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    total_actual_before: String(fixNumber(Number(i[6]), 1)),
                    january: i[0] === 3 && i[7] === "" ? "0.0" : String(fixNumber(Number(i[7]), 1)),
                    february: i[0] === 3 && i[8] === "" ? "0.0" : String(fixNumber(Number(i[8]), 1)),
                    march: i[0] === 3 && i[9] === "" ? "0.0" : String(fixNumber(Number(i[9]), 1)),
                    april: i[0] === 3 && i[10] === "" ? "0.0" : String(fixNumber(Number(i[10]), 1)),
                    may: i[0] === 3 && i[11] === "" ? "0.0" : String(fixNumber(Number(i[11]), 1)),
                    june: i[0] === 3 && i[12] === "" ? "0.0" : String(fixNumber(Number(i[12]), 1)),
                    july: i[0] === 3 && i[13] === "" ? "0.0" : String(fixNumber(Number(i[13]), 1)),
                    august: i[0] === 3 && i[14] === "" ? "0.0" : String(fixNumber(Number(i[14]), 1)),
                    september: i[0] === 3 && i[15] === "" ? "0.0" : String(fixNumber(Number(i[15]), 1)),
                    october: i[0] === 3 && i[16] === "" ? "0.0" : String(fixNumber(Number(i[16]), 1)),
                    november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(fixNumber(Number(i[17].value), 1)) : String(fixNumber(Number(i[17]), 1))),
                    december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(fixNumber(Number(i[18].value), 1)) : String(fixNumber(Number(i[18]), 1))),
                    total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(fixNumber(Number(i[19]), 1)),
                })
            })
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
346
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
347
            "outlook_pa_id": this.props.outlook_pa_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
348 349 350
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
351
            "currency_id": this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
352 353 354
            "status": type,
            "balance_sheet": data
        }
faisalhamdi's avatar
faisalhamdi committed
355
        console.log(data);
Deni Rinaldi's avatar
Deni Rinaldi committed
356
        this.setState({ loading: false })
Faisal Hamdi's avatar
Faisal Hamdi committed
357
        if (type == 'submitted') {
d.arizona's avatar
d.arizona committed
358 359 360 361 362 363 364 365 366 367 368
            this.props.saveToOLPA(payload, 'BS')
            // let bodyRatioOLPA = {
            //     "report": 'ratio',
            //     "outlookPaId": this.props.outlook_pa_id,
            //     "companyId": this.props.company.company_id,
            //     "periode": this.props.periode
            // }
            // api.create().triggerRatioOLPA(bodyRatioOLPA).then((res) => {
            //     console.log(res)
            //     this.setState({ loading: false })
            // })
Faisal Hamdi's avatar
Faisal Hamdi committed
369 370 371 372
            this.props.onClickClose()
        } else {
            this.props.saveToOLPA(payload)
            this.props.onClickClose()
Faisal Hamdi's avatar
Faisal Hamdi committed
373
        }
Faisal Hamdi's avatar
Faisal Hamdi committed
374

Deni Rinaldi's avatar
Deni Rinaldi committed
375 376 377 378
    }

    downloadTemplate = async () => {
        let res = await fetch(
379
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/outlook_pa/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&currency_id=${this.props.defaultCurrency.id}`
Deni Rinaldi's avatar
Deni Rinaldi committed
380 381
        )
        res = await res.blob()
Deni Rinaldi's avatar
Deni Rinaldi committed
382
        // console.log(res)
Deni Rinaldi's avatar
Deni Rinaldi committed
383 384 385 386
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
Deni Rinaldi's avatar
Deni Rinaldi committed
387
            a.download = 'Template Outlook PA Balance Sheet.xlsx';
Deni Rinaldi's avatar
Deni Rinaldi committed
388 389 390 391 392 393 394 395 396 397 398 399 400
            a.click();
        }
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
Deni Rinaldi's avatar
Deni Rinaldi committed
401
                // console.log(resp.rows[2]);
Deni Rinaldi's avatar
Deni Rinaldi committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
                            item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
                            item_report: i[1] === undefined ? "" : String(i[1]).trim(),
                            total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
                            january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
                            february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
                            march: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
                            april: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
                            may: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
                            june: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
                            july: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
                            august: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
                            september: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
                            october: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
                            november: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
                            december: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
                            total_current_year: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    balance_sheet: payload
                }
faisalhamdi's avatar
faisalhamdi committed
432
                console.log(body)
Deni Rinaldi's avatar
Deni Rinaldi committed
433 434 435 436 437 438
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
            }
        });
    }

    checkUpload() {
439 440 441 442 443
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        api.create().checkUploadOLPA(payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
444
            // console.log(JSON.stringify(this.state.payload));
Deni Rinaldi's avatar
Deni Rinaldi committed
445
            console.log(response)
Deni Rinaldi's avatar
Deni Rinaldi committed
446 447 448 449 450 451 452 453 454 455 456 457
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, visibleBalanceSheet: false, loading: true })
                    let dataTable = response.data.data.map((item, index) => {
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.item_report,
                            item.total_actual_before,
Riri Novita's avatar
Riri Novita committed
458 459 460 461 462 463 464 465 466 467 468 469 470
                            Number(item.january),
                            Number(item.february),
                            Number(item.march),
                            Number(item.april),
                            Number(item.may),
                            Number(item.june),
                            Number(item.july),
                            Number(item.august),
                            Number(item.september),
                            Number(item.october),
                            item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.november), formula: item.november_formula } : Number(item.november),
                            item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.december), formula: item.december_formula } : Number(item.december),
                            Number(item.total_current_year),
Deni Rinaldi's avatar
Deni Rinaldi committed
471 472 473
                            item.orders,
                            item.condition_it_should_be,
                            item.condition_if_wrong,
Deni Rinaldi's avatar
Deni Rinaldi committed
474
                            item.forecast_formula == null ? [] : item.forecast_formula,
Deni Rinaldi's avatar
Deni Rinaldi committed
475 476 477
                            item.error
                        ]
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
478
                    console.log(this.state.dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
479 480
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
                        this.state.dataTable.map(item => {
Deni Rinaldi's avatar
Deni Rinaldi committed
481
                            if (item[24].length > 0) {
faisalhamdi's avatar
faisalhamdi committed
482
                                console.log('masuk')
Deni Rinaldi's avatar
Deni Rinaldi committed
483 484 485
                                this.setState({ buttonError: true, errorPreview: true, editable: true })
                            }
                        })
faisalhamdi's avatar
faisalhamdi committed
486
                        console.log(this.state.dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
487
                    })
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);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
497 498 499 500 501 502 503
                }
            }
        })
    }

    uploadBalanceSheet(type) {
        let data = []
Riri Novita's avatar
Riri Novita committed
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    total_actual_before: String(Number(i[6])),
                    january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7])),
                    february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8])),
                    march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9])),
                    april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10])),
                    may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11])),
                    june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12])),
                    july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13])),
                    august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14])),
                    september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15])),
                    october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16])),
                    november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[17].value)) : String(Number(i[17]))),
                    december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[18].value)) : String(Number(i[18]))),
                    total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19])),
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
523
            })
Riri Novita's avatar
Riri Novita committed
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    total_actual_before: String(fixNumber(Number(i[6]), 1)),
                    january: i[0] === 3 && i[7] === "" ? "0.0" : String(fixNumber(Number(i[7]), 1)),
                    february: i[0] === 3 && i[8] === "" ? "0.0" : String(fixNumber(Number(i[8]), 1)),
                    march: i[0] === 3 && i[9] === "" ? "0.0" : String(fixNumber(Number(i[9]), 1)),
                    april: i[0] === 3 && i[10] === "" ? "0.0" : String(fixNumber(Number(i[10]), 1)),
                    may: i[0] === 3 && i[11] === "" ? "0.0" : String(fixNumber(Number(i[11]), 1)),
                    june: i[0] === 3 && i[12] === "" ? "0.0" : String(fixNumber(Number(i[12]), 1)),
                    july: i[0] === 3 && i[13] === "" ? "0.0" : String(fixNumber(Number(i[13]), 1)),
                    august: i[0] === 3 && i[14] === "" ? "0.0" : String(fixNumber(Number(i[14]), 1)),
                    september: i[0] === 3 && i[15] === "" ? "0.0" : String(fixNumber(Number(i[15]), 1)),
                    october: i[0] === 3 && i[16] === "" ? "0.0" : String(fixNumber(Number(i[16]), 1)),
                    november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(fixNumber(Number(i[17].value), 1)) : String(fixNumber(Number(i[17]), 1))),
                    december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(fixNumber(Number(i[18].value), 1)) : String(fixNumber(Number(i[18]), 1))),
                    total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(fixNumber(Number(i[19]), 1)),
                })
            })
        }

Deni Rinaldi's avatar
Deni Rinaldi committed
546
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
547
            outlook_pa_id: this.props.outlook_pa_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
548 549 550
            company_id: this.props.company.company_id,
            periode: this.props.periode,
            report_id: this.props.report_id,
Riri Novita's avatar
Riri Novita committed
551
            currency_id: this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
552 553 554
            balance_sheet: data,
            status: type
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
555
        // console.log(JSON.stringify(body));
Deni Rinaldi's avatar
Deni Rinaldi committed
556
        api.create('UPLOAD').uploadOLPA(body).then(response => {
faisalhamdi's avatar
faisalhamdi committed
557
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
558 559
            if (response.data) {
                if (response.data.status === "success") {
Faisal Hamdi's avatar
Faisal Hamdi committed
560 561 562 563 564 565 566
                    if (type == 'submitted') {
                        this.props.onClickClose()
                        this.props.getReport()
                        let bodyRatioOLPA = {
                            "report": 'ratio',
                            "outlookPaId": this.props.outlook_pa_id,
                            "companyId": this.props.company.company_id,
Riri Novita's avatar
Riri Novita committed
567 568 569
                            "periode": this.props.periode,
                            "currency_id": this.props.defaultCurrency.id,

Faisal Hamdi's avatar
Faisal Hamdi committed
570 571 572 573 574 575 576 577
                        }
                        api.create().triggerRatioOLPA(bodyRatioOLPA).then((res) => {
                            console.log(res)
                            this.setState({ loading: false })
                        })
                    } else {
                        this.props.onClickClose()
                        this.props.getReport()
Faisal Hamdi's avatar
Faisal Hamdi committed
578
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
579
                } else {
580 581 582 583 584 585 586 587 588 589 590 591
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ visibleAlertSave: true, 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);
                            }
                        })
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
592 593 594 595 596 597 598 599 600
                }
            } else {
                this.setState({ loading: false })
                alert(response.problem)
            }
        })
    }

    async downloadAllData() {
faisalhamdi's avatar
faisalhamdi committed
601
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/outlook_pa/export_outlook_pa?outlook_pa_id=${this.props.outlook_pa_id}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
Deni Rinaldi's avatar
Deni Rinaldi committed
602
        // console.log(url);
Deni Rinaldi's avatar
Deni Rinaldi committed
603
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
604
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/outlook_pa/export_outlook_pa?outlook_pa_id=${this.props.outlook_pa_id === null ? "" : this.props.outlook_pa_id}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
Deni Rinaldi's avatar
Deni Rinaldi committed
605 606 607 608 609 610 611
        )
        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;
Deni Rinaldi's avatar
Deni Rinaldi committed
612
            a.download = 'Outlook PA Balance Sheet.xlsx';
Deni Rinaldi's avatar
Deni Rinaldi committed
613 614 615 616 617 618
            a.click();
        }
    }

    handleValidate() {
        let data = []
faisalhamdi's avatar
faisalhamdi committed
619 620 621
        let err = false
        let dataTable = this.state.dataTable
        let kansas = this.state.kansas
Deni Rinaldi's avatar
Deni Rinaldi committed
622
        // console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
623 624
        dataTable.map((i, index) => {
            if (String(i[5]) == "Control (should be nil)") {
Riri Novita's avatar
Riri Novita committed
625 626 627 628 629
                // console.log(this.state.minValue)
                // console.log(this.state.maxValue)
                // console.log(Number(i[17].value).toFixed(1))
                // console.log(Number(i[18].value).toFixed(1))
                // console.log(Number(i[19]).toFixed(1))
syadziy's avatar
syadziy committed
630

Riri Novita's avatar
Riri Novita committed
631
                if ((this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[17].value), 1) : Number(i[17].value) < Number(this.state.minValue)) || (this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[17].value), 1) : Number(i[17].value) > Number(this.state.maxValue))) {
632
                    console.log("masuk selisih control 1")
faisalhamdi's avatar
faisalhamdi committed
633
                    err = true
Riri Novita's avatar
Riri Novita committed
634
                } else if ((this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[18].value), 1) : Number(i[18].value) < Number(this.state.minValue)) || (this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[18].value), 1) : Number(i[18].value) > Number(this.state.maxValue))) {
635
                    console.log("masuk selisih control 2")
faisalhamdi's avatar
faisalhamdi committed
636
                    err = true
Riri Novita's avatar
Riri Novita committed
637
                } else if ((this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[19]), 1) : Number(i[19]) < Number(this.state.minValue)) || (this.props.defaultCurrency.id == 1 ? fixNumber(Number(i[19]), 1) : Number(i[19]) > Number(this.state.maxValue))) {
638
                    console.log("masuk selisih control 3")
faisalhamdi's avatar
faisalhamdi committed
639 640 641 642
                    err = true
                }
            }

Deni Rinaldi's avatar
Deni Rinaldi committed
643 644 645
            data.push({
                item_report_id: i[1],
                total_actual_before: String(i[6]),
Riri Novita's avatar
Riri Novita committed
646 647 648 649 650 651 652 653 654 655 656 657 658
                january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7])),
                february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8])),
                march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9])),
                april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10])),
                may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11])),
                june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12])),
                july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13])),
                august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14])),
                september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15])),
                october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16])),
                november: i[0] === 3 && i[17] === "" ? "0.0" : String(Number(i[17])),
                december: i[0] === 3 && i[18] === "" ? "0.0" : String(Number(i[18])),
                total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19])),
Deni Rinaldi's avatar
Deni Rinaldi committed
659 660
            })
        })
syadziy's avatar
syadziy committed
661
        console.log(JSON.stringify(data))
Deni Rinaldi's avatar
Deni Rinaldi committed
662
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
663
            "outlook_pa_id": this.props.outlook_pa_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
664 665 666
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
667
            "currency_id": this.props.defaultCurrency.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
668 669 670
            "balance_sheet": data,
            "status": "submitted"
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
671
        api.create().validateSubmitReportOLPA(payload).then((response) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
672
            // console.log(response)
faisalhamdi's avatar
faisalhamdi committed
673 674 675 676 677 678 679
            // console.log(response.data.data.result)
            // console.log(err);
            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 })
                        if (kansas == 0) {
faisalhamdi's avatar
faisalhamdi committed
680
                            this.setState({ kansas: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
681 682 683
                                this.handleValidate()
                            })
                        } else {
faisalhamdi's avatar
faisalhamdi committed
684
                            this.setState({ kansas: 0 })
faisalhamdi's avatar
faisalhamdi committed
685 686 687 688
                        }
                    } else {
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: true })
                        if (kansas == 0) {
faisalhamdi's avatar
faisalhamdi committed
689
                            this.setState({ kansas: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
690 691 692
                                this.handleValidate()
                            })
                        } else {
faisalhamdi's avatar
faisalhamdi committed
693
                            this.setState({ kansas: 0 })
faisalhamdi's avatar
faisalhamdi committed
694 695 696 697
                        }
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
698
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
699 700 701 702 703 704 705
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
706
            } else {
faisalhamdi's avatar
faisalhamdi committed
707
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
Deni Rinaldi's avatar
Deni Rinaldi committed
708 709 710 711 712 713 714 715 716 717 718
            }
        })
    }

    closeAlert() {
        this.setState({ alert: false })
    }

    render() {
        let dataTable2 = this.state.dataTable
        const handleChange = (value, tableMeta, type) => {
faisalhamdi's avatar
faisalhamdi committed
719
            console.log(dataTable2);
Deni Rinaldi's avatar
Deni Rinaldi committed
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
            let val = String(value).split(",").join("")
            if (type === "actual") {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
            } else {
                let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2])
                if (indexParent > 0) {
                    // console.log(indexParent)
                    let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
                    let jagain = dataTable2[indexParent][tableMeta.columnIndex]
                    a = dataTable2[indexParent][tableMeta.columnIndex] = jagain === undefined ? (0 + Number(val)) : (jagain + Number(val))
                } else {
                    dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
                }
            }
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
735

Deni Rinaldi's avatar
Deni Rinaldi committed
736 737 738 739
        const handleValue = (data) => {
            let total = 0
            dataTable2.map((item, index) => {
                if (data.rowData[1] === item[2]) {
Deni Rinaldi's avatar
Deni Rinaldi committed
740 741
                    let itemVal = item[data.columnIndex].value !== undefined ? Number(item[data.columnIndex].value) : Number(item[data.columnIndex])
                    total = item[data.columnIndex] === undefined ? Number(total) + 0 : Number(total) + itemVal
Deni Rinaldi's avatar
Deni Rinaldi committed
742 743 744 745 746 747 748
                }
            })
            let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
            let a = dataTable2[data.rowIndex][data.columnIndex] = Number(total)
            // console.log(indexParent);
            return a
        }
idlanirined's avatar
idlanirined committed
749

syadziy's avatar
syadziy committed
750 751 752 753
        const handleTotal = (tableMeta) => {
            let total = 0
            tableMeta.rowData.map((item, index) => {
                if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd") {
syadziy's avatar
syadziy committed
754
                    // console.log(index)
syadziy's avatar
syadziy committed
755
                    if (index >= 7 && index <= 18) {
syadziy's avatar
syadziy committed
756
                        // console.log(item.value + "aaa")
syadziy's avatar
syadziy committed
757 758 759 760 761 762 763 764 765 766 767 768 769 770
                        if (item.value == undefined) {
                            total += Number(item)
                        } else {
                            total += Number(item.value)
                        }
                    }
                }
            })
            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
                // console.log([tableMeta.rowIndex][tableMeta.columnIndex])
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
            }
syadziy's avatar
syadziy committed
771
            // console.log(total)
syadziy's avatar
syadziy committed
772 773
            return total
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
774 775

        const handleValueFormula = (value, tableMeta, column, periode, forecast) => {
syadziy's avatar
syadziy committed
776 777
            // console.log(value)
            // console.log(tableMeta.rowData[5])
Deni Rinaldi's avatar
Deni Rinaldi committed
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
            let splitFormula = String(tableMeta.rowData[3]).split('@')
            let baru = []
            let anjay = []
            splitFormula.map((item, index) => {
                let items = String(item).substr(Number(String(item).length) - 1, 1)
                let re = /^[a-zA-Z0-9]+$/;
                let asd = ''
                if (item !== "") {
                    if (!re.test(items)) {
                        if (String(item).substr(Number(String(item).length) - 1, 1) === ']') {
                            baru.push(String(item))
                        } else {
                            baru.push(String(item).substr(0, Number(String(item).length) - 1))
                            baru.push(String(item).substr(Number(String(item).length) - 1, 1))
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
793
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
794
                        baru.push(String(item))
Deni Rinaldi's avatar
Deni Rinaldi committed
795 796 797 798
                    }
                }
            })

Deni Rinaldi's avatar
Deni Rinaldi committed
799 800 801
            baru.map((item, index) => {
                if (item == '-' || item == '+' || item == '/' || item == '*') {
                    anjay.push(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
802
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
                    if (String(item).includes('#')) {
                        if (forecast !== undefined) {
                            let forecastt = 0
                            forecast.map((items, index) => {
                                if (items.periode == periode) {
                                    forecastt += Number(items.value)
                                }
                            })
                            anjay.push(forecastt)
                        } else if (String(item).includes('[M-1]')) {
                            let tst = String(item).replace('[M-1]', '')
                            let data = tableMeta.columnIndex == 7 ? 18 : tableMeta.columnIndex - 1
                            let period = data == 18 ? Number(this.props.periode) - 1 : this.props.periode
                            // console.log(tableMeta.columnIndex)
                            let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)
                            // console.log(indexID)
                            if (indexID !== -1) {
                                let valuezz = tableMeta.rowData[data].formula[indexID].value
                                // baru.push(valuezz)
                                anjay.push(valuezz == "" ? 0 : valuezz)
                                // console.log(valuezz)
                            }
d.arizona's avatar
d.arizona committed
825 826 827 828 829 830 831 832 833 834
                        } else {
                            // console.log(baru);
                            // console.log(value);
                            let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
                            // console.log(indexID)
                            if (indexID !== -1) {
                                // console.log(value.formula[indexID].value)
                                let valuezz = value.formula[indexID].value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850
                        }
                    } else if (String(item).includes('[M-1]')) {
                        let tst = String(item).replace('[M-1]', '')
                        if (tableMeta.columnIndex === 7 || tableMeta.columnIndex === 19) {
                            let indexID = dataTable2.findIndex((val) => val[20] == tst)
                            if (indexID !== -1) {
                                let valuezz = dataTable2[indexID][6]
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        } else {
                            let data = tableMeta.columnIndex - 1
                            let indexID = dataTable2.findIndex((val) => val[20] == tst)
                            if (indexID !== -1) {
                                let valuezz = dataTable2[indexID][data].value !== undefined ? dataTable2[indexID][data].value : dataTable2[indexID][data]
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
syadziy's avatar
syadziy committed
851 852
                            // if (tableMeta.rowData[5] == 'R/E (Cummulative)') {
                            // console.log(tst, data, tableMeta.rowData[data]);}
Deni Rinaldi's avatar
Deni Rinaldi committed
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867
                        }
                    } else {
                        let indexID = dataTable2.findIndex((val) => val[20] == item)
                        // console.log(dataTable2[indexID])
                        if (indexID !== -1) {
                            let valuezz = dataTable2[indexID][tableMeta.columnIndex].value == undefined ? dataTable2[indexID][tableMeta.columnIndex] : dataTable2[indexID][tableMeta.columnIndex].value
                            anjay.push(valuezz == "" ? 0 : valuezz)
                        } else {
                            if (item === '(-1)') {
                                anjay.push(-1)
                            }
                            // console.log(item);

                        }
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
868 869
                }
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
870 871
            // console.log(baru)
            // console.log(anjay)
syadziy's avatar
syadziy committed
872 873 874 875 876
            // if (tableMeta.rowData[5] == 'R/E (Cummulative)') {
            //     console.log(splitFormula)
            //     console.log(baru)
            //     console.log(anjay)
            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
877 878
            let total = 0
            let opt = ""
Deni Rinaldi's avatar
Deni Rinaldi committed
879
            anjay.map((item, index) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
880 881 882 883 884 885 886 887 888
                if (item == "+") {
                    opt = "tambah"
                } else if (item == "-") {
                    opt = "kurang"
                } else if (item == "*") {
                    opt = "kali"
                } else if (item == "/") {
                    opt = "bagi"
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
889
                    item = item == "" ? 0 : item
Deni Rinaldi's avatar
Deni Rinaldi committed
890 891 892 893 894 895 896
                    if (opt == "tambah") {
                        total = Number(total) + Number(item)
                    } else if (opt == "kurang") {
                        total = Number(total) - Number(item)
                    } else if (opt == "kali") {
                        total = Number(total) * Number(item)
                    } else if (opt == "bagi") {
Deni Rinaldi's avatar
Deni Rinaldi committed
897
                        total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
898
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
899
                        total += Number(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
900 901 902
                    }
                }
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
903 904 905 906 907 908 909 910 911 912 913 914 915 916
            total = R.equals(total, NaN) ? "0.0" : total

            if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value == undefined) {
                // console.log([tableMeta.rowIndex][tableMeta.columnIndex])
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = total
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex].value = total
            }

            return total
        }

        const handleValidation = (data, tableMeta) => {
            let a = handleValueFormula(data, tableMeta)
Deni Rinaldi's avatar
Deni Rinaldi committed
917 918 919
            return a
        }

Deni Rinaldi's avatar
Deni Rinaldi committed
920 921
        const handleForecast = (tableMeta, periode, column) => {
            let total = 0
d.arizona's avatar
d.arizona committed
922 923 924 925 926 927
            if (column == 19 && String(tableMeta.rowData[5]).toLocaleLowerCase() == "r/e (cummulative)") {
                total = tableMeta.rowData[7]
                dataTable2[tableMeta.rowIndex][column] = tableMeta.rowData[7]
            } else {
                total = handleValueFormula(dataTable2[tableMeta.rowIndex][column], tableMeta, column, periode, dataTable2[tableMeta.rowIndex][23])
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
928 929 930 931
            // console.log(total)
            return total
        }

Deni Rinaldi's avatar
Deni Rinaldi committed
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995
        const 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[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>
                    )
                }
            }
        }, {
            name: `31 Dec ${Number(this.props.periode) - 1} Actual`,
            options: {
                customHeadRender: (columnMeta) => (
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 4 ?
                                null
                                : tableMeta.rowData[0] === 1 ?
                                    null :
idlanirined's avatar
idlanirined committed
996 997 998 999 1000 1001 1002 1003 1004 1005 1006
                                    // <div style={{ flex: 1 }}>
                                    //     <FormControlLabel
                                    //         style={{ margin: 0 }}
                                    //         value={value}
                                    //         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
1007
                                    //                 value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
idlanirined's avatar
idlanirined committed
1008 1009 1010 1011
                                    //             />
                                    //         }
                                    //     />
                                    // </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1012 1013 1014 1015 1016 1017 1018
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1019
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1020 1021
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1022 1023
                                                    disabled={true}
                                                    // disabled={this.props.isApprover == true ? true : ((this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
Riri Novita's avatar
Riri Novita committed
1024
                                                    value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
idlanirined's avatar
idlanirined committed
1025 1026 1027 1028
                                                    onBlur={(event) => {
                                                        handleChange(event.target.value, tableMeta)
                                                        // console.log(dataTable2)
                                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041
                                                />
                                            }
                                        />
                                    </div>
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jan ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1042
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1043 1044 1045 1046 1047 1048 1049
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1050 1051 1052 1053 1054 1055 1056 1057 1058
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1059
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1060
                                    />
faisalhamdi's avatar
faisalhamdi committed
1061
                                    :
idlanirined's avatar
idlanirined committed
1062 1063 1064 1065 1066 1067 1068
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1069
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1070 1071
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1072
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1073
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1074
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1075 1076
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1077
                                        />
idlanirined's avatar
idlanirined committed
1078
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1079 1080 1081 1082 1083 1084 1085 1086 1087
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Feb ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1088
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1089 1090 1091 1092 1093 1094 1095
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1096 1097 1098 1099 1100 1101 1102 1103 1104
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1105
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1106
                                    />
faisalhamdi's avatar
faisalhamdi committed
1107
                                    :
idlanirined's avatar
idlanirined committed
1108 1109 1110 1111 1112 1113 1114
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1115
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1116 1117
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1118
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1119
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1120
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1121 1122
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1123
                                        />
idlanirined's avatar
idlanirined committed
1124
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1125 1126 1127 1128 1129 1130 1131 1132 1133
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Mar ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1134
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1135 1136 1137 1138 1139 1140 1141
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1142 1143 1144 1145 1146 1147 1148 1149 1150
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1151
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1152
                                    />
faisalhamdi's avatar
faisalhamdi committed
1153
                                    :
idlanirined's avatar
idlanirined committed
1154 1155 1156 1157 1158 1159 1160
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1161
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1162 1163
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1164
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1165
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1166
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1167 1168
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1169
                                        />
idlanirined's avatar
idlanirined committed
1170
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1171 1172 1173 1174 1175 1176 1177 1178 1179
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Apr ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1180
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1181 1182 1183 1184 1185 1186 1187
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1188 1189 1190 1191 1192 1193 1194 1195 1196
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1197
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1198
                                    />
faisalhamdi's avatar
faisalhamdi committed
1199
                                    :
idlanirined's avatar
idlanirined committed
1200 1201 1202 1203 1204 1205 1206
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1207
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1208 1209
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1210
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1211
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1212
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1213 1214
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1215
                                        />
idlanirined's avatar
idlanirined committed
1216
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1217 1218 1219 1220 1221 1222 1223 1224 1225
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `May ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1226
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1227 1228 1229 1230 1231 1232 1233
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1234 1235 1236 1237 1238 1239 1240 1241 1242
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1243
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1244
                                    />
faisalhamdi's avatar
faisalhamdi committed
1245
                                    :
idlanirined's avatar
idlanirined committed
1246 1247 1248 1249 1250 1251 1252
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1253
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1254 1255
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1256
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1257
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1258
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1259 1260
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1261
                                        />
idlanirined's avatar
idlanirined committed
1262
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1263 1264 1265 1266 1267 1268 1269 1270 1271
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jun ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1272
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1273 1274 1275 1276 1277 1278 1279
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1280 1281 1282 1283 1284 1285 1286 1287 1288
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1289
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1290
                                    />
faisalhamdi's avatar
faisalhamdi committed
1291
                                    :
idlanirined's avatar
idlanirined committed
1292 1293 1294 1295 1296 1297 1298
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1299
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1300 1301
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1302
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1303
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1304
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1305 1306
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1307
                                        />
idlanirined's avatar
idlanirined committed
1308
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1309 1310 1311 1312 1313 1314 1315 1316 1317
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jul ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1318
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1319 1320 1321 1322 1323 1324 1325
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1326 1327 1328 1329 1330 1331 1332 1333 1334
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1335
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1336
                                    />
faisalhamdi's avatar
faisalhamdi committed
1337
                                    :
idlanirined's avatar
idlanirined committed
1338 1339 1340 1341 1342 1343 1344
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1345
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1346 1347
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1348
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1349
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1350
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1351 1352
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1353
                                        />
idlanirined's avatar
idlanirined committed
1354
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1355 1356 1357 1358 1359 1360 1361 1362 1363
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Aug ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1364
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1365 1366 1367 1368 1369 1370 1371
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1372 1373 1374 1375 1376 1377 1378 1379 1380
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1381
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1382
                                    />
faisalhamdi's avatar
faisalhamdi committed
1383
                                    :
idlanirined's avatar
idlanirined committed
1384 1385 1386 1387 1388 1389 1390
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1391
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1392 1393
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1394
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1395
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1396
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1397 1398
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1399
                                        />
idlanirined's avatar
idlanirined committed
1400
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1401 1402 1403 1404 1405 1406 1407 1408 1409
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Sep ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1410
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1411 1412 1413 1414 1415 1416 1417
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1418 1419 1420 1421 1422 1423 1424 1425 1426
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1427
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1428
                                    />
faisalhamdi's avatar
faisalhamdi committed
1429
                                    :
idlanirined's avatar
idlanirined committed
1430 1431 1432 1433 1434 1435 1436
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1437
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1438 1439
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1440
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1441
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1442
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1443 1444
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1445
                                        />
idlanirined's avatar
idlanirined committed
1446
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1447 1448 1449 1450 1451 1452 1453 1454 1455
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Oct ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1456
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1457 1458 1459 1460 1461 1462 1463
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1464 1465 1466 1467 1468 1469 1470 1471 1472
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1473
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1474
                                    />
faisalhamdi's avatar
faisalhamdi committed
1475
                                    :
idlanirined's avatar
idlanirined committed
1476 1477 1478 1479 1480 1481 1482
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1483
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1484 1485
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1486
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1487
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1488
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1489 1490
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1491
                                        />
idlanirined's avatar
idlanirined committed
1492
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1493 1494 1495 1496 1497 1498 1499 1500 1501
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Nov ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1502
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1503 1504 1505 1506 1507 1508 1509
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1510 1511 1512 1513 1514 1515 1516 1517 1518 1519
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null
                                :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1520
                                        value={this.props.status === 'CLOSED' ? fixNumber(Number(value), 1) : (tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ? (fixNumber(Number(value.value), 1) == 0 ? "0.0" : fixNumber(Number(value.value), 1)) : (fixNumber(Number(value), 1) == 0 ? "0.0" : fixNumber(Number(value), 1)))}
Deni Rinaldi's avatar
Deni Rinaldi committed
1521 1522
                                    />
                                    :
faisalhamdi's avatar
faisalhamdi committed
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533
                                    tableMeta.rowData[0] === 3 ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1534 1535
                                                        // disabled={this.props.isApprover == true ? true : ((this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                        disabled={this.props.isApprover ? true : false}
Riri Novita's avatar
Riri Novita committed
1536
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1537 1538 1539 1540 1541 1542
                                                        onBlur={(event) => {
                                                            handleChange(event.target.value, tableMeta)
                                                            // console.log(dataTable2)
                                                        }}
                                                    />
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1543
                                            />
faisalhamdi's avatar
faisalhamdi committed
1544 1545 1546
                                        </div> :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
idlanirined's avatar
idlanirined committed
1547 1548
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1549
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1550 1551
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1552
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1553
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(tableMeta)), 1) : (Number(handleValue(tableMeta)) == 0 ? "0.0" : Number(handleValue(tableMeta)))}
idlanirined's avatar
idlanirined committed
1554
                                                />
faisalhamdi's avatar
faisalhamdi committed
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566
                                            </span>
                                            :
                                            tableMeta.rowData[0] === 4 ?
                                                null
                                                :
                                                tableMeta.rowData[0] === 6 ?
                                                    <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
1567
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValueFormula(value, tableMeta)), 1) : (Number(handleValueFormula(value, tableMeta)) == 0 ? "0.0" : Number(handleValueFormula(value, tableMeta)))}
faisalhamdi's avatar
faisalhamdi committed
1568 1569 1570 1571 1572 1573 1574 1575 1576
                                                    />
                                                    :
                                                    tableMeta.rowData[0] === 5 ?
                                                        <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
1577
                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValueFormula(value, tableMeta)), 1) : (Number(handleValueFormula(value, tableMeta)) == 0 ? "0.0" : Number(handleValueFormula(value, tableMeta)))}
faisalhamdi's avatar
faisalhamdi committed
1578
                                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
1579
                                                        :
faisalhamdi's avatar
faisalhamdi committed
1580 1581 1582 1583
                                                        tableMeta.rowData[0] === 1 ?
                                                            null
                                                            :
                                                            tableMeta.rowData[0] === 7 ?
Riri Novita's avatar
Riri Novita committed
1584 1585
                                                                this.props.defaultCurrency.id == 1 ?
                                                                    (fixNumber(Number(handleValidation(value, tableMeta)), 1) >= Number(this.state.minValue) && fixNumber(Number(handleValidation(value, tableMeta)), 1) <= Number(this.state.maxValue)) ?
faisalhamdi's avatar
faisalhamdi committed
1586 1587 1588 1589 1590 1591 1592 1593
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{
                                                                                fontSize: 12,
                                                                                textAlign: 'right',
                                                                                borderColor: 'transparent',
                                                                                margin: 0,
                                                                                width: 96,
Riri Novita's avatar
Riri Novita committed
1594
                                                                                backgroundColor: 'transparent'
faisalhamdi's avatar
faisalhamdi committed
1595 1596 1597 1598
                                                                            }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
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 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653
                                                                            value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : fixNumber(Number(handleValidation(value, tableMeta)), 1)}
                                                                        /> :
                                                                        <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{
                                                                                    fontSize: 12,
                                                                                    textAlign: 'right',
                                                                                    borderColor: 'transparent',
                                                                                    margin: 0,
                                                                                    width: 96,
                                                                                    backgroundColor: 'transparent',
                                                                                    color: 'red'
                                                                                }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
                                                                                value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : fixNumber(Number(handleValidation(value, tableMeta)), 1)}
                                                                            />
                                                                        </LightTooltip>
                                                                    :
                                                                    (Number(handleValidation(value, tableMeta)) >= Number(this.state.minValue) && Number(handleValidation(value, tableMeta)) <= Number(this.state.maxValue)) ?
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{
                                                                                fontSize: 12,
                                                                                textAlign: 'right',
                                                                                borderColor: 'transparent',
                                                                                margin: 0,
                                                                                width: 96,
                                                                                backgroundColor: 'transparent'
                                                                            }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : Number(handleValidation(value, tableMeta))}
                                                                        /> :
                                                                        <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{
                                                                                    fontSize: 12,
                                                                                    textAlign: 'right',
                                                                                    borderColor: 'transparent',
                                                                                    margin: 0,
                                                                                    width: 96,
                                                                                    backgroundColor: 'transparent',
                                                                                    color: 'red'
                                                                                }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
                                                                                value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : Number(handleValidation(value, tableMeta))}
                                                                            />
                                                                        </LightTooltip>
faisalhamdi's avatar
faisalhamdi committed
1654 1655
                                                                :
                                                                null
faisalhamdi's avatar
faisalhamdi committed
1656
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1657 1658 1659 1660 1661
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1662
            name: `Dec ${this.props.periode}`,
Deni Rinaldi's avatar
Deni Rinaldi committed
1663 1664
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1665 1666
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
                        <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1667 1668 1669 1670 1671 1672
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null
                                :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1683
                                        value={Number(value) == 0 ? "0.0" : this.props.status === 'CLOSED' ? fixNumber(Number(value), 1) : (tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 || tableMeta.rowData[0] === 7 ? Number(value.value).toFixed(1) : Number(value).toFixed(1))}
Deni Rinaldi's avatar
Deni Rinaldi committed
1684
                                    />
faisalhamdi's avatar
faisalhamdi committed
1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696
                                    :
                                    tableMeta.rowData[0] === 3 ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1697 1698
                                                        // disabled={this.props.isApprover == true ? true : ((this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                        disabled={this.props.isApprover ? true : false}
Riri Novita's avatar
Riri Novita committed
1699
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : (Number(value) == 0 ? "0.0" : Number(value))}
faisalhamdi's avatar
faisalhamdi committed
1700 1701 1702 1703 1704 1705 1706 1707 1708 1709
                                                        onBlur={(event) => {
                                                            handleChange(event.target.value, tableMeta)
                                                            // console.log(dataTable2)
                                                        }}
                                                    />
                                                }
                                            />
                                        </div> :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
idlanirined's avatar
idlanirined committed
1710 1711
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1712
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1713 1714
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1715
                                                    disabled={true}
Riri Novita's avatar
Riri Novita committed
1716
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(tableMeta)), 1) : (Number(handleValue(tableMeta)) == 0 ? "0.0" : Number(handleValue(tableMeta)))}
idlanirined's avatar
idlanirined committed
1717
                                                />
faisalhamdi's avatar
faisalhamdi committed
1718
                                            </span>
Deni Rinaldi's avatar
Deni Rinaldi committed
1719
                                            :
faisalhamdi's avatar
faisalhamdi committed
1720 1721
                                            tableMeta.rowData[0] === 4 ?
                                                null
Deni Rinaldi's avatar
Deni Rinaldi committed
1722
                                                :
faisalhamdi's avatar
faisalhamdi committed
1723 1724 1725 1726 1727 1728 1729
                                                tableMeta.rowData[0] === 6 ?
                                                    <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
1730
                                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValueFormula(value, tableMeta)), 1) : (Number(handleValueFormula(value, tableMeta)) == 0 ? "0.0" : Number(handleValueFormula(value, tableMeta)))}
faisalhamdi's avatar
faisalhamdi committed
1731
                                                    />
Deni Rinaldi's avatar
Deni Rinaldi committed
1732
                                                    :
faisalhamdi's avatar
faisalhamdi committed
1733 1734 1735 1736 1737 1738 1739
                                                    tableMeta.rowData[0] === 5 ?
                                                        <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
1740
                                                            value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValueFormula(value, tableMeta)), 1) : (Number(handleValueFormula(value, tableMeta)) == 0 ? "0.0" : Number(handleValueFormula(value, tableMeta)))}
faisalhamdi's avatar
faisalhamdi committed
1741 1742 1743 1744 1745 1746
                                                        />
                                                        :
                                                        tableMeta.rowData[0] === 1 ?
                                                            null
                                                            :
                                                            tableMeta.rowData[0] === 7 ?
Riri Novita's avatar
Riri Novita committed
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783
                                                                this.props.defaultCurrency.id == 1 ?
                                                                    (fixNumber(Number(handleValidation(value, tableMeta)), 1) >= Number(this.state.minValue) && fixNumber(Number(handleValidation(value, tableMeta)), 1) <= Number(this.state.maxValue)) ?
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{
                                                                                fontSize: 12,
                                                                                textAlign: 'right',
                                                                                borderColor: 'transparent',
                                                                                margin: 0,
                                                                                width: 96,
                                                                                backgroundColor: 'transparent'
                                                                            }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : fixNumber(Number(handleValidation(value, tableMeta)), 1)}
                                                                        /> :
                                                                        <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{
                                                                                    fontSize: 12,
                                                                                    textAlign: 'right',
                                                                                    borderColor: 'transparent',
                                                                                    margin: 0,
                                                                                    width: 96,
                                                                                    backgroundColor: 'transparent',
                                                                                    color: 'red'
                                                                                }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
                                                                                value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : fixNumber(Number(handleValidation(value, tableMeta)), 1)}
                                                                            />
                                                                        </LightTooltip>
                                                                    :
                                                                    (Number(handleValidation(value, tableMeta)) >= Number(this.state.minValue) && Number(handleValidation(value, tableMeta)) <= Number(this.state.maxValue)) ?
faisalhamdi's avatar
faisalhamdi committed
1784 1785 1786 1787 1788 1789 1790 1791
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{
                                                                                fontSize: 12,
                                                                                textAlign: 'right',
                                                                                borderColor: 'transparent',
                                                                                margin: 0,
                                                                                width: 96,
Riri Novita's avatar
Riri Novita committed
1792
                                                                                backgroundColor: 'transparent'
faisalhamdi's avatar
faisalhamdi committed
1793 1794 1795 1796
                                                                            }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816
                                                                            value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : Number(handleValidation(value, tableMeta))}
                                                                        /> :
                                                                        <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{
                                                                                    fontSize: 12,
                                                                                    textAlign: 'right',
                                                                                    borderColor: 'transparent',
                                                                                    margin: 0,
                                                                                    width: 96,
                                                                                    backgroundColor: 'transparent',
                                                                                    color: 'red'
                                                                                }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
                                                                                value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : Number(handleValidation(value, tableMeta))}
                                                                            />
                                                                        </LightTooltip>
faisalhamdi's avatar
faisalhamdi committed
1817 1818 1819 1820 1821 1822 1823 1824
                                                                :
                                                                null
                            }
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1825
            name: `31 Dec ${this.props.periode} Total`,
faisalhamdi's avatar
faisalhamdi committed
1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845
            options: {
                customHeadRender: (columnMeta) => (
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96 }}>
                        <Typography style={{ color: 'black', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
                            {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                null
                                :
                                this.state.get_for == 'view' ?
                                    <NumberFormat
                                        thousandSeparator={true}
                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                        type="text"
                                        placeholder=""
                                        disabled={true}
Riri Novita's avatar
Riri Novita committed
1846
                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
faisalhamdi's avatar
faisalhamdi committed
1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859
                                    />
                                    :
                                    tableMeta.rowData[0] === 3 ?
                                        <div style={{ flex: 1 }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
                                                value={value}
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1860 1861
                                                        // disabled={this.props.isApprover == true ? true : ((this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                        disabled={this.props.isApprover ? true : false}
Riri Novita's avatar
Riri Novita committed
1862
                                                        value={Number(value) == 0 ? "0.0" : fixNumber(Number(value), 1)}
faisalhamdi's avatar
faisalhamdi committed
1863 1864 1865 1866 1867 1868 1869 1870 1871
                                                        onBlur={(event) => {
                                                            handleChange(event.target.value, tableMeta)
                                                            // console.log(dataTable2)
                                                        }}
                                                    />
                                                }
                                            />
                                        </div> :
                                        tableMeta.rowData[0] === 2 ?
faisalhamdi's avatar
faisalhamdi committed
1872 1873 1874 1875 1876 1877 1878
                                            <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
1879
                                                    value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(handleValue(tableMeta)), 1) : (Number(handleValue(tableMeta)) == 0 ? "0.0" : Number(handleValue(tableMeta)))}
faisalhamdi's avatar
faisalhamdi committed
1880
                                                />
faisalhamdi's avatar
faisalhamdi committed
1881
                                            </span>
faisalhamdi's avatar
faisalhamdi committed
1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892
                                            :
                                            tableMeta.rowData[0] === 4 ?
                                                null
                                                :
                                                tableMeta.rowData[0] === 6 ?
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        disabled={true}
syadziy's avatar
syadziy committed
1893
                                                        value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "profit (loss) mtd" ? Number(handleTotal(tableMeta)).toFixed(1) : Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1894 1895 1896 1897 1898 1899 1900 1901 1902
                                                    />
                                                    :
                                                    tableMeta.rowData[0] === 5 ?
                                                        <NumberFormat
                                                            thousandSeparator={true}
                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                            type="text"
                                                            placeholder=""
                                                            disabled={true}
d.arizona's avatar
d.arizona committed
1903
                                                            value={Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1904
                                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
1905
                                                        :
faisalhamdi's avatar
faisalhamdi committed
1906 1907 1908 1909
                                                        tableMeta.rowData[0] === 1 ?
                                                            null
                                                            :
                                                            tableMeta.rowData[0] === 7 ?
Riri Novita's avatar
Riri Novita committed
1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946
                                                                this.props.defaultCurrency.id == 1 ?
                                                                    (fixNumber(Number(handleValidation(value, tableMeta)), 1) >= Number(this.state.minValue) && fixNumber(Number(handleValidation(value, tableMeta)), 1) <= Number(this.state.maxValue)) ?
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{
                                                                                fontSize: 12,
                                                                                textAlign: 'right',
                                                                                borderColor: 'transparent',
                                                                                margin: 0,
                                                                                width: 96,
                                                                                backgroundColor: 'transparent'
                                                                            }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : fixNumber(Number(handleValidation(value, tableMeta)), 1)}
                                                                        /> :
                                                                        <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{
                                                                                    fontSize: 12,
                                                                                    textAlign: 'right',
                                                                                    borderColor: 'transparent',
                                                                                    margin: 0,
                                                                                    width: 96,
                                                                                    backgroundColor: 'transparent',
                                                                                    color: 'red'
                                                                                }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
                                                                                value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : fixNumber(Number(handleValidation(value, tableMeta)), 1)}
                                                                            />
                                                                        </LightTooltip>
                                                                    :
                                                                    (Number(handleValidation(value, tableMeta)) >= Number(this.state.minValue) && Number(handleValidation(value, tableMeta)) <= Number(this.state.maxValue)) ?
faisalhamdi's avatar
faisalhamdi committed
1947 1948 1949 1950 1951 1952 1953 1954
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{
                                                                                fontSize: 12,
                                                                                textAlign: 'right',
                                                                                borderColor: 'transparent',
                                                                                margin: 0,
                                                                                width: 96,
Riri Novita's avatar
Riri Novita committed
1955
                                                                                backgroundColor: 'transparent'
faisalhamdi's avatar
faisalhamdi committed
1956 1957 1958 1959
                                                                            }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
Riri Novita's avatar
Riri Novita committed
1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
                                                                            value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : Number(handleValidation(value, tableMeta))}
                                                                        /> :
                                                                        <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[23]}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{
                                                                                    fontSize: 12,
                                                                                    textAlign: 'right',
                                                                                    borderColor: 'transparent',
                                                                                    margin: 0,
                                                                                    width: 96,
                                                                                    backgroundColor: 'transparent',
                                                                                    color: 'red'
                                                                                }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
                                                                                value={Number(handleValidation(value, tableMeta)) == 0 ? "0.0" : Number(handleValidation(value, tableMeta))}
                                                                            />
                                                                        </LightTooltip>
faisalhamdi's avatar
faisalhamdi committed
1980 1981
                                                                :
                                                                null
Deni Rinaldi's avatar
Deni Rinaldi committed
1982 1983 1984 1985 1986
                            }
                        </div>
                    )
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1987
        },
qorri_di's avatar
qorri_di committed
1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
        {
            name: "",
            options: {
                display: false
            }
        },
        {
            name: "",
            options: {
                display: false
            }
        }]
Deni Rinaldi's avatar
Deni Rinaldi committed
2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014

        const loadingComponent = (
            <div style={{ position: 'absolute', 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>
        );

        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 }}>
faisalhamdi's avatar
faisalhamdi committed
2015
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Outlook Performance Appraisal Submission</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033
                </div>
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
                {/* {this.state.loading && loadingComponent} */}
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
                    {this.state.visibleBalanceSheet === true ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Outlook Performance Appraisal - Balance Sheet</Typography>
                            </div>
                            <div style={{ padding: 20 }}>
                                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
2034 2035 2036 2037 2038
                                        {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>
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
2039 2040
                                    </div>
                                    <div style={{ width: '50%' }}>
Riri Novita's avatar
Riri Novita committed
2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095
                                        {/* {this.props.isApprover == true || this.state.dataTable.length == 0 ? null : */}
                                        {this.props.isApprover == true || this.state.get_for == 'view' ?
                                            null
                                            // <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            //     <a data-tip={'Download'} data-for="download">
                                            //         <button
                                            //             style={{
                                            //                 backgroundColor: 'transparent',
                                            //                 cursor: 'pointer',
                                            //                 borderColor: 'transparent',
                                            //                 margin: 5
                                            //             }}
                                            //             onClick={() =>
                                            //                 this.setState({ loading: true }, () => {
                                            //                     setTimeout(() => {
                                            //                         this.downloadAllData()
                                            //                     }, 100);
                                            //                 })}
                                            //         >
                                            //             <img src={Images.download} />
                                            //         </button>
                                            //     </a>
                                            //     <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                            // </div> 
                                            :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                <a data-tip={'Download Template'} data-for="template">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.downloadTemplate()}
                                                    >
                                                        <img src={Images.template} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                                <a data-tip={'Upload'} data-for="upload">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.setState({ visibleUpload: true })}
                                                    >
                                                        <img src={Images.upload} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                                {/* <a data-tip={'Download'} data-for="download">
Deni Rinaldi's avatar
Deni Rinaldi committed
2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
qorri_di's avatar
qorri_di committed
2113
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
Riri Novita's avatar
Riri Novita committed
2114 2115
                                            </div>
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128
                                    </div>
                                </div>

                                <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>
Riri Novita's avatar
Riri Novita committed
2129 2130 2131 2132 2133
                                <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
2134 2135 2136 2137
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
faisalhamdi's avatar
faisalhamdi committed
2138
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
Riri Novita's avatar
Riri Novita committed
2139 2140 2141
                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2142
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5 }}>Notes : {this.state.notes}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160
                            </div>
                            <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                <div className="col-1">
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none'
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
2161
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2162 2163 2164
                                        </div>
                                    </button>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2165 2166
                                {this.props.isApprover === true ?
                                    <div className="col-2">
faisalhamdi's avatar
faisalhamdi committed
2167
                                    </div> :
faisalhamdi's avatar
faisalhamdi committed
2168
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
Riri Novita's avatar
Riri Novita committed
2169
                                        {this.state.get_for == 'view' && this.state.viewOnly && <button
faisalhamdi's avatar
faisalhamdi committed
2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true, refresh: true }, () => {
                                                    this.handleGetFor('edit')
                                                })
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Edit</Typography>
                                            </div>
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
faisalhamdi's avatar
faisalhamdi committed
2200
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221
                                                    setTimeout(() => {
                                                        this.handleValidate()
                                                    }, 100);
                                                })
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
2222 2223 2224
                                                this.state.saveDraft ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    :
2225 2226
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2227 2228
                                                            this.backToOLPA('draft')
                                                        })
faisalhamdi's avatar
faisalhamdi committed
2229 2230 2231 2232 2233 2234
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                            </div>
                                        </button>}
qorri_di's avatar
qorri_di committed
2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256
                                        {this.state.get_for == 'edit' &&
                                            <button
                                                type="button"
                                                disabled={this.state.buttonError}
                                                onClick={() => this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                    :
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
                                                            this.backToOLPA('submitted')
                                                        })}
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: this.state.buttonError === true ? 'default' : 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                }}
                                            >
                                                <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                                </div>
                                            </button>}
faisalhamdi's avatar
faisalhamdi committed
2257
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2258 2259 2260 2261 2262 2263 2264 2265 2266 2267
                                }
                            </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 : {this.props.periode}</Typography>
Riri Novita's avatar
Riri Novita committed
2268 2269 2270 2271 2272
                                        {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>
                                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299
                                    </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>

                                <div className="grid grid-2x" style={{ marginTop: 20 }}>
                                    <div className="col-1">
                                        <button
                                            type="button"
                                            onClick={() => this.setState({ loading: true, visibleBalanceSheet: true }, () => {
                                                setTimeout(() => {
                                                    this.getItemHierarki()
                                                }, 100);
                                            })}
                                            style={{ marginRight: 20 }}
                                        >
                                            <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
2300
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2301 2302 2303 2304
                                            </div>
                                        </button>
                                    </div>
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
2305
                                        {this.state.get_for == 'edit' && <button
Deni Rinaldi's avatar
Deni Rinaldi committed
2306 2307 2308 2309
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
2310
                                                cursor: 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2311 2312 2313 2314 2315
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
2316
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2317
                                                    setTimeout(() => {
2318
                                                        this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
2319 2320 2321 2322 2323 2324 2325
                                                    }, 100);
                                                })
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
                                            </div>
2326 2327 2328
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
                                            className="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
2329 2330 2331 2332 2333 2334 2335 2336 2337
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
2338 2339 2340
                                                this.state.saveDraft ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    :
2341 2342
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
2343 2344
                                                            this.uploadBalanceSheet('draft')
                                                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
2345 2346 2347 2348 2349
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                            </div>
2350
                                        </button>}
qorri_di's avatar
qorri_di committed
2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372
                                        {this.state.get_for == 'edit' &&
                                            <button
                                                type="button"
                                                // disabled={this.state.buttonError}
                                                onClick={() => this.state.buttonError ?
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                    :
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
                                                            this.uploadBalanceSheet('submitted')
                                                        })}
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: this.state.buttonError === true ? 'default' : 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                }}
                                            >
                                                <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                                </div>
                                            </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397
                                    </div>
                                </div>
                            </div>
                        </Paper>}
                </div>

                {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>
2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414
                            <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.judul).includes("OUTLOOK") && String(this.state.judul).includes("PA") && String(this.state.judul).includes("BALANCE") && String(this.state.judul).includes("SHEET") ?
                                            this.checkUpload() :
                                            this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                    }}
                                />
                            </div>
2415
                            <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>
2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443
                        </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
                                        }}
2444
                                        onClick={() => this.setState({ visibleAlertSave: false, loading: false })}
2445 2446 2447 2448 2449 2450 2451
                                    >
                                        <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>
Deni Rinaldi's avatar
Deni Rinaldi committed
2452 2453 2454 2455 2456 2457 2458
                        </div>
                    </div>
                )}
            </div>
        )
    }
}