ProgressReport.js 31.6 KB
Newer Older
d.arizona's avatar
d.arizona committed
1
import React, { Component } from 'react';
Riri Novita's avatar
Riri Novita committed
2
import { Typography, Paper, TextField, Snackbar, withStyles} from '@material-ui/core';
Faisal Hamdi's avatar
Faisal Hamdi committed
3 4 5
import Images from '../../assets/Images';
import Constant from '../../library/Constant';
import api from '../../api';
d.arizona's avatar
d.arizona committed
6 7 8
import { PropagateLoader } from 'react-spinners';
import { format } from 'date-fns';
import Autocomplete from '@material-ui/lab/Autocomplete';
Faisal Hamdi's avatar
Faisal Hamdi committed
9
import TableProgressReport from './TableProgressReport'
d.arizona's avatar
d.arizona committed
10
import ReactTooltip from "react-tooltip";
Riri Novita's avatar
Riri Novita committed
11 12 13 14
import MuiAlert from '@material-ui/lab/Alert';

const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
d.arizona's avatar
d.arizona committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

class ReportProgress extends Component {
    constructor(props) {
        super(props)
        this.state = {
            listApproval: null,
            listCategory: {
                options: [{ name: 'Report Status', value: 'report-status' }, { name: 'Approval Progress', value: 'approval-progress' }],
                getOptionLabel: (option) => option.name,
            },
            listReportType: null,
            listQuarter: {
                options: [{ name: 'Q1', value: 'q1' }, { name: 'Q2', value: 'q2' }, { name: 'Q3', value: 'q3' }],
                getOptionLabel: (option) => option.name,
            },
            listMonth: null,
            listPeriodeMB: null,
            quarter: {
                name: 'Q1', value: 'q1'
            },
            category: {
                name: 'Report Status', value: 'report-status'
            },
            month: null,
            periodeMB: null,
            reportType: null,
Riri Novita's avatar
Riri Novita committed
41 42 43 44
            dataTable: [],
            alert: false,
            tipeAlert: '',
            messageAlert: '',
d.arizona's avatar
d.arizona committed
45 46 47 48 49
        }
    }

    componentDidMount() {
        this.getMonth()
Faisal Hamdi's avatar
Faisal Hamdi committed
50 51
        // console.log(this.state.listCategory);
        // console.log(this.state.category);
d.arizona's avatar
d.arizona committed
52 53 54
    }

    getMonth() {
Faisal Hamdi's avatar
Faisal Hamdi committed
55
        this.setState({ loading: true })
d.arizona's avatar
d.arizona committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
        api.create().getMonthTransaction().then(response => {
            let dateNow = new Date()
            dateNow.setMonth(dateNow.getMonth() - 1);
            let month = format(dateNow, 'MMMM')
            if (response.data) {
                if (response.data.status === "success") {
                    let data = response.data.data
                    let monthData = data.map((item) => {
                        return {
                            month_id: item.id,
                            month_value: String(item.month_name).substr(0, 3)
                        }
                    })
                    let defaultProps = {
                        options: monthData,
                        getOptionLabel: (option) => option.month_value,
                    };
                    let index = data.findIndex((val) => val.month_name == month)
                    this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => {
                        this.getPeriode()
                    })
                } else {
78 79 80 81 82 83 84 85
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
d.arizona's avatar
d.arizona committed
86 87
                }
            } else {
88
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
89 90 91 92 93 94 95 96 97 98
            }
        })
    }

    getPeriode() {
        let currentYear = new Date().getFullYear()
        let MB = []
        for (var i = 2000; i <= currentYear; i++) {
            MB.push({ name: String(i), value: i })
            if (i == currentYear) {
syadziy's avatar
syadziy committed
99
                MB.push({ name: String(i + 1), value: i + 1})
d.arizona's avatar
d.arizona committed
100 101 102 103 104 105 106 107 108 109 110 111
            }
        }

        let defaultPropsMB = {
            options: MB,
            getOptionLabel: (option) => option.name,
        };

        this.setState({
            listPeriodeMB: defaultPropsMB,
            periodeMB: MB[MB.length - 1],
        }, () => {
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
            this.getReportType()
            // console.log(this.state.listMonth)
            // console.log(this.state.listPeriodeMB)
        })
    }

    getReportType() {
        let arrayReportType = [
            {
                name: 'Master Budget',
                value: 0
            }, {
                name: 'Monthly Report',
                value: 1
            }, {
                name: 'Rolling Outlook',
                value: 2
            }, {
                name: 'Outlook PA',
                value: 3
            },
        ]

        let defaultProps = {
            options: arrayReportType,
            getOptionLabel: (option) => option.name,
        };
        this.setState({ listReportType: defaultProps, reportType: arrayReportType[0] }, () => {
            // console.log(this.state.periodeMB)
            this.getDataMonitoring()
            // console.log(this.state.listReportType)
            // console.log(this.state.reportType)
d.arizona's avatar
d.arizona committed
144 145 146
        })
    }

