FixedAssetsMovementMR.js 106 KB
Newer Older
faisalhamdi's avatar
faisalhamdi committed
1
import React, { Component } from 'react';
faisalhamdi's avatar
faisalhamdi committed
2
import { createMuiTheme, FormControlLabel, MuiThemeProvider, Paper, TableCell, Tooltip, Typography, withStyles, Snackbar } from '@material-ui/core';
faisalhamdi's avatar
faisalhamdi committed
3 4
import MUIDataTable from 'mui-datatables';
import api from '../../api';
faisalhamdi's avatar
faisalhamdi committed
5 6
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
faisalhamdi's avatar
faisalhamdi committed
7
import NumberFormat from 'react-number-format';
faisalhamdi's avatar
faisalhamdi committed
8
import { PropagateLoader } from 'react-spinners';
faisalhamdi's avatar
faisalhamdi committed
9 10
import UploadFile from '../../library/Upload';
import { ExcelRenderer } from 'react-excel-renderer';
faisalhamdi's avatar
faisalhamdi committed
11 12 13
import * as R from 'ramda'
import Constant from '../../library/Constant';
import { Alert } from '@material-ui/lab';
faisalhamdi's avatar
faisalhamdi committed
14 15 16 17 18 19 20 21 22

const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);
faisalhamdi's avatar
faisalhamdi committed
23 24 25 26 27

var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());

const options = ct.customOptionsFixedColumn();
faisalhamdi's avatar
faisalhamdi committed
28

faisalhamdi's avatar
faisalhamdi committed
29 30 31 32
const style = {
    position: "sticky",
    left: 0,
    background: "white",
faisalhamdi's avatar
faisalhamdi committed
33
    zIndex: 101,
faisalhamdi's avatar
faisalhamdi committed
34 35 36 37
};
const style2 = {
    position: "sticky",
    background: "white",
faisalhamdi's avatar
faisalhamdi committed
38 39
    zIndex: 100,
    top: 0
faisalhamdi's avatar
faisalhamdi committed
40 41 42 43 44 45
};

export default class FixedAssetsMovementMR extends Component {
    constructor(props) {
        super(props)
        this.state = {
faisalhamdi's avatar
faisalhamdi committed
46
            dataTable: [],
faisalhamdi's avatar
faisalhamdi committed
47
            loading: true,
faisalhamdi's avatar
faisalhamdi committed
48
            visibleFAMMR: true,
faisalhamdi's avatar
faisalhamdi committed
49
            updateBy: [],
d.arizona's avatar
d.arizona committed
50
            notesUpdate: '-',
rifkaki's avatar
rifkaki committed
51
            get_for: 'view',
faisalhamdi's avatar
faisalhamdi committed
52 53
            saveDraft: true,
            buttonError: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
54
            viewOnly: true
faisalhamdi's avatar
faisalhamdi committed
55
        }
faisalhamdi's avatar
faisalhamdi committed
56
        this.fileHandler = this.fileHandler.bind(this);
faisalhamdi's avatar
faisalhamdi committed
57 58 59 60
    }

    componentDidMount() {
        this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
61
        this.getLatestUpdate()
rifkaki's avatar
rifkaki committed
62
        this.handleViewOnly()
faisalhamdi's avatar
faisalhamdi committed
63 64
    }

d.arizona's avatar
d.arizona committed
65
    handleGetFor(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
66
        this.setState({ get_for: type }, () => {
d.arizona's avatar
d.arizona committed
67 68 69 70 71
            this.getItemHierarki()
            this.getLatestUpdate()
        })
    }

rifkaki's avatar
rifkaki committed
72 73 74 75
    handleViewOnly() {
        let checkApprover = false
        let checkLastStatus = false
        let checkStatus = false
d.arizona's avatar
d.arizona committed
76
        let checkPrevRev = false
rifkaki's avatar
rifkaki committed
77 78 79 80 81 82

        if (this.props.isApprover) {
            checkApprover = true
        } else {
            checkApprover = false
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
83

rifkaki's avatar
rifkaki committed
84 85 86 87
        if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
            checkLastStatus = true
        } else {
            checkLastStatus = false
Deni Rinaldi's avatar
Deni Rinaldi committed
88
        }
d.arizona's avatar
d.arizona committed
89 90 91 92 93 94
        
        if (this.props.prevRevision) {
            checkPrevRev = true
        } else {
            checkPrevRev = false
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
95

rifkaki's avatar
rifkaki committed
96 97 98 99 100 101
        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
102
        this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
rifkaki's avatar
rifkaki committed
103 104
    }

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

faisalhamdi's avatar
faisalhamdi committed
137
    getItemHierarki() {
faisalhamdi's avatar
faisalhamdi committed
138 139 140 141 142
        let payload = {
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
faisalhamdi's avatar
faisalhamdi committed
143
            "monthly_report_id": this.props.monthlyReportId,
d.arizona's avatar
d.arizona committed
144 145
            "months": this.props.month.month_id,
            "get_for": this.state.get_for
faisalhamdi's avatar
faisalhamdi committed
146
        }
faisalhamdi's avatar
faisalhamdi committed
147
        api.create().getHierarkiMontlyReportFAM(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
148
            // console.log(payload);
rifkaki's avatar
rifkaki committed
149
            console.log(response);
faisalhamdi's avatar
faisalhamdi committed
150 151
            let dataTable = []
            if (response.data) {
faisalhamdi's avatar
faisalhamdi committed
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
                if (response.data.status === 'success') {
                    let res = response.data.data
                    const handlePushChild = (item) => {
                        let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                        if (indexIDzz === -1) {
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
                                item.fixed_asset_movement.mtd_mb === "" ? "0.0" : item.fixed_asset_movement.mtd_mb,
                                item.fixed_asset_movement.mtd_rb === "" ? "0.0" : item.fixed_asset_movement.mtd_rb,
                                item.fixed_asset_movement.mtd_actual === "" ? "0.0" : item.fixed_asset_movement.mtd_actual,
                                item.fixed_asset_movement.act_vs_mb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_amount,
                                item.fixed_asset_movement.act_vs_mb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_percent,
                                item.fixed_asset_movement.act_vs_rb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_amount,
                                item.fixed_asset_movement.act_vs_rb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_percent,
faisalhamdi's avatar
faisalhamdi committed
171
                                item.fixed_asset_movement.actual_formula,
faisalhamdi's avatar
faisalhamdi committed
172 173 174 175 176 177 178 179 180 181 182 183
                                item.order
                            ])
                        }
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
                        }
                    }
                    res.map((item, index) => {
faisalhamdi's avatar
faisalhamdi committed
184 185 186 187 188 189 190
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.description,
faisalhamdi's avatar
faisalhamdi committed
191 192 193 194 195 196 197
                            item.fixed_asset_movement.mtd_mb === "" ? "0.0" : item.fixed_asset_movement.mtd_mb,
                            item.fixed_asset_movement.mtd_rb === "" ? "0.0" : item.fixed_asset_movement.mtd_rb,
                            item.fixed_asset_movement.mtd_actual === "" ? "0.0" : item.fixed_asset_movement.mtd_actual,
                            item.fixed_asset_movement.act_vs_mb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_amount,
                            item.fixed_asset_movement.act_vs_mb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_percent,
                            item.fixed_asset_movement.act_vs_rb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_amount,
                            item.fixed_asset_movement.act_vs_rb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_percent,
faisalhamdi's avatar
faisalhamdi committed
198
                            item.fixed_asset_movement.actual_formula,
faisalhamdi's avatar
faisalhamdi committed
199
                            item.order
faisalhamdi's avatar
faisalhamdi committed
200
                        ])
faisalhamdi's avatar
faisalhamdi committed
201 202 203 204 205 206
                        if (item.children !== null) {
                            if (item.children.length > 0) {
                                item.children.map((items, indexs) => {
                                    handlePushChild(items)
                                })
                            }
faisalhamdi's avatar
faisalhamdi committed
207
                        }
faisalhamdi's avatar
faisalhamdi committed
208
                    })
rifkaki's avatar
rifkaki committed
209
                    console.log(dataTable);
faisalhamdi's avatar
faisalhamdi committed
210
                    this.setState({ dataTable, loading: false, refresh: false, buttonError: true, saveDraft: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
211
                        this.setState({ loading: true, refresh: true })
d.arizona's avatar
d.arizona committed
212
                        setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
213
                            this.setState({ loading: false, refresh: false, buttonError: true, saveDraft: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
214 215
                        }, 200);

d.arizona's avatar
d.arizona committed
216
                    })
faisalhamdi's avatar
faisalhamdi committed
217 218
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
219
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
220 221 222 223
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
faisalhamdi's avatar
faisalhamdi committed
224
                        }
faisalhamdi's avatar
faisalhamdi committed
225
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
226
                }
faisalhamdi's avatar
faisalhamdi committed
227
            } else {
faisalhamdi's avatar
faisalhamdi committed
228
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, refresh: false, buttonError: true, saveDraft: true })
faisalhamdi's avatar
faisalhamdi committed
229 230 231 232
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
233 234
    downloadTemplate = async () => {
        let res = await fetch(
235
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/fam/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}`
faisalhamdi's avatar
faisalhamdi committed
236 237 238 239 240 241 242 243 244
        )
        res = await res.blob()
        console.log(res);
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Template Monthly Report Fixed Assets Movement.xlsx'
            a.click();
Deni Rinaldi's avatar
Deni Rinaldi committed
245
        }
faisalhamdi's avatar
faisalhamdi committed
246 247 248
    }

    async downloadAllData() {
faisalhamdi's avatar
faisalhamdi committed
249
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/fam/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
250 251
        console.log(url);
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
252
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/fam/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
253
        )
faisalhamdi's avatar
faisalhamdi committed
254 255
        res = await res.blob()
        this.setState({ loading: false })
faisalhamdi's avatar
faisalhamdi committed
256 257 258 259 260 261 262 263 264
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Monthly Report Fixed Assets Movement.xlsx';
            a.click();
        }
    }

faisalhamdi's avatar
faisalhamdi committed
265 266 267 268 269 270 271 272 273 274 275 276 277
    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            if (err) {
                console.log(err);
            }
            else {
                let isi = resp.rows.slice(3)
                let payload = []
                let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
                isi.map((i, index) => {
                    if (i.length > 0) {
                        payload.push({
faisalhamdi's avatar
faisalhamdi committed
278
                            orders: i[0] === undefined ? "" : String(i[0]).trim(),
faisalhamdi's avatar
faisalhamdi committed
279 280
                            item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
                            item_report: i[2] === undefined ? "" : String(i[2]).trim(),
faisalhamdi's avatar
faisalhamdi committed
281
                            mtd_actual: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
faisalhamdi's avatar
faisalhamdi committed
282 283 284 285 286 287 288
                        })
                    }
                })
                let body = {
                    company_id: this.props.company.company_id,
                    periode: this.props.periode,
                    report_id: this.props.report_id,
faisalhamdi's avatar
faisalhamdi committed
289
                    months: this.props.month.month_id,
d.arizona's avatar
d.arizona committed
290 291
                    fixed_asset_movement: payload,
                    status: 'submitted'
faisalhamdi's avatar
faisalhamdi committed
292
                }
faisalhamdi's avatar
faisalhamdi committed
293
                // console.log(body)
rifkaki's avatar
rifkaki committed
294
                this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[0][0] })
faisalhamdi's avatar
faisalhamdi committed
295 296 297
            }
        });
    }
Deni Rinaldi's avatar
Deni Rinaldi committed
298

faisalhamdi's avatar
faisalhamdi committed
299 300
    checkUpload() {
        api.create().checkUploadMonthlyReportFAM(this.state.payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
301
            // console.log(JSON.stringify(this.state.payload));
faisalhamdi's avatar
faisalhamdi committed
302
            // console.log(this.state.payload)
d.arizona's avatar
d.arizona committed
303
            console.log(response)
faisalhamdi's avatar
faisalhamdi committed
304 305
            if (response.data) {
                if (response.data.status === 'success') {
faisalhamdi's avatar
faisalhamdi committed
306
                    this.setState({ visibleUpload: false, loading: true, visibleFAMMR: false, refresh: true })
faisalhamdi's avatar
faisalhamdi committed
307 308 309 310 311 312 313 314 315 316 317
                    let dataTable = response.data.data.map((item, index) => {
                        return [
                            item.type_report_id,
                            item.item_report_id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.item_report,
                            item.mtd_mb,
                            item.mtd_rb,
                            item.mtd_actual,
faisalhamdi's avatar
faisalhamdi committed
318 319 320 321 322
                            item.act_vs_mb_amount,
                            item.act_vs_mb_percent,
                            item.act_vs_rb_amount,
                            item.act_vs_rb_percent,
                            item.actual_formula,
faisalhamdi's avatar
faisalhamdi committed
323 324 325 326
                            item.order,
                            item.error
                        ]
                    })
faisalhamdi's avatar
faisalhamdi committed
327 328
                    console.log(dataTable)
                    this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: true, editable: true, refresh: false }, () => {
faisalhamdi's avatar
faisalhamdi committed
329
                        this.state.dataTable.map(item => {
d.arizona's avatar
d.arizona committed
330
                            if (item[15].length > 0) {
faisalhamdi's avatar
faisalhamdi committed
331
                                console.log('masuk')
faisalhamdi's avatar
faisalhamdi committed
332 333 334 335
                                this.setState({ buttonError: true, errorPreview: true, editable: true, loading: true, refresh: true })
                                setTimeout(() => {
                                    this.setState({ loading: false, refresh: false })
                                }, 200);
faisalhamdi's avatar
faisalhamdi committed
336 337
                            }
                        })
faisalhamdi's avatar
faisalhamdi committed
338
                        // console.log(this.state.dataTable);
faisalhamdi's avatar
faisalhamdi committed
339
                    })
Riri Novita's avatar
Riri Novita committed
340 341
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
342
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
343 344 345 346 347 348
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
faisalhamdi's avatar
faisalhamdi committed
349 350 351 352 353 354 355 356 357 358
                }
            }
        })
    }

    uploadFAMMR(type) {
        let data = []
        this.state.dataTable.map(i => {
            data.push({
                item_report_id: i[1],
faisalhamdi's avatar
faisalhamdi committed
359
                item_report: String(i[5]),
faisalhamdi's avatar
faisalhamdi committed
360 361 362
                mtd_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[6]).toFixed(1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6]).toFixed(1)),
                mtd_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[7]).toFixed(1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
                mtd_actual: i[0] === 5 || i[0] === 6 ? String(Number(i[8]).toFixed(1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
faisalhamdi's avatar
faisalhamdi committed
363 364 365 366
                act_vs_mb_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[9]).toFixed(1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
                act_vs_mb_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[10]).toFixed(1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
                act_vs_rb_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[11]).toFixed(1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
                act_vs_rb_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[12]).toFixed(1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
faisalhamdi's avatar
faisalhamdi committed
367 368 369
            })
        })
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
370
            "monthly_report_id": this.props.monthlyReportId,
faisalhamdi's avatar
faisalhamdi committed
371 372 373 374 375 376 377 378 379
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
            "months": this.props.month.month_id,
            "fixed_asset_movement": data
        }
        console.log(data);
        api.create('UPLOAD').uploadMonthlyReportFAM(body).then(response => {
faisalhamdi's avatar
faisalhamdi committed
380
            // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
381
            if (response.data) {
faisalhamdi's avatar
faisalhamdi committed
382
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
383
                    // this.props.onClickClose()
d.arizona's avatar
d.arizona committed
384 385 386 387 388
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('FAM')
                    } else {
                        this.props.saveToMonthlyReport()
                    }
faisalhamdi's avatar
faisalhamdi committed
389
                    // this.props.getReport()
faisalhamdi's avatar
faisalhamdi committed
390
                } else {
faisalhamdi's avatar
faisalhamdi committed
391
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
392
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
393 394 395 396 397 398
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
faisalhamdi's avatar
faisalhamdi committed
399
                }
faisalhamdi's avatar
faisalhamdi committed
400 401
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
faisalhamdi's avatar
faisalhamdi committed
402 403 404 405
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
406
    backToMonthlyReport(type) {
faisalhamdi's avatar
faisalhamdi committed
407
        this.setState({ loading: true })
faisalhamdi's avatar
faisalhamdi committed
408
        // console.log(this.state.dataTable);
faisalhamdi's avatar
faisalhamdi committed
409 410 411
        let data = []
        this.state.dataTable.map(i => {
            data.push({
faisalhamdi's avatar
faisalhamdi committed
412
                "item_report_id": i[1],
faisalhamdi's avatar
faisalhamdi committed
413 414 415 416 417 418 419
                "mtd_mb": String(Number(i[6]).toFixed(1)),
                "mtd_rb": String(Number(i[7]).toFixed(1)),
                "mtd_actual": String(Number(i[8]).toFixed(1)),
                "act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(Number(i[9]).toFixed(1)),
                "act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(Number(i[10]).toFixed(1)),
                "act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(Number(i[11]).toFixed(1)),
                "act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(Number(i[12]).toFixed(1))
faisalhamdi's avatar
faisalhamdi committed
420
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
421
        })
faisalhamdi's avatar
faisalhamdi committed
422
        let payload = {
Deni Rinaldi's avatar
Deni Rinaldi committed
423
            "monthly_report_id": this.props.monthlyReportId,
faisalhamdi's avatar
faisalhamdi committed
424 425 426 427 428 429 430
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": type,
            "months": this.props.month.month_id,
            "fixed_asset_movement": data
        }
faisalhamdi's avatar
faisalhamdi committed
431
        // console.log(JSON.stringify(payload));
Deni Rinaldi's avatar
Deni Rinaldi committed
432

faisalhamdi's avatar
faisalhamdi committed
433
        api.create('UPLOAD').createMonthlyReportFAM(payload).then(response => {
faisalhamdi's avatar
faisalhamdi committed
434
            // console.log(response);
faisalhamdi's avatar
faisalhamdi committed
435 436
            if (response.data) {
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
437 438 439 440 441
                    if (type == 'submitted') {
                        this.props.saveToMonthlyReport('FAM')
                    } else {
                        this.props.saveToMonthlyReport()
                    }
faisalhamdi's avatar
faisalhamdi committed
442
                } else {
Riri Novita's avatar
Riri Novita committed
443 444
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false}, () => {
                        document.body.style.overflow = 'unset';
d.arizona's avatar
d.arizona committed
445
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Riri Novita's avatar
Riri Novita committed
446 447 448 449 450
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
faisalhamdi's avatar
faisalhamdi committed
451 452
                        this.props.saveToMonthlyReport()
                    })
Riri Novita's avatar
Riri Novita committed
453 454 455 456 457 458
                } 
                // else {
                //     this.setState({ loading: false }, () => {
                //         this.props.saveToMonthlyReport()
                //     })
                // }
faisalhamdi's avatar
faisalhamdi committed
459 460 461 462 463
            } else {
                this.setState({ loading: false }, () => {
                    this.getSubmission()
                    document.body.style.overflow = 'unset';
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
464 465
            }
        })
faisalhamdi's avatar
faisalhamdi committed
466 467
    }

faisalhamdi's avatar
faisalhamdi committed
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
    handleValidate() {
        let data = []
        let err = false
        this.state.dataTable.map((i, index) => {
            
            data.push({
                "item_report_id": i[1],
                "mtd_mb": i[6],
                "mtd_rb": i[7],
                "mtd_actual": i[8],
                "act_vs_mb_amount": String(i[9]) === 'NaN' || String(i[9]) === 'Infinity' || String(i[9]) === '-Infinity' ? '0.0' : String(i[9]),
                "act_vs_mb_percent": String(i[10]) === 'NaN' || String(i[10]) === 'Infinity' || String(i[10]) === '-Infinity' ? '0.0' : String(i[10]),
                "act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(i[11]),
                "act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(i[12])
            })
        })


        // console.log(JSON.stringify(data))
        let payload = {
            "monthly_report_id": this.props.monthlyReportId,
            "company_id": this.props.company.company_id,
            "periode": this.props.periode,
            "report_id": this.props.report_id,
            "status": "submitted",
            "months": this.props.month.month_id,
            "fixed_asset_movement": data
        }
        // console.log(JSON.stringify(payload));
        api.create().validateSubmitReportFAM(payload).then((response) => {
            console.log(response.data.data.result)
            console.log(err);
            if (response.data) {
                if (response.data.status === "success") {
                    if (response.data.data.result && err === false) {
                        this.setState({ loading: false, buttonError: false, editable: false, saveDraft: false })
                    } else {
                        this.setState({ loading: false, buttonError: true, editable: true, saveDraft: false })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
d.arizona's avatar
d.arizona committed
509
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
faisalhamdi's avatar
faisalhamdi committed
510 511 512 513 514 515 516 517 518 519 520 521 522
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
            }
        })
    }

faisalhamdi's avatar
faisalhamdi committed
523 524 525 526
    closeAlert() {
        this.setState({ alert: false })
    }

faisalhamdi's avatar
faisalhamdi committed
527
    render() {
faisalhamdi's avatar
faisalhamdi committed
528
        let dataTable2 = this.state.dataTable
faisalhamdi's avatar
faisalhamdi committed
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543

        const handleValueFormula = (tableMeta, colIdx) => {
            // loading = true
            // console.log(tableMeta);
            // "@44[M-1]#BS"
            let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
            let baru = []
            let anjay = []
            // console.log(splitFormula);
            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)
                // console.log(item);
                // console.log(items);
                // console.log(subForm);
Deni Rinaldi's avatar
Deni Rinaldi committed
544

faisalhamdi's avatar
faisalhamdi committed
545 546 547 548 549 550 551 552 553 554
                let re = /^[a-zA-Z0-9_]+$/;
                if (item !== "") {
                    if (items == ']') {
                        baru.push(String(item))
                    } else if (!re.test(items)) {
                        baru.push(subForm)
                        baru.push(items)
                    } else {
                        baru.push(String(item))
                    }
faisalhamdi's avatar
faisalhamdi committed
555 556 557
                }
            })

faisalhamdi's avatar
faisalhamdi committed
558
            // console.log(baru);
Riri Novita's avatar
Riri Novita committed
559 560
            let tambahan = false
            let opet = ""
faisalhamdi's avatar
faisalhamdi committed
561
            baru.map((item, index) => {
Riri Novita's avatar
Riri Novita committed
562 563 564
                if (item == 'X') {
                    tambahan = true
                } else if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
faisalhamdi's avatar
faisalhamdi committed
565
                    anjay.push(item)
faisalhamdi's avatar
faisalhamdi committed
566
                } else {
faisalhamdi's avatar
faisalhamdi committed
567 568
                    if (String(item).includes('#')) {
                        if (String(item).includes('[M-1]')) {
Riri Novita's avatar
Riri Novita committed
569
                            let tst = '@' + String(item).replace('[M-1]', '[M1]')
Deni Rinaldi's avatar
Deni Rinaldi committed
570 571
                            // console.log(dataTable2[tableMeta.rowIndex]);
                            // console.log(tableMeta);
Riri Novita's avatar
Riri Novita committed
572
                            console.log(tst);
faisalhamdi's avatar
faisalhamdi committed
573
                            let indexID = dataTable2[tableMeta.rowIndex][13].findIndex((val) => val.item_formula == tst)
Deni Rinaldi's avatar
Deni Rinaldi committed
574
                            // console.log(indexID);
Deni Rinaldi's avatar
Deni Rinaldi committed
575

faisalhamdi's avatar
faisalhamdi committed
576
                            if (indexID !== -1) {
faisalhamdi's avatar
faisalhamdi committed
577
                                let valuezz = dataTable2[tableMeta.rowIndex][13][indexID].value
faisalhamdi's avatar
faisalhamdi committed
578
                                anjay.push(valuezz == "" ? 0 : valuezz)
Deni Rinaldi's avatar
Deni Rinaldi committed
579
                                // console.log(valuezz);
faisalhamdi's avatar
faisalhamdi committed
580
                            }
faisalhamdi's avatar
faisalhamdi committed
581
                        } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
582
                            let data = tableMeta.rowData[13] == null ? [] : tableMeta.rowData[13]
faisalhamdi's avatar
faisalhamdi committed
583 584 585 586 587
                            let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
                            if (indexID !== -1) {
                                let valuezz = data[indexID].value
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
faisalhamdi's avatar
faisalhamdi committed
588 589
                        }
                    } else {
faisalhamdi's avatar
faisalhamdi committed
590 591
                        if (String(item).includes('[M-1]')) {
                            let tst = String(item).replace('[M-1]', '')
faisalhamdi's avatar
faisalhamdi committed
592
                            let indexID = dataTable2.findIndex((val) => val[14] == tst)
faisalhamdi's avatar
faisalhamdi committed
593 594 595 596 597
                            if (indexID !== -1) {
                                let valuezz = dataTable2[indexID][8]
                                anjay.push(valuezz == "" ? 0 : valuezz)
                            }
                        } else {
faisalhamdi's avatar
faisalhamdi committed
598
                            let indexID = dataTable2.findIndex((val) => val[14] == item)
Riri Novita's avatar
Riri Novita committed
599 600 601 602 603
                            if (item == 'X-1') {
                                anjay.push(-1)
                            } else if (tambahan) {
                                if (item == '-' || item == '+' || item == '/' || item == '*') {
                                    opet = item
faisalhamdi's avatar
faisalhamdi committed
604
                                } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
605
                                    anjay.push(opet == '' ? Number(item) : Number(String(opet + String(item))))
Riri Novita's avatar
Riri Novita committed
606 607
                                    tambahan = false
                                    opet = ""
faisalhamdi's avatar
faisalhamdi committed
608 609
                                }
                            } else {
Riri Novita's avatar
Riri Novita committed
610 611 612 613 614 615 616 617 618 619 620
                                if (indexID !== -1) {
                                    let valuezz = dataTable2[indexID][colIdx]
                                    if (item == dataTable2[tableMeta.rowIndex][28]) {
                                        anjay.push(0)
                                    } else {
                                        anjay.push(valuezz == "" ? 0 : valuezz)
                                    }
                                } else {
                                    if (item === '(-1)') {
                                        anjay.push(-1)
                                    }
faisalhamdi's avatar
faisalhamdi committed
621 622
                                }
                            }
faisalhamdi's avatar
faisalhamdi committed
623 624 625 626 627
                        }
                    }
                }
            })

faisalhamdi's avatar
faisalhamdi committed
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
            let anjay2 = []
            let kurung = false
            let item1 = []
            anjay.map((item, index) => {
                if (item == "(") {
                    kurung = true
                } else if (item == ")") {
                    kurung = false
                    anjay2.push(item1)
                    item1 = []
                } else {
                    if (kurung) {
                        item1.push(item)
                    } else {
                        anjay2.push(item)
                    }
                }
            })

faisalhamdi's avatar
faisalhamdi committed
647
            let total = 0
faisalhamdi's avatar
faisalhamdi committed
648
            let opt = ""
faisalhamdi's avatar
faisalhamdi committed
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
            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)
                            }
                        }
                    })
faisalhamdi's avatar
faisalhamdi committed
678

faisalhamdi's avatar
faisalhamdi committed
679 680 681 682 683 684 685 686 687 688 689 690 691
                    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)
                        }
                    }
faisalhamdi's avatar
faisalhamdi committed
692
                } else {
faisalhamdi's avatar
faisalhamdi committed
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
                    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 = ""
                        }
faisalhamdi's avatar
faisalhamdi committed
725
                    } else {
faisalhamdi's avatar
faisalhamdi committed
726 727 728 729 730 731 732 733 734 735 736
                        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)
                        }
faisalhamdi's avatar
faisalhamdi committed
737
                    }
faisalhamdi's avatar
faisalhamdi committed
738 739
                }
            })
faisalhamdi's avatar
faisalhamdi committed
740

faisalhamdi's avatar
faisalhamdi committed
741 742 743 744
            total = R.equals(total, NaN) ? "0.0" : total
            dataTable2[tableMeta.rowIndex][colIdx] = total
            return total
        }
faisalhamdi's avatar
faisalhamdi committed
745

faisalhamdi's avatar
faisalhamdi committed
746
        const handleChange = (value, tableMeta, type) => {
d.arizona's avatar
d.arizona committed
747 748
            let val = String(value).split(",").join("")
            dataTable2[tableMeta.rowIndex][type] = val
d.arizona's avatar
d.arizona committed
749
            // console.log(dataTable2)
faisalhamdi's avatar
faisalhamdi committed
750 751 752
            // console.log(dataTable2[tableMeta.rowIndex][type]);
            // console.log(value);
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
753

faisalhamdi's avatar
faisalhamdi committed
754 755 756 757 758 759 760 761 762 763 764 765
        const handleValue = (data, type) => {
            // console.log(data, type);            
            let total = 0
            dataTable2.map((item, index) => {
                if (data.rowData[1] === item[2]) {
                    let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type])
                    total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal
                }
            })
            let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
            let a = dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
            // console.log(indexParent);
faisalhamdi's avatar
faisalhamdi committed
766 767
            return a
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
768

faisalhamdi's avatar
faisalhamdi committed
769 770
        const handleVariance = (tableMeta, dex, type) => {
            let total = 0
faisalhamdi's avatar
faisalhamdi committed
771 772 773
            // if (dex === 1) {
            //     total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[9]) == NaN? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[9])
            //     dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
774 775 776
            // console.log(tableMeta.rowData[8]);
            // console.log(tableMeta.rowData[9]);
            // console.log(total)
faisalhamdi's avatar
faisalhamdi committed
777
            if (dex === 2) {
Deni Rinaldi's avatar
Deni Rinaldi committed
778
                total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[6]) == NaN ? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[6])
Deni Rinaldi's avatar
Deni Rinaldi committed
779
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
d.arizona's avatar
d.arizona committed
780 781 782
                // console.log(tableMeta.rowData[8]);
                // console.log(tableMeta.rowData[6]);
                // console.log(total)
faisalhamdi's avatar
faisalhamdi committed
783
            } else if (dex === 3) {
Deni Rinaldi's avatar
Deni Rinaldi committed
784
                total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[7]) == NaN ? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[7])
Deni Rinaldi's avatar
Deni Rinaldi committed
785
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Riri Novita's avatar
Riri Novita committed
786 787 788
                // console.log(tableMeta.rowData[8]);
                // console.log(tableMeta.rowData[7]);
                // console.log(total)
faisalhamdi's avatar
faisalhamdi committed
789
            }
d.arizona's avatar
d.arizona committed
790 791
            // console.log(dex)
            // console.log(Number(tableMeta.columnIndex) + Number(type))
faisalhamdi's avatar
faisalhamdi committed
792 793
            // console.log(total);
            // console.log(dataTable2);
faisalhamdi's avatar
faisalhamdi committed
794 795 796 797 798
            return total
        }

        const handleVariancePercent = (tableMeta, dex, type) => {
            let total = 0
faisalhamdi's avatar
faisalhamdi committed
799 800 801 802 803 804
            // if (tableMeta.rowData[5] === "Disposal (negative value)") {
            //     console.log(dataTable2);
            //     console.log(tableMeta);
            // }
            // value={Number(handleVariancePercent(tableMeta, 1, 3)).toFixed(1)}
            // dataTable2[5][11]
faisalhamdi's avatar
faisalhamdi committed
805 806 807
            // if (dex === 1) {
            //     total = R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])
            //     dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
Deni Rinaldi's avatar
Deni Rinaldi committed
808 809 810 811 812
            // if (tableMeta.rowData[5] === "Cash and cash equivalent") {
            // console.log(total);
            // console.log(Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10]));
            //     console.log(dataTable2[tableMeta.rowIndex]);
            // }
faisalhamdi's avatar
faisalhamdi committed
813 814
            if (dex === 2) {
                total = R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])
Deni Rinaldi's avatar
Deni Rinaldi committed
815
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
faisalhamdi's avatar
faisalhamdi committed
816
            } else if (dex === 3) {
faisalhamdi's avatar
faisalhamdi committed
817
                total = R.equals((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][7])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][7])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][7])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][7])
Deni Rinaldi's avatar
Deni Rinaldi committed
818
                dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
faisalhamdi's avatar
faisalhamdi committed
819
                // console.log(total);
faisalhamdi's avatar
faisalhamdi committed
820
            }
d.arizona's avatar
d.arizona committed
821 822
            // console.log(dex)
            // console.log(Number(tableMeta.columnIndex) + Number(type))
d.arizona's avatar
d.arizona committed
823
            return total * 100
faisalhamdi's avatar
faisalhamdi committed
824 825
        }

faisalhamdi's avatar
faisalhamdi committed
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
        let columns = [
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
Deni Rinaldi's avatar
Deni Rinaldi committed
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882
                name: "Account",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300, borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style }),
                    customBodyRender: (value, tableMeta) => {
                        return (
                            <div style={{ width: 300 }}>
                                {tableMeta.rowData[24] ?
                                    tableMeta.rowData[24].length > 0 ?
                                        <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 ? "" : value}</span>
                                            </LightTooltip>
                                        </div>
                                        :
                                        tableMeta.rowData[4] === 0 ?
                                            <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : value).toUpperCase()}</span>
                                            :
                                            <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                                <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : value}</span>
                                            </div>
faisalhamdi's avatar
faisalhamdi committed
883
                                    :
faisalhamdi's avatar
faisalhamdi committed
884 885
                                    tableMeta.rowData[4] === 0 ?
                                        <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : value).toUpperCase()}</span>
faisalhamdi's avatar
faisalhamdi committed
886 887
                                        :
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
faisalhamdi's avatar
faisalhamdi committed
888
                                            <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : value}</span>
faisalhamdi's avatar
faisalhamdi committed
889
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
890 891 892 893
                                }
                            </div>
                        )
                    }
faisalhamdi's avatar
faisalhamdi committed
894
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
895 896 897 898 899 900
            }, {
                name: `Month To Date (MTD)`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <th style={{ ...style2, color: '#fff', backgroundColor: '#1c71b8', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)", padding: 0 }} >
                            {/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
faisalhamdi's avatar
faisalhamdi committed
901 902
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell> */}
Deni Rinaldi's avatar
Deni Rinaldi committed
903 904 905 906 907 908 909 910 911 912 913
                            <div style={{ borderBottom: "1px #fff solid", backgroundColor: '#1c71b8', justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45 }}>{columnMeta.name}</div>
                            <div className="grid grid-3x" style={{ ...style2, color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                    <span>{"Master Budget (MB)"}</span>
                                </div>
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                    <span>{"Rolling Budget (RB)"}</span>
                                </div>
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
                                    <span>{"Actual"}</span>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
914
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
915 916 917 918 919 920 921 922 923 924 925 926
                        </th>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (value, tableMeta, updateValue) => {
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {
                                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
                                                    null :
faisalhamdi's avatar
faisalhamdi committed
927 928 929 930 931 932 933 934 935 936 937
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
d.arizona's avatar
d.arizona committed
938
                                                                    value={Number(tableMeta.rowData[6]).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
939 940
                                                                />
                                                            }
faisalhamdi's avatar
faisalhamdi committed
941
                                                        />
faisalhamdi's avatar
faisalhamdi committed
942
                                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
943 944
                                            }
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
945
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
946 947 948 949 950
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
                                            {
                                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
                                                    null :
faisalhamdi's avatar
faisalhamdi committed
951 952 953 954 955 956 957
                                                    <div style={{ flex: 1 }}>
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                    type="text"
                                                                    placeholder=""
                                                                    disabled={true}
                                                                    value={Number(tableMeta.rowData[7]).toFixed(1)}
                                                                />
                                                            }
                                                        />
                                                    </div>
                                            }
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 120 }}>
                                            {
                                                tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
                                                    null :
                                                    this.state.get_for == 'view' ?
                                                        <FormControlLabel
                                                            style={{ margin: 0 }}
                                                            value={value}
                                                            control={
                                                                <NumberFormat
                                                                    thousandSeparator={true}
                                                                    style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
faisalhamdi's avatar
faisalhamdi committed
983 984
                                                                    type="text"
                                                                    placeholder=""
Deni Rinaldi's avatar
Deni Rinaldi committed
985
                                                                    disabled={true}
Deni Rinaldi's avatar
Deni Rinaldi committed
986
                                                                    value={Number(tableMeta.rowData[8]).toFixed(1)}
faisalhamdi's avatar
faisalhamdi committed
987 988 989
                                                                />
                                                            }
                                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007
                                                        :
                                                        tableMeta.rowData[0] === 3 ?
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={value}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            // style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            style={{ color: this.props.isApprover || this.state.get_for == 'view' ? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
                                                                            value={Number(tableMeta.rowData[8]).toFixed(1)}
                                                                            onBlur={(event) => {
                                                                                handleChange(event.target.value, tableMeta, 8)
                                                                            }}
d.arizona's avatar
d.arizona committed
1008 1009
                                                                            fixedDecimalScale={1}
                                                                            decimalScale={1}
Deni Rinaldi's avatar
Deni Rinaldi committed
1010 1011 1012 1013 1014 1015
                                                                        />
                                                                    }
                                                                />
                                                            </div> :
                                                            tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
                                                                <span style={{ fontSize: 12, textAlign: 'right' }}>
faisalhamdi's avatar
faisalhamdi committed
1016 1017
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
d.arizona's avatar
d.arizona committed
1018
                                                                        style={{ color: String(tableMeta.rowData[5]).toLocaleLowerCase() == "beginning balance" && this.props.periode == 2021 && this.props.month.month_id == 1? "#5198ea" : "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
faisalhamdi's avatar
faisalhamdi committed
1019 1020
                                                                        type="text"
                                                                        placeholder=""
d.arizona's avatar
d.arizona committed
1021 1022 1023 1024 1025 1026 1027
                                                                        disabled={String(tableMeta.rowData[5]).toLocaleLowerCase() == "beginning balance" && this.props.periode == 2021 && this.props.month.month_id == 1? false : true}
                                                                        value={String(tableMeta.rowData[5]).toLocaleLowerCase() == "beginning balance" && this.props.periode == 2021 && this.props.month.month_id == 1? Number(tableMeta.rowData[8]).toFixed(1) : Number(handleValueFormula(tableMeta, 8)).toFixed(1)}
                                                                        onBlur={(event) => {
                                                                            handleChange(event.target.value, tableMeta, 8)
                                                                        }}
                                                                        fixedDecimalScale={1}
                                                                        decimalScale={1}
faisalhamdi's avatar
faisalhamdi committed
1028
                                                                    />
Deni Rinaldi's avatar
Deni Rinaldi committed
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
                                                                </span> :
                                                                <div style={{ flex: 1 }}>
                                                                    <FormControlLabel
                                                                        style={{ margin: 0 }}
                                                                        value={value}
                                                                        control={
                                                                            <NumberFormat
                                                                                thousandSeparator={true}
                                                                                style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                                type="text"
                                                                                placeholder=""
                                                                                disabled={true}
                                                                                value={Number(tableMeta.rowData[8]).toFixed(1)}
                                                                            />
                                                                        }
                                                                    />
                                                                </div>
                                            }
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1048 1049 1050
                                    </div>
                                </div>
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1051 1052
                        )
                    }
faisalhamdi's avatar
faisalhamdi committed
1053
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
            }, {
                name: `Variance`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
                            <div style={{ borderLeft: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>{columnMeta.name}</div>
                            <div className="grid grid-2x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}>
                                    <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
                                        <span>{"Act vs MB"}</span>
faisalhamdi's avatar
faisalhamdi committed
1064
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1065 1066 1067 1068 1069 1070 1071
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
                                            <span>{"Amount"}</span>
                                        </div>
                                        <div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
                                            <span>{"%"}</span>
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1072 1073
                                    </div>
                                </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1074 1075 1076
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}>
                                    <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
                                        <span>{"Act vs RB"}</span>
faisalhamdi's avatar
faisalhamdi committed
1077
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1078 1079 1080 1081 1082 1083 1084
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
                                            <span>{"Amount"}</span>
                                        </div>
                                        <div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
                                            <span>{"%"}</span>
                                        </div>
faisalhamdi's avatar
faisalhamdi committed
1085 1086 1087
                                    </div>
                                </div>
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136
                        </th>
                    ),
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 10
                        }
                    }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        // console.log(tableMeta);
                        return (
                            <div>
                                <div className="grid grid-2x content-center">
                                    <div className="column-1">
                                        <div className="grid grid-2x content-center">
                                            <div className="column-1">
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null :
                                                        this.state.get_for == 'view' ?
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(tableMeta.rowData[9]).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                            :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            value={Number(handleVariance(tableMeta, 2, 2)).toFixed(1)}
                                                                        />
                                                                    }
faisalhamdi's avatar
faisalhamdi committed
1137
                                                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
1138 1139 1140
                                                            </div>
                                                    }
                                                </div>
faisalhamdi's avatar
faisalhamdi committed
1141
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
                                            <div className="column-2">
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null :
                                                        this.state.get_for == 'view' ?
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        suffix={'%'}
                                                                        value={Number(Number(tableMeta.rowData[10]) * 100).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                            :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            suffix={'%'}
                                                                            // value={0}
                                                                            value={Number(handleVariancePercent(tableMeta, 2, 3)).toFixed(1)}
                                                                        />
                                                                    }
faisalhamdi's avatar
faisalhamdi committed
1179
                                                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
1180 1181 1182
                                                            </div>
                                                    }
                                                </div>
faisalhamdi's avatar
faisalhamdi committed
1183 1184 1185
                                            </div>
                                        </div>
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
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
                                    <div className="column-2">
                                        <div className="grid grid-2x content-center">
                                            <div className="column-1">
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null :
                                                        this.state.get_for == 'view' ?
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        value={Number(tableMeta.rowData[11]).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                            :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            value={Number(handleVariance(tableMeta, 3, 4)).toFixed(1)}
                                                                        />
                                                                    }
faisalhamdi's avatar
faisalhamdi committed
1222
                                                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
1223 1224 1225
                                                            </div>
                                                    }
                                                </div>
faisalhamdi's avatar
faisalhamdi committed
1226
                                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
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 1262 1263
                                            <div className="column-2">
                                                <div style={{ textAlign: 'right', width: 120 }}>
                                                    {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
                                                        null :
                                                        this.state.get_for == 'view' ?
                                                            <FormControlLabel
                                                                style={{ margin: 0 }}
                                                                value={val}
                                                                control={
                                                                    <NumberFormat
                                                                        thousandSeparator={true}
                                                                        style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
                                                                        type="text"
                                                                        placeholder=""
                                                                        disabled={true}
                                                                        suffix={'%'}
                                                                        value={Number(Number(tableMeta.rowData[10]) * 100).toFixed(1)}
                                                                    />
                                                                }
                                                            />
                                                            :
                                                            <div style={{ flex: 1 }}>
                                                                <FormControlLabel
                                                                    style={{ margin: 0 }}
                                                                    value={val}
                                                                    control={
                                                                        <NumberFormat
                                                                            thousandSeparator={true}
                                                                            style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                                            type="text"
                                                                            placeholder=""
                                                                            disabled={true}
                                                                            suffix={'%'}
                                                                            // value={0}
                                                                            value={Number(handleVariancePercent(tableMeta, 3, 5)).toFixed(1)}
                                                                        />
                                                                    }
faisalhamdi's avatar
faisalhamdi committed
1264
                                                                />
Deni Rinaldi's avatar
Deni Rinaldi committed
1265 1266 1267
                                                            </div>
                                                    }
                                                </div>
faisalhamdi's avatar
faisalhamdi committed
1268 1269 1270 1271 1272
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1273 1274
                        )
                    }
faisalhamdi's avatar
faisalhamdi committed
1275
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }, {
                name: "",
                options: {
                    display: false
                }
            }]
faisalhamdi's avatar
faisalhamdi committed
1312

faisalhamdi's avatar
faisalhamdi committed
1313
        const loadingComponent = (
faisalhamdi's avatar
faisalhamdi committed
1314
            <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)' }}>
faisalhamdi's avatar
faisalhamdi committed
1315 1316 1317 1318 1319 1320 1321 1322 1323
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );

faisalhamdi's avatar
faisalhamdi committed
1324 1325
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
faisalhamdi's avatar
faisalhamdi committed
1326
                {this.state.loading && loadingComponent}
faisalhamdi's avatar
faisalhamdi committed
1327 1328 1329
                <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
1330 1331 1332 1333 1334
                <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
1335
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
faisalhamdi's avatar
faisalhamdi committed
1336 1337 1338 1339 1340 1341 1342 1343 1344
                    {this.state.visibleFAMMR ?
                        <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Fixed Assets Movement</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
1345
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
faisalhamdi's avatar
faisalhamdi committed
1346 1347 1348
                                        <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                    </div>
                                    <div style={{ width: '50%' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
1349
                                        {this.props.isApprover === true || this.state.get_for == 'view' ?
faisalhamdi's avatar
faisalhamdi committed
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 1378 1379
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() =>
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
                                                                    this.downloadAllData()
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            </div> :
                                            <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                                <a data-tip={'Download Template'} data-for="template">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1380
                                                        onClick={() => this.downloadTemplate()}
faisalhamdi's avatar
faisalhamdi committed
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407
                                                    >
                                                        <img src={Images.template} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                                <a data-tip={'Upload'} data-for="upload">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
                                                        onClick={() => this.setState({ visibleUpload: true })}
                                                    >
                                                        <img src={Images.upload} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                                <a data-tip={'Download'} data-for="download">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            margin: 5
                                                        }}
Deni Rinaldi's avatar
Deni Rinaldi committed
1408
                                                        onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
1409 1410
                                                            this.setState({ loading: true }, () => {
                                                                setTimeout(() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1411
                                                                    this.downloadAllData()
faisalhamdi's avatar
faisalhamdi committed
1412 1413 1414 1415 1416 1417 1418 1419 1420
                                                                }, 100);
                                                            })}
                                                    >
                                                        <img src={Images.download} />
                                                    </button>
                                                </a>
                                                <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                            </div>
                                        }
faisalhamdi's avatar
faisalhamdi committed
1421 1422 1423
                                    </div>
                                </div>

faisalhamdi's avatar
faisalhamdi committed
1424
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
faisalhamdi's avatar
faisalhamdi committed
1425
                                    {!this.state.refresh && (
faisalhamdi's avatar
faisalhamdi committed
1426 1427 1428 1429 1430 1431 1432 1433
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
faisalhamdi's avatar
faisalhamdi committed
1434
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
                                <div style={{display: 'flex'}}>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : </Typography>
                                    <div style={{marginLeft: 10, overflowY: 'scroll', height: this.state.updateBy.length < 2 ? 25 : 75, marginTop: 10}}>
                                        {
                                            this.state.updateBy.length > 0 ? this.state.updateBy.reverse().map((item, index) => {
                                                return (
                                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>{item.latest_update}</Typography>
                                                )
                                            }) :
                                            <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 10, marginRight: 5 }}>-</Typography>

                                        }
                                    </div>
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1449
                                <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 5 }}>Notes : {this.state.notesUpdate}</Typography>
faisalhamdi's avatar
faisalhamdi committed
1450
                            </div>
faisalhamdi's avatar
faisalhamdi committed
1451
                            <div className="grid grid-2x" style={{ padding: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
1452
                                <div className="col-1" style={{ paddingLeft: 0 }}>
faisalhamdi's avatar
faisalhamdi committed
1453 1454
                                    <button
                                        type="button"
faisalhamdi's avatar
faisalhamdi committed
1455 1456 1457 1458 1459
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
faisalhamdi's avatar
faisalhamdi committed
1460 1461 1462 1463
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
faisalhamdi's avatar
faisalhamdi committed
1464
                                            outline: 'none'
faisalhamdi's avatar
faisalhamdi committed
1465 1466
                                        }}
                                    >
faisalhamdi's avatar
faisalhamdi committed
1467 1468
                                        <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>
faisalhamdi's avatar
faisalhamdi committed
1469 1470
                                        </div>
                                    </button>
faisalhamdi's avatar
faisalhamdi committed
1471
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1472
                                {this.props.isApprover === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
1473
                                    <div className="col-2"></div>
faisalhamdi's avatar
faisalhamdi committed
1474
                                    :
faisalhamdi's avatar
faisalhamdi committed
1475
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
rifkaki's avatar
rifkaki committed
1476
                                        {this.state.get_for == 'view' && this.state.viewOnly && <button
d.arizona's avatar
d.arizona committed
1477 1478 1479 1480 1481 1482
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
faisalhamdi's avatar
faisalhamdi committed
1483
                                                outline: 'none'
d.arizona's avatar
d.arizona committed
1484 1485
                                            }}
                                            onClick={() => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1486
                                                this.setState({ loading: true, refresh: true }, () => {
d.arizona's avatar
d.arizona committed
1487
                                                    this.handleGetFor('edit')
Deni Rinaldi's avatar
Deni Rinaldi committed
1488 1489 1490
                                                    // setTimeout(() => {
                                                    //     this.setState({ loading: false })
                                                    // }, 100);
d.arizona's avatar
d.arizona committed
1491 1492 1493 1494 1495 1496 1497 1498
                                                })
                                            }}
                                        >
                                            <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
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
faisalhamdi's avatar
faisalhamdi committed
1509
                                                this.setState({ loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
1510
                                                    setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
1511 1512
                                                        // this.setState({ loading: false })
                                                        this.handleValidate()
faisalhamdi's avatar
faisalhamdi committed
1513 1514 1515 1516 1517 1518 1519
                                                    }, 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>
d.arizona's avatar
d.arizona committed
1520 1521
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
faisalhamdi's avatar
faisalhamdi committed
1522 1523 1524 1525
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1526
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
1527 1528 1529 1530 1531
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
1532
                                                this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1533
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
1534
                                                    :
1535 1536
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
1537 1538 1539 1540 1541 1542 1543
                                                            this.backToMonthlyReport('draft')
                                                        })
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
                                            </div>
d.arizona's avatar
d.arizona committed
1544 1545
                                        </button>}
                                        {this.state.get_for == 'edit' && <button
faisalhamdi's avatar
faisalhamdi committed
1546
                                            type="button"
Riri Novita's avatar
Riri Novita committed
1547
                                            // disabled={this.state.buttonError}
faisalhamdi's avatar
faisalhamdi committed
1548 1549
                                            onClick={() =>
                                                this.state.buttonError ?
Riri Novita's avatar
Riri Novita committed
1550
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
1551
                                                    :
1552 1553
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1 }, () => {
faisalhamdi's avatar
faisalhamdi committed
1554 1555 1556 1557
                                                            this.backToMonthlyReport('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1558
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
1559 1560 1561 1562 1563 1564 1565
                                                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>
d.arizona's avatar
d.arizona committed
1566
                                        </button>}
Deni Rinaldi's avatar
Deni Rinaldi committed
1567
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
1568
                                }
faisalhamdi's avatar
faisalhamdi committed
1569 1570 1571 1572 1573 1574 1575
                            </div>
                        </Paper> :
                        <Paper style={{ paddingTop: 10 }}>
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Fixed Assets Movement</Typography>
                            </div>
                            <div style={{ padding: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
1576 1577
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
d.arizona's avatar
d.arizona committed
1578
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {String(this.props.month.month_value).toLocaleUpperCase()} {this.props.periode} (rev.{this.props.revision})</Typography>
faisalhamdi's avatar
faisalhamdi committed
1579 1580 1581
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                </div>
                                <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
faisalhamdi's avatar
faisalhamdi committed
1582
                                    {!this.state.refresh && (
faisalhamdi's avatar
faisalhamdi committed
1583 1584 1585 1586 1587 1588 1589 1590 1591
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={dataTable2}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
                                    )}
                                </div>
faisalhamdi's avatar
faisalhamdi committed
1592
                                <div className="grid grid-2x" style={{ marginTop: 20 }}>
faisalhamdi's avatar
faisalhamdi committed
1593
                                    <div className="col-1" style={{ paddingLeft: 0 }}>
faisalhamdi's avatar
faisalhamdi committed
1594 1595
                                        <button
                                            type="button"
faisalhamdi's avatar
faisalhamdi committed
1596
                                            onClick={() => this.setState({ loading: true, visibleFAMMR: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
1597
                                                setTimeout(() => {
rifkaki's avatar
rifkaki committed
1598
                                                    this.getItemHierarki()
faisalhamdi's avatar
faisalhamdi committed
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614
                                                }, 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>
                                    </div>
                                    {/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null :
                                        (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') ? */}
faisalhamdi's avatar
faisalhamdi committed
1615
                                    <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
faisalhamdi's avatar
faisalhamdi committed
1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628
                                        <button
                                            className="button"
                                            type="button"
                                            style={{
                                                backgroundColor: 'transparent',
                                                cursor: 'pointer',
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() => {
                                                this.setState({ loading: true }, () => {
                                                    setTimeout(() => {
faisalhamdi's avatar
faisalhamdi committed
1629 1630
                                                        // this.setState({ loading: false })
                                                        this.handleValidate()
faisalhamdi's avatar
faisalhamdi committed
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643
                                                    }, 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
1644
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
1645 1646 1647 1648 1649
                                                borderColor: 'transparent',
                                                outline: 'none',
                                                marginRight: 20
                                            }}
                                            onClick={() =>
faisalhamdi's avatar
faisalhamdi committed
1650
                                                this.state.saveDraft === true ?
Riri Novita's avatar
Riri Novita committed
1651
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
1652
                                                    :
1653 1654
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
1655 1656 1657 1658 1659
                                                            this.uploadFAMMR('draft')
                                                        })
                                            }
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
1660
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
faisalhamdi's avatar
faisalhamdi committed
1661 1662 1663 1664
                                            </div>
                                        </button>
                                        <button
                                            type="button"
faisalhamdi's avatar
faisalhamdi committed
1665
                                            // disabled={this.state.buttonError}
faisalhamdi's avatar
faisalhamdi committed
1666 1667
                                            onClick={() =>
                                                this.state.buttonError ?
Riri Novita's avatar
Riri Novita committed
1668
                                                    this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'error' })
faisalhamdi's avatar
faisalhamdi committed
1669
                                                    :
1670 1671
                                                    this.state.handleDoubleClick === 1 ? null :
                                                        this.setState({ handleDoubleClick: 1, loading: true }, () => {
faisalhamdi's avatar
faisalhamdi committed
1672 1673 1674 1675
                                                            this.uploadFAMMR('submitted')
                                                        })}
                                            style={{
                                                backgroundColor: 'transparent',
Riri Novita's avatar
Riri Novita committed
1676
                                                cursor: 'pointer',
faisalhamdi's avatar
faisalhamdi committed
1677 1678 1679 1680 1681
                                                borderColor: 'transparent',
                                                outline: 'none',
                                            }}
                                        >
                                            <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
d.arizona's avatar
d.arizona committed
1682
                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
faisalhamdi's avatar
faisalhamdi committed
1683 1684
                                            </div>
                                        </button>
Deni Rinaldi's avatar
Deni Rinaldi committed
1685
                                    </div>
faisalhamdi's avatar
faisalhamdi committed
1686 1687 1688 1689
                                </div>
                            </div>
                        </Paper>
                    }
faisalhamdi's avatar
faisalhamdi committed
1690
                </div>
faisalhamdi's avatar
faisalhamdi committed
1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719
                {this.state.visibleUpload && (
                    <div className="test app-popup-show">
                        <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
                            <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
                                <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
                                    <div className="popup-title">
                                        <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
                                    </div>
                                </div>
                                <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        className="btn btn-circle btn-white"
                                        onClick={() => this.setState({ visibleUpload: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
                                </div>
                            </div>
                            <UploadFile
                                type={this.state.uploadStatus}
                                percentage={this.state.percentage}
                                result={this.state.result}
                                acceptedFiles={["xlsx"]}
                                onHandle={(dt) => {
                                    this.fileHandler(dt)
                                    this.setState({ uploadStatus: 'idle', percentage: '0' })
                                }}
                                onUpload={() => {
rifkaki's avatar
rifkaki committed
1720
                                    String(this.state.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("FIXED") && String(this.state.judul).includes("ASSETS") && String(this.state.judul).includes("MOVEMENT") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") ?
faisalhamdi's avatar
faisalhamdi committed
1721 1722 1723 1724 1725 1726 1727
                                        this.checkUpload() :
                                        this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
                                }}
                            />
                        </div>
                    </div>
                )}
faisalhamdi's avatar
faisalhamdi committed
1728 1729 1730 1731
            </div>
        )
    }
}