MonthlyReport.js 205 KB
Newer Older
1
import React, { Component } from 'react';
d.arizona's avatar
d.arizona committed
2
import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel, Snackbar, withStyles, createMuiTheme, MuiThemeProvider, Checkbox, Input } from '@material-ui/core';
3
import MUIDataTable from 'mui-datatables';
syadziy's avatar
syadziy committed
4 5
import Images from '../../assets/Images';
import api from '../../api';
6
import Autocomplete from '@material-ui/lab/Autocomplete';
syadziy's avatar
syadziy committed
7
import { titleCase } from '../../library/Utils';
8
import { ExcelRenderer } from 'react-excel-renderer';
syadziy's avatar
syadziy committed
9
import UploadFile from "../../library/Upload";
10
import { format } from 'date-fns';
syadziy's avatar
syadziy committed
11 12 13 14 15
import BalanceSheetMR from './BalanceSheetMR';
import ProfitLossMR from './ProfitLossMR';
import TaxPlanningMR from './TaxPlanningMR';
import FixedAssetsMovementMR from './FixedAssetsMovementMR';
import ListOfCreditFacilities from './ListOfCreditFacilitiesMR'
Deni Rinaldi's avatar
Deni Rinaldi committed
16 17
import { PropagateLoader } from 'react-spinners';
import MuiAlert from '@material-ui/lab/Alert';
syadziy's avatar
syadziy committed
18 19 20 21
import Constant from '../../library/Constant';
import OperatingIndicatorMR from './OperatingIndicatorMR';
import CorporateAnnualTargetMR from './CorporateAnnualTargetMR';
import CashFlowMR from './CashFlowMR';
d.arizona's avatar
d.arizona committed
22 23
import { DatePicker } from '@material-ui/pickers';
import moment from 'moment';
24
import * as R from 'ramda'
qorri_di's avatar
qorri_di committed
25 26
import { PhotoSizeSelectLargeTwoTone, ThreeSixty } from '@material-ui/icons';
import { startTransition } from 'react';
Deni Rinaldi's avatar
Deni Rinaldi committed
27

syadziy's avatar
syadziy committed
28
var ct = require("../../library/CustomTable");
qorri_di's avatar
qorri_di committed
29
const getMuiTheme = () => createMuiTheme(ct.customTable6());
Deni Rinaldi's avatar
Deni Rinaldi committed
30 31 32

const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
33

qorri_di's avatar
qorri_di committed
34 35 36 37 38 39 40 41 42 43
const CustomCheckbox = withStyles({
    root: {
        color: '#5198ea',
        '&$checked': {
            color: '#5198ea',
        },
    },
    checked: {},
})((props) => <Checkbox color="default" {...props} />);

