Commit 5c827416 authored by Riri Novita's avatar Riri Novita

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into riri

parents e31f32c3 bd259167
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel, Snackbar, withStyles, createMuiTheme, MuiThemeProvider, Checkbox } from '@material-ui/core'; import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel, Snackbar, withStyles, createMuiTheme, MuiThemeProvider, Checkbox, Input } from '@material-ui/core';
import MUIDataTable from 'mui-datatables'; import MUIDataTable from 'mui-datatables';
import Images from '../assets/Images'; import Images from '../assets/Images';
import api from '../api'; import api from '../api';
...@@ -19,6 +19,8 @@ import Constant from '../library/Constant'; ...@@ -19,6 +19,8 @@ import Constant from '../library/Constant';
import OperatingIndicatorMR from './MonthlyReport/OperatingIndicatorMR'; import OperatingIndicatorMR from './MonthlyReport/OperatingIndicatorMR';
import CorporateAnnualTargetMR from './MonthlyReport/CorporateAnnualTargetMR'; import CorporateAnnualTargetMR from './MonthlyReport/CorporateAnnualTargetMR';
import CashFlowMR from './MonthlyReport/CashFlowMR'; import CashFlowMR from './MonthlyReport/CashFlowMR';
import { DatePicker } from '@material-ui/pickers';
import moment from 'moment';
var ct = require("../library/CustomTable"); var ct = require("../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -61,11 +63,17 @@ export default class MonthlyReport extends Component { ...@@ -61,11 +63,17 @@ export default class MonthlyReport extends Component {
company_submit: null, company_submit: null,
still_approver: false, still_approver: false,
status: '', status: '',
lastStatus: '' lastStatus: '',
approverTrue: false,
listStatus: [],
selectedStatus: []
} }
this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
scrollToMyRef = () => window.scrollTo(0, this.myRef.current.offsetTop)
getPermission() { getPermission() {
let payload = { let payload = {
menu: "monthly report" menu: "monthly report"
...@@ -100,25 +108,43 @@ export default class MonthlyReport extends Component { ...@@ -100,25 +108,43 @@ export default class MonthlyReport extends Component {
this.getPermission() this.getPermission()
this.setState({ loading: true }) this.setState({ loading: true })
// this.getCompanyActive() // this.getCompanyActive()
// this.getCompanySubmitted()
} }
getChecApprover() { getChecApprover() {
let listStatus1 = [
{name: 'Open', value: 'not-yet'},
{name: 'Submitted', value: 'submitted'},
{name: 'Waiting for Review', value: 'approval_review'},
{name: 'Waiting for Approval', value: 'approval_process'},
{name: 'Revision', value: 'revision'},
{name: 'Approved', value: 'approved'},
]
let listStatus2 = [
{name: 'Open', value: 'not-yet'},
{name: 'Submitted', value: 'submitted'},
{name: 'Revision', value: 'revision'},
{name: 'Approved', value: 'approved'},
]
api.create().checkApproverMonthly().then(response => { api.create().checkApproverMonthly().then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
if (response.data.data.is_approver === true) { if (response.data.data.is_approver === true) {
this.setState({ isApprover: true, checkApprover: true, still_approver: true}, () => this.setState({ isApprover: true, checkApprover: true, still_approver: true, approverTrue: true, listStatus: listStatus1, selectedStatus: [listStatus1[0]]}, () =>
{ {
if (this.state.submittedOnly) { // if (this.state.submittedOnly) {
this.getMonth() this.getMonth()
} else { // } else {
this.getCompanyActive() // this.getCompanyActive()
} // }
}) })
} else { } else {
this.setState({ isApprover: false, checkApprover: false, still_approver: false }, () => this.setState({ isApprover: false, checkApprover: false, still_approver: false, approverTrue: false, listStatus: listStatus2, selectedStatus: [listStatus2[0]]}, () =>
this.getCompanyActive()) this.getMonth())
// this.getCompanyActive())
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -185,8 +211,20 @@ export default class MonthlyReport extends Component { ...@@ -185,8 +211,20 @@ export default class MonthlyReport extends Component {
item.revision item.revision
] ]
}) })
let dataTableRevision = []
response.data.data.map((item, index) => {
if (item.report_name !== 'Cash Flow') {
dataTableRevision.push([
item.report_id,
item.report_name === 'CAT' ? 'Corporate Annual Target' : item.report_name,
"",
item.number
])
}
})
// console.log(dataTable); // console.log(dataTable);
this.setState({ dataTable, loading: false }) this.setState({ dataTable, loading: false, dataTableRevision: dataTableRevision.sort((a, b) => a.number - b.number), dataForRevision: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -260,15 +298,17 @@ export default class MonthlyReport extends Component { ...@@ -260,15 +298,17 @@ export default class MonthlyReport extends Component {
let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == month) let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == month)
console.log(index); console.log(index);
this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => { this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => {
if (this.state.isApprover === true) { // if (this.state.isApprover === true) {
if (this.state.submittedOnly) { // if (this.state.submittedOnly) {
this.getPeriode() // console.log('masuk cuk')
} else { // this.getPeriode()
this.getLastPeriod() // } else {
} // this.getLastPeriod()
} else { // }
this.getLastPeriod() // } else {
} // this.getLastPeriod()
this.getPeriode()
// }
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -299,6 +339,7 @@ export default class MonthlyReport extends Component { ...@@ -299,6 +339,7 @@ export default class MonthlyReport extends Component {
getPeriode() { getPeriode() {
api.create().getPeriodeTransaction().then(response => { api.create().getPeriodeTransaction().then(response => {
console.log(response)
let currentYear = new Date().getFullYear() let currentYear = new Date().getFullYear()
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
...@@ -309,7 +350,10 @@ export default class MonthlyReport extends Component { ...@@ -309,7 +350,10 @@ export default class MonthlyReport extends Component {
data.push(item) data.push(item)
} }
} else { } else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) { // if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
// data.push(item)
// }
if ((item >= 2000) && (item == currentYear || item <= currentYear + 1)) {
data.push(item) data.push(item)
} }
} }
...@@ -323,18 +367,19 @@ export default class MonthlyReport extends Component { ...@@ -323,18 +367,19 @@ export default class MonthlyReport extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, getOptionLabel: (option) => option.periode,
}; };
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod === undefined ? String(Number(currentYear) + 1) : this.state.lastPeriod) let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod === undefined ? String(Number(currentYear)) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode) let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// console.log(data) // console.log(data)
console.log(this.state.lastPeriod) console.log(this.state.lastPeriod)
// console.log(periodeData) // console.log(periodeData)
console.log(index) console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => { this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
if (this.state.isApprover === true && this.state.submittedOnly) { // if (this.state.isApprover === true && this.state.submittedOnly) {
this.getCompanySubmitted() this.getCompanySubmitted()
} else { // console.log('masuk')
this.getRevision() // } else {
} // this.getRevision()
// }
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -353,9 +398,13 @@ export default class MonthlyReport extends Component { ...@@ -353,9 +398,13 @@ export default class MonthlyReport extends Component {
} }
getCompanySubmitted() { getCompanySubmitted() {
let selectedStatus = this.state.selectedStatus.map((item) => {
return item.value
})
let body = { let body = {
"periode": this.state.periode.periode, "periode": this.state.periode.periode,
"months": this.state.month.month_id, "months": this.state.month.month_id,
"status": selectedStatus
} }
api.create().getCompanySubmittedMonthly(body).then(response => { api.create().getCompanySubmittedMonthly(body).then(response => {
console.log(response); console.log(response);
...@@ -478,9 +527,10 @@ export default class MonthlyReport extends Component { ...@@ -478,9 +527,10 @@ export default class MonthlyReport extends Component {
// this.getReport() // this.getReport()
// this.getReportAttachment() // this.getReportAttachment()
api.create().checkApproverMonthly().then(response => { api.create().checkApproverMonthly().then(response => {
console.log(response)
if (this.state.btnCreate === true && this.state.btnEdit === true) { if (this.state.btnCreate === true && this.state.btnEdit === true) {
console.log('editable'); console.log('editable');
this.setState({ isApprover: this.state.still_approver? true : false, checkApprover: false }) this.setState({ isApprover: false, checkApprover: false })
} else { } else {
console.log('just view'); console.log('just view');
this.setState({ isApprover: true, checkApprover: true }) this.setState({ isApprover: true, checkApprover: true })
...@@ -756,6 +806,98 @@ export default class MonthlyReport extends Component { ...@@ -756,6 +806,98 @@ export default class MonthlyReport extends Component {
this.setState({ alert: false }) this.setState({ alert: false })
} }
validate() {
this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden';
})
let array = []
let canSubmit = true
this.state.dataTable.map(item => {
// if (item[1] !== 'Cash Flow') {
if (item[3] !== "submitted" && item[3] !== 'approved') {
canSubmit = false
array.push(item[3])
}
// }
// if (item[3].includes("not-yet") || item[3].includes("draft")) {
// array.push(item[3])
// } else {
// array.push(item[3])
// }
})
if (canSubmit === true) {
let body = {
submission_id: this.state.submissionID
}
api.create().submitMasterBudget(body).then(response => {
// // // console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.getSubmission()
}
}
})
} else {
this.setState({ alert: true, messageAlert: 'Data Is Not Complete', tipeAlert: 'warning', loading: false }, () => {
document.body.style.overflow = 'unset';
})
}
// if (array.includes("not-yet" || "draft")) {
// // // console.log('gagal');
// } else {
// // // console.log('masuk');
// }
}
validateRevision() {
this.scrollToMyRef()
let arrayRevisi = this.state.detailRevisiCheck
let remarksKosong = 0
arrayRevisi.map((item, index) => {
if (item.remarks == "") {
remarksKosong += 1
}
})
// // console.log(arrayRevisi)
if (arrayRevisi.length == 0 || remarksKosong > 0) {
this.setState({ alert: true, messageAlert: 'Remarks Cannot be Empty', tipeAlert: 'error' })
} else {
this.setState({ visibleRevision: false }, () => this.approvalSubmission('revision'))
}
}
approvalSubmission(type) {
this.scrollToMyRef()
this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden';
})
let body = {
"approval_id": this.state.approverID,
"status": type,
"detail": this.state.detailRevisiCheck
}
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"min_periode": moment(this.state.minDateRevision).format('YYYY-MM-DD'),
"max_periode": moment(this.state.maxDateRevision).format('YYYY-MM-DD')
}
// // // console.log(payload)
// // console.log(this.props.location);
// // console.log(body)
api.create().approvalSubmission(body).then((res) => {
// // // console.log(res)
// this.setState({ loading: false }, () => {
// })
if (type == 'revision') {
api.create().createPeriodeRevision(payload).then((res))
}
this.getSubmission()
})
}
render() { render() {
const columns = ["#", "Report Type", const columns = ["#", "Report Type",
{ {
...@@ -883,6 +1025,145 @@ export default class MonthlyReport extends Component { ...@@ -883,6 +1025,145 @@ export default class MonthlyReport extends Component {
rowsPerPage: 5 rowsPerPage: 5
} }
const optionsRevision = {
filter: false,
sort: false,
responsive: "scroll",
print: false,
download: false,
selectableRows: false,
viewColumns: false,
pagination: false,
search: false
}
const handleMaxDate = () => {
let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
return handleDate < 0 ? moment(this.state.minDateRevision).format('YYYY/MM/DD') : moment(this.state.maxDateRevision).format('YYYY/MM/DD')
}
const handleChangeText = (value, tableMeta) => {
let dataTableRevision = this.state.dataTableRevision
dataTableRevision[tableMeta.rowIndex][tableMeta.columnIndex] = value
let detailRevisiCheck = this.state.detailRevisiCheck
let indexId = detailRevisiCheck.findIndex((val) => val.report_id == tableMeta.rowData[0])
if (indexId !== -1) {
detailRevisiCheck[indexId].remarks = value
}
this.setState({ dataTableRevision, detailRevisiCheck })
}
const handleCheckRevision = (value) => {
let detailRevisiCheck = this.state.detailRevisiCheck
let payload = {
report_id: value[0],
remarks: value[2],
number: value[3]
}
let indexDataRevisi = this.state.dataTableRevision.findIndex((val) => val[3] == value[3])
let indexId = detailRevisiCheck.sort((a, b) => a.number - b.number).findIndex((val) => val.number == value[3])
// // console.log(indexId)
if (indexId == -1) {
this.state.dataTableRevision.map((item, index) => {
if (index > indexDataRevisi) {
let indexIds = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIds == -1) {
let payload2 = {
report_id: item[0],
remarks: item[2],
number: item[3]
}
detailRevisiCheck.push(payload2)
}
}
})
detailRevisiCheck.push(payload)
} else {
let x = 0
detailRevisiCheck.sort((a, b) => a.number - b.number).map((item, index) => {
if (item.number < value[3]) {
x += 1
}
})
if (x < 1) {
this.state.dataTableRevision.map((item, index) => {
if (index > indexDataRevisi) {
let indexIdz = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIdz !== -1) {
detailRevisiCheck.splice(indexIdz, 1)
}
}
})
detailRevisiCheck.splice(indexId, 1)
}
}
this.setState({ detailRevisiCheck: detailRevisiCheck.sort((a, b) => a.number - b.number) })
// // console.log(detailRevisiCheck)
}
const columnRevisi = [
{
name: "#",
options: {
customBodyRender: (val, tableMeta, updateValue) => {
var list = [];
for (var i = 0; i <= tableMeta.rowData[6]; i++) {
list.push(i);
}
return (
<div style={{ display: 'flex' }}>
<FormControlLabel
style={{ margin: 0 }}
value={val}
control={
<Checkbox
checked={this.state.detailRevisiCheck.findIndex((val) => val.report_id == tableMeta.rowData[0]) == -1 ? false : true}
onClick={() => handleCheckRevision(tableMeta.rowData)} />
}
/>
</div >
);
}
}
}, "Report Type",
{
name: 'Remarks',
options: {
customBodyRender: (value, tableMeta, updateValue) => {
return (
<div style={{ textAlign: 'left' }}>
<FormControlLabel
style={{ margin: 0 }}
// value={value}
control={
<Input
disableUnderline={true}
style={{ fontSize: 12, textAlign: 'center', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent', marginTop: -10 }}
type="text"
placeholder=""
defaultValue={value}
color={"#5198ea"}
onBlur={(event) => {
// // // console.log(event.target.value)
// updateValue(event.target.value)
handleChangeText(event.target.value, tableMeta)
// // // console.log(dataTable2)
}}
/>}
/>
</div>
)
}
}
}, {
name: "",
options: { display: false }
}
]
const loadingComponent = ( 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)' }}> <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 <PropagateLoader
...@@ -914,7 +1195,7 @@ export default class MonthlyReport extends Component { ...@@ -914,7 +1195,7 @@ export default class MonthlyReport extends Component {
</div> </div>
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{this.state.isApprover? {/* {this.state.isApprover?
<div className="grid grid-2x" style={{}}> <div className="grid grid-2x" style={{}}>
<div className="col-1" style={{ display: 'flex', maxWidth: '100%', paddingLeft: 0}}> <div className="col-1" style={{ display: 'flex', maxWidth: '100%', paddingLeft: 0}}>
<Autocomplete <Autocomplete
...@@ -976,18 +1257,18 @@ export default class MonthlyReport extends Component { ...@@ -976,18 +1257,18 @@ export default class MonthlyReport extends Component {
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold', marginLeft: 5, alignSelf: 'center'}}>Submitted Only</Typography> <Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold', marginLeft: 5, alignSelf: 'center'}}>Submitted Only</Typography>
</div> </div>
</div> </div>
: : */}
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Autocomplete <Autocomplete
{...this.state.listMonth} {...this.state.listMonth}
id="month" id="month"
onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => { onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
if (this.state.isApprover === true) { // if (this.state.isApprover === true) {
this.getCompanySubmitted() // this.getCompanySubmitted()
} else { // } else {
this.setState({ visibleTableHistory: false }) this.setState({ visibleTableHistory: false })
this.getRevision() this.getRevision()
} // }
})} })}
disableClearable disableClearable
style={{ minWidth: 250, marginRight: 20 }} style={{ minWidth: 250, marginRight: 20 }}
...@@ -998,12 +1279,12 @@ export default class MonthlyReport extends Component { ...@@ -998,12 +1279,12 @@ export default class MonthlyReport extends Component {
{...this.state.listPeriode} {...this.state.listPeriode}
id="periode" id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => { onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => {
if (this.state.isApprover === true) { // if (this.state.isApprover === true) {
this.getCompanySubmitted() // this.getCompanySubmitted()
} else { // } else {
this.setState({ visibleTableHistory: false }) this.setState({ visibleTableHistory: false })
this.getRevision() this.getRevision()
} // }
})} })}
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
...@@ -1012,10 +1293,38 @@ export default class MonthlyReport extends Component { ...@@ -1012,10 +1293,38 @@ export default class MonthlyReport extends Component {
/> />
</div> </div>
} {/* } */}
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
multiple
id="tags-standard"
options={this.state.listStatus}
getOptionLabel={(option) => option.name}
style={{ width: 250 }}
onChange={(event, newInputValue) => {
this.setState({selectedStatus: newInputValue}, () => {
this.getCompanySubmitted()
})
}}
value={this.state.selectedStatus}
renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />}
/>
{/* <Autocomplete
{...this.state.listCompany}
multiple
id="company"
disabled={this.state.listCompany === null ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.getMonthlyReportID()
})}
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
value={[this.state.listCompany[0]]}
/> */}
</div> </div>
<div style={{ marginTop: 20 }}> <div style={{ marginTop: 20 }}>
<Autocomplete <Autocomplete
...@@ -1061,7 +1370,7 @@ export default class MonthlyReport extends Component { ...@@ -1061,7 +1370,7 @@ export default class MonthlyReport extends Component {
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography> <Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
</div> </div>
{!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && ( {!this.state.approverTrue && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
<button <button
style={{ style={{
...@@ -1107,7 +1416,7 @@ export default class MonthlyReport extends Component { ...@@ -1107,7 +1416,7 @@ export default class MonthlyReport extends Component {
: null : null
} }
</div> </div>
{!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && ( {!this.state.approverTrue && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
{ {
this.state.listAttachment.length > 0 ? this.state.listAttachment.length > 0 ?
...@@ -1132,7 +1441,7 @@ export default class MonthlyReport extends Component { ...@@ -1132,7 +1441,7 @@ export default class MonthlyReport extends Component {
</div> </div>
)} )}
</div> </div>
{this.state.checkApprover === true ? {this.state.approverTrue === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ? this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}> <div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{this.state.lastStatus}</span> <span>{this.state.lastStatus}</span>
...@@ -1176,11 +1485,125 @@ export default class MonthlyReport extends Component { ...@@ -1176,11 +1485,125 @@ export default class MonthlyReport extends Component {
</div> </div>
)} )}
</div> </div>
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} > {this.state.isAdmin && this.state.lastStatus == 'APPROVED' ?
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography> <div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
</div>
</button>
{/* <button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button> */}
</div>
</div> </div>
</div> :
this.state.checkApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() =>
this.approvalSubmission('review')
}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Review</Typography>
</div>
</button>
</div> : (this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' && this.state.btnApprove) ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
</div>
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div> : null
:
(this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && this.state.isSubmit === true ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.validate()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
</div>
</button>
</div> :
this.state.lastStatus === 'SUBMITTED' && this.state.submitter ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('cancel')}
>
<div style={{ backgroundColor: 'gray', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div> : null
}
</Paper> </Paper>
</div> </div>
...@@ -1370,6 +1793,124 @@ export default class MonthlyReport extends Component { ...@@ -1370,6 +1793,124 @@ export default class MonthlyReport extends Component {
lastStatus={this.state.lastStatus} lastStatus={this.state.lastStatus}
/> />
)} )}
{
this.state.visibleRevision && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Revision</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleRevision: false })}
>
<img src={Images.close} />
</button>
</div>
</div>
<div className="border-bottom" style={{ padding: 20 }}>
<span>You ask your subsidiary to make a revision</span>
<div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTableRevision}
columns={columnRevisi}
options={optionsRevision}
/>
</MuiThemeProvider>
</div>
<div style={{ marginTop: 20 }}>
<span>Timing duration you give for revision:</span>
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 20 }}>
<div>
<DatePicker
margin="normal"
id="startDate"
label="Valid From"
format="dd-MM-yyyy"
onChange={(e) => this.setState({ minDateRevision: moment(e).format('YYYY/MM/DD') }, () => this.setState({ maxDateRevision: handleMaxDate() }))}
value={moment(this.state.minDateRevision).format('YYYY/MM/DD')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
<span style={{ alignSelf: 'center' }}>Until</span>
<div>
<DatePicker
margin="normal"
id="startDate"
label="Valid To"
format="dd-MM-yyyy"
onChange={(e) => this.setState({ maxDateRevision: moment(e).format('YYYY/MM/DD') })}
minDate={moment(this.state.minDateRevision).format('YYYY/MM/DD')}
value={moment(this.state.maxDateRevision).format('YYYY/MM/DD')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.setState({ visibleRevision: false })}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.validateRevision()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Revision</span>
</div>
</button>
</div>
</div>
</div>
</div>
)
}
</div > </div >
); );
} }
......
...@@ -630,13 +630,18 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -630,13 +630,18 @@ export default class CorporateAnnualTargetMR extends Component {
perfomanceScore = 'IST' perfomanceScore = 'IST'
} }
this.setState({ totalScore: total, perfomanceScore }) this.setState({ totalScore: total, perfomanceScore }, () => {
setTimeout(() => {
console.log(total)
this.setState({ totalScore: total })
}, 1000);
})
}) })
} }
handleBackgroundPerf(total) { handleBackgroundPerf(total) {
console.log(total) // console.log(total)
let color = 'white' let color = 'white'
if (total >= 1.00 && total <= 2.00) { if (total >= 1.00 && total <= 2.00) {
color = 'red' color = 'red'
...@@ -1071,7 +1076,14 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1071,7 +1076,14 @@ export default class CorporateAnnualTargetMR extends Component {
// if (tableMeta.rowData[5] == 'Trading profit (NPBT buah luar & plasma)') { // if (tableMeta.rowData[5] == 'Trading profit (NPBT buah luar & plasma)') {
// console.log(dataTable2[tableMeta.rowIndex]) // console.log(dataTable2[tableMeta.rowIndex])
// } // }
let handlePercent = String(dataTable2[tableMeta.rowIndex][6]).substr(0, String(dataTable2[tableMeta.rowIndex][6]).length - 1) let handlePercent = ''
if (String(dataTable2[tableMeta.rowIndex][6]).includes('%')) {
// handlePercent = String(dataTable2[tableMeta.rowIndex][6])
handlePercent = String(dataTable2[tableMeta.rowIndex][6]).substr(0, String(dataTable2[tableMeta.rowIndex][6]).length - 1)
} else {
handlePercent = String(dataTable2[tableMeta.rowIndex][6])
}
// console.log(handlePercent)
if (dataTable2[tableMeta.rowIndex][12] == '' || String(dataTable2[tableMeta.rowIndex][12]) == '0' || String(dataTable2[tableMeta.rowIndex][12]) == '0.0') { if (dataTable2[tableMeta.rowIndex][12] == '' || String(dataTable2[tableMeta.rowIndex][12]) == '0' || String(dataTable2[tableMeta.rowIndex][12]) == '0.0') {
total = 0 total = 0
} else { } else {
...@@ -1079,37 +1091,6 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1079,37 +1091,6 @@ export default class CorporateAnnualTargetMR extends Component {
// console.log(total) // console.log(total)
} }
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(2) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total).toFixed(2)
if (tableMeta.rowIndex == dataTable2.length - 1) {
let totals = 0
let perfomanceScoreX = ''
dataTable2.map((item, index) => {
let value = String(item[15]) == 'NaN' || String(item[15]) == '' ? 0 : Number(item[15])
totals += value
})
totals = Number(totals).toFixed(2)
if (totals >= 1.00 && totals <= 2.00) {
perfomanceScoreX = 'K'
} else if (totals >= 2.01 && totals <= 2.75) {
perfomanceScoreX = 'C'
} else if (totals >= 2.76 && totals <= 3.00) {
perfomanceScoreX = 'B-'
} else if (totals >= 3.01 && totals <= 3.75) {
perfomanceScoreX = 'B'
} else if (totals >= 3.76 && totals <= 4.00) {
perfomanceScoreX = 'B+'
} else if (totals >= 4.01 && totals <= 4.75) {
perfomanceScoreX = 'BS'
} else if (totals >= 4.76 && totals <= 5.00) {
perfomanceScoreX = 'IST'
}
// totalScoreXXX = totals
// perfomanceScore = perfomanceScoreX
// setTimeout(() => {
// console.log(totalScoreXXX)
// console.log(perfomanceScore)
// }, 300);
}
return total return total
} }
...@@ -1709,7 +1690,9 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1709,7 +1690,9 @@ export default class CorporateAnnualTargetMR extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>TOTAL SCORE</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>TOTAL SCORE</Typography>
</div> </div>
<div style={{ border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}> <div style={{ border: '1px solid black', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalScore}</Typography> {!this.state.loading && (
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.state.totalScore}</Typography>
)}
</div> </div>
</div> </div>
</div> </div>
...@@ -1722,7 +1705,9 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1722,7 +1705,9 @@ export default class CorporateAnnualTargetMR extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>PERFOMANCE</Typography>
</div> </div>
<div style={{ borderStyle: 'solid', backgroundColor: this.handleBackgroundPerf(this.state.totalScore), borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}> <div style={{ borderStyle: 'solid', backgroundColor: this.handleBackgroundPerf(this.state.totalScore), borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
<Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</Typography> {!this.state.loading && (
<Typography style={{ fontSize: '11px', color: 'black', fontWeight: 'bold' }}>{this.state.perfomanceScore}</Typography>
)}
</div> </div>
</div> </div>
</div> </div>
......
...@@ -49,7 +49,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -49,7 +49,7 @@ export default class FixedAssetsMovementMR extends Component {
updateBy: '-', updateBy: '-',
notesUpdate: '-', notesUpdate: '-',
get_for: 'view', get_for: 'view',
viewOnly : true viewOnly: true
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -61,7 +61,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -61,7 +61,7 @@ export default class FixedAssetsMovementMR extends Component {
} }
handleGetFor(type) { handleGetFor(type) {
this.setState({get_for: type}, () => { this.setState({ get_for: type }, () => {
this.getItemHierarki() this.getItemHierarki()
this.getLatestUpdate() this.getLatestUpdate()
}) })
...@@ -77,23 +77,23 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -77,23 +77,23 @@ export default class FixedAssetsMovementMR extends Component {
} else { } else {
checkApprover = false checkApprover = false
} }
if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') { if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
checkLastStatus = true checkLastStatus = true
} else { } else {
checkLastStatus = false checkLastStatus = false
} }
// else if (this.props.prevRevision) { // else if (this.props.prevRevision) {
// viewOnly = false // viewOnly = false
// } // }
if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') { if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
checkStatus = true checkStatus = true
} else { } else {
checkStatus = false checkStatus = false
} }
this.setState({viewOnly: !checkApprover && checkLastStatus && checkStatus}) this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus })
} }
getLatestUpdate() { getLatestUpdate() {
...@@ -201,10 +201,12 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -201,10 +201,12 @@ export default class FixedAssetsMovementMR extends Component {
} }
}) })
console.log(dataTable); console.log(dataTable);
this.setState({ dataTable }, () => { this.setState({ dataTable, loading: false, refresh: false }, () => {
this.setState({ loading: true, refresh: true })
setTimeout(() => { setTimeout(() => {
this.setState({loading: false, refresh: false}) this.setState({ loading: false, refresh: false })
}, 300); }, 200);
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
...@@ -215,7 +217,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -215,7 +217,7 @@ export default class FixedAssetsMovementMR extends Component {
}, 1000); }, 1000);
} }
}) })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, refresh: false }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false, refresh: false })
} }
...@@ -234,7 +236,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -234,7 +236,7 @@ export default class FixedAssetsMovementMR extends Component {
a.href = url; a.href = url;
a.download = 'Template Monthly Report Fixed Assets Movement.xlsx' a.download = 'Template Monthly Report Fixed Assets Movement.xlsx'
a.click(); a.click();
} }
} }
async downloadAllData() { async downloadAllData() {
...@@ -287,7 +289,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -287,7 +289,7 @@ export default class FixedAssetsMovementMR extends Component {
} }
}); });
} }
checkUpload() { checkUpload() {
api.create().checkUploadMonthlyReportFAM(this.state.payload).then(response => { api.create().checkUploadMonthlyReportFAM(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload)); // console.log(JSON.stringify(this.state.payload));
...@@ -295,7 +297,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -295,7 +297,7 @@ export default class FixedAssetsMovementMR extends Component {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleFAMMR: false }) this.setState({ visibleUpload: false, loading: true, visibleFAMMR: false, refresh: true })
let dataTable = response.data.data.map((item, index) => { let dataTable = response.data.data.map((item, index) => {
return [ return [
item.type_report_id, item.type_report_id,
...@@ -317,11 +319,14 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -317,11 +319,14 @@ export default class FixedAssetsMovementMR extends Component {
] ]
}) })
// console.log(dataTable) // console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, refresh: false }, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[15].length > 0) { if (item[15].length > 0) {
console.log('masuk') console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true }) this.setState({ buttonError: true, errorPreview: true, editable: true, loading: true, refresh: true })
setTimeout(() => {
this.setState({ loading: false, refresh: false })
}, 200);
} }
}) })
// console.log(this.state.dataTable); // console.log(this.state.dataTable);
...@@ -394,7 +399,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -394,7 +399,7 @@ export default class FixedAssetsMovementMR extends Component {
"act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(i[11]), "act_vs_rb_amount": String(i[11]) === 'NaN' || String(i[11]) === 'Infinity' || String(i[11]) === '-Infinity' ? '0.0' : String(i[11]),
"act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(i[12]) "act_vs_rb_percent": String(i[12]) === 'NaN' || String(i[12]) === 'Infinity' || String(i[12]) === '-Infinity' ? '0.0' : String(i[12])
}) })
}) })
let payload = { let payload = {
"monthly_report_id": this.props.monthlyReportId, "monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
...@@ -405,7 +410,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -405,7 +410,7 @@ export default class FixedAssetsMovementMR extends Component {
"fixed_asset_movement": data "fixed_asset_movement": data
} }
// console.log(JSON.stringify(payload)); // console.log(JSON.stringify(payload));
api.create('UPLOAD').createMonthlyReportFAM(payload).then(response => { api.create('UPLOAD').createMonthlyReportFAM(payload).then(response => {
// console.log(response); // console.log(response);
if (response.data) { if (response.data) {
...@@ -421,8 +426,8 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -421,8 +426,8 @@ export default class FixedAssetsMovementMR extends Component {
this.getSubmission() this.getSubmission()
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
}) })
} }
}) })
} }
closeAlert() { closeAlert() {
...@@ -446,7 +451,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -446,7 +451,7 @@ export default class FixedAssetsMovementMR extends Component {
// console.log(item); // console.log(item);
// console.log(items); // console.log(items);
// console.log(subForm); // console.log(subForm);
let re = /^[a-zA-Z0-9_]+$/; let re = /^[a-zA-Z0-9_]+$/;
if (item !== "") { if (item !== "") {
if (items == ']') { if (items == ']') {
...@@ -477,14 +482,14 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -477,14 +482,14 @@ export default class FixedAssetsMovementMR extends Component {
console.log(tst); console.log(tst);
let indexID = dataTable2[tableMeta.rowIndex][13].findIndex((val) => val.item_formula == tst) let indexID = dataTable2[tableMeta.rowIndex][13].findIndex((val) => val.item_formula == tst)
// console.log(indexID); // console.log(indexID);
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = dataTable2[tableMeta.rowIndex][13][indexID].value let valuezz = dataTable2[tableMeta.rowIndex][13][indexID].value
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
// console.log(valuezz); // console.log(valuezz);
} }
} else { } else {
let data = tableMeta.rowData[13] == null? [] : tableMeta.rowData[13] let data = tableMeta.rowData[13] == null ? [] : tableMeta.rowData[13]
let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`)) let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = data[indexID].value let valuezz = data[indexID].value
...@@ -507,7 +512,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -507,7 +512,7 @@ export default class FixedAssetsMovementMR extends Component {
if (item == '-' || item == '+' || item == '/' || item == '*') { if (item == '-' || item == '+' || item == '/' || item == '*') {
opet = item opet = item
} else { } else {
anjay.push(opet == ''? Number(item) : Number(String(opet + String(item)))) anjay.push(opet == '' ? Number(item) : Number(String(opet + String(item))))
tambahan = false tambahan = false
opet = "" opet = ""
} }
...@@ -655,7 +660,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -655,7 +660,7 @@ export default class FixedAssetsMovementMR extends Component {
// console.log(dataTable2[tableMeta.rowIndex][type]); // console.log(dataTable2[tableMeta.rowIndex][type]);
// console.log(value); // console.log(value);
} }
const handleValue = (data, type) => { const handleValue = (data, type) => {
// console.log(data, type); // console.log(data, type);
let total = 0 let total = 0
...@@ -670,23 +675,23 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -670,23 +675,23 @@ export default class FixedAssetsMovementMR extends Component {
// console.log(indexParent); // console.log(indexParent);
return a return a
} }
const handleVariance = (tableMeta, dex, type) => { const handleVariance = (tableMeta, dex, type) => {
let total = 0 let total = 0
// if (dex === 1) { // if (dex === 1) {
// total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[9]) == NaN? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[9]) // total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[9]) == NaN? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[9])
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
// console.log(tableMeta.rowData[8]); // console.log(tableMeta.rowData[8]);
// console.log(tableMeta.rowData[9]); // console.log(tableMeta.rowData[9]);
// console.log(total) // console.log(total)
if (dex === 2) { if (dex === 2) {
total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[6]) == NaN? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[6]) total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[6]) == NaN ? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[6])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
// console.log(tableMeta.rowData[8]); // console.log(tableMeta.rowData[8]);
// console.log(tableMeta.rowData[6]); // console.log(tableMeta.rowData[6]);
// console.log(total) // console.log(total)
} else if (dex === 3) { } else if (dex === 3) {
total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[7]) == NaN? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[7]) total = Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[7]) == NaN ? "0.0" : Number(tableMeta.rowData[8]) - Number(tableMeta.rowData[7])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
// console.log(tableMeta.rowData[8]); // console.log(tableMeta.rowData[8]);
// console.log(tableMeta.rowData[7]); // console.log(tableMeta.rowData[7]);
...@@ -694,6 +699,8 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -694,6 +699,8 @@ export default class FixedAssetsMovementMR extends Component {
} }
// console.log(dex) // console.log(dex)
// console.log(Number(tableMeta.columnIndex) + Number(type)) // console.log(Number(tableMeta.columnIndex) + Number(type))
console.log(total);
console.log(dataTable2);
return total return total
} }
...@@ -708,11 +715,11 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -708,11 +715,11 @@ export default class FixedAssetsMovementMR extends Component {
// if (dex === 1) { // if (dex === 1) {
// total = R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9]) // total = R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])
// dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) // dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
// if (tableMeta.rowData[5] === "Cash and cash equivalent") { // if (tableMeta.rowData[5] === "Cash and cash equivalent") {
// console.log(total); // console.log(total);
// console.log(Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10])); // console.log(Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10]));
// console.log(dataTable2[tableMeta.rowIndex]); // console.log(dataTable2[tableMeta.rowIndex]);
// } // }
if (dex === 2) { if (dex === 2) {
total = R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6]) total = R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][9]) / Number(dataTable2[tableMeta.rowIndex][6])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
...@@ -758,24 +765,31 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -758,24 +765,31 @@ export default class FixedAssetsMovementMR extends Component {
} }
}, },
{ {
name: "Account", name: "Account",
options: { options: {
customHeadRender: (columnMeta) => ( customHeadRender: (columnMeta) => (
<TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300, borderRight: '1px #fff solid' }}> <TableCell key={columnMeta.index} style={{ ...style, top: 0, zIndex: 102, backgroundColor: '#1c71b8', width: 300, borderRight: '1px #fff solid' }}>
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography> <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'left' }}>{columnMeta.name}</Typography>
</TableCell> </TableCell>
), ),
setCellProps: () => ({ style }), setCellProps: () => ({ style }),
customBodyRender: (value, tableMeta) => { customBodyRender: (value, tableMeta) => {
return ( return (
<div style={{ width: 300 }}> <div style={{ width: 300 }}>
{tableMeta.rowData[24] ? {tableMeta.rowData[24] ?
tableMeta.rowData[24].length > 0 ? tableMeta.rowData[24].length > 0 ?
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}> <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<LightTooltip title={"Report Items Not Registered"} arrow> <LightTooltip title={"Report Items Not Registered"} arrow>
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : value}</span> <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : value}</span>
</LightTooltip> </LightTooltip>
</div> </div>
:
tableMeta.rowData[4] === 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : value).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : value}</span>
</div>
: :
tableMeta.rowData[4] === 0 ? tableMeta.rowData[4] === 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : value).toUpperCase()}</span> <span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : value).toUpperCase()}</span>
...@@ -783,50 +797,43 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -783,50 +797,43 @@ export default class FixedAssetsMovementMR extends Component {
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}> <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : value}</span> <span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : value}</span>
</div> </div>
: }
tableMeta.rowData[4] === 0 ? </div>
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : value).toUpperCase()}</span> )
: }
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : value}</span>
</div>
}
</div>
)
} }
} }, {
}, { name: `Month To Date (MTD)`,
name: `Month To Date (MTD)`, options: {
options: { customHeadRender: (columnMeta) => (
customHeadRender: (columnMeta) => ( <th style={{ ...style2, color: '#fff', backgroundColor: '#1c71b8', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)", padding: 0 }} >
<th style={{ ...style2, color: '#fff', backgroundColor: '#1c71b8', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)", padding: 0 }} > {/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
{/* <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#1c71b8', width: 96 }}>
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography> <Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell> */} </TableCell> */}
<div style={{ borderBottom: "1px #fff solid", backgroundColor: '#1c71b8', justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45}}>{columnMeta.name}</div> <div style={{ borderBottom: "1px #fff solid", backgroundColor: '#1c71b8', justifyContent: 'center', display: 'flex', alignItems: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45 }}>{columnMeta.name}</div>
<div className="grid grid-3x" style={{ ...style2, color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}> <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', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}> <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<span>{"Master Budget (MB)"}</span> <span>{"Master Budget (MB)"}</span>
</div> </div>
<div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}> <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, borderRight: "1px #fff solid", backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<span>{"Rolling Budget (RB)"}</span> <span>{"Rolling Budget (RB)"}</span>
</div> </div>
<div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}> <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, backgroundColor: '#07a7d0', height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<span>{"Actual"}</span> <span>{"Actual"}</span>
</div>
</div> </div>
</div> </th>
</th> ),
), setCellProps: () => ({ style2 }),
setCellProps: () => ({ style2 }), customBodyRender: (value, tableMeta, updateValue) => {
customBodyRender: (value, tableMeta, updateValue) => { return (
return ( <div>
<div> <div className="grid grid-3x content-center">
<div className="grid grid-3x content-center"> <div className="col-1">
<div className="col-1"> <div style={{ textAlign: 'right', width: 90 }}>
<div style={{ textAlign: 'right', width: 90 }}> {
{ tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? null :
null :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -843,55 +850,14 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -843,55 +850,14 @@ export default class FixedAssetsMovementMR extends Component {
} }
/> />
</div> </div>
} }
</div> </div>
</div>
<div className="col-2">
<div style={{ textAlign: 'right', width: 90 }}>
{
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null :
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[7]).toFixed(1)}
/>
}
/>
</div>
}
</div> </div>
</div> <div className="col-2">
<div className="col-3"> <div style={{ textAlign: 'right', width: 90 }}>
<div style={{ textAlign: 'right', width: 120 }}> {
{ tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? null :
null :
this.state.get_for == 'view'?
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[8]).toFixed(1)}
/>
}
/>
:
tableMeta.rowData[0] === 3 ?
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -899,312 +865,353 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -899,312 +865,353 @@ export default class FixedAssetsMovementMR extends Component {
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
// style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
style={{ color: this.props.isApprover || this.state.get_for == 'view'? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[7]).toFixed(1)}
/>
}
/>
</div>
}
</div>
</div>
<div className="col-3">
<div style={{ textAlign: 'right', width: 120 }}>
{
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null :
this.state.get_for == 'view' ?
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={this.props.isApprover? true : (this.state.get_for == 'view'? true : false)} disabled={true}
value={Number(tableMeta.rowData[8]).toFixed(1)} value={Number(tableMeta.rowData[8]).toFixed(1)}
onBlur={(event) => {
handleChange(event.target.value, tableMeta, 8)
}}
/> />
} }
/> />
</div> : :
tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6? tableMeta.rowData[0] === 3 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <div style={{ flex: 1 }}>
<NumberFormat <FormControlLabel
thousandSeparator={true} style={{ margin: 0 }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} value={value}
type="text" control={
placeholder="" <NumberFormat
disabled={true} thousandSeparator={true}
value={Number(handleValueFormula(tableMeta, 8)).toFixed(1)} // style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
/> style={{ color: this.props.isApprover || this.state.get_for == 'view' ? 'black' : "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
</span> : type="text"
<div style={{ flex: 1 }}> placeholder=""
<FormControlLabel disabled={this.props.isApprover ? true : (this.state.get_for == 'view' ? true : false)}
style={{ margin: 0 }} value={Number(tableMeta.rowData[8]).toFixed(1)}
value={value} onBlur={(event) => {
control={ handleChange(event.target.value, tableMeta, 8)
}}
/>
}
/>
</div> :
tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(tableMeta.rowData[8]).toFixed(1)} value={Number(handleValueFormula(tableMeta, 8)).toFixed(1)}
/> />
} </span> :
/> <div style={{ flex: 1 }}>
</div> <FormControlLabel
} style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[8]).toFixed(1)}
/>
}
/>
</div>
}
</div>
</div> </div>
</div> </div>
</div> </div>
</div> )
) }
} }
} }, {
}, { name: `Variance`,
name: `Variance`, options: {
options: { customHeadRender: (columnMeta) => (
customHeadRender: (columnMeta) => ( <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
<th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} > <div style={{ borderLeft: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>{columnMeta.name}</div>
<div style={{ borderLeft: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>{columnMeta.name}</div> <div className="grid grid-2x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
<div className="grid grid-2x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}> <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}>
<div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}> <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}> <span>{"Act vs MB"}</span>
<span>{"Act vs MB"}</span>
</div>
<div className="grid grid-2x">
<div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Amount"}</span>
</div> </div>
<div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}> <div className="grid grid-2x">
<span>{"%"}</span> <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Amount"}</span>
</div>
<div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"%"}</span>
</div>
</div> </div>
</div> </div>
</div> <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}>
<div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}> <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}> <span>{"Act vs RB"}</span>
<span>{"Act vs RB"}</span>
</div>
<div className="grid grid-2x">
<div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Amount"}</span>
</div> </div>
<div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}> <div className="grid grid-2x">
<span>{"%"}</span> <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Amount"}</span>
</div>
<div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"%"}</span>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </th>
</th> ),
), setCellProps: () => ({
setCellProps: () => ({ style: {
style: { paddingLeft: 0,
paddingLeft: 0, paddingRight: 10
paddingRight: 10 }
} }),
}), customBodyRender: (val, tableMeta, updateValue) => {
customBodyRender: (val, tableMeta, updateValue) => { // console.log(tableMeta);
// console.log(tableMeta); return (
return ( <div>
<div> <div className="grid grid-2x content-center">
<div className="grid grid-2x content-center"> <div className="column-1">
<div className="column-1"> <div className="grid grid-2x content-center">
<div className="grid grid-2x content-center"> <div className="column-1">
<div className="column-1"> <div style={{ textAlign: 'right', width: 120 }}>
<div style={{ textAlign: 'right', width: 120 }}> {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? null :
null : this.state.get_for == 'view' ?
this.state.get_for == 'view'? <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={val}
value={val} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} value={Number(tableMeta.rowData[9]).toFixed(1)}
value={Number(tableMeta.rowData[9]).toFixed(1)} />
/> }
} />
/> :
: <div style={{ flex: 1 }}>
<div style={{ flex: 1 }}> <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={val}
value={val} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} value={Number(handleVariance(tableMeta, 2, 2)).toFixed(1)}
value={Number(handleVariance(tableMeta, 2, 2)).toFixed(1)} />
}
/> />
} </div>
/> }
</div> </div>
}
</div> </div>
</div> <div className="column-2">
<div className="column-2"> <div style={{ textAlign: 'right', width: 120 }}>
<div style={{ textAlign: 'right', width: 120 }}> {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? null :
null : this.state.get_for == 'view' ?
this.state.get_for == 'view'? <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={val}
value={val} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} suffix={'%'}
suffix={'%'} value={Number(Number(tableMeta.rowData[10]) * 100).toFixed(1)}
value={Number(Number(tableMeta.rowData[10]) * 100).toFixed(1)} />
/> }
} />
/> :
: <div style={{ flex: 1 }}>
<div style={{ flex: 1 }}> <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={val}
value={val} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} suffix={'%'}
suffix={'%'} // value={0}
// value={0} value={Number(handleVariancePercent(tableMeta, 2, 3)).toFixed(1)}
value={Number(handleVariancePercent(tableMeta, 2, 3)).toFixed(1)} />
}
/> />
} </div>
/> }
</div> </div>
}
</div> </div>
</div> </div>
</div> </div>
</div> <div className="column-2">
<div className="column-2"> <div className="grid grid-2x content-center">
<div className="grid grid-2x content-center"> <div className="column-1">
<div className="column-1"> <div style={{ textAlign: 'right', width: 120 }}>
<div style={{ textAlign: 'right', width: 120 }}> {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? null :
null : this.state.get_for == 'view' ?
this.state.get_for == 'view'? <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={val}
value={val} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} value={Number(tableMeta.rowData[11]).toFixed(1)}
value={Number(tableMeta.rowData[11]).toFixed(1)} />
/> }
} />
/> :
: <div style={{ flex: 1 }}>
<div style={{ flex: 1 }}> <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={val}
value={val} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} value={Number(handleVariance(tableMeta, 3, 4)).toFixed(1)}
value={Number(handleVariance(tableMeta, 3, 4)).toFixed(1)} />
}
/> />
} </div>
/> }
</div> </div>
}
</div> </div>
</div> <div className="column-2">
<div className="column-2"> <div style={{ textAlign: 'right', width: 120 }}>
<div style={{ textAlign: 'right', width: 120 }}> {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
{tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ? null :
null : this.state.get_for == 'view' ?
this.state.get_for == 'view'? <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={val}
value={val} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} suffix={'%'}
suffix={'%'} value={Number(Number(tableMeta.rowData[10]) * 100).toFixed(1)}
value={Number(Number(tableMeta.rowData[10]) * 100).toFixed(1)} />
/> }
} />
/> :
: <div style={{ flex: 1 }}>
<div style={{ flex: 1 }}> <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={val}
value={val} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} suffix={'%'}
suffix={'%'} // value={0}
// value={0} value={Number(handleVariancePercent(tableMeta, 3, 5)).toFixed(1)}
value={Number(handleVariancePercent(tableMeta, 3, 5)).toFixed(1)} />
}
/> />
} </div>
/> }
</div> </div>
}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> )
) }
} }
} }, {
}, { name: "",
name: "", options: {
options: { display: false
display: false }
} }, {
}, { name: "",
name: "", options: {
options: { display: false
display: false }
} }, {
}, { name: "",
name: "", options: {
options: { display: false
display: false }
} }, {
}, { name: "",
name: "", options: {
options: { display: false
display: false }
} }, {
}, { name: "",
name: "", options: {
options: { display: false
display: false }
} }, {
}, { name: "",
name: "", options: {
options: { display: false
display: false }
} }, {
}, { name: "",
name: "", options: {
options: { display: false
display: false }
} }]
}]
const loadingComponent = ( const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}> <div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
...@@ -1242,7 +1249,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1242,7 +1249,7 @@ export default class FixedAssetsMovementMR extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div> </div>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
{this.props.isApprover === true || this.state.get_for == 'view'? {this.props.isApprover === true || this.state.get_for == 'view' ?
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download'} data-for="download"> <a data-tip={'Download'} data-for="download">
<button <button
...@@ -1273,7 +1280,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1273,7 +1280,7 @@ export default class FixedAssetsMovementMR extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => this.downloadTemplate() } onClick={() => this.downloadTemplate()}
> >
<img src={Images.template} /> <img src={Images.template} />
</button> </button>
...@@ -1301,10 +1308,10 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1301,10 +1308,10 @@ export default class FixedAssetsMovementMR extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => onClick={() =>
this.setState({ loading: true }, () => { this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.downloadAllData() this.downloadAllData()
}, 100); }, 100);
})} })}
> >
...@@ -1318,7 +1325,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1318,7 +1325,7 @@ export default class FixedAssetsMovementMR extends Component {
</div> </div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && !this.state.refresh && ( {!this.state.refresh && (
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
...@@ -1353,7 +1360,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1353,7 +1360,7 @@ export default class FixedAssetsMovementMR extends Component {
</button> </button>
</div> </div>
{this.props.isApprover === true ? {this.props.isApprover === true ?
<div className="col-2"></div> <div className="col-2"></div>
: :
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}> <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%', paddingRight: 5 }}>
{this.state.get_for == 'view' && this.state.viewOnly && <button {this.state.get_for == 'view' && this.state.viewOnly && <button
...@@ -1366,8 +1373,11 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1366,8 +1373,11 @@ export default class FixedAssetsMovementMR extends Component {
outline: 'none' outline: 'none'
}} }}
onClick={() => { onClick={() => {
this.setState({loading: true, refresh: true}, () => { this.setState({ loading: true, refresh: true }, () => {
this.handleGetFor('edit') this.handleGetFor('edit')
// setTimeout(() => {
// this.setState({ loading: false })
// }, 100);
}) })
}} }}
> >
...@@ -1444,7 +1454,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1444,7 +1454,7 @@ export default class FixedAssetsMovementMR extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
</div> </div>
</button>} </button>}
</div> </div>
} }
</div> </div>
</Paper> : </Paper> :
...@@ -1459,7 +1469,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1459,7 +1469,7 @@ export default class FixedAssetsMovementMR extends Component {
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography> <Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div> </div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && ( {!this.state.refresh && (
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
...@@ -1562,7 +1572,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1562,7 +1572,7 @@ export default class FixedAssetsMovementMR extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
</div> </div>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
</Paper> </Paper>
......
...@@ -167,7 +167,7 @@ export default class ListOfCreditFacilities extends Component { ...@@ -167,7 +167,7 @@ export default class ListOfCreditFacilities extends Component {
checkStatus = false checkStatus = false
} }
// this.setState({viewOnly: !checkApprover && checkLastStatus && checkStatus}) this.setState({viewOnly: !checkApprover && checkLastStatus && checkStatus})
} }
getItemHierarki() { getItemHierarki() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment