RollingOutlook.js 84.5 KB
Newer Older
EKSAD's avatar
EKSAD committed
1
import React, { Component } from 'react';
EKSAD's avatar
EKSAD committed
2
import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel, Snackbar, withStyles, createMuiTheme, MuiThemeProvider, Checkbox, Input } from '@material-ui/core';
EKSAD's avatar
EKSAD committed
3 4 5 6
import MUIDataTable from 'mui-datatables';
import Images from '../assets/Images';
import api from '../api';
import Autocomplete from '@material-ui/lab/Autocomplete';
EKSAD's avatar
EKSAD committed
7
import MuiAlert from '@material-ui/lab/Alert';
EKSAD's avatar
EKSAD committed
8
import { titleCase } from '../library/Utils';
9 10 11
import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../library/Upload";
import { format } from 'date-fns';
EKSAD's avatar
EKSAD committed
12 13 14 15
import Constant from '../library/Constant';
import PropagateLoader from "react-spinners/PropagateLoader"
import { DatePicker } from '@material-ui/pickers';
import moment from 'moment';
Deni Rinaldi's avatar
Deni Rinaldi committed
16
import BalanceSheetRO from './RollingOutlook/BalanceSheetRO';
Riri Novita's avatar
Riri Novita committed
17
import ProfitLossRO from './RollingOutlook/ProfitLossRO';
r.kurnia's avatar
r.kurnia committed
18
import TaxPlanningRO from './RollingOutlook/TaxPlanningRO';
faisalhamdi's avatar
faisalhamdi committed
19
import CorporateAnnualTargetRO from './RollingOutlook/CorporateAnnualTargetRO';
r.kurnia's avatar
r.kurnia committed
20
import CashFlowRO from './RollingOutlook/CashFlowRO';
EKSAD's avatar
EKSAD committed
21

EKSAD's avatar
EKSAD 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} />);

EKSAD's avatar
EKSAD committed
28 29 30 31 32
export default class RollingOutlook extends Component {
    constructor(props) {
        super(props)
        this.state = {
            perusahaan: 'TAP Group',
33 34 35 36
            listRevision: null,
            revision: null,
            listPeriode: null,
            periode: null,
EKSAD's avatar
EKSAD committed
37 38 39
            listCompany: null,
            company: null,
            report_id: null,
EKSAD's avatar
EKSAD committed
40 41
            visibleRollingOutlook: true,
            visibleBS: false,
EKSAD's avatar
EKSAD committed
42
            visiblePL: false,
EKSAD's avatar
EKSAD committed
43
            visibleTP: false,
44
            visibleCAT: false,
r.kurnia's avatar
r.kurnia committed
45
            visibleCF: false,
46
            listAttachment: [],
EKSAD's avatar
EKSAD committed
47 48 49 50 51
            visibleUpload: false,
            revisionTable: null,
            alert: false,
            tipeAlert: '',
            messageAlert: '',
52
            rollingOutlookID: null,
EKSAD's avatar
EKSAD committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
            isSubmit: false,
            visibleTableHistory: false,
            isApprover: false,
            lastStatus: "",
            intent: "",
            approverID: null,
            pic: '',
            submitter: false,
            detailRevisiCheck: [],
            lastRevision: "",
            checkApprover: false,
            lastPeriod: '',
            latestPeriode: '',
            minDateRevision: new Date(),
            maxDateRevision: new Date(),
d.arizona's avatar
d.arizona committed
68
            btnApprove: false,
d.arizona's avatar
d.arizona committed
69 70
            listStatus: [],
            selectedStatus: [],
d.arizona's avatar
d.arizona committed
71
            quarterList: [
d.arizona's avatar
d.arizona committed
72 73 74
                { value: 'q1', name: 'Q1' },
                { value: 'q2', name: 'Q2' },
                { value: 'q3', name: 'Q3' },
d.arizona's avatar
d.arizona committed
75
                // {value: 'ol_pa', name: 'OL PA'},
d.arizona's avatar
d.arizona committed
76 77
            ],
            quarter: null
EKSAD's avatar
EKSAD committed
78
        }
EKSAD's avatar
EKSAD committed
79
        this.myRef = React.createRef()
80
        this.fileHandler = this.fileHandler.bind(this);
EKSAD's avatar
EKSAD committed
81 82
    }

EKSAD's avatar
EKSAD committed
83 84
    scrollToMyRef = () => window.scrollTo(0, this.myRef.current.offsetTop)

EKSAD's avatar
EKSAD committed
85
    componentDidMount() {
EKSAD's avatar
EKSAD committed
86 87
        this.setState({ loading: true })
        this.props.selectIndex('Rolling Outlook & CAT')
r.kurnia's avatar
r.kurnia committed
88 89 90 91 92 93 94 95
        if (this.props.location.state !== undefined) {
            console.log(this.props);
            this.setState({ userType: this.props.location.state.userType, intent: 'Home', lastPeriod: this.props.location.state.rawData.periode, rawData: this.props.location.state.rawData }, () => {
            this.getPermission()
            })
        } else {
            this.getPermission()
        }
EKSAD's avatar
EKSAD committed
96 97
    }

d.arizona's avatar
d.arizona committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
    getPermission() {
        let payload = {
            menu: "rolling outlook & cat revision"
        }
        api.create().getPermission(payload).then(response => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({
                        btnCreate: response.data.data.create,
                        btnEdit: response.data.data.edit
                    }, () => {
                        this.checkApprover()
                    })
                } 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' })
            }
        })
    }