44 45 46 47 48
export default class MonthlyReport extends Component {
    constructor(props) {
        super(props)
        this.state = {
            perusahaan: 'TAP Group',
49 50 51
            listRevision: null,
            revision: null,
            visibleMonthlyReport: true,
52
            visibleBS: false,
53 54
            listPeriode: null,
            periode: null,
Deni Rinaldi's avatar
Deni Rinaldi committed
55 56
            listMonth: null,
            month: null,
57 58 59 60 61
            listCompany: null,
            company: null,
            report_id: null,
            visiblePL: false,
            visibleFAM: false,
62
            visibleCAT: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
63
            visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
64
            visibleCF: false,
65
            listAttachment: [],
Deni Rinaldi's avatar
Deni Rinaldi committed
66
            visibleUpload: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
67 68 69 70 71
            lastRevision: 0,
            loading: false,
            alert: false,
            tipeAlert: '',
            messageAlert: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
72
            btnCreate: false,
d.arizona's avatar
d.arizona committed
73 74 75 76
            loadview: false,
            submittedOnly: false,
            company_active: null,
            company_submit: null,
d.arizona's avatar
d.arizona committed
77 78
            still_approver: false,
            status: '',
d.arizona's avatar
d.arizona committed
79 80 81
            lastStatus: '',
            approverTrue: false,
            listStatus: [],
d.arizona's avatar
d.arizona committed
82
            selectedStatus: [],
Arfin Syadziy's avatar
Arfin Syadziy committed
83
            detailRevisiCheck: [],
d.arizona's avatar
d.arizona committed
84
            isApprovedMB: false,
d.arizona's avatar
d.arizona committed
85
            textRevision: '',
d.arizona's avatar
d.arizona committed
86
            dbCF: [],
d.arizona's avatar
d.arizona committed
87
            dbPL: [],
d.arizona's avatar
d.arizona committed
88
            PLBSFAMSubmitted: false,
d.arizona's avatar
d.arizona committed
89
            PLID: null,
90 91
            monthHome: null,
            listApprover: null,
d.arizona's avatar
d.arizona committed
92
            approver: null,
qorri_di's avatar
qorri_di committed
93 94 95 96 97
            isAdmin: false,
            selectReport: [],
            isCheckAll: false,
            downloadedFileReportId: null,
            arrayReport: [],
Riri Novita's avatar
Riri Novita committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
            popupDownload: false,
            defaultCurrency: null,
            dataCurrency: [],
            currency: [],
            visibleAlertSave: false,
            dataCurrency: [
                {
                    "id": 1,
                    "value": "IDR"
                },
                {
                    "id": 2,
                    "value": "USD",
                }
            ]
113
        }
d.arizona's avatar
d.arizona committed
114
        this.myRef = React.createRef()
115
        this.fileHandler = this.fileHandler.bind(this);
116 117
    }

d.arizona's avatar
d.arizona committed
118 119
    scrollToMyRef = () => window.scrollTo(0, this.myRef.current.offsetTop)

r.kurnia's avatar
r.kurnia committed
120 121 122 123 124 125 126 127 128
    getPermission() {
        let payload = {
            menu: "monthly report"
        }
        api.create().getPermission(payload).then(response => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
129 130 131 132
                        btnCreate: response.data.data.create,
                        btnEdit: response.data.data.edit
                    }, () => {
                        this.getChecApprover()
r.kurnia's avatar
r.kurnia committed
133 134 135
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
136
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
r.kurnia's avatar
r.kurnia committed
137 138 139 140 141 142 143 144 145 146 147 148 149
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

150
    componentDidMount() {
d.arizona's avatar
d.arizona committed
151
        // this.getPermission()
Deni Rinaldi's avatar
Deni Rinaldi committed
152
        this.setState({ loading: true })
d.arizona's avatar
d.arizona committed
153 154
        this.props.selectIndex('Monthly Report')
        if (this.props.location.state !== undefined) {
d.arizona's avatar
d.arizona committed
155 156
            console.log(this.props);
            if (this.props.location.state.month != null || this.props.location.state.month != undefined) {
157
                this.setState({ monthHome: this.props.location.state.month })
d.arizona's avatar
d.arizona committed
158
            }
159
            this.setState({ userType: this.props.location.state.userType, intent: 'Home', lastPeriod: this.props.location.state.rawData.periode, rawData: this.props.location.state.rawData }, () => {
d.arizona's avatar
d.arizona committed
160 161 162 163 164 165
                this.getPermission()
            })
        } else {
            this.getPermission()
        }
        // console.log(this.props)
Deni Rinaldi's avatar
Deni Rinaldi committed
166
        // this.getCompanyActive()
d.arizona's avatar
d.arizona committed
167
        // this.getCompanySubmitted()
d.arizona's avatar
d.arizona committed
168
        // console.log(a)
Deni Rinaldi's avatar
Deni Rinaldi committed
169 170 171
    }

    getChecApprover() {
d.arizona's avatar
d.arizona committed
172
        let listStatus1 = [
173 174 175
            { name: 'Open', value: 'not-yet' },
            { name: 'Submitted', value: 'approval_review' },
            { name: 'Waiting for Review / Approval', value: 'approval_proccess' },
d.arizona's avatar
d.arizona committed
176 177
            // {name: 'Waiting for Approval', value: 'approval_proccess'},
            // {name: 'Revision', value: 'revision'},
178
            { name: 'Approved', value: 'approved' },
d.arizona's avatar
d.arizona committed
179 180 181
        ]

        let listStatus2 = [
182 183
            { name: 'Open', value: 'not-yet' },
            { name: 'Submitted', value: 'approval_review' },
d.arizona's avatar
d.arizona committed
184
            // {name: 'Revision', value: 'revision'},
185
            { name: 'Approved', value: 'approved' },
d.arizona's avatar
d.arizona committed
186 187
        ]

Deni Rinaldi's avatar
Deni Rinaldi committed
188 189 190 191
        api.create().checkApproverMonthly().then(response => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
Deni Rinaldi's avatar
Deni Rinaldi committed
192
                    if (response.data.data.is_approver === true) {
193 194 195 196 197 198 199
                        this.setState({ isApprover: true, checkApprover: true, still_approver: true, approverTrue: true, listStatus: listStatus1, selectedStatus: listStatus1 }, () => {
                            // if (this.state.submittedOnly) {
                            this.getMonth()
                            // } else {
                            //     this.getCompanyActive()
                            // }
                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
200
                    } else {
201
                        this.setState({ isApprover: false, checkApprover: false, still_approver: false, approverTrue: false, listStatus: listStatus2, selectedStatus: listStatus2 }, () =>
d.arizona's avatar
d.arizona committed
202
                            this.getMonth())
203
                        // this.getCompanyActive())
Deni Rinaldi's avatar
Deni Rinaldi committed
204
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
205 206
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
207
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
208 209 210 211 212 213 214 215 216 217 218
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
219
    }
220

221 222 223 224 225
    getReportAttachment() {
        let payload = {
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
            "revision": this.state.revision.revision,
Deni Rinaldi's avatar
Deni Rinaldi committed
226
            "months": this.state.month.month_id
227
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
228
        api.create().getMontlyReportAtt(payload).then(response => {
229 230 231
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({ listAttachment: response.data.data })
Deni Rinaldi's avatar
Deni Rinaldi committed
232 233
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
234
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
235 236 237 238 239 240
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
241
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
242 243
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
244 245
            }
        })
246 247 248 249 250
    }

    getReport() {
        let payload = {
            "company_id": this.state.company.company_id,
251
            "periode": this.state.periode.periode,
252
            "report_type": "Monthly Report",
faisalhamdi's avatar
faisalhamdi committed
253
            "months": this.state.month.month_id,
Riri Novita's avatar
Riri Novita committed
254
            "currency_id": this.state.defaultCurrency.id
255
        }
faisalhamdi's avatar
faisalhamdi committed
256
        api.create().getMonthlyReport(payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
257
            console.log(response);
258 259 260
            if (response.data) {
                if (response.data.status === "success") {
                    let dataTable = response.data.data.map((item, index) => {
d.arizona's avatar
d.arizona committed
261 262 263
                        let indexC = String(item.current_status).toLocaleUpperCase().indexOf('C')
                        let status_approv = ''
                        if (String(item.current_status).toLocaleUpperCase().includes('CC')) {
264
                            status_approv = `${String(item.current_status).substr(0, indexC)}${String(item.current_status).substr(indexC + 1, String(item.current_status).length)}`
d.arizona's avatar
d.arizona committed
265 266 267
                        } else {
                            status_approv = String(item.current_status)
                        }
268
                        return [
269
                            item.number,
270
                            item.report_name == "CAT" ? "Corporate Annual Target" : item.report_name,
271
                            item.revision,
d.arizona's avatar
d.arizona committed
272
                            this.state.isApprovedMB ? (this.state.lastStatus === 'APPROVED' ? 'CLOSED' : this.state.isSubmit === false ? "CLOSED" : status_approv) : "CLOSED",
273
                            item.report_id,
d.arizona's avatar
d.arizona committed
274 275
                            // item.is_can_upload,
                            item.report_name === "Cash Flow" ? item.is_can_upload : (Number(item.revision) > 0 ? (item.current_status == "not-yet" ? false : item.is_can_upload) : item.is_can_upload),
276
                            item.revision
277 278
                        ]
                    })
d.arizona's avatar
d.arizona committed
279 280 281 282 283 284 285 286 287 288 289 290

                    let dataTableRevision = []
                    response.data.data.map((item, index) => {
                        if (item.report_name !== 'Cash Flow') {
                            dataTableRevision.push([
                                item.report_id,
                                item.report_name === 'CAT' ? 'Corporate Annual Target' : item.report_name,
                                "",
                                item.number
                            ])
                        }
                    })
291
                    // console.log(dataTable);
292
                    this.setState({ dataTable, dataTableRevision: dataTableRevision.sort((a, b) => a.number - b.number), dataForRevision: response.data.data })
Deni Rinaldi's avatar
Deni Rinaldi committed
293 294
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
295
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
296 297 298 299 300 301
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
302
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
303
            } else {
Riri Novita's avatar
Riri Novita committed
304
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
305 306 307 308 309 310
            }
        })
    }

    getCompanyActive() {
        api.create().getPerusahaanActive().then((response) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
311 312 313 314 315 316 317 318 319 320 321 322 323
            if (response.data) {
                if (response.data.status === 'success') {
                    let data = response.data.data
                    let companyData = data.map((item) => {
                        return {
                            company_id: item.company_id,
                            company_name: item.company_name,
                        }
                    })
                    let defaultProps = {
                        options: companyData,
                        getOptionLabel: (option) => titleCase(option.company_name),
                    };
324
                    this.setState({ listCompany: defaultProps, company: companyData[0], company_active: defaultProps }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
325
                        this.getMonth()
Riri Novita's avatar
Riri Novita committed
326
                        this.getCurrency(this.state.company.company_id)
d.arizona's avatar
d.arizona committed
327
                        // console.log(this.state.company_active)
Deni Rinaldi's avatar
Deni Rinaldi committed
328 329 330
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
331
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
332 333 334 335 336 337 338
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
339
            } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
340
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
341 342 343 344
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
345
    getMonth() {
Deni Rinaldi's avatar
Deni Rinaldi committed
346
        api.create().getMonthTransaction().then(response => {
d.arizona's avatar
d.arizona committed
347 348
            let dateNow = new Date()
            dateNow.setMonth(dateNow.getMonth() - 1);
Deni Rinaldi's avatar
Deni Rinaldi committed
349 350 351 352 353 354 355 356 357
            let month = format(dateNow, 'MMMM')
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
                    console.log(response);
                    let data = response.data.data
                    let monthData = data.map((item) => {
                        return {
                            month_id: item.id,
Deni Rinaldi's avatar
Deni Rinaldi committed
358
                            month_value: String(item.month_name).substr(0, 3)
Deni Rinaldi's avatar
Deni Rinaldi committed
359 360 361 362 363 364
                        }
                    })
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_value,
                    };
Riri Novita's avatar
Riri Novita committed
365
                    let index = data.findIndex((val) => val.month_name == month)
Deni Rinaldi's avatar
Deni Rinaldi committed
366
                    console.log(index);
d.arizona's avatar
d.arizona committed
367 368 369 370 371
                    let indexMonthHome = -1
                    if (this.state.monthHome != null) {
                        indexMonthHome = monthData.findIndex((val) => val.month_id == this.state.monthHome.month_id)
                    }
                    console.log(indexMonthHome)
372
                    this.setState({ listMonth: defaultProps, month: indexMonthHome == -1 ? (index == -1 ? monthData[0] : monthData[index]) : monthData[indexMonthHome] }, () => {
d.arizona's avatar
d.arizona committed
373 374 375 376 377 378 379 380
                        // if (this.state.isApprover === true) {
                        //     if (this.state.submittedOnly) {
                        //         console.log('masuk cuk')
                        //         this.getPeriode()
                        //     } else {
                        //         this.getLastPeriod()
                        //     }
                        // } else {
381 382
                        // this.getLastPeriod()
                        this.getPeriode()
d.arizona's avatar
d.arizona committed
383
                        // }
Deni Rinaldi's avatar
Deni Rinaldi committed
384
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
385 386
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
387
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
388 389 390 391 392 393
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
394
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
395 396
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
397 398 399 400
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
401 402 403 404 405 406 407 408 409 410 411
    getLastPeriod() {
        api.create().getLastPeriodMonthly(this.state.company.company_id).then(response => {
            console.log(response);
            if (response.data.status === "success") {
                this.setState({ lastPeriod: response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => {
                    this.getPeriode()
                })
            }
        })
    }

412 413
    getPeriode() {
        api.create().getPeriodeTransaction().then(response => {
d.arizona's avatar
d.arizona committed
414
            console.log(response)
Deni Rinaldi's avatar
Deni Rinaldi committed
415
            let currentYear = new Date().getFullYear()
416 417
            if (response.data) {
                if (response.data.status === "success") {
Deni Rinaldi's avatar
Deni Rinaldi committed
418 419 420
                    let data = []
                    response.data.data.map((item) => {
                        if (this.state.isApprover) {
Arfin Syadziy's avatar
Arfin Syadziy committed
421
                            if (item >= 2000 && item <= (Number(currentYear))) {
Deni Rinaldi's avatar
Deni Rinaldi committed
422 423 424
                                data.push(item)
                            }
                        } else {
d.arizona's avatar
d.arizona committed
425 426 427
                            // if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
                            //     data.push(item)
                            // }
Arfin Syadziy's avatar
Arfin Syadziy committed
428
                            if ((item >= 2000) && (item == currentYear || item <= currentYear)) {
Deni Rinaldi's avatar
Deni Rinaldi committed
429 430 431 432
                                data.push(item)
                            }
                        }
                    })
433 434 435 436 437 438 439 440 441
                    let periodeData = data.map((item) => {
                        return {
                            periode: item,
                        }
                    })
                    let defaultProps = {
                        options: periodeData,
                        getOptionLabel: (option) => option.periode,
                    };
d.arizona's avatar
d.arizona committed
442
                    let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod === undefined ? String(Number(currentYear)) : this.state.lastPeriod)
d.arizona's avatar
d.arizona committed
443 444 445 446 447 448
                    let dateNow = new Date()
                    dateNow.setMonth(dateNow.getMonth() - 1);
                    let yearNow = dateNow.getFullYear()
                    // let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
                    // console.log(yearNow)
                    let index = data.sort((a, b) => a - b).findIndex((val) => val == yearNow)
Deni Rinaldi's avatar
Deni Rinaldi committed
449
                    // console.log(data)
d.arizona's avatar
d.arizona committed
450
                    // console.log(this.state.lastPeriod)
Deni Rinaldi's avatar
Deni Rinaldi committed
451
                    // console.log(periodeData)
d.arizona's avatar
d.arizona committed
452
                    // console.log(index)
Deni Rinaldi's avatar
Deni Rinaldi committed
453
                    this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
d.arizona's avatar
d.arizona committed
454
                        // if (this.state.isApprover === true && this.state.submittedOnly) {
455 456
                        this.getDetailUser()
                        // this.getCompanySubmitted()
d.arizona's avatar
d.arizona committed
457 458
                        //     console.log('masuk')
                        // } else {
459
                        // this.getRevision()
d.arizona's avatar
d.arizona committed
460
                        // }
461
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
462 463
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
464
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
465 466 467 468 469 470
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
471
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
472 473
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
474 475 476 477
            }
        })
    }

Riri Novita's avatar
Riri Novita committed
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 509 510 511 512 513 514 515 516 517 518 519 520 521 522
    getCurrency(companyID) {
        console.log(companyID);
        api.create().getDetailPerusahaan(companyID).then(response => {
            console.log(response);
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === "success") {
                        let data = response.data.data
                        let datas = []
                        if (response.data.data.currency.length > 0) {
                            response.data.data.currency.map((item) => {
                                // console.log(item);
                                datas.push({
                                    id: item.currencyId,
                                    value: item.currencyName
                                })

                            })
                        }
                        let index = datas.findIndex((val) => val.id == response.data.data.default_currency)
                        this.setState({
                            defaultCurrencyID: response.data.data.default_currency,
                            currency: datas,
                            defaultCurrency: index == -1 ? null : datas[index]
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }

        })
    }

d.arizona's avatar
d.arizona committed
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
    getDetailUser() {
        let userId = localStorage.getItem(Constant.USER)
        api.create().getDetailUser(userId).then((response) => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        this.getRole(response.data.data.role_id)
                        this.setState({ userCompany: response.data.data.company }, () => {
                            this.getCompanySubmitted()
                        })
                    }
                }
            }
        })
    }

    getRole(id) {
        api.create().getDetailRole(id).then((response) => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        // this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
                        // // // console.log(response.data.data)
                        if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') {
                            this.setState({ isAdmin: true })
                        }
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
551
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
568
    getCompanySubmitted() {
d.arizona's avatar
d.arizona committed
569 570 571
        let selectedStatus = this.state.selectedStatus.map((item) => {
            return item.value
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
572
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
573 574
            "periode": this.state.periode.periode,
            "months": this.state.month.month_id,
d.arizona's avatar
d.arizona committed
575
            "status": selectedStatus
Deni Rinaldi's avatar
Deni Rinaldi committed
576
        }
d.arizona's avatar
d.arizona committed
577
        // this.setState({ isApprovedMB: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
578
        api.create().getCompanySubmittedMonthly(body).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
579
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
580 581 582 583 584 585 586 587 588 589 590
            if (response.data) {
                if (response.data.status === 'success') {
                    if (response.data.data.length > 0) {
                        let data = response.data.data
                        let companyData = data.map((item) => {
                            return {
                                company_id: item.company_id,
                                company_name: item.company_name,
                            }
                        })

d.arizona's avatar
d.arizona committed
591 592 593 594 595 596 597 598 599
                        let arrayBaru = []
                        this.state.userCompany.map((item, index) => {
                            let indexID = companyData.findIndex((val) => val.company_id == item)
                            if (indexID !== -1) {
                                arrayBaru.push(companyData[indexID])
                            }
                        })

                        if (arrayBaru.length > 0) {
600
                            arrayBaru = arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name))
d.arizona's avatar
d.arizona committed
601
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
602
                        let defaultProps = {
d.arizona's avatar
d.arizona committed
603
                            options: arrayBaru,
Deni Rinaldi's avatar
Deni Rinaldi committed
604 605 606 607
                            getOptionLabel: (option) => titleCase(option.company_name),
                        }
                        let indexID = null
                        if (this.state.rawData !== undefined) {
d.arizona's avatar
d.arizona committed
608
                            indexID = arrayBaru.findIndex((val) => val.company_id == this.state.rawData.company_id)
Deni Rinaldi's avatar
Deni Rinaldi committed
609
                        }
d.arizona's avatar
d.arizona committed
610
                        // console.log(response.data.data.length)
d.arizona's avatar
d.arizona committed
611
                        this.setState({ listCompany: defaultProps, company: indexID == null ? arrayBaru[0] : arrayBaru[indexID], company_submit: defaultProps }, () => {
Riri Novita's avatar
Riri Novita committed
612
                            console.log(this.state.company)
Deni Rinaldi's avatar
Deni Rinaldi committed
613 614
                            if (response.data.data.length > 0) {
                                this.getRevision()
Riri Novita's avatar
Riri Novita committed
615
                                this.getCurrency(this.state.company.company_id)
Deni Rinaldi's avatar
Deni Rinaldi committed
616
                            } else {
d.arizona's avatar
d.arizona committed
617 618
                                // console.log(this.state.listCompany)
                                // console.log(this.state.company_submit)
d.arizona's avatar
d.arizona committed
619
                                this.setState({ listRevision: null, revision: null, dataTable: [], lastRevision: "", visibleTableHistory: false })
Deni Rinaldi's avatar
Deni Rinaldi committed
620 621 622 623
                            }
                            //
                        })
                    } else {
d.arizona's avatar
d.arizona committed
624
                        this.setState({ listRevision: null, revision: null, listCompany: null, company: null, dataTable: [], lastRevision: "", visibleTableHistory: false, loading: false }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
625 626 627 628 629
                            document.body.style.overflow = 'unset';
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
630
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
631 632 633 634 635 636 637 638 639 640 641 642 643
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null })
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
644 645
    onClickClose() {
        this.setState({})
Deni Rinaldi's avatar
Deni Rinaldi committed
646 647
    }

648
    getRevision() {
qorri_di's avatar
qorri_di 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 678 679 680
        this.setState({ selectReport: [], isCheckAll: false }, () => {
            let payload = {
                "company_id": this.state.company.company_id,
                "periode": this.state.periode.periode
            }
            api.create().getRevision(payload).then(response => {
                console.log(response);
                if (response.data) {
                    if (response.data.status === "success") {
                        let data = response.data.data
                        let revisionData = data.map((item) => {
                            return {
                                revision: item,
                            }
                        })
                        let defaultProps = {
                            options: revisionData,
                            getOptionLabel: (option) => option.revision,
                        };
                        this.setState({ listRevision: defaultProps, revision: revisionData[0] }, () => {
                            this.getMonthlyReportID()
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
681
                } else {
qorri_di's avatar
qorri_di committed
682
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
683
                }
qorri_di's avatar
qorri_di committed
684
            })
685 686 687
        })
    }

688
    getMonthlyReportID(type) {
qorri_di's avatar
qorri_di committed
689 690 691 692 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 725 726 727 728 729
        this.setState({ selectReport: [], isCheckAll: false }, () => {
            let payload = {
                "company_id": this.state.company.company_id,
                "periode": this.state.periode.periode,
                "months": this.state.month.month_id,
                "is_approver": this.state.isAdmin && this.state.lastStatus == 'WAITING FOR APPROVAL' ? false : this.state.isApprover
            }
            this.setState({ visibleTableHistory: false })
            api.create().getMonthlyReportID(payload).then(response => {
                console.log(response);
                if (response.data) {
                    if (response.data.status === 'success') {
                        this.setState({
                            submitter: response.data.data.submitter,
                            approverID: response.data.data.approve_id, pic: response.data.data.approver == null ? '' : response.data.data.approver,
                            lastStatus: response.data.data.last_status === null ? 'SUBMIT' : response.data.data.last_status,
                            lastRevision: response.data.data.last_revision,
                            btnApprove: response.data.data.is_submit,
                            monthlyReportId: response.data.data ? response.data.data.monthly_report_id : null,
                            isApprovedMB: response.data.data.is_approved_master_budget,
                            textRevision: response.data.data.text_revision
                        }, () => {
                            // // console.log(this.state.lastStatus);
                            this.historyApproval()
                            this.getLatestPeriodSubmit()
                            if (this.state.isAdmin) {
                                console.log('masuk')
                                api.create().getListApprover('monthly_report', this.state.monthlyReportId).then((response) => {
                                    console.log(response)
                                    if (response.data.data) {
                                        let dataListApprover = []
                                        response.data.data.map((item, index) => {
                                            dataListApprover.push({ userId: item.user_id, fullname: item.fullname })
                                        })
                                        let defaultProps = {
                                            options: dataListApprover,
                                            getOptionLabel: (option) => option.fullname,
                                        };
                                        this.setState({ listApprover: defaultProps })
                                    }
                                })
730
                            }
qorri_di's avatar
qorri_di committed
731 732
                            // this.getPL(type)
                            if (type != undefined && type == 'PL') {
733
                                this.getPL(type)
qorri_di's avatar
qorri_di committed
734 735 736 737 738 739
                            } else if (type != undefined && type == 'LOCF') {
                                let bodyRatioLocf = {
                                    "report": 'ratio',
                                    "monthlyReportId": this.state.monthlyReportId,
                                    "periode": this.state.periode.periode,
                                    "companyId": this.state.company.company_id,
Riri Novita's avatar
Riri Novita committed
740 741
                                    "months": this.state.month.month_id,
                                    "currency_id": this.state.defaultCurrency.id
qorri_di's avatar
qorri_di committed
742
                                }
743 744 745 746
                                api.create().triggerHistoricalRatio(bodyRatioLocf).then((res) => {
                                    console.log(res)
                                    this.setState({ loading: false })
                                })
qorri_di's avatar
qorri_di committed
747 748 749 750 751 752
                            } else if (type != undefined && type == 'BS') {
                                let bodyRatioBs = {
                                    "report": 'ratio',
                                    "monthlyReportId": this.state.monthlyReportId,
                                    "periode": this.state.periode.periode,
                                    "companyId": this.state.company.company_id,
Riri Novita's avatar
Riri Novita committed
753 754
                                    "months": this.state.month.month_id,
                                    "currency_id": this.state.defaultCurrency.id
qorri_di's avatar
qorri_di committed
755
                                }
756 757 758 759
                                api.create().triggerRatioFromLOCF(bodyRatioBs).then((res) => {
                                    console.log(res)
                                    this.setState({ loading: false })
                                })
qorri_di's avatar
qorri_di committed
760
                            } else {
761
                                this.setState({ loading: false })
Faisal Hamdi's avatar
Faisal Hamdi committed
762
                            }
qorri_di's avatar
qorri_di committed
763 764 765 766 767 768 769 770 771 772 773 774
                            // this.getFR(type)
                            // this.getReport()
                            // this.getReportAttachment()
                            api.create().checkApproverMonthly().then(response => {
                                console.log(response)
                                if (this.state.btnCreate === true && this.state.btnEdit === true) {
                                    console.log('editable');
                                    this.setState({ isApprover: this.state.approverTrue ? true : false, checkApprover: this.state.approverTrue ? true : false })
                                } else {
                                    console.log('just view');
                                    this.setState({ isApprover: true, checkApprover: true })
                                }
Faisal Hamdi's avatar
Faisal Hamdi committed
775
                            })
qorri_di's avatar
qorri_di committed
776 777 778 779 780 781 782 783
                        })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
Deni Rinaldi's avatar
Deni Rinaldi committed
784 785
                            }
                        })
qorri_di's avatar
qorri_di committed
786
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
787
                } else {
qorri_di's avatar
qorri_di committed
788
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
789
                }
qorri_di's avatar
qorri_di committed
790
            })
Deni Rinaldi's avatar
Deni Rinaldi committed
791
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
792 793
    }

d.arizona's avatar
d.arizona committed
794 795 796 797
    getLatestPeriodSubmit() {
        let body = {
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
798
            "months": this.state.month.month_id
d.arizona's avatar
d.arizona committed
799 800 801 802 803 804 805 806 807 808 809 810 811 812
        }
        api.create().getSubmitMonthlyReport(body).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({ isSubmit: response.data.data.is_can_submit }, () => {
                        this.getReport()
                        this.getReportAttachment()
                    })
                }
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
813 814 815 816 817 818 819 820 821 822 823
    historyApproval() {
        let body = {
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
            "months": this.state.month.month_id
        }
        api.create().historyApprovalMonthly(body).then(response => {
            console.log(response);
            if (response.data.data) {
                if (response.data.data.length > 0) {
                    let dataTableHistory = response.data.data.map(item => {
d.arizona's avatar
d.arizona committed
824 825 826
                        let indexC = String(item.status_approval).toLocaleUpperCase().indexOf('C')
                        let status_approv = ''
                        if (String(item.status_approval).toLocaleUpperCase().includes('CC')) {
827
                            status_approv = `${String(item.status_approval).substr(0, indexC)}${String(item.status_approval).substr(indexC + 1, String(item.status_approval).length)}`
d.arizona's avatar
d.arizona committed
828 829 830
                        } else {
                            status_approv = String(item.status_approval)
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
831 832
                        return [
                            item.pic,
d.arizona's avatar
d.arizona committed
833
                            status_approv,
Deni Rinaldi's avatar
Deni Rinaldi committed
834 835 836 837 838 839 840 841 842 843 844
                            item.remarks,
                            item.item_revision,
                            item.history_approval_date
                        ]
                    })
                    this.setState({ dataTableHistory, visibleTableHistory: true })
                }
            }
        })
    }

845
    saveToMonthlyReport(type) {
Deni Rinaldi's avatar
Deni Rinaldi committed
846 847
        this.setState({
            visibleMonthlyReport: true,
d.arizona's avatar
d.arizona committed
848
            loading: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
849 850 851
            visibleBS: false,
            visiblePL: false,
            visibleCAT: false,
d.arizona's avatar
d.arizona committed
852
            visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
853 854 855 856
            visibleFAM: false,
            visibleTP: false,
            visibleLOCF: false,
            visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
857
        }, () => {
858
            this.getMonthlyReportID(type)
Deni Rinaldi's avatar
Deni Rinaldi committed
859 860 861
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
862
    clickDetail(item, id, revision, status) {
d.arizona's avatar
d.arizona committed
863 864 865
        console.log(this.state.dataForRevision)
        console.log(item)
        console.log(revision)
d.arizona's avatar
d.arizona committed
866
        console.log(item)
d.arizona's avatar
d.arizona committed
867
        let items = ''
d.arizona's avatar
d.arizona committed
868
        let PLBSFAMSubmitted = 0
d.arizona's avatar
d.arizona committed
869 870 871 872 873 874 875
        if (item === 'Corporate Annual Target') {
            items = 'CAT'
        } else {
            items = item
        }
        this.state.dataForRevision.map(i => {
            if (i.report_name === items) {
d.arizona's avatar
d.arizona committed
876
                if (i.revision == revision) {
d.arizona's avatar
d.arizona committed
877 878 879 880 881
                    this.setState({ prevRevision: true })
                } else {
                    this.setState({ prevRevision: false })
                }
            }
882
            if (String(i.report_name).toLocaleLowerCase() == "profit loss" || String(i.report_name).toLocaleLowerCase() == "balance sheet" || String(i.report_name).toLocaleLowerCase() == "fixed assets movement") {
d.arizona's avatar
d.arizona committed
883 884 885 886
                if (String(i.current_status).toLocaleLowerCase() == "submitted") {
                    PLBSFAMSubmitted += 1
                }
            }
d.arizona's avatar
d.arizona committed
887
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
888 889 890 891 892
        this.setState({
            report_id: id,
            revisionTable: revision,
            status: status
        }, () => {
d.arizona's avatar
d.arizona committed
893
            console.log(status)
d.arizona's avatar
d.arizona committed
894
            console.log(this.state.prevRevision)
Deni Rinaldi's avatar
Deni Rinaldi committed
895 896 897 898 899 900 901 902
            if (item === 'Balance Sheet') {
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: true,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleFAM: false,
                    visibleTP: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
903
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
904
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
905
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
906
                })
d.arizona's avatar
d.arizona committed
907
            } else if (item === 'Profit Loss') {
Deni Rinaldi's avatar
Deni Rinaldi committed
908 909 910 911 912 913
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: true,
                    visibleCAT: false,
                    visibleFAM: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
914 915
                    visibleTP: false,
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
916
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
917
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
918 919 920 921 922 923 924 925
                })
            } else if (item === 'Tax Planning') {
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleFAM: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
926 927
                    visibleTP: true,
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
928
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
929
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
930 931 932 933 934 935 936 937
                })
            } else if (item === 'Fixed Assets Movement') {
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleFAM: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
938 939
                    visibleTP: false,
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
940
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
941
                })
d.arizona's avatar
d.arizona committed
942
            } else if (item === 'Corporate Annual Target') {
Deni Rinaldi's avatar
Deni Rinaldi committed
943 944 945 946 947 948
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: true,
                    visibleFAM: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
949 950
                    visibleTP: false,
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
951
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
952
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
953
                })
Riri Novita's avatar
Riri Novita committed
954
            } else if (item === 'List Of Credit Facilities and Investment') {
Deni Rinaldi's avatar
Deni Rinaldi committed
955 956 957 958 959 960 961 962
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleFAM: false,
                    visibleTP: false,
                    visibleLOCF: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
963
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
964
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
965 966 967 968 969 970 971 972 973 974 975
                })
            } else if (item === 'Operating Indicator') {
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleFAM: false,
                    visibleTP: false,
                    visibleLOCF: false,
                    visibleOI: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
976 977 978 979 980 981 982 983 984 985 986 987 988
                    visibleCF: false,
                })
            } else if (item === 'Cash Flow') {
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleFAM: false,
                    visibleTP: false,
                    visibleLOCF: false,
                    visibleOI: false,
                    visibleCF: true,
989
                    PLBSFAMSubmitted: PLBSFAMSubmitted == 3 ? true : false
Deni Rinaldi's avatar
Deni Rinaldi committed
990
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
991 992
            }
        })
993 994
    }

995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
    handleChange(value, tableMeta) {
        let data = this.state.dataTable
        data[tableMeta.rowIndex][tableMeta.columnIndex] = value
    }

    fileHandler = (event) => {
        let fileObj = event
        ExcelRenderer(fileObj, (err, resp) => {
            // console.log(resp)
            if (err) {
                console.log(err);
            }
            else {
                const formData = new FormData();
Deni Rinaldi's avatar
Deni Rinaldi committed
1009
                formData.append("revision", Number(this.state.lastRevision));
1010 1011 1012
                formData.append("companyId", this.state.company.company_id);
                formData.append("periode", Number(this.state.periode.periode));
                formData.append("file", event);
Deni Rinaldi's avatar
Deni Rinaldi committed
1013
                formData.append("months", this.state.month.month_id)
1014 1015 1016 1017 1018 1019
                this.setState({ formData })
            }
        })
    }

    uploadAttachment(formData) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1020 1021
        api.create().uploadAttachmentMonthly(formData).then(response => {
            console.log(response);
1022 1023 1024 1025 1026 1027
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({ visibleUpload: false }, () => {
                        this.getReport()
                        this.getReportAttachment()
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
1028 1029
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
1030
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
Deni Rinaldi's avatar
Deni Rinaldi committed
1031 1032 1033 1034 1035 1036
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
1037
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
1038
            } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
1039
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
1040 1041 1042 1043
            }
            // console.log(response)
        })
    }
1044

Deni Rinaldi's avatar
Deni Rinaldi committed
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
    deleteAttachment(item) {
        api.create().deleteAttachmentMonthly(item.attachment_id).then(response => {
            // // console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
                    this.getMonthlyReportID()
                }
            }
        })
    }

    async downloadAttachment(fileurl, name) {
        let length = name.split(".").length
        let fileType = name.split(".")[length - 1]
        // // console.log(fileType);
faisalhamdi's avatar
faisalhamdi committed
1060
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/monthly_report/download_attachment?fileName=${fileurl}&&fileType=${fileType}`
Deni Rinaldi's avatar
Deni Rinaldi committed
1061 1062
        // // console.log(url);
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
1063
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/monthly_report/download_attachment?fileName=${fileurl}&&fileType=${fileType}`
Deni Rinaldi's avatar
Deni Rinaldi committed
1064 1065
        )
        res = await res.blob()
Deni Rinaldi's avatar
Deni Rinaldi committed
1066
        this.setState({ loading: false }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077
            document.body.style.overflow = 'unset';
        })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = 'Monthly Report Attachment.xlsx';
            a.click();
        }
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
1078 1079 1080 1081
    closeAlert() {
        this.setState({ alert: false })
    }

d.arizona's avatar
d.arizona committed
1082 1083

    validate() {
d.arizona's avatar
d.arizona committed
1084 1085
        this.setState({ loading: true, selectedStatus: this.state.listStatus }, () => {
            // document.body.style.overflow = 'hidden';
d.arizona's avatar
d.arizona committed
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
        })
        let array = []
        let canSubmit = true
        this.state.dataTable.map(item => {
            // if (item[1] !== 'Cash Flow') {
            if (item[3] !== "submitted" && item[3] !== 'approved') {
                canSubmit = false
                array.push(item[3])
            }
            // }
            // if (item[3].includes("not-yet") || item[3].includes("draft")) {
            //     array.push(item[3])
            // } else {
            //     array.push(item[3])
            // }
        })
        if (canSubmit === true) {
            let body = {
d.arizona's avatar
d.arizona committed
1104
                monthly_report_id: this.state.monthlyReportId
d.arizona's avatar
d.arizona committed
1105
            }
d.arizona's avatar
d.arizona committed
1106 1107
            api.create().submitMonthlyReport(body).then(response => {
                console.log(response);
d.arizona's avatar
d.arizona committed
1108 1109
                if (response.data) {
                    if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
1110
                        this.getMonthlyReportID()
d.arizona's avatar
d.arizona committed
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127
                    }
                }
            })
        } else {
            this.setState({ alert: true, messageAlert: 'Data Is Not Complete', tipeAlert: 'warning', loading: false }, () => {
                document.body.style.overflow = 'unset';
            })
        }
        // if (array.includes("not-yet" || "draft")) {
        //     // // console.log('gagal');
        // } else {
        //     // // console.log('masuk');
        // }

    }

    validateRevision() {
d.arizona's avatar
d.arizona committed
1128
        // this.scrollToMyRef()
d.arizona's avatar
d.arizona committed
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143
        let arrayRevisi = this.state.detailRevisiCheck
        let remarksKosong = 0
        arrayRevisi.map((item, index) => {
            if (item.remarks == "") {
                remarksKosong += 1
            }
        })
        // // console.log(arrayRevisi)
        if (arrayRevisi.length == 0 || remarksKosong > 0) {
            this.setState({ alert: true, messageAlert: 'Remarks Cannot be Empty', tipeAlert: 'error' })
        } else {
            this.setState({ visibleRevision: false }, () => this.approvalSubmission('revision'))
        }
    }

d.arizona's avatar
d.arizona committed
1144
    async setHeaderTokenSuperadmin(type) {
1145
        let realToken = await localStorage.getItem(Constant.TOKEN)
d.arizona's avatar
d.arizona committed
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
        api.create().getIdToken(this.state.approver.userId).then((response) => {
            console.log(response.data.data.token)
            localStorage.setItem(Constant.TOKEN, response.data.data.token)
            this.approvalSubmission(type, realToken)
        })
    }

    approvalSubmission(type, realToken) {
        // this.scrollToMyRef()
        // if (this.state.isAdmin && type == 'approve') {
        //     api.create().getIdToken(this.state.approver.userId).then((response) => {
        //         localStorage.setItem(Constant.TOKEN, response.data.data.token)
        //     })
        // }
d.arizona's avatar
d.arizona committed
1160 1161
        this.setState({ loading: true, selectedStatus: this.state.listStatus }, () => {
            // document.body.style.overflow = 'hidden';
d.arizona's avatar
d.arizona committed
1162 1163 1164 1165
        })
        let body = {
            "approval_id": this.state.approverID,
            "status": type,
d.arizona's avatar
d.arizona committed
1166
            "months": this.state.month.month_id,
d.arizona's avatar
d.arizona committed
1167
            "detail": this.state.detailRevisiCheck,
1168 1169
            "is_superadmin": this.state.isAdmin,
            "currency_id": this.state.defaultCurrency.id
d.arizona's avatar
d.arizona committed
1170 1171 1172 1173
        }
        let payload = {
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
d.arizona's avatar
d.arizona committed
1174
            "months": this.state.month.month_id,
d.arizona's avatar
d.arizona committed
1175 1176 1177
            "min_periode": moment(this.state.minDateRevision).format('YYYY-MM-DD'),
            "max_periode": moment(this.state.maxDateRevision).format('YYYY-MM-DD')
        }
d.arizona's avatar
d.arizona committed
1178
        console.log(payload)
d.arizona's avatar
d.arizona committed
1179 1180
        // // console.log(this.props.location);
        // // console.log(body)
1181 1182 1183 1184 1185
        setTimeout(() => {
            api.create().approvalMonthly(body).then((res) => {
                console.log(res)
                // this.setState({ loading: false }, () => {
                // })
Faisal Hamdi's avatar
Faisal Hamdi committed
1186
                if (this.state.isAdmin && type == 'approve') {
1187
                    localStorage.setItem(Constant.TOKEN, realToken)
Faisal Hamdi's avatar
Faisal Hamdi committed
1188
                    this.setState({ visibleApproveSuperadmin: false })
1189 1190 1191 1192 1193 1194 1195 1196 1197
                }
                setTimeout(() => {
                    if (type == 'revision') {
                        api.create().createPeriodeRevisionMonthly(payload).then((res))
                    }
                    this.getMonthlyReportID()
                }, 300);
            })
        }, 100);
d.arizona's avatar
d.arizona committed
1198 1199
    }

d.arizona's avatar
d.arizona committed
1200
    getCashFlow(type) {
d.arizona's avatar
d.arizona committed
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259
        let payload = {
            "report_id": 13,
            "revision": Number(this.state.lastRevision),
            "periode": this.state.periode.periode,
            "company_id": this.state.company.company_id,
            "monthly_report_id": this.state.monthlyReportId,
            "months": this.state.month.month_id,
            "get_for": "edit"
        }

        api.create().getHierarkiMontlyReportCF(payload).then(response => {
            console.log(response);
            let dataTable = []
            if (response.data) {
                let res = response.data.data
                const handlePushChild = (item) => {
                    let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                    if (indexIDzz === -1) {
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.description,
                            { value: item.cash_flow.actual, formula: item.cash_flow.actual_formula },
                            item.order,
                            false
                        ])
                    }
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                }
                res.map((item, index) => {
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
                        { value: item.cash_flow.actual, formula: item.cash_flow.actual_formula },
                        item.order,
                        false
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
                console.log(dataTable)
d.arizona's avatar
d.arizona committed
1260
                this.setState({ dbCF: dataTable }, () => {
d.arizona's avatar
d.arizona committed
1261
                    this.olahDataCashFlow(this.state.dbCF, type)
d.arizona's avatar
d.arizona committed
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281
                })
            }
        })
    }

    handleValueFormula = (item, indexS) => {
        // loading = true
        // console.log(tableMeta);
        // "@44[M-1]#BS"
        let dbCF = this.state.dbCF
        let splitFormula = String(item[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);
1282

d.arizona's avatar
d.arizona committed
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 1312 1313
            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))
                }
            }
        })

        // console.log(baru);
        let tambahan = false
        let opet = ""
        let itung2x = ''
        baru.map((item, index) => {
            if (item == 'X') {
                tambahan = true
            } else if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
                anjay.push(item)
            } else {
                if (String(item).includes('#')) {
                    if (String(item).includes('[M-1]')) {
                        let tst = '@' + String(item).replace('[M-1]', '[M1]')
                        // console.log(dbCF[tableMeta.rowIndex]);
                        // console.log(tableMeta);
                        // console.log(tst);
                        let indexID = dbCF[indexS][6].formula.findIndex((val) => val.item_formula == tst)
                        // console.log(indexID);
1314

d.arizona's avatar
d.arizona committed
1315 1316 1317 1318 1319 1320
                        if (indexID !== -1) {
                            let valuezz = dbCF[indexS][6].formula[indexID].value
                            anjay.push(valuezz == "" ? 0 : valuezz)
                            // console.log(valuezz);
                        }
                    } else {
1321
                        let data = dbCF[indexS][6].formula == null ? [] : dbCF[indexS][6].formula
d.arizona's avatar
d.arizona committed
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344
                        // console.log(data)
                        let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
                        if (indexID !== -1) {
                            let valuezz = data[indexID].value
                            anjay.push(valuezz == "" ? 0 : valuezz)
                        }
                    }
                } else {
                    if (String(item).includes('[M-1]')) {
                        let tst = String(item).replace('[M-1]', '')
                        let indexID = dbCF.findIndex((val) => val[7] == tst)
                        if (indexID !== -1) {
                            let valuezz = dbCF[indexID][8]
                            anjay.push(valuezz == "" ? 0 : valuezz)
                        }
                    } else {
                        let indexID = dbCF.findIndex((val) => val[7] == item)
                        if (item == 'X-1') {
                            anjay.push(-1)
                        } else if (tambahan) {
                            if (item == '-' || item == '+' || item == '/' || item == '*') {
                                opet = item
                            } else {
1345
                                anjay.push(opet == '' ? Number(item) : Number(String(opet + String(item))))
d.arizona's avatar
d.arizona committed
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 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 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489
                                tambahan = false
                                opet = ""
                            }
                        } else {
                            if (indexID !== -1) {
                                let valuezz = dbCF[indexID][6].value
                                if (item == dbCF[indexS][7]) {
                                    anjay.push(0)
                                } else {
                                    anjay.push(valuezz == "" ? 0 : valuezz)
                                }
                            } else {
                                if (item === '(-1)') {
                                    anjay.push(-1)
                                }
                            }
                        }
                    }
                }
            }
        })

        // console.log(item[5])
        // console.log(splitFormula)
        // console.log(baru)
        // console.log(anjay)
        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)
                }
            }
        })

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

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

        // dataTable2[tableMeta.rowIndex][6].value = total

        return total
    }

d.arizona's avatar
d.arizona committed
1490
    olahDataCashFlow(dbCF, type) {
1491 1492 1493
        dbCF.map((item, index) => {
            if (item[0] == 5 || item[0] == 6) {
                item[6].value = this.handleValueFormula(item, index)
d.arizona's avatar
d.arizona committed
1494 1495
            }
        })
1496
        console.log(dbCF)
1497
        this.setState({ dbCF }, () => {
d.arizona's avatar
d.arizona committed
1498
            this.payloadCF(type)
d.arizona's avatar
d.arizona committed
1499 1500 1501
        })
    }

d.arizona's avatar
d.arizona committed
1502
    payloadCF(type) {
d.arizona's avatar
d.arizona committed
1503
        let listCF = []
1504
        this.state.dbCF.map((item, index) => {
d.arizona's avatar
d.arizona committed
1505
            if (item[6].value == "" || item[6].value == 0 || item[6].value == "0.0") {
1506
                item[6].value = this.handleValueFormula(item, index)
d.arizona's avatar
d.arizona committed
1507 1508
                listCF.push({
                    "item_report_id": item[1],
1509
                    "actual": item[0] == 1 ? "" : Number(item[6].value).toFixed(1)
d.arizona's avatar
d.arizona committed
1510 1511 1512 1513
                })
            } else {
                listCF.push({
                    "item_report_id": item[1],
1514
                    "actual": item[0] == 1 ? "" : Number(item[6].value).toFixed(1)
d.arizona's avatar
d.arizona committed
1515 1516
                })
            }
1517

d.arizona's avatar
d.arizona committed
1518 1519
        })

d.arizona's avatar
d.arizona committed
1520
        console.log(this.state.dbCF)
1521
        this.setState({ dbCF: listCF }, () => {
d.arizona's avatar
d.arizona committed
1522 1523
            if (type != undefined) {
                if (type == 'BS' || type == 'FAM' || type == 'PL') {
d.arizona's avatar
d.arizona committed
1524 1525
                    console.log('tarik sis')
                    this.createCashFlow()
d.arizona's avatar
d.arizona committed
1526 1527
                }
            }
d.arizona's avatar
d.arizona committed
1528
        })
d.arizona's avatar
d.arizona committed
1529 1530
    }

1531
    createCashFlow(payload) {
1532
        console.log(JSON.stringify(payload))
1533
        api.create().createMonthlyReportCF(payload).then((res) => {
1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550
            if (res.data.status === "success") {
                this.saveToMonthlyReport()
                console.log(res)
            } else {
                if (res.data?.message == "Please Set Up Rate Currency First") {
                    this.setState({ visibleAlertSave: true })
                } else {
                    this.setState({ alert: true, messageAlert: res.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
                        if (res.data.message.includes("Someone Logged In") || res.data.message.includes("Token Expired")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            }
1551
        })
d.arizona's avatar
d.arizona committed
1552 1553
    }

1554
    getPL(type) {
d.arizona's avatar
d.arizona committed
1555 1556
        let PLID = null
        let payloadID = {
1557
            "periode": this.state.periode.periode,
Riri Novita's avatar
Riri Novita committed
1558 1559
            "company_id": this.state.company.company_id,
            "currency_id": this.state.defaultCurrency.id
1560
        }
d.arizona's avatar
d.arizona committed
1561 1562 1563 1564
        console.log(payloadID);
        api.create().getPLID(payloadID).then(response => {
            console.log(response);
            if (response) {
1565
                PLID = response.data.data == null ? null : response.data.data.profit_loss_id
d.arizona's avatar
d.arizona committed
1566 1567 1568 1569 1570 1571 1572 1573 1574 1575
            } else {
                PLID = null
            }
            this.setState({ PLID }, () => {
                let payload = {
                    "revision": Number(this.state.lastRevision),
                    "periode": this.state.periode.periode,
                    "company_id": this.state.company.company_id,
                    "months": this.state.month.month_id,
                    "quarter": 0,
1576
                    "report_id": 28,
Riri Novita's avatar
Riri Novita committed
1577 1578
                    "submission_id": this.state.PLID,
                    "currency_id": this.state.defaultCurrency.id
d.arizona's avatar
d.arizona committed
1579
                }
1580

d.arizona's avatar
d.arizona committed
1581 1582 1583 1584
                api.create().getHierarkiCreateReportPLMR(payload).then((response) => {
                    console.log(response)
                    let dataTable = []
                    let err = false
1585

d.arizona's avatar
d.arizona committed
1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598
                    if (response.data) {
                        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,
1599
                                        this.state.month.month_id == 1 ?
d.arizona's avatar
d.arizona committed
1600
                                            { value: item.profit_detail.january, formula: item.profit_detail.january_formula, value_ro: 0 } :
1601
                                            this.state.month.month_id == 2 ?
d.arizona's avatar
d.arizona committed
1602
                                                { value: item.profit_detail.february, formula: item.profit_detail.february_formula, value_ro: 0 } :
1603
                                                this.state.month.month_id == 3 ?
d.arizona's avatar
d.arizona committed
1604
                                                    { value: item.profit_detail.march, formula: item.profit_detail.march_formula, value_ro: 0 } :
1605
                                                    this.state.month.month_id == 4 ?
d.arizona's avatar
d.arizona committed
1606
                                                        { value: item.profit_detail.april, formula: item.profit_detail.april_formula, value_ro: 0 } :
1607
                                                        this.state.month.month_id == 5 ?
d.arizona's avatar
d.arizona committed
1608
                                                            { value: item.profit_detail.may, formula: item.profit_detail.may_formula, value_ro: 0 } :
1609
                                                            this.state.month.month_id == 6 ?
d.arizona's avatar
d.arizona committed
1610
                                                                { value: item.profit_detail.june, formula: item.profit_detail.june_formula, value_ro: 0 } :
1611
                                                                this.state.month.month_id == 7 ?
d.arizona's avatar
d.arizona committed
1612
                                                                    { value: item.profit_detail.july, formula: item.profit_detail.july_formula, value_ro: 0 } :
1613
                                                                    this.state.month.month_id == 8 ?
d.arizona's avatar
d.arizona committed
1614
                                                                        { value: item.profit_detail.august, formula: item.profit_detail.august_formula, value_ro: 0 } :
1615
                                                                        this.state.month.month_id == 9 ?
d.arizona's avatar
d.arizona committed
1616
                                                                            { value: item.profit_detail.september, formula: item.profit_detail.september_formula, value_ro: 0 } :
1617
                                                                            this.state.month.month_id == 10 ?
d.arizona's avatar
d.arizona committed
1618
                                                                                { value: item.profit_detail.october, formula: item.profit_detail.october_formula, value_ro: 0 } :
1619
                                                                                this.state.month.month_id == 11 ?
d.arizona's avatar
d.arizona committed
1620 1621
                                                                                    { value: item.profit_detail.november, formula: item.profit_detail.november_formula, value_ro: 0 } :
                                                                                    { value: item.profit_detail.december, formula: item.profit_detail.december_formula, value_ro: 0 },
d.arizona's avatar
d.arizona committed
1622
                                        item.order,
d.arizona's avatar
d.arizona committed
1623
                                        item.profit_detail.notes
d.arizona's avatar
d.arizona committed
1624 1625 1626 1627 1628 1629 1630 1631 1632
                                    ])
                                }
                                if (item.children !== null) {
                                    if (item.children.length > 0) {
                                        item.children.map((items, indexs) => {
                                            handlePushChild(items)
                                        })
                                    }
                                }
1633
                            }
d.arizona's avatar
d.arizona committed
1634 1635 1636 1637 1638 1639 1640 1641
                            res.map((item, index) => {
                                dataTable.push([
                                    item.type_report_id,
                                    item.id,
                                    item.parent,
                                    item.formula,
                                    item.level,
                                    item.description,
1642
                                    this.state.month.month_id == 1 ?
d.arizona's avatar
d.arizona committed
1643
                                        { value: item.profit_detail.january, formula: item.profit_detail.january_formula, value_ro: 0 } :
1644
                                        this.state.month.month_id == 2 ?
d.arizona's avatar
d.arizona committed
1645
                                            { value: item.profit_detail.february, formula: item.profit_detail.february_formula, value_ro: 0 } :
1646
                                            this.state.month.month_id == 3 ?
d.arizona's avatar
d.arizona committed
1647
                                                { value: item.profit_detail.march, formula: item.profit_detail.march_formula, value_ro: 0 } :
1648
                                                this.state.month.month_id == 4 ?
d.arizona's avatar
d.arizona committed
1649
                                                    { value: item.profit_detail.april, formula: item.profit_detail.april_formula, value_ro: 0 } :
1650
                                                    this.state.month.month_id == 5 ?
d.arizona's avatar
d.arizona committed
1651
                                                        { value: item.profit_detail.may, formula: item.profit_detail.may_formula, value_ro: 0 } :
1652
                                                        this.state.month.month_id == 6 ?
d.arizona's avatar
d.arizona committed
1653
                                                            { value: item.profit_detail.june, formula: item.profit_detail.june_formula, value_ro: 0 } :
1654
                                                            this.state.month.month_id == 7 ?
d.arizona's avatar
d.arizona committed
1655
                                                                { value: item.profit_detail.july, formula: item.profit_detail.july_formula, value_ro: 0 } :
1656
                                                                this.state.month.month_id == 8 ?
d.arizona's avatar
d.arizona committed
1657
                                                                    { value: item.profit_detail.august, formula: item.profit_detail.august_formula, value_ro: 0 } :
1658
                                                                    this.state.month.month_id == 9 ?
d.arizona's avatar
d.arizona committed
1659
                                                                        { value: item.profit_detail.september, formula: item.profit_detail.september_formula, value_ro: 0 } :
1660
                                                                        this.state.month.month_id == 10 ?
d.arizona's avatar
d.arizona committed
1661
                                                                            { value: item.profit_detail.october, formula: item.profit_detail.october_formula, value_ro: 0 } :
1662
                                                                            this.state.month.month_id == 11 ?
d.arizona's avatar
d.arizona committed
1663 1664
                                                                                { value: item.profit_detail.november, formula: item.profit_detail.november_formula, value_ro: 0 } :
                                                                                { value: item.profit_detail.december, formula: item.profit_detail.december_formula, value_ro: 0 },
d.arizona's avatar
d.arizona committed
1665
                                    item.order,
d.arizona's avatar
d.arizona committed
1666
                                    item.profit_detail.notes
d.arizona's avatar
d.arizona committed
1667 1668 1669 1670 1671 1672 1673 1674 1675
                                ])
                                if (item.children !== null) {
                                    if (item.children.length > 0) {
                                        item.children.map((items, indexs) => {
                                            handlePushChild(items)
                                        })
                                    }
                                }
                            })
d.arizona's avatar
d.arizona committed
1676
                            console.log(JSON.stringify(dataTable))
d.arizona's avatar
d.arizona committed
1677 1678
                            console.log(dataTable)
                            this.setState({ dbPL: dataTable }, () => {
1679
                                this.olahDataPL(this.state.dbPL, type)
d.arizona's avatar
d.arizona committed
1680 1681 1682
                            })
                        } else {
                            this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
d.arizona's avatar
d.arizona committed
1683
                                if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
d.arizona's avatar
d.arizona committed
1684 1685 1686 1687 1688 1689
                                    setTimeout(() => {
                                        localStorage.removeItem(Constant.TOKEN)
                                        window.location.reload();
                                    }, 1000);
                                }
                            })
1690
                        }
d.arizona's avatar
d.arizona committed
1691 1692
                    } else {
                        this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true, refresh: false })
1693
                    }
d.arizona's avatar
d.arizona committed
1694
                    // console.log(dataTable);
d.arizona's avatar
d.arizona committed
1695 1696
                })
            })
1697
        })
1698

1699 1700
    }

d.arizona's avatar
d.arizona committed
1701
    handleValueFormulaDBPLMR = (value, tableMeta, column, typeRO) => {
1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731
        let splitFormula = String(tableMeta[3]).split(/([()@])/)
        // let splitFormula = String(tableMeta.rowData[3]).split('@')
        let baru = []
        let anjay = []
        // let colIndex = tableMeta.columnIndex + column
        let dataTable2 = this.state.dbPL
        // if (forecast !== undefined) {
        //     console.log(tableMeta)
        // }

        splitFormula.map((item, index) => {
            let items = String(item).substr(Number(String(item).length) - 1, 1)
            let subForm = String(item).substr(0, Number(String(item).length) - 1)
            let re = /^[a-zA-Z0-9_]+$/;
            let asd = ''
            if (item !== "") {
                if (!re.test(items)) {
                    baru.push(subForm)
                    baru.push(items)
                } else {
                    baru.push(String(item))
                }
            }
        })

        baru.map((item, index) => {
            if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
                anjay.push(item)
            } else {
                if (String(item).includes('#')) {
d.arizona's avatar
d.arizona committed
1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751
                    // if (typeRO !== undefined) {
                    // let forecastt = 0
                    // val.item_formula
                    // forecast.map((items, index) => {
                    //     if (items.periode == periode) {
                    //         forecastt += Number(items.value)
                    //     }
                    // })
                    // anjay.push(forecastt)
                    // } else {
                    if (String(item).includes('[M-1]')) {
                        // let tst = String(item).replace('[M-1]', '')
                        // let data = column == 7 ? 18 : column - 1
                        // let period = data == 18 ? Number(this.props.periode) - 1 : this.props.periode
                        // let indexID = tableMeta.rowData[data].formula.findIndex((val) => val.item_formula == String(`@${tst}`) && val.periode == period)

                        // if (indexID !== -1) {
                        //     let valuezz = tableMeta.rowData[data].formula[indexID].value
                        //     anjay.push(valuezz == "" ? 0 : valuezz)
                        // }
1752
                    } else {
d.arizona's avatar
d.arizona committed
1753 1754 1755 1756 1757 1758 1759
                        let indexID = value.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.state.periode.periode))
                        if (indexID !== -1) {
                            let valuezz = 0
                            if (typeRO != undefined) {
                                valuezz = value.formula[indexID].value_ro
                            } else {
                                valuezz = value.formula[indexID].value
1760
                            }
d.arizona's avatar
d.arizona committed
1761
                            anjay.push(valuezz == "" ? 0 : valuezz)
1762 1763
                        }
                    }
d.arizona's avatar
d.arizona committed
1764
                    // }
1765
                } else {
d.arizona's avatar
d.arizona committed
1766
                    let indexID = dataTable2.findIndex((val) => val[7] == item)
1767
                    if (indexID !== -1) {
d.arizona's avatar
d.arizona committed
1768 1769 1770 1771 1772
                        let valuezz = 0
                        if (typeRO != undefined) {
                            valuezz = dataTable2[indexID][column].value_ro == undefined ? dataTable2[indexID][column] : dataTable2[indexID][column].value_ro
                        } else {
                            valuezz = dataTable2[indexID][column].value == undefined ? dataTable2[indexID][column] : dataTable2[indexID][column].value
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901
                        }
                        anjay.push(valuezz == "" ? 0 : valuezz)
                    } else {
                        if (item === '(-1)') {
                            anjay.push(-1)
                        }
                    }
                }
            }
        })

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

        // if (tableMeta.rowData[5] == "1.0 Cash inflow/ (outflow)  from Operating Activities") {
        //     console.log(anjay2)
        // }

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

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

Riri Novita's avatar
Riri Novita committed
1902 1903 1904 1905 1906 1907 1908
        // if (tableMeta[5] == "Direct Material" && typeRO != undefined) {
        //     console.log(splitFormula)
        //     console.log(baru)
        //     console.log(anjay)
        //     console.log(anjay2)
        //     console.log(total)
        // }
d.arizona's avatar
d.arizona committed
1909

1910 1911 1912 1913 1914
        total = R.equals(total, NaN) ? "0.0" : total
        return total

    }

1915
    olahDataPL(dbPL, type) {
1916 1917 1918
        dbPL.map((item, index) => {
            if (item[0] == 5 || item[0] == 6) {
                item[6].value = this.handleValueFormulaDBPLMR(item[6], item, 6)
d.arizona's avatar
d.arizona committed
1919
                item[6].value_ro = this.handleValueFormulaDBPLMR(item[6], item, 6, 'ro')
1920 1921 1922
            }
        })
        // console.log(dbPL)
1923
        this.setState({ dbPL }, () => {
1924
            this.payloadPL(type)
1925 1926 1927
        })
    }

1928
    payloadPL(type) {
1929
        let listPL = []
1930
        this.state.dbPL.map((item, index) => {
d.arizona's avatar
d.arizona committed
1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948
            // if (item[6].value == "" || item[6].value == 0 || item[6].value == "0.0") {
            item[6].value = this.handleValueFormulaDBPLMR(item[6], item, 6)
            item[6].value_ro = this.handleValueFormulaDBPLMR(item[6], item, 6, 'ro')
            listPL.push({
                "item_report_id": item[1],
                "actual": item[0] == 1 ? "" : Number(item[6].value).toFixed(1),
                "rolling_outlook": item[0] == 1 ? "" : Number(item[6].value_ro).toFixed(1),
                "notes": item[8]
            })
            // } else {
            //     item[6].value = this.handleValueFormulaDBPLMR(item[6], item, 6)
            //     listPL.push({
            //         "item_report_id": item[1],
            //         "actual": item[0] == 1 ? "" : Number(item[6].value).toFixed(1),
            //         "rolling_outlook": item[0] == 1 ? "" : Number(item[6].value_ro).toFixed(1),
            //         "notes": item[8]
            //     })
            // }
1949
        })
d.arizona's avatar
d.arizona committed
1950
        // console.log(this.state.dbPL)
1951
        this.setState({ dbPL: listPL }, () => {
d.arizona's avatar
d.arizona committed
1952
            if (type != undefined) {
d.arizona's avatar
d.arizona committed
1953
                if (type == 'PL') {
1954 1955 1956
                    // console.log(this.state.dbPL)
                    // this.setState({ loading: false })
                    console.log('tarik sis')
1957
                    this.createPL()
d.arizona's avatar
d.arizona committed
1958 1959
                }
            }
1960 1961 1962
        })
    }

