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

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

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

export default class MonthlyReport extends Component {
    constructor(props) {
        super(props)
        this.state = {
            perusahaan: 'TAP Group',
34 35 36
            listRevision: null,
            revision: null,
            visibleMonthlyReport: true,
37
            visibleBS: false,
38 39
            listPeriode: null,
            periode: null,
Deni Rinaldi's avatar
Deni Rinaldi committed
40 41
            listMonth: null,
            month: null,
42 43 44 45 46
            listCompany: null,
            company: null,
            report_id: null,
            visiblePL: false,
            visibleFAM: false,
47
            visibleCAT: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
48
            visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
49
            visibleCF: false,
50
            listAttachment: [],
Deni Rinaldi's avatar
Deni Rinaldi committed
51
            visibleUpload: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
52 53 54 55 56
            lastRevision: 0,
            loading: false,
            alert: false,
            tipeAlert: '',
            messageAlert: '',
Deni Rinaldi's avatar
Deni Rinaldi committed
57
            btnCreate: false,
r.kurnia's avatar
r.kurnia committed
58
            loadview: false
59
        }
60
        this.fileHandler = this.fileHandler.bind(this);
61 62
    }

r.kurnia's avatar
r.kurnia committed
63 64 65 66 67 68 69 70 71
    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
72 73 74 75
                        btnCreate: response.data.data.create,
                        btnEdit: response.data.data.edit
                    }, () => {
                        this.getChecApprover()
r.kurnia's avatar
r.kurnia committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

93
    componentDidMount() {
r.kurnia's avatar
r.kurnia committed
94
        this.getPermission()
Deni Rinaldi's avatar
Deni Rinaldi committed
95
        this.setState({ loading: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
96 97 98 99 100 101 102 103
        // this.getCompanyActive()
    }

    getChecApprover() {
        api.create().checkApproverMonthly().then(response => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
Deni Rinaldi's avatar
Deni Rinaldi committed
104 105
                    if (response.data.data.is_approver === true) {
                        this.setState({ isApprover: true, checkApprover: true }, () =>
Deni Rinaldi's avatar
Deni Rinaldi committed
106
                            this.getMonth())
Deni Rinaldi's avatar
Deni Rinaldi committed
107
                    } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
108 109
                        this.setState({ isApprover: false, checkApprover: false }, () =>
                            this.getCompanyActive())
Deni Rinaldi's avatar
Deni Rinaldi committed
110
                    }
Deni Rinaldi's avatar
Deni Rinaldi committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
125
    }
126

127 128 129 130 131
    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
132
            "months": this.state.month.month_id
133
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
134
        api.create().getMontlyReportAtt(payload).then(response => {
135 136 137
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({ listAttachment: response.data.data })
Deni Rinaldi's avatar
Deni Rinaldi committed
138 139 140 141 142 143 144 145 146
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
147
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
148 149
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
150 151
            }
        })
152 153 154 155 156
    }

    getReport() {
        let payload = {
            "company_id": this.state.company.company_id,
157
            "periode": this.state.periode.periode,
158
            "report_type": "Monthly Report",
faisalhamdi's avatar
faisalhamdi committed
159
            "months": this.state.month.month_id,
160
        }
faisalhamdi's avatar
faisalhamdi committed
161
        api.create().getMonthlyReport(payload).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
162
            console.log(response);
163 164 165 166
            if (response.data) {
                if (response.data.status === "success") {
                    let dataTable = response.data.data.map((item, index) => {
                        return [
167
                            item.number,
168
                            item.report_name,
169 170 171 172 173
                            item.revision,
                            item.current_status,
                            item.report_id,
                            item.is_can_upload,
                            item.revision
174 175
                        ]
                    })
176
                    // console.log(dataTable);
Deni Rinaldi's avatar
Deni Rinaldi committed
177 178 179 180 181 182 183 184 185 186
                    this.setState({ dataTable, loading: false })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
187
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
188 189
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
190 191 192 193 194 195
            }
        })
    }

    getCompanyActive() {
        api.create().getPerusahaanActive().then((response) => {
Deni Rinaldi's avatar
Deni Rinaldi committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
            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),
                    };
                    this.setState({ listCompany: defaultProps, company: companyData[0] }, () => {
                        this.getMonth()
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
222
            } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
223
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
224 225 226 227
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
228
    getMonth() {
Deni Rinaldi's avatar
Deni Rinaldi committed
229 230 231 232 233 234 235 236 237 238 239
        api.create().getMonthTransaction().then(response => {
            let dateNow = new Date
            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
240
                            month_value: String(item.month_name).substr(0, 3)
Deni Rinaldi's avatar
Deni Rinaldi committed
241 242 243 244 245 246 247 248
                        }
                    })
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_value,
                    };
                    let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == month)
                    console.log(index);
