ProgressReport.js 32.1 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: '',
Riri Novita's avatar
Riri Novita committed
45
            company: null
d.arizona's avatar
d.arizona committed
46 47 48 49 50
        }
    }

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

    getMonth() {
Faisal Hamdi's avatar
Faisal Hamdi committed
56
        this.setState({ loading: true })
d.arizona's avatar
d.arizona committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
        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 {
79 80 81 82 83 84 85 86
                    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
87 88
                }
            } else {
89
                this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
d.arizona's avatar
d.arizona committed
90 91 92 93 94 95 96 97 98 99
            }
        })
    }

    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
100
                MB.push({ name: String(i + 1), value: i + 1})
d.arizona's avatar
d.arizona committed
101 102
            }
        }
Riri Novita's avatar
Riri Novita committed
103
        console.log(MB);
d.arizona's avatar
d.arizona committed
104 105 106 107 108 109 110 111

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

        this.setState({
            listPeriodeMB: defaultPropsMB,
Riri Novita's avatar
Riri Novita committed
112 113
            // periodeMB: MB[MB.length - 1],
            periodeMB: MB[MB.length - 2],
d.arizona's avatar
d.arizona committed
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 144 145 146
            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
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 174 175 176
    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
177
                        let report = []
r.kurnia's avatar
r.kurnia committed
178 179
                        let statusSubmission = String(item.submission_status).toLocaleUpperCase()
                        let statusOI = String(item.operating_indicator).toLocaleUpperCase()
d.arizona's avatar
d.arizona committed
180 181 182
                        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
183
                        })
d.arizona's avatar
d.arizona committed
184
                        report.push(
qorri_di's avatar
qorri_di committed
185
                            {report_name: 'Operating Indicator', status_report: statusOI}, 
d.arizona's avatar
d.arizona committed
186
                            {report_name: 'Submission Status', status_report: (statusSubmission == 'APPROVED' || statusSubmission == 'REVISION' || statusSubmission == 'COMPLETED') ? (statusSubmission + ' - ' + item.submissionStatusDate) : statusSubmission})
187
                        dataTable.push([
r.kurnia's avatar
r.kurnia committed
188
                            item.company_name,
Riri Novita's avatar
Riri Novita committed
189
                            report,
Riri Novita's avatar
Riri Novita committed
190 191 192
                            item.automatic_reminder_report_date,
                            item.manual_reminder_report_status,
                            item.manual_reminder_report_date,
Riri Novita's avatar
Riri Novita committed
193
                            item.submission_status,
Riri Novita's avatar
Riri Novita committed
194
                            item.manual_reminder_report_button,
Riri Novita's avatar
Riri Novita committed
195
                            item.company_id,
196 197
                        ])
                    })
d.arizona's avatar
d.arizona committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
                    // 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
215
                    // console.log(dataTable)
216 217 218 219 220 221 222 223 224 225 226 227 228 229
                    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 })
            }
qorri_di's avatar
qorri_di committed
230
        })    
231 232 233 234 235 236 237 238 239 240 241 242 243 244
    }

    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
245 246 247 248
                            report,
                            item.automatic_reminder_report_date,
                            item.manual_reminder_report_status,
                            item.manual_reminder_report_date,
Riri Novita's avatar
Riri Novita committed
249
                            item.monthly_status,
Riri Novita's avatar
Riri Novita committed
250
                            item.manual_reminder_report_button,
Riri Novita's avatar
Riri Novita committed
251
                            item.company_id,
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
                        ])
                    })
                    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 })
            }
qorri_di's avatar
qorri_di committed
268
        })    
269 270 271 272 273 274 275 276 277 278 279 280 281 282
    }

    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
283 284 285 286
                            report,
                            item.automatic_reminder_report_date,
                            item.manual_reminder_report_status,
                            item.manual_reminder_report_date,
Riri Novita's avatar
Riri Novita committed
287
                            item.rolling_status,
Riri Novita's avatar
Riri Novita committed
288
                            item.manual_reminder_report_button,
Riri Novita's avatar
Riri Novita committed
289
                            item.company_id,
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
                        ])
                    })
                    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 })
            }
qorri_di's avatar
qorri_di committed
306
        })    
307 308 309 310 311 312 313 314 315 316
    }

    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
