ProfitLossMR.js 40.2 KB
Newer Older
Riri Novita's avatar
Riri Novita committed
1
import { createMuiTheme, FormControlLabel, Input, MuiThemeProvider, Paper, TableCell, Tooltip, Typography, withStyles } from '@material-ui/core'
d.arizona's avatar
d.arizona committed
2 3 4 5
import MUIDataTable from 'mui-datatables';
import React, { Component } from 'react'
import ReactTooltip from 'react-tooltip';
import Images from '../../assets/Images';
Riri Novita's avatar
Riri Novita committed
6
import api from '../../api';
d.arizona's avatar
d.arizona committed
7

EKSAD's avatar
EKSAD committed
8 9 10 11 12 13 14 15 16
const LightTooltip = withStyles((theme) => ({
    tooltip: {
        backgroundColor: theme.palette.common.white,
        color: 'rgba(0, 0, 0, 0.87)',
        boxShadow: theme.shadows[1],
        fontSize: 11,
    },
}))(Tooltip);

d.arizona's avatar
d.arizona committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());

const options = ct.customOptionsFixedColumn();

const style = {
    position: "sticky",
    left: 0,
    zIndex: 101,
    background: "white",
};
const style2 = {
    position: "sticky",
    background: "white",
    zIndex: 100,
    top: 0
};
EKSAD's avatar
EKSAD committed
34 35 36 37 38 39
const stylenotes = {
    position: "sticky",
    background: "white",
    zIndex: 101,
    left: 350
};
d.arizona's avatar
d.arizona committed
40

Riri Novita's avatar
Riri Novita committed
41 42 43 44 45 46
const styleNotesEmpty = {
    position: "sticky",
    background: "white",
    zIndex: 99,
    left: 0
}
EKSAD's avatar
EKSAD committed
47
export default class ProfitLossMR extends Component {
EKSAD's avatar
EKSAD committed
48 49 50
    constructor(props) {
        super(props)
        this.state = {
Riri Novita's avatar
Riri Novita committed
51 52
            dataTable: [],
            loading: true
EKSAD's avatar
EKSAD committed
53 54
        }
    }
Riri Novita's avatar
Riri Novita committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

    componentDidMount() {
        this.getItemHierarki()
    }

    getItemHierarki() {
        let payload = {
            "report_id": this.props.report_id,
            "revision": Number(this.props.revision),
            "periode": this.props.periode,
            "company_id": this.props.company.company_id,
            "monthly_report_id": this.props.monthlyReportId,
            "month": this.props.month.month_id
        }
        api.create().getHierarkiMontlyReportPL(payload).then(response => {
            console.log(response);
            let dataTable = []
            if (response.data) {
                let res = response.data.data
                const handlePushChild = (item) => {
                    let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
                    if (indexIDzz === -1) {
                        dataTable.push([
                            item.type_report_id,
                            item.id,
                            item.parent,
                            item.formula,
                            item.level,
                            item.description,
                            item.profit_loss.notes === "" ? null : item.profit_loss.notes,
                            item.profit_loss.rolling_outlook === null ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook,
                            {
                                mb: item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget,
                                rb: item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
                                actual: item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual
                            },
                            item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
                            item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
                            {
                                aavpm: item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
                                pavpm: item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
                                aavmb: item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
                                pavmb: item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_act_vs_mb,
                                aavrb: item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb,
                                pavrb: item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_act_vs_rb,
                            },
                            {
                                mtdvpm: item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month,
                                mtdvmb: item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb,
                                mtdvrb: item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb,
                            }
                        ])
                    }
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                }
                res.map((item, index) => {
                    dataTable.push([
                        item.type_report_id,
                        item.id,
                        item.parent,
                        item.formula,
                        item.level,
                        item.description,
                        item.profit_loss.notes === "" ? null : item.profit_loss.notes,
                        item.profit_loss.rolling_outlook === null ? "0.0" : item.profit_loss.rolling_outlook === "" ? "0.0" : item.profit_loss.rolling_outlook,
                        {
                            mb: item.profit_loss.master_budget === "" ? "0.0" : item.profit_loss.master_budget,
                            rb: item.profit_loss.rolling_budget === "" ? "0.0" : item.profit_loss.rolling_budget,
                            actual: item.profit_loss.actual === "" ? "0.0" : item.profit_loss.actual
                        },
                        item.profit_loss.ytd_actual === null ? "0.0" : item.profit_loss.ytd_actual === "" ? "0.0" : item.profit_loss.ytd_actual,
                        item.profit_loss.actual_previous_month === null ? "0.0" : item.profit_loss.actual_previous_month === "" ? "0.0" : item.profit_loss.actual_previous_month,
                        {
                            aavpm: item.profit_loss.amount_act_vs_previous_month === "" ? "0.0" : item.profit_loss.amount_act_vs_previous_month,
                            pavpm: item.profit_loss.percent_act_vs_previous_month === "" ? "0.0" : item.profit_loss.percent_act_vs_previous_month,
                            aavmb: item.profit_loss.amount_act_vs_mb === "" ? "0.0" : item.profit_loss.amount_act_vs_mb,
                            pavmb: item.profit_loss.percent_act_vs_mb === "" ? "0.0" : item.profit_loss.percent_act_vs_mb,
                            aavrb: item.profit_loss.amount_act_vs_rb === "" ? "0.0" : item.profit_loss.amount_act_vs_rb,
                            pavrb: item.profit_loss.percent_act_vs_rb === "" ? "0.0" : item.profit_loss.percent_act_vs_rb,
                        },
                        {
                            mtdvpm: item.profit_loss.mtd_vs_previous_month === "" ? "0.0" : item.profit_loss.mtd_vs_previous_month,
                            mtdvmb: item.profit_loss.mtd_vs_mb === "" ? "0.0" : item.profit_loss.mtd_vs_mb,
                            mtdvrb: item.profit_loss.mtd_vs_rb === "" ? "0.0" : item.profit_loss.mtd_vs_rb,
                        }
                    ])
                    if (item.children !== null) {
                        if (item.children.length > 0) {
                            item.children.map((items, indexs) => {
                                handlePushChild(items)
                            })
                        }
                    }
                })
                this.setState({ dataTable, loading: false })
            }
        })
    }

d.arizona's avatar
d.arizona committed
160
    render() {
Riri Novita's avatar
Riri Novita committed
161 162 163 164 165 166
        let dataTable2 = this.state.dataTable
        const handleNotes = (value, tableMeta) => {
            console.log(value)
            let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
            console.log(dataTable2[tableMeta.rowIndex]);
        }
d.arizona's avatar
d.arizona committed
167
        let columns = [
Riri Novita's avatar
Riri Novita committed
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
            {
                name: "",
                options: {
                    display: false
                }
            },
d.arizona's avatar
d.arizona committed
198 199 200 201 202 203 204 205 206 207 208 209
            {
                name: "Account",
                options: {
                    customHeadRender: (columnMeta) => (
                        <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300 }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style }),
                    customBodyRender: (val, tableMeta) => {
                        return (
                            <div style={{ width: 300 }}>
Riri Novita's avatar
Riri Novita committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
                                {tableMeta.rowData[0] === null ?
                                    tableMeta.rowData[4] == 0 ?
                                        <LightTooltip title={"Report Items Not Registered"} arrow>
                                            <span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(val).toUpperCase()}</span>
                                        </LightTooltip> :
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                            <LightTooltip title={"Report Items Not Registered"} arrow>
                                                <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                            </LightTooltip>
                                        </div>
                                    :
                                    tableMeta.rowData[4] == 0 ?
                                        <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
                                        :
                                        <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
                                            <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
                                        </div>
                                }
d.arizona's avatar
d.arizona committed
228 229 230 231
                            </div>
                        )
                    }
                }
Riri Novita's avatar
Riri Novita committed
232
            }, {
EKSAD's avatar
EKSAD committed
233
                name: "Notes",
d.arizona's avatar
d.arizona committed
234 235
                options: {
                    customHeadRender: (columnMeta) => (
Riri Novita's avatar
Riri Novita committed
236 237 238 239 240
                        dataTable2.length > 0 ?
                        <TableCell style={{ ...stylenotes, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 96 }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell> :
                        <TableCell style={{ ...styleNotesEmpty, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 96 }}>
EKSAD's avatar
EKSAD committed
241
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
d.arizona's avatar
d.arizona committed
242 243
                        </TableCell>
                    ),
EKSAD's avatar
EKSAD committed
244 245 246 247 248 249 250 251
                    setCellProps: () => ({
                        style: {
                            position: "sticky",
                            background: "white",
                            zIndex: 101,
                            left: 350
                        }
                      }),
Riri Novita's avatar
Riri Novita committed
252
                    customBodyRender: (value, tableMeta, updateValue) => {
d.arizona's avatar
d.arizona committed
253
                        return (
EKSAD's avatar
EKSAD committed
254
                            <div style={{ textAlign: 'right' }}>
EKSAD's avatar
EKSAD committed
255
                                <div style={{ flex: 1 }}>
Riri Novita's avatar
Riri Novita committed
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
                                    {tableMeta.rowData[0] === 3 ?
                                        <FormControlLabel
                                            style={{ margin: 0 }}
                                            // value={value}
                                            control={
                                                <Input
                                                    disableUnderline={true}
                                                    style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
                                                    type="text"
                                                    placeholder=""
                                                    // disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
                                                    defaultValue={value}
                                                    onBlur={(event) => {
                                                        // updateValue(event.target.value)
                                                        handleNotes(event.target.value, tableMeta)
                                                        // console.log(dataTable2)
                                                    }}
                                                />
                                            }
                                        />: null}
EKSAD's avatar
EKSAD committed
276
                                </div>
d.arizona's avatar
d.arizona committed
277 278 279 280
                            </div>
                        )
                    }
                }
Riri Novita's avatar
Riri Novita committed
281
            }, {
d.arizona's avatar
d.arizona committed
282 283 284
                name: "Rolling Outlook (FY2021)",
                options: {
                    customHeadRender: (columnMeta) => (
Riri Novita's avatar
Riri Novita committed
285 286
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#07a7d0', width: 96, borderLeft: '1px #fff solid', borderRight: '1px #fff solid' }}>
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
d.arizona's avatar
d.arizona committed
287 288 289 290 291 292
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
293 294 295 296
                                {tableMeta.rowData[0] === 4 ?
                                    null :
                                    val
                                }
d.arizona's avatar
d.arizona committed
297 298 299 300 301 302 303 304 305
                            </div>
                        )
                    }
                }
            },
            {
                name: `Month To Date (MTD)`,
                options: {
                    customHeadRender: (columnMeta) => (
Riri Novita's avatar
Riri Novita committed
306
                        <th style={{ ...style2, color: '#fff', backgroundColor: '#1c71b8', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)", padding: 0 }} >
d.arizona's avatar
d.arizona committed
307
                            {/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
Riri Novita's avatar
Riri Novita committed
308 309 310 311 312
                                  <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                              </TableCell> */}
                            <div style={{ borderBottom: "1px #fff solid", backgroundColor: '#1c71b8', justifyContent: 'center', display: 'flex', alignItems: 'center', height: 43, fontSize: 12, fontWeight: 'bold', padding: 5 }}>{columnMeta.name}</div>
                            <div className="grid grid-3x" style={{ ...style2, color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0' }}>
d.arizona's avatar
d.arizona committed
313 314
                                    <span>{"Master Budget (MB)"}</span>
                                </div>
Riri Novita's avatar
Riri Novita committed
315
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0' }}>
d.arizona's avatar
d.arizona committed
316 317
                                    <span>{"Rolling Budget (RB)"}</span>
                                </div>
Riri Novita's avatar
Riri Novita committed
318
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, backgroundColor: '#37b5e6', height: '100%' }}>
d.arizona's avatar
d.arizona committed
319 320 321 322 323
                                    <span>{"Actual"}</span>
                                </div>
                            </div>
                        </th>
                    ),
Riri Novita's avatar
Riri Novita committed
324 325 326 327 328 329
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
d.arizona's avatar
d.arizona committed
330
                    customBodyRender: (val, tableMeta, updateValue) => {
Riri Novita's avatar
Riri Novita committed
331
                        // console.log(tableMeta);
d.arizona's avatar
d.arizona committed
332 333 334 335 336
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
337 338 339 340
                                            {tableMeta.rowData[0] === 4 ?
                                                null :
                                                val.mb
                                            }
d.arizona's avatar
d.arizona committed
341 342 343 344
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
345 346 347 348
                                            {tableMeta.rowData[0] === 4 ?
                                                null :
                                                val.rb
                                            }
d.arizona's avatar
d.arizona committed
349 350 351 352
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
353 354 355 356
                                            {tableMeta.rowData[0] === 4 ?
                                                null :
                                                val.actual
                                            }
d.arizona's avatar
d.arizona committed
357 358 359 360 361 362 363
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
Riri Novita's avatar
Riri Novita committed
364 365
            },
            {
d.arizona's avatar
d.arizona committed
366 367 368
                name: "YTD Actual",
                options: {
                    customHeadRender: (columnMeta) => (
Riri Novita's avatar
Riri Novita committed
369
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
370 371 372 373 374 375 376
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
377 378 379 380
                                {tableMeta.rowData[0] === 4 ?
                                    null :
                                    val
                                }
d.arizona's avatar
d.arizona committed
381 382 383 384 385 386 387 388 389
                            </div>
                        )
                    }
                }
            },
            {
                name: "Actual Previous Month",
                options: {
                    customHeadRender: (columnMeta) => (
Riri Novita's avatar
Riri Novita committed
390
                        <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#37b5e6', width: 96, borderRight: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
391 392 393 394 395 396 397
                            <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                        </TableCell>
                    ),
                    setCellProps: () => ({ style2 }),
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
398 399 400 401
                                {tableMeta.rowData[0] === 4 ?
                                    null :
                                    val
                                }
d.arizona's avatar
d.arizona committed
402 403 404 405
                            </div>
                        )
                    }
                }
Riri Novita's avatar
Riri Novita committed
406
            }, 
