CorporateAnnualTargetMR.js 140 KB
Newer Older
faisalhamdi's avatar
faisalhamdi committed
1 2 3 4 5 6
import { Typography, Paper, createMuiTheme, ThemeProvider, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, withStyles, makeStyles, Snackbar } from '@material-ui/core';
import MUIDataTable from 'mui-datatables';
import React, { Component } from 'react'
import ReactTooltip from 'react-tooltip';
import Images from '../../assets/Images';
import api from '../../api';
7
import { fixNumber, titleCase } from '../../library/Utils';
faisalhamdi's avatar
faisalhamdi committed
8 9
import Tooltip from '@material-ui/core/Tooltip';
import NumberFormat from 'react-number-format';
faisalhamdi's avatar
faisalhamdi committed
10 11
import Constant from '../../library/Constant';
import { Alert, Autocomplete } from '@material-ui/lab';
faisalhamdi's avatar
faisalhamdi committed
12 13
import UploadFile from '../../library/Upload';
import { ExcelRenderer } from 'react-excel-renderer';
faisalhamdi's avatar
faisalhamdi committed
14
import { PropagateLoader } from 'react-spinners';
d.arizona's avatar
d.arizona committed
15
import * as R from 'ramda'
faisalhamdi's avatar
faisalhamdi committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

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,
    background: "white",
    zIndex: 101,
};
const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100,
    top: 0
};

const theme = createMuiTheme({
    overrides: {
        // Style sheet name ⚛️
        MuiInputBase: {
            input: {
                color: '#5198ea'
            }
        }
    },
});

export default class CorporateAnnualTargetMR extends Component {
    constructor(props) {
Deni Rinaldi's avatar
Deni Rinaldi committed
57
        super(props)
faisalhamdi's avatar
faisalhamdi committed
58 59
        this.state = {
            dataTables: [],
faisalhamdi's avatar
faisalhamdi committed
60 61
            loading: true,
            kpiTypeList: [],
faisalhamdi's avatar
faisalhamdi committed
62 63 64 65 66
            maxAchList: [],
            formulaYtdList: {
                options: [{ value: 'SUM' }, { value: 'AVG' }, { value: 'LAST' }],
                getOptionLabel: (option) => titleCase(option.value),
            },
faisalhamdi's avatar
faisalhamdi committed
67
            visibleCATMR: true,
faisalhamdi's avatar
faisalhamdi committed
68
            updateBy: [],
faisalhamdi's avatar
faisalhamdi committed
69 70
            notes: "",
            judulColumn: null,
d.arizona's avatar
d.arizona committed
71 72
            get_for: "view",
            parameterScore: [],
d.arizona's avatar
d.arizona committed
73
            parameterPerfom: [],
d.arizona's avatar
d.arizona committed
74 75
            totalScore: 0,
            perfomanceScore: '',
d.arizona's avatar
d.arizona committed
76
            buttonError: true,
d.arizona's avatar
d.arizona committed
77
            viewOnly: true,
d.arizona's avatar
d.arizona committed
78
            aa: 0,
79 80
            perfomanceScoreColor: '#fff',
            defaultCurrencyUpload: this.props.defaultCurrency,
Riri Novita's avatar
Riri Novita committed
81
            visibleAlertSave: false,
faisalhamdi's avatar
faisalhamdi committed
82
        }
faisalhamdi's avatar
faisalhamdi committed
83
        this.fileHandler = this.fileHandler.bind(this);
faisalhamdi's avatar
faisalhamdi committed
84 85 86
    }

    componentDidMount() {
d.arizona's avatar
d.arizona committed
87
        // this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
88 89
        this.getLatestUpdate()
        this.getKPIType()
faisalhamdi's avatar
faisalhamdi committed
90
        this.getMaxAch()
d.arizona's avatar
d.arizona committed
91
        this.getParameterGroup()
d.arizona's avatar
d.arizona committed
92
        this.getParameterGroupPerfom()
93
        this.handleViewOnly()
faisalhamdi's avatar
faisalhamdi committed
94 95
    }

faisalhamdi's avatar
faisalhamdi committed
96
    handleGetFor(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
97
        this.setState({ get_for: type }, () => {
d.arizona's avatar
d.arizona committed
98 99 100
            this.getLatestUpdate()
            this.getKPIType()
            this.getMaxAch()
faisalhamdi's avatar
faisalhamdi committed
101 102 103
        })
    }

d.arizona's avatar
d.arizona committed
104 105 106 107
    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
d.arizona's avatar
d.arizona committed
108
        let checkPrevRev = false
d.arizona's avatar
d.arizona committed
109 110 111 112 113
        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
114

d.arizona's avatar
d.arizona committed
115 116 117 118
        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
Deni Rinaldi's avatar
Deni Rinaldi committed
119
        }
d.arizona's avatar
d.arizona committed
120 121 122 123 124 125

        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
126

d.arizona's avatar
d.arizona committed
127 128 129 130 131 132
        if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
            checkStatus = true
        } else {
            checkStatus = false
        }

d.arizona's avatar
d.arizona committed
133
        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
d.arizona's avatar
d.arizona committed
134
        // this.setState({ viewOnly: true })
d.arizona's avatar
d.arizona committed
135 136
    }

d.arizona's avatar
d.arizona committed
137
    getParameterGroup() {
syadziy's avatar
syadziy committed
138 139 140 141 142 143 144 145 146
        this.setState({ loading: true }, () => {
            api.create().getParameterByGroupName({
                "group_name": 'ACHIEVEMENT_KPI'
            }).then((response) => {
                console.log(response.data)
                if (response.data) {
                    this.setState({ parameterScore: response.data.data, loading: false })
                }
            })
d.arizona's avatar
d.arizona committed
147 148 149
        })
    }

d.arizona's avatar
d.arizona committed
150
    getParameterGroupPerfom() {
syadziy's avatar
syadziy committed
151 152 153 154 155 156 157 158 159
        this.setState({ loading: true }, () => {
            api.create().getParameterByGroupName({
                "group_name": "PERFORMANCE_KPI"
            }).then((response) => {
                console.log(response.data)
                if (response.data) {
                    this.setState({ parameterPerfom: response.data.data, loading: false })
                }
            })
d.arizona's avatar
d.arizona committed
160 161 162
        })
    }

faisalhamdi's avatar
faisalhamdi committed
163
    getLatestUpdate() {
faisalhamdi's avatar
faisalhamdi committed
164 165 166 167 168 169
        let payload = {
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "monthly_report_id": this.props.monthlyReportId,
Riri Novita's avatar
Riri Novita committed
170
            "months": this.props.month.month_id
faisalhamdi's avatar
faisalhamdi committed
171
        }
d.arizona's avatar
d.arizona committed
172
        // console.log(payload)
faisalhamdi's avatar
faisalhamdi committed
173
        api.create().getLastestUpdateMR(payload).then(response => {
rifkaki's avatar
rifkaki committed
174
            // console.log(JSON.stringify(response))
faisalhamdi's avatar
faisalhamdi committed
175 176 177
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
faisalhamdi's avatar
faisalhamdi committed
178
                        updateBy: response.data.data.detail === null ? [] : response.data.data.detail,
faisalhamdi's avatar
faisalhamdi committed
179
                        notes: response.data.data.notes_update === null ? "" : response.data.data.notes_update
faisalhamdi's avatar
faisalhamdi committed
180 181 182
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, typeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
183
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
184 185 186 187 188 189 190 191
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
d.arizona's avatar
d.arizona committed
192
                // console.log('brrrrrrrr')
faisalhamdi's avatar
faisalhamdi committed
193 194 195 196 197 198 199 200 201
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

    getItemHierarki() {
        let payload = {
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
faisalhamdi's avatar
faisalhamdi committed
202
            "periode": this.props.periode,
faisalhamdi's avatar
faisalhamdi committed
203 204
            "company_id": this.props.company.company_id,
            "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
205
            "months": this.props.month.month_id,
206
            "currency_id": this.props.defaultCurrency.id,
d.arizona's avatar
d.arizona committed
207
            "get_for": this.state.get_for
faisalhamdi's avatar
faisalhamdi committed
208
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
209

Riri Novita's avatar
Riri Novita committed
210
        api.create().getHierarkiMontlyReportCAT(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
211
            let dataTable = []
faisalhamdi's avatar
faisalhamdi committed
212
            console.log(payload);
faisalhamdi's avatar
faisalhamdi committed
213 214
            console.log(response);
            if (response.data) {
faisalhamdi's avatar
faisalhamdi committed
215 216
                if (response.data.status === 'success') {
                    let res = response.data.data
d.arizona's avatar
d.arizona committed
217
                    const handlePushChild = (item, index, length) => {
faisalhamdi's avatar
faisalhamdi committed
218 219 220
                        let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                        if (indexIDzz === -1) {
                            let parentTrue = item.parent_name == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || item.parent_name == 'CUSTOMER PERSPECTIVE'
221 222
                            let weight = String(item.weight).includes('%') ? String(item.weight).substr(0, String(item.weight).length - 1) : String(item.weight)
                            let weightTB = String(item.corporate_annual_target.weight).includes('%') ? String(item.corporate_annual_target.weight).substr(0, String(item.corporate_annual_target.weight).length - 1) : String(item.corporate_annual_target.weight)
rifkaki's avatar
rifkaki committed
223
                            // console.log(weight)
faisalhamdi's avatar
faisalhamdi committed
224 225 226 227 228 229 230
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
d.arizona's avatar
d.arizona committed
231
                                // item.corporate_annual_target.weight == "" ? Number(0).toFixed(1) : Number(weight).toFixed(1),
d.arizona's avatar
d.arizona committed
232
                                parentTrue ? weight : weightTB,
faisalhamdi's avatar
faisalhamdi committed
233
                                parentTrue ? item.corporate_annual_target.uom : item.uom,
d.arizona's avatar
d.arizona committed
234
                                parentTrue ? item.corporate_annual_target.jenis_kpi == "" ? null : item.corporate_annual_target.jenis_kpi : item.jenis_kpi == "" ? null : item.kpi_type,
faisalhamdi's avatar
faisalhamdi committed
235 236 237
                                // parentTrue ? item.corporate_annual_target.kpi_type == "" ? null : { value: item.corporate_annual_target.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
                                parentTrue ? item.corporate_annual_target.max_ach == "" ? null : titleCase(item.corporate_annual_target.max_ach) : item.max_ach == "" ? null : titleCase(item.max_ach),
                                // parentTrue ? item.corporate_annual_target.max_ach == "" ? null : { value: titleCase(item.corporate_annual_target.max_ach) } : item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
d.arizona's avatar
d.arizona committed
238
                                item.corporate_annual_target.formula_ytd == "" ? null : item.corporate_annual_target.formula_ytd,
faisalhamdi's avatar
faisalhamdi committed
239
                                // parentTrue ? item.corporate_annual_target.formula == "" ? null : { value: item.corporate_annual_target.formula } : item.formula_ytd == "" ? null : { value: item.formula_ytd },
240
                                item.corporate_annual_target.actual_monthly == "" ? item.corporate_annual_target.actual_monthly : String(item.corporate_annual_target.actual_monthly).indexOf(".") == -1 ? Number(item.corporate_annual_target.actual_monthly) : Number(item.corporate_annual_target.actual_monthly),
Deni Rinaldi's avatar
Deni Rinaldi committed
241 242 243 244 245 246
                                item.corporate_annual_target.target_monthly === null ? "0" : item.corporate_annual_target.target_monthly,
                                item.corporate_annual_target.achivement_monthly === null ? "0" : item.corporate_annual_target.achivement_monthly,
                                item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score,
                                item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight,
                                item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes,
                                item.corporate_annual_target.actual_formula === null ? [] : item.corporate_annual_target.actual_formula,
d.arizona's avatar
d.arizona committed
247
                                item.order
faisalhamdi's avatar
faisalhamdi committed
248
                            ])
d.arizona's avatar
d.arizona committed
249
                            // let index = dataTable.findIndex((val) => val[5] == item.description)
d.arizona's avatar
d.arizona committed
250
                            // console.log(index, length - 1)
d.arizona's avatar
d.arizona committed
251
                            if (index == length - 1 && item.parent_name == "LEARNING & GROWTH PERSPECTIVE") {
d.arizona's avatar
d.arizona committed
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
                                dataTable.push([
                                    4,
                                    0,
                                    null,
                                    "",
                                    0,
                                    "",
                                    0.0,
                                    "",
                                    null,
                                    null,
                                    "",
                                    "",
                                    0.0,
                                    "",
                                    "",
                                    "",
                                    "",
                                    [],
                                    item.order + 1
                                ])
                            }
faisalhamdi's avatar
faisalhamdi committed
274 275 276 277
                        }
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
d.arizona's avatar
d.arizona committed
278 279
                                    // console.log(indexs, item.children.length)
                                    handlePushChild(items, indexs, item.children.length)
faisalhamdi's avatar
faisalhamdi committed
280 281 282 283 284
                                })
                            }
                        }
                    }
                    res.map((item, index) => {
faisalhamdi's avatar
faisalhamdi committed
285 286 287 288 289 290 291
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.description,
292
                            item.weight == '' ? Number(0) : Number(Number(item.weight) * 100),
faisalhamdi's avatar
faisalhamdi committed
293 294 295 296 297
                            item.uom,
                            item.kpi_type == "" ? null : item.kpi_type,
                            // item.kpi_type == "" ? null : { value: item.kpi_type },
                            item.max_ach == "" ? null : titleCase(item.max_ach),
                            // item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
d.arizona's avatar
d.arizona committed
298
                            item.corporate_annual_target.formula == "" ? null : item.corporate_annual_target.formula_ytd,
faisalhamdi's avatar
faisalhamdi committed
299
                            // item.formula == "" ? null : { value: item.formula_ytd },
300
                            item.corporate_annual_target.actual_monthly == "" ? item.corporate_annual_target.actual_monthly : String(item.corporate_annual_target.actual_monthly).indexOf(".") == -1 ? Number(item.corporate_annual_target.actual_monthly) : Number(item.corporate_annual_target.actual_monthly),
Deni Rinaldi's avatar
Deni Rinaldi committed
301 302 303 304 305 306
                            item.corporate_annual_target.target_monthly === null ? "0" : item.corporate_annual_target.target_monthly,
                            item.corporate_annual_target.achivement_monthly === null ? "0" : item.corporate_annual_target.achivement_monthly,
                            item.corporate_annual_target.score === null ? "0" : item.corporate_annual_target.score,
                            item.corporate_annual_target.score_x_weight === null ? "0" : item.corporate_annual_target.score_x_weight,
                            item.corporate_annual_target.notes === null ? "" : item.corporate_annual_target.notes,
                            item.corporate_annual_target.actual_formula === null ? [] : item.corporate_annual_target.actual_formula,
d.arizona's avatar
d.arizona committed
307
                            item.order
faisalhamdi's avatar
faisalhamdi committed
308
                        ])
faisalhamdi's avatar
faisalhamdi committed
309 310 311
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
d.arizona's avatar
d.arizona committed
312
                                    handlePushChild(items, indexs, item.children.length)
faisalhamdi's avatar
faisalhamdi committed
313 314
                                })
                            }