Deni Rinaldi's avatar
Deni Rinaldi committed
249
                    this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
250 251 252 253 254
                        if (this.state.isApprover === true) {
                            this.getPeriode()
                        } else {
                            this.getLastPeriod()
                        }
Deni Rinaldi's avatar
Deni Rinaldi committed
255
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
256 257 258 259 260 261 262 263 264
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
265
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
266 267
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
Deni Rinaldi's avatar
Deni Rinaldi committed
268 269 270 271
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
272 273 274 275 276 277 278 279 280 281 282
    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()
                })
            }
        })
    }

283 284
    getPeriode() {
        api.create().getPeriodeTransaction().then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
285
            let currentYear = new Date().getFullYear()
286 287
            if (response.data) {
                if (response.data.status === "success") {
Deni Rinaldi's avatar
Deni Rinaldi committed
288 289 290 291 292 293 294 295 296 297 298 299
                    let data = []
                    response.data.data.map((item) => {
                        if (this.state.isApprover) {
                            if (item >= 2000 && item <= (Number(currentYear) + 1)) {
                                data.push(item)
                            }
                        } else {
                            if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
                                data.push(item)
                            }
                        }
                    })
300 301 302 303 304 305 306 307 308
                    let periodeData = data.map((item) => {
                        return {
                            periode: item,
                        }
                    })
                    let defaultProps = {
                        options: periodeData,
                        getOptionLabel: (option) => option.periode,
                    };
Deni Rinaldi's avatar
Deni Rinaldi committed
309
                    let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod === undefined ? String(Number(currentYear) + 1) : this.state.lastPeriod)
Deni Rinaldi's avatar
Deni Rinaldi committed
310 311 312 313 314 315 316 317 318 319 320
                    let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
                    // console.log(data)
                    console.log(this.state.lastPeriod)
                    // console.log(periodeData)
                    console.log(index)
                    this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
                        if (this.state.isApprover === true) {
                            this.getCompanySubmitted()
                        } else {
                            this.getRevision()
                        }
321
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
322 323 324 325 326 327 328 329 330
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
331
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
332 333
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
334 335 336 337
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
338 339
    getCompanySubmitted() {
        let body = {
Deni Rinaldi's avatar
Deni Rinaldi committed
340 341
            "periode": this.state.periode.periode,
            "months": this.state.month.month_id,
Deni Rinaldi's avatar
Deni Rinaldi committed
342 343
        }
        api.create().getCompanySubmittedMonthly(body).then(response => {
Deni Rinaldi's avatar
Deni Rinaldi committed
344
            console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
            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,
                            }
                        })

                        let defaultProps = {
                            options: companyData,
                            getOptionLabel: (option) => titleCase(option.company_name),
                        }
                        let indexID = null
                        if (this.state.rawData !== undefined) {
                            indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id)
                        }

                        this.setState({ listCompany: defaultProps, company: indexID == null ? companyData[0] : companyData[indexID] }, () => {
                            if (response.data.data.length > 0) {
                                this.getRevision()
                            } else {
                                this.setState({ listRevision: null, revision: null, dataTable: [], checkApprover: false, lastRevision: "", visibleTableHistory: false })
                            }
                            //
                        })
                    } else {
                        this.setState({ listRevision: null, revision: null, dataTable: [], checkApprover: false, lastRevision: "", visibleTableHistory: false, loading: false }, () => {
                            document.body.style.overflow = 'unset';
                        })
                    }
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            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
394 395
    onClickClose() {
        this.setState({})
Deni Rinaldi's avatar
Deni Rinaldi committed
396 397
    }