d.arizona's avatar
d.arizona committed
407 408 409 410 411
            {
                name: `Variance`,
                options: {
                    customHeadRender: (columnMeta) => (
                        <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
Riri Novita's avatar
Riri Novita committed
412
                            <div style={{ borderBottom: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 40 }}>{columnMeta.name}</div>
d.arizona's avatar
d.arizona committed
413
                            <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
Riri Novita's avatar
Riri Novita committed
414 415
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#37b5e6' }}>
                                    <div style={{ borderBottom: '1px #fff solid', backgroundColor: '#37b5e6' }}>
d.arizona's avatar
d.arizona committed
416 417
                                        <span>{"Act vs Previous Month"}</span>
                                    </div>
Riri Novita's avatar
Riri Novita committed
418 419
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid', backgroundColor: '#37b5e6' }}>
d.arizona's avatar
d.arizona committed
420 421
                                            <span>{"Amount"}</span>
                                        </div>
Riri Novita's avatar
Riri Novita committed
422
                                        <div className="column-2" style={{ borderLeft: '1px #fff solid', backgroundColor: '#37b5e6' }}>
d.arizona's avatar
d.arizona committed
423 424 425 426
                                            <span>{"%"}</span>
                                        </div>
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
427 428
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}>
                                    <div style={{ borderBottom: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
429 430
                                        <span>{"Act vs MB"}</span>
                                    </div>
Riri Novita's avatar
Riri Novita committed
431 432
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
433 434
                                            <span>{"Amount"}</span>
                                        </div>
Riri Novita's avatar
Riri Novita committed
435
                                        <div className="column-2" style={{ borderLeft: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
436 437 438 439
                                            <span>{"%"}</span>
                                        </div>
                                    </div>
                                </div>
Riri Novita's avatar
Riri Novita committed
440 441
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}>
                                    <div style={{ borderBottom: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
442 443
                                        <span>{"Act vs RB"}</span>
                                    </div>
Riri Novita's avatar
Riri Novita committed
444 445
                                    <div className="grid grid-2x">
                                        <div className="column-1" style={{ borderRight: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
446 447
                                            <span>{"Amount"}</span>
                                        </div>
Riri Novita's avatar
Riri Novita committed
448
                                        <div className="column-2" style={{ borderLeft: '1px #fff solid' }}>
d.arizona's avatar
d.arizona committed
449 450 451 452 453 454 455
                                            <span>{"%"}</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </th>
                    ),
Riri Novita's avatar
Riri Novita committed
456 457 458 459 460 461
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
d.arizona's avatar
d.arizona committed
462 463 464 465
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
Riri Novita's avatar
Riri Novita committed
466
                                    <div className="column-1">
d.arizona's avatar
d.arizona committed
467
                                        <div className="grid grid-2x content-center">
Riri Novita's avatar
Riri Novita committed
468
                                            <div className="column-1">
d.arizona's avatar
d.arizona committed
469
                                                <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
470 471 472 473
                                                    {tableMeta.rowData[0] === 4 ?
                                                        null :
                                                        val.aavpm
                                                    }
d.arizona's avatar
d.arizona committed
474 475
                                                </div>
                                            </div>
Riri Novita's avatar
Riri Novita committed
476
                                            <div className="column-2">
d.arizona's avatar
d.arizona committed
477
                                                <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
478 479 480 481
                                                    {tableMeta.rowData[0] === 4 ?
                                                        null :
                                                        val.pavpm
                                                    }
d.arizona's avatar
d.arizona committed
482 483 484 485
                                                </div>
                                            </div>
                                        </div>
                                    </div>
Riri Novita's avatar
Riri Novita committed
486
                                    <div className="column-2">
d.arizona's avatar
d.arizona committed
487
                                        <div className="grid grid-2x content-center">
Riri Novita's avatar
Riri Novita committed
488
                                            <div className="column-1">
d.arizona's avatar
d.arizona committed
489
                                                <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
490 491 492 493
                                                    {tableMeta.rowData[0] === 4 ?
                                                        null :
                                                        val.aavmb
                                                    }
d.arizona's avatar
d.arizona committed
494 495
                                                </div>
                                            </div>
Riri Novita's avatar
Riri Novita committed
496
                                            <div className="column-2">
d.arizona's avatar
d.arizona committed
497
                                                <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
498 499 500 501
                                                    {tableMeta.rowData[0] === 4 ?
                                                        null :
                                                        val.pavmb
                                                    }
d.arizona's avatar
d.arizona committed
502 503 504 505
                                                </div>
                                            </div>
                                        </div>
                                    </div>
Riri Novita's avatar
Riri Novita committed
506
                                    <div className="column-3">
d.arizona's avatar
d.arizona committed
507
                                        <div className="grid grid-2x content-center">
Riri Novita's avatar
Riri Novita committed
508
                                            <div className="column-1">
d.arizona's avatar
d.arizona committed
509
                                                <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
510 511 512 513
                                                    {tableMeta.rowData[0] === 4 ?
                                                        null :
                                                        val.aavrb
                                                    }
d.arizona's avatar
d.arizona committed
514 515
                                                </div>
                                            </div>
Riri Novita's avatar
Riri Novita committed
516
                                            <div className="column-2">
d.arizona's avatar
d.arizona committed
517
                                                <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
518 519 520 521
                                                    {tableMeta.rowData[0] === 4 ?
                                                        null :
                                                        val.pavrb
                                                    }
d.arizona's avatar
d.arizona committed
522 523 524 525 526 527 528 529 530 531 532 533 534 535
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
            {
                name: `MTD Explanation`,
                options: {
                    customHeadRender: (columnMeta) => (
Riri Novita's avatar
Riri Novita committed
536
                        <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)", padding: 0 }} >
d.arizona's avatar
d.arizona committed
537 538 539
                            {/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
                                <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
                            </TableCell> */}
Riri Novita's avatar
Riri Novita committed
540 541 542
                            <div style={{ borderBottom: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 40 }}>{columnMeta.name}</div>
                            <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
                                <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45, backgroundColor: '#37b5e6' }}>
d.arizona's avatar
d.arizona committed
543 544
                                    <span>{"vs Prev Month"}</span>
                                </div>
Riri Novita's avatar
Riri Novita committed
545
                                <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45, backgroundColor: '#07a7d0' }}>
d.arizona's avatar
d.arizona committed
546 547
                                    <span>{"vs MB"}</span>
                                </div>
Riri Novita's avatar
Riri Novita committed
548
                                <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, justifyContent: 'center', display: 'flex', alignItems: 'center', height: 45, backgroundColor: '#07a7d0' }}>
d.arizona's avatar
d.arizona committed
549 550 551 552 553
                                    <span>{"vs RB"}</span>
                                </div>
                            </div>
                        </th>
                    ),
Riri Novita's avatar
Riri Novita committed
554 555 556 557 558 559
                    setCellProps: () => ({
                        style: {
                            paddingLeft: 0,
                            paddingRight: 0
                        }
                    }),
d.arizona's avatar
d.arizona committed
560 561 562 563 564 565
                    customBodyRender: (val, tableMeta, updateValue) => {
                        return (
                            <div>
                                <div className="grid grid-3x content-center">
                                    <div className="col-1">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
566 567 568 569
                                            {tableMeta.rowData[0] === 4 ?
                                                null :
                                                val.mtdvpm
                                            }
d.arizona's avatar
d.arizona committed
570 571 572 573
                                        </div>
                                    </div>
                                    <div className="col-2">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
574 575 576 577
                                            {tableMeta.rowData[0] === 4 ?
                                                null :
                                                val.mtdvmb
                                            }
d.arizona's avatar
d.arizona committed
578 579 580 581
                                        </div>
                                    </div>
                                    <div className="col-3">
                                        <div style={{ textAlign: 'right', width: 90 }}>
Riri Novita's avatar
Riri Novita committed
582 583 584 585
                                            {tableMeta.rowData[0] === 4 ?
                                                null :
                                                val.mtdvrb
                                            }
d.arizona's avatar
d.arizona committed
586 587 588 589 590 591 592 593 594
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )
                    }
                }
            },
        ]