faisalhamdi's avatar
faisalhamdi committed
315
                        }
faisalhamdi's avatar
faisalhamdi committed
316 317
                    })
                    // console.log(dataTable);
d.arizona's avatar
d.arizona committed
318
                    this.setState({ dataTable, loading: false, saveDraft: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
319
                        this.handleCalculate(dataTable)
d.arizona's avatar
d.arizona committed
320
                    })
faisalhamdi's avatar
faisalhamdi committed
321 322
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
323
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
324 325 326 327
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
faisalhamdi's avatar
faisalhamdi committed
328
                        }
faisalhamdi's avatar
faisalhamdi committed
329 330 331
                    })
                }
            } else {
d.arizona's avatar
d.arizona committed
332 333
                // console.log('terrrr')
                // 
faisalhamdi's avatar
faisalhamdi committed
334
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, saveDraft: true })
faisalhamdi's avatar
faisalhamdi committed
335 336 337 338 339
            }
            console.log(dataTable);
        })
    }

340
    downloadTemplate = async () => {
Riri Novita's avatar
Riri Novita committed
341
        console.log(`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}&&currency_id=${this.props.defaultCurrency.id}`)
faisalhamdi's avatar
faisalhamdi committed
342
        let res = await fetch(
Riri Novita's avatar
Riri Novita committed
343
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}&&currency_id=${this.props.defaultCurrency.id}`
faisalhamdi's avatar
faisalhamdi committed
344 345
        )
        console.log(res);
faisalhamdi's avatar
faisalhamdi committed
346
        res = await res.blob()
faisalhamdi's avatar
faisalhamdi committed
347 348 349 350 351 352
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Template Monthly Report Corporate Annual Target.xlsx'
            a.click();
Deni Rinaldi's avatar
Deni Rinaldi committed
353
        }
faisalhamdi's avatar
faisalhamdi committed
354 355
    }

faisalhamdi's avatar
faisalhamdi committed
356
    async downloadAllData() {
faisalhamdi's avatar
faisalhamdi committed
357
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
faisalhamdi's avatar
faisalhamdi committed
358 359
        console.log(url);
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
360
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/export_monthly_report?monthly_report_id=${this.props.monthlyReportId === null ? "" : this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
faisalhamdi's avatar
faisalhamdi committed
361 362 363 364 365 366 367 368 369 370 371 372
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Monthly Report Corporate Annual Target - Performance.xlsx';
            a.click();
        }
    }

faisalhamdi's avatar
faisalhamdi committed
373 374 375 376 377 378 379 380
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
faisalhamdi's avatar
faisalhamdi committed
381
                console.log(isi);
faisalhamdi's avatar
faisalhamdi committed
382 383 384 385 386 387 388
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
faisalhamdi's avatar
faisalhamdi committed
389
                            weight: i[3] === undefined ? "" : (String(i[3])) === false ? "0" : String(i[3]).trim(),
faisalhamdi's avatar
faisalhamdi committed
390
                            uom: i[4] === undefined ? "" : (String(i[4])) === false ? "0" : String(i[4]).trim(),
faisalhamdi's avatar
faisalhamdi committed
391
                            jenis_kpi: i[5] === undefined ? "" : (String(i[5])) === false ? "0" : String(i[5]).trim(),
faisalhamdi's avatar
faisalhamdi committed
392 393 394 395 396 397 398 399 400 401 402
                            max_ach: i[6] === undefined ? "" : (String(i[6])) === false ? "0" : String(i[6]).trim(),
                            actual_monthly: i[7] === undefined ? "0.0" : (String(i[7])) === false ? "0" : String(i[7]).trim(),
                            notes: i[8] === undefined ? "" : (String(i[8])) === false ? "0" : String(i[8]).trim(),
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
                    months: this.props.month.month_id,
403 404
                    corporate_annual_target: payload,
                    status: "submitted"
faisalhamdi's avatar
faisalhamdi committed
405 406
                }
                console.log(body)
d.arizona's avatar
d.arizona committed
407
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
faisalhamdi's avatar
faisalhamdi committed
408 409 410
            }
        });
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
411

faisalhamdi's avatar
faisalhamdi committed
412
    checkUpload() {
Deni Rinaldi's avatar
Deni Rinaldi committed
413
        this.setState({ loading: true })
414 415 416 417 418
        let payload = {
            ...this.state.payload,
            currency_id: this.state.defaultCurrencyUpload?.id
        }
        api.create().checkUploadMonthlyReportCAT(payload).then(response => {
419
            // console.log(JSON.stringify(this.state.payload));
faisalhamdi's avatar
faisalhamdi committed
420 421
            console.log(this.state.payload)
            console.log(response)
faisalhamdi's avatar
faisalhamdi committed
422 423 424 425 426 427 428 429 430 431 432
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({ visibleUpload: false, loading: true, visibleCATMR: false })
                    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,
syadziy's avatar
syadziy committed
433
                            item.parent == null ? (String(item.weight).includes("%") ? Number(String(item.weight).trim().substr(0, String(item.weight).trim().length - 1)) : Number(item.weight) * 100) : (String(item.weight).includes("%") ? String(item.weight).trim().substr(0, String(item.weight).trim().length - 1) : item.weight),
faisalhamdi's avatar
faisalhamdi committed
434
                            item.uom,
faisalhamdi's avatar
faisalhamdi committed
435
                            item.jenis_kpi,
faisalhamdi's avatar
faisalhamdi committed
436
                            item.max_ach,
faisalhamdi's avatar
faisalhamdi committed
437
                            item.formula_ytd,
faisalhamdi's avatar
faisalhamdi committed
438 439 440 441 442
                            item.actual_monthly,
                            item.target_monthly,
                            item.achivement_monthly,
                            item.score,
                            item.score_x_weight,
faisalhamdi's avatar
faisalhamdi committed
443
                            item.notes,
Deni Rinaldi's avatar
Deni Rinaldi committed
444
                            item.actual_formula === null ? [] : item.actual_formula,
d.arizona's avatar
d.arizona committed
445
                            item.order,
faisalhamdi's avatar
faisalhamdi committed
446
                            item.error
faisalhamdi's avatar
faisalhamdi committed
447 448 449 450
                        ]
                    })
                    console.log(dataTable)
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
d.arizona's avatar
d.arizona committed
451
                        this.handleCalculate(dataTable)
faisalhamdi's avatar
faisalhamdi committed
452
                        this.state.dataTable.map(item => {
faisalhamdi's avatar
faisalhamdi committed
453
                            if (item[16].length > 0) {
faisalhamdi's avatar
faisalhamdi committed
454 455 456 457 458 459
                                console.log('masuk')
                                this.setState({ buttonError: true, errorPreview: true, editable: true })
                            }
                        })
                        console.log(this.state.dataTable);
                    })
Riri Novita's avatar
Riri Novita committed
460 461
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
462
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
463 464 465 466 467 468
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
faisalhamdi's avatar
faisalhamdi committed
469 470 471 472 473 474 475
                }
            }
        })
    }

    uploadCATMR(type) {
        let data = []
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    item_report: String(i[5]),
                    weight: String(i[6]),
                    uom: String(i[7]),
                    jenis_kpi: i[8] == null ? "" : i[8],
                    max_ach: i[9] == null ? "" : i[9],
                    formula_ytd: i[10] == null ? "" : i[10],
                    actual_monthly: String(Number(i[11])),
                    target_monthly: String(Number(i[12])),
                    achivement_monthly: String(Number(i[13])),
                    score: String(Number(i[14])),
                    score_x_weight: String(Number(i[15])),
                    notes: String(i[16])
                })
faisalhamdi's avatar
faisalhamdi committed
493
            })
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    item_report_id: i[1],
                    item_report: String(i[5]),
                    weight: String(i[6]),
                    uom: String(i[7]),
                    jenis_kpi: i[8] == null ? "" : i[8],
                    max_ach: i[9] == null ? "" : i[9],
                    formula_ytd: i[10] == null ? "" : i[10],
                    actual_monthly: String(fixNumber(Number(i[11]), 1)),
                    target_monthly: String(fixNumber(Number(i[12]), 1)),
                    achivement_monthly: String(fixNumber(Number(i[13]), 1)),
                    score: String(fixNumber(Number(i[14]), 0)),
                    score_x_weight: String(fixNumber(Number(i[15]), 2)),
                    notes: String(i[16])
                })
            })
        }

faisalhamdi's avatar
faisalhamdi committed
514
        let body = {
faisalhamdi's avatar
faisalhamdi committed
515
            // "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
516
            "monthly_report_id": this.props.monthlyReportId,
faisalhamdi's avatar
faisalhamdi committed
517
            "company_id": this.props.company.company_id,
d.arizona's avatar
d.arizona committed
518
            "periode": this.props.periode,
faisalhamdi's avatar
faisalhamdi committed
519 520 521
            "report_id": this.props.report_id,
            "status": type,
            "months": this.props.month.month_id,
522
            "currency_id": this.props.defaultCurrency.id,
523 524 525
            "corporate_annual_target": data,
            "total_score": this.state.totalScore,
            "performance": this.state.perfomanceScore
faisalhamdi's avatar
faisalhamdi committed
526
        }
faisalhamdi's avatar
faisalhamdi committed
527
        console.log(JSON.stringify(body));
faisalhamdi's avatar
faisalhamdi committed
528
        api.create('UPLOAD').uploadMonthlyReportCAT(body).then(response => {
rifkaki's avatar
rifkaki committed
529 530
            console.log(body);
            console.log(response);
faisalhamdi's avatar
faisalhamdi committed
531 532
            if (response.data) {
                if (response.data.status === "success") {
Riri Novita's avatar
Riri Novita committed
533 534
                    this.props.saveToMonthlyReport()
                    // this.props.onClickClose()
faisalhamdi's avatar
faisalhamdi committed
535 536
                    // this.props.getReport()
                } else {
537 538 539 540 541 542 543 544 545 546 547 548
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ visibleAlertSave: true, alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
faisalhamdi's avatar
faisalhamdi committed
549 550 551 552 553 554 555
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
    getKPIType() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'KPI_TYPE'
        }
        api.create().getAllSettingByType(body).then(response => {
            console.log(response)
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        // // // console.log(data)
                        let inputKPI = []

                        data.map((item) => {
                            inputKPI.push({
                                value: item.value
                            })
                        })
                        let defaultProps = {
                            options: inputKPI,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
                        // // // console.log(defaultProps)
                        this.setState({ kpiTypeList: defaultProps })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
584
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
    getMaxAch() {
        let body = {
            group: 'CAT',
            company_id: this.props.company.company_id,
            type: 'MAX_ACHIEVEMENT'
        }
        api.create().getAllSettingByType(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        let inputMaxAch = data.map((item) => {
                            return {
                                value: item.value
                            }
                        })
                        let defaultProps = {
                            options: inputMaxAch,
                            getOptionLabel: (option) => titleCase(option.value),
                        };
                        // setTimeout(() => {
syadziy's avatar
syadziy committed
623 624 625
                        this.setState({ maxAchList: defaultProps }, () => {
                            this.getItemHierarki()
                        })
faisalhamdi's avatar
faisalhamdi committed
626 627 628
                        // }, 300);
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
629
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
630 631 632 633 634 635 636 637 638 639 640 641 642 643
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                        // alert(response.data.message)
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
644

faisalhamdi's avatar
faisalhamdi committed
645 646 647
        })
    }

faisalhamdi's avatar
faisalhamdi committed
648 649 650 651
    backToMonthlyReport(type) {
        this.setState({ loading: true })
        console.log(this.state.dataTable);
        let data = []
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
        if (this.props.defaultCurrency.id == 2) {
            this.state.dataTable.map(i => {
                data.push({
                    "item_report_id": i[1],
                    "weight": i[6],
                    "uom": i[7],
                    "jenis_kpi": i[8] == null ? "" : i[8],
                    "max_ach": i[9] == null ? "" : i[9],
                    "formula_ytd": i[10] == null ? "" : i[10],
                    "actual_monthly": i[11] == null || i[11] == "" ? 0.0 : String(Number(i[11])),
                    "target_monthly": i[12] == null || i[12] == "" ? 0.0 : String(Number(i[12])),
                    "achivement_monthly": String(Number(i[13])),
                    "score": String(Number(i[14])),
                    "score_x_weight": String(Number(i[15])),
                    "notes": i[16]
                })
faisalhamdi's avatar
faisalhamdi committed
668
            })
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687
        } else {
            this.state.dataTable.map(i => {
                data.push({
                    "item_report_id": i[1],
                    "weight": i[6],
                    "uom": i[7],
                    "jenis_kpi": i[8] == null ? "" : i[8],
                    "max_ach": i[9] == null ? "" : i[9],
                    "formula_ytd": i[10] == null ? "" : i[10],
                    "actual_monthly": i[11] == null || i[11] == "" ? 0.0 : String(fixNumber(Number(i[11]), 1)),
                    "target_monthly": i[12] == null || i[12] == "" ? 0.0 : String(fixNumber(Number(i[12]), 1)),
                    "achivement_monthly": String(fixNumber(Number(i[13]), 1)),
                    "score": String(fixNumber(Number(i[14]), 0)),
                    "score_x_weight": String(fixNumber(Number(i[15]), 2)),
                    "notes": i[16]
                })
            })
        }

faisalhamdi's avatar
faisalhamdi committed
688 689 690
        let payload = {
            "monthly_report_id": this.props.monthlyReportId,
            "company_id": this.props.company.company_id,
d.arizona's avatar
d.arizona committed
691
            "periode": this.props.periode,
faisalhamdi's avatar
faisalhamdi committed
692 693 694
            "report_id": this.props.report_id,
            "status": type,
            "months": this.props.month.month_id,
695
            "currency_id": this.props.defaultCurrency.id,
696 697 698
            "corporate_annual_target": data,
            "total_score": this.state.totalScore,
            "performance": this.state.perfomanceScore
faisalhamdi's avatar
faisalhamdi committed
699
        }
700 701
        // console.log(JSON.stringify(payload));
        console.log(payload);
Deni Rinaldi's avatar
Deni Rinaldi committed
702

faisalhamdi's avatar
faisalhamdi committed
703 704 705 706 707 708
        api.create('UPLOAD').createMonthlyReportCAT(payload).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
                    this.props.saveToMonthlyReport()
                } else {
709 710 711 712 713 714 715 716 717 718 719 720 721 722
                    if (response.data?.message == "Please Set Up Rate Currency First") {
                        this.setState({ visibleAlertSave: true })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                            document.body.style.overflow = 'unset';
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                            this.props.saveToMonthlyReport()
                        })
                    }
723
                }
Riri Novita's avatar
Riri Novita committed
724 725 726 727 728
                // else {
                //     this.setState({ loading: false }, () => {
                //         this.props.saveToMonthlyReport()
                //     })
                // }
faisalhamdi's avatar
faisalhamdi committed
729 730
            } else {
                this.setState({ loading: false }, () => {
d.arizona's avatar
d.arizona committed
731
                    // this.getSubmission()
faisalhamdi's avatar
faisalhamdi committed
732 733
                    document.body.style.overflow = 'unset';
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
734 735
            }
        })
faisalhamdi's avatar
faisalhamdi committed
736 737 738 739 740 741
    }

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

d.arizona's avatar
d.arizona committed
742
    handleCalculate(datatable2) {
d.arizona's avatar
d.arizona committed
743
        // console.log(datatable2)
d.arizona's avatar
d.arizona committed
744
        this.setState({ loading: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
745 746
            let total = 0
            let perfomanceScore = ''
747
            let totalWeight = 0
d.arizona's avatar
d.arizona committed
748
            // console.log(datatable2)
d.arizona's avatar
d.arizona committed
749
            let datatable3 = datatable2.map((item, index) => {
750 751 752 753 754 755 756 757 758 759
                // console.log(item[6])
                //total weight
                if (item[0] !== 1 && item[0] !== 4) {
                    if (item[12] == '' || String(item[12]) == '0' || String(item[12]) == '0.0') {
                        totalWeight += Number(0)
                    } else {
                        totalWeight += Number(item[6])
                    }
                }

d.arizona's avatar
d.arizona committed
760 761 762 763 764
                //ach
                let totalAch = 0
                if (item[8] == 'HIB') {
                    let actual = item[11] == "" ? 0 : Number(item[11])
                    let target = item[12] == "" ? 0 : Number(item[12])
d.arizona's avatar
d.arizona committed
765 766 767 768 769 770 771 772 773 774 775 776 777
                    // if (item[5] == "Striping Ratio (SR) YTD") {
                    //     console.log(actual)
                    //     console.log(target)
                    //     console.log(actual/target)
                    // }
                    if (target < 0) {
                        if (actual > target) {
                            totalAch = (actual / target) - 1
                        } else {
                            totalAch = (actual / target)
                        }
                    } else if (target == 0) {
                        if (target >= actual) {
d.arizona's avatar
d.arizona committed
778
                            totalAch = 1.26
d.arizona's avatar
d.arizona committed
779 780 781 782 783 784 785
                        } else {
                            totalAch = 0
                        }
                    } else {
                        if (actual == target) {
                            totalAch = (actual / target)
                        } else {
d.arizona's avatar
d.arizona committed
786
                            totalAch = 2 - (actual / target)
d.arizona's avatar
d.arizona committed
787 788 789 790 791 792 793
                        }
                    }
                    // if (item[5] == "Striping Ratio (SR) YTD") {
                    //     console.log(actual)
                    //     console.log(target)
                    //     console.log(actual/target)
                    // }
d.arizona's avatar
d.arizona committed
794 795 796
                } else {
                    let actual = item[11] == "" ? 0 : Number(item[11])
                    let target = item[12] == "" ? 0 : Number(item[12])
d.arizona's avatar
d.arizona committed
797 798
                    if (target < 0) {
                        if (actual >= target) {
d.arizona's avatar
d.arizona committed
799
                            totalAch = ((target - actual) / target) + 1
d.arizona's avatar
d.arizona committed
800
                        } else {
d.arizona's avatar
d.arizona committed
801
                            totalAch = (target - actual) / target
d.arizona's avatar
d.arizona committed
802 803 804
                        }
                    } else if (target == 0) {
                        if (target <= actual) {
d.arizona's avatar
d.arizona committed
805
                            totalAch = 1.26
d.arizona's avatar
d.arizona committed
806 807 808 809
                        } else {
                            totalAch = 0
                        }
                    } else {
d.arizona's avatar
d.arizona committed
810
                        // if (actual <= target) {
d.arizona's avatar
d.arizona committed
811
                        totalAch = (actual / target)
d.arizona's avatar
d.arizona committed
812 813 814
                        // } else {
                        //     totalAch = 1 - (actual / target)
                        // }
d.arizona's avatar
d.arizona committed
815
                    }
d.arizona's avatar
d.arizona committed
816 817
                }
                totalAch = String(totalAch) == 'NaN' || String(totalAch) == 'Infinity' || String(totalAch) == '-Infinity' ? 0 : totalAch
818
                totalAch = this.props.lastStatus == 'APPROVED' ? item[13] : Number(totalAch) * 100
d.arizona's avatar
d.arizona committed
819

d.arizona's avatar
d.arizona committed
820 821 822 823 824 825 826 827
                //score
                let listParameter = this.state.parameterScore
                let parameterKpi = item[8]
                let parameterAch = String(item[9]).includes('%') ? `MAX${String(item[9]).substr(0, String(item[9]).length - 1)}` : String(item[9])
                let parameterMix = `${parameterKpi}_${parameterAch}`
                let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase())
                let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id)
                let totalScore = 0
d.arizona's avatar
d.arizona committed
828
                let achx100 = item[9] == '100%' && (item[8] == 'HIB' || item[8] == 'HIG') ? (Number(totalAch) / 100 > 1 ? 1 : Number(totalAch) / 100) : Number(totalAch) / 100
d.arizona's avatar
d.arizona committed
829
                // if (item[5] == "Max Quality drop from Bor-Barge") {
d.arizona's avatar
d.arizona committed
830
                // console.log(listParameterFilter)
d.arizona's avatar
d.arizona committed
831 832
                //     console.log(listParameterFilterCompany)
                //     // console.log(Number(item.min_value))
d.arizona's avatar
d.arizona committed
833
                // console.log(Number(item.max_value))
d.arizona's avatar
d.arizona committed
834
                // }
d.arizona's avatar
d.arizona committed
835
                if (listParameterFilterCompany.length == 0) {
d.arizona's avatar
d.arizona committed
836 837 838
                    listParameterFilter.map((items, index) => {
                        if (Number(achx100) >= Number(items.min_value) && Number(achx100) <= Number(items.max_value)) {
                            totalScore = Number(items.value)
d.arizona's avatar
d.arizona committed
839 840 841
                        }
                    })
                } else {
d.arizona's avatar
d.arizona committed
842 843 844
                    listParameterFilterCompany.map((items, index) => {
                        if (Number(achx100) >= Number(items.min_value) && Number(achx100) <= Number(items.max_value)) {
                            totalScore = Number(items.value)
d.arizona's avatar
d.arizona committed
845 846 847
                        }
                    })
                }
848
                let totalScorez = this.props.lastStatus == 'APPROVED' ? item[14] : this.props.defaultCurrency.id == 1 ? fixNumber(Number(totalScore), 0) : Number(totalScore)
d.arizona's avatar
d.arizona committed
849 850 851
                // if (item[5] == "Max Quality drop from Bor-Barge") {
                //     console.log(totalScorez)
                // }
d.arizona's avatar
d.arizona committed
852 853 854 855 856 857 858 859 860 861 862
                //Score X Weight
                let totalSW = 0
                let handlePercent = ''
                if (String(item[6]).includes('%')) {
                    handlePercent = String(item[6]).substr(0, String(item[6]).length - 1)
                } else {
                    handlePercent = String(item[6])
                }
                if (item[12] == '' || String(item[12]) == '0' || String(item[12]) == '0.0') {
                    totalSW = 0
                } else {
d.arizona's avatar
d.arizona committed
863
                    totalSW = (Number(totalScorez) * Number(handlePercent) / 100)
d.arizona's avatar
d.arizona committed
864
                }
865
                totalSW = this.props.lastStatus == 'APPROVED' ? item[15] : this.props.defaultCurrency.id == 1 ? fixNumber(Number(totalSW), 2) : Number(totalSW)
d.arizona's avatar
d.arizona committed
866 867 868
                if (item[0] !== 1 && item[0] !== 4) {
                    total += Number(totalSW)
                }
d.arizona's avatar
d.arizona committed
869 870 871 872 873 874 875
                // console.log(item[5])
                // console.log(totalAch);
                // console.log(achx100);
                // console.log(listParameterFilter);
                // console.log(listParameterFilterCompany);
                // console.log(totalScorez)
                // console.log(totalSW)
d.arizona's avatar
d.arizona committed
876 877
                // console.log(item[12])
                // console.log(item[5])
d.arizona's avatar
d.arizona committed
878
                // console.log(total)
d.arizona's avatar
d.arizona committed
879
                return [
d.arizona's avatar
d.arizona committed
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898
                    item[0],
                    item[1],
                    item[2],
                    item[3],
                    item[4],
                    item[5],
                    item[6],
                    item[7],
                    item[8],
                    item[9],
                    item[10],
                    item[11],
                    item[12],
                    totalAch,
                    totalScorez,
                    totalSW,
                    item[16],
                    item[17],
                    item[18],
d.arizona's avatar
d.arizona committed
899 900
                    //     item[19],
                    // ]
d.arizona's avatar
d.arizona committed
901
                ]
Deni Rinaldi's avatar
Deni Rinaldi committed
902
            })
d.arizona's avatar
d.arizona committed
903 904 905
            // console.log(totalWeight)
            // console.log(total)
            // console.log(datatable3);
d.arizona's avatar
d.arizona committed
906
            let totalWeightz = Number(totalWeight) / 100
907
            let totalz = this.props.defaultCurrency.id == 1 ? (Number(fixNumber(fixNumber(Number(total), 2) / Number(totalWeightz)), 2)) : Number(Number(total) / Number(totalWeightz))
d.arizona's avatar
d.arizona committed
908
            console.log(totalz)
d.arizona's avatar
d.arizona committed
909
            let lastTotal = R.equals(totalz, NaN) ? 0.0 : totalz
d.arizona's avatar
d.arizona committed
910 911 912 913 914 915

            if (R.equals(totalz, NaN) || R.equals(totalz, "NaN")) {
                lastTotal = 0.0
            } else {
                lastTotal = totalz
            }
d.arizona's avatar
d.arizona committed
916

917
            console.log(fixNumber(Number(Number(total), 2) / fixNumber(Number(totalWeightz)), 2))
d.arizona's avatar
d.arizona committed
918 919 920 921 922 923 924
            let indexPerform = this.state.parameterPerfom.findIndex((val) => val.company_id == this.props.company.company_id)
            let listPerfomanceDefault = []
            if (indexPerform == -1) {
                listPerfomanceDefault = this.state.parameterPerfom.filter((val) => String(val.company_name).toLocaleLowerCase() == "default")
            } else {
                listPerfomanceDefault = this.state.parameterPerfom.filter((val) => val.company_id == this.props.company.company_id)
            }
d.arizona's avatar
d.arizona committed
925 926 927 928
            let performanceScore = ''
            let perfomanceScoreColor = '#fff'
            if (listPerfomanceDefault.length > 0) {
                listPerfomanceDefault.map((item, index) => {
Riri Novita's avatar
Riri Novita committed
929 930 931
                    // console.log(Number(lastTotal))
                    // console.log(Number(item.min_value))
                    // console.log(Number(item.max_value))
d.arizona's avatar
d.arizona committed
932 933 934 935 936 937
                    if (Number(lastTotal) >= Number(item.min_value) && Number(lastTotal) <= Number(item.max_value)) {
                        console.log('masuk')
                        perfomanceScore = item.description
                        perfomanceScoreColor = item.value
                    }
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
938
            }
d.arizona's avatar
d.arizona committed
939 940 941 942 943
            // console.log(Number(lastTotal))
            console.log(this.state.parameterPerfom)
            console.log(listPerfomanceDefault)
            console.log(perfomanceScore)
            console.log(perfomanceScoreColor)
d.arizona's avatar
d.arizona committed
944
            console.log(datatable3)
d.arizona's avatar
d.arizona committed
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
            // if (lastTotal >= 1.00 && lastTotal <= 2.00) {
            //     perfomanceScore = 'K'
            // } else if (lastTotal >= 2.01 && lastTotal <= 2.75) {
            //     perfomanceScore = 'C'
            // } else if (lastTotal >= 2.76 && lastTotal <= 3.00) {
            //     perfomanceScore = 'B-'
            // } else if (lastTotal >= 3.01 && lastTotal <= 3.75) {
            //     perfomanceScore = 'B'
            // } else if (lastTotal >= 3.76 && lastTotal <= 4.00) {
            //     perfomanceScore = 'B+'
            // } else if (lastTotal >= 4.01 && lastTotal <= 4.75) {
            //     perfomanceScore = 'BS'
            // } else if (lastTotal >= 4.76 && lastTotal <= 5.00) {
            //     perfomanceScore = 'IST'
            // }
d.arizona's avatar
d.arizona committed
960
            setTimeout(() => {
d.arizona's avatar
d.arizona committed
961 962
                this.setState({ totalScore: lastTotal, perfomanceScore, loading: false, perfomanceScoreColor }, () => {
                    this.setState({ loading: true })
d.arizona's avatar
d.arizona committed
963
                    setTimeout(() => {
d.arizona's avatar
d.arizona committed
964
                        this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
965 966
                    }, 500);
                })
d.arizona's avatar
d.arizona committed
967
            }, 500);
d.arizona's avatar
d.arizona committed
968 969 970 971 972
        })

    }

    handleBackgroundPerf(total) {
d.arizona's avatar
d.arizona committed
973
        // console.log(total)
d.arizona's avatar
d.arizona committed
974
        let color = 'white'
Deni Rinaldi's avatar
Deni Rinaldi committed
975
        if (total >= 1.00 && total <= 2.00) {
d.arizona's avatar
d.arizona committed
976
            color = 'red'
Deni Rinaldi's avatar
Deni Rinaldi committed
977
        } else if (total >= 2.01 && total <= 2.75) {
d.arizona's avatar
d.arizona committed
978
            color = 'yellow'
Deni Rinaldi's avatar
Deni Rinaldi committed
979
        } else if (total >= 2.76 && total <= 3.00) {
d.arizona's avatar
d.arizona committed
980
            color = 'lightgreen'
Deni Rinaldi's avatar
Deni Rinaldi committed
981
        } else if (total >= 3.01 && total <= 3.75) {
d.arizona's avatar
d.arizona committed
982
            color = 'yellowgreen'
Deni Rinaldi's avatar
Deni Rinaldi committed
983
        } else if (total >= 3.76 && total <= 4.00) {
d.arizona's avatar
d.arizona committed
984
            color = 'forestgreen'
Deni Rinaldi's avatar
Deni Rinaldi committed
985
        } else if (total >= 4.01 && total <= 4.75) {
d.arizona's avatar
d.arizona committed
986
            color = 'deepskyblue'
Deni Rinaldi's avatar
Deni Rinaldi committed
987
        } else if (total >= 4.76 && total <= 5.00) {
d.arizona's avatar
d.arizona committed
988 989 990 991 992
            color = 'dodgerblue'
        }
        return color
    }

faisalhamdi's avatar
faisalhamdi committed
993 994 995
    render() {
        let dataTable2 = this.state.dataTable
        let dataDelete = this.state.dataDelete
d.arizona's avatar
d.arizona committed
996
        const handleChange = (value, tableMeta, type) => {
faisalhamdi's avatar
faisalhamdi committed
997
            let val = String(value).split(",").join("")
d.arizona's avatar
d.arizona committed
998 999 1000 1001 1002
            if (type == 'text') {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
            } else {
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
            }
d.arizona's avatar
d.arizona committed
1003 1004
        }

d.arizona's avatar
d.arizona committed
1005 1006
        const handleValueFormula = (value, tableMeta, column, periode, forecast) => {
            // loading = true
d.arizona's avatar
d.arizona committed
1007 1008 1009
            let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
            let baru = []
            let anjay = []
d.arizona's avatar
d.arizona committed
1010

d.arizona's avatar
d.arizona committed
1011 1012 1013 1014 1015
            splitFormula.map((item, index) => {
                let items = String(item).substr(Number(String(item).length) - 1, 1)
                let subForm = String(item).substr(0, Number(String(item).length) - 1)
                let re = /^[a-zA-Z0-9_]+$/;
                if (item !== "") {
d.arizona's avatar
d.arizona committed
1016
                    if (!re.test(items)) {
d.arizona's avatar
d.arizona committed
1017 1018 1019 1020 1021 1022 1023
                        baru.push(subForm)
                        baru.push(items)
                    } else {
                        baru.push(String(item))
                    }
                }
            })
d.arizona's avatar
d.arizona committed
1024 1025
            // console.log(splitFormula)
            // console.log(baru)
d.arizona's avatar
d.arizona committed
1026
            baru.map((item, index) => {
d.arizona's avatar
d.arizona committed
1027
                if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
d.arizona's avatar
d.arizona committed
1028
                    anjay.push(item)
d.arizona's avatar
d.arizona committed
1029 1030
                } else if (item == '' || item == '@') {

Deni Rinaldi's avatar
Deni Rinaldi committed
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
                    // } else if (item == "CurrMonth") {
                    //     anjay.push(String(column))
                    // } else if (item.includes('[CM]SUM')) {
                    //     let columnStart = 13
                    //     let indexX = String(item).indexOf('[')
                    //     let formulaAwal = String(item).substr(0, indexX)
                    //     let columnEnd = 24
                    //     let month = column - 1
                    //     let total = 0
                    //     // // // console.log(formulaAwal)
                    //     if (forecast == undefined) {
                    //         dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
                    //             if (indexz >= columnStart && indexz <= columnStart + month) {
                    //                 let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${formulaAwal}`) && val.periode == Number(this.props.periode))
                    //                 if (indexID !== -1) {
                    //                     let valuezz = Number(value.formula[indexID].value)
                    //                     total += valuezz
                    //                 }
                    //             }
                    //         })
                    //     } else {
d.arizona's avatar
d.arizona committed
1052

Deni Rinaldi's avatar
Deni Rinaldi committed
1053
                    //     }
d.arizona's avatar
d.arizona committed
1054

Deni Rinaldi's avatar
Deni Rinaldi committed
1055 1056 1057 1058 1059 1060 1061
                    //     anjay.push(String(total))
                    // } else if (item.includes('[CM]AVG')) {
                    //     if (forecast == undefined) {
                    //         anjay.push('/')
                    //         anjay.push(column)
                    //     }
                }
d.arizona's avatar
d.arizona committed
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
                else if (item.includes('X')) {
                    let indexX = String(item).indexOf('X')
                    if (indexX == 0) {
                        anjay.push(String(item).substr(1, String(item).length))
                    } else {
                        let formulaAwal = String(item).substr(0, indexX - 1)
                        let operatorX = String(item).substr(indexX - 1, 1)
                        let nilaiX = String(item).substr(indexX + 1, String(item).length)

                        if (forecast == undefined) {
d.arizona's avatar
d.arizona committed
1072 1073
                            // console.log(formulaAwal)
                            // console.log(tableMeta.rowData[17])
d.arizona's avatar
d.arizona committed
1074 1075 1076 1077 1078 1079
                            let convertID = -1
                            if (tableMeta.rowData[10] == 'FORMULA') {
                                let indexIDReport = dataTable2.findIndex((val) => val[1] == formulaAwal)
                                convertID = dataTable2[indexIDReport][18]
                                let indexID = dataTable2.findIndex((val) => val[18] == (convertID == -1 ? item : convertID))
                                let valuezz = dataTable2[indexID][column].value == undefined ? dataTable2[indexID][column] : dataTable2[indexID][column].value
d.arizona's avatar
d.arizona committed
1080
                                anjay.push(valuezz == "" ? 0 : valuezz)
d.arizona's avatar
d.arizona committed
1081 1082 1083 1084 1085 1086
                            } else {
                                let indexID = tableMeta.rowData[17].findIndex((val) => val.item_formula == String(`@${formulaAwal}`) && val.periode == Number(this.props.periode))
                                if (indexID !== -1) {
                                    let valuezz = tableMeta.rowData[17][indexID].value
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
d.arizona's avatar
d.arizona committed
1087 1088
                            }
                        } else {
d.arizona's avatar
d.arizona committed
1089
                            // // // console.log(dataTable2[tableMeta.rowIndex][30])
d.arizona's avatar
d.arizona committed
1090
                            let array = dataTable2[tableMeta.rowIndex][18].filter((val) => val.periode == Number(column))
d.arizona's avatar
d.arizona committed
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
                            let valuezz = array[0].value
                            // // // console.log(valuezz)
                            anjay.push(valuezz == "" ? 0 : valuezz)
                            // let indexID = dataTable2[tableMeta.rowIndex][30].findIndex((val) => val.periode == Number(this.props.periode))
                            // if (indexID !== -1) {
                            //     let valuezz = value.formula[indexID].value
                            //     anjay.push(valuezz == "" ? 0 : valuezz)
                            // }
                        }

                        anjay.push(operatorX)
                        anjay.push(nilaiX)
                    }
                } else {
                    if (String(item).includes('#')) {
                        if (forecast == undefined) {
                            let indexID = tableMeta.rowData[17].findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
d.arizona's avatar
d.arizona committed
1108
                            if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
1109 1110
                                let valuezz = tableMeta.rowData[17][indexID].value
                                anjay.push(valuezz == "" || valuezz == null ? "0" : valuezz)
d.arizona's avatar
d.arizona committed
1111 1112
                            }
                        }
d.arizona's avatar
d.arizona committed
1113

d.arizona's avatar
d.arizona committed
1114
                    } else {
d.arizona's avatar
d.arizona committed
1115 1116 1117 1118 1119 1120
                        let convertID = -1
                        if (tableMeta.rowData[10] == 'FORMULA') {
                            let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
                            convertID = dataTable2[indexIDReport][18]
                        }
                        let indexID = dataTable2.findIndex((val) => val[18] == (convertID == -1 ? item : convertID))
d.arizona's avatar
d.arizona committed
1121 1122
                        if (indexID !== -1) {
                            let valuezz = dataTable2[indexID][column].value == undefined ? dataTable2[indexID][column] : dataTable2[indexID][column].value
d.arizona's avatar
d.arizona committed
1123
                            if (item == dataTable2[tableMeta.rowIndex][18]) {
d.arizona's avatar
d.arizona committed
1124 1125 1126
                                anjay.push(0)
                            } else {
                                anjay.push(valuezz == "" ? "0" : valuezz)
d.arizona's avatar
d.arizona committed
1127 1128
                            }
                        } else {
d.arizona's avatar
d.arizona committed
1129
                            if (item === '(-1)') {
d.arizona's avatar
d.arizona committed
1130 1131 1132 1133 1134 1135 1136
                                anjay.push(-1)
                            }
                        }
                    }
                }
            })

d.arizona's avatar
d.arizona committed
1137 1138 1139 1140 1141 1142
            // if (tableMeta.rowData[10] == 'FORMULA') {
            //     // let indexIDReport = dataTable2.findIndex((val) => val[1] == item)
            //     // convertID = dataTable2[indexIDReport][18]
            //     console.log(baru)
            //     console.log(anjay)
            // }
d.arizona's avatar
d.arizona committed
1143 1144 1145 1146

            let anjay2 = []
            let kurung = false
            let item1 = []
d.arizona's avatar
d.arizona committed
1147
            let brpKurung = 0
d.arizona's avatar
d.arizona committed
1148 1149 1150
            anjay.map((item, index) => {
                if (item == "(") {
                    kurung = true
d.arizona's avatar
d.arizona committed
1151
                    // brpKurung += 1
d.arizona's avatar
d.arizona committed
1152
                } else if (item == ")") {
d.arizona's avatar
d.arizona committed
1153 1154
                    // brpKurung -= 1
                    // if (brpKurung == 0) {
d.arizona's avatar
d.arizona committed
1155 1156 1157
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
d.arizona's avatar
d.arizona committed
1158
                    // }
d.arizona's avatar
d.arizona committed
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261
                } else {
                    if (kurung) {
                        item1.push(item)
                    } else {
                        anjay2.push(item)
                    }
                }
            })

            let total = 0
            let opt = ""
            let totalPrio = 0
            let optPrio = ""
            let prio = false
            anjay2.map((item, index) => {
                if (Array.isArray(item)) {
                    prio = true
                    item.map((items, indexs) => {
                        if (items == "+") {
                            optPrio = "tambah"
                        } else if (items == "-") {
                            optPrio = "kurang"
                        } else if (items == "*") {
                            optPrio = "kali"
                        } else if (items == "/") {
                            optPrio = "bagi"
                        } else {
                            if (optPrio == "tambah") {
                                totalPrio = Number(totalPrio) + Number(items)
                            } else if (optPrio == "kurang") {
                                totalPrio = Number(totalPrio) - Number(items)
                            } else if (optPrio == "kali") {
                                totalPrio = Number(totalPrio) * Number(items)
                            } else if (optPrio == "bagi") {
                                totalPrio = Number(totalPrio) / Number(items) == NaN ? 0 : Number(totalPrio) / Number(items)
                            } else {
                                totalPrio += Number(items)
                            }
                        }
                    })

                    if (index == anjay2.length - 1) {
                        if (opt == "tambah") {
                            total = Number(total) + Number(totalPrio)
                        } else if (opt == "kurang") {
                            total = Number(total) - Number(totalPrio)
                        } else if (opt == "kali") {
                            total = Number(total) * Number(totalPrio)
                        } else if (opt == "bagi") {
                            total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
                        } else {
                            total += Number(totalPrio)
                        }
                    }
                } else {
                    if (item == "+") {
                        opt = "tambah"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "-") {
                        opt = "kurang"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "*") {
                        opt = "kali"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else if (item == "/") {
                        opt = "bagi"
                        if (prio) {
                            total = Number(Number(totalPrio) + Number(total))
                            prio = false
                            totalPrio = 0
                            optPrio = ""
                        }
                    } else {
                        if (opt == "tambah") {
                            total = Number(total) + Number(item)
                        } else if (opt == "kurang") {
                            total = Number(total) - Number(item)
                        } else if (opt == "kali") {
                            total = Number(total) * Number(item)
                        } else if (opt == "bagi") {
                            total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
                        } else {
                            total += Number(item)
                        }
                    }
                }
            })

d.arizona's avatar
d.arizona committed
1262 1263 1264 1265
            total = R.equals(total, NaN) ? "0.0" : total
            // if (dataTable2[tableMeta.rowIndex][5] == "ROIC") {
            //     dataTable2[tableMeta.rowIndex][column] = 0
            // } else {
1266
            dataTable2[tableMeta.rowIndex][column] = this.props.defaultCurrency.i == 1 ? fixNumber(Number(total), 1) : Number(total)
d.arizona's avatar
d.arizona committed
1267
            // }
d.arizona's avatar
d.arizona committed
1268

1269
            return this.props.defaultCurrency.i == 1 ? fixNumber(Number(total), 1) : Number(total)
faisalhamdi's avatar
faisalhamdi committed
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281
        }

        const handleChangeText = (value, tableMeta) => {
            // // console.log(value)
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
            // this.setState({dataTable: dataTable2})
        }

        const handleAction = (idParent, typeReport, tableMeta) => {
            if (this.props.isApprover) {
                return false
            } else {
d.arizona's avatar
d.arizona committed
1282
                // if ((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')) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1283 1284 1285 1286 1287
                if (idParent !== null) {
                    // console.log(tableMeta)
                    let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
                    if (dataTable2[indexsss][5] == 'CUSTOMER PERSPECTIVE' || dataTable2[indexsss][5] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE') {
                        return true
faisalhamdi's avatar
faisalhamdi committed
1288
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1289
                        if (typeReport == 3) {
faisalhamdi's avatar
faisalhamdi committed
1290 1291 1292 1293 1294
                            return true
                        } else {
                            return false
                        }
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
                } else {
                    if (typeReport == null || typeReport == 3) {
                        return true
                    } else if (tableMeta !== undefined && tableMeta.rowData[0] == 1) {
                        let indexID = dataTable2.findIndex((val) => val[2] == tableMeta.rowData[1])
                        if (indexID !== -1) {
                            return false
                        } else {
                            return true
                        }
                    } else {
                        return false
                    }
                }
d.arizona's avatar
d.arizona committed
1309 1310 1311
                // } else {
                //     return false
                // }
faisalhamdi's avatar
faisalhamdi committed
1312
            }
Deni Rinaldi's avatar
Deni Rinaldi committed
1313

faisalhamdi's avatar
faisalhamdi committed
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
        }

        const handleTambah = (data, rowIndex) => {
            // console.log(dataTable2)
            let newData = []
            dataTable2.map((item, index) => {
                newData.push(item)
                if (index == rowIndex) {
                    newData.push([
                        null,
                        "",
Deni Rinaldi's avatar
Deni Rinaldi committed
1325
                        item[2] == null || item[2] == "" ? item[1] : item[2],
faisalhamdi's avatar
faisalhamdi committed
1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
                        item[3],
                        item[4],
                        "",
                        "",
                        "",
                        "",
                        null,
                        null,
                        null,
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        "",
                        ""
                    ])

                }
            })
            dataTable2 = newData
            this.setState({ dataTable: dataTable2 }, () => {
                setTimeout(() => {
                    this.setState({ loading: false })
                    // console.log(dataTable2)
                }, 500)
            })
        }

        const handleDelete = (index) => {
            if (dataTable2[index][1] !== "") {
                dataDelete.push(dataTable2[index][1])
            }
            dataTable2.splice(index, 1)
            this.setState({ dataTable: dataTable2, dataDelete }, () => {
                setTimeout(() => {
                    this.setState({ loading: false })
                }, 100)
            })
        }

d.arizona's avatar
d.arizona committed
1378
        const handleAchiement = (tableMeta) => {
faisalhamdi's avatar
faisalhamdi committed
1379
            let total = 0
d.arizona's avatar
d.arizona committed
1380 1381 1382 1383 1384 1385 1386 1387 1388
            // if (tableMeta.rowData[8] == 'HIB') {
            //     let actual = tableMeta.rowData[11] == "" ? 0 : Number(tableMeta.rowData[11])
            //     let target = tableMeta.rowData[12] == "" ? 0 : Number(tableMeta.rowData[12])
            //     total = 2 - (actual / target)
            // } else {
            //     let actual = tableMeta.rowData[11] == "" ? 0 : Number(tableMeta.rowData[11])
            //     let target = tableMeta.rowData[12] == "" ? 0 : Number(tableMeta.rowData[12])
            //     total = actual / target
            // }
d.arizona's avatar
d.arizona committed
1389
            if (tableMeta.rowData[8] == 'HIB') {
Deni Rinaldi's avatar
Deni Rinaldi committed
1390 1391
                let actual = tableMeta.rowData[11] == "" ? 0 : Number(tableMeta.rowData[11])
                let target = tableMeta.rowData[12] == "" ? 0 : Number(tableMeta.rowData[12])
d.arizona's avatar
d.arizona committed
1392 1393 1394 1395 1396 1397 1398 1399
                if (target < 0) {
                    if (actual > target) {
                        total = (actual / target) - 1
                    } else {
                        total = (actual / target)
                    }
                } else if (target == 0) {
                    if (target >= actual) {
d.arizona's avatar
d.arizona committed
1400
                        total = 1.26
d.arizona's avatar
d.arizona committed
1401 1402 1403 1404 1405 1406 1407
                    } else {
                        total = 0
                    }
                } else {
                    if (actual == target) {
                        total = (actual / target)
                    } else {
d.arizona's avatar
d.arizona committed
1408
                        total = 2 - (actual / target)
d.arizona's avatar
d.arizona committed
1409 1410
                    }
                }
d.arizona's avatar
d.arizona committed
1411
            } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1412 1413
                let actual = tableMeta.rowData[11] == "" ? 0 : Number(tableMeta.rowData[11])
                let target = tableMeta.rowData[12] == "" ? 0 : Number(tableMeta.rowData[12])
d.arizona's avatar
d.arizona committed
1414 1415
                if (target < 0) {
                    if (actual >= target) {
d.arizona's avatar
d.arizona committed
1416
                        total = ((target - actual) / target) + 1
d.arizona's avatar
d.arizona committed
1417
                    } else {
d.arizona's avatar
d.arizona committed
1418
                        total = (target - actual) / target
d.arizona's avatar
d.arizona committed
1419 1420 1421
                    }
                } else if (target == 0) {
                    if (target <= actual) {
d.arizona's avatar
d.arizona committed
1422
                        total = 1.26
d.arizona's avatar
d.arizona committed
1423 1424 1425 1426
                    } else {
                        total = 0
                    }
                } else {
d.arizona's avatar
d.arizona committed
1427
                    // if (actual <= target) {
d.arizona's avatar
d.arizona committed
1428
                    total = (actual / target)
d.arizona's avatar
d.arizona committed
1429 1430 1431
                    // } else {
                    //     total = 1 - (actual / target)
                    // }
d.arizona's avatar
d.arizona committed
1432
                }
d.arizona's avatar
d.arizona committed
1433 1434
            }
            total = String(total) == 'NaN' || String(total) == 'Infinity' || String(total) == '-Infinity' ? 0 : total
Deni Rinaldi's avatar
Deni Rinaldi committed
1435 1436
            dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total) * 100
            return Number(total) * 100
d.arizona's avatar
d.arizona committed
1437 1438 1439 1440 1441
        }

        const handleScore = (tableMeta) => {
            let listParameter = this.state.parameterScore
            let parameterKpi = tableMeta.rowData[8]
Deni Rinaldi's avatar
Deni Rinaldi committed
1442
            let parameterAch = String(tableMeta.rowData[9]).includes('%') ? `MAX${String(tableMeta.rowData[9]).substr(0, String(tableMeta.rowData[9]).length - 1)}` : String(tableMeta.rowData[9])
d.arizona's avatar
d.arizona committed
1443
            let parameterMix = `${parameterKpi}_${parameterAch}`
rifkaki's avatar
rifkaki committed
1444
            let listParameterFilter = listParameter.filter((val) => val.setting_type == String(parameterMix).toLocaleUpperCase() && String(val.company_name).toLocaleLowerCase() === "default")
d.arizona's avatar
d.arizona committed
1445
            let listParameterFilterCompany = listParameterFilter.filter((val) => val.company_id == this.props.company.company_id)
d.arizona's avatar
d.arizona committed
1446
            let totalScore = 0
d.arizona's avatar
d.arizona committed
1447
            let achx100 = tableMeta.rowData[9] == '100%' && (tableMeta.rowData[8] == 'HIB' || tableMeta.rowData[8] == 'HIG') ? (Number(tableMeta.rowData[13]) / 100 > 1 ? 1 : Number(tableMeta.rowData[13]) / 100) : Number(tableMeta.rowData[13]) / 100
d.arizona's avatar
d.arizona committed
1448
            if (listParameterFilterCompany.length == 0) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1449
                listParameterFilter.map((item, index) => {
d.arizona's avatar
d.arizona committed
1450 1451 1452 1453 1454
                    if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
                        totalScore = Number(item.value)
                    }
                })
            } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1455
                listParameterFilterCompany.map((item, index) => {
d.arizona's avatar
d.arizona committed
1456 1457 1458 1459 1460
                    if (Number(achx100) >= Number(item.min_value) && Number(achx100) <= Number(item.max_value)) {
                        totalScore = Number(item.value)
                    }
                })
            }