317
                        let report = []
r.kurnia's avatar
r.kurnia committed
318 319
                        let statusSubmission = String(item.outlook_status).toLocaleUpperCase()
                        let statusOI = String(item.operating_indicator).toLocaleUpperCase()
d.arizona's avatar
d.arizona committed
320 321 322
                        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
323
                        })
d.arizona's avatar
d.arizona committed
324
                        report.push(
qorri_di's avatar
qorri_di committed
325
                            {report_name: 'Operating Indicator', status_report: statusOI}, 
d.arizona's avatar
d.arizona committed
326
                            {report_name: 'OLPA Status', status_report: (statusSubmission == 'APPROVED' || statusSubmission == 'REVISION' || statusSubmission == 'COMPLETED') ? (statusSubmission + ' - ' + item.submissionStatusDate) : statusSubmission})
327
                        dataTable.push([
r.kurnia's avatar
r.kurnia committed
328
                            item.company_name,
Riri Novita's avatar
Riri Novita committed
329 330 331 332
                            report,
                            item.automatic_reminder_report_date,
                            item.manual_reminder_report_status,
                            item.manual_reminder_report_date,
Riri Novita's avatar
Riri Novita committed
333
                            item.outlook_status,
Riri Novita's avatar
Riri Novita committed
334
                            item.manual_reminder_report_button,
Riri Novita's avatar
Riri Novita committed
335
                            item.company_id,
336
                        ])
d.arizona's avatar
d.arizona committed
337 338
                    })
                    // data.map((item,index) => {
qorri_di's avatar
qorri_di committed
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
                        // 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
                        // ])
                        // 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
360
                    // })
361 362 363 364 365 366 367 368 369 370 371 372 373 374
                    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 })
            }
qorri_di's avatar
qorri_di committed
375
        })    
376 377 378 379 380 381
    }

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