EKSAD's avatar
EKSAD committed
128
    checkApprover() {
d.arizona's avatar
d.arizona committed
129
        // console.log('tot')
d.arizona's avatar
d.arizona committed
130 131 132 133 134 135 136 137 138 139 140 141 142
        let listStatus1 = [
            { name: 'Open', value: 'not-yet' },
            { name: 'Submitted', value: 'approval_review' },
            { name: 'Waiting for Review / Approval', value: 'approval_proccess' },
            { name: 'Approved', value: 'approved' },
        ]

        let listStatus2 = [
            { name: 'Open', value: 'not-yet' },
            { name: 'Submitted', value: 'approval_review' },
            { name: 'Approved', value: 'approved' },
        ]

d.arizona's avatar
d.arizona committed
143
        api.create().getRollingOutlookIsApprover().then(response => {
d.arizona's avatar
d.arizona committed
144
            // console.log('yuuuu')
EKSAD's avatar
EKSAD committed
145 146
            console.log(response);
            if (response.data.data.is_approver === true) {
d.arizona's avatar
d.arizona committed
147
                this.setState({ isApprover: true, checkApprover: true, listStatus: listStatus1, selectedStatus: listStatus1 }, () =>
EKSAD's avatar
EKSAD committed
148 149
                    this.getPeriode())
            } else {
d.arizona's avatar
d.arizona committed
150 151 152
                this.setState({ isApprover: false, checkApprover: false, listStatus: listStatus2, selectedStatus: listStatus2 }, () =>
                    this.getPeriode())
                // this.getDetailUser())
EKSAD's avatar
EKSAD committed
153 154 155 156 157
            }
        })
    }

    getCompanySubmitted() {
d.arizona's avatar
d.arizona committed
158 159 160
        let selectedStatus = this.state.selectedStatus.map((item) => {
            return item.value
        })
EKSAD's avatar
EKSAD committed
161
        let body = {
d.arizona's avatar
d.arizona committed
162 163 164
            "periode": this.state.periode.periode,
            "quartal": this.state.quarter.value,
            "status": selectedStatus
EKSAD's avatar
EKSAD committed
165
        }
d.arizona's avatar
d.arizona committed
166 167
        // this.setState({ isApprovedMB: true })
        api.create().getRollingOutlookCompanySubmitted(body).then(response => {
EKSAD's avatar
EKSAD committed
168 169 170
            console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
d.arizona's avatar
d.arizona committed
171 172 173 174 175 176 177 178
                    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,
                            }
                        })
EKSAD's avatar
EKSAD committed
179

d.arizona's avatar
d.arizona committed
180 181 182 183 184 185 186
                        let arrayBaru = []
                        this.state.userCompany.map((item, index) => {
                            let indexID = companyData.findIndex((val) => val.company_id == item)
                            if (indexID !== -1) {
                                arrayBaru.push(companyData[indexID])
                            }
                        })
d.arizona's avatar
d.arizona committed
187

d.arizona's avatar
d.arizona committed
188 189
                        if (arrayBaru.length > 0) {
                            arrayBaru = arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name))
EKSAD's avatar
EKSAD committed
190
                        }
d.arizona's avatar
d.arizona committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
                        let defaultProps = {
                            options: arrayBaru,
                            getOptionLabel: (option) => titleCase(option.company_name),
                        }
                        let indexID = null
                        if (this.state.rawData !== undefined) {
                            indexID = arrayBaru.findIndex((val) => val.company_id == this.state.rawData.company_id)
                        }
                        // console.log(response.data.data.length)
                        this.setState({ listCompany: defaultProps, company: indexID == null ? arrayBaru[0] : arrayBaru[indexID], company_submit: defaultProps }, () => {
                            // console.log(response.data.data.length)
                            if (response.data.data.length > 0) {
                                this.getRevision()
                            } else {
                                // console.log(this.state.listCompany)
                                // console.log(this.state.company_submit)
                                this.setState({ listRevision: null, revision: null, dataTable: [], lastRevision: "", visibleTableHistory: false })
                            }
                            //
                        })
                    } else {
                        this.setState({ listRevision: null, revision: null, listCompany: null, company: null, dataTable: [], lastRevision: "", visibleTableHistory: false, loading: false }, () => {
                            document.body.style.overflow = 'unset';
                        })
                    }
EKSAD's avatar
EKSAD committed
216 217 218 219 220 221 222 223 224 225 226 227 228 229
                } 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 })
            }
        })
EKSAD's avatar
EKSAD committed
230 231
    }

232 233 234 235 236
    getReportAttachment() {
        let payload = {
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
            "revision": this.state.revision.revision,
d.arizona's avatar
d.arizona committed
237
            "quartal": this.state.quarter.value
238
        }
d.arizona's avatar
d.arizona committed
239
        api.create().getRollingOutlookAttachment(payload).then(response => {
EKSAD's avatar
EKSAD committed
240
            console.log(response)
241 242 243 244 245 246 247 248 249
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({ listAttachment: response.data.data })
                }
            }
            // console.log(response);
        })
    }

EKSAD's avatar
EKSAD committed
250 251 252
    getReport() {
        let payload = {
            "company_id": this.state.company.company_id,
253
            "periode": this.state.periode.periode,
EKSAD's avatar
EKSAD committed
254
            "report_type": "Rolling Outlook",
d.arizona's avatar
d.arizona committed
255
            "quartal": this.state.quarter.value
EKSAD's avatar
EKSAD committed
256
        }
d.arizona's avatar
d.arizona committed
257
        let dataHardcode = []
d.arizona's avatar
d.arizona committed
258
        api.create().getRollingOutlookReport(payload).then(response => {
EKSAD's avatar
EKSAD committed
259
            console.log(response);
EKSAD's avatar
EKSAD committed
260 261 262
            if (response.data) {
                if (response.data.status === "success") {
                    let dataTable = response.data.data.map((item, index) => {
d.arizona's avatar
d.arizona committed
263
                        return [
264
                            item.number,
EKSAD's avatar
EKSAD committed
265
                            item.report_name,
266
                            item.revision,
EKSAD's avatar
EKSAD committed
267
                            this.state.isSubmit === false ? "CLOSED" : item.current_status,
268
                            item.report_id,
EKSAD's avatar
EKSAD committed
269
                            Number(item.revision) > 0 ? (item.current_status == "not-yet" ? false : item.is_can_upload) : item.is_can_upload,
270
                            item.revision
d.arizona's avatar
d.arizona committed
271
                        ]
EKSAD's avatar
EKSAD committed
272
                    })
EKSAD's avatar
EKSAD committed
273 274 275 276 277 278 279
                    let dataTableRevision = response.data.data.map((item, index) => {
                        return [
                            item.report_id,
                            item.report_name,
                            ""
                        ]
                    })
280
                    // console.log(dataTable);
d.arizona's avatar
d.arizona committed
281
                    this.setState({ dataTable, loading: false, dataTableRevision, dataForRevision: response.data.data })
EKSAD's avatar
EKSAD committed
282 283 284 285 286 287 288 289 290 291
                }
            } else {
                this.setState({ loading: false })
            }
        })
    }

    getLatestPeriodSubmit() {
        let body = {
            "company_id": this.state.company.company_id,
d.arizona's avatar
d.arizona committed
292 293 294
            "periode": this.state.periode.periode,
            "is_approver": this.state.isApprover,
            "quartal": this.state.quarter.value
EKSAD's avatar
EKSAD committed
295
        }
d.arizona's avatar
d.arizona committed
296
        api.create().getSubmitRollingOutlook(body).then(response => {
EKSAD's avatar
EKSAD committed
297 298 299
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
d.arizona's avatar
d.arizona committed
300
                    this.setState({ isSubmit: response.data.data.is_can_submit }, () => {
EKSAD's avatar
EKSAD committed
301 302 303 304 305 306 307 308 309 310 311 312 313 314
                        this.getReport()
                        this.getReportAttachment()
                    })
                }
            }
        })
    }

    getDetailUser() {
        let userId = localStorage.getItem(Constant.USER)
        api.create().getDetailUser(userId).then((response) => {
            if (response.data) {
                if (response.ok) {
                    if (response.data.status === 'success') {
d.arizona's avatar
d.arizona committed
315
                        this.getRole(response.data.data.role_id)
EKSAD's avatar
EKSAD committed
316
                        this.setState({ userCompany: response.data.data.company }, () => {
d.arizona's avatar
d.arizona committed
317
                            this.getCompanySubmitted()
EKSAD's avatar
EKSAD committed
318 319
                        })
                    }
EKSAD's avatar
EKSAD committed
320 321 322 323 324
                }
            }
        })
    }