d.arizona's avatar
d.arizona committed
1461
            if (Number(tableMeta.rowData[12]) == Number(0)) {
1462 1463
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(0), 0) : Number(0)
                return this.props.defaultCurrency.id == 1 ? fixNumber(Number(0), 0) : Number(0)
d.arizona's avatar
d.arizona committed
1464
            } else {
1465 1466
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(totalScore), 0) : Number(totalScore)
                return this.props.defaultCurrency.id == 1 ? fixNumber(Number(totalScore), 0) : Number(totalScore)
rifkaki's avatar
rifkaki committed
1467
            }
d.arizona's avatar
d.arizona committed
1468 1469
        }

d.arizona's avatar
d.arizona committed
1470
        let someXXX = this.state.aa
d.arizona's avatar
d.arizona committed
1471 1472
        const handleTotal = (tableMeta) => {
            let total = 0
d.arizona's avatar
d.arizona committed
1473
            let handlePercent = ''
d.arizona's avatar
d.arizona committed
1474 1475 1476
            // if (tableMeta.rowData[5] == 'Trading profit (NPBT buah luar & plasma)') {
            //     console.log(dataTable2[tableMeta.rowIndex])
            // }
d.arizona's avatar
d.arizona committed
1477 1478
            if (tableMeta.rowData[0] == 4) {
                let totalScore = 0
d.arizona's avatar
d.arizona committed
1479 1480
                dataTable2.map((item, index) => {
                    if (item[0] !== 4 && item[0] !== 1) {
d.arizona's avatar
d.arizona committed
1481 1482 1483
                        totalScore += Number(item[15])
                    }
                })
1484
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(totalScore), 2) : Number(totalScore)
d.arizona's avatar
d.arizona committed
1485
                if (tableMeta.rowIndex == dataTable2.length - 1) {
1486
                    someXXX = this.props.defaultCurrency.id == 1 ? fixNumber(Number(totalScore), 2) : Number(totalScore)
Riri Novita's avatar
Riri Novita committed
1487
                    // console.log(someXXX)
d.arizona's avatar
d.arizona committed
1488 1489
                }
                return null
d.arizona's avatar
d.arizona committed
1490
            } else {
d.arizona's avatar
d.arizona committed
1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503
                if (String(dataTable2[tableMeta.rowIndex][6]).includes('%')) {
                    // handlePercent = String(dataTable2[tableMeta.rowIndex][6])
                    handlePercent = String(dataTable2[tableMeta.rowIndex][6]).substr(0, String(dataTable2[tableMeta.rowIndex][6]).length - 1)
                } else {
                    handlePercent = String(dataTable2[tableMeta.rowIndex][6])
                }
                // console.log(handlePercent)
                if (dataTable2[tableMeta.rowIndex][12] == '' || String(dataTable2[tableMeta.rowIndex][12]) == '0' || String(dataTable2[tableMeta.rowIndex][12]) == '0.0') {
                    total = 0
                } else {
                    total = Number(dataTable2[tableMeta.rowIndex][14]) * Number(handlePercent) / 100
                    // console.log(total)
                }
1504
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = this.props.defaultCurrency.id == 1 ? fixNumber(Number(total), 2) : Number(total)
d.arizona's avatar
d.arizona committed
1505
                return total
d.arizona's avatar
d.arizona committed
1506
            }
d.arizona's avatar
d.arizona committed
1507

faisalhamdi's avatar
faisalhamdi committed
1508 1509 1510
        }

        let columns = [
Riri Novita's avatar
Riri Novita committed
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
faisalhamdi's avatar
faisalhamdi committed
1535 1536 1537 1538 1539
            {
                name: "",
                options: {
                    display: false
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1540
            },
faisalhamdi's avatar
faisalhamdi committed
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551
            {
                name: "Key Performance Indicator",
                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 (
Deni Rinaldi's avatar
Deni Rinaldi committed
1552
                            handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) && (tableMeta.rowData[1] == "" || String(this.props.status).toLocaleLowerCase() == 'draft' || String(this.props.status).toLocaleLowerCase() == 'submitted' || String(this.props.status).toLocaleLowerCase() == 'revision') ?
faisalhamdi's avatar
faisalhamdi committed
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574
                                <div style={{ textAlign: 'left', paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                    {!this.state.loading && <FormControlLabel
                                        style={{ margin: 0 }}
                                        control={
                                            <Input
                                                disableUnderline={true}
                                                style={{ color: tableMeta.rowData[1] == "" ? "#5198ea" : "black", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                defaultValue={val}
                                                // disabled={!handleAction(tableMeta.rowData[2])}
                                                onBlur={(event) => {
                                                    // // console.log(event.target.value)
                                                    handleChangeText(event.target.value, tableMeta)
                                                    // console.log(dataTable2)
                                                }}
                                            />
                                        }
                                    />}
                                </div>
                                :
                                <div style={{ width: 300 }}>
d.arizona's avatar
d.arizona committed
1575 1576
                                    {tableMeta.rowData[19] ?
                                        tableMeta.rowData[19].length > 0 ?
faisalhamdi's avatar
faisalhamdi committed
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607
                                            <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                <LightTooltip title={"Report Items Not Registered"} arrow>
                                                    <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                </LightTooltip>
                                            </div>
                                            :
                                            tableMeta.rowData[4] == 0 ?
                                                <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                                :
                                                tableMeta.rowData[1] == null ?
                                                    <div style={{ paddingLeft: 20 }}>
                                                        <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                    </div>
                                                    :
                                                    <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                        <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                    </div>
                                        :
                                        tableMeta.rowData[4] == 0 ?
                                            <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                            :
                                            tableMeta.rowData[1] == null ?
                                                <div style={{ paddingLeft: 20 }}>
                                                    <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                </div>
                                                :
                                                <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                    <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                                </div>
                                    }
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624
                        )
                    }
                }
            }, {
                name: "Weight",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 60, borderLeft: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (value, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'center' }}>
                                {tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null :
d.arizona's avatar
d.arizona committed
1625
                                    <FormControlLabel
Deni Rinaldi's avatar
Deni Rinaldi committed
1626
                                        style={{ margin: 0 }}
d.arizona's avatar
d.arizona committed
1627 1628 1629 1630 1631 1632 1633 1634
                                        value={value}
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
                                                suffix={"%"}
1635
                                                value={fixNumber(Number(value), 1)}
d.arizona's avatar
d.arizona committed
1636 1637 1638 1639 1640 1641
                                                disabled={true}
                                                // disabled={this.props.isApprover ? 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)}
                                                decimalScale={1}
                                            />
                                        }
                                    />
faisalhamdi's avatar
faisalhamdi committed
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656
                                }
                            </div>
                        )
                    }
                }
            }, {
                name: "UOM",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', borderLeft: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    customBodyRender: (value, tableMeta, updateValue) => {
                        return (
Deni Rinaldi's avatar
Deni Rinaldi committed
1657
                            <div style={{ textAlign: 'center' }}>
faisalhamdi's avatar
faisalhamdi committed
1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674
                                <div style={{ textAlign: 'center', width: 60 }}>
                                    {value}
                                </div>
                            </div>
                        )
                    }
                }
            }, {
                name: "KPI Type",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96, borderLeft: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    customBodyRender: (val, tableMeta) => {
                        return (
faisalhamdi's avatar
faisalhamdi committed
1675
                            <div style={{ textAlign: 'center', width: 60 }}>
faisalhamdi's avatar
faisalhamdi committed
1676
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
faisalhamdi's avatar
faisalhamdi committed
1677
                                    null :
faisalhamdi's avatar
faisalhamdi committed
1678
                                    val
faisalhamdi's avatar
faisalhamdi committed
1679
                                }
faisalhamdi's avatar
faisalhamdi committed
1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694
                            </div>
                        )
                    }
                }
            }, {
                name: "Max Ach.",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 60, borderLeft: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ textAlign: 'center', width: 60 }}>
faisalhamdi's avatar
faisalhamdi committed
1695
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
faisalhamdi's avatar
faisalhamdi committed
1696
                                    null :
faisalhamdi's avatar
faisalhamdi committed
1697
                                    val
faisalhamdi's avatar
faisalhamdi committed
1698
                                }
faisalhamdi's avatar
faisalhamdi committed
1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712
                            </div>
                        )
                    }
                }
            }, {
                name: "Formula YTD",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 60, borderLeft: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
faisalhamdi's avatar
faisalhamdi committed
1713
                            <div style={{ textAlign: 'center', width: 60 }}>
faisalhamdi's avatar
faisalhamdi committed
1714
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
faisalhamdi's avatar
faisalhamdi committed
1715
                                    null :
faisalhamdi's avatar
faisalhamdi committed
1716
                                    val
faisalhamdi's avatar
faisalhamdi committed
1717
                                }
faisalhamdi's avatar
faisalhamdi committed
1718 1719 1720 1721 1722 1723 1724 1725
                            </div>
                        )
                    }
                }
            }, {
                name: `Actual ${this.props.month.month_value} ${Number(this.props.periode)}`,
                options: {
                    customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1726
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 75, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1727 1728 1729 1730 1731
                            <Typography style={{ color: '#fff', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    customBodyRender: (value, tableMeta) => {
                        return (
d.arizona's avatar
d.arizona committed
1732
                            <div style={{ width: 75, textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1733 1734 1735
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
Deni Rinaldi's avatar
Deni Rinaldi committed
1736
                                    this.state.get_for == 'view' ?
d.arizona's avatar
d.arizona committed
1737 1738 1739 1740 1741
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
1742
                                            value={fixNumber(Number(value), 1) == 0 ? "0.0" : fixNumber(Number(value), 1)}
d.arizona's avatar
d.arizona committed
1743 1744 1745 1746
                                            // disabled={this.props.isApprover ? 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={true}
                                            decimalScale={1}
                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
1747 1748 1749 1750
                                        :
                                        <div style={{ flex: 1, textAlign: 'right' }}>
                                            <FormControlLabel
                                                style={{ margin: 0 }}
1751
                                                value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : Number(value)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1752 1753 1754 1755 1756 1757
                                                control={
                                                    <NumberFormat
                                                        thousandSeparator={true}
                                                        style={{ color: this.state.get_for == 'view' ? "black" : handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta) ? "#5198ea" : 'black', fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
Riri Novita's avatar
Riri Novita committed
1758
                                                        value={this.props.defaultCurrency.id == 1 ? (tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ? fixNumber(Number(handleValueFormula(value, tableMeta, tableMeta.columnIndex)), 1) : fixNumber(Number(value), 1)) : (tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ? (Number(handleValueFormula(value, tableMeta, tableMeta.columnIndex)) == 0 ? "0.0" : Number(handleValueFormula(value, tableMeta, tableMeta.columnIndex))) : Number(value) == 0 ? "0.0" : Number(value))}
Deni Rinaldi's avatar
Deni Rinaldi committed
1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770
                                                        // disabled={this.props.isApprover ? 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.state.get_for == 'view' ? true : !handleAction(tableMeta.rowData[2], tableMeta.rowData[0], tableMeta)}
                                                        decimalScale={1}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta)
                                                            // // console.log(dataTable2)
                                                        }}
                                                    />
                                                }
                                            />
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1771 1772 1773 1774 1775 1776 1777 1778 1779
                                }
                            </div>
                        )
                    }
                }
            }, {
                name: `Target ${this.props.month.month_value} ${Number(this.props.periode)}`,
                options: {
                    customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1780
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 75, borderLeft: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
1781
                            <Typography style={{ color: '#fff', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
faisalhamdi's avatar
faisalhamdi committed
1782 1783 1784 1785
                        </TableCell>
                    ),
                    customBodyRender: (value, tableMeta) => {
                        return (
d.arizona's avatar
d.arizona committed
1786
                            <div style={{ width: 75, textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1787
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
faisalhamdi's avatar
faisalhamdi committed
1788 1789 1790
                                    null :
                                    <FormControlLabel
                                        style={{ margin: 0 }}
1791
                                        value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : Number(value) == 0 ? "0.0" : Number(value)}
faisalhamdi's avatar
faisalhamdi committed
1792 1793 1794 1795 1796 1797
                                        control={
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
1798
                                                value={this.props.defaultCurrency.id == 1 ? fixNumber(Number(value), 1) : Number(value) == 0 ? "0.0" : Number(value)}
faisalhamdi's avatar
faisalhamdi committed
1799 1800 1801 1802 1803
                                                decimalScale={1}
                                                disabled={true}
                                            />
                                        }
                                    />
faisalhamdi's avatar
faisalhamdi committed
1804
                                }
faisalhamdi's avatar
faisalhamdi committed
1805 1806 1807 1808 1809 1810 1811 1812
                            </div>
                        )
                    }
                }
            }, {
                name: `Achivement ${this.props.month.month_value} ${Number(this.props.periode)} (%)`,
                options: {
                    customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1813
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 75, borderLeft: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
1814
                            <Typography style={{ color: '#fff', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
faisalhamdi's avatar
faisalhamdi committed
1815 1816 1817 1818
                        </TableCell>
                    ),
                    customBodyRender: (value, tableMeta) => {
                        return (
d.arizona's avatar
d.arizona committed
1819
                            <div style={{ width: 75, textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1820
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
faisalhamdi's avatar
faisalhamdi committed
1821
                                    null :
Deni Rinaldi's avatar
Deni Rinaldi committed
1822
                                    this.state.get_for == 'view' ?
d.arizona's avatar
d.arizona committed
1823 1824 1825 1826 1827
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
1828
                                            value={fixNumber(Number(value), 1)}
d.arizona's avatar
d.arizona committed
1829 1830
                                            // disabled={this.props.isApprover ? 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={true}
d.arizona's avatar
d.arizona committed
1831
                                            suffix={"%"}
d.arizona's avatar
d.arizona committed
1832 1833
                                            decimalScale={1}
                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
1834 1835 1836
                                        :
                                        <FormControlLabel
                                            style={{ margin: 0 }}
1837
                                            value={fixNumber(Number(value), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1838 1839 1840 1841 1842 1843 1844
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    suffix={"%"}
1845
                                                    value={fixNumber(handleAchiement(tableMeta), 1)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1846 1847 1848 1849 1850
                                                    decimalScale={1}
                                                    disabled={true}
                                                />
                                            }
                                        />
faisalhamdi's avatar
faisalhamdi committed
1851
                                }
faisalhamdi's avatar
faisalhamdi committed
1852 1853 1854 1855 1856 1857 1858 1859
                            </div>
                        )
                    }
                }
            }, {
                name: `Score (Scale 1-5)`,
                options: {
                    customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1860
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 70, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1861 1862 1863 1864 1865
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    customBodyRender: (value, tableMeta) => {
                        return (
d.arizona's avatar
d.arizona committed
1866
                            <div style={{ width: 70, textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1867
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
faisalhamdi's avatar
faisalhamdi committed
1868
                                    null :
Deni Rinaldi's avatar
Deni Rinaldi committed
1869
                                    this.state.get_for == 'view' ?
d.arizona's avatar
d.arizona committed
1870 1871 1872 1873 1874
                                        <NumberFormat
                                            thousandSeparator={true}
                                            style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                            type="text"
                                            placeholder=""
1875
                                            value={fixNumber(Number(value), 0)}
d.arizona's avatar
d.arizona committed
1876 1877
                                            // disabled={this.props.isApprover ? 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={true}
d.arizona's avatar
d.arizona committed
1878
                                            decimalScale={0}
d.arizona's avatar
d.arizona committed
1879
                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
1880 1881 1882
                                        :
                                        <FormControlLabel
                                            style={{ margin: 0 }}
1883
                                            value={fixNumber(Number(value), 0)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1884 1885 1886 1887 1888 1889 1890 1891 1892
                                            control={
                                                <NumberFormat
                                                    thousandSeparator={true}
                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    value={handleScore(tableMeta)}
                                                    decimalScale={0}
                                                    disabled={true}
qorri_di's avatar
qorri_di committed
1893 1894 1895 1896 1897
                                                // onBlur={(event) => {
                                                //     // updateValue(event.target.value)
                                                //     handleChange(event.target.value, tableMeta)
                                                //     // // console.log(dataTable2)
                                                // }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1898 1899 1900
                                                />
                                            }
                                        />
faisalhamdi's avatar
faisalhamdi committed
1901
                                }
faisalhamdi's avatar
faisalhamdi committed
1902 1903 1904 1905 1906 1907 1908 1909
                            </div>
                        )
                    }
                }
            }, {
                name: `Score x Weight`,
                options: {
                    customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1910
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 75, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1911 1912 1913 1914 1915
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    customBodyRender: (value, tableMeta) => {
                        return (
faisalhamdi's avatar
faisalhamdi committed
1916
                            <div style={{ width: 75 }}>
d.arizona's avatar
d.arizona committed
1917
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 ?
faisalhamdi's avatar
faisalhamdi committed
1918
                                    null :
d.arizona's avatar
d.arizona committed
1919 1920
                                    tableMeta.rowData[0] === 4 ?
                                        handleTotal(tableMeta)
Deni Rinaldi's avatar
Deni Rinaldi committed
1921
                                        :
d.arizona's avatar
d.arizona committed
1922 1923 1924 1925 1926 1927
                                        this.state.get_for == 'view' ?
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
1928
                                                value={fixNumber(Number(value), 2)}
d.arizona's avatar
d.arizona committed
1929 1930 1931 1932 1933 1934 1935 1936 1937 1938
                                                // disabled={this.props.isApprover ? 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={true}
                                                decimalScale={2}
                                            />
                                            :
                                            <NumberFormat
                                                thousandSeparator={true}
                                                style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                type="text"
                                                placeholder=""
1939
                                                value={fixNumber(handleTotal(tableMeta), 2)}
d.arizona's avatar
d.arizona committed
1940 1941 1942
                                                decimalScale={2}
                                                disabled={true}
                                            />
faisalhamdi's avatar
faisalhamdi committed
1943
                                }
faisalhamdi's avatar
faisalhamdi committed
1944 1945 1946 1947 1948 1949 1950 1951
                            </div>
                        )
                    }
                }
            }, {
                name: `Notes`,
                options: {
                    customHeadRender: (columnMeta) => (
faisalhamdi's avatar
faisalhamdi committed
1952
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 75, borderLeft: '1px #fff solid' }}>
faisalhamdi's avatar
faisalhamdi committed
1953 1954 1955 1956 1957
                            <Typography style={{ color: '#fff', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    customBodyRender: (value, tableMeta) => {
                        return (
rifkaki's avatar
rifkaki committed
1958
                            <div style={{ width: 150 }}>
faisalhamdi's avatar
faisalhamdi committed
1959 1960 1961
                                {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4 ?
                                    null
                                    :
Deni Rinaldi's avatar
Deni Rinaldi committed
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985
                                    this.state.get_for == 'view' ?
                                        value
                                        :
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            control={
                                                <ThemeProvider theme={theme}>
                                                    <Input
                                                        disableUnderline={true}
                                                        style={{ color: this.state.get_for == 'view' ? "black" : "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 150, backgroundColor: 'transparent' }}
                                                        type="text"
                                                        placeholder=""
                                                        multiline={true}
                                                        defaultValue={value}
                                                        disabled={this.state.get_for == 'view'}
                                                        onBlur={(event) => {
                                                            // updateValue(event.target.value)
                                                            handleChange(event.target.value, tableMeta, 'text')
                                                            // // console.log(dataTable2)
                                                        }}
                                                    />
                                                </ThemeProvider>
                                            }
                                        />
faisalhamdi's avatar
faisalhamdi committed
1986 1987 1988 1989 1990
                                }
                            </div>
                        )
                    }
                }
d.arizona's avatar
d.arizona committed
1991 1992 1993 1994 1995 1996
            },
            {
                name: "",
                options: {
                    display: false
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1997
            },
d.arizona's avatar
d.arizona committed
1998

faisalhamdi's avatar
faisalhamdi committed
1999 2000
        ]

faisalhamdi's avatar
faisalhamdi committed
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011
        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>
        );

faisalhamdi's avatar
faisalhamdi committed
2012 2013
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
faisalhamdi's avatar
faisalhamdi committed
2014
                {this.state.loading && loadingComponent}
faisalhamdi's avatar
faisalhamdi committed
2015 2016 2017
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
                </div>
faisalhamdi's avatar
faisalhamdi committed
2018 2019 2020 2021 2022
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
faisalhamdi's avatar
faisalhamdi committed
2023
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
faisalhamdi's avatar
faisalhamdi committed
2024 2025 2026 2027 2028 2029 2030 2031 2032
                    {this.state.visibleCATMR ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Corporate Annual Target - Performance</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>
d.arizona's avatar
d.arizona committed
2033
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
2034 2035 2036 2037 2038
                                        {this.props.defaultCurrency.id === 1 ?
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                            :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                        }
faisalhamdi's avatar
faisalhamdi committed
2039 2040 2041
                                    </div>
                                    <div style={{ width: '50%' }}>
                                        <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
d.arizona's avatar
d.arizona committed
2042
                                            {this.state.get_for == 'edit' && <a data-tip={'Download Template'} data-for="template">
faisalhamdi's avatar
faisalhamdi committed
2043 2044 2045 2046 2047 2048 2049
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2050
                                                    onClick={() => this.downloadTemplate()}
faisalhamdi's avatar
faisalhamdi committed
2051 2052 2053
                                                >
                                                    <img src={Images.template} />
                                                </button>
d.arizona's avatar
d.arizona committed
2054
                                            </a>}
faisalhamdi's avatar
faisalhamdi committed
2055
                                            <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
d.arizona's avatar
d.arizona committed
2056
                                            {this.state.get_for == 'edit' && <a data-tip={'Upload'} data-for="upload">
faisalhamdi's avatar
faisalhamdi committed
2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
                                                    onClick={() => this.setState({ visibleUpload: true })}
                                                >
                                                    <img src={Images.upload} />
                                                </button>
d.arizona's avatar
d.arizona committed
2068
                                            </a>}
faisalhamdi's avatar
faisalhamdi committed
2069
                                            <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
qorri_di's avatar
qorri_di committed
2070
                                            {/* <a data-tip={'Download'} data-for="download">
faisalhamdi's avatar
faisalhamdi committed
2071 2072 2073 2074 2075 2076 2077
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5
                                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
2078
                                                    onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
2079 2080
                                                        this.setState({ loading: true }, () => {
                                                            setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2081
                                                                this.downloadAllData()
faisalhamdi's avatar
faisalhamdi committed
2082 2083 2084 2085 2086 2087
                                                            }, 100);
                                                        })}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
qorri_di's avatar
qorri_di committed
2088
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> */}
faisalhamdi's avatar
faisalhamdi committed
2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102
                                        </div>
                                    </div>
                                </div>

                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {!this.state.loading && (
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
2103
                                    {this.state.get_for == 'view' && this.state.viewOnly && <div style={{ color: '#000', marginTop: 10, fontSize: 12 }}>(*) There may be discrepancies in amount due to rounding</div>}
faisalhamdi's avatar
faisalhamdi committed
2104
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2105
                                <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5 }}>
d.arizona's avatar
d.arizona committed
2106
                                    <div>
2107
                                        <div style={{ display: 'flex' }}>
faisalhamdi's avatar
faisalhamdi committed
2108
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
2109
                                            <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
faisalhamdi's avatar
faisalhamdi committed
2110 2111
                                                {
                                                    this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
qorri_di's avatar
qorri_di committed
2112 2113 2114 2115
                                                        return (
                                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                        )
                                                    }) :
2116
                                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
faisalhamdi's avatar
faisalhamdi committed
2117 2118 2119 2120

                                                }
                                            </div>
                                        </div>
d.arizona's avatar
d.arizona committed
2121
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2122 2123
                                    <div style={{ display: 'flex', flexDirection: 'row' }}>
                                        <div style={{ padding: 5 }}>
d.arizona's avatar
d.arizona committed
2124 2125
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>TOTAL SCORE</Typography>
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2126
                                        <div style={{ border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
faisalhamdi's avatar
faisalhamdi committed
2127 2128 2129
                                            {!this.state.loading && (
                                                <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalScore}</Typography>
                                            )}
d.arizona's avatar
d.arizona committed
2130 2131 2132
                                        </div>
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2133
                                <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15 }}>
d.arizona's avatar
d.arizona committed
2134 2135 2136
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notes}</Typography>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2137 2138
                                    <div style={{ display: 'flex', flexDirection: 'row' }}>
                                        <div style={{ padding: 5 }}>
d.arizona's avatar
d.arizona committed
2139 2140
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography>
                                        </div>
d.arizona's avatar
d.arizona committed
2141
                                        <div style={{ borderStyle: 'solid', backgroundColor: this.state.perfomanceScoreColor, borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
faisalhamdi's avatar
faisalhamdi committed
2142 2143
                                            {!this.state.loading && (
                                                <Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</Typography>
d.arizona's avatar
d.arizona committed
2144
                                            )}
d.arizona's avatar
d.arizona committed
2145 2146 2147
                                        </div>
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164
                            </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'
                                        }}
                                    >
d.arizona's avatar
d.arizona committed
2165
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginLeft: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
2166 2167 2168 2169 2170
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
                                        </div>
                                    </button>
                                </div>
                                {this.props.isApprover === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2171
                                    <div className="col-2"></div>
faisalhamdi's avatar
faisalhamdi committed
2172 2173
                                    :
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
d.arizona's avatar
d.arizona committed
2174
                                        {this.state.get_for == 'view' && this.state.viewOnly && <button
faisalhamdi's avatar
faisalhamdi committed
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
2185
                                                this.setState({ loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2186 2187 2188 2189 2190 2191 2192 2193 2194
                                                    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
faisalhamdi's avatar
faisalhamdi committed
2195 2196 2197 2198 2199 2200 2201 2202 2203 2204
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
d.arizona's avatar
d.arizona committed
2205
                                                this.setState({ loading: true, dataTable: dataTable2, saveDraft: false, buttonError: false }, () => {
faisalhamdi's avatar
faisalhamdi committed
2206
                                                    setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
2207
                                                        // this.handleValidate()
d.arizona's avatar
d.arizona committed
2208
                                                        this.handleCalculate(dataTable2)
faisalhamdi's avatar
faisalhamdi committed
2209 2210 2211 2212 2213 2214 2215
                                                    }, 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>
faisalhamdi's avatar
faisalhamdi committed
2216 2217
                                        </button>}
                                        {this.state.get_for === 'edit' && <button
faisalhamdi's avatar
faisalhamdi committed
2218 2219 2220 2221
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2222
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
2223 2224 2225 2226 2227
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
2228
                                                this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
2229
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
2230
                                                    :
2231 2232
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2233 2234 2235 2236 2237
                                                            this.backToMonthlyReport('draft')
                                                        })
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
2238
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
faisalhamdi's avatar
faisalhamdi committed
2239
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
2240 2241
                                        </button>}
                                        {this.state.get_for === 'edit' && <button
faisalhamdi's avatar
faisalhamdi committed
2242
                                            type="button"
d.arizona's avatar
d.arizona committed
2243
                                            // disabled={this.state.buttonError}
faisalhamdi's avatar
faisalhamdi committed
2244 2245
                                            onClick={() =>
                                                this.state.buttonError ?
Riri Novita's avatar
Riri Novita committed
2246
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
2247
                                                    :
2248 2249
                                                    this.state.handleDoubleClick == 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2250 2251 2252 2253
                                                            this.backToMonthlyReport('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2254
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
2255 2256 2257 2258
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                        >
d.arizona's avatar
d.arizona committed
2259
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 10 }}>
d.arizona's avatar
d.arizona committed
2260
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
faisalhamdi's avatar
faisalhamdi committed
2261
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
2262
                                        </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
2263
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2264 2265 2266 2267 2268 2269 2270 2271
                                }
                            </div>
                        </Paper> :
                        <Paper style={{ paddingTop: 10 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Corporate Annual Target - Performance</Typography>
                            </div>
                            <div style={{ padding: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
2272 2273
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
faisalhamdi's avatar
faisalhamdi committed
2274
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
Riri Novita's avatar
Riri Novita committed
2275 2276 2277 2278 2279
                                    {this.props.defaultCurrency.id === 1 ?
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                        :
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in USD thousand</Typography>
                                    }
faisalhamdi's avatar
faisalhamdi committed
2280
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2281 2282 2283 2284 2285 2286 2287 2288 2289 2290
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
                                    {!this.state.loading && (
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
faisalhamdi's avatar
faisalhamdi committed
2291
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2292
                                <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15, marginTop: 5 }}>
d.arizona's avatar
d.arizona committed
2293
                                    <div>
2294
                                        <div style={{ display: 'flex' }}>
faisalhamdi's avatar
faisalhamdi committed
2295
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
2296
                                            <div style={{ marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10 }}>
faisalhamdi's avatar
faisalhamdi committed
2297 2298
                                                {
                                                    this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
qorri_di's avatar
qorri_di committed
2299 2300 2301 2302
                                                        return (
                                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                        )
                                                    }) :
2303
                                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>
faisalhamdi's avatar
faisalhamdi committed
2304 2305 2306 2307

                                                }
                                            </div>
                                        </div>
d.arizona's avatar
d.arizona committed
2308
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2309 2310
                                    <div style={{ display: 'flex', flexDirection: 'row' }}>
                                        <div style={{ padding: 5 }}>
d.arizona's avatar
d.arizona committed
2311 2312
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>TOTAL SCORE</Typography>
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2313
                                        <div style={{ border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
d.arizona's avatar
d.arizona committed
2314 2315 2316 2317
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalScore}</Typography>
                                        </div>
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2318
                                <div style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '100%', paddingLeft: 15, paddingRight: 15 }}>
d.arizona's avatar
d.arizona committed
2319 2320 2321
                                    <div>
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10 }}>Notes : {this.state.notes}</Typography>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
2322 2323
                                    <div style={{ display: 'flex', flexDirection: 'row' }}>
                                        <div style={{ padding: 5 }}>
d.arizona's avatar
d.arizona committed
2324 2325
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography>
                                        </div>
d.arizona's avatar
d.arizona committed
2326
                                        <div style={{ borderStyle: 'solid', backgroundColor: this.state.perfomanceScoreColor, borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
d.arizona's avatar
d.arizona committed
2327 2328 2329 2330
                                            <Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</Typography>
                                        </div>
                                    </div>
                                </div>
rifkaki's avatar
rifkaki committed
2331
                                <div className="grid grid-2x" style={{ marginTop: 10, padding: 20, paddingLeft: 0, paddingRight: 0 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2332
                                    <div className="col-1" style={{ paddingLeft: 0 }}>
faisalhamdi's avatar
faisalhamdi committed
2333 2334
                                        <button
                                            type="button"
faisalhamdi's avatar
faisalhamdi committed
2335
                                            onClick={() => this.setState({ loading: true, visibleCATMR: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2336
                                                setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
2337
                                                    this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350
                                                }, 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' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
                                            </div>
                                        </button>
faisalhamdi's avatar
faisalhamdi committed
2351
                                    </div>
rifkaki's avatar
rifkaki committed
2352
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
d.arizona's avatar
d.arizona committed
2364
                                                this.setState({ loading: true, dataTable: dataTable2, saveDraft: false, buttonError: false }, () => {
faisalhamdi's avatar
faisalhamdi committed
2365 2366
                                                    setTimeout(() => {
                                                        // this.handleValidate()
Deni Rinaldi's avatar
Deni Rinaldi committed
2367
                                                        this.handleCalculate(dataTable2)
faisalhamdi's avatar
faisalhamdi committed
2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380
                                                    }, 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>
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2381
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
2382 2383 2384 2385 2386 2387
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
                                                this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
2388
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
2389
                                                    :
2390 2391
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2392 2393 2394 2395 2396
                                                            this.uploadCATMR('draft')
                                                        })
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
2397
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
faisalhamdi's avatar
faisalhamdi committed
2398 2399 2400 2401
                                            </div>
                                        </button>
                                        <button
                                            type="button"
d.arizona's avatar
d.arizona committed
2402
                                            // disabled={this.state.buttonError}
faisalhamdi's avatar
faisalhamdi committed
2403 2404
                                            onClick={() =>
                                                this.state.buttonError ?
Riri Novita's avatar
Riri Novita committed
2405
                                                    this.setState({ alert: true, messageAlert: 'Data Incomplete', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
2406
                                                    :
2407 2408
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
2409 2410 2411 2412
                                                            this.uploadCATMR('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
2413
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
2414 2415 2416 2417 2418 2419 2420 2421
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
                                            </div>
                                        </button>
Deni Rinaldi's avatar
Deni Rinaldi committed
2422
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
2423
                                </div>
faisalhamdi's avatar
faisalhamdi committed
2424
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2425 2426
                        </Paper>
                    }
faisalhamdi's avatar
faisalhamdi committed
2427
                </div>
faisalhamdi's avatar
faisalhamdi committed
2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446
                {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>
2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463
                            <div style={{ padding: '25px 30px' }}>
                                <UploadFile
                                    type={this.state.uploadStatus}
                                    percentage={this.state.percentage}
                                    result={this.state.result}
                                    acceptedFiles={["xlsx"]}
                                    onHandle={(dt) => {
                                        this.fileHandler(dt)
                                        this.setState({ uploadStatus: 'idle', percentage: '0' })
                                    }}
                                    onUpload={() => {
                                        String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("PERFORMANCE") && String(this.state.judul).includes("CAT") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
                                            this.checkUpload() :
                                            this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                    }}
                                />
                            </div>
2464
                            <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data in <b>{this.props.defaultCurrency.id == 1 ? "IDR mn" : "thousand USD"}</b></div>
2465 2466 2467 2468
                        </div>
                    </div>
                )}

Riri Novita's avatar
Riri Novita committed
2469
                {this.state.visibleAlertSave && (
2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492
                    <div className="test app-popup-show">
                        <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
                            <div style={{ margin: 30 }}>
                                <div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
                                    <div style={{ alignSelf: 'center', marginRight: 25 }}>
                                        <img src={Images.warning} />
                                    </div>
                                    <div style={{ justifyContent: 'center', fontSize: 20, color: '#1D2995', marginTop: 10 }}>
                                        <b>Rate Currency USD</b> pada periode yang dipilih <b>belum</b> diatur.<br /> Silahkan menghubungi Superadmin
                                    </div>
                                </div>
                                <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            background: '#F6F7F9',
                                            cursor: 'pointer',
                                            border: '1px solid #3549609e',
                                            outline: 'none',
                                            marginRight: 20,
                                            borderRadius: 9
                                        }}
2493
                                        onClick={() => this.setState({ visibleAlertSave: false, handleDoubleClick: 0, loading: false })}
2494 2495 2496 2497 2498 2499 2500
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 9, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
                                            <Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
                                        </div>
                                    </button>
                                </div>
                            </div>
faisalhamdi's avatar
faisalhamdi committed
2501 2502 2503
                        </div>
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
2504 2505 2506 2507
            </div>
        )
    }
}