BalanceSheetOLPA.js 136 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';
Deni Rinaldi's avatar
Deni Rinaldi committed
14 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

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
51
            updateBy: [],
52
            handleDoubleClick: 0,
faisalhamdi's avatar
faisalhamdi committed
53
            viewOnly: true,
faisalhamdi's avatar
faisalhamdi committed
54 55 56 57
            get_for: 'view',
            minValue: "0",
            maxValue: "0",
            kansas: 0
Deni Rinaldi's avatar
Deni Rinaldi committed
58
        }
faisalhamdi's avatar
faisalhamdi committed
59 60
        this.handleValue = this.handleValue.bind(this)
        this.fileHandler = this.fileHandler.bind(this);
Deni Rinaldi's avatar
Deni Rinaldi committed
61 62 63
    }

    componentDidMount() {
faisalhamdi's avatar
faisalhamdi committed
64 65
        this.getLatestUpdate()
        this.handleViewOnly()
faisalhamdi's avatar
faisalhamdi committed
66
        this.getSettingControl()
Deni Rinaldi's avatar
Deni Rinaldi committed
67 68
    }

faisalhamdi's avatar
faisalhamdi committed
69 70 71 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
    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
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
            this.getSettingControl()
        })
    }

    getSettingControl() {
        let body = {
            group: 'THRESHOLD_CONTROL',
            company_id: this.props.company.company_id,
            type: 'BALANCE_SHEET'
        }

        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
128
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
129 130 131 132 133 134 135 136 137 138
                            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
139 140 141 142
        })
    }

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

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

faisalhamdi's avatar
faisalhamdi committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
    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
298 299 300 301
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
Deni Rinaldi's avatar
Deni Rinaldi committed
302 303 304 305 306 307 308 309 310 311 312
                total_actual_before: String(Number(i[6]).toFixed(1)),
                january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
                february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
                march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
                april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
                may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
                june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
                july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
                august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
                september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
                october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)),
d.arizona's avatar
d.arizona committed
313 314
                november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1))),
                december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1))),
Deni Rinaldi's avatar
Deni Rinaldi committed
315
                total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19]).toFixed(1)),
Deni Rinaldi's avatar
Deni Rinaldi committed
316 317 318
            })
        })
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
319
            "outlook_pa_id": this.props.outlook_pa_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
320 321 322 323 324 325
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
            "balance_sheet": data
        }
faisalhamdi's avatar
faisalhamdi committed
326
        console.log(data);
Deni Rinaldi's avatar
Deni Rinaldi committed
327
        this.setState({ loading: false })
Faisal Hamdi's avatar
Faisal Hamdi committed
328
        if (type == 'submitted') {
d.arizona's avatar
d.arizona committed
329 330 331 332 333 334 335 336 337 338 339
            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
340 341 342 343
            this.props.onClickClose()
        } else {
            this.props.saveToOLPA(payload)
            this.props.onClickClose()
Faisal Hamdi's avatar
Faisal Hamdi committed
344
        }
Faisal Hamdi's avatar
Faisal Hamdi committed
345

Deni Rinaldi's avatar
Deni Rinaldi committed
346 347 348 349
    }

    downloadTemplate = async () => {
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
350
            `${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}`
Deni Rinaldi's avatar
Deni Rinaldi committed
351 352
        )
        res = await res.blob()
Deni Rinaldi's avatar
Deni Rinaldi committed
353
        // console.log(res)
Deni Rinaldi's avatar
Deni Rinaldi committed
354 355 356 357
        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
358
            a.download = 'Template Outlook PA Balance Sheet.xlsx';
Deni Rinaldi's avatar
Deni Rinaldi committed
359 360 361 362 363 364 365 366 367 368 369 370 371
            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
372
                // console.log(resp.rows[2]);
Deni Rinaldi's avatar
Deni Rinaldi committed
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
                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
403
                console.log(body)
Deni Rinaldi's avatar
Deni Rinaldi committed
404 405 406 407 408 409
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
            }
        });
    }

    checkUpload() {
Deni Rinaldi's avatar
Deni Rinaldi committed
410
        api.create().checkUploadOLPA(this.state.payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
411
            // console.log(JSON.stringify(this.state.payload));
Deni Rinaldi's avatar
Deni Rinaldi committed
412
            console.log(response)
Deni Rinaldi's avatar
Deni Rinaldi committed
413 414 415 416 417 418 419 420 421 422 423 424
            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,
Deni Rinaldi's avatar
Deni Rinaldi committed
425 426 427 428 429 430 431 432 433 434
                            Number(item.january).toFixed(1),
                            Number(item.february).toFixed(1),
                            Number(item.march).toFixed(1),
                            Number(item.april).toFixed(1),
                            Number(item.may).toFixed(1),
                            Number(item.june).toFixed(1),
                            Number(item.july).toFixed(1),
                            Number(item.august).toFixed(1),
                            Number(item.september).toFixed(1),
                            Number(item.october).toFixed(1),
d.arizona's avatar
d.arizona committed
435 436
                            item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.november).toFixed(1), formula: item.november_formula } : Number(item.november).toFixed(1),
                            item.type_report_id == 5 || item.type_report_id == 6 || item.type_report_id == 7 ? { value: Number(item.december).toFixed(1), formula: item.december_formula } : Number(item.december).toFixed(1),