d.arizona's avatar
d.arizona committed
382 383 384 385
    downloadData() {
        let path = ''
        let type = ''
        if (String(this.state.reportType.name).toLocaleUpperCase().includes('MASTER')) {
386
            path = `public/transaction/monitoring/master_budget?periode=${this.state.periodeMB.name}`
d.arizona's avatar
d.arizona committed
387 388
            type = 'Master Budget'
        } else if (String(this.state.reportType.name).toLocaleUpperCase().includes('MONTHLY')) {
389
            path = `public/transaction/monitoring/monthly_report?months=${this.state.month.month_id}&&periode=${this.state.periodeMB.name}`
d.arizona's avatar
d.arizona committed
390 391
            type = `Monthly Report (${this.state.month.month_value})`
        } else if (String(this.state.reportType.name).toLocaleUpperCase().includes('ROLLING')) {
392
            path = `public/transaction/monitoring/rolling_outlook?quartals=${this.state.quarter.value}&&periode=${this.state.periodeMB.name}`
d.arizona's avatar
d.arizona committed
393 394
            type = `Rolling Outlook ${this.state.quarter.name}`
        } else {
395
            path = `public/transaction/monitoring/outlook_pa?periode=${this.state.periodeMB.name}`
d.arizona's avatar
d.arizona committed
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
            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
418
    render() {
Faisal Hamdi's avatar
Faisal Hamdi committed
419

Faisal Hamdi's avatar
Faisal Hamdi committed
420
        const dataTableMB = [
Faisal Hamdi's avatar
Faisal Hamdi committed
421
            ['Tax Planning', '2', 'ABA: Anugerah Buminusantara Abadi', '2021-05-03'],
Faisal Hamdi's avatar
Faisal Hamdi committed
422
            ['CAT', '1', 'ABA: Anugerah Buminusantara Abadi', '2021-05-03'],
Faisal Hamdi's avatar
Faisal Hamdi committed
423 424
            ['Profit Loss', '0', 'ABA: Anugerah Buminusantara Abadi', '2021-05-03']
        ]
Faisal Hamdi's avatar
Faisal Hamdi committed
425 426 427 428 429 430 431

        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
432 433 434 435 436 437 438 439 440 441
        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
442

d.arizona's avatar
d.arizona committed
443 444
        return (
            <div style={{ flex: 1, backgroundColor: '#f8f8f8', minHeight: this.props.height }}>
445 446 447 448 449
                <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
450 451 452 453 454
                <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
455
                        <Paper style={{ paddingTop: 10, paddingBottom: 50 }}>
d.arizona's avatar
d.arizona committed
456 457 458
                            <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                                <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Report Status & Approval Progress</Typography>
                            </div>
459
                            {/* <div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
d.arizona's avatar
d.arizona committed
460 461 462 463 464 465 466
                                <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
467
                                            this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
468 469 470 471 472 473 474 475 476 477 478
                                        })}
                                        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
479
                                            this.setState({ loading: false })
d.arizona's avatar
d.arizona committed
480 481 482 483 484 485 486
                                        })}
                                        disableClearable
                                        style={{ minWidth: 210, marginRight: 20 }}
                                        renderInput={(params) => <TextField {...params} label="Report Type" margin="normal" style={{ marginTop: 7 }} />}
                                        value={this.state.reportType}
                                    />
                                </div>
487
                            </div> */}
d.arizona's avatar
d.arizona committed
488 489
                            <div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
                                <div style={{ marginTop: 15, display: 'flex' }}>
490 491 492 493 494 495 496 497 498 499 500 501
                                    <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
502 503 504 505 506
                                    <Autocomplete
                                        {...this.state.listPeriodeMB}
                                        id="periode"
                                        onChange={(event, newInputValue) => this.setState({ periodeMB: newInputValue, loading: true }, () => {
                                            // this.getListUserSubcoRO()
507
                                            this.getDataMonitoring()
d.arizona's avatar
d.arizona committed
508 509 510 511 512 513 514 515 516 517 518
                                        })}
                                        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()
519
                                            this.getDataMonitoring()
d.arizona's avatar
d.arizona committed
520 521 522 523 524 525
                                        })}
                                        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
526
                                    {this.state.reportType != null && this.state.reportType.value == 2 && <Autocomplete
d.arizona's avatar
d.arizona committed
527 528 529 530
                                        {...this.state.listQuarter}
                                        id="quarter"
                                        onChange={(event, newInputValue) => this.setState({ quarter: newInputValue, loading: true }, () => {
                                            // this.getListUserSubcoRO()
531
                                            this.getDataMonitoring()
d.arizona's avatar
d.arizona committed
532 533 534 535 536 537 538 539 540
                                        })}
                                        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
541
                                <div style={{ display: 'flex', justifyContent: 'space-between', padding: '0px 20px 10px 20px' }}>
d.arizona's avatar
d.arizona committed
542
                                    <div></div>
d.arizona's avatar
d.arizona committed
543
                                    {/* {this.state.previewDownload && ( */}
qorri_di's avatar
qorri_di committed
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
                                        <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(() => {
                                                            this.downloadData()
                                                        }, 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
565 566
                                    {/* )} */}
                                </div>
d.arizona's avatar
d.arizona committed
567
                                {this.state.loading && loadingComponent}
568
                                {this.state.reportType != null && !this.state.loading && (
qorri_di's avatar
qorri_di committed
569 570 571 572 573 574 575 576 577 578 579 580
                                <TableProgressReport
                                    width={this.props.width}
                                    // height={this.props.height}
                                    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}
                                    dataTable={this.state.dataTable}
                                    // dataTable={this.state.dataTable}
                                    periode={this.state.periode ? this.state.periode.periode : null}
                                    quarter={this.state.quarter.name}
                                    month={this.state.month.month_id}
Riri Novita's avatar
Riri Novita committed
581
                                    company={this.state.company_id}
qorri_di's avatar
qorri_di committed
582 583 584 585 586 587 588
                                    typeReport={String(this.state.reportType.name).toLocaleUpperCase()}
                                    year={this.state.periodeMB.value}
                                    getMonitoringMB={this.getMonitoringMB.bind(this)}
                                    getMonitoringMR={this.getMonitoringMR.bind(this)}
                                    getMonitoringRO={this.getMonitoringRO.bind(this)}
                                    getMonitoringOLPA={this.getMonitoringOLPA.bind(this)}
                                />
589
                                )}
d.arizona's avatar
d.arizona committed
590 591 592 593 594 595 596 597 598 599 600
                            </div>
                        </Paper>
                    </div>
                </div>
            </div>
        );

    }
}

export default ReportProgress;