d.arizona's avatar
d.arizona committed
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
    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' }, () => {
                            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' })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
            }
        })
    }

EKSAD's avatar
EKSAD committed
354 355
    getCompanyActive() {
        api.create().getPerusahaanActive().then((response) => {
EKSAD's avatar
EKSAD committed
356 357 358 359 360 361 362 363 364 365 366 367
            console.log(response);
            if (response.data) {
                if (response.data.status === 'success') {
                    let data = response.data.data
                    let comID = this.state.rawData ? this.state.rawData.company_id : 0
                    let companyData = data.map((item) => {
                        return {
                            company_id: item.company_id,
                            company_name: item.company_name,
                        }
                    })

d.arizona's avatar
d.arizona committed
368
                    if (companyData.length > 0) {
d.arizona's avatar
d.arizona committed
369
                        companyData = companyData.sort((a, b) => a.company_name.localeCompare(b.company_name))
d.arizona's avatar
d.arizona committed
370 371
                    }

EKSAD's avatar
EKSAD committed
372 373 374 375 376 377 378 379
                    let arrayBaru = []
                    this.state.userCompany.map((item, index) => {
                        let indexID = companyData.findIndex((val) => val.company_id == item)
                        if (indexID !== -1) {
                            arrayBaru.push(companyData[indexID])
                        }
                    })

d.arizona's avatar
d.arizona committed
380
                    if (arrayBaru.length > 0) {
d.arizona's avatar
d.arizona committed
381
                        arrayBaru = arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name))
d.arizona's avatar
d.arizona committed
382 383
                    }

EKSAD's avatar
EKSAD committed
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
                    let defaultProps = {
                        options: arrayBaru,
                        getOptionLabel: (option) => titleCase(option.company_name),
                    };
                    let index = arrayBaru.findIndex((val) => val.company_id == comID)
                    this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
                        this.getLastPeriod()
                    })
                } 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 })
            }
        })
    }

    getLastPeriod() {
        api.create().getLastPeriod(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 }, () => {
413 414
                    this.getPeriode()
                })
EKSAD's avatar
EKSAD committed
415 416 417 418
            }
        })
    }

419 420
    getPeriode() {
        api.create().getPeriodeTransaction().then(response => {
d.arizona's avatar
d.arizona committed
421
            console.log(response)
EKSAD's avatar
EKSAD committed
422
            let currentYear = new Date().getFullYear()
423 424
            if (response.data) {
                if (response.data.status === "success") {
EKSAD's avatar
EKSAD committed
425 426 427
                    let data = []
                    response.data.data.map((item) => {
                        if (this.state.isApprover) {
d.arizona's avatar
d.arizona committed
428
                            if (item >= 2000 && item <= (Number(currentYear))) {
EKSAD's avatar
EKSAD committed
429 430 431
                                data.push(item)
                            }
                        } else {
d.arizona's avatar
d.arizona committed
432 433 434 435
                            // if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
                            //     data.push(item)
                            // }
                            if ((item >= 2000) && (item == currentYear || item <= currentYear)) {
EKSAD's avatar
EKSAD committed
436 437 438 439
                                data.push(item)
                            }
                        }
                    })
440 441 442 443 444 445 446 447 448
                    let periodeData = data.map((item) => {
                        return {
                            periode: item,
                        }
                    })
                    let defaultProps = {
                        options: periodeData,
                        getOptionLabel: (option) => option.periode,
                    };
d.arizona's avatar
d.arizona committed
449 450 451 452 453 454
                    let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod === undefined ? String(Number(currentYear)) : this.state.lastPeriod)
                    let dateNow = new Date()
                    dateNow.setMonth(dateNow.getMonth() - 1);
                    let yearNow = dateNow.getFullYear()
                    // let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
                    // console.log(yearNow)
r.kurnia's avatar
r.kurnia committed
455 456
                    // let index = data.sort((a, b) => a - b).findIndex((val) => val == yearNow)
                    let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
d.arizona's avatar
d.arizona committed
457 458 459 460
                    // console.log(data)
                    // console.log(this.state.lastPeriod)
                    // console.log(periodeData)
                    // console.log(index)
d.arizona's avatar
d.arizona committed
461 462 463 464
                    let defaultPropsQuarter = {
                        options: this.state.quarterList,
                        getOptionLabel: (option) => option.name
                    }
r.kurnia's avatar
r.kurnia committed
465 466 467 468 469
                    let indexID = null
                    if (this.state.rawData !== undefined) {
                        indexID = this.state.quarterList.findIndex((val) => String(val.value).toLocaleLowerCase() == this.state.rawData.quarter)
                    }
                    this.setState({ listPeriode: defaultProps, listQuarter: defaultPropsQuarter, quarter: indexID == null ? this.state.quarterList[0] : this.state.quarterList[indexID], periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
d.arizona's avatar
d.arizona committed
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
                        // if (this.state.isApprover === true && this.state.submittedOnly) {
                        this.getDetailUser()
                        // this.getCompanySubmitted()
                        //     console.log('masuk')
                        // } else {
                        // this.getRevision()
                        // }
                    })
                } 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);
EKSAD's avatar
EKSAD committed
485
                        }
486 487
                    })
                }
d.arizona's avatar
d.arizona committed
488 489
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
490 491 492 493 494 495 496
            }
        })
    }

    getRevision() {
        let payload = {
            "company_id": this.state.company.company_id,
d.arizona's avatar
d.arizona committed
497 498
            "periode": this.state.periode.periode,
            "quartal": this.state.quarter.value
499
        }
d.arizona's avatar
d.arizona committed
500
        api.create().getRollingOutlookRevision(payload).then(response => {
501 502 503 504 505 506 507 508 509 510 511 512 513 514
            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] }, () => {
515
                        this.getRollingOutlookID()
516 517 518 519 520 521
                    })
                }
            }
        })
    }

522
    getRollingOutlookID() {
EKSAD's avatar
EKSAD committed
523 524 525 526
        this.setState({ loading: true })
        let payload = {
            "company_id": this.state.company.company_id,
            "periode": this.state.periode.periode,
d.arizona's avatar
d.arizona committed
527 528
            "is_approver": this.state.isApprover,
            "quartal": this.state.quarter.value
EKSAD's avatar
EKSAD committed
529
        }
d.arizona's avatar
d.arizona committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543
        api.create().getRollingOutlookID(payload).then(response => {
            console.log(response)
            if (response) {
                if (response.data.status === "success") {
                    this.setState({
                        rollingOutlookID: response.data.data.rolling_outlook_id,
                        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,
                        loading: false,
                        lastRevision: response.data.data.last_revision,
                        btnApprove: response.data.data.is_submit
                    }, () => {
                        console.log(this.state.lastStatus);
EKSAD's avatar
EKSAD committed
544 545
                        this.historyApproval()
                        this.getLatestPeriodSubmit()
d.arizona's avatar
d.arizona committed
546 547 548
                        // api.create().checkApprover().then(response => {
                        //     console.log(response);
                            if (this.state.isApprover) {
EKSAD's avatar
EKSAD committed
549 550 551 552 553
                                this.setState({ isApprover: true, checkApprover: true })
                            } else {
                                this.setState({ isApprover: this.state.lastStatus === "SUBMITTED" ? true : false, checkApprover: false })
                            }

d.arizona's avatar
d.arizona committed
554
                        // })
d.arizona's avatar
d.arizona committed
555 556 557 558 559 560
                    })
                } else {
                    this.setState({ rollingOutlookID: null, loading: false })
                }
            }
        })
EKSAD's avatar
EKSAD committed
561 562 563 564 565
    }

    historyApproval() {
        let body = {
            "company_id": this.state.company.company_id,
d.arizona's avatar
d.arizona committed
566 567
            "periode": this.state.periode.periode,
            "quartal": this.state.quarter.value
EKSAD's avatar
EKSAD committed
568
        }
d.arizona's avatar
d.arizona committed
569
        api.create().historyApprovalRO(body).then(response => {
EKSAD's avatar
EKSAD committed
570 571 572 573 574 575 576 577 578 579 580
            console.log(response);
            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
                    ]
                })
d.arizona's avatar
d.arizona committed
581
                this.setState({ dataTableHistory, visibleTableHistory: true })
EKSAD's avatar
EKSAD committed
582 583 584 585 586
            }
        })
    }

    approvalSubmission(type) {
d.arizona's avatar
d.arizona committed
587
        // this.scrollToMyRef()
EKSAD's avatar
EKSAD committed
588 589 590 591
        this.setState({ loading: true })
        let body = {
            "approval_id": this.props.location.state == undefined ? this.state.approverID : this.state.rawData.approval_id,
            "status": type,
d.arizona's avatar
d.arizona committed
592 593
            "detail": this.state.detailRevisiCheck,
            "quartal": this.state.quarter.value
EKSAD's avatar
EKSAD committed
594 595 596 597
        }
        let payload = {
            "company_id": this.state.company.company_id,
            "min_periode": moment(this.state.minDateRevision).format('YYYY-MM-DD'),
d.arizona's avatar
d.arizona committed
598
            "periode": this.state.periode.periode,
d.arizona's avatar
d.arizona committed
599 600
            "max_periode": moment(this.state.maxDateRevision).format('YYYY-MM-DD'),
            "quartal": this.state.quarter.value
EKSAD's avatar
EKSAD committed
601 602
        }
        console.log(payload)
d.arizona's avatar
d.arizona committed
603
        api.create().approvalRolling(body).then((res) => {
EKSAD's avatar
EKSAD committed
604 605
            console.log(res)
            this.setState({ loading: false }, () => {
606
                this.getRollingOutlookID()
EKSAD's avatar
EKSAD committed
607 608
            })
            if (type == 'revision') {
d.arizona's avatar
d.arizona committed
609
                api.create().createPeriodeRevisionRO(payload).then((res) => console.log(res))
EKSAD's avatar
EKSAD committed
610 611 612 613 614 615 616 617
            }
        })
    }

    clickDetail(item, id, revision, status) {
        console.log(this.state.dataForRevision);
        this.state.dataForRevision.map(i => {
            if (i.report_name === item) {
d.arizona's avatar
d.arizona committed
618
                if (i.revision == revision) {
EKSAD's avatar
EKSAD committed
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
                    this.setState({ prevRevision: true })
                } else {
                    this.setState({ prevRevision: false })
                }
            }
        })
        this.setState({
            report_id: id,
            revisionTable: revision,
            status: status
        }, () => {
            if (item === 'Balance Sheet') {
                this.setState({
                    visibleRollingOutlook: false,
                    visibleBS: true,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleTP: false,
r.kurnia's avatar
r.kurnia committed
637
                    visibleCF: false,
EKSAD's avatar
EKSAD committed
638 639 640 641 642 643 644 645
                })
            } else if (item === 'Profit Loss') {
                this.setState({
                    visibleRollingOutlook: false,
                    visibleBS: false,
                    visiblePL: true,
                    visibleCAT: false,
                    visibleTP: false,
r.kurnia's avatar
r.kurnia committed
646 647 648 649 650 651 652 653 654 655
                    visibleCF: false,
                })
            } else if (item === 'Cash Flow') {
                this.setState({
                    visibleRollingOutlook: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleTP: false,
                    visibleCF: true,
EKSAD's avatar
EKSAD committed
656 657 658 659 660 661 662 663
                })
            } else if (item === 'Tax Planning') {
                this.setState({
                    visibleRollingOutlook: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: false,
                    visibleTP: true,
r.kurnia's avatar
r.kurnia committed
664
                    visibleCF: false,
EKSAD's avatar
EKSAD committed
665
                })
d.arizona's avatar
d.arizona committed
666
            } else if (item === 'CAT') {
EKSAD's avatar
EKSAD committed
667 668 669 670 671 672
                this.setState({
                    visibleRollingOutlook: false,
                    visibleBS: false,
                    visiblePL: false,
                    visibleCAT: true,
                    visibleTP: false,
r.kurnia's avatar
r.kurnia committed
673
                    visibleCF: false,
EKSAD's avatar
EKSAD committed
674
                })
d.arizona's avatar
d.arizona committed
675
            }
EKSAD's avatar
EKSAD committed
676
        })
EKSAD's avatar
EKSAD committed
677 678
    }

679 680 681 682 683 684 685 686 687 688 689 690 691 692
    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();
EKSAD's avatar
EKSAD committed
693
                formData.append("revision", Number(this.state.revision.revision));
694 695
                formData.append("companyId", this.state.company.company_id);
                formData.append("periode", Number(this.state.periode.periode));
rifkaki's avatar
rifkaki committed
696
                formData.append("quartal", this.state.quarter.value);
697 698 699 700 701 702 703
                formData.append("file", event);
                this.setState({ formData })
            }
        })
    }

    uploadAttachment(formData) {
rifkaki's avatar
rifkaki committed
704 705 706 707 708 709 710 711
        var object = {};
        formData.forEach(function (value, key) {
            object[key] = value;
        });
        var json = JSON.stringify(object);
        console.log(object)
        console.log(json)
        api.create().uploadAttachmentRO(formData).then(response => {
rifkaki's avatar
rifkaki committed
712
            console.log(response)
713 714 715
            if (response.data) {
                if (response.data.status === "success") {
                    this.setState({ visibleUpload: false }, () => {
716
                        this.getRollingOutlookID()
EKSAD's avatar
EKSAD committed
717 718 719 720 721 722 723
                    })
                }
            }
        })
    }

    deleteAttachment(item) {
rifkaki's avatar
rifkaki committed
724
        api.create().deleteAttachmentRO(item.attachment_id).then(response => {
EKSAD's avatar
EKSAD committed
725 726
            if (response.data) {
                if (response.data.status === "success") {
727
                    this.getRollingOutlookID()
EKSAD's avatar
EKSAD committed
728 729 730 731 732 733 734 735 736
                }
            }
        })
    }

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

Riri Novita's avatar
Riri Novita committed
737
    saveToRollingOutlook(data) {
EKSAD's avatar
EKSAD committed
738 739 740 741 742 743
        this.setState({ loading: true })
        // console.log(JSON.stringify(data));
        api.create('UPLOAD').createSubmitReport(data).then(response => {
            console.log(response);
            if (response.data) {
                if (response.data.status === "success") {
744
                    this.getRollingOutlookID()
EKSAD's avatar
EKSAD committed
745 746
                } else {
                    this.setState({ loading: false }, () => {
747
                        this.getRollingOutlookID()
748 749
                    })
                }
EKSAD's avatar
EKSAD committed
750 751
            } else {
                this.setState({ loading: false }, () => {
752
                    this.getRollingOutlookID()
EKSAD's avatar
EKSAD committed
753
                })
754 755 756
            }
        })
    }
EKSAD's avatar
EKSAD committed
757