398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
    getRevision() {
        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] }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
418
                        this.getMonthlyReportID()
419
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
420 421 422 423 424 425 426 427 428
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
429
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
430 431
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
432 433 434 435
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
436 437 438 439
    getMonthlyReportID() {
        let payload = {
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
Deni Rinaldi's avatar
Deni Rinaldi committed
440 441
            "months": this.state.month.month_id,
            "is_approver": this.state.isApprover
Deni Rinaldi's avatar
Deni Rinaldi committed
442 443 444 445 446 447
        }
        api.create().getMonthlyReportID(payload).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
                    this.setState({
Deni Rinaldi's avatar
Deni Rinaldi committed
448 449 450 451 452
                        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,
Deni Rinaldi's avatar
Deni Rinaldi committed
453 454
                        monthlyReportId: response.data.data ? response.data.data.monthly_report_id : null
                    }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
455 456 457
                        // // console.log(this.state.lastStatus);
                        this.historyApproval()
                        // this.getLatestPeriodSubmit()
Deni Rinaldi's avatar
Deni Rinaldi committed
458 459
                        this.getReport()
                        this.getReportAttachment()
Deni Rinaldi's avatar
Deni Rinaldi committed
460 461
                        api.create().checkApproverMonthly().then(response => {
                            // // console.log(response);
Deni Rinaldi's avatar
Deni Rinaldi committed
462 463
                            if (this.state.btnCreate === true && this.state.btnEdit === true) {
                                console.log('editable');
Deni Rinaldi's avatar
Deni Rinaldi committed
464
                                this.setState({ isApprover: false, checkApprover: false })
Deni Rinaldi's avatar
Deni Rinaldi committed
465 466 467
                            } else {
                                console.log('just view');
                                this.setState({ isApprover: true, checkApprover: true })
Deni Rinaldi's avatar
Deni Rinaldi committed
468 469
                            }
                        })
Deni Rinaldi's avatar
Deni Rinaldi committed
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
                    })
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
            }
        })
Deni Rinaldi's avatar
Deni Rinaldi committed
485 486
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
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
    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 => {
                        return [
                            item.pic,
                            item.status_approval,
                            item.remarks,
                            item.item_revision,
                            item.history_approval_date
                        ]
                    })
                    this.setState({ dataTableHistory, visibleTableHistory: true })
                }
            }
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
512
    saveToMonthlyReport() {
Deni Rinaldi's avatar
Deni Rinaldi committed
513 514 515 516 517 518 519 520 521
        this.setState({
            visibleMonthlyReport: true,
            visibleBS: false,
            visiblePL: false,
            visibleCAT: false,
            visibleFAM: false,
            visibleTP: false,
            visibleLOCF: false,
            visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
522
        }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
523
            this.getMonthlyReportID()
Deni Rinaldi's avatar
Deni Rinaldi committed
524 525 526
        })
    }

Deni Rinaldi's avatar
Deni Rinaldi committed
527
    clickDetail(item, id, revision, status) {
d.arizona's avatar
d.arizona committed
528
        console.log(item)
Deni Rinaldi's avatar
Deni Rinaldi committed
529 530 531 532 533 534 535 536 537 538 539 540 541
        this.setState({
            report_id: id,
            revisionTable: revision,
            status: status
        }, () => {
            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
542
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
543
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
544
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
545
                })
d.arizona's avatar
d.arizona committed
546
            } else if (item === 'Profit Loss') {
Deni Rinaldi's avatar
Deni Rinaldi committed
547 548 549 550 551 552
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: true,
                    visibleCAT: false,
                    visibleFAM: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
553 554
                    visibleTP: false,
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
555
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
556
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
557 558 559 560 561 562 563 564
                })
            } else if (item === 'Tax Planning') {
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleFAM: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
565 566
                    visibleTP: true,
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
567
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
568
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
569 570 571 572 573 574 575 576
                })
            } 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
