Commit 6fe8586b authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

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

parents de54a1ba 5340be35
...@@ -38,7 +38,7 @@ const create = (type = "") => { ...@@ -38,7 +38,7 @@ const create = (type = "") => {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
// 40 second timeout... // 40 second timeout...
timeout: 40000 timeout: 50000
}) })
break; break;
default: default:
...@@ -202,6 +202,9 @@ const create = (type = "") => { ...@@ -202,6 +202,9 @@ const create = (type = "") => {
const getAllOperatingInd = (body) => api.post('transaction/get_all_operating_indicator_report', body) const getAllOperatingInd = (body) => api.post('transaction/get_all_operating_indicator_report', body)
const getOperatingIndDetail = (body) => api.post('transaction/operating_indicator/get_operating_indicator_report_hierarki', body) const getOperatingIndDetail = (body) => api.post('transaction/operating_indicator/get_operating_indicator_report_hierarki', body)
const createOpetaingInd = (body) => api.post('transaction/operating_indicator/create_submission_report', body) const createOpetaingInd = (body) => api.post('transaction/operating_indicator/create_submission_report', body)
const checkUploadOperatingInd = (body) => api.post('transaction/operating_indicator/check_import', body)
const uploadOperatingInd = (body) => api.post('transaction/operating_indicator/import_operating_indicator', body)
//Template //Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`) const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
...@@ -343,7 +346,9 @@ const create = (type = "") => { ...@@ -343,7 +346,9 @@ const create = (type = "") => {
getOpetratingIndID, getOpetratingIndID,
createAllItemReport, createAllItemReport,
deleteAllItemReport, deleteAllItemReport,
validateSubmitReport validateSubmitReport,
checkUploadOperatingInd,
uploadOperatingInd
} }
} }
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, withStyles, makeStyles } from '@material-ui/core'; import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, withStyles, makeStyles, Snackbar } from '@material-ui/core';
import MUIDataTable from 'mui-datatables'; import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import api from '../../api'; import api from '../../api';
...@@ -11,7 +11,7 @@ import ReactTooltip from 'react-tooltip'; ...@@ -11,7 +11,7 @@ import ReactTooltip from 'react-tooltip';
import Tooltip from '@material-ui/core/Tooltip'; import Tooltip from '@material-ui/core/Tooltip';
import { titleCase } from '../../library/Utils'; import { titleCase } from '../../library/Utils';
import Constant from '../../library/Constant'; import Constant from '../../library/Constant';
import { Autocomplete } from '@material-ui/lab'; import { Alert, Autocomplete } from '@material-ui/lab';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
...@@ -60,8 +60,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -60,8 +60,9 @@ export default class CorporateAnnualTarget extends Component {
kpiTypeList: [], kpiTypeList: [],
maxAchList: [], maxAchList: [],
visibleCAT: true, visibleCAT: true,
buttonError: false buttonError: true,
// formulaYTDList: null, // formulaYTDList: null,,
dataDelete: []
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -383,14 +384,15 @@ export default class CorporateAnnualTarget extends Component { ...@@ -383,14 +384,15 @@ export default class CorporateAnnualTarget extends Component {
}) })
} }
backToMasterBudget(type) { handleValidate() {
let data = [] let data = []
console.log(this.state.dataTable) console.log(this.state.dataTable)
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
// console.log(i[9] == null? "" : i[9].value) // console.log(i[9] == null? "" : i[9].value)
data.push({ data.push({
"item_report_id": i[1], "item_report_id": i[1],
"item_report": String(i[6]), "item_name": i[1] !== ""? null : String(i[6]),
"parent": i[1] !== ""? null : i[2],
"weight": String(i[7]), "weight": String(i[7]),
"uom": String(i[8]), "uom": String(i[8]),
"kpi_type": i[9] == null? "" : i[9].value, "kpi_type": i[9] == null? "" : i[9].value,
...@@ -422,34 +424,100 @@ export default class CorporateAnnualTarget extends Component { ...@@ -422,34 +424,100 @@ export default class CorporateAnnualTarget extends Component {
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
"periode": this.props.periode, "periode": this.props.periode,
"report_id": this.props.report_id, "report_id": this.props.report_id,
"status": type, "status": "submitted",
"cat": data "cat": data
} }
console.log(JSON.stringify(payload)); api.create().validateSubmitReport(payload).then((response) => {
this.addNewReport(payload) console.log(response)
if (response.data.data.result) {
this.setState({ loading: false, buttonError: false, editable: true })
} else {
this.setState({ loading: false, buttonError: true, editable: true })
} }
})
addNewReport(payloadBro) {
let data = this.state.dataTable.map((item,index) => {
if (item[1] == "") {
return {
"item_name": item[6],
"parent": item[2]
} }
closeAlert() {
this.setState({ alert: false })
} }
})
backToMasterBudget(type) {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
// console.log(i[9] == null? "" : i[9].value)
data.push({
"item_report_id": i[1],
"item_name": i[1] !== ""? null : String(i[6]),
"parent": i[1] !== ""? null : i[2],
"weight": String(i[7]),
"uom": String(i[8]),
"kpi_type": i[9] == null? "" : i[9].value,
"max_ach": i[10] == null? "" : i[10].value,
"formula": i[11] == null? "" : i[11].value,
"total_actual_before": String(i[12]),
"january": String(i[13]),
"february": String(i[14]),
"march": String(i[15]),
"april": String(i[16]),
"may": String(i[17]),
"june": String(i[18]),
"july": String(i[19]),
"august": String(i[20]),
"september": String(i[21]),
"october": String(i[22]),
"november": String(i[23]),
"december": String(i[24]),
"total_current_year": String(i[25]),
"total_next_year": String(i[26]),
"total_more_year": String(i[27]),
"strategic": String(i[28]),
"pic": String(i[29])
})
})
console.log(JSON.stringify(data))
let payload = { let payload = {
"company_id": 1, "submission_id": this.props.submissionID,
"item_report": data "company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"cat": data
} }
console.log(JSON.stringify(payload));
this.deleteReport(payload)
}
deleteReport(payloadBro) {
let payload = {"item_report_id": this.state.dataDelete}
api.create().createAllItemReport(payload).then((response) => { if (this.state.dataDelete.length > 0) {
api.create().deleteAllItemReport(payload).then((response) => {
console.log(response)
// api.create().validateSubmitReport(payloadBro).then((response) => {
// console.log(response)
// if (response.data.data.result) {
this.props.saveToMasterBudget(payloadBro) this.props.saveToMasterBudget(payloadBro)
this.props.onClickClose() this.props.onClickClose()
// } else {
// }
// })
}) })
} else {
// api.create().validateSubmitReport(payloadBro).then((response) => {
// console.log(response)
// if (response.data.data.result) {
this.props.saveToMasterBudget(payloadBro)
this.props.onClickClose()
// } else {
// }
// })
} }
}
getKPIType() { getKPIType() {
let body = { let body = {
...@@ -536,6 +604,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -536,6 +604,7 @@ export default class CorporateAnnualTarget extends Component {
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
let dataDelete = this.state.dataDelete
const handleChange = (value, tableMeta) => { const handleChange = (value, tableMeta) => {
let val = String(value).split(",").join("") let val = String(value).split(",").join("")
let total = 0 let total = 0
...@@ -564,63 +633,6 @@ export default class CorporateAnnualTarget extends Component { ...@@ -564,63 +633,6 @@ export default class CorporateAnnualTarget extends Component {
// this.setState({dataTable: dataTable2}) // this.setState({dataTable: dataTable2})
} }
const handleValue = (data) => {
let total = 0
dataTable2.map((item, index) => {
if (data.rowData[1] == item[2]) {
total = item[data.columnIndex] == undefined ? (Number(total) + 0) : (Number(total) + Number(item[data.columnIndex]))
}
})
let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[data.rowIndex][2])
let a = dataTable2[data.rowIndex][data.columnIndex] = Number(total)
// console.log(indexParent);
return a
}
const handleFormula = (data, tableMeta) => {
let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let arrayJumlah = []
arrayFormula.map((item, indexs) => {
let index = dataTable2.findIndex((val) => val[1] == item)
if (index > 0) {
arrayJumlah.push(dataTable2[index][tableMeta.columnIndex])
} else {
arrayJumlah.push(item)
}
// if (indexs % 2 !== 0) {
// operator.push(item)
// }
})
let array = arrayJumlah
let total = 0
let opt = ""
array.map((item, index) => {
if (item == "+") {
opt = "tambah"
} else if (item == "-") {
opt = "kurang"
} else if (item == "*") {
opt = "kali"
} else if (item == "/") {
opt = "bagi"
} else {
if (opt == "tambah") {
total = Number(total) + Number(item)
} else if (opt == "kurang") {
total = Number(total) - Number(item)
} else if (opt == "kali") {
total = Number(total) * Number(item)
} else if (opt == "bagi") {
total = Number(total) / Number(item)
} else {
total += item
}
}
})
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
return a
}
const handleAction = (idParent) => { const handleAction = (idParent) => {
if (idParent !== null) { if (idParent !== null) {
let indexsss = dataTable2.findIndex((val) => val[1] == idParent) let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
...@@ -634,12 +646,12 @@ export default class CorporateAnnualTarget extends Component { ...@@ -634,12 +646,12 @@ export default class CorporateAnnualTarget extends Component {
} }
} }
const handleTambah = (data) => { const handleTambah = (data, rowIndex) => {
console.log(dataTable2) console.log(dataTable2)
let newData = [] let newData = []
dataTable2.map((item, index) => { dataTable2.map((item, index) => {
newData.push(item) newData.push(item)
if (item[1] == data) { if (index == rowIndex) {
newData.push([ newData.push([
3, 3,
"", "",
...@@ -683,8 +695,11 @@ export default class CorporateAnnualTarget extends Component { ...@@ -683,8 +695,11 @@ export default class CorporateAnnualTarget extends Component {
} }
const handleDelete = (index) => { const handleDelete = (index) => {
if (dataTable2[index][1] !== "") {
dataDelete.push(dataTable2[index][1])
}
dataTable2.splice(index, 1) dataTable2.splice(index, 1)
this.setState({dataTable: dataTable2}, () => { this.setState({dataTable: dataTable2, dataDelete}, () => {
setTimeout(() => { setTimeout(() => {
this.setState({loading: false}) this.setState({loading: false})
}, 500) }, 500)
...@@ -742,7 +757,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -742,7 +757,7 @@ export default class CorporateAnnualTarget extends Component {
// onClick={() => console.log(tableMeta.rowData[1])} // onClick={() => console.log(tableMeta.rowData[1])}
onClick={() => { onClick={() => {
this.setState({loading: true}) this.setState({loading: true})
handleTambah(tableMeta.rowData[1]) handleTambah(tableMeta.rowData[1],tableMeta.rowIndex)
}} }}
> >
<img src={Images.add} /> <img src={Images.add} />
...@@ -1761,6 +1776,11 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1761,6 +1776,11 @@ export default class CorporateAnnualTarget extends Component {
<Typography style={{ fontSize: '16px', color: 'white' }}>Pengajuan Budget Tahunan</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Pengajuan Budget Tahunan</Typography>
</div> </div>
{/* {this.state.loading && loadingComponent} */} {/* {this.state.loading && loadingComponent} */}
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleCAT? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}> {this.state.visibleCAT? <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
...@@ -1847,7 +1867,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1847,7 +1867,7 @@ export default class CorporateAnnualTarget extends Component {
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
}} }}
onClick={() => this.props.onClickClose()} onClick={() => this.backToMasterBudget('draft')}
> >
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <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> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
...@@ -1888,7 +1908,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1888,7 +1908,7 @@ export default class CorporateAnnualTarget extends Component {
onClick={() => { onClick={() => {
this.setState({ loading: true }, () => { this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false, buttonError: false, editable: true }) this.handleValidate()
}, 100); }, 100);
}) })
}} }}
...@@ -1899,8 +1919,10 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1899,8 +1919,10 @@ export default class CorporateAnnualTarget extends Component {
</button> </button>
<button <button
type="button" type="button"
disabled={this.state.buttonError} // disabled={this.state.buttonError}
onClick={() => this.backToMasterBudget('submitted')} onClick={() => this.state.buttonError?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
: this.backToMasterBudget('submitted')}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer', cursor: this.state.buttonError === true ? 'default' : 'pointer',
......
...@@ -352,6 +352,7 @@ export default class ProfitLoss extends Component { ...@@ -352,6 +352,7 @@ export default class ProfitLoss extends Component {
}) })
}) })
let body = { let body = {
submission_id: this.props.submissionID,
company_id: this.props.company.company_id, company_id: this.props.company.company_id,
periode: this.props.periode, periode: this.props.periode,
report_id: this.props.report_id, report_id: this.props.report_id,
...@@ -370,6 +371,9 @@ export default class ProfitLoss extends Component { ...@@ -370,6 +371,9 @@ export default class ProfitLoss extends Component {
} }
} else { } else {
alert(response.problem) alert(response.problem)
this.setState({loading: false})
this.props.onClickClose()
this.props.getReport()
} }
}) })
} }
...@@ -406,15 +410,20 @@ export default class ProfitLoss extends Component { ...@@ -406,15 +410,20 @@ export default class ProfitLoss extends Component {
// } else { // } else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// } // }
}
}
const handleTotal = (tableMeta) => {
let total = 0 let total = 0
dataTable2[tableMeta.rowIndex].map((item,index) => { dataTable2[tableMeta.rowIndex].map((item, index) => {
if (index >= 8 && index <= 19) { if (index >= 7 && index <= 18) {
let valItem = item == undefined || item == ""? 0 : item let valItem = item == undefined || item == "" ? 0 : item
total += Number(valItem) total += Number(valItem)
} }
}) })
dataTable2[tableMeta.rowIndex][20] = total dataTable2[tableMeta.rowIndex][19] = total
} return total
// console.log(total);
} }
const handleNotes = (value, tableMeta) => { const handleNotes = (value, tableMeta) => {
console.log(value) console.log(value)
...@@ -557,14 +566,14 @@ export default class ProfitLoss extends Component { ...@@ -557,14 +566,14 @@ export default class ProfitLoss extends Component {
{tableMeta.rowData[4] === 0 ? null : tableMeta.rowData[4] === 1 ? null : {tableMeta.rowData[4] === 0 ? null : tableMeta.rowData[4] === 1 ? null :
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={value} // value={value}
control={ control={
<Input <Input
disableUnderline={true} disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} defaultValue={value}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleNotes(event.target.value, tableMeta) handleNotes(event.target.value, tableMeta)
...@@ -1692,29 +1701,19 @@ export default class ProfitLoss extends Component { ...@@ -1692,29 +1701,19 @@ export default class ProfitLoss extends Component {
setCellProps: () => ({ style2 }), setCellProps: () => ({ style2 }),
customBodyRender: (value, tableMeta, updateValue) => { customBodyRender: (value, tableMeta, updateValue) => {
return ( return (
<div style={{ textAlign: 'right' }}> <div style={{ width: 96, textAlign: 'right' }}>
{tableMeta.rowData[0] === 3 ? {tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
<div style={{ flex: 1 }}> null : tableMeta.rowData[0] === 2 ?
<FormControlLabel <span style={{ fontSize: 12, textAlign: 'right' }}>
style={{ margin: 0 }}
value={value}
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: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={value} disabled={true}
onBlur={(event) => { value={handleValue(tableMeta)}
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
/>
}
/> />
</div> : </span> :
tableMeta.rowData[0] === 2 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
...@@ -1722,50 +1721,9 @@ export default class ProfitLoss extends Component { ...@@ -1722,50 +1721,9 @@ export default class ProfitLoss extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={handleValue(tableMeta)} value={handleTotal(tableMeta)}
/> />
</span> </span>}
:
tableMeta.rowData[0] === 4 ?
null
:
tableMeta.rowData[0] === 6 ?
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={handleFormula(value, tableMeta)}
// />
null
:
tableMeta.rowData[0] === 5 ?
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={handleFormula(value, tableMeta)}
// />
null
:
tableMeta.rowData[0] === 1 ?
// value === "" ?
// null :
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(value)}
// />
null
:
null
}
</div> </div>
) )
} }
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel } from '@material-ui/core'; import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel, createMuiTheme, MuiThemeProvider } 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 OperatingIndicatorDetail from './OperatingIndicatorDetail' import OperatingIndicatorDetail from './OperatingIndicatorDetail'
...@@ -10,6 +10,9 @@ import { ExcelRenderer } from 'react-excel-renderer'; ...@@ -10,6 +10,9 @@ import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { format } from 'date-fns'; import { format } from 'date-fns';
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
export default class OperatingIndicator extends Component { export default class OperatingIndicator extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -121,7 +124,7 @@ export default class OperatingIndicator extends Component { ...@@ -121,7 +124,7 @@ export default class OperatingIndicator extends Component {
let index = data.sort((a, b) => a - b).findIndex((val) => val == year) let index = data.sort((a, b) => a - b).findIndex((val) => val == year)
this.setState({ listPeriode: defaultProps, periode: index == -1 ? periodeData[0] : periodeData[index] }, () => { this.setState({ listPeriode: defaultProps, periode: index == -1 ? periodeData[0] : periodeData[index] }, () => {
this.getReport() this.getReport()
this.getSubmission() this.getOperatingID()
}) })
} }
} }
...@@ -156,7 +159,7 @@ export default class OperatingIndicator extends Component { ...@@ -156,7 +159,7 @@ export default class OperatingIndicator extends Component {
}) })
} }
getSubmission() { getOperatingID() {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
"periode": this.state.periode.periode "periode": this.state.periode.periode
...@@ -353,7 +356,7 @@ export default class OperatingIndicator extends Component { ...@@ -353,7 +356,7 @@ export default class OperatingIndicator extends Component {
id="periode" id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.getReport() this.getReport()
this.getSubmission() this.getOperatingID()
// this.getReportAttachment() // this.getReportAttachment()
})} })}
debug debug
...@@ -369,7 +372,7 @@ export default class OperatingIndicator extends Component { ...@@ -369,7 +372,7 @@ export default class OperatingIndicator extends Component {
id="company" id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => { onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.getReport() this.getReport()
this.getSubmission() this.getOperatingID()
// this.getReportAttachment() // this.getReportAttachment()
})} })}
debug debug
...@@ -379,72 +382,15 @@ export default class OperatingIndicator extends Component { ...@@ -379,72 +382,15 @@ export default class OperatingIndicator extends Component {
value={this.state.company} value={this.state.company}
/> />
</div> </div>
{/* <div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listRevision}
id="revision"
onChange={(event, newInputValue) => this.setState({ revision: newInputValue }, () => {
this.getReport()
this.getReportAttachment()
})}
debug
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Revision" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.revision}
/>
</div> */}
<div style={{ marginTop: 20 }}> <div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={this.state.dataTable} data={this.state.dataTable}
columns={columns} columns={columns}
options={options} options={options}
open={this.props.open}
height={this.props.height}
width={this.props.width}
/> />
</MuiThemeProvider>
</div> </div>
{/* <div style={{ display: 'flex', marginTop: 20 }}>
<div style={{ width: '50%' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
</div>
<div style={{ width: '50%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<Typography style={{ fontSize: '16px', color: '#5198ea' }}>Upload File</Typography>
</button>
</div>
</div>
<div style={{ display: 'flex', marginTop: 10 }}>
<div style={{ width: '50%', paddingLeft: 20 }}>
{this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item) => {
return (
<Typography style={{ fontSize: '16px', color: '#4b4b4b' }}>{item.attachment_name}</Typography>
)
})
: null
}
</div>
<div style={{ width: '50%' }}>
{this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item) => {
return (
<Typography style={{ fontSize: '16px', color: '#ff3939' }}>Delete</Typography>
)
})
: null
}
</div>
</div> */}
</div> </div>
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} > <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
...@@ -459,6 +405,7 @@ export default class OperatingIndicator extends Component { ...@@ -459,6 +405,7 @@ export default class OperatingIndicator extends Component {
{this.state.visibleDetailOpt && {this.state.visibleDetailOpt &&
<OperatingIndicatorDetail <OperatingIndicatorDetail
open={this.props.open}
data={this.state.dataDetail} data={this.state.dataDetail}
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
......
...@@ -53,7 +53,7 @@ export default class BalanceSheet extends Component { ...@@ -53,7 +53,7 @@ export default class BalanceSheet extends Component {
componentDidMount() { componentDidMount() {
// this.getItemHierarki() // this.getItemHierarki()
this.getDataDetail() this.getDataDetail()
console.log(this.props.data); console.log(this.props);
} }
getDataDetail() { getDataDetail() {
...@@ -79,6 +79,7 @@ export default class BalanceSheet extends Component { ...@@ -79,6 +79,7 @@ export default class BalanceSheet extends Component {
item.formula, item.formula,
item.level, item.level,
item.description, item.description,
item.uom,
item.master_budget.total_actual_before, item.master_budget.total_actual_before,
item.master_budget.january, item.master_budget.january,
item.master_budget.february, item.master_budget.february,
...@@ -265,61 +266,36 @@ export default class BalanceSheet extends Component { ...@@ -265,61 +266,36 @@ export default class BalanceSheet extends Component {
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
console.log(isi); console.log(isi);
let payload = [] let payload = []
let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
isi.map((i, index) => { isi.map((i, index) => {
if (i.length > 0) { if (i.length > 0) {
payload.push({ payload.push({
item_report_id: i[0] === undefined ? "" : String(i[0]).trim(), item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(), item_report: i[1] === undefined ? "" : String(i[1]).trim(),
total_actual_before: i[2] === undefined ? "" : String(i[2]).trim(), total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
january: i[3] === undefined ? "" : String(i[3]).trim(), january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
february: i[4] === undefined ? "" : String(i[4]).trim(), february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
march: i[5] === undefined ? "" : String(i[5]).trim(), march: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
april: i[6] === undefined ? "" : String(i[6]).trim(), april: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
may: i[7] === undefined ? "" : String(i[7]).trim(), may: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
june: i[8] === undefined ? "" : String(i[8]).trim(), june: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
july: i[9] === undefined ? "" : String(i[9]).trim(), july: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
august: i[10] === undefined ? "" : String(i[10]).trim(), august: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
september: i[11] === undefined ? "" : String(i[11]).trim(), september: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
october: i[12] === undefined ? "" : String(i[12]).trim(), october: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
november: i[13] === undefined ? "" : String(i[13]).trim(), november: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
december: i[14] === undefined ? "" : String(i[14]).trim(), december: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
total_current_year: i[15] === undefined ? "" : String(i[15]).trim(), total_current_year: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
total_next_year: i[16] === undefined ? "" : String(i[16]).trim(), total_next_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
total_more_year: i[16] === undefined ? "" : String(i[17]).trim() total_more_year: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()
}) })
} }
}) })
let rows = isi.map((i, index) => {
return [
String(i[0]) === '-' ? 4 : 3,
0,
0,
"",
1,
i[0] === undefined ? "" : String(i[0]),
i[1] === undefined ? "" : String(i[1]),
i[2] === undefined ? "" : String(i[2]),
i[3] === undefined ? "" : String(i[3]),
i[4] === undefined ? "" : String(i[4]),
i[5] === undefined ? "" : String(i[5]),
i[6] === undefined ? "" : String(i[6]),
i[7] === undefined ? "" : String(i[7]),
i[8] === undefined ? "" : String(i[8]),
i[9] === undefined ? "" : String(i[9]),
i[10] === undefined ? "" : String(i[10]),
i[11] === undefined ? "" : String(i[11]),
i[12] === undefined ? "" : String(i[12]),
i[13] === undefined ? "" : String(i[13]),
i[14] === undefined ? "" : String(i[14]),
i[15] === undefined ? "" : String(i[15]),
i[16] === undefined ? "" : String(i[16])
]
})
let body = { let body = {
company_id: this.props.company.company_id, company_id: this.props.company.company_id,
periode: this.props.periode, periode: this.props.periode,
report_id: this.props.report_id, report_id: this.props.report_id,
balance_sheet: payload master_budget: payload
} }
// console.log(JSON.stringify(body)) // console.log(JSON.stringify(body))
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] }) this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
...@@ -1216,22 +1192,6 @@ export default class BalanceSheet extends Component { ...@@ -1216,22 +1192,6 @@ export default class BalanceSheet extends Component {
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
<button
type="button"
// disabled={this.state.disabledSave}
onClick={() => this.createData()}
style={{
backgroundColor: 'transparent',
cursor: this.state.disabledSave === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center'}}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
<button <button
className="button" className="button"
type="button" type="button"
...@@ -1239,7 +1199,8 @@ export default class BalanceSheet extends Component { ...@@ -1239,7 +1199,8 @@ export default class BalanceSheet extends Component {
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none' outline: 'none',
marginRight: 20
}} }}
onClick={() => { onClick={() => {
this.setState({ loading: true }, () => { this.setState({ loading: true }, () => {
...@@ -1253,6 +1214,22 @@ export default class BalanceSheet extends Component { ...@@ -1253,6 +1214,22 @@ export default class BalanceSheet extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div> </div>
</button> </button>
<button
type="button"
// disabled={this.state.disabledSave}
onClick={() => this.createData()}
style={{
backgroundColor: 'transparent',
cursor: this.state.disabledSave === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
// marginRight: 20
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center'}}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
</div> </div>
</div> </div>
</Paper> </Paper>
......
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