EKSAD's avatar
EKSAD committed
758 759 760 761
    async downloadAttachment(fileurl, name) {
        let length = name.split(".").length
        let fileType = name.split(".")[length - 1]
        console.log(fileType);
rifkaki's avatar
rifkaki committed
762 763 764 765 766 767
        // console.log(fileurl);
        let indexStrip = String(fileurl).indexOf("-")
        let fileName = String(fileurl).substr(indexStrip + 1, String(fileurl).length)
        let cobaSplit = String(fileName).split("-")
        let mapSplit = ""
        cobaSplit.map((item, index) => {
d.arizona's avatar
d.arizona committed
768 769
            if (item != "") {
                mapSplit += index == 0 ? `${titleCase(item)}` : ` ${item}`
rifkaki's avatar
rifkaki committed
770 771 772
            }
        })
        // console.log(mapSplit);
faisalhamdi's avatar
faisalhamdi committed
773
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/download_attachment?fileName=${fileurl}&&fileType=${fileType}`
EKSAD's avatar
EKSAD committed
774 775
        // console.log(url);
        let res = await fetch(
faisalhamdi's avatar
faisalhamdi committed
776
            `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/master_budget/download_attachment?fileName=${fileurl}&&fileType=${fileType}`
EKSAD's avatar
EKSAD committed
777 778 779 780 781 782 783
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
d.arizona's avatar
d.arizona committed
784
            a.download = "(Rolling Outlook Attachment) - " + mapSplit;
EKSAD's avatar
EKSAD committed
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
            a.click();
        }
    }

    validate() {
        this.setState({ loading: true })
        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 = {
808
                rolling_outlook_id: this.state.rollingOutlookID
EKSAD's avatar
EKSAD committed
809
            }
d.arizona's avatar
d.arizona committed
810
            api.create().submitRollingOutlook(body).then(response => {
EKSAD's avatar
EKSAD committed
811 812
                console.log(response);
                if (response.data) {
d.arizona's avatar
d.arizona committed
813
                    if (response.data.status === "success") {
814
                        this.getRollingOutlookID()
EKSAD's avatar
EKSAD committed
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831
                    }
                }
            })
        } else {
            this.setState({ alert: true, messageAlert: 'Data Is Not Complete', tipeAlert: 'warning', loading: false })
        }
        // if (array.includes("not-yet" || "draft")) {
        //     console.log('gagal');
        // } else {
        //     console.log('masuk');
        // }

    }

    validateRevision() {
        let arrayRevisi = this.state.detailRevisiCheck
        let remarksKosong = 0
d.arizona's avatar
d.arizona committed
832
        arrayRevisi.map((item, index) => {
EKSAD's avatar
EKSAD committed
833 834 835 836 837 838 839 840 841 842 843
            if (item.remarks == "") {
                remarksKosong += 1
            }
        })
        if (remarksKosong > 0) {
            this.setState({ alert: true, messageAlert: 'Remarks Cannot be Empty', tipeAlert: 'error' })
        } else {
            this.setState({ visibleRevision: false }, () => this.approvalSubmission('revision'))
        }
    }

EKSAD's avatar
EKSAD committed
844
    render() {
EKSAD's avatar
EKSAD committed
845 846
        const handleMaxDate = () => {
            let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
d.arizona's avatar
d.arizona committed
847
            return handleDate < 0 ? moment(this.state.minDateRevision).format('YYYY/MM/DD') : moment(this.state.maxDateRevision).format('YYYY/MM/DD')
EKSAD's avatar
EKSAD committed
848 849
        }
        const columns = ["#", "Report Type",
EKSAD's avatar
EKSAD committed
850
            {
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883
                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 >
                        );
                    }
                }
            }, {
EKSAD's avatar
EKSAD committed
884 885 886 887 888
                name: "Status",
                options: {
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ display: 'flex' }}>
889
                                {val === "submitted" || val === "approved" ?
EKSAD's avatar
EKSAD committed
890 891 892
                                    <span>COMPLETED</span> :
                                    val === "draft" ?
                                        <span>DRAFT</span> :
Deni Rinaldi's avatar
Deni Rinaldi committed
893 894 895 896
                                        val === "incomplete" ?
                                            <span>INCOMPLETE</span> :
                                            val === "revision" ?
                                                <span>REVISION</span> :
r.kurnia's avatar
r.kurnia committed
897
                                                val === "approval_proccess" ?
Deni Rinaldi's avatar
Deni Rinaldi committed
898 899 900 901 902 903 904 905
                                                    <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 }} />
EKSAD's avatar
EKSAD committed
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920
                                }
                            </div >
                        );
                    }
                }
            },
            {
                name: "Action",
                options: {
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ display: 'flex' }}>
                                <button
                                    style={{
                                        backgroundColor: 'transparent',
EKSAD's avatar
EKSAD committed
921
                                        cursor: tableMeta.rowData[5] ? 'pointer' : 'default',
EKSAD's avatar
EKSAD committed
922 923
                                        borderColor: 'transparent'
                                    }}
924
                                    onClick={() =>
d.arizona's avatar
d.arizona committed
925
                                        tableMeta.rowData[5] == true ?
EKSAD's avatar
EKSAD committed
926
                                            this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
d.arizona's avatar
d.arizona committed
927
                                            : null
928
                                    }
EKSAD's avatar
EKSAD committed
929
                                >
EKSAD's avatar
EKSAD committed
930 931 932 933
                                    {/* {this.state.isApprover == true ? 
                                        (tableMeta.rowData[5] ? '#5198ea' : 'GrayText') :
                                        (this.state.lastRevision == 0 ? (tableMeta.rowData[5] ? '#5198ea' : 'GrayText') :
                                        (tableMeta.rowData[3] !== 'submitted' ? '#5198ea' : 'GrayText'))} */}
934
                                    <Typography style={{ color: tableMeta.rowData[5] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography>
EKSAD's avatar
EKSAD committed
935 936 937 938 939
                                </button>
                            </div >
                        );
                    }
                }
940 941 942 943 944 945
            }, {
                name: "",
                options: { display: false }
            }, {
                name: "",
                options: { display: false }
EKSAD's avatar
EKSAD committed
946
            }]
EKSAD's avatar
EKSAD committed
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006

        const columnsHistory = [
            "Name", "Status", "Remarks", "Revision Item", "Date"
        ]

        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>
                        )
                    }
                }
            }
EKSAD's avatar
EKSAD committed
1007
        ]
EKSAD's avatar
EKSAD committed
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038

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

            let indexId = detailRevisiCheck.findIndex((val) => val.report_id == value[0])
            if (indexId == -1) {
                detailRevisiCheck.push(payload)
            } else {
                detailRevisiCheck.splice(indexId, 1)
            }
            this.setState({ detailRevisiCheck })
            console.log(detailRevisiCheck)
        }

EKSAD's avatar
EKSAD committed
1039 1040 1041 1042 1043 1044 1045 1046
        const options = {
            filter: false,
            sort: false,
            responsive: "scroll",
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
EKSAD's avatar
EKSAD committed
1047
            pagination: false,
EKSAD's avatar
EKSAD committed
1048 1049
            search: false
        }
EKSAD's avatar
EKSAD committed
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070
        const optionsRevision = {
            filter: false,
            sort: false,
            responsive: "scroll",
            print: false,
            download: false,
            selectableRows: false,
            viewColumns: false,
            pagination: false,
            search: false
        }
        const loadingComponent = (
            <div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );
EKSAD's avatar
EKSAD committed
1071
        return (
EKSAD's avatar
EKSAD committed
1072 1073 1074 1075 1076 1077 1078
            <div style={{ flex: 1, backgroundColor: '#f8f8f8' }} ref={this.myRef}>
                <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}
EKSAD's avatar
EKSAD committed
1079 1080 1081
                {this.state.visibleRollingOutlook && (
                    <div>
                        <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
EKSAD's avatar
EKSAD committed
1082
                            <Typography style={{ fontSize: '16px', color: 'white' }}>Rolling Outlook & CAT Revision</Typography>
EKSAD's avatar
EKSAD committed
1083 1084 1085 1086
                        </div>
                        <div style={{ padding: 20, width: '100%' }}>
                            <Paper style={{ paddingTop: 10 }}>
                                <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
EKSAD's avatar
EKSAD committed
1087
                                    <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Rolling Outlook & CAT</Typography>
EKSAD's avatar
EKSAD committed
1088 1089 1090
                                </div>
                                <div style={{ padding: 20 }}>
                                    <div>
1091 1092
                                        <Autocomplete
                                            {...this.state.listPeriode}
EKSAD's avatar
EKSAD committed
1093
                                            id="periode"
1094
                                            onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
d.arizona's avatar
d.arizona committed
1095 1096
                                                this.setState({ visibleTableHistory: false })
                                                if (this.state.listCompany == null) {
EKSAD's avatar
EKSAD committed
1097 1098 1099 1100
                                                    this.getCompanySubmitted()
                                                } else {
                                                    this.getRevision()
                                                }
1101
                                            })}
EKSAD's avatar
EKSAD committed
1102
                                            disabled={this.state.intent === 'Home' ? true : false}
1103 1104
                                            disableClearable
                                            style={{ width: 250 }}
EKSAD's avatar
EKSAD committed
1105 1106 1107
                                            renderInput={(params) =>
                                                <TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }}
                                                />}
EKSAD's avatar
EKSAD committed
1108
                                            value={this.state.periode}
1109
                                        />
EKSAD's avatar
EKSAD committed
1110
                                    </div>
d.arizona's avatar
d.arizona committed
1111 1112 1113 1114 1115 1116 1117
                                    <div style={{ marginTop: 20 }}>
                                        <Autocomplete
                                            {...this.state.listQuarter}
                                            id="company"
                                            disabled={this.state.intent === 'Home' ? true : false}
                                            onChange={(event, newInputValue) => this.setState({ quarter: newInputValue }, () => {
                                                this.setState({ visibleTableHistory: false })
d.arizona's avatar
d.arizona committed
1118 1119 1120 1121 1122
                                                if (this.state.listCompany == null) {
                                                    this.getCompanySubmitted()
                                                } else {
                                                    this.getRevision()
                                                }
d.arizona's avatar
d.arizona committed
1123 1124 1125
                                            })}
                                            disableClearable
                                            style={{ width: 250 }}
d.arizona's avatar
d.arizona committed
1126
                                            renderInput={(params) => <TextField {...params} label="Quarter" margin="normal" style={{ marginTop: 7 }} />}
d.arizona's avatar
d.arizona committed
1127 1128 1129
                                            value={this.state.quarter}
                                        />
                                    </div>
d.arizona's avatar
d.arizona committed
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
                                    <div style={{ marginTop: 20 }}>
                                        <Autocomplete
                                            multiple
                                            id="tags-standard"
                                            options={this.state.listStatus}
                                            getOptionLabel={(option) => option.name}
                                            style={{ width: 250 }}
                                            onChange={(event, newInputValue) => {
                                                this.setState({ selectedStatus: newInputValue, loading: true }, () => {
                                                    console.log(newInputValue);
                                                    this.getCompanySubmitted()
                                                })
                                            }}
                                            value={this.state.selectedStatus}
                                            renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />}
                                        />
                                    </div>
EKSAD's avatar
EKSAD committed
1147 1148 1149 1150
                                    <div style={{ marginTop: 20 }}>
                                        <Autocomplete
                                            {...this.state.listCompany}
                                            id="company"
EKSAD's avatar
EKSAD committed
1151
                                            disabled={this.state.intent === 'Home' ? true : false}
1152
                                            onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
EKSAD's avatar
EKSAD committed
1153 1154
                                                this.setState({ visibleTableHistory: false })
                                                this.getRevision()
1155
                                            })}
EKSAD's avatar
EKSAD committed
1156 1157 1158 1159 1160 1161 1162
                                            disableClearable
                                            style={{ width: 250 }}
                                            renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.company}
                                        />
                                    </div>
                                    <div style={{ marginTop: 20 }}>
EKSAD's avatar
EKSAD committed
1163
                                        {/* <Autocomplete
1164 1165 1166 1167 1168 1169
                                            {...this.state.listRevision}
                                            id="revision"
                                            onChange={(event, newInputValue) => this.setState({ revision: newInputValue }, () => {
                                                this.getReport()
                                                this.getReportAttachment()
                                            })}
EKSAD's avatar
EKSAD committed
1170
                                            disabled={true}
1171 1172 1173 1174
                                            disableClearable
                                            style={{ width: 250 }}
                                            renderInput={(params) => <TextField {...params} label="Revision" margin="normal" style={{ marginTop: 7 }} />}
                                            value={this.state.revision}
EKSAD's avatar
EKSAD committed
1175 1176
                                        /> */}
                                        <TextField disabled={true} label="Revision" margin="normal" style={{ marginTop: 7, width: 250 }} value={this.state.lastRevision} />
EKSAD's avatar
EKSAD committed
1177 1178 1179
                                    </div>

                                    <div style={{ marginTop: 20 }}>
EKSAD's avatar
EKSAD committed
1180 1181 1182 1183 1184 1185 1186
                                        <MuiThemeProvider theme={getMuiTheme()}>
                                            <MUIDataTable
                                                data={this.state.dataTable}
                                                columns={columns}
                                                options={options}
                                            />
                                        </MuiThemeProvider>
EKSAD's avatar
EKSAD committed
1187 1188 1189 1190 1191
                                    </div>
                                    <div style={{ display: 'flex', marginTop: 20 }}>
                                        <div style={{ width: '50%' }}>
                                            <Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
                                        </div>
rifkaki's avatar
rifkaki committed
1192
                                        {!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
EKSAD's avatar
EKSAD committed
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206
                                            <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>
                                        )}
EKSAD's avatar
EKSAD committed
1207 1208 1209
                                    </div>
                                    <div style={{ display: 'flex', marginTop: 10 }}>
                                        <div style={{ width: '50%', paddingLeft: 20 }}>
1210
                                            {this.state.listAttachment.length > 0 ?
EKSAD's avatar
EKSAD committed
1211
                                                this.state.listAttachment.map((item, index) => {
1212
                                                    return (
EKSAD's avatar
EKSAD committed
1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232
                                                        <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>
1233 1234 1235 1236
                                                    )
                                                })
                                                : null
                                            }
EKSAD's avatar
EKSAD committed
1237
                                        </div>
rifkaki's avatar
rifkaki committed
1238
                                        {!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
EKSAD's avatar
EKSAD committed
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
                                            <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>
                                        )}
EKSAD's avatar
EKSAD committed
1261
                                    </div>
EKSAD's avatar
EKSAD committed
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298
                                    {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> : 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={options}
                                                />
                                            </MuiThemeProvider>
                                        </div>
                                    )}
EKSAD's avatar
EKSAD committed
1299
                                </div>
EKSAD's avatar
EKSAD committed
1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384
                                {this.state.checkApprover === true ?
                                    this.state.lastStatus === 'WAITING FOR REVIEW' ?
                                        <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('review')
                                                }
                                            >
                                                <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>
                                                </div>
                                            </button>
                                        </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">
                                                    <button
                                                        style={{
                                                            backgroundColor: 'transparent',
                                                            cursor: 'pointer',
                                                            borderColor: 'transparent',
                                                            outline: 'none',
                                                        }}
                                                        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>
                                                </div>
                                                <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
                                                    <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 === true ?
                                        <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
                                }
EKSAD's avatar
EKSAD committed
1385 1386 1387 1388 1389
                            </Paper>

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

                {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>
                )}
Deni Rinaldi's avatar
Deni Rinaldi committed
1424 1425 1426 1427

                {this.state.visibleBS && (
                    <BalanceSheetRO
                        width={this.props.width}
1428
                        height={this.props.height}
Deni Rinaldi's avatar
Deni Rinaldi committed
1429
                        open={this.props.open}
1430 1431 1432 1433 1434
                        report_id={this.state.report_id}
                        company={this.state.company}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
                        rollingOutlookID={this.state.rollingOutlookID}
d.arizona's avatar
d.arizona committed
1435
                        refresh={this.getRollingOutlookID.bind(this)}
Deni Rinaldi's avatar
Deni Rinaldi committed
1436
                        onClickClose={() => this.setState({ visibleBS: false, visibleRollingOutlook: true })}
d.arizona's avatar
d.arizona committed
1437
                        isApprover={this.state.isApprover}
d.arizona's avatar
d.arizona committed
1438
                        quarter={this.state.quarter.value}
d.arizona's avatar
d.arizona committed
1439
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
d.arizona's avatar
d.arizona committed
1440 1441
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
Deni Rinaldi's avatar
Deni Rinaldi committed
1442 1443
                    />
                )}
EKSAD's avatar
EKSAD committed
1444

Riri Novita's avatar
Riri Novita committed
1445 1446 1447
                {this.state.visiblePL && (
                    <ProfitLossRO
                        width={this.props.width}
Riri Novita's avatar
Riri Novita committed
1448
                        height={this.props.height}
Riri Novita's avatar
Riri Novita committed
1449
                        open={this.props.open}
Riri Novita's avatar
Riri Novita committed
1450 1451 1452 1453 1454
                        report_id={this.state.report_id}
                        company={this.state.company}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
                        rollingOutlookID={this.state.rollingOutlookID}
Riri Novita's avatar
Riri Novita committed
1455
                        onClickClose={() => this.setState({ visiblePL: false, visibleRollingOutlook: true })}
d.arizona's avatar
d.arizona committed
1456 1457
                        refresh={this.getRollingOutlookID.bind(this)}
                        quarter={this.state.quarter.value}
d.arizona's avatar
d.arizona committed
1458 1459
                        isApprover={this.state.isApprover}
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
d.arizona's avatar
d.arizona committed
1460 1461
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
Riri Novita's avatar
Riri Novita committed
1462 1463 1464
                    />
                )}

r.kurnia's avatar
r.kurnia committed
1465 1466 1467 1468 1469 1470 1471 1472 1473
                {this.state.visibleTP && (
                    <TaxPlanningRO
                        width={this.props.width}
                        height={this.props.height}
                        open={this.props.open}
                        report_id={this.state.report_id}
                        company={this.state.company}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
1474
                        rollingOutlookID={this.state.rollingOutlookID}
r.kurnia's avatar
r.kurnia committed
1475
                        onClickClose={() => this.setState({ visibleTP: false, visibleRollingOutlook: true })}
d.arizona's avatar
d.arizona committed
1476
                        refresh={this.getRollingOutlookID.bind(this)}
r.kurnia's avatar
r.kurnia committed
1477 1478
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
d.arizona's avatar
d.arizona committed
1479
                        quarter={this.state.quarter.value}
d.arizona's avatar
d.arizona committed
1480
                        isApprover={this.state.isApprover}
r.kurnia's avatar
r.kurnia committed
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
                    />
                )}

                {this.state.visibleCF && (
                    <CashFlowRO
                        width={this.props.width}
                        height={this.props.height}
                        open={this.props.open}
                        report_id={this.state.report_id}
                        company={this.state.company}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
                        rollingOutlookID={this.state.rollingOutlookID}
                        onClickClose={() => this.setState({ visibleCF: false, visibleRollingOutlook: true })}
                        refresh={this.getRollingOutlookID.bind(this)}
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
                        quarter={this.state.quarter.value}
                        isApprover={this.state.isApprover}
d.arizona's avatar
d.arizona committed
1501
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
r.kurnia's avatar
r.kurnia committed
1502 1503 1504
                    />
                )}

faisalhamdi's avatar
faisalhamdi committed
1505
                {this.state.visibleCAT && (
faisalhamdi's avatar
faisalhamdi committed
1506
                    <CorporateAnnualTargetRO
faisalhamdi's avatar
faisalhamdi committed
1507
                        width={this.props.width}
faisalhamdi's avatar
faisalhamdi committed
1508
                        height={this.props.height}
faisalhamdi's avatar
faisalhamdi committed
1509
                        open={this.props.open}
faisalhamdi's avatar
faisalhamdi committed
1510 1511 1512 1513 1514
                        report_id={this.state.report_id}
                        company={this.state.company}
                        revision={this.state.revisionTable}
                        periode={this.state.periode.periode}
                        rollingOutlookID={this.state.rollingOutlookID}
faisalhamdi's avatar
faisalhamdi committed
1515
                        onClickClose={() => this.setState({ visibleCAT: false, visibleRollingOutlook: true })}
faisalhamdi's avatar
faisalhamdi committed
1516
                        refresh={this.getRollingOutlookID.bind(this)}
faisalhamdi's avatar
faisalhamdi committed
1517
                        quarter={this.state.quarter.value}
faisalhamdi's avatar
faisalhamdi committed
1518 1519
                        isApprover={this.state.isApprover}
                        prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
faisalhamdi's avatar
faisalhamdi committed
1520 1521
                        status={this.state.status}
                        lastStatus={this.state.lastStatus}
faisalhamdi's avatar
faisalhamdi committed
1522 1523 1524
                    />
                )}

EKSAD's avatar
EKSAD committed
1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564

                {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"
d.arizona's avatar
d.arizona committed
1565
                                                onChange={(e) => this.setState({ minDateRevision: moment(e).format('YYYY/MM/DD') }, () => this.setState({ maxDateRevision: handleMaxDate() }))}
EKSAD's avatar
EKSAD committed
1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591
                                                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"
d.arizona's avatar
d.arizona committed
1592
                                                onChange={(e) => this.setState({ maxDateRevision: moment(e).format('YYYY/MM/DD') })}
EKSAD's avatar
EKSAD committed
1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640
                                                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>
                )}
EKSAD's avatar
EKSAD committed
1641 1642 1643 1644
            </div >
        );
    }
}