Commit aa3c7621 authored by faisalhamdi's avatar faisalhamdi

update fam

parent 73927f46
......@@ -11,8 +11,17 @@ import ReactTooltip from 'react-tooltip';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
const LightTooltip = withStyles((theme) => ({
tooltip: {
backgroundColor: theme.palette.common.white,
color: 'rgba(0, 0, 0, 0.87)',
boxShadow: theme.shadows[1],
fontSize: 11,
},
}))(Tooltip);
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const getMuiTheme = () => createMuiTheme(ct.customTable3());
const options = ct.customOptionsFixedColumn();
const style = {
......@@ -31,16 +40,12 @@ export default class FixedAssetsMovement extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [
// ["COST", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181", "9,884,181"],
// ["Control", "-", "-"],
// ["Accumulated Depreciation (negative value)", "2,647,647", "2,058,898"],
// ["Control", "-", "-"],
// ["Gain / (Loss) on Fixed Assets", "-", "-"],
// ["Control", "-", "-"]
],
dataTable: [],
visibleFixedAssetsMovement: true,
disabledSave: true
disabledSave: true,
editable: false,
buttonError: false,
judulColumn: null
}
this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this);
......@@ -57,598 +62,18 @@ export default class FixedAssetsMovement extends Component {
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID
}
console.log(payload);
// console.log(payload);
api.create().getDetailReportMB(payload).then(response => {
console.log(response);
let dataTable = []
if (response.data) {
if (response.data.status === "success") {
let dataTable = []
response.data.data.map((item, index) => {
if (item.children && item.children.length > 0) {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.fixed_asset_movement.total_actual_before,
item.fixed_asset_movement.january,
item.fixed_asset_movement.february,
item.fixed_asset_movement.march,
item.fixed_asset_movement.april,
item.fixed_asset_movement.may,
item.fixed_asset_movement.june,
item.fixed_asset_movement.july,
item.fixed_asset_movement.august,
item.fixed_asset_movement.september,
item.fixed_asset_movement.october,
item.fixed_asset_movement.november,
item.fixed_asset_movement.december,
item.fixed_asset_movement.total_current_year,
item.fixed_asset_movement.total_next_year,
item.fixed_asset_movement.total_more_year
])
item.children.map(i => {
if (i.children) {
if (i.children.length > 0) {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.formula,
i.level,
i.description,
i.fixed_asset_movement.total_actual_before,
i.fixed_asset_movement.january,
i.fixed_asset_movement.february,
i.fixed_asset_movement.march,
i.fixed_asset_movement.april,
i.fixed_asset_movement.may,
i.fixed_asset_movement.june,
i.fixed_asset_movement.july,
i.fixed_asset_movement.august,
i.fixed_asset_movement.september,
i.fixed_asset_movement.october,
i.fixed_asset_movement.november,
i.fixed_asset_movement.december,
i.fixed_asset_movement.total_current_year,
i.fixed_asset_movement.total_next_year,
i.fixed_asset_movement.total_more_year
])
i.children.map(val => {
if (val.children && val.children.length > 0) {
dataTable.push([
val.type_report_id,
val.id,
val.parent,
val.formula,
val.level,
val.description,
val.fixed_asset_movement.total_actual_before,
val.fixed_asset_movement.january,
val.fixed_asset_movement.february,
val.fixed_asset_movement.march,
val.fixed_asset_movement.april,
val.fixed_asset_movement.may,
val.fixed_asset_movement.june,
val.fixed_asset_movement.july,
val.fixed_asset_movement.august,
val.fixed_asset_movement.september,
val.fixed_asset_movement.october,
val.fixed_asset_movement.november,
val.fixed_asset_movement.december,
val.fixed_asset_movement.total_current_year,
val.fixed_asset_movement.total_next_year,
val.fixed_asset_movement.total_more_year
])
val.children.map(items => {
if (items.children && items.children.length > 0) {
dataTable.push([
items.type_report_id,
items.id,
items.parent,
items.formula,
items.level,
items.description,
items.fixed_asset_movement.total_actual_before,
items.fixed_asset_movement.january,
items.fixed_asset_movement.february,
items.fixed_asset_movement.march,
items.fixed_asset_movement.april,
items.fixed_asset_movement.may,
items.fixed_asset_movement.june,
items.fixed_asset_movement.july,
items.fixed_asset_movement.august,
items.fixed_asset_movement.september,
items.fixed_asset_movement.october,
items.fixed_asset_movement.november,
items.fixed_asset_movement.december,
items.fixed_asset_movement.total_current_year,
items.fixed_asset_movement.total_next_year,
items.fixed_asset_movement.total_more_year
])
items.children.map(itemss => {
if (itemss.children && itemss.children.length > 0) {
dataTable.push([
itemss.type_report_id,
itemss.id,
itemss.parent,
itemss.formula,
itemss.level,
itemss.description,
itemss.fixed_asset_movement.total_actual_before,
itemss.fixed_asset_movement.january,
itemss.fixed_asset_movement.february,
itemss.fixed_asset_movement.march,
itemss.fixed_asset_movement.april,
itemss.fixed_asset_movement.may,
itemss.fixed_asset_movement.june,
itemss.fixed_asset_movement.july,
itemss.fixed_asset_movement.august,
itemss.fixed_asset_movement.september,
itemss.fixed_asset_movement.october,
itemss.fixed_asset_movement.november,
itemss.fixed_asset_movement.december,
itemss.fixed_asset_movement.total_current_year,
itemss.fixed_asset_movement.total_next_year,
itemss.fixed_asset_movement.total_more_year
])
itemss.children.map(item1 => {
if (item1.children && item1.children.length > 0) {
dataTable.push([
item1.type_report_id,
item1.id,
item1.parent,
item1.formula,
item1.level,
item1.description,
item1.fixed_asset_movement.total_actual_before,
item1.fixed_asset_movement.january,
item1.fixed_asset_movement.february,
item1.fixed_asset_movement.march,
item1.fixed_asset_movement.april,
item1.fixed_asset_movement.may,
item1.fixed_asset_movement.june,
item1.fixed_asset_movement.july,
item1.fixed_asset_movement.august,
item1.fixed_asset_movement.september,
item1.fixed_asset_movement.october,
item1.fixed_asset_movement.november,
item1.fixed_asset_movement.december,
item1.fixed_asset_movement.total_current_year,
item1.fixed_asset_movement.total_next_year,
item1.fixed_asset_movement.total_more_year
])
item1.children.map(item2 => {
if (item2.children && item2.children.length > 0) {
dataTable.push([
item2.type_report_id,
item2.id,
item2.parent,
item2.formula,
item2.level,
item2.description,
item2.fixed_asset_movement.total_actual_before,
item2.fixed_asset_movement.january,
item2.fixed_asset_movement.february,
item2.fixed_asset_movement.march,
item2.fixed_asset_movement.april,
item2.fixed_asset_movement.may,
item2.fixed_asset_movement.june,
item2.fixed_asset_movement.july,
item2.fixed_asset_movement.august,
item2.fixed_asset_movement.september,
item2.fixed_asset_movement.october,
item2.fixed_asset_movement.november,
item2.fixed_asset_movement.december,
item2.fixed_asset_movement.total_current_year,
item2.fixed_asset_movement.total_next_year,
item2.fixed_asset_movement.total_more_year
])
item2.children.map(item3 => {
if (item3.children && item3.children.length > 0) {
dataTable.push([
item3.type_report_id,
item3.id,
item3.parent,
item3.formula,
item3.level,
item3.description,
item3.fixed_asset_movement.total_actual_before,
item3.fixed_asset_movement.january,
item3.fixed_asset_movement.february,
item3.fixed_asset_movement.march,
item3.fixed_asset_movement.april,
item3.fixed_asset_movement.may,
item3.fixed_asset_movement.june,
item3.fixed_asset_movement.july,
item3.fixed_asset_movement.august,
item3.fixed_asset_movement.september,
item3.fixed_asset_movement.october,
item3.fixed_asset_movement.november,
item3.fixed_asset_movement.december,
item3.fixed_asset_movement.total_current_year,
item3.fixed_asset_movement.total_next_year,
item3.fixed_asset_movement.total_more_year
])
item3.children.map(item4 => {
if (item4.children && item4.children.length > 0) {
dataTable.push([
item4.type_report_id,
item4.id,
item4.parent,
item4.formula,
item4.level,
item4.description,
item4.fixed_asset_movement.total_actual_before,
item4.fixed_asset_movement.january,
item4.fixed_asset_movement.february,
item4.fixed_asset_movement.march,
item4.fixed_asset_movement.april,
item4.fixed_asset_movement.may,
item4.fixed_asset_movement.june,
item4.fixed_asset_movement.july,
item4.fixed_asset_movement.august,
item4.fixed_asset_movement.september,
item4.fixed_asset_movement.october,
item4.fixed_asset_movement.november,
item4.fixed_asset_movement.december,
item4.fixed_asset_movement.total_current_year,
item4.fixed_asset_movement.total_next_year,
item4.fixed_asset_movement.total_more_year
])
item4.children.map(item5 => {
if (item5.children && item5.children.length > 0) {
dataTable.push([
item5.type_report_id,
item5.id,
item5.parent,
item5.formula,
item5.level,
item5.description,
item5.fixed_asset_movement.total_actual_before,
item5.fixed_asset_movement.january,
item5.fixed_asset_movement.february,
item5.fixed_asset_movement.march,
item5.fixed_asset_movement.april,
item5.fixed_asset_movement.may,
item5.fixed_asset_movement.june,
item5.fixed_asset_movement.july,
item5.fixed_asset_movement.august,
item5.fixed_asset_movement.september,
item5.fixed_asset_movement.october,
item5.fixed_asset_movement.november,
item5.fixed_asset_movement.december,
item5.fixed_asset_movement.total_current_year,
item5.fixed_asset_movement.total_next_year,
item5.fixed_asset_movement.total_more_year
])
item5.children.map(item6 => {
if (item6.children && item.children.length > 0) {
dataTable.push([
item6.type_report_id,
item6.id,
item6.parent,
item6.formula,
item6.level,
item6.description,
item6.fixed_asset_movement.total_actual_before,
item6.fixed_asset_movement.january,
item6.fixed_asset_movement.february,
item6.fixed_asset_movement.march,
item6.fixed_asset_movement.april,
item6.fixed_asset_movement.may,
item6.fixed_asset_movement.june,
item6.fixed_asset_movement.july,
item6.fixed_asset_movement.august,
item6.fixed_asset_movement.september,
item6.fixed_asset_movement.october,
item6.fixed_asset_movement.november,
item6.fixed_asset_movement.december,
item6.fixed_asset_movement.total_current_year,
item6.fixed_asset_movement.total_next_year,
item6.fixed_asset_movement.total_more_year
])
} else {
dataTable.push([
item6.type_report_id,
item6.id,
item6.parent,
item6.formula,
item6.level,
item6.description,
item6.fixed_asset_movement.total_actual_before,
item6.fixed_asset_movement.january,
item6.fixed_asset_movement.february,
item6.fixed_asset_movement.march,
item6.fixed_asset_movement.april,
item6.fixed_asset_movement.may,
item6.fixed_asset_movement.june,
item6.fixed_asset_movement.july,
item6.fixed_asset_movement.august,
item6.fixed_asset_movement.september,
item6.fixed_asset_movement.october,
item6.fixed_asset_movement.november,
item6.fixed_asset_movement.december,
item6.fixed_asset_movement.total_current_year,
item6.fixed_asset_movement.total_next_year,
item6.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
item5.type_report_id,
item5.id,
item5.parent,
item5.formula,
item5.level,
item5.description,
item5.fixed_asset_movement.total_actual_before,
item5.fixed_asset_movement.january,
item5.fixed_asset_movement.february,
item5.fixed_asset_movement.march,
item5.fixed_asset_movement.april,
item5.fixed_asset_movement.may,
item5.fixed_asset_movement.june,
item5.fixed_asset_movement.july,
item5.fixed_asset_movement.august,
item5.fixed_asset_movement.september,
item5.fixed_asset_movement.october,
item5.fixed_asset_movement.november,
item5.fixed_asset_movement.december,
item5.fixed_asset_movement.total_current_year,
item5.fixed_asset_movement.total_next_year,
item5.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
item4.type_report_id,
item4.id,
item4.parent,
item4.formula,
item4.level,
item4.description,
item4.fixed_asset_movement.total_actual_before,
item4.fixed_asset_movement.january,
item4.fixed_asset_movement.february,
item4.fixed_asset_movement.march,
item4.fixed_asset_movement.april,
item4.fixed_asset_movement.may,
item4.fixed_asset_movement.june,
item4.fixed_asset_movement.july,
item4.fixed_asset_movement.august,
item4.fixed_asset_movement.september,
item4.fixed_asset_movement.october,
item4.fixed_asset_movement.november,
item4.fixed_asset_movement.december,
item4.fixed_asset_movement.total_current_year,
item4.fixed_asset_movement.total_next_year,
item4.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
item3.type_report_id,
item3.id,
item3.parent,
item3.formula,
item3.level,
item3.description,
item3.fixed_asset_movement.total_actual_before,
item3.fixed_asset_movement.january,
item3.fixed_asset_movement.february,
item3.fixed_asset_movement.march,
item3.fixed_asset_movement.april,
item3.fixed_asset_movement.may,
item3.fixed_asset_movement.june,
item3.fixed_asset_movement.july,
item3.fixed_asset_movement.august,
item3.fixed_asset_movement.september,
item3.fixed_asset_movement.october,
item3.fixed_asset_movement.november,
item3.fixed_asset_movement.december,
item3.fixed_asset_movement.total_current_year,
item3.fixed_asset_movement.total_next_year,
item3.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
item2.type_report_id,
item2.id,
item2.parent,
item2.formula,
item2.level,
item2.description,
item2.fixed_asset_movement.total_actual_before,
item2.fixed_asset_movement.january,
item2.fixed_asset_movement.february,
item2.fixed_asset_movement.march,
item2.fixed_asset_movement.april,
item2.fixed_asset_movement.may,
item2.fixed_asset_movement.june,
item2.fixed_asset_movement.july,
item2.fixed_asset_movement.august,
item2.fixed_asset_movement.september,
item2.fixed_asset_movement.october,
item2.fixed_asset_movement.november,
item2.fixed_asset_movement.december,
item2.fixed_asset_movement.total_current_year,
item2.fixed_asset_movement.total_next_year,
item2.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
item1.type_report_id,
item1.id,
item1.parent,
item1.formula,
item1.level,
item1.description,
item1.fixed_asset_movement.total_actual_before,
item1.fixed_asset_movement.january,
item1.fixed_asset_movement.february,
item1.fixed_asset_movement.march,
item1.fixed_asset_movement.april,
item1.fixed_asset_movement.may,
item1.fixed_asset_movement.june,
item1.fixed_asset_movement.july,
item1.fixed_asset_movement.august,
item1.fixed_asset_movement.september,
item1.fixed_asset_movement.october,
item1.fixed_asset_movement.november,
item1.fixed_asset_movement.december,
item1.fixed_asset_movement.total_current_year,
item1.fixed_asset_movement.total_next_year,
item1.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
itemss.type_report_id,
itemss.id,
itemss.parent,
itemss.formula,
itemss.level,
itemss.description,
itemss.fixed_asset_movement.total_actual_before,
itemss.fixed_asset_movement.january,
itemss.fixed_asset_movement.february,
itemss.fixed_asset_movement.march,
itemss.fixed_asset_movement.april,
itemss.fixed_asset_movement.may,
itemss.fixed_asset_movement.june,
itemss.fixed_asset_movement.july,
itemss.fixed_asset_movement.august,
itemss.fixed_asset_movement.september,
itemss.fixed_asset_movement.october,
itemss.fixed_asset_movement.november,
itemss.fixed_asset_movement.december,
itemss.fixed_asset_movement.total_current_year,
itemss.fixed_asset_movement.total_next_year,
itemss.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
items.type_report_id,
items.id,
items.parent,
items.formula,
items.level,
items.description,
items.fixed_asset_movement.total_actual_before,
items.fixed_asset_movement.january,
items.fixed_asset_movement.february,
items.fixed_asset_movement.march,
items.fixed_asset_movement.april,
items.fixed_asset_movement.may,
items.fixed_asset_movement.june,
items.fixed_asset_movement.july,
items.fixed_asset_movement.august,
items.fixed_asset_movement.september,
items.fixed_asset_movement.october,
items.fixed_asset_movement.november,
items.fixed_asset_movement.december,
items.fixed_asset_movement.total_current_year,
items.fixed_asset_movement.total_next_year,
items.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
val.type_report_id,
val.id,
val.parent,
val.formula,
val.level,
val.description,
val.fixed_asset_movement.total_actual_before,
val.fixed_asset_movement.january,
val.fixed_asset_movement.february,
val.fixed_asset_movement.march,
val.fixed_asset_movement.april,
val.fixed_asset_movement.may,
val.fixed_asset_movement.june,
val.fixed_asset_movement.july,
val.fixed_asset_movement.august,
val.fixed_asset_movement.september,
val.fixed_asset_movement.october,
val.fixed_asset_movement.november,
val.fixed_asset_movement.december,
val.fixed_asset_movement.total_current_year,
val.fixed_asset_movement.total_next_year,
val.fixed_asset_movement.total_more_year
])
}
})
} else {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.formula,
i.level,
i.description,
i.fixed_asset_movement.total_actual_before,
i.fixed_asset_movement.january,
i.fixed_asset_movement.february,
i.fixed_asset_movement.march,
i.fixed_asset_movement.april,
i.fixed_asset_movement.may,
i.fixed_asset_movement.june,
i.fixed_asset_movement.july,
i.fixed_asset_movement.august,
i.fixed_asset_movement.september,
i.fixed_asset_movement.october,
i.fixed_asset_movement.november,
i.fixed_asset_movement.december,
i.fixed_asset_movement.total_current_year,
i.fixed_asset_movement.total_next_year,
i.fixed_asset_movement.total_more_year
])
}
} else {
dataTable.push([
i.type_report_id,
i.id,
i.parent,
i.formula,
i.level,
i.description,
i.fixed_asset_movement.total_actual_before,
i.fixed_asset_movement.january,
i.fixed_asset_movement.february,
i.fixed_asset_movement.march,
i.fixed_asset_movement.april,
i.fixed_asset_movement.may,
i.fixed_asset_movement.june,
i.fixed_asset_movement.july,
i.fixed_asset_movement.august,
i.fixed_asset_movement.september,
i.fixed_asset_movement.october,
i.fixed_asset_movement.november,
i.fixed_asset_movement.december,
i.fixed_asset_movement.total_current_year,
i.fixed_asset_movement.total_next_year,
i.fixed_asset_movement.total_more_year
])
}
})
} else {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
item.id,
......@@ -674,12 +99,50 @@ export default class FixedAssetsMovement extends Component {
item.fixed_asset_movement.total_more_year
])
}
})
console.log(dataTable);
this.setState({ dataTable, loading: false })
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
}
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.fixed_asset_movement.total_actual_before,
item.fixed_asset_movement.january,
item.fixed_asset_movement.february,
item.fixed_asset_movement.march,
item.fixed_asset_movement.april,
item.fixed_asset_movement.may,
item.fixed_asset_movement.june,
item.fixed_asset_movement.july,
item.fixed_asset_movement.august,
item.fixed_asset_movement.september,
item.fixed_asset_movement.october,
item.fixed_asset_movement.november,
item.fixed_asset_movement.december,
item.fixed_asset_movement.total_current_year,
item.fixed_asset_movement.total_next_year,
item.fixed_asset_movement.total_more_year
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
this.setState({ dataTable, loading: false, buttonError: true })
} else {
this.setState({ loading: false })
this.setState({ dataTable, loading: false, buttonError: true })
}
})
}
......@@ -709,8 +172,6 @@ export default class FixedAssetsMovement extends Component {
} else {
data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
}
// this.forceUpdate()
// console.log(this.state.dataTable)
}
backToMasterBudget(type) {
......@@ -774,29 +235,30 @@ export default class FixedAssetsMovement extends Component {
}
else {
let isi = resp.rows.slice(3)
console.log(isi);
console.log(resp.rows[2]);
let payload = []
let reg = /^\d+$/;
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(),
total_actual_before: i[2] === undefined ? "" : String(i[2]).trim(),
january: i[3] === undefined ? "" : String(i[3]).trim(),
february: i[4] === undefined ? "" : String(i[4]).trim(),
march: i[5] === undefined ? "" : String(i[5]).trim(),
april: i[6] === undefined ? "" : String(i[6]).trim(),
may: i[7] === undefined ? "" : String(i[7]).trim(),
june: i[8] === undefined ? "" : String(i[8]).trim(),
july: i[9] === undefined ? "" : String(i[9]).trim(),
august: i[10] === undefined ? "" : String(i[10]).trim(),
september: i[11] === undefined ? "" : String(i[11]).trim(),
october: i[12] === undefined ? "" : String(i[12]).trim(),
november: i[13] === undefined ? "" : String(i[13]).trim(),
december: i[14] === undefined ? "" : String(i[14]).trim(),
total_current_year: i[15] === undefined ? "" : String(i[15]).trim(),
total_next_year: i[16] === undefined ? "" : String(i[16]).trim(),
total_more_year: i[17] === undefined ? "" : String(i[17]).trim()
total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
march: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
april: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
may: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
june: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
july: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
august: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
september: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
october: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
november: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
december: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).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 ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
total_more_year: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()
})
}
})
......@@ -806,8 +268,8 @@ export default class FixedAssetsMovement extends Component {
report_id: this.props.report_id,
fixed_asset_movement: payload
}
// console.log(JSON.stringify(body))
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
}
});
}
......@@ -846,20 +308,20 @@ export default class FixedAssetsMovement extends Component {
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
this.state.dataTable.map(item => {
if (item[22].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(this.state.dataTable);
})
}
}
})
}
checkError(tableMeta) {
if (tableMeta.rowData[22]) {
if (tableMeta.rowData[22][0] === 'item') {
this.setState({ buttonError: true })
}
}
}
uploadFAM() {
let data = []
this.state.dataTable.map(i => {
......@@ -2448,7 +1910,7 @@ export default class FixedAssetsMovement extends Component {
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ width: '50%' }}>
......@@ -2504,21 +1966,31 @@ export default class FixedAssetsMovement extends Component {
</div>
</div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150), height: this.props.height - 200 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</MuiThemeProvider>}
</div>
</div>
<div className="grid grid-2x">
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1">
<button
type="button"
onClick={() => this.backToMasterBudget('draft')}
onClick={() => this.state.editable === true ?
this.setState({ loading: true }, () => {
setTimeout(() => {
this.backToMasterBudget('draft')
}, 100);
}) :
this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
......@@ -2542,49 +2014,51 @@ export default class FixedAssetsMovement extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.props.onClickClose()
}}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.disabledSave}
onClick={() => this.backToMasterBudget('submitted')}
style={{
backgroundColor: 'transparent',
cursor: this.state.disabledSave === true ? 'default' : 'pointer',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: false, editable: true })
}, 100);
})
}}
>
<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>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.buttonError}
onClick={() => this.backToMasterBudget('submitted')}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, disabledSave: false })
}, 100);
})
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
</div>
......@@ -2596,11 +2070,11 @@ export default class FixedAssetsMovement extends Component {
<div style={{ padding: 25 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150), height: this.props.height - 400 }}>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
......@@ -2614,40 +2088,32 @@ export default class FixedAssetsMovement extends Component {
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button
type="button"
onClick={() => this.setState({ visibleFixedAssetsMovement: true }, () => this.getItemHierarki())}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError == true ? true : false}
onClick={() => this.setState({ loading: true }, () => {
onClick={() => this.setState({ visibleFixedAssetsMovement: true }, () => {
setTimeout(() => {
this.uploadFAM()
this.getItemHierarki()
}, 100);
})}
style={{ 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 style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.buttonError}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none'
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false })
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
}, 100);
})
}}
......@@ -2656,6 +2122,19 @@ export default class FixedAssetsMovement extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadFAM()
}, 100);
})}
>
<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>
</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