1963 1964
    createPL() {
        console.log();
1965
        let payload = {
d.arizona's avatar
d.arizona committed
1966
            // "monthly_report_id": this.state.monthlyReportId,
1967 1968
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
1969
            "report_id": 28,
1970 1971 1972
            "status": "submitted",
            "months": this.state.month.month_id,
            "quarter": 0,
d.arizona's avatar
d.arizona committed
1973
            "profit_loss_id": this.state.PLID,
Riri Novita's avatar
Riri Novita committed
1974 1975
            "profit_loss_mr": this.state.dbPL,
            "currency_id": this.state.defaultCurrency.id
1976
        }
1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
        api.create().createReportPLMR(payload).then((res) => {
            console.log(res)
            // console.log(this.state.dbPL)
            this.setState({ loading: false })
            // if (response.data) {
            //     if (response.data.status === "success") {
            //         this.props.saveToMonthlyReport()
            //     } else {
            //         this.setState({ loading: false }, () => {
            //             this.props.saveToMonthlyReport()
            //         })
            //     }
            // } else {
            //     this.setState({ loading: false }, () => {
            //         // this.getSubmission()
            //         document.body.style.overflow = 'unset';
            //     })
            // }
        })
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007
    }

    getFR(type) {
        let FRID = null
        let payloadID = {
            "periode": this.state.periode.periode,
            "company_id": this.state.company.company_id
        }
        console.log(payloadID);
        api.create().getFRID(payloadID).then(response => {
            console.log(response);
            if (response) {
2008
                FRID = response.data.data == null ? null : response.data.data.ratio_id
2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036
            } else {
                FRID = null
            }
            this.setState({ FRID }, () => {
                let payload = {
                    "report_id": 29,
                    "revision": Number(this.state.lastRevision),
                    "periode": this.state.periode.periode,
                    "company_id": this.state.company.company_id,
                    "submission_id": this.state.FRID,
                    "months": this.state.month.month_id
                }
                api.create().getHierarkiCreateReportFRMR(payload).then(response => {
                    // console.log(response);
                    let dataTable = []
                    if (response.data) {
                        // let dataTable = []
                        console.log(response)
                        let res = response.data.data
                        const handlePushChild = (item) => {
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
                                item.uom,
d.arizona's avatar
d.arizona committed
2037
                                // "",
2038
                                // item.ratio.total_actual_before === null ? "0.0" : item.ratio.total_actual_before === "" ? "0.0" : item.ratio.total_actual_before,
d.arizona's avatar
d.arizona committed
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050
                                Number(item.ratio.monthly_january).toFixed(2),
                                Number(item.ratio.monthly_february).toFixed(2),
                                Number(item.ratio.monthly_march).toFixed(2),
                                Number(item.ratio.monthly_april).toFixed(2),
                                Number(item.ratio.monthly_may).toFixed(2),
                                Number(item.ratio.monthly_june).toFixed(2),
                                Number(item.ratio.monthly_july).toFixed(2),
                                Number(item.ratio.monthly_august).toFixed(2),
                                Number(item.ratio.monthly_september).toFixed(2),
                                Number(item.ratio.monthly_october).toFixed(2),
                                Number(item.ratio.monthly_november).toFixed(2),
                                Number(item.ratio.monthly_december).toFixed(2),
2051
                            ])
2052

2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069
                            if (item.children !== null) {
                                if (item.children.length > 0) {
                                    item.children.map((items, indexs) => {
                                        handlePushChild(items)
                                    })
                                }
                            }
                        }
                        res.map((item, index) => {
                            dataTable.push([
                                item.type_report_id,
                                item.id,
                                item.parent,
                                item.formula,
                                item.level,
                                item.description,
                                item.uom,
d.arizona's avatar
d.arizona committed
2070
                                // "",
2071
                                // item.ratio.total_actual_before === null ? "0.0" : item.ratio.total_actual_before === "" ? "0.0" : item.ratio.total_actual_before,
d.arizona's avatar
d.arizona committed
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085
                                Number(item.ratio.january).toFixed(2),
                                Number(item.ratio.february).toFixed(2),
                                Number(item.ratio.march).toFixed(2),
                                Number(item.ratio.april).toFixed(2),
                                Number(item.ratio.may).toFixed(2),
                                Number(item.ratio.june).toFixed(2),
                                Number(item.ratio.july).toFixed(2),
                                Number(item.ratio.august).toFixed(2),
                                Number(item.ratio.september).toFixed(2),
                                Number(item.ratio.october).toFixed(2),
                                Number(item.ratio.november).toFixed(2),
                                Number(item.ratio.december).toFixed(2),
                                Number(item.ratio.total_next_year).toFixed(2),
                                Number(item.ratio.total_more_year).toFixed(2),
2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096
                            ])
                            if (item.children !== null) {
                                if (item.children.length > 0) {
                                    item.children.map((items, indexs) => {
                                        handlePushChild(items)
                                    })
                                }
                            }
                        })
                        console.log(dataTable)
                        this.setState({ dbFR: dataTable, loading: false }, () => {
2097
                            this.olahDataFR(this.state.dbFR, type)
2098 2099 2100 2101
                        })
                    } else {
                        this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
                    }
2102 2103


2104 2105 2106
                })
            })
        })
2107 2108


2109 2110 2111 2112 2113 2114 2115
    }

    handleFormulaRatio = (value, tableMeta, month) => {
        // console.log(dataTable2)
        let dataTable2 = this.state.dbFR
        let total = 0
        if (month > 12) {
d.arizona's avatar
d.arizona committed
2116
            total = Number(dataTable2[35][6 + month])
2117 2118
        } else {
            for (let index = 0; index < month; index++) {
d.arizona's avatar
d.arizona committed
2119
                total += Number(dataTable2[35][7 + index])
2120 2121
                // console.log(index);
            }
2122
            total = total / month
2123 2124 2125
        }
        let hasil = Number(value) / total
        // console.log(hasil, value, total);
d.arizona's avatar
d.arizona committed
2126
        return Number(hasil).toFixed(2)
2127 2128 2129
    }

    olahDataFR(dbFR, type) {
2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145
        dbFR.map((item, index) => {
            if (item[0] != 4 || item[0] != 1) {
                if (item[5] === "Return on Invested Capital - YTD (ROIC)") {
                    item[7] = this.handleFormulaRatio(item[7], item, 1)
                    item[8] = this.handleFormulaRatio(item[8], item, 2)
                    item[9] = this.handleFormulaRatio(item[9], item, 3)
                    item[10] = this.handleFormulaRatio(item[10], item, 4)
                    item[11] = this.handleFormulaRatio(item[11], item, 5)
                    item[12] = this.handleFormulaRatio(item[12], item, 6)
                    item[13] = this.handleFormulaRatio(item[13], item, 7)
                    item[14] = this.handleFormulaRatio(item[14], item, 8)
                    item[15] = this.handleFormulaRatio(item[15], item, 9)
                    item[16] = this.handleFormulaRatio(item[16], item, 10)
                    item[17] = this.handleFormulaRatio(item[17], item, 11)
                    item[18] = this.handleFormulaRatio(item[18], item, 12)
                }
2146 2147
            }
        })
2148
        this.setState({ dbFR }, () => {
2149 2150 2151 2152 2153 2154 2155
            this.payloadFR(type)
        })
    }

    payloadFR(type) {
        let listFR = []
        console.log(this.state.dbFR)
2156
        this.state.dbFR.map((item, index) => {
2157
            if (item[0] != 4 || item[0] != 1) {
d.arizona's avatar
d.arizona committed
2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170
                // if (item[5] === "Return on Invested Capital - YTD (ROIC)" ) {
                //     item[7] = this.handleFormulaRatio(item[7],item,1)
                //     item[8] = this.handleFormulaRatio(item[8],item,2)
                //     item[9] = this.handleFormulaRatio(item[9],item,3)
                //     item[10] = this.handleFormulaRatio(item[10],item,4)
                //     item[11] = this.handleFormulaRatio(item[11],item,5)
                //     item[12] = this.handleFormulaRatio(item[12],item,6)
                //     item[13] = this.handleFormulaRatio(item[13],item,7)
                //     item[14] = this.handleFormulaRatio(item[14],item,8)
                //     item[15] = this.handleFormulaRatio(item[15],item,9)
                //     item[16] = this.handleFormulaRatio(item[16],item,10)
                //     item[17] = this.handleFormulaRatio(item[17],item,11)
                //     item[18] = this.handleFormulaRatio(item[18],item,12)
qorri_di's avatar
qorri_di committed
2171
                // } 
2172
            }
2173

2174 2175 2176 2177

            listFR.push(
                {
                    "item_report_id": item[1],
2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200
                    "actual": this.state.month.month_id == 1 ?
                        String(item[7] == undefined || item[7] == 'Infinity' || item[7] == '-Infinity' ? "0.0" : Number(item[7]).toFixed(2)) :
                        this.state.month.month_id == 2 ?
                            String(item[8] == undefined || item[8] == 'Infinity' || item[8] == '-Infinity' ? "0.0" : Number(item[8]).toFixed(2)) :
                            this.state.month.month_id == 3 ?
                                String(item[9] == undefined || item[9] == 'Infinity' || item[9] == '-Infinity' ? "0.0" : Number(item[9]).toFixed(2)) :
                                this.state.month.month_id == 4 ?
                                    String(item[10] == undefined || item[10] == 'Infinity' || item[10] == '-Infinity' ? "0.0" : Number(item[10]).toFixed(2)) :
                                    this.state.month.month_id == 5 ?
                                        String(item[11] == undefined || item[11] == 'Infinity' || item[11] == '-Infinity' ? "0.0" : Number(item[11]).toFixed(2)) :
                                        this.state.month.month_id == 6 ?
                                            String(item[12] == undefined || item[12] == 'Infinity' || item[12] == '-Infinity' ? "0.0" : Number(item[12]).toFixed(2)) :
                                            this.state.month.month_id == 7 ?
                                                String(item[13] == undefined || item[13] == 'Infinity' || item[13] == '-Infinity' ? "0.0" : Number(item[13]).toFixed(2)) :
                                                this.state.month.month_id == 8 ?
                                                    String(item[14] == undefined || item[14] == 'Infinity' || item[14] == '-Infinity' ? "0.0" : Number(item[14]).toFixed(2)) :
                                                    this.state.month.month_id == 9 ?
                                                        String(item[15] == undefined || item[15] == 'Infinity' || item[15] == '-Infinity' ? "0.0" : Number(item[15]).toFixed(2)) :
                                                        this.state.month.month_id == 10 ?
                                                            String(item[16] == undefined || item[16] == 'Infinity' || item[16] == '-Infinity' ? "0.0" : Number(item[16]).toFixed(2)) :
                                                            this.state.month.month_id == 11 ?
                                                                String(item[17] == undefined || item[17] == 'Infinity' || item[17] == '-Infinity' ? "0.0" : Number(item[17]).toFixed(2)) :
                                                                String(item[18] == undefined || item[18] == 'Infinity' || item[18] == '-Infinity' ? "0.0" : Number(item[18]).toFixed(2))
2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214
                    // "january": String(item[7] == undefined? item[7] : Number(item[7]).toFixed(1)),
                    // "february": String(item[8] == undefined? item[8] : Number(item[8]).toFixed(1)),
                    // "march": String(item[9] == undefined? item[9] : Number(item[9]).toFixed(1)),
                    // "april": String(item[10] == undefined? item[10] : Number(item[10]).toFixed(1)),
                    // "may": String(item[11] == undefined? item[11] : Number(item[11]).toFixed(1)),
                    // "june": String(item[12] == undefined? item[12] : Number(item[12]).toFixed(1)),
                    // "july": String(item[13] == undefined? item[13] : Number(item[13]).toFixed(1)),
                    // "august": String(item[14] == undefined? item[14] : Number(item[14]).toFixed(1)),
                    // "september": String(item[15] == undefined? item[15] : Number(item[15]).toFixed(1)),
                    // "october": String(item[16] == undefined? item[16] : Number(item[16]).toFixed(1)),
                    // "november": String(item[17] == undefined? item[17] : Number(item[17]).toFixed(1)),
                    // "december": String(item[18] == undefined? item[18] : Number(item[18]).toFixed(1)),
                    // "total_next_year": String(item[19] != ''? Number(item[19]).toFixed(1) : item[19]),
                    // "total_more_year": String(item[20] != ''? Number(item[20]).toFixed(1) : item[20]),
2215
                }
2216
            )
2217

2218 2219 2220
        })

        console.log(listFR)
2221 2222
        console.log('subOD', this.state.submissionID)
        this.setState({ dbFR: listFR }, () => {
d.arizona's avatar
d.arizona committed
2223
            if (this.state.monthlyReportId != null) {
2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258
                this.createDBFR()
            }
        })
    }

    createDBFR() {
        let payload = {
            // "submission_id": this.state.submissionID,
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
            "report_id": 29,
            "status": "submitted",
            "ratio_id": this.state.FRID,
            "ratio_mr": this.state.dbFR,
            "months": this.state.month.month_id,
        }
        // console.log(this.state.dbCF)
        console.log(JSON.stringify(payload))
        api.create().createReportFRMR(payload).then((res) => {
            console.log(res)
            // if (response.data) {
            //     if (response.data.status === "success") {
            //         this.props.saveToMonthlyReport()
            //     } else {
            //         this.setState({ loading: false }, () => {
            //             this.props.saveToMonthlyReport()
            //         })
            //     }
            // } else {
            //     this.setState({ loading: false }, () => {
            //         // this.getSubmission()
            //         document.body.style.overflow = 'unset';
            //     })
            // }
        })
2259
    }
2260

2261 2262 2263 2264
    handleApproveAdmin() {
        this.setState({ visibleApproveSuperadmin: true })
    }

qorri_di's avatar
qorri_di committed
2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306
    handleSelectAll(data) {
        if (this.state.isCheckAll) {
            let checkAll = []
            this.setState({ selectReport: checkAll, isCheckAll: false })
        } else {
            let checkAll = this.state.selectReport
            let isAllDetail = true
            // console.log(checkAll, this.state.selectReport, data);
            data.map((item, index) => {
                if (item[5] === true || this.state.periode.periode <= 2022) {
                    if (!this.state.selectReport.includes(item[4])) {
                        checkAll.push(item[4])
                    }
                } else {
                    isAllDetail = false
                    checkAll.splice(index, 1)
                }
            })
            console.log(checkAll);
            this.setState({ selectReport: checkAll, isCheckAll: isAllDetail })
        }
    }

    handleItemChecked(item) {
        let indexID = this.state.selectReport.findIndex((val) => val === item.rowData[4])
        return indexID === -1 ? false : true
    }

    handleItemClick(item) {
        let indexID = this.state.selectReport.findIndex((val) => val === item.rowData[4])
        let selectReport = this.state.selectReport
        if (indexID === -1) {
            selectReport.push(item.rowData[4])
        } else {
            selectReport.splice(indexID, 1)
        }
        let isCheckAll = selectReport.length === this.state.dataTable.length
        this.setState({ selectReport, isCheckAll })
        console.log(selectReport);
    }

    handleDownloadReport(tableMeta) {
Riri Novita's avatar
Riri Novita committed
2307
        let { selectReport, company, periode, month, defaultCurrency } = this.state
qorri_di's avatar
qorri_di committed
2308 2309 2310 2311 2312 2313
        let payload = {
            "company_id": company.company_id,
            "year": periode.periode,
            "report_id": selectReport,
            "month": month ? String(month.month_id).toString() : "",
            "quartal": "",
Riri Novita's avatar
Riri Novita committed
2314
            "type_report_name": "Monthly Report",
2315
            "currency_id": defaultCurrency.id
qorri_di's avatar
qorri_di committed
2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353
        }
        console.log(payload);
        api.create().createDownloadFile(payload).then((response) => {
            console.log(response)
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        let data = response.data.data
                        this.setState({ downloadedFileReportId: data.downloadedFileReportId, popupDownload: true }, () => this.handleGenerateReport(tableMeta))
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                // this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error'})
                alert(response.problem)
            }
        })
    }

    // componentDidUpdate = (prevProps, prevState) => {
    //     if (this.state.selectReport.length > 0 && (this.state.arrayReport.length == this.state.selectReport.length)) {
    //         setTimeout(() => {
    //             this.handleZip()
    //         }, 200);
    //     }
    // }

    async handleGenerateReport(data) {
Riri Novita's avatar
Riri Novita committed
2354
        let { selectReport, monthlyReportId, company, periode, revisionTable, month, downloadedFileReportId, defaultCurrency } = this.state
qorri_di's avatar
qorri_di committed
2355 2356 2357 2358
        if (selectReport.length > 0) {
            let result = []
            console.log('mulai hit')
            for (const items of selectReport) {
Riri Novita's avatar
Riri Novita committed
2359
                let urlReport = items === 8 ? "profit_loss" : items === 12 ? "tax_planning" : items === 7 ? "balance_sheet" : items === 9 ? "fam" : items === 13 ? "cash_flow" : items === 10 ? "cat" : null
qorri_di's avatar
qorri_di committed
2360 2361
                let datas = data.findIndex((val) => val[4] == items)
                let report = data[datas]
Riri Novita's avatar
Riri Novita committed
2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388
                if (items !== 11) {
                    try {
                        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/${urlReport}/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
                        let res = await fetch(
                            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/${urlReport}/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
                        )
                        if (res.status === 200) {
                            result = [...result, res];
                        }
                    } catch (error) {
                        alert(error)
                    }
                } else {
                    try {
                        let res1 = await fetch(
                            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
                        )
                        if (res1.status === 200) {
                            let res2 = await fetch(
                                `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/lov/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
                            )
                            if (res2.status === 200) {
                                result = [...result, res2];
                            }
                        }
                    } catch (error) {
                        alert(error)
2389
                    }
qorri_di's avatar
qorri_di committed
2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522
                }
            }

            console.log('ini result', result);
            // every untuk cek ke setiap result di dalam array
            if (result.every((e) => e.status == 200)) {
                this.handleZip();
            }

            // selectReport.map(async (items) => {

            // if (items === 8) {
            //     let datas = data.findIndex((val) => val[4] == items)
            //     let report = data[datas]
            //     let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/profit_loss/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     console.log(url);
            //     let res = await fetch(
            //         `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/profit_loss/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     )
            //     console.log(res);
            //     if (res.status === 200) {
            //         this.setState({ arrayReport: [...this.state.arrayReport, items] })
            //     }
            // } else if (items === 12) {
            //     let datas = data.findIndex((val) => val[4] == items)
            //     let report = data[datas]
            //     let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/tax_planning/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     console.log(url);
            //     let res = await fetch(
            //         `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/tax_planning/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     )
            //     console.log(res);
            //     if (res.status === 200) {
            //         this.setState({ arrayReport: [...this.state.arrayReport, items] })
            //     }
            // } else if (items === 7) {
            //     let datas = data.findIndex((val) => val[4] == items)
            //     let report = data[datas]
            //     let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     console.log(url);
            //     let res = await fetch(
            //         `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     )
            //     console.log(res);
            //     if (res.status === 200) {
            //         this.setState({ arrayReport: [...this.state.arrayReport, items] })
            //     }
            // } else if (items === 9) {
            //     let datas = data.findIndex((val) => val[4] == items)
            //     let report = data[datas]
            //     let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/fam/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     console.log(url);
            //     let res = await fetch(
            //         `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/fam/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     )
            //     console.log(res);
            //     if (res.status === 200) {
            //         this.setState({ arrayReport: [...this.state.arrayReport, items] })
            //     }
            // } else if (items === 13) {
            //     let datas = data.findIndex((val) => val[4] == items)
            //     let report = data[datas]
            //     let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cash_flow/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     console.log(url);
            //     let res = await fetch(
            //         `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cash_flow/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     )
            //     console.log(res);
            //     if (res.status === 200) {
            //         this.setState({ arrayReport: [...this.state.arrayReport, items] })
            //     }
            // } else if (items === 11) {
            //     let datas = data.findIndex((val) => val[4] == items)
            //     let report = data[datas]
            //     let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     console.log(url);
            //     let res = await fetch(
            //         `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     )
            //     console.log(res);
            //     if (res.status === 200) {
            //         this.setState({ arrayReport: [...this.state.arrayReport, items] })
            //     }
            // } else if (items === 10) {
            //     let datas = data.findIndex((val) => val[4] == items)
            //     let report = data[datas]
            //     let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     console.log(url);
            //     let res = await fetch(
            //         `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/cat/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId === null ? "" : monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
            //     )
            //     console.log(res);
            //     if (res.status === 200) {
            //         this.setState({ arrayReport: [...this.state.arrayReport, items] })
            //     }
            // }

            // })
        } else {
            alert("Anda harus memilih report yang ingin di download terlebih dahulu!")
            this.setState({ popupDownload: false })
        }
    }

    async handleZip() {
        console.log('mulai zip')
        api.create().createZipReport(this.state.downloadedFileReportId).then((response) => {
            console.log(response)
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
                        this.setState({ arrayReport: [] })
                    } else {
                        this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                            if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                                setTimeout(() => {
                                    localStorage.removeItem(Constant.TOKEN)
                                    window.location.reload();
                                }, 1000);
                            }
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
                }
            } else {
                // this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error'})
                alert(response.problem)
            }
        })
    }


2523
    render() {
Deni Rinaldi's avatar
+  
Deni Rinaldi committed
2524
        const columns = ["#", "Report Type",
2525
            {
2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558
                name: "Revision",
                options: {
                    customBodyRender: (val, tableMeta, updateValue) => {
                        var list = [];
                        for (var i = 0; i <= tableMeta.rowData[6]; i++) {
                            list.push(i);
                        }
                        return (
                            <div style={{ display: 'flex' }}>
                                <FormControlLabel
                                    style={{ margin: 0 }}
                                    value={val}
                                    control={
                                        <Select
                                            value={val}
                                            onChange={event => {
                                                // console.log(event.target)
                                                updateValue(event.target.value)
                                                this.handleChange(event.target.value, tableMeta)
                                            }}
                                            autoWidth
                                        >
                                            {list.map((item, index) =>
                                                <MenuItem key={index} value={item}>{item}</MenuItem>
                                            )}
                                        </Select>
                                    }
                                />
                            </div >
                        );
                    }
                }
            }, {
2559 2560 2561 2562 2563
                name: "Status",
                options: {
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ display: 'flex' }}>
2564
                                {val === "submitted" || val === "approved" ?
Deni Rinaldi's avatar
Deni Rinaldi committed
2565 2566 2567
                                    <span>COMPLETED</span> :
                                    val === "draft" ?
                                        <span>DRAFT</span> :
d.arizona's avatar
d.arizona committed
2568 2569 2570 2571
                                        val === "incomplete" ?
                                            <span>INCOMPLETE</span> :
                                            val === "revision" ?
                                                <span>REVISION</span> :
d.arizona's avatar
d.arizona committed
2572
                                                val === "approval_process" ?
d.arizona's avatar
d.arizona committed
2573 2574 2575 2576 2577 2578 2579 2580
                                                    <span>APPROVAL PROCCESS</span> :
                                                    val === "approval_review" ?
                                                        <span>APPROVAL REVIEW</span> :
                                                        val === "not-yet" ?
                                                            <span>OPEN</span> :
                                                            val === "CLOSED" ?
                                                                <span>CLOSED</span> :
                                                                <img src={Images.cross} style={{ width: 31, height: 24 }} />
2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595
                                }
                            </div >
                        );
                    }
                }
            },
            {
                name: "Action",
                options: {
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ display: 'flex' }}>
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
Deni Rinaldi's avatar
Deni Rinaldi committed
2596
                                        cursor: tableMeta.rowData[5] ? 'pointer' : 'default',
2597 2598
                                        borderColor: 'transparent'
                                    }}
d.arizona's avatar
d.arizona committed
2599
                                    onClick={() =>
2600
                                        this.state.periode.periode <= 2020 ?
d.arizona's avatar
d.arizona committed
2601
                                            this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
2602 2603 2604
                                            :

                                            // {
2605
                                            (tableMeta.rowData[5] ?
2606
                                                this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
2607
                                                : null)
d.arizona's avatar
d.arizona committed
2608 2609
                                        // console.log(tableMeta.rowData)
                                        // }
2610

Deni Rinaldi's avatar
Deni Rinaldi committed
2611
                                    }
2612
                                >
d.arizona's avatar
d.arizona committed
2613
                                    <Typography style={{ color: this.state.periode.periode <= 2020 || tableMeta.rowData[5] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography>
2614 2615 2616 2617 2618
                                </button>
                            </div >
                        );
                    }
                }
qorri_di's avatar
qorri_di committed
2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634
            }, {
                name: "Download",
                options: {
                    customBodyRender: (val, tableMeta) => {
                        // console.log(tableMeta);
                        return (
                            <div style={{ display: 'flex' }}>
                                <CustomCheckbox
                                    checked={this.handleItemChecked(tableMeta)}
                                    onChange={() => this.state.periode.periode <= 2020 ? this.handleItemClick(tableMeta) : (tableMeta.rowData[5] ? this.handleItemClick(tableMeta) : null)}
                                    disabled={this.state.periode.periode <= 2020 ? false : (tableMeta.rowData[5] ? false : true)}
                                />
                            </div >
                        );
                    }
                }
2635 2636 2637 2638 2639 2640
            }, {
                name: "",
                options: { display: false }
            }, {
                name: "",
                options: { display: false }
2641
            }]
Deni Rinaldi's avatar
Deni Rinaldi committed
2642

Deni Rinaldi's avatar
Deni Rinaldi committed
2643 2644 2645 2646
        const columnsHistory = [
            "Name", "Status", "Remarks", "Revision Item", "Date"
        ]

2647 2648 2649
        const options = {
            filter: false,
            sort: false,
syadziy's avatar
syadziy committed
2650
            responsive: "scroll",
2651 2652 2653 2654
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
2655
            pagination: false,
2656 2657
            search: false
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
2658

Deni Rinaldi's avatar
Deni Rinaldi committed
2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671
        const optionsHistory = {
            filter: false,
            sort: false,
            responsive: "scroll",
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
            pagination: true,
            search: false,
            rowsPerPage: 5
        }

d.arizona's avatar
d.arizona committed
2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687
        const optionsRevision = {
            filter: false,
            sort: false,
            responsive: "scroll",
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
            pagination: false,
            search: false
        }

        const handleMaxDate = () => {
            let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
            return handleDate < 0 ? moment(this.state.minDateRevision).format('YYYY/MM/DD') : moment(this.state.maxDateRevision).format('YYYY/MM/DD')
        }
2688

d.arizona's avatar
d.arizona committed
2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810
        const handleChangeText = (value, tableMeta) => {
            let dataTableRevision = this.state.dataTableRevision
            dataTableRevision[tableMeta.rowIndex][tableMeta.columnIndex] = value

            let detailRevisiCheck = this.state.detailRevisiCheck
            let indexId = detailRevisiCheck.findIndex((val) => val.report_id == tableMeta.rowData[0])
            if (indexId !== -1) {
                detailRevisiCheck[indexId].remarks = value
            }

            this.setState({ dataTableRevision, detailRevisiCheck })
        }

        const handleCheckRevision = (value) => {
            let detailRevisiCheck = this.state.detailRevisiCheck
            let payload = {
                report_id: value[0],
                remarks: value[2],
                number: value[3]
            }
            let indexDataRevisi = this.state.dataTableRevision.findIndex((val) => val[3] == value[3])
            let indexId = detailRevisiCheck.sort((a, b) => a.number - b.number).findIndex((val) => val.number == value[3])
            // // console.log(indexId)
            if (indexId == -1) {
                this.state.dataTableRevision.map((item, index) => {
                    if (index > indexDataRevisi) {
                        let indexIds = detailRevisiCheck.findIndex((val) => val.number == item[3])
                        if (indexIds == -1) {
                            let payload2 = {
                                report_id: item[0],
                                remarks: item[2],
                                number: item[3]
                            }
                            detailRevisiCheck.push(payload2)
                        }
                    }
                })
                detailRevisiCheck.push(payload)
            } else {

                let x = 0
                detailRevisiCheck.sort((a, b) => a.number - b.number).map((item, index) => {
                    if (item.number < value[3]) {
                        x += 1
                    }
                })
                if (x < 1) {
                    this.state.dataTableRevision.map((item, index) => {
                        if (index > indexDataRevisi) {
                            let indexIdz = detailRevisiCheck.findIndex((val) => val.number == item[3])
                            if (indexIdz !== -1) {
                                detailRevisiCheck.splice(indexIdz, 1)
                            }
                        }
                    })
                    detailRevisiCheck.splice(indexId, 1)
                }
            }
            this.setState({ detailRevisiCheck: detailRevisiCheck.sort((a, b) => a.number - b.number) })
            // // console.log(detailRevisiCheck)
        }

        const columnRevisi = [
            {
                name: "#",
                options: {
                    customBodyRender: (val, tableMeta, updateValue) => {
                        var list = [];
                        for (var i = 0; i <= tableMeta.rowData[6]; i++) {
                            list.push(i);
                        }
                        return (
                            <div style={{ display: 'flex' }}>
                                <FormControlLabel
                                    style={{ margin: 0 }}
                                    value={val}
                                    control={
                                        <Checkbox
                                            checked={this.state.detailRevisiCheck.findIndex((val) => val.report_id == tableMeta.rowData[0]) == -1 ? false : true}
                                            onClick={() => handleCheckRevision(tableMeta.rowData)} />
                                    }
                                />
                            </div >
                        );
                    }
                }
            }, "Report Type",
            {
                name: 'Remarks',
                options: {
                    customBodyRender: (value, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'left' }}>
                                <FormControlLabel
                                    style={{ margin: 0 }}
                                    // value={value}
                                    control={
                                        <Input
                                            disableUnderline={true}
                                            style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginTop: -10 }}
                                            type="text"
                                            placeholder=""
                                            defaultValue={value}
                                            color={"#5198ea"}
                                            onBlur={(event) => {
                                                // // // console.log(event.target.value)
                                                // updateValue(event.target.value)
                                                handleChangeText(event.target.value, tableMeta)
                                                // // // console.log(dataTable2)
                                            }}
                                        />}
                                />
                            </div>
                        )
                    }
                }
            }, {
                name: "",
                options: { display: false }
            }
        ]