Deni Rinaldi's avatar
Deni Rinaldi committed
437
                            Number(item.total_current_year).toFixed(1),
Deni Rinaldi's avatar
Deni Rinaldi committed
438 439 440
                            item.orders,
                            item.condition_it_should_be,
                            item.condition_if_wrong,
Deni Rinaldi's avatar
Deni Rinaldi committed
441
                            item.forecast_formula == null ? [] : item.forecast_formula,
Deni Rinaldi's avatar
Deni Rinaldi committed
442 443 444
                            item.error
                        ]
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
445
                    console.log(this.state.dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
446 447
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
                        this.state.dataTable.map(item => {
Deni Rinaldi's avatar
Deni Rinaldi committed
448
                            if (item[24].length > 0) {
faisalhamdi's avatar
faisalhamdi committed
449
                                console.log('masuk')
Deni Rinaldi's avatar
Deni Rinaldi committed
450 451 452
                                this.setState({ buttonError: true, errorPreview: true, editable: true })
                            }
                        })
faisalhamdi's avatar
faisalhamdi committed
453
                        console.log(this.state.dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
454
                    })
Riri Novita's avatar
Riri Novita committed
455 456
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
457
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
458 459 460 461 462 463
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
464 465 466 467 468 469 470 471 472 473
                }
            }
        })
    }

    uploadBalanceSheet(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
Deni Rinaldi's avatar
Deni Rinaldi committed
474 475 476 477 478 479 480 481 482 483 484
                total_actual_before: String(Number(i[6]).toFixed(1)),
                january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
                february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
                march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
                april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
                may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
                june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
                july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
                august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
                september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
                october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)),
d.arizona's avatar
d.arizona committed
485
                november: i[0] === 3 && i[17] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[17].value).toFixed(1)) : String(Number(i[17]).toFixed(1))),
syadziy's avatar
syadziy committed
486
                december: i[0] === 3 && i[18] === "" ? "0.0" : (i[0] === 5 || i[0] === 6 || i[0] === 7 ? String(Number(i[18].value).toFixed(1)) : String(Number(i[18]).toFixed(1))),
Deni Rinaldi's avatar
Deni Rinaldi committed
487
                total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19]).toFixed(1)),
Deni Rinaldi's avatar
Deni Rinaldi committed
488 489 490
            })
        })
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
491
            outlook_pa_id: this.props.outlook_pa_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
492 493 494 495 496 497
            company_id: this.props.company.company_id,
            periode: this.props.periode,
            report_id: this.props.report_id,
            balance_sheet: data,
            status: type
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
498
        // console.log(JSON.stringify(body));