147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
    getDataMonitoring() {
        let payload = {
            "year": this.state.periodeMB.name,
            "month": this.state.month.month_id,
            "quarter": this.state.quarter.value

        }
        console.log(payload)
        if (String(this.state.reportType.name).toLocaleUpperCase().includes('MASTER')) {
            this.getMonitoringMB(payload)
        } else if (String(this.state.reportType.name).toLocaleUpperCase().includes('MONTHLY')) {
            this.getMonitoringMR(payload)
        } else if (String(this.state.reportType.name).toLocaleUpperCase().includes('ROLLING')) {
            this.getMonitoringRO(payload)
        } else {
            this.getMonitoringOLPA(payload)
        }
    }

    getMonitoringMB(payload) {
        let dataTable = []
        api.create().getMonitoringMB(payload).then((response) => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    let data = response.data.data
                    data.map((item,index) => {
d.arizona's avatar
d.arizona committed
174
                        let report = []
r.kurnia's avatar
r.kurnia committed
175 176
                        let statusSubmission = String(item.submission_status).toLocaleUpperCase()
                        let statusOI = String(item.operating_indicator).toLocaleUpperCase()
d.arizona's avatar
d.arizona committed
177 178 179
                        item.report.map((items,index) => {
                            let statusReport = String(items.status_report).toLocaleUpperCase()
                            report.push({report_name: items.report_name, status_report: (statusReport == 'APPROVED' || statusReport == 'REVISION' || statusReport == 'COMPLETED') ? (statusReport + ' - ' + items.report_date) : statusReport })
d.arizona's avatar
d.arizona committed
180
                        })
d.arizona's avatar
d.arizona committed
181 182 183
                        report.push(
                            {report_name: 'Operating Indicator', status_report: statusOI}, 
                            {report_name: 'Submission Status', status_report: (statusSubmission == 'APPROVED' || statusSubmission == 'REVISION' || statusSubmission == 'COMPLETED') ? (statusSubmission + ' - ' + item.submissionStatusDate) : statusSubmission})
184
                        dataTable.push([
r.kurnia's avatar
r.kurnia committed
185
                            item.company_name,
Riri Novita's avatar
Riri Novita committed
186
                            report,
Riri Novita's avatar
Riri Novita committed
187 188 189
                            item.automatic_reminder_report_date,
                            item.manual_reminder_report_status,
                            item.manual_reminder_report_date,
Riri Novita's avatar
Riri Novita committed
190
                            item.company_id,
191 192
                        ])
                    })
d.arizona's avatar
d.arizona committed
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
                    // data.map((item,index) => {
                    //     let report = []
                    //     item.report.map((items,indexs) => {
                    //         if (!String(items.report_name).includes('Indicator') && !String(items.report_name).includes('OLPA')) {
                    //             if (String(items.report_name).includes('Fixed')) {
                    //                 report.push({...items, status_report: (items.report_date == null? items.status_report : items.status_report + ' - ' + items.report_date), report_name: 'Fixed Assets Movement'})
                    //             } else {
                    //                 report.push({...items, status_report: (items.report_date == null? items.status_report : items.status_report + ' - ' + items.report_date)})
                    //             }
                    //         }
                    //     })
                    //     report.push({report_name: 'Operating Indicator', status_report: item.operatingIndicator}, {report_name: 'Submission Status', status_report: (item.submissionStatusDate == null? item.submissionStatus : item.submissionStatus + ' - ' + item.submissionStatusDate)})
                    //     dataTable.push([
                    //         item.companyName,
                    //         report
                    //     ])
                    // })
Riri Novita's avatar
Riri Novita committed
210
                    // console.log(dataTable)
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
                    this.setState({dataTable, loading: false})
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
            }
        })    
    }

    getMonitoringMR(payload) {
        let dataTable = []
        api.create().getMonitoringMR(payload).then((response) => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    let data = response.data.data
                    data.map((item,index) => {
                        let report = item.report
                        report.push({report_name: 'Operating Indicator', status_report: item.operating_indicator}, {report_name: 'Monthly Status', status_report: item.monthly_status})
                        dataTable.push([
                            item.company_name,
Riri Novita's avatar
Riri Novita committed
240 241 242 243 244
                            report,
                            item.automatic_reminder_report_date,
                            item.manual_reminder_report_status,
                            item.manual_reminder_report_date,
                            item.company_id,
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
                        ])
                    })
                    this.setState({dataTable, loading: false})
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' , loading: false}, () => {
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
            }
        })    
    }

    getMonitoringRO(payload) {
        let dataTable = []
        api.create().getMonitoringRO(payload).then((response) => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    let data = response.data.data
                    data.map((item,index) => {
                        let report = item.report
                        report.push({report_name: 'Operating Indicator', status_report: item.operating_indicator}, {report_name: 'Rolling Status', status_report: item.rolling_status})
                        dataTable.push([
                            item.company_name,
Riri Novita's avatar
Riri Novita committed
276 277 278 279 280
                            report,
                            item.automatic_reminder_report_date,
                            item.manual_reminder_report_status,
                            item.manual_reminder_report_date,
                            item.company_id,
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
                        ])
                    })
                    this.setState({dataTable, loading: false})
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
            }
        })    
    }

    getMonitoringOLPA(payload) {
        let dataTable = []
        api.create().getMonitoringOLPA(payload).then((response) => {
            console.log(response)
            if (response.data) {
                if (response.data.status === "success") {
                    let data = response.data.data
                    data.map((item,index) => {
d.arizona's avatar
d.arizona committed
308
                        let report = []
r.kurnia's avatar
r.kurnia committed
309 310
                        let statusSubmission = String(item.outlook_status).toLocaleUpperCase()
                        let statusOI = String(item.operating_indicator).toLocaleUpperCase()
d.arizona's avatar
d.arizona committed
311 312 313
                        item.report.map((items,index) => {
                            let statusReport = String(items.status_report).toLocaleUpperCase()
                            report.push({report_name: items.report_name, status_report: (statusReport == 'APPROVED' || statusReport == 'REVISION' || statusReport == 'COMPLETED') ? (statusReport + ' - ' + items.report_date) : statusReport })
d.arizona's avatar
d.arizona committed
314
                        })
d.arizona's avatar
d.arizona committed
315 316 317
                        report.push(
                            {report_name: 'Operating Indicator', status_report: statusOI}, 
                            {report_name: 'OLPA Status', status_report: (statusSubmission == 'APPROVED' || statusSubmission == 'REVISION' || statusSubmission == 'COMPLETED') ? (statusSubmission + ' - ' + item.submissionStatusDate) : statusSubmission})
318
                        dataTable.push([
r.kurnia's avatar
r.kurnia committed
319
                            item.company_name,
Riri Novita's avatar
Riri Novita committed
320 321 322 323 324
                            report,
                            item.automatic_reminder_report_date,
                            item.manual_reminder_report_status,
                            item.manual_reminder_report_date,
                            item.company_id,
325
                        ])
d.arizona's avatar
d.arizona committed
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
                    })
                    // data.map((item,index) => {
                        // let report = []
                        // item.report.map((items,indexs) => {
                        //     if (!String(items.report_name).includes('Indicator') && !String(items.report_name).includes('OLPA')) {
                        //         if (String(items.report_name).includes('Fixed')) {
                        //             report.push({...items, status_report: (items.report_date == null? items.status_report : items.status_report + ' - ' + items.report_date), report_name: 'Fixed Assets Movement'})
                        //         } else {
                        //             report.push({...items, status_report: (items.report_date == null? items.status_report : items.status_report + ' - ' + items.report_date)})
                        //         }
                        //     }
                        // })
                        // report.push({report_name: 'Operating Indicator', status_report: item.operatingIndicator}, {report_name: 'OLPA Status', status_report: (item.submissionStatusDate == null? item.submissionStatus : item.submissionStatus + ' - ' + item.submissionStatusDate)})
                        // dataTable.push([
                        //     item.companyName,
                        //     report
                        // ])
d.arizona's avatar
d.arizona committed
343 344 345 346 347 348
                        // let report = item.report
                        // report.push({report_name: 'Operating Indicator', status_report: item.operating_indicator}, {report_name: 'OLPA Status', status_report: item.olpa_status})
                        // dataTable.push([
                        //     item.company_name,
                        //     report
                        // ])
d.arizona's avatar
d.arizona committed
349
                    // })
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
                    this.setState({dataTable, loading: false})
                } else {
                    this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
                        if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
                            setTimeout(() => {
                                localStorage.removeItem(Constant.TOKEN)
                                window.location.reload();
                            }, 1000);
                        }
                    })
                }
            } else {
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
            }
        })    
    }

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