Riri Novita's avatar
Riri Novita committed
595

d.arizona's avatar
d.arizona committed
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
        return (
            <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
                <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                    <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
                </div>
                <div style={{ flex: 1, padding: 20, width: '100%' }}>
                    <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
                        <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
                            <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Profit Loss</Typography>
                        </div>
                        <div style={{ padding: 20 }}>
                            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                <div>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
                                    <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
                                </div>
                                <div style={{ width: '50%' }}>
                                    <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
                                        <a data-tip={'Download Template'} data-for="template">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() => null}
                                            >
                                                <img src={Images.template} />
                                            </button>
                                        </a>
                                        <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
                                        <a data-tip={'Upload'} data-for="upload">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() => null}
                                            >
                                                <img src={Images.upload} />
                                            </button>
                                        </a>
                                        <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
                                        <a data-tip={'Download'} data-for="download">
                                            <button
                                                style={{
                                                    backgroundColor: 'transparent',
                                                    cursor: 'pointer',
                                                    borderColor: 'transparent',
                                                    margin: 5
                                                }}
                                                onClick={() => null}
                                            >
                                                <img src={Images.download} />
                                            </button>
                                        </a>
                                        <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
                                    </div>
                                </div>
                            </div>

                            <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
Riri Novita's avatar
Riri Novita committed
662 663 664 665 666 667 668 669 670
                                {!this.state.loading && (
                                    <MuiThemeProvider theme={getMuiTheme()}>
                                        <MUIDataTable
                                            data={dataTable2}
                                            columns={columns}
                                            options={options}
                                        />
                                    </MuiThemeProvider>
                                )}
d.arizona's avatar
d.arizona committed
671 672
                            </div>
                        </div>
EKSAD's avatar
EKSAD committed
673
                        <div className="grid grid-2x" style={{ marginTop: 20 }}>
Riri Novita's avatar
Riri Novita committed
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
                                <div className="col-1">
                                    <button
                                        type="button"
                                        onClick={() => this.setState({ loading: true }, () => {
                                            setTimeout(() => {
                                                this.props.onClickClose()
                                            }, 100);
                                        })}
                                        style={{
                                            backgroundColor: 'transparent',
                                            cursor: 'pointer',
                                            borderColor: 'transparent',
                                            outline: 'none'
                                        }}
                                    >
                                        <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
                                            <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
                                        </div>
                                    </button>
                                </div>
EKSAD's avatar
EKSAD committed
694
                        </div>
d.arizona's avatar
d.arizona committed
695 696 697 698 699 700
                    </Paper>
                </div>
            </div>
        )
    }
}