Deni Rinaldi's avatar
Deni Rinaldi committed
499
        api.create('UPLOAD').uploadOLPA(body).then(response => {
faisalhamdi's avatar
faisalhamdi committed
500
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
501 502
            if (response.data) {
                if (response.data.status === "success") {
Faisal Hamdi's avatar
Faisal Hamdi committed
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
                    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,
                            "periode": this.props.periode
                        }
                        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
519
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
520
                } else {
Riri Novita's avatar
Riri Novita committed
521
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
522
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
523 524 525 526 527 528
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
529 530 531 532 533 534 535 536 537
                }
            } else {
                this.setState({ loading: false })
                alert(response.problem)
            }
        })
    }

    async downloadAllData() {
faisalhamdi's avatar
faisalhamdi committed
538
        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
539
        // console.log(url);
Deni Rinaldi's avatar
Deni Rinaldi committed
540
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
541
            `${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
542 543 544 545 546 547 548
        )
        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
549
            a.download = 'Outlook PA Balance Sheet.xlsx';
Deni Rinaldi's avatar
Deni Rinaldi committed
550 551 552 553 554 555
            a.click();
        }
    }

    handleValidate() {
        let data = []
faisalhamdi's avatar
faisalhamdi committed
556 557 558
        let err = false
        let dataTable = this.state.dataTable
        let kansas = this.state.kansas
Deni Rinaldi's avatar
Deni Rinaldi committed
559
        // console.log(this.state.dataTable)
faisalhamdi's avatar
faisalhamdi committed
560 561
        dataTable.map((i, index) => {
            if (String(i[5]) == "Control (should be nil)") {
562 563 564 565 566
                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
567 568

                if ((Number(i[17].value).toFixed(1) < Number(this.state.minValue)) || (Number(i[17].value).toFixed(1) > Number(this.state.maxValue))) {
569
                    console.log("masuk selisih control 1")
faisalhamdi's avatar
faisalhamdi committed
570
                    err = true
syadziy's avatar
syadziy committed
571
                } else if ((Number(i[18].value).toFixed(1) < Number(this.state.minValue)) || (Number(i[18].value).toFixed(1) > Number(this.state.maxValue))) {
572
                    console.log("masuk selisih control 2")
faisalhamdi's avatar
faisalhamdi committed
573
                    err = true
syadziy's avatar
syadziy committed
574
                } else if ((Number(i[19]).toFixed(1) < Number(this.state.minValue)) || (Number(i[19]).toFixed(1) > Number(this.state.maxValue))) {
575
                    console.log("masuk selisih control 3")
faisalhamdi's avatar
faisalhamdi committed
576 577 578 579
                    err = true
                }
            }

Deni Rinaldi's avatar
Deni Rinaldi committed
580 581 582
            data.push({
                item_report_id: i[1],
                total_actual_before: String(i[6]),
Deni Rinaldi's avatar
Deni Rinaldi committed
583 584 585 586 587 588 589 590 591 592 593 594 595
                january: i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
                february: i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
                march: i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
                april: i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
                may: i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
                june: i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
                july: i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
                august: i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
                september: i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
                october: i[0] === 3 && i[16] === "" ? "0.0" : String(Number(i[16]).toFixed(1)),
                november: i[0] === 3 && i[17] === "" ? "0.0" : String(Number(i[17]).toFixed(1)),
                december: i[0] === 3 && i[18] === "" ? "0.0" : String(Number(i[18]).toFixed(1)),
                total_current_year: i[0] === 3 && i[19] === "" ? "0.0" : String(Number(i[19]).toFixed(1)),
Deni Rinaldi's avatar
Deni Rinaldi committed
596 597
            })
        })
syadziy's avatar
syadziy committed
598
        console.log(JSON.stringify(data))
Deni Rinaldi's avatar
Deni Rinaldi committed
599
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
600
            "outlook_pa_id": this.props.outlook_pa_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
601 602 603 604 605 606
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "balance_sheet": data,
            "status": "submitted"
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
607
        api.create().validateSubmitReportOLPA(payload).then((response) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
608
            // console.log(response)
faisalhamdi's avatar
faisalhamdi committed
609 610 611 612 613 614 615
            // 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
616
                            this.setState({ kansas: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
617 618 619
                                this.handleValidate()
                            })
                        } else {
faisalhamdi's avatar
faisalhamdi committed
620
                            this.setState({ kansas: 0 })
faisalhamdi's avatar
faisalhamdi committed
621 622 623 624
                        }
                    } else {
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: true })
                        if (kansas == 0) {
faisalhamdi's avatar
faisalhamdi committed
625
                            this.setState({ kansas: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
626 627 628
                                this.handleValidate()
                            })
                        } else {
faisalhamdi's avatar
faisalhamdi committed
629
                            this.setState({ kansas: 0 })
faisalhamdi's avatar
faisalhamdi committed
630 631 632 633
                        }
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
634
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
635 636 637 638 639 640 641
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
642
            } else {
faisalhamdi's avatar
faisalhamdi committed
643
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
Deni Rinaldi's avatar
Deni Rinaldi committed
644 645 646 647 648 649 650 651 652 653 654
            }
        })
    }

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

    render() {
        let dataTable2 = this.state.dataTable
        const handleChange = (value, tableMeta, type) => {
faisalhamdi's avatar
faisalhamdi committed
655
            console.log(dataTable2);
Deni Rinaldi's avatar
Deni Rinaldi committed
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
            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
671

Deni Rinaldi's avatar
Deni Rinaldi committed
672 673 674 675
        const handleValue = (data) => {
            let total = 0
            dataTable2.map((item, index) => {
                if (data.rowData[1] === item[2]) {
Deni Rinaldi's avatar
Deni Rinaldi committed
676 677
                    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
678 679 680 681 682 683 684
                }
            })
            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
685

syadziy's avatar
syadziy committed
686 687 688 689
        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
690
                    // console.log(index)
syadziy's avatar
syadziy committed
691
                    if (index >= 7 && index <= 18) {
syadziy's avatar
syadziy committed
692
                        // console.log(item.value + "aaa")
syadziy's avatar
syadziy committed
693 694 695 696 697 698 699 700 701 702 703 704 705 706
                        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
707
            // console.log(total)
syadziy's avatar
syadziy committed
708 709
            return total
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
710 711

        const handleValueFormula = (value, tableMeta, column, periode, forecast) => {
syadziy's avatar
syadziy committed
712 713
            // console.log(value)
            // console.log(tableMeta.rowData[5])
Deni Rinaldi's avatar
Deni Rinaldi committed
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
            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
729
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
730
                        baru.push(String(item))
Deni Rinaldi's avatar
Deni Rinaldi committed
731 732 733 734
                    }
                }
            })

Deni Rinaldi's avatar
Deni Rinaldi committed
735 736 737
            baru.map((item, index) => {
                if (item == '-' || item == '+' || item == '/' || item == '*') {
                    anjay.push(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
738
                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760
                    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
761 762 763 764 765 766 767 768 769 770
                        } 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
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
                        }
                    } 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
787 788
                            // if (tableMeta.rowData[5] == 'R/E (Cummulative)') {
                            // console.log(tst, data, tableMeta.rowData[data]);}
Deni Rinaldi's avatar
Deni Rinaldi committed
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
                        }
                    } 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
804 805
                }
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
806 807
            // console.log(baru)
            // console.log(anjay)
syadziy's avatar
syadziy committed
808 809 810 811 812
            // if (tableMeta.rowData[5] == 'R/E (Cummulative)') {
            //     console.log(splitFormula)
            //     console.log(baru)
            //     console.log(anjay)
            // }
Deni Rinaldi's avatar
Deni Rinaldi committed
813 814
            let total = 0
            let opt = ""
Deni Rinaldi's avatar
Deni Rinaldi committed
815
            anjay.map((item, index) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
816 817 818 819 820 821 822 823 824
                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
825
                    item = item == "" ? 0 : item
Deni Rinaldi's avatar
Deni Rinaldi committed
826 827 828 829 830 831 832
                    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
833
                        total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
834
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
835
                        total += Number(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
836 837 838
                    }
                }
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
839 840 841 842 843 844 845 846 847 848 849 850 851 852
            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
853 854 855
            return a
        }

Deni Rinaldi's avatar
Deni Rinaldi committed
856 857
        const handleForecast = (tableMeta, periode, column) => {
            let total = 0
d.arizona's avatar
d.arizona committed
858 859 860 861 862 863
            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
864 865 866 867
            // console.log(total)
            return total
        }

Deni Rinaldi's avatar
Deni Rinaldi committed
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931
        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
932 933 934 935 936 937 938 939 940 941 942
                                    // <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}
Deni Rinaldi's avatar
Deni Rinaldi committed
943
                                    //                 value={Number(value).toFixed(1)}
idlanirined's avatar
idlanirined committed
944 945 946 947
                                    //             />
                                    //         }
                                    //     />
                                    // </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
948 949 950 951 952 953 954
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
955
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
Deni Rinaldi's avatar
Deni Rinaldi committed
956 957
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
958 959
                                                    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)}
Deni Rinaldi's avatar
Deni Rinaldi committed
960
                                                    value={Number(value).toFixed(1)}
idlanirined's avatar
idlanirined committed
961 962 963 964
                                                    onBlur={(event) => {
                                                        handleChange(event.target.value, tableMeta)
                                                        // console.log(dataTable2)
                                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
965 966 967 968 969 970 971 972 973 974 975 976 977
                                                />
                                            }
                                        />
                                    </div>
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jan ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
978
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
979 980 981 982 983 984 985
                        <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
986 987 988 989 990 991 992 993 994 995
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
996
                                    />
faisalhamdi's avatar
faisalhamdi committed
997
                                    :
idlanirined's avatar
idlanirined committed
998 999 1000 1001 1002 1003 1004
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1005
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1006 1007
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1008
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1009
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1010
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1011 1012
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1013
                                        />
idlanirined's avatar
idlanirined committed
1014
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1015 1016 1017 1018 1019 1020 1021 1022 1023
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Feb ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1024
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1025 1026 1027 1028 1029 1030 1031
                        <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
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1042
                                    />
faisalhamdi's avatar
faisalhamdi committed
1043
                                    :
idlanirined's avatar
idlanirined committed
1044 1045 1046 1047 1048 1049 1050
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1051
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1052 1053
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1054
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1055
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1056
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1057 1058
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1059
                                        />
idlanirined's avatar
idlanirined committed
1060
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1061 1062 1063 1064 1065 1066 1067 1068 1069
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Mar ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1070
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1071 1072 1073 1074 1075 1076 1077
                        <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
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1088
                                    />
faisalhamdi's avatar
faisalhamdi committed
1089
                                    :
idlanirined's avatar
idlanirined committed
1090 1091 1092 1093 1094 1095 1096
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1097
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1098 1099
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1100
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1101
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1102
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1103 1104
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1105
                                        />
idlanirined's avatar
idlanirined committed
1106
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1107 1108 1109 1110 1111 1112 1113 1114 1115
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Apr ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1116
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1117 1118 1119 1120 1121 1122 1123
                        <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
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1134
                                    />
faisalhamdi's avatar
faisalhamdi committed
1135
                                    :
idlanirined's avatar
idlanirined committed
1136 1137 1138 1139 1140 1141 1142
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1143
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1144 1145
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1146
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1147
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1148
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1149 1150
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1151
                                        />
idlanirined's avatar
idlanirined committed
1152
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1153 1154 1155 1156 1157 1158 1159 1160 1161
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `May ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1162
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1163 1164 1165 1166 1167 1168 1169
                        <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
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1180
                                    />
faisalhamdi's avatar
faisalhamdi committed
1181
                                    :
idlanirined's avatar
idlanirined committed
1182 1183 1184 1185 1186 1187 1188
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1189
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1190 1191
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1192
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1193
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1194
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1195 1196
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1197
                                        />
idlanirined's avatar
idlanirined committed
1198
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1199 1200 1201 1202 1203 1204 1205 1206 1207
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jun ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1208
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1209 1210 1211 1212 1213 1214 1215
                        <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
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1226
                                    />
faisalhamdi's avatar
faisalhamdi committed
1227
                                    :
idlanirined's avatar
idlanirined committed
1228 1229 1230 1231 1232 1233 1234
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1235
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1236 1237
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1238
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1239
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1240
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1241 1242
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1243
                                        />
idlanirined's avatar
idlanirined committed
1244
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1245 1246 1247 1248 1249 1250 1251 1252 1253
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Jul ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1254
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1255 1256 1257 1258 1259 1260 1261
                        <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
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1272
                                    />
faisalhamdi's avatar
faisalhamdi committed
1273
                                    :
idlanirined's avatar
idlanirined committed
1274 1275 1276 1277 1278 1279 1280
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1281
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1282 1283
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1284
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1285
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1286
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1287 1288
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1289
                                        />
idlanirined's avatar
idlanirined committed
1290
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1291 1292 1293 1294 1295 1296 1297 1298 1299
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Aug ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1300
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1301 1302 1303 1304 1305 1306 1307
                        <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
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1318
                                    />
faisalhamdi's avatar
faisalhamdi committed
1319
                                    :
idlanirined's avatar
idlanirined committed
1320 1321 1322 1323 1324 1325 1326
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1327
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1328 1329
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1330
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1331
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1332
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1333 1334
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1335
                                        />
idlanirined's avatar
idlanirined committed
1336
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1337 1338 1339 1340 1341 1342 1343 1344 1345
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Sep ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1346
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1347 1348 1349 1350 1351 1352 1353
                        <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
1354 1355 1356 1357 1358 1359 1360 1361 1362 1363
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1364
                                    />
faisalhamdi's avatar
faisalhamdi committed
1365
                                    :
idlanirined's avatar
idlanirined committed
1366 1367 1368 1369 1370 1371 1372
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1373
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1374 1375
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1376
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1377
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1378
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1379 1380
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1381
                                        />
idlanirined's avatar
idlanirined committed
1382
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1383 1384 1385 1386 1387 1388 1389 1390 1391
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Oct ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1392
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1393 1394 1395 1396 1397 1398 1399
                        <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
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409
                            {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}
                                        value={Number(value).toFixed(1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1410
                                    />
faisalhamdi's avatar
faisalhamdi committed
1411
                                    :
idlanirined's avatar
idlanirined committed
1412 1413 1414 1415 1416 1417 1418
                                    <div style={{ flex: 1 }}>
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            value={value}
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1419
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1420 1421
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1422
                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
1423
                                                    value={Number(value).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1424
                                                    decimalScale={1}
idlanirined's avatar
idlanirined committed
1425 1426
                                                />
                                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1427
                                        />
idlanirined's avatar
idlanirined committed
1428
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1429 1430 1431 1432 1433 1434 1435 1436 1437
                            }
                        </div>
                    )
                }
            }
        }, {
            name: `Nov ${this.props.periode}`,
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1438
                    <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderRight: '1px #fff solid' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1439 1440 1441 1442 1443 1444 1445
                        <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
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455
                            {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}
syadziy's avatar
syadziy committed
1456
                                        value={this.props.status === 'CLOSED' ? Number(value).toFixed(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
1457 1458
                                    />
                                    :
faisalhamdi's avatar
faisalhamdi committed
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469
                                    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
1470 1471
                                                        // 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}
faisalhamdi's avatar
faisalhamdi committed
1472 1473 1474 1475 1476 1477 1478
                                                        value={Number(value).toFixed(1)}
                                                        onBlur={(event) => {
                                                            handleChange(event.target.value, tableMeta)
                                                            // console.log(dataTable2)
                                                        }}
                                                    />
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1479
                                            />
faisalhamdi's avatar
faisalhamdi committed
1480 1481 1482
                                        </div> :
                                        tableMeta.rowData[0] === 2 ?
                                            <span style={{ fontSize: 12, textAlign: 'right' }}>
idlanirined's avatar
idlanirined committed
1483 1484
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1485
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1486 1487
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1488
                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1489
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
idlanirined's avatar
idlanirined committed
1490
                                                />
faisalhamdi's avatar
faisalhamdi committed
1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514
                                            </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}
                                                        value={Number(handleValueFormula(value, tableMeta)).toFixed(1)}
                                                    />
                                                    :
                                                    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}
                                                            value={Number(handleValueFormula(value, tableMeta)).toFixed(1)}
                                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
1515
                                                        :
faisalhamdi's avatar
faisalhamdi committed
1516 1517 1518 1519
                                                        tableMeta.rowData[0] === 1 ?
                                                            null
                                                            :
                                                            tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
1520
                                                                (Number(handleValidation(value, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(value, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
faisalhamdi's avatar
faisalhamdi committed
1521 1522 1523 1524 1525 1526 1527 1528
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
faisalhamdi's avatar
faisalhamdi committed
1529
                                                                            backgroundColor: 'transparent'
faisalhamdi's avatar
faisalhamdi committed
1530 1531 1532 1533 1534
                                                                        }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(value, tableMeta)).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553
                                                                    /> :
                                                                    <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)).toFixed(1)}
                                                                        />
                                                                    </LightTooltip>