d.arizona's avatar
d.arizona committed
371 372 373 374
    downloadData() {
        let path = ''
        let type = ''
        if (String(this.state.reportType.name).toLocaleUpperCase().includes('MASTER')) {
375
            path = `public/transaction/monitoring/master_budget?periode=${this.state.periodeMB.name}`
d.arizona's avatar
d.arizona committed
376 377
            type = 'Master Budget'
        } else if (String(this.state.reportType.name).toLocaleUpperCase().includes('MONTHLY')) {
378
            path = `public/transaction/monitoring/monthly_report?months=${this.state.month.month_id}&&periode=${this.state.periodeMB.name}`
d.arizona's avatar
d.arizona committed
379 380
            type = `Monthly Report (${this.state.month.month_value})`
        } else if (String(this.state.reportType.name).toLocaleUpperCase().includes('ROLLING')) {
381
            path = `public/transaction/monitoring/rolling_outlook?quartals=${this.state.quarter.value}&&periode=${this.state.periodeMB.name}`
d.arizona's avatar
d.arizona committed
382 383
            type = `Rolling Outlook ${this.state.quarter.name}`
        } else {
384
            path = `public/transaction/monitoring/outlook_pa?periode=${this.state.periodeMB.name}`
d.arizona's avatar
d.arizona committed
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
            type = 'Outlook PA'
        }
        this.downloadAllData(path, type)
    }

    async downloadAllData(path, type) {
        let url = `${process.env.REACT_APP_URL_MAIN_BE}/${path}`
        console.log(url);
        let res = await fetch(
            `${process.env.REACT_APP_URL_MAIN_BE}/${path}`
        )
        res = await res.blob()
        this.setState({ loading: false })
        if (res.size > 0) {
            let url = window.URL.createObjectURL(res);
            let a = document.createElement('a');
            a.href = url;
            a.download = `Progress Report - ${type}.xlsx`;
            a.click();
        }
    }