577 578
                    visibleTP: false,
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
579
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
580 581 582 583 584 585 586 587
                })
            } else if (item === 'CAT') {
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: true,
                    visibleFAM: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
588 589
                    visibleTP: false,
                    visibleLOCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
590
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
591
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
592
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
593
            } else if (item === 'List of Credit Facilities') {
Deni Rinaldi's avatar
Deni Rinaldi committed
594 595 596 597 598 599 600 601
                this.setState({
                    visibleMonthlyReport: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleFAM: false,
                    visibleTP: false,
                    visibleLOCF: true,
Deni Rinaldi's avatar
Deni Rinaldi committed
602
                    visibleOI: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
603
                    visibleCF: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
604 605 606 607 608 609 610 611 612 613 614
                })
            } 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
615 616 617 618 619 620 621 622 623 624 625 626 627
                    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,
Deni Rinaldi's avatar
Deni Rinaldi committed
628
                })
Deni Rinaldi's avatar
Deni Rinaldi committed
629 630
            }
        })
631 632
    }

633 634 635 636 637 638 639 640 641 642 643 644 645 646
    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
647
                formData.append("revision", Number(this.state.lastRevision));
648 649 650
                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
651
                formData.append("months", this.state.month.month_id)
652 653 654 655 656 657
                this.setState({ formData })
            }
        })
    }

    uploadAttachment(formData) {
Deni Rinaldi's avatar
Deni Rinaldi committed
658 659
        api.create().uploadAttachmentMonthly(formData).then(response => {
            console.log(response);
660 661 662 663 664 665
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({ visibleUpload: false }, () => {
                        this.getReport()
                        this.getReportAttachment()
                    })
Deni Rinaldi's avatar
Deni Rinaldi committed
666 667 668 669 670 671 672 673 674
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
675
                }
Deni Rinaldi's avatar
Deni Rinaldi committed
676
            } else {
Deni Rinaldi's avatar
Deni Rinaldi committed
677
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
678 679 680 681
            }
            // console.log(response)
        })
    }
682

Deni Rinaldi's avatar
Deni Rinaldi committed
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
    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
698
        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
699 700
        // // console.log(url);
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
701
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/monthly_report/download_attachment?fileName=${fileurl}&&fileType=${fileType}`
Deni Rinaldi's avatar
Deni Rinaldi committed
702 703
        )
        res = await res.blob()
Deni Rinaldi's avatar
Deni Rinaldi committed
704
        this.setState({ loading: false }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
705 706 707 708 709 710 711 712 713 714 715
            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
716 717 718 719
    closeAlert() {
        this.setState({ alert: false })
    }

720
    render() {
Deni Rinaldi's avatar
+  
Deni Rinaldi committed
721
        const columns = ["#", "Report Type",
722
            {
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
                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 >
                        );
                    }
                }
            }, {
756 757 758 759 760
                name: "Status",
                options: {
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ display: 'flex' }}>
761
                                {val === "submitted" || val === "approved" ?
Deni Rinaldi's avatar
Deni Rinaldi committed
762 763 764 765 766 767 768 769 770 771 772 773 774 775
                                    <span>COMPLETED</span> :
                                    val === "draft" ?
                                        <span>DRAFT</span> :
                                        val === "revision" ?
                                            <span>REVISION</span> :
                                            val === "approval_proccess" ?
                                                <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 }} />
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790
                                }
                            </div >
                        );
                    }
                }
            },
            {
                name: "Action",
                options: {
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ display: 'flex' }}>
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
Deni Rinaldi's avatar
Deni Rinaldi committed
791
                                        cursor: tableMeta.rowData[5] ? 'pointer' : 'default',
792 793
                                        borderColor: 'transparent'
                                    }}
Deni Rinaldi's avatar
Deni Rinaldi committed
794
                                    onClick={() =>
Deni Rinaldi's avatar
Deni Rinaldi committed
795 796
                                        // tableMeta.rowData[5] ?
                                        this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
797
                                        // : null
Deni Rinaldi's avatar
Deni Rinaldi committed
798
                                    }
799
                                >
800
                                    <Typography style={{ color: tableMeta.rowData[5] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography>
801 802 803 804 805
                                </button>
                            </div >
                        );
                    }
                }
806 807 808 809 810 811
            }, {
                name: "",
                options: { display: false }
            }, {
                name: "",
                options: { display: false }
812
            }]
Deni Rinaldi's avatar
Deni Rinaldi committed
813

Deni Rinaldi's avatar
Deni Rinaldi committed
814 815 816 817
        const columnsHistory = [
            "Name", "Status", "Remarks", "Revision Item", "Date"
        ]

818 819 820
        const options = {
            filter: false,
            sort: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
821
            // responsive: "scroll",
822 823 824 825
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
Deni Rinaldi's avatar
Deni Rinaldi committed
826
            pagination: false,
827 828
            search: false
        }
Deni Rinaldi's avatar
Deni Rinaldi committed
829

Deni Rinaldi's avatar
Deni Rinaldi committed
830 831 832 833 834 835 836 837 838 839 840 841 842
        const optionsHistory = {
            filter: false,
            sort: false,
            responsive: "scroll",
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
            pagination: true,
            search: false,
            rowsPerPage: 5
        }

Deni Rinaldi's avatar
Deni Rinaldi committed
843 844 845 846 847 848 849 850 851 852 853
        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>
        );

854 855
        return (
            <div style={{ flex: 1, backgroundColor: '#f8f8f8' }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
856 857 858 859 860 861
                <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}
862
                {this.state.visibleMonthlyReport && (
863 864 865 866 867 868 869
                    <div>
                        <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                            <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
                        </div>
                        <div style={{ padding: 20, width: '100%' }}>
                            <Paper style={{ paddingTop: 10 }}>
                                <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
Deni Rinaldi's avatar
Deni Rinaldi committed
870
                                    <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report</Typography>
871 872
                                </div>
                                <div style={{ padding: 20 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
873 874 875 876
                                    <div style={{ display: 'flex' }}>
                                        <Autocomplete
                                            {...this.state.listMonth}
                                            id="month"
Deni Rinaldi's avatar
Deni Rinaldi committed
877
                                            onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
878 879 880 881 882 883
                                                if (this.state.isApprover === true) {
                                                    this.getCompanySubmitted()
                                                } else {
                                                    this.setState({ visibleTableHistory: false })
                                                    this.getRevision()
                                                }
Deni Rinaldi's avatar
Deni Rinaldi committed
884 885 886 887 888 889
                                            })}
                                            disableClearable
                                            style={{ width: 250, marginRight: 20 }}
                                            renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.month}
                                        />
Deni Rinaldi's avatar
Deni Rinaldi committed
890

891 892
                                        <Autocomplete
                                            {...this.state.listPeriode}
893
                                            id="periode"
Deni Rinaldi's avatar
Deni Rinaldi committed
894
                                            onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
895 896 897 898 899 900
                                                if (this.state.isApprover === true) {
                                                    this.getCompanySubmitted()
                                                } else {
                                                    this.setState({ visibleTableHistory: false })
                                                    this.getRevision()
                                                }
901 902 903
                                            })}
                                            disableClearable
                                            style={{ width: 250 }}
Deni Rinaldi's avatar
+  
Deni Rinaldi committed
904
                                            renderInput={(params) => <TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }} />}
905
                                            value={this.state.periode}
906
                                        />
907 908 909 910 911
                                    </div>
                                    <div style={{ marginTop: 20 }}>
                                        <Autocomplete
                                            {...this.state.listCompany}
                                            id="company"
Deni Rinaldi's avatar
Deni Rinaldi committed
912 913
                                            disabled={this.state.listCompany === null ? true : false}
                                            onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
Deni Rinaldi's avatar
Deni Rinaldi committed
914
                                                this.getMonthlyReportID()
915
                                            })}
916 917 918 919 920 921 922
                                            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
923
                                        {/* <Autocomplete
924 925 926 927 928 929 930 931 932 933 934
                                            {...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
935 936
                                        /> */}
                                        <TextField disabled={true} label="Revision" margin="normal" style={{ marginTop: 7, width: 250 }} value={this.state.lastRevision} />
937 938 939
                                    </div>

                                    <div style={{ marginTop: 20 }}>
Deni Rinaldi's avatar
Deni Rinaldi committed
940 941 942 943 944 945 946
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={this.state.dataTable}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
947 948 949 950 951
                                    </div>
                                    <div style={{ display: 'flex', marginTop: 20 }}>
                                        <div style={{ width: '50%' }}>
                                            <Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966
                                        {!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
                                            <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>
                                        )}
967 968 969
                                    </div>
                                    <div style={{ display: 'flex', marginTop: 10 }}>
                                        <div style={{ width: '50%', paddingLeft: 20 }}>
970
                                            {this.state.listAttachment.length > 0 ?
Deni Rinaldi's avatar
Deni Rinaldi committed
971
                                                this.state.listAttachment.map((item, index) => {
972
                                                    return (
Deni Rinaldi's avatar
Deni Rinaldi committed
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992
                                                        <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>
993 994 995 996
                                                    )
                                                })
                                                : null
                                            }
997
                                        </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
                                        {!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
                                            <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>
                                        )}
1022
                                    </div>
Deni Rinaldi's avatar
Deni Rinaldi committed
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065
                                    {this.state.checkApprover === true ?
                                        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>
                                                    </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
                                        :
                                        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 }}>
                                                        <span>NEED REVISION</span>
                                                    </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>
                                    )}
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077
                                </div>
                                <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
                                    <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>
                                </div>
                            </Paper>

                        </div>
                    </div>
                )}

1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111
                {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>
                )}

1112
                {this.state.visibleBS && (
Deni Rinaldi's avatar
Deni Rinaldi committed
1113 1114
                    <BalanceSheetMR
                        open={this.props.open}
1115
                        report_id={this.state.report_id}
Deni Rinaldi's avatar
Deni Rinaldi committed
1116 1117
                        height={this.props.height}
                        width={this.props.width}
1118
                        company={this.state.company}
Deni Rinaldi's avatar
Deni Rinaldi committed
1119 1120
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
Deni Rinaldi's avatar
Deni Rinaldi committed
1121
                        monthlyReportId={this.state.monthlyReportId}
Deni Rinaldi's avatar
Deni Rinaldi committed
1122
                        month={this.state.month}
Deni Rinaldi's avatar
Deni Rinaldi committed
1123
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1124
                        onClickClose={() => this.setState({ visibleBS: false, visibleMonthlyReport: true })}
Deni Rinaldi's avatar
Deni Rinaldi committed
1125
                        isApprover={this.state.isApprover}
Deni Rinaldi's avatar
Deni Rinaldi committed
1126
                    // getReport={this.getCompanyActive.bind(this)}
1127 1128 1129
                    />
                )}
                {this.state.visiblePL && (
d.arizona's avatar
d.arizona committed
1130 1131
                    <ProfitLossMR
                        open={this.props.open}
1132
                        report_id={this.state.report_id}
d.arizona's avatar
d.arizona committed
1133 1134
                        height={this.props.height}
                        width={this.props.width}
1135
                        company={this.state.company}
d.arizona's avatar
d.arizona committed
1136 1137
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
Riri Novita's avatar
Riri Novita committed
1138 1139
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
Riri Novita's avatar
Riri Novita committed
1140
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
EKSAD's avatar
EKSAD committed
1141
                        onClickClose={() => this.setState({ visiblePL: false, visibleMonthlyReport: true })}
Riri Novita's avatar
Riri Novita committed
1142
                        isApprover={this.state.isApprover}
Deni Rinaldi's avatar
Deni Rinaldi committed
1143
                    // getReport={this.getCompanyActive.bind(this)}
1144
                    />
1145

1146 1147
                )}
                {this.state.visibleTP && (
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
1148
                    <TaxPlanningMR
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
1149
                        open={this.props.open}
1150
                        report_id={this.state.report_id}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
1151 1152
                        height={this.props.height}
                        width={this.props.width}
1153
                        company={this.state.company}
Rifka Kurnia Irfiana's avatar
Rifka Kurnia Irfiana committed
1154 1155
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
r.kurnia's avatar
r.kurnia committed
1156 1157
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
1158
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
1159
                        onClickClose={() => this.setState({ visibleTP: false, visibleMonthlyReport: true })}
Deni Rinaldi's avatar
Deni Rinaldi committed
1160
                        btnCreate={this.state.btnCreate}
r.kurnia's avatar
r.kurnia committed
1161
                        loadview={this.state.loadview}
r.kurnia's avatar
r.kurnia committed
1162
                        isApprover={this.state.isApprover}
Deni Rinaldi's avatar
Deni Rinaldi committed
1163
                    // getReport={this.getCompanyActive.bind(this)}
1164 1165 1166
                    />
                )}
                {this.state.visibleFAM && (
faisalhamdi's avatar
faisalhamdi committed
1167 1168 1169 1170 1171 1172 1173 1174
                    <FixedAssetsMovementMR
                        open={this.props.open}
                        report_id={this.state.report_id}
                        height={this.props.height}
                        width={this.props.width}
                        company={this.state.company}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
faisalhamdi's avatar
faisalhamdi committed
1175 1176
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
faisalhamdi's avatar
faisalhamdi committed
1177
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
1178
                        onClickClose={() => this.setState({ visibleFAM: false, visibleMonthlyReport: true })}
faisalhamdi's avatar
faisalhamdi committed
1179
                        isApprover={this.state.isApprover}
1180 1181 1182
                    />
                )}
                {this.state.visibleCAT && (
faisalhamdi's avatar
faisalhamdi committed
1183
                    <CorporateAnnualTargetMR
Deni Rinaldi's avatar
Deni Rinaldi committed
1184 1185 1186 1187 1188 1189 1190
                        open={this.props.open}
                        report_id={this.state.report_id}
                        height={this.props.height}
                        width={this.props.width}
                        company={this.state.company}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
faisalhamdi's avatar
faisalhamdi committed
1191 1192
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
faisalhamdi's avatar
faisalhamdi committed
1193
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
1194
                        onClickClose={() => this.setState({ visibleCAT: false, visibleMonthlyReport: true })}
faisalhamdi's avatar
faisalhamdi committed
1195
                        isApprover={this.state.isApprover}
1196 1197
                    />
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
1198 1199
                {this.state.visibleLOCF && (
                    <ListOfCreditFacilities
Deni Rinaldi's avatar
Deni Rinaldi committed
1200 1201 1202 1203
                        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
1204 1205 1206
                        company={this.state.company}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
Deni Rinaldi's avatar
Deni Rinaldi committed
1207 1208
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
d.arizona's avatar
d.arizona committed
1209 1210 1211
                        saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
                        onClickClose={() => this.setState({ visibleLOCF: false, visibleMonthlyReport: true })}
                        isApprover={this.state.isApprover}
Deni Rinaldi's avatar
Deni Rinaldi committed
1212 1213
                    />
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225

                {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}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
Riri Novita's avatar
Riri Novita committed
1226
                        onClickClose={() => this.setState({ visibleOI: false, visibleMonthlyReport: true })}
Deni Rinaldi's avatar
Deni Rinaldi committed
1227 1228
                    />
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243

                {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}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
                        monthlyReportId={this.state.monthlyReportId}
                        month={this.state.month}
                        onClickClose={() => this.setState({ visibleCF: false, visibleMonthlyReport: true })}
                    />
                )}
1244 1245 1246 1247
            </div >
        );
    }
}