Deni Rinaldi's avatar
Deni Rinaldi committed
2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821
        const loadingComponent = (
            <div style={{ position: 'fixed', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );

2822
        return (
d.arizona's avatar
d.arizona committed
2823
            <div style={{ flex: 1, backgroundColor: '#f8f8f8', overflow: 'scroll' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2824 2825 2826 2827 2828 2829
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
                {this.state.loading && loadingComponent}
2830
                {this.state.visibleMonthlyReport && (
2831 2832
                    <div>
                        <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
d.arizona's avatar
d.arizona committed
2833
                            <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report Submission</Typography>
2834 2835 2836 2837
                        </div>
                        <div style={{ padding: 20, width: '100%' }}>
                            <Paper style={{ paddingTop: 10 }}>
                                <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
Deni Rinaldi's avatar
Deni Rinaldi committed
2838
                                    <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report</Typography>
2839 2840
                                </div>
                                <div style={{ padding: 20 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
2841
                                    <div style={{ display: 'flex' }}>
qorri_di's avatar
qorri_di committed
2842
                                        {/* {this.state.isApprover? 
d.arizona's avatar
d.arizona committed
2843
                                            <div className="grid grid-2x" style={{}}>
qorri_di's avatar
qorri_di committed
2844
                                                <div className="col-1" style={{ display: 'flex', maxWidth: '100%', paddingLeft: 0}}> 
d.arizona's avatar
d.arizona committed
2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903
                                                    <Autocomplete
                                                        {...this.state.listMonth}
                                                        id="month"
                                                        onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
                                                            if (this.state.isApprover === true) {
                                                                    this.getCompanySubmitted()
                                                            } else {
                                                                this.setState({ visibleTableHistory: false })
                                                                this.getRevision()
                                                            }
                                                        })}
                                                        disableClearable
                                                        style={{ width: 250, marginRight: 20 }}
                                                        renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                                                        value={this.state.month}
                                                    />
                                                    <Autocomplete
                                                        {...this.state.listPeriode}
                                                        id="periode"
                                                        onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => {
                                                            if (this.state.isApprover === true) {
                                                                this.getCompanySubmitted()
                                                            } else {
                                                                this.setState({ visibleTableHistory: false })
                                                                this.getRevision()
                                                            }
                                                        })}
                                                        disableClearable
                                                        style={{ width: 250 }}
                                                        renderInput={(params) => <TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }} />}
                                                        value={this.state.periode}
                                                    />
                                                </div>
                                                <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', alignSelf: 'flex-end'}}>
                                                    <FormControlLabel
                                                        style={{ margin: 0 }}
                                                        value={this.state.submittedOnly}
                                                        control={
                                                            <Checkbox
                                                            checked={this.state.submittedOnly}
                                                            onClick={() => this.setState({submittedOnly: !this.state.submittedOnly, loading: true}, () => {
                                                                this.getChecApprover()
                                                                // console.log(this.state.company)
                                                                // this.setState({listCompany: this.state.submittedOnly? this.state.company_submit : this.state.company_active, company: this.state.listCompany != null? this.state.listCompany.options[0] : null})
                                                                // console.log(this.state.company_active)
                                                                // console.log(this.state.company_submit)
                                                                // console.log(this.state.company)
                                                                // console.log(this.state.submittedOnly)
                                                                // if (this.state.submittedOnly) {
                                                                //     this.getCompanySubmitted()
                                                                // } else {
                                                                //     this.getCompanyActive()
                                                                // }
                                                            })} />
                                                        }
                                                    />
                                                    <Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold', marginLeft: 5, alignSelf: 'center'}}>Submitted Only</Typography>
                                                </div>
                                            </div>
d.arizona's avatar
d.arizona committed
2904
                                        :  */}
d.arizona's avatar
d.arizona committed
2905 2906 2907 2908 2909
                                        <div style={{ display: 'flex' }}>
                                            <Autocomplete
                                                {...this.state.listMonth}
                                                id="month"
                                                onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
2910 2911 2912
                                                    // if (this.state.isApprover === true) {
                                                    //     this.getCompanySubmitted()
                                                    // } else {
2913 2914 2915 2916 2917 2918
                                                    this.setState({ visibleTableHistory: false })
                                                    if (this.state.listCompany == null) {
                                                        this.getCompanySubmitted()
                                                    } else {
                                                        this.getRevision()
                                                    }
d.arizona's avatar
d.arizona committed
2919
                                                    // }
d.arizona's avatar
d.arizona committed
2920 2921
                                                })}
                                                disableClearable
d.arizona's avatar
d.arizona committed
2922
                                                style={{ minWidth: 250, marginRight: 20 }}
d.arizona's avatar
d.arizona committed
2923 2924 2925 2926 2927 2928 2929
                                                renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                                                value={this.state.month}
                                            />
                                            <Autocomplete
                                                {...this.state.listPeriode}
                                                id="periode"
                                                onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
2930 2931 2932
                                                    // if (this.state.isApprover === true) {
                                                    //         this.getCompanySubmitted()
                                                    // } else {
2933 2934 2935 2936 2937 2938
                                                    this.setState({ visibleTableHistory: false })
                                                    if (this.state.listCompany == null) {
                                                        this.getCompanySubmitted()
                                                    } else {
                                                        this.getRevision()
                                                    }
d.arizona's avatar
d.arizona committed
2939
                                                    // }
d.arizona's avatar
d.arizona committed
2940 2941 2942 2943 2944 2945 2946
                                                })}
                                                disableClearable
                                                style={{ width: 250 }}
                                                renderInput={(params) => <TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }} />}
                                                value={this.state.periode}
                                            />
                                        </div>
2947

d.arizona's avatar
d.arizona committed
2948
                                        {/* } */}
2949 2950 2951



d.arizona's avatar
d.arizona committed
2952
                                    </div>
Riri Novita's avatar
Riri Novita committed
2953
                                    <div style={{ display: 'flex', marginTop: 20 }}>
d.arizona's avatar
d.arizona committed
2954 2955 2956 2957 2958 2959 2960
                                        <Autocomplete
                                            multiple
                                            id="tags-standard"
                                            options={this.state.listStatus}
                                            getOptionLabel={(option) => option.name}
                                            style={{ width: 250 }}
                                            onChange={(event, newInputValue) => {
2961
                                                this.setState({ selectedStatus: newInputValue, loading: true }, () => {
d.arizona's avatar
d.arizona committed
2962
                                                    console.log(newInputValue);
d.arizona's avatar
d.arizona committed
2963 2964 2965 2966 2967 2968
                                                    this.getCompanySubmitted()
                                                })
                                            }}
                                            value={this.state.selectedStatus}
                                            renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />}
                                        />
Riri Novita's avatar
Riri Novita committed
2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994

                                        <Autocomplete
                                            id="tipe"
                                            disableClearable
                                            options={this.state.currency}
                                            getOptionLabel={(option) => option.value}
                                            value={this.state.defaultCurrency}
                                            // onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue })}
                                            onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue }, () => {
                                                this.getRevision()
                                            })}
                                            style={{ width: 250 }}
                                            renderInput={(params) => <TextField {...params} label="Currency" margin="normal" style={{ marginTop: 7, marginLeft: 20 }} />}
                                        // renderInput={(params) =>
                                        //     <TextField
                                        //         {...params}
                                        //         variant="standard"
                                        //         label="Currency"
                                        //         margin="normal"
                                        //         style={{ marginTop: 6 }}
                                        //     // InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
                                        //     // InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
                                        //     />
                                        // }

                                        />
d.arizona's avatar
d.arizona committed
2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006
                                        {/* <Autocomplete
                                            {...this.state.listCompany}
                                            multiple
                                            id="company"
                                            disabled={this.state.listCompany === null ? true : false}
                                            onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
                                                this.getMonthlyReportID()
                                            })}
                                            style={{ width: 250 }}
                                            renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
                                            value={[this.state.listCompany[0]]}
                                        /> */}
3007 3008 3009 3010 3011
                                    </div>
                                    <div style={{ marginTop: 20 }}>
                                        <Autocomplete
                                            {...this.state.listCompany}
                                            id="company"
Deni Rinaldi's avatar
Deni Rinaldi committed
3012
                                            disabled={this.state.listCompany === null ? true : false}
d.arizona's avatar
d.arizona committed
3013
                                            onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
3014
                                                this.getMonthlyReportID()
Riri Novita's avatar
Riri Novita committed
3015
                                                this.getCurrency(newInputValue.company_id)
3016
                                            })}
3017 3018 3019 3020 3021 3022 3023
                                            disableClearable
                                            style={{ width: 250 }}
                                            renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.company}
                                        />
                                    </div>
                                    <div style={{ marginTop: 20 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
3024
                                        {/* <Autocomplete
3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035
                                            {...this.state.listRevision}
                                            id="revision"
                                            onChange={(event, newInputValue) => this.setState({ revision: newInputValue }, () => {
                                                this.getReport()
                                                this.getReportAttachment()
                                            })}
                                            debug
                                            disableClearable
                                            style={{ width: 250 }}
                                            renderInput={(params) => <TextField {...params} label="Revision" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.revision}
Deni Rinaldi's avatar
Deni Rinaldi committed
3036 3037
                                        /> */}
                                        <TextField disabled={true} label="Revision" margin="normal" style={{ marginTop: 7, width: 250 }} value={this.state.lastRevision} />
3038 3039 3040
                                    </div>

                                    <div style={{ marginTop: 20 }}>
qorri_di's avatar
qorri_di committed
3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072
                                        <div style={{ display: 'flex', justifyContent: 'flex-end', margin: '24px 5px' }}>
                                            <button
                                                className="button"
                                                type="button"
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                    marginRight: 20
                                                }}
                                                onClick={() => this.handleSelectAll(this.state.dataTable)}
                                            >
                                                <div style={{ backgroundColor: '#fff', width: 100, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Check All</Typography>
                                                </div>
                                            </button>
                                            <button
                                                type="button"
                                                disabled={this.state.buttonError}
                                                onClick={() => this.state.selectReport.length > 0 ? this.handleDownloadReport(this.state.dataTable) : alert("Anda harus memilih report yang ingin di download terlebih dahulu!")}
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                }}
                                            >
                                                <div style={{ backgroundColor: '#354960', width: 100, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Download</Typography>
                                                </div>
                                            </button>
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
3073 3074 3075 3076 3077 3078 3079
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={this.state.dataTable}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
3080 3081 3082 3083 3084
                                    </div>
                                    <div style={{ display: 'flex', marginTop: 20 }}>
                                        <div style={{ width: '50%' }}>
                                            <Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
                                        </div>
d.arizona's avatar
d.arizona committed
3085
                                        {!this.state.checkApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
Deni Rinaldi's avatar
Deni Rinaldi committed
3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099
                                            <div style={{ width: '50%' }}>
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: this.state.isSubmit === false ? 'default' : 'pointer',
                                                        borderColor: 'transparent',
                                                        outline: 'none'
                                                    }}
                                                    onClick={() => this.state.isSubmit === false ? null : this.setState({ visibleUpload: true })}
                                                >
                                                    <Typography style={{ fontSize: '16px', color: this.state.isSubmit === false ? 'GrayText' : '#5198ea' }}>Upload File</Typography>
                                                </button>
                                            </div>
                                        )}
3100 3101 3102
                                    </div>
                                    <div style={{ display: 'flex', marginTop: 10 }}>
                                        <div style={{ width: '50%', paddingLeft: 20 }}>
3103
                                            {this.state.listAttachment.length > 0 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
3104
                                                this.state.listAttachment.map((item, index) => {
3105
                                                    return (
Deni Rinaldi's avatar
Deni Rinaldi committed
3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125
                                                        <div style={{ display: 'flex' }}>
                                                            <Typography style={{ fontSize: '13px', color: '#4b4b4b', width: 25 }}>{index + 1}. </Typography>

                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    outline: 'none',
                                                                    display: 'grid'
                                                                }}
                                                                onClick={() => {
                                                                    this.downloadAttachment(item.attachment_url, item.attachment_name)
                                                                }}
                                                            >
                                                                <div>
                                                                    <Typography style={{ fontSize: '13px', color: '#5198ea' }}> {item.attachment_name}</Typography>
                                                                </div>
                                                            </button>
                                                        </div>
3126 3127 3128 3129
                                                    )
                                                })
                                                : null
                                            }
3130
                                        </div>
d.arizona's avatar
d.arizona committed
3131
                                        {!this.state.checkApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
Deni Rinaldi's avatar
Deni Rinaldi committed
3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154
                                            <div style={{ width: '50%' }}>
                                                {
                                                    this.state.listAttachment.length > 0 ?
                                                        this.state.listAttachment.map((item) => {
                                                            return (
                                                                <button
                                                                    style={{
                                                                        backgroundColor: 'transparent',
                                                                        cursor: this.state.isSubmit === false ? 'default' : 'pointer',
                                                                        borderColor: 'transparent',
                                                                        outline: 'none',
                                                                        display: 'grid'
                                                                    }}
                                                                    onClick={() => this.state.isSubmit === false ? null : this.deleteAttachment(item)}
                                                                >
                                                                    <Typography style={{ fontSize: '13px', color: this.state.isSubmit === false ? 'GrayText' : '#ff3939' }}>Delete</Typography>
                                                                </button>
                                                            )
                                                        })
                                                        : null
                                                }
                                            </div>
                                        )}
3155
                                    </div>
Arfin Syadziy's avatar
Arfin Syadziy committed
3156 3157 3158 3159 3160
                                    {this.state.isApprovedMB === false && (
                                        <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
                                            <span>Master Budget Has Not Been Approved</span>
                                        </div>
                                    )}
d.arizona's avatar
d.arizona committed
3161
                                    {this.state.approverTrue === true ?
Deni Rinaldi's avatar
Deni Rinaldi committed
3162 3163 3164 3165 3166 3167 3168 3169 3170
                                        this.state.lastStatus === 'WAITING FOR REVIEW' ?
                                            <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
                                                <span>{this.state.lastStatus}</span>
                                            </div> : this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' ?
                                                <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
                                                    <span>{this.state.lastStatus}</span>
                                                </div> : this.state.lastStatus === 'WAITING FOR APPROVAL' ?
                                                    <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
                                                        <span>{`${this.state.lastStatus} - ${this.state.pic}`}</span>
d.arizona's avatar
d.arizona committed
3171
                                                    </div> : this.state.lastStatus === 'REVISION' ?
Deni Rinaldi's avatar
Deni Rinaldi committed
3172
                                                        <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
d.arizona's avatar
d.arizona committed
3173 3174 3175 3176 3177
                                                            <span>{this.state.textRevision}</span>
                                                        </div> : this.state.lastStatus === 'APPROVED' ?
                                                            <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
                                                                <span>{`${this.state.lastStatus}`}</span>
                                                            </div> : null
Deni Rinaldi's avatar
Deni Rinaldi committed
3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188
                                        :
                                        this.state.lastStatus === 'SUBMITTED' ?
                                            <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
                                                <span>{this.state.lastStatus}</span>
                                            </div> :
                                            this.state.lastStatus === 'WAITING FOR APPROVAL' ?
                                                <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
                                                    <span>{`${this.state.lastStatus} - ${this.state.pic}`}</span>
                                                </div> :
                                                this.state.lastStatus === 'REVISION' ?
                                                    <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
d.arizona's avatar
d.arizona committed
3189
                                                        <span>{this.state.textRevision}</span>
Deni Rinaldi's avatar
Deni Rinaldi committed
3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206
                                                    </div> :
                                                    this.state.lastStatus === 'APPROVED' ?
                                                        <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
                                                            <span>APPROVED</span>
                                                        </div> : null
                                    }
                                    {this.state.visibleTableHistory && (
                                        <div style={{ marginTop: 20 }}>
                                            <MuiThemeProvider theme={getMuiTheme()}>
                                                <MUIDataTable
                                                    data={this.state.dataTableHistory}
                                                    columns={columnsHistory}
                                                    options={optionsHistory}
                                                />
                                            </MuiThemeProvider>
                                        </div>
                                    )}
3207
                                </div>
d.arizona's avatar
d.arizona committed
3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239
                                {this.state.isAdmin && this.state.lastStatus == 'APPROVED' ?
                                    <div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
                                        <div className="col-1" />
                                        <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                    marginRight: 20
                                                }}
                                                onClick={() => this.setState({ visibleRevision: true })}
                                            >
                                                <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
                                                </div>
                                            </button>
                                            {/* <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    outline: 'none',
                                                }}
                                                onClick={() => this.approvalSubmission('approve')}
                                            >
                                                <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
                                                </div>
                                            </button> */}
                                        </div>
3240
                                    </div>
d.arizona's avatar
d.arizona committed
3241
                                    :
Faisal Hamdi's avatar
Faisal Hamdi committed
3242
                                    this.state.isAdmin && (this.state.lastStatus == 'WAITING FOR YOUR APPROVAL' || this.state.lastStatus == 'WAITING FOR APPROVAL') ?
3243 3244 3245
                                        <div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
                                            <div className="col-1" />
                                            <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
d.arizona's avatar
d.arizona committed
3246 3247 3248 3249 3250 3251 3252
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        outline: 'none',
                                                    }}
3253
                                                    onClick={() => this.handleApproveAdmin()}
d.arizona's avatar
d.arizona committed
3254 3255
                                                >
                                                    <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
3256
                                                        <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
d.arizona's avatar
d.arizona committed
3257 3258
                                                    </div>
                                                </button>
3259 3260
                                            </div>
                                        </div>
d.arizona's avatar
d.arizona committed
3261
                                        :
3262 3263
                                        this.state.checkApprover ?
                                            this.state.lastStatus === 'WAITING FOR REVIEW' ?
d.arizona's avatar
d.arizona committed
3264 3265 3266 3267 3268 3269 3270 3271
                                                <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            outline: 'none',
                                                        }}
3272 3273 3274
                                                        onClick={() =>
                                                            this.approvalSubmission('review')
                                                        }
d.arizona's avatar
d.arizona committed
3275
                                                    >
3276 3277
                                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Review</Typography>
d.arizona's avatar
d.arizona committed
3278 3279
                                                        </div>
                                                    </button>
3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345
                                                </div> : (this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' && this.state.btnApprove) ?
                                                    <div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
                                                        <div className="col-1" />
                                                        <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    outline: 'none',
                                                                    marginRight: 20
                                                                }}
                                                                onClick={() => this.setState({ visibleRevision: true })}
                                                            >
                                                                <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
                                                                </div>
                                                            </button>
                                                            <button
                                                                style={{
                                                                    backgroundColor: 'transparent',
                                                                    cursor: 'pointer',
                                                                    borderColor: 'transparent',
                                                                    outline: 'none',
                                                                }}
                                                                onClick={() => this.approvalSubmission('approve')}
                                                            >
                                                                <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                                    <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
                                                                </div>
                                                            </button>
                                                        </div>
                                                    </div> : null
                                            :
                                            (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && this.state.isSubmit ?
                                                <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            outline: 'none',
                                                        }}
                                                        onClick={() => this.validate()}
                                                    >
                                                        <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
                                                        </div>
                                                    </button>
                                                </div> :
                                                this.state.lastStatus === 'SUBMITTED' && this.state.submitter ?
                                                    <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
                                                        <button
                                                            style={{
                                                                backgroundColor: 'transparent',
                                                                cursor: 'pointer',
                                                                borderColor: 'transparent',
                                                                outline: 'none',
                                                            }}
                                                            onClick={() => this.approvalSubmission('cancel')}
                                                        >
                                                            <div style={{ backgroundColor: 'gray', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                                                <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
                                                            </div>
                                                        </button>
                                                    </div> : null
d.arizona's avatar
d.arizona committed
3346
                                }
3347 3348 3349 3350 3351 3352
                            </Paper>

                        </div>
                    </div>
                )}

3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386
                {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={() => this.uploadAttachment(this.state.formData)}
                            />
                        </div>
                    </div>
                )}

3387
                {this.state.visibleBS && (
Deni Rinaldi's avatar
Deni Rinaldi committed
3388 3389
                    <BalanceSheetMR
                        open={this.props.open}
3390
                        report_id={this.state.report_id}
Deni Rinaldi's avatar
Deni Rinaldi committed
3391 3392
                        height={this.props.height}
                        width={this.props.width}
3393
                        company={this.state.company}
Riri Novita's avatar
Riri Novita committed
3394 3395
                        defaultCurrency={this.state.defaultCurrency}
                        currency={this.state.currency}
Deni Rinaldi's avatar
Deni Rinaldi committed
3396 3397
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
Deni Rinaldi's avatar
Deni Rinaldi committed
3398
                        monthlyReportId={this.state.monthlyReportId}
Deni Rinaldi's avatar
Deni Rinaldi committed
3399
                        month={this.state.month}
Deni Rinaldi's avatar
Deni Rinaldi committed
3400
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
Deni Rinaldi's avatar
Deni Rinaldi committed
3401
                        onClickClose={() => this.setState({ visibleBS: false, visibleMonthlyReport: true })}
Deni Rinaldi's avatar
Deni Rinaldi committed
3402
                        isApprover={this.state.isApprover}
d.arizona's avatar
d.arizona committed
3403 3404
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
d.arizona's avatar
d.arizona committed
3405
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
d.arizona's avatar
d.arizona committed
3406
                        createCF={this.createCashFlow.bind(this)}
qorri_di's avatar
qorri_di committed
3407
                    // getReport={this.getCompanyActive.bind(this)}
3408 3409 3410
                    />
                )}
                {this.state.visiblePL && (
d.arizona's avatar
d.arizona committed
3411 3412
                    <ProfitLossMR
                        open={this.props.open}
3413
                        report_id={this.state.report_id}
d.arizona's avatar
d.arizona committed
3414 3415
                        height={this.props.height}
                        width={this.props.width}
3416
                        company={this.state.company}
Riri Novita's avatar
Riri Novita committed
3417 3418
                        defaultCurrency={this.state.defaultCurrency}
                        currency={this.state.currency}
d.arizona's avatar
d.arizona committed
3419 3420
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
Riri Novita's avatar
Riri Novita committed
3421 3422
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
Riri Novita's avatar
Riri Novita committed
3423
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
EKSAD's avatar
EKSAD committed
3424
                        onClickClose={() => this.setState({ visiblePL: false, visibleMonthlyReport: true })}
Riri Novita's avatar
Riri Novita committed
3425
                        isApprover={this.state.isApprover}
d.arizona's avatar
d.arizona committed
3426 3427
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
d.arizona's avatar
d.arizona committed
3428
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
d.arizona's avatar
d.arizona committed
3429
                        createCF={this.createCashFlow.bind(this)}
qorri_di's avatar
qorri_di committed
3430
                    // getReport={this.getCompanyActive.bind(this)}
3431
                    />
3432

3433 3434
                )}
                {this.state.visibleTP && (
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
3435
                    <TaxPlanningMR
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
3436
                        open={this.props.open}
3437
                        report_id={this.state.report_id}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
3438 3439
                        height={this.props.height}
                        width={this.props.width}
3440
                        company={this.state.company}
Riri Novita's avatar
Riri Novita committed
3441 3442
                        defaultCurrency={this.state.defaultCurrency}
                        currency={this.state.currency}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
3443 3444
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
r.kurnia's avatar
r.kurnia committed
3445 3446
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
3447
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
3448
                        onClickClose={() => this.setState({ visibleTP: false, visibleMonthlyReport: true })}
Deni Rinaldi's avatar
Deni Rinaldi committed
3449
                        btnCreate={this.state.btnCreate}
r.kurnia's avatar
r.kurnia committed
3450
                        loadview={this.state.loadview}
r.kurnia's avatar
r.kurnia committed
3451
                        isApprover={this.state.isApprover}
d.arizona's avatar
d.arizona committed
3452 3453
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
3454
                        // getReport={this.getCompanyActive.bind(this)}
d.arizona's avatar
d.arizona committed
3455
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
3456 3457 3458
                    />
                )}
                {this.state.visibleFAM && (
faisalhamdi's avatar
faisalhamdi committed
3459 3460 3461 3462 3463 3464
                    <FixedAssetsMovementMR
                        open={this.props.open}
                        report_id={this.state.report_id}
                        height={this.props.height}
                        width={this.props.width}
                        company={this.state.company}
Riri Novita's avatar
Riri Novita committed
3465 3466
                        defaultCurrency={this.state.defaultCurrency}
                        currency={this.state.currency}
faisalhamdi's avatar
faisalhamdi committed
3467 3468
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
faisalhamdi's avatar
faisalhamdi committed
3469 3470
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
faisalhamdi's avatar
faisalhamdi committed
3471
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
3472
                        onClickClose={() => this.setState({ visibleFAM: false, visibleMonthlyReport: true })}
faisalhamdi's avatar
faisalhamdi committed
3473
                        isApprover={this.state.isApprover}
d.arizona's avatar
d.arizona committed
3474 3475
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
d.arizona's avatar
d.arizona committed
3476
                        createCF={this.createCashFlow.bind(this)}
d.arizona's avatar
d.arizona committed
3477
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
3478 3479 3480
                    />
                )}
                {this.state.visibleCAT && (
faisalhamdi's avatar
faisalhamdi committed
3481
                    <CorporateAnnualTargetMR
Deni Rinaldi's avatar
Deni Rinaldi committed
3482 3483 3484 3485 3486
                        open={this.props.open}
                        report_id={this.state.report_id}
                        height={this.props.height}
                        width={this.props.width}
                        company={this.state.company}
Riri Novita's avatar
Riri Novita committed
3487 3488
                        defaultCurrency={this.state.defaultCurrency}
                        currency={this.state.currency}
Deni Rinaldi's avatar
Deni Rinaldi committed
3489 3490
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
faisalhamdi's avatar
faisalhamdi committed
3491 3492
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
faisalhamdi's avatar
faisalhamdi committed
3493
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
3494
                        onClickClose={() => this.setState({ visibleCAT: false, visibleMonthlyReport: true })}
faisalhamdi's avatar
faisalhamdi committed
3495
                        isApprover={this.state.isApprover}
d.arizona's avatar
d.arizona committed
3496
                        status={this.state.status}
d.arizona's avatar
d.arizona committed
3497 3498
                        // status={'not-yet'}
                        // lastStatus={'SUBMIT'}
d.arizona's avatar
d.arizona committed
3499
                        lastStatus={this.state.lastStatus}
d.arizona's avatar
d.arizona committed
3500
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
3501 3502
                    />
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
3503 3504
                {this.state.visibleLOCF && (
                    <ListOfCreditFacilities
Deni Rinaldi's avatar
Deni Rinaldi committed
3505 3506 3507 3508
                        open={this.props.open}
                        report_id={this.state.report_id}
                        height={this.props.height}
                        width={this.props.width}
Deni Rinaldi's avatar
Deni Rinaldi committed
3509
                        company={this.state.company}
Riri Novita's avatar
Riri Novita committed
3510 3511
                        defaultCurrency={this.state.defaultCurrency}
                        currency={this.state.currency}
Deni Rinaldi's avatar
Deni Rinaldi committed
3512 3513
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
Deni Rinaldi's avatar
Deni Rinaldi committed
3514 3515
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
d.arizona's avatar
d.arizona committed
3516 3517 3518
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
                        onClickClose={() => this.setState({ visibleLOCF: false, visibleMonthlyReport: true })}
                        isApprover={this.state.isApprover}
d.arizona's avatar
d.arizona committed
3519 3520
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
d.arizona's avatar
d.arizona committed
3521
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
Deni Rinaldi's avatar
Deni Rinaldi committed
3522 3523
                    />
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
3524 3525 3526 3527 3528 3529 3530 3531

                {this.state.visibleOI && (
                    <OperatingIndicatorMR
                        open={this.props.open}
                        report_id={this.state.report_id}
                        height={this.props.height}
                        width={this.props.width}
                        company={this.state.company}
Riri Novita's avatar
Riri Novita committed
3532 3533
                        defaultCurrency={this.state.defaultCurrency}
                        currency={this.state.currency}
Deni Rinaldi's avatar
Deni Rinaldi committed
3534 3535 3536 3537
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
Riri Novita's avatar
Riri Novita committed
3538
                        onClickClose={() => this.setState({ visibleOI: false, visibleMonthlyReport: true })}
d.arizona's avatar
d.arizona committed
3539 3540
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
d.arizona's avatar
d.arizona committed
3541
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
Deni Rinaldi's avatar
Deni Rinaldi committed
3542 3543
                    />
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
3544 3545 3546 3547 3548 3549 3550 3551

                {this.state.visibleCF && (
                    <CashFlowMR
                        open={this.props.open}
                        report_id={this.state.report_id}
                        height={this.props.height}
                        width={this.props.width}
                        company={this.state.company}
Riri Novita's avatar
Riri Novita committed
3552 3553
                        defaultCurrency={this.state.defaultCurrency}
                        currency={this.state.currency}
Deni Rinaldi's avatar
Deni Rinaldi committed
3554 3555 3556 3557 3558
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
                        onClickClose={() => this.setState({ visibleCF: false, visibleMonthlyReport: true })}
d.arizona's avatar
d.arizona committed
3559
                        status={this.state.status}
d.arizona's avatar
d.arizona committed
3560
                        // status={'not-yet'}
d.arizona's avatar
d.arizona committed
3561
                        lastStatus={this.state.lastStatus}
d.arizona's avatar
d.arizona committed
3562 3563
                        isApprover={this.state.isApprover}
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
3564
                        PLBSFAMSubmitted={this.state.lastStatus == 'APPROVED' ? true : false}
d.arizona's avatar
d.arizona committed
3565
                        // PLBSFAMSubmitted={false}
d.arizona's avatar
d.arizona committed
3566
                        createCashFlow={this.createCashFlow.bind(this)}
Deni Rinaldi's avatar
Deni Rinaldi committed
3567 3568
                    />
                )}
d.arizona's avatar
d.arizona committed
3569

3570
                {
d.arizona's avatar
d.arizona committed
3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686
                    this.state.visibleRevision && (
                        <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' }}>Revision</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({ visibleRevision: false })}
                                        >
                                            <img src={Images.close} />
                                        </button>
                                    </div>
                                </div>
                                <div className="border-bottom" style={{ padding: 20 }}>
                                    <span>You ask your subsidiary to make a revision</span>
                                    <div style={{ marginTop: 20 }}>
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={this.state.dataTableRevision}
                                                columns={columnRevisi}
                                                options={optionsRevision}
                                            />
                                        </MuiThemeProvider>
                                    </div>
                                    <div style={{ marginTop: 20 }}>
                                        <span>Timing duration you give for revision:</span>
                                        <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 20 }}>
                                            <div>
                                                <DatePicker
                                                    margin="normal"
                                                    id="startDate"
                                                    label="Valid From"
                                                    format="dd-MM-yyyy"
                                                    onChange={(e) => this.setState({ minDateRevision: moment(e).format('YYYY/MM/DD') }, () => this.setState({ maxDateRevision: handleMaxDate() }))}
                                                    value={moment(this.state.minDateRevision).format('YYYY/MM/DD')}
                                                    KeyboardButtonProps={{
                                                        'aria-label': 'change date',
                                                    }}
                                                    inputProps={{
                                                        style: {
                                                            fontSize: 11
                                                        }
                                                    }}
                                                    InputLabelProps={{
                                                        style: {
                                                            fontSize: 11,
                                                            color: '#7e8085'
                                                        }
                                                    }}

                                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                                />
                                            </div>
                                            <span style={{ alignSelf: 'center' }}>Until</span>
                                            <div>
                                                <DatePicker
                                                    margin="normal"
                                                    id="startDate"
                                                    label="Valid To"
                                                    format="dd-MM-yyyy"
                                                    onChange={(e) => this.setState({ maxDateRevision: moment(e).format('YYYY/MM/DD') })}
                                                    minDate={moment(this.state.minDateRevision).format('YYYY/MM/DD')}
                                                    value={moment(this.state.maxDateRevision).format('YYYY/MM/DD')}
                                                    KeyboardButtonProps={{
                                                        'aria-label': 'change date',
                                                    }}
                                                    inputProps={{
                                                        style: {
                                                            fontSize: 11
                                                        }
                                                    }}
                                                    InputLabelProps={{
                                                        style: {
                                                            fontSize: 11,
                                                            color: '#7e8085'
                                                        }
                                                    }}

                                                    style={{ padding: 0, margin: 0, width: '100%' }}
                                                />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
                                    <div className="column-1" style={{ alignSelf: 'center' }}>
                                        <button
                                            type="button"
                                            onClick={() => this.setState({ visibleRevision: false })}
                                        >
                                            <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                                <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
                                            </div>
                                        </button>
                                    </div>
                                    <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
                                        <button
                                            type="button"
                                            onClick={() => this.validateRevision()}
                                        >
                                            <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                                <span style={{ color: '#fff', fontSize: 11 }}>Revision</span>
                                            </div>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    )
                }
3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737

                {this.state.visibleApproveSuperadmin && (
                    <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' }}>Superadmin Approve</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({ visibleApproveSuperadmin: false })}
                                    >
                                        <img src={Images.close} />
                                    </button>
                                </div>
                            </div>
                            <div className="border-bottom" style={{ padding: 20 }}>
                                <span>Choose approver you want</span>
                                <div style={{ marginTop: 20 }}>
                                    <Autocomplete
                                        {...this.state.listApprover}
                                        id="periode"
                                        onChange={(event, newInputValue) => this.setState({ approver: newInputValue })}
                                        disabled={false}
                                        disableClearable
                                        style={{ width: 250 }}
                                        renderInput={(params) =>
                                            <TextField {...params} label="Approver" margin="normal" style={{ marginTop: 7 }}
                                            />}
                                        value={this.state.approver}
                                    />
                                </div>
                            </div>
                            <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
                                <div className="column-1" style={{ alignSelf: 'center' }}>
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ visibleApproveSuperadmin: false })}
                                    >
                                        <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                            <span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
                                        </div>
                                    </button>
                                </div>
                                <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
                                    <button
                                        type="button"
Faisal Hamdi's avatar
Faisal Hamdi committed
3738
                                        onClick={() => this.state.approver == null ? this.setState({ alert: true, messageAlert: 'Approver Cannot be Empty', tipeAlert: 'error' }) : this.setHeaderTokenSuperadmin('approve')}
3739 3740 3741 3742 3743 3744 3745 3746 3747 3748
                                    >
                                        <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
                                            <span style={{ color: '#fff', fontSize: 11 }}>Confirm  Approve</span>
                                        </div>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                )}
qorri_di's avatar
qorri_di committed
3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777

                {this.state.popupDownload && (
                    <div className="test app-popup-show">
                        <div className="popup-content border-radius" style={{ background: '#D9D9D9', borderRadius: 10, width: 609, height: 276 }}>
                            <div>
                                <div style={{ justifyContent: 'center', fontSize: 20, color: '#33508B', margin: '70px 20px' }}>Download Monthly Report {this.state.company.company_name} {this.state.month.month_value} {this.state.periode.periode} In Progress, silahkan cek status dan unduh report di menu <b>Download Report</b></div>
                                <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            background: '#F6F7F9',
                                            cursor: 'pointer',
                                            border: '1px solid #3549609e',
                                            outline: 'none',
                                            marginRight: 20,
                                            borderRadius: 3
                                        }}
                                        onClick={() => this.setState({ popupDownload: false })}
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
                                            <Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
                                        </div>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                )}
3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802

                {this.state.visibleAlertSave && (
                    <div className="test app-popup-show">
                        <div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
                            <div style={{ margin: 30 }}>
                                <div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
                                    <div style={{ alignSelf: 'center', marginRight: 25 }}>
                                        <img src={Images.warning} />
                                    </div>
                                    <div style={{ justifyContent: 'center', fontSize: 20, color: '#1D2995', marginTop: 10 }}>
                                        <b>Rate Currency USD</b> pada periode yang dipilih <b>belum</b> diatur.<br /> Silahkan menghubungi Superadmin
                                    </div>
                                </div>
                                <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                                    <button
                                        className="button"
                                        type="button"
                                        style={{
                                            background: '#F6F7F9',
                                            cursor: 'pointer',
                                            border: '1px solid #3549609e',
                                            outline: 'none',
                                            marginRight: 20,
                                            borderRadius: 9
                                        }}
3803
                                        onClick={() => this.setState({ visibleAlertSave: false, loading: false })}
3804 3805 3806 3807 3808 3809 3810 3811 3812 3813
                                    >
                                        <div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 9, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
                                            <Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
                                        </div>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                )}
3814 3815 3816 3817
            </div >
        );
    }
}