Commit 246cfd3b authored by d.arizona's avatar d.arizona

apdet

parent e81216cf
......@@ -168,6 +168,8 @@ const create = (type = "") => {
const getReportParent = (body) => api.post('item_report/get_parent_item_report', body)
const deleteReportItems = (id) => api.post(`item_report/delete_item_report/${id}`)
const getAllSettingByType = (body) => api.post('setting/get_all_setting_by_type', body)
const createAllItemReport = (body) => api.post('item_report/create_all_item_report', body)
const deleteAllItemReport = (body) => api.post('/item_report/delete_all_item_report', body)
//PARAMETER
const getAllParameter = () => api.get('/setting/get_all_setting')
......@@ -335,7 +337,9 @@ const create = (type = "") => {
createOpetaingInd,
uploadMasterBudget,
getAllSettingByType,
getOpetratingIndID
getOpetratingIndID,
createAllItemReport,
deleteAllItemReport
}
}
......
......@@ -24,7 +24,7 @@ const LightTooltip = withStyles((theme) => ({
},
}))(Tooltip);
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const getMuiTheme = () => createMuiTheme(ct.customTable3());
const options = ct.customOptionsFixedColumn();
const style = {
......@@ -59,7 +59,8 @@ export default class CorporateAnnualTarget extends Component {
},
kpiTypeList: [],
maxAchList: [],
visibleCAT: true
visibleCAT: true,
buttonError: false
// formulaYTDList: null,
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -83,10 +84,11 @@ export default class CorporateAnnualTarget extends Component {
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID
}
console.log(JSON.stringify(payload))
api.create().getDetailReportMB(payload).then(response => {
let dataTable = []
console.log(response)
let res = response.data.data
console.log(res)
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (indexIDzz === -1) {
......@@ -100,9 +102,9 @@ export default class CorporateAnnualTarget extends Component {
item.description,
item.cat.weight,
item.cat.uom,
item.cat.kpi_type == "" ? null : item.cat.kpi_type,
item.cat.max_ach == "" ? null : item.cat.max_ach,
item.cat.formula == "" ? null : item.cat.formula,
item.cat.kpi_type == "" ? null : {value: item.cat.kpi_type},
item.cat.max_ach == "" ? null : {value: item.cat.max_ach},
item.cat.formula == "" ? null : {value: item.cat.formula},
item.cat.total_actual_before,
item.cat.january,
item.cat.february,
......@@ -142,9 +144,9 @@ export default class CorporateAnnualTarget extends Component {
item.description,
item.cat.weight,
item.cat.uom,
item.cat.kpi_type == "" ? null : item.cat.kpi_type,
item.cat.max_ach == "" ? null : item.cat.max_ach,
item.cat.formula == "" ? null : item.cat.formula,
item.cat.kpi_type == "" ? null : {value: item.cat.kpi_type},
item.cat.max_ach == "" ? null : {value: item.cat.max_ach},
item.cat.formula == "" ? null : {value: item.cat.formula},
item.cat.total_actual_before,
item.cat.january,
item.cat.february,
......@@ -224,6 +226,7 @@ export default class CorporateAnnualTarget extends Component {
if (i.length > 0) {
payload.push({
item_report_id: i[0] === undefined ? "0" : reg.test(String(i[0])) === false ? "0" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(),
weight: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
uom: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
kpi_type: i[4] === undefined ? "" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
......@@ -267,83 +270,98 @@ export default class CorporateAnnualTarget extends Component {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleCAT: false })
// this.setState({ visibleUpload: false, visibleCAT: false, loading: true })
// let dataTable = response.data.data.map((item, index) => {
// return [
// item.type_report_id,
// item.id,
// item.parent,
// item.formula,
// item.level,
// "",
// item.description,
// item.weight,
// item.uom,
// item.kpi_type == "" ? null : item.kpi_type,
// item.max_ach == "" ? null : item.max_ach,
// item.formula == "" ? null : item.formula,
// item.total_actual_before,
// item.january,
// item.february,
// item.march,
// item.april,
// item.may,
// item.june,
// item.july,
// item.august,
// item.september,
// item.october,
// item.november,
// item.december,
// item.total_current_year,
// item.total_next_year,
// item.total_more_year,
// item.pic,
// item.error
// ]
// })
// 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);
// })
// this.setState({ visibleUpload: false, visibleCAT: false })
this.setState({ visibleUpload: false, visibleCAT: false, loading: true })
let dataTable = response.data.data.map((item, index) => {
return [
item.type_report_id,
item.item_report_id,
item.parent,
item.formula,
item.level,
"",
item.item_report,
item.weight,
item.uom,
item.kpi_type == "" ? null : item.kpi_type,
item.max_ach == "" ? null : item.max_ach,
item.formula == "" ? null : item.formula,
item.total_actual_before,
item.january,
item.february,
item.march,
item.april,
item.may,
item.june,
item.july,
item.august,
item.september,
item.october,
item.november,
item.december,
item.total_current_year,
item.total_next_year,
item.total_more_year,
item.strategic,
item.pic,
item.error
]
})
console.log(dataTable)
console.log(this.state.buttonError)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
this.state.dataTable.map(item => {
if (item[30].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true })
}
})
// console.log(this.state.dataTable);
})
}
}
})
}
uploadBalanceSheet() {
uploadCAT() {
let data = []
console.log(this.state.dataTable)
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
total_actual_before: String(i[6]),
january: String(i[7]),
february: String(i[8]),
march: String(i[9]),
april: String(i[10]),
may: String(i[11]),
june: String(i[12]),
july: String(i[13]),
august: String(i[14]),
september: String(i[15]),
october: String(i[16]),
november: String(i[17]),
december: String(i[18]),
total_current_year: String(i[19]),
total_next_year: String(i[20]),
total_more_year: String(i[21])
"item_report_id": i[0],
"item_report": String(i[6]),
"weight": String(i[7]),
"uom": String(i[8]),
"kpi_type": String(i[9].value) == undefined || String(i[9]) == null ? String(i[9]) : (String(i[9].value) == undefined ? String(i[9].value) : String(i[9].value)),
"max_ach": String(i[10].value) == undefined || String(i[10]) == null ? String(i[10]) : (String(i[10].value) == undefined ? String(i[10].value) : String(i[10].value)),
"formula": String(i[11].value) == undefined || String(i[11]) == null ? String(i[11]) : (String(i[11].value) == undefined ? String(i[11].value) :String(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])
})
})
let body = {
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
// "revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"submission_id": this.props.submissionID,
// "status": "submitted",
"cat": data
}
console.log(data);
......@@ -364,39 +382,70 @@ export default class CorporateAnnualTarget extends Component {
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],
total_actual_before: String(i[6]),
january: String(i[7]),
february: String(i[8]),
march: String(i[9]),
april: String(i[10]),
may: String(i[11]),
june: String(i[12]),
july: String(i[13]),
august: String(i[14]),
september: String(i[15]),
october: String(i[16]),
november: String(i[17]),
december: String(i[18]),
total_current_year: String(i[19]),
total_next_year: String(i[20]),
total_more_year: String(i[21])
"item_report_id": i[1],
"item_report": String(i[6]),
"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 = {
"submission_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"balance_sheet": data
"cat": data
}
console.log(JSON.stringify(payload));
this.addNewReport(payload)
}
addNewReport(payloadBro) {
let data = this.state.dataTable.map((item,index) => {
if (item[1] == "") {
return {
"item_name": item[6],
"parent": item[2]
}
}
// console.log(data);
this.props.saveToMasterBudget(payload)
})
let payload = {
"company_id": 1,
"item_report": data
}
api.create().createAllItemReport(payload).then((response) => {
this.props.saveToMasterBudget(payloadBro)
this.props.onClickClose()
})
}
getKPIType() {
......@@ -486,14 +535,6 @@ export default class CorporateAnnualTarget extends Component {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => {
let val = String(value).split(",").join("")
// let data = this.state.dataTable2
// let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[tableMeta.rowIndex][2])
// if (indexParent > 0) {
// // console.log(indexParent)
// let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// let jagain = dataTable2[indexParent][tableMeta.columnIndex]
// a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
// } else {
let total = 0
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
dataTable2[tableMeta.rowIndex].map((item,index) => {
......@@ -504,11 +545,10 @@ export default class CorporateAnnualTarget extends Component {
})
dataTable2[tableMeta.rowIndex][25] = total
console.log(dataTable2[tableMeta.rowIndex])
// }
}
const handleChangeDropdown = (value, tableMeta) => {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value.value
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = value
}
const handleChangePercentage = (value, tableMeta) => {
......@@ -591,12 +631,13 @@ export default class CorporateAnnualTarget extends Component {
}
const handleTambah = (data) => {
console.log(dataTable2)
let newData = []
dataTable2.map((item, index) => {
newData.push(item)
if (item[1] == data) {
newData.push([
item[0],
3,
"",
item[2],
item[3],
......@@ -605,9 +646,9 @@ export default class CorporateAnnualTarget extends Component {
"",
"",
"",
"",
"",
"",
null,
null,
null,
"",
"",
"",
......@@ -645,6 +686,7 @@ export default class CorporateAnnualTarget extends Component {
}, 500)
})
}
const columns = [{
name: "",
options: {
......@@ -674,6 +716,7 @@ export default class CorporateAnnualTarget extends Component {
name: "",
options: {
filter: false,
display: this.state.visibleCAT,
customBodyRender: (val, tableMeta) => {
return (
// handleAction(tableMeta.rowData[2]) &&
......@@ -885,9 +928,10 @@ export default class CorporateAnnualTarget extends Component {
disableClearable
disabled={!handleAction(tableMeta.rowData[2])}
value={val}
style={{padding: 0, margin: 0}}
renderInput={(params) =>
<div ref={params.InputProps.ref}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center'}} type="text" {...params.inputProps} />
<div ref={params.InputProps.ref} style={{padding: 0, margin: 0}}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0}} type="text" {...params.inputProps} />
</div>
}
/>
......@@ -917,10 +961,11 @@ export default class CorporateAnnualTarget extends Component {
debug
disableClearable
value={val}
style={{padding: 0, margin: 0}}
disabled={!handleAction(tableMeta.rowData[2])}
renderInput={(params) =>
<div ref={params.InputProps.ref}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center'}} type="text" {...params.inputProps} />
<div ref={params.InputProps.ref} style={{padding: 0, margin: 0}}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0}} type="text" {...params.inputProps} />
</div>
}
// value={this.state.parent}
......@@ -954,9 +999,10 @@ export default class CorporateAnnualTarget extends Component {
disableClearable
value={val}
disabled={!handleAction(tableMeta.rowData[2])}
style={{padding: 0, margin: 0}}
renderInput={(params) =>
<div ref={params.InputProps.ref}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center'}} type="text" {...params.inputProps} />
<div ref={params.InputProps.ref} style={{padding: 0, margin: 0}}>
<input style={{ borderColor: 'white', width: 96, textAlign: 'center', padding: 0, margin: 0}} type="text" {...params.inputProps} />
</div>
}
// value={this.state.parent}
......@@ -1481,10 +1527,11 @@ export default class CorporateAnnualTarget extends Component {
<Typography style={{ color: 'white', fontSize: 12, fontWeight: 'bold', textAlign: 'center' }}>{columnMeta.name}</Typography>
</TableCell>
),
customBodyRender: (val) => {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ width: 96 }}>
{val}
{tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 2 || tableMeta.rowData[0] === 4?
null : val}
</div>
)
}
......@@ -1715,11 +1762,11 @@ export default class CorporateAnnualTarget extends Component {
margin: 5
}}
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
}, 100);
})}
// this.setState({ loading: true }, () => {
// setTimeout(() => {
this.downloadAllData()}
// }, 100);
// })}
>
<img src={Images.download} />
</button>
......@@ -1768,49 +1815,51 @@ export default class CorporateAnnualTarget extends Component {
outline: 'none',
marginRight: 20
}}
onClick={() => {
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.createData()}
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>
<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>
</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>
......@@ -1879,7 +1928,7 @@ export default class CorporateAnnualTarget extends Component {
disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadBalanceSheet()
this.uploadCAT()
}, 100);
})}
>
......
......@@ -182,7 +182,7 @@ export default class ProfitLoss extends Component {
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
notes: String(i[6]),
notes: i[6] == null || i[6] == "" ? "" : String(i[6]),
total_actual_before: String(i[7]),
january: String(i[8]),
february: String(i[9]),
......@@ -397,15 +397,23 @@ export default class ProfitLoss extends Component {
if (type === "actual") {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
} else {
let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[tableMeta.rowIndex][2])
if (indexParent > 0) {
// console.log(indexParent)
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
let jagain = dataTable2[indexParent][tableMeta.columnIndex]
a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (jagain + Number(val))
} else {
// let indexParent = dataTable2.findIndex((val) => val[1] == dataTable2[tableMeta.rowIndex][2])
// if (indexParent > 0) {
// // console.log(indexParent)
// let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// let jagain = dataTable2[indexParent][tableMeta.columnIndex]
// a = dataTable2[indexParent][tableMeta.columnIndex] = jagain == undefined ? (0 + Number(val)) : (Number(jagain) + Number(val))
// } else {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
// }
let total = 0
dataTable2[tableMeta.rowIndex].map((item,index) => {
if (index >= 8 && index <= 19) {
let valItem = item == undefined || item == ""? 0 : item
total += Number(valItem)
}
})
dataTable2[tableMeta.rowIndex][20] = total
}
}
const handleNotes = (value, tableMeta) => {
......
......@@ -1170,7 +1170,7 @@ export default class BalanceSheet extends Component {
</div>
</div>
<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}
......
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