d.arizona's avatar
d.arizona committed
407
    render() {
Faisal Hamdi's avatar
Faisal Hamdi committed
408

Faisal Hamdi's avatar
Faisal Hamdi committed
409
        const dataTableMB = [
Faisal Hamdi's avatar
Faisal Hamdi committed
410
            ['Tax Planning', '2', 'ABA: Anugerah Buminusantara Abadi', '2021-05-03'],
Faisal Hamdi's avatar
Faisal Hamdi committed
411
            ['CAT', '1', 'ABA: Anugerah Buminusantara Abadi', '2021-05-03'],
Faisal Hamdi's avatar
Faisal Hamdi committed
412 413
            ['Profit Loss', '0', 'ABA: Anugerah Buminusantara Abadi', '2021-05-03']
        ]
Faisal Hamdi's avatar
Faisal Hamdi committed
414 415 416 417 418 419 420

        const dataTableMBStatus = [
            ['ABA: Anugerah Buminusantara Abadi', '2021', 'approved', '2', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved'],
            ['ABA: Anugerah Buminusantara Abadi', '2021', 'approved', '1', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved'],
            ['ABA: Anugerah Buminusantara Abadi', '2021', 'approved', '0', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved', 'Sudah Approved']
        ]

d.arizona's avatar
d.arizona committed
421 422 423 424 425 426 427 428 429 430
        const loadingComponent = (
            <div style={{ position: 'fixed', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
                <PropagateLoader
                    // css={override}
                    size={20}
                    color={"#274B80"}
                    loading={this.state.loading}
                />
            </div>
        );
Faisal Hamdi's avatar
Faisal Hamdi committed
431

d.arizona's avatar
d.arizona committed
432 433
        return (
            <div style={{ flex: 1, backgroundColor: '#f8f8f8', minHeight: this.props.height }}>
434 435 436 437 438
                <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
                    <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
                        {this.state.messageAlert}
                    </Alert>
                </Snackbar>
d.arizona's avatar
d.arizona committed
439 440 441 442 443
                <div>
                    <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                        <Typography style={{ fontSize: '16px', color: 'white' }}>Report Status & Approval Progress Monitoring</Typography>
                    </div>
                    <div style={{ padding: 20, width: '100%' }}>
Faisal Hamdi's avatar
Faisal Hamdi committed
444
                        <Paper style={{ paddingTop: 10, paddingBottom: 50 }}>
d.arizona's avatar
d.arizona committed
445 446 447
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Report Status & Approval Progress</Typography>
                            </div>
448
                            {/* <div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
d.arizona's avatar
d.arizona committed
449 450 451 452 453 454 455
                                <div style={{ marginTop: 15, display: 'flex' }}>
                                    <Autocomplete
                                        {...this.state.listCategory}
                                        id="category"
                                        onChange={(event, newInputValue) => this.setState({ category: newInputValue, loading: true }, () => {
                                            // this.getListUserSubcoRO()
                                            this.getReportType()
Faisal Hamdi's avatar
Faisal Hamdi committed
456
                                            this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
457 458 459 460 461 462 463 464 465 466 467
                                        })}
                                        disableClearable
                                        style={{ minWidth: 210, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Category" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.category}
                                    />
                                    <Autocomplete
                                        {...this.state.listReportType}
                                        id="report-type"
                                        onChange={(event, newInputValue) => this.setState({ reportType: newInputValue, loading: true }, () => {
                                            // this.getListUserSubcoRO()
Faisal Hamdi's avatar
Faisal Hamdi committed
468
                                            this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
469 470 471 472 473 474 475
                                        })}
                                        disableClearable
                                        style={{ minWidth: 210, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Report Type" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.reportType}
                                    />
                                </div>
476
                            </div> */}
d.arizona's avatar
d.arizona committed
477 478
                            <div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
                                <div style={{ marginTop: 15, display: 'flex' }}>
479 480 481 482 483 484 485 486 487 488 489 490
                                    <Autocomplete
                                        {...this.state.listReportType}
                                        id="menu"
                                        onChange={(event, newInputValue) => this.setState({ reportType: newInputValue, loading: true, dataTable: [] }, () => {
                                            // this.getListUserSubcoRO()
                                            this.getDataMonitoring()
                                        })}
                                        disableClearable
                                        style={{ minWidth: 210, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Menu" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.reportType}
                                    />
d.arizona's avatar
d.arizona committed
491 492 493 494 495
                                    <Autocomplete
                                        {...this.state.listPeriodeMB}
                                        id="periode"
                                        onChange={(event, newInputValue) => this.setState({ periodeMB: newInputValue, loading: true }, () => {
                                            // this.getListUserSubcoRO()
496
                                            this.getDataMonitoring()
d.arizona's avatar
d.arizona committed
497 498 499 500 501 502 503 504 505 506 507
                                        })}
                                        disableClearable
                                        style={{ minWidth: 210, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Periode" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.periodeMB}
                                    />
                                    {this.state.reportType != null && this.state.reportType.value == 1 && <Autocomplete
                                        {...this.state.listMonth}
                                        id="month"
                                        onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
                                            // this.getListUserSubcoRO()
508
                                            this.getDataMonitoring()
d.arizona's avatar
d.arizona committed
509 510 511 512 513 514
                                        })}
                                        disableClearable
                                        style={{ minWidth: 210, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.month}
                                    />}
d.arizona's avatar
d.arizona committed
515
                                    {this.state.reportType != null && this.state.reportType.value == 2 && <Autocomplete
d.arizona's avatar
d.arizona committed
516 517 518 519
                                        {...this.state.listQuarter}
                                        id="quarter"
                                        onChange={(event, newInputValue) => this.setState({ quarter: newInputValue, loading: true }, () => {
                                            // this.getListUserSubcoRO()
520
                                            this.getDataMonitoring()
d.arizona's avatar
d.arizona committed
521 522 523 524 525 526 527 528 529
                                        })}
                                        disableClearable
                                        style={{ minWidth: 210, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Quarter" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.quarter}
                                    />}
                                </div>
                            </div>
                            <div style={{ marginTop: 20, marginBottom: 20 }}>
d.arizona's avatar
d.arizona committed
530
                                <div style={{ display: 'flex', justifyContent: 'space-between', padding: '0px 20px 10px 20px' }}>
d.arizona's avatar
d.arizona committed
531
                                    <div></div>
d.arizona's avatar
d.arizona committed
532
                                    {/* {this.state.previewDownload && ( */}
d.arizona's avatar
d.arizona committed
533 534 535 536 537 538 539 540 541 542 543 544
                                        <div style={{ width: '50%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                            <a data-tip={'Download'} data-for="download">
                                                <button
                                                    style={{
                                                        backgroundColor: 'transparent',
                                                        cursor: 'pointer',
                                                        borderColor: 'transparent',
                                                        margin: 5,
                                                        outline: 'none'
                                                    }}
                                                    onClick={() => this.setState({ loading: true }, () => {
                                                        setTimeout(() => {
d.arizona's avatar
d.arizona committed
545
                                                            this.downloadData()
d.arizona's avatar
d.arizona committed
546 547 548 549 550 551 552 553
                                                        }, 100);
                                                    })}
                                                >
                                                    <img src={Images.download} />
                                                </button>
                                            </a>
                                            <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                        </div>
d.arizona's avatar
d.arizona committed
554 555
                                    {/* )} */}
                                </div>
d.arizona's avatar
d.arizona committed
556
                                {this.state.loading && loadingComponent}
557
                                {this.state.reportType != null && !this.state.loading && (
Faisal Hamdi's avatar
Faisal Hamdi committed
558 559
                                <TableProgressReport
                                    width={this.props.width}
560
                                    // height={this.props.height}
Faisal Hamdi's avatar
Faisal Hamdi committed
561 562 563 564
                                    open={this.props.open}
                                    // month={this.state.month.month_value}
                                    category={this.state.category ? this.state.category.value : 1}
                                    reportType={this.state.reportType ? this.state.reportType.value : 0}
565
                                    dataTable={this.state.dataTable}
Faisal Hamdi's avatar
Faisal Hamdi committed
566 567 568
                                    // dataTable={this.state.dataTable}
                                    periode={this.state.periode ? this.state.periode.periode : null}
                                    quarter={this.state.quarter.name}
Riri Novita's avatar
Riri Novita committed
569
                                    month={this.state.month.month_id}
Faisal Hamdi's avatar
Faisal Hamdi committed
570
                                    company={this.state.company}
571
                                    typeReport={String(this.state.reportType.name).toLocaleUpperCase()}
Riri Novita's avatar
Riri Novita committed
572
                                    year={this.state.periodeMB.value}
Riri Novita's avatar
Riri Novita committed
573 574 575 576
                                    getMonitoringMB={this.getMonitoringMB.bind(this)}
                                    getMonitoringMR={this.getMonitoringMR.bind(this)}
                                    getMonitoringRO={this.getMonitoringRO.bind(this)}
                                    getMonitoringOLPA={this.getMonitoringOLPA.bind(this)}
Faisal Hamdi's avatar
Faisal Hamdi committed
577
                                />
578
                                )}
d.arizona's avatar
d.arizona committed
579 580 581 582 583 584 585 586 587 588 589
                            </div>
                        </Paper>
                    </div>
                </div>
            </div>
        );

    }
}

export default ReportProgress;