faisalhamdi's avatar
faisalhamdi committed
1554 1555
                                                                :
                                                                null
faisalhamdi's avatar
faisalhamdi committed
1556
                            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1557 1558 1559 1560 1561
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1562
            name: `Dec ${this.props.periode}`,
Deni Rinaldi's avatar
Deni Rinaldi committed
1563 1564
            options: {
                customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1565 1566
                    <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
1567 1568 1569 1570 1571 1572
                    </TableCell>
                ),
                setCellProps: () => ({ style2 }),
                customBodyRender: (value, tableMeta, updateValue) => {
                    return (
                        <div style={{ textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582
                            {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}
syadziy's avatar
syadziy committed
1583
                                        value={this.props.status === 'CLOSED' ? Number(value).toFixed(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
1584
                                    />
faisalhamdi's avatar
faisalhamdi committed
1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596
                                    :
                                    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
1597 1598
                                                        // 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}
faisalhamdi's avatar
faisalhamdi committed
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609
                                                        value={Number(value).toFixed(1)}
                                                        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
1610 1611
                                                <NumberFormat
                                                    thousandSeparator={true}
faisalhamdi's avatar
faisalhamdi committed
1612
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
idlanirined's avatar
idlanirined committed
1613 1614
                                                    type="text"
                                                    placeholder=""
faisalhamdi's avatar
faisalhamdi committed
1615
                                                    disabled={true}
faisalhamdi's avatar
faisalhamdi committed
1616
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
idlanirined's avatar
idlanirined committed
1617
                                                />
faisalhamdi's avatar
faisalhamdi committed
1618
                                            </span>
Deni Rinaldi's avatar
Deni Rinaldi committed
1619
                                            :
faisalhamdi's avatar
faisalhamdi committed
1620 1621
                                            tableMeta.rowData[0] === 4 ?
                                                null
Deni Rinaldi's avatar
Deni Rinaldi committed
1622
                                                :
faisalhamdi's avatar
faisalhamdi committed
1623 1624 1625 1626 1627 1628 1629 1630 1631
                                                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}
                                                        value={Number(handleValueFormula(value, tableMeta)).toFixed(1)}
                                                    />
Deni Rinaldi's avatar
Deni Rinaldi committed
1632
                                                    :
faisalhamdi's avatar
faisalhamdi committed
1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646
                                                    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}
                                                            value={Number(handleValueFormula(value, tableMeta)).toFixed(1)}
                                                        />
                                                        :
                                                        tableMeta.rowData[0] === 1 ?
                                                            null
                                                            :
                                                            tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
1647
                                                                (Number(handleValidation(value, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(value, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
faisalhamdi's avatar
faisalhamdi committed
1648 1649 1650 1651 1652 1653 1654 1655
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
faisalhamdi's avatar
faisalhamdi committed
1656
                                                                            backgroundColor: 'transparent'
Faisal Hamdi's avatar
Faisal Hamdi committed
1657
                                                                        }}
faisalhamdi's avatar
faisalhamdi committed
1658 1659 1660 1661
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(value, tableMeta)).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680
                                                                    /> :
                                                                    <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)).toFixed(1)}
                                                                        />
                                                                    </LightTooltip>
faisalhamdi's avatar
faisalhamdi committed
1681 1682 1683 1684 1685 1686 1687 1688
                                                                :
                                                                null
                            }
                        </div>
                    )
                }
            }
        }, {
faisalhamdi's avatar
faisalhamdi committed
1689
            name: `31 Dec ${this.props.periode} Total`,
faisalhamdi's avatar
faisalhamdi committed
1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723
            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}
                                        value={Number(value).toFixed(1)}
                                    />
                                    :
                                    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
1724 1725
                                                        // 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}
faisalhamdi's avatar
faisalhamdi committed
1726 1727 1728 1729 1730 1731 1732 1733 1734 1735
                                                        value={Number(value).toFixed(1)}
                                                        onBlur={(event) => {
                                                            handleChange(event.target.value, tableMeta)
                                                            // console.log(dataTable2)
                                                        }}
                                                    />
                                                }
                                            />
                                        </div> :
                                        tableMeta.rowData[0] === 2 ?
faisalhamdi's avatar
faisalhamdi committed
1736 1737 1738 1739 1740 1741 1742 1743
                                            <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}
                                                    value={Number(handleValue(tableMeta)).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1744
                                                />
faisalhamdi's avatar
faisalhamdi committed
1745
                                            </span>
faisalhamdi's avatar
faisalhamdi committed
1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756
                                            :
                                            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
1757
                                                        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
1758 1759 1760 1761 1762 1763 1764 1765 1766
                                                    />
                                                    :
                                                    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
1767
                                                            value={Number(handleForecast(tableMeta, `${Number(this.props.periode)}`, 19)).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1768
                                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
1769
                                                        :
faisalhamdi's avatar
faisalhamdi committed
1770 1771 1772 1773
                                                        tableMeta.rowData[0] === 1 ?
                                                            null
                                                            :
                                                            tableMeta.rowData[0] === 7 ?
faisalhamdi's avatar
faisalhamdi committed
1774
                                                                (Number(handleValidation(value, tableMeta)).toFixed(1) >= Number(this.state.minValue) && Number(handleValidation(value, tableMeta)).toFixed(1) <= Number(this.state.maxValue)) ?
faisalhamdi's avatar
faisalhamdi committed
1775 1776 1777 1778 1779 1780 1781 1782
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{
                                                                            fontSize: 12,
                                                                            textAlign: 'right',
                                                                            borderColor: 'transparent',
                                                                            margin: 0,
                                                                            width: 96,
faisalhamdi's avatar
faisalhamdi committed
1783
                                                                            backgroundColor: 'transparent'
faisalhamdi's avatar
faisalhamdi committed
1784 1785 1786 1787 1788
                                                                        }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(handleValidation(value, tableMeta)).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807
                                                                    /> :
                                                                    <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)).toFixed(1)}
                                                                        />
                                                                    </LightTooltip>
faisalhamdi's avatar
faisalhamdi committed
1808 1809
                                                                :
                                                                null
Deni Rinaldi's avatar
Deni Rinaldi committed
1810 1811 1812 1813 1814
                            }
                        </div>
                    )
                }
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826
        },
        {
            name: "",
            options: {
                display: false
            }
        },
        {
            name: "",
            options: {
                display: false
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842
        }]

        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
1843
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Outlook Performance Appraisal Submission</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864
                </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>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
faisalhamdi's avatar
faisalhamdi committed
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887
                                        {/* {this.props.isApprover == true || this.state.dataTable.length == 0 ? null : */}
                                        {this.props.isApprover == true || this.state.get_for == 'view' ?
                                            <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> :
Deni Rinaldi's avatar
Deni Rinaldi committed
1888
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
faisalhamdi's avatar
faisalhamdi committed
1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916
                                                <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" />
Deni Rinaldi's avatar
Deni Rinaldi committed
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 1947 1948 1949 1950
                                                <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="download" place="bottom" type="light" effect="solid" />
                                            </div>
                                        }
                                    </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
1951 1952 1953 1954 1955 1956 1957 1958 1959
                                <div style={{ display: 'flex' }}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
                                        {
                                            this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
faisalhamdi's avatar
faisalhamdi committed
1960
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
Riri Novita's avatar
Riri Novita committed
1961 1962 1963
                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1964
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5 }}>Notes : {this.state.notes}</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
                            </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
1983
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
1984 1985 1986
                                        </div>
                                    </button>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1987 1988
                                {this.props.isApprover === true ?
                                    <div className="col-2">
faisalhamdi's avatar
faisalhamdi committed
1989
                                    </div> :
faisalhamdi's avatar
faisalhamdi committed
1990
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
Riri Novita's avatar
Riri Novita committed
1991
                                        {this.state.get_for == 'view' && this.state.viewOnly && <button
faisalhamdi's avatar
faisalhamdi committed
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021
                                            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
2022
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043
                                                    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
2044 2045 2046
                                                this.state.saveDraft ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    :
2047 2048
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2049 2050
                                                            this.backToOLPA('draft')
                                                        })
faisalhamdi's avatar
faisalhamdi committed
2051 2052 2053 2054 2055 2056
                                            }
                                        >
                                            <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>}
2057 2058
                                        {this.state.get_for == 'edit' && 
                                        <button
faisalhamdi's avatar
faisalhamdi committed
2059 2060 2061 2062 2063
                                            type="button"
                                            disabled={this.state.buttonError}
                                            onClick={() => this.state.buttonError ?
                                                this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                :
2064 2065
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079
                                                        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>}
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117
                                }
                            </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>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    {this.state.dataLoaded && (
                                        <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                            {this.state.loading && loadingComponent}
                                            <MuiThemeProvider theme={getMuiTheme()}>
                                                <MUIDataTable
                                                    data={dataTable2}
                                                    columns={columns}
                                                    options={options}
                                                />
                                            </MuiThemeProvider>
                                        </div>
                                    )}
                                </div>

                                <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
2118
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
Deni Rinaldi's avatar
Deni Rinaldi committed
2119 2120 2121 2122
                                            </div>
                                        </button>
                                    </div>
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
2123
                                        {this.state.get_for == 'edit' && <button
Deni Rinaldi's avatar
Deni Rinaldi committed
2124 2125 2126 2127
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
2128
                                                cursor: 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2129 2130 2131 2132 2133
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
2134
                                                this.setState({ loading: true, dataTable: dataTable2 }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2135
                                                    setTimeout(() => {
2136
                                                        this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
2137 2138 2139 2140 2141 2142 2143
                                                    }, 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>
2144 2145 2146
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
                                            className="button"
Deni Rinaldi's avatar
Deni Rinaldi committed
2147 2148 2149 2150 2151 2152 2153 2154 2155
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: this.state.editable !== true ? 'pointer' : 'default',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
2156 2157 2158
                                                this.state.saveDraft ?
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete !', tipeAlert: 'error' })
                                                    :
2159 2160
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
2161 2162
                                                            this.uploadBalanceSheet('draft')
                                                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
2163 2164 2165 2166 2167
                                            }
                                        >
                                            <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>
2168 2169
                                        </button>}
                                        {this.state.get_for == 'edit' && 
Deni Rinaldi's avatar
Deni Rinaldi committed
2170 2171
                                        <button
                                            type="button"
2172 2173 2174 2175
                                            // disabled={this.state.buttonError}
                                            onClick={() => this.state.buttonError ?
                                                this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
                                                :
2176 2177
                                                this.state.handleDoubleClick == 1 ? null :
                                                    this.setState({ handleDoubleClick: 1 }, () => {
2178 2179
                                                        this.uploadBalanceSheet('submitted')
                                                    })}
Deni Rinaldi's avatar
Deni Rinaldi committed
2180 2181
                                            style={{
                                                backgroundColor: 'transparent',
2182
                                                cursor: this.state.buttonError === true ? 'default' : 'pointer',
Deni Rinaldi's avatar
Deni Rinaldi committed
2183 2184 2185 2186 2187 2188 2189
                                                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>
2190
                                        </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225
                                    </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>
                            <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={() => {
r.kurnia's avatar
r.kurnia committed
2226
                                    String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PA") && String(this.state.judul).includes("BALANCE") && String(this.state.judul).includes("SHEET") ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
            </div>
        )
    }
}