Commit fa79167a authored by Deni Rinaldi's avatar Deni Rinaldi

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

parents d14a15cd c29d5cf2
...@@ -279,10 +279,12 @@ const create = (type = "") => { ...@@ -279,10 +279,12 @@ const create = (type = "") => {
const checkUploadMonthlyReportFAM = (body) => api.post('transaction/monthly_report/fam/check_import', body) const checkUploadMonthlyReportFAM = (body) => api.post('transaction/monthly_report/fam/check_import', body)
const checkUploadMonthlyReportBS = (body) => api.post('transaction/monthly_report_bs/check_import', body) const checkUploadMonthlyReportBS = (body) => api.post('transaction/monthly_report_bs/check_import', body)
const checkUploadMonthlyReportOI = (body) => api.post('transaction/monthly_report_oi/check_import', body) const checkUploadMonthlyReportOI = (body) => api.post('transaction/monthly_report_oi/check_import', body)
const checkUploadMonthlyReportCAT = (body) => api.post('transaction/monthly_report/cat/check_import', body)
const uploadMonthlyReportBS = (body) => api.post('transaction/monthly_report_bs/import_monthly_report', body) const uploadMonthlyReportBS = (body) => api.post('transaction/monthly_report_bs/import_monthly_report', body)
const uploadMonthlyReportFAM = (body) => api.post('transaction/monthly_report/fam/import_monthly_report', body) const uploadMonthlyReportFAM = (body) => api.post('transaction/monthly_report/fam/import_monthly_report', body)
const uploadMonthlyReportTP = (body) => api.post('transaction/monthly_report_tp/import_monthly_report', body) const uploadMonthlyReportTP = (body) => api.post('transaction/monthly_report_tp/import_monthly_report', body)
const uploadMonthlyReportOI = (body) => api.post('transaction/monthly_report_oi/import_monthly_report', body) const uploadMonthlyReportOI = (body) => api.post('transaction/monthly_report_oi/import_monthly_report', body)
const uploadMonthlyReportCAT = (body) => api.post('transaction/monthly_report/cat/import_monthly_report', body)
const validateSubmitReportMR = (body) => api.post('transaction/monthly_report/validate_save', body) const validateSubmitReportMR = (body) => api.post('transaction/monthly_report/validate_save', body)
// MonthlyPL // MonthlyPL
...@@ -502,6 +504,7 @@ const create = (type = "") => { ...@@ -502,6 +504,7 @@ const create = (type = "") => {
checkUploadMonthlyReportTP, checkUploadMonthlyReportTP,
checkUploadMonthlyReportFAM, checkUploadMonthlyReportFAM,
checkUploadMonthlyReportOI, checkUploadMonthlyReportOI,
checkUploadMonthlyReportCAT,
uploadMonthlyReportPL, uploadMonthlyReportPL,
getMonthlyReport, getMonthlyReport,
checkUploadMonthlyReportBS, checkUploadMonthlyReportBS,
...@@ -509,6 +512,7 @@ const create = (type = "") => { ...@@ -509,6 +512,7 @@ const create = (type = "") => {
uploadMonthlyReportFAM, uploadMonthlyReportFAM,
uploadMonthlyReportTP, uploadMonthlyReportTP,
uploadMonthlyReportOI, uploadMonthlyReportOI,
uploadMonthlyReportCAT,
getHierarkiMontlyReportCF, getHierarkiMontlyReportCF,
validateSubmitReportMR validateSubmitReportMR
} }
......
...@@ -94,8 +94,8 @@ export default class CorporateAnnualTarget extends Component { ...@@ -94,8 +94,8 @@ export default class CorporateAnnualTarget extends Component {
this.getKPIType() this.getKPIType()
this.getMaxAch() this.getMaxAch()
this.getLatestUpdate() this.getLatestUpdate()
// // console.log(this.props.status) // // // console.log(this.props.status)
// // // console.log(this.props.lastStatus); // // // // console.log(this.props.lastStatus);
} }
...@@ -108,7 +108,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -108,7 +108,7 @@ export default class CorporateAnnualTarget extends Component {
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
"submission_id": this.props.submissionID "submission_id": this.props.submissionID
} }
// // console.log(JSON.stringify(payload)) // // // console.log(JSON.stringify(payload))
api.create().getDetailReportMB(payload).then(response => { api.create().getDetailReportMB(payload).then(response => {
let dataTable = [] let dataTable = []
let dataCustomerPrs = [] let dataCustomerPrs = []
...@@ -173,7 +173,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -173,7 +173,7 @@ export default class CorporateAnnualTarget extends Component {
item.level, item.level,
"", "",
item.description, item.description,
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.cat.weight).indexOf(".") == -1 ? item.cat.weight : `${Number(item.weight) * 100}%`), item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(Number(String(item.cat.weight).substr(0,String(item.cat.weight).length-1)).toFixed(1)) + '%'),
parentTrue ? item.cat.uom : item.uom, parentTrue ? item.cat.uom : item.uom,
parentTrue ? item.cat.kpi_type == "" ? null : { value: item.cat.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type }, parentTrue ? item.cat.kpi_type == "" ? null : { value: item.cat.kpi_type } : item.kpi_type == "" ? null : { value: item.kpi_type },
parentTrue ? item.cat.max_ach == "" ? null : { value: titleCase(item.cat.max_ach) } : item.max_ach == "" ? null : { value: titleCase(item.max_ach) }, parentTrue ? item.cat.max_ach == "" ? null : { value: titleCase(item.cat.max_ach) } : item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
...@@ -217,7 +217,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -217,7 +217,7 @@ export default class CorporateAnnualTarget extends Component {
item.level, item.level,
"", "",
item.description, item.description,
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : item.cat.weight, item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(Number(String(item.cat.weight).substr(0,String(item.cat.weight).length-1)).toFixed(1)) + '%'),
item.cat.uom, item.cat.uom,
item.kpi_type == "" ? null : { value: item.kpi_type }, item.kpi_type == "" ? null : { value: item.kpi_type },
item.max_ach == "" ? null : { value: titleCase(item.max_ach) }, item.max_ach == "" ? null : { value: titleCase(item.max_ach) },
...@@ -251,9 +251,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -251,9 +251,9 @@ export default class CorporateAnnualTarget extends Component {
} }
} }
}) })
// console.log(dataTable) // // console.log(dataTable)
this.setState({ dataTable, loading: false, dataReal: res, editable: true, dataCustomerPrs, dataInternalBsn, dataFin, dataLearn}, () => { this.setState({ dataTable, loading: false, dataReal: res, editable: true, dataCustomerPrs, dataInternalBsn, dataFin, dataLearn}, () => {
// // console.log(dataCustomerPrs) // // // console.log(dataCustomerPrs)
}) })
} 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 }, () => {
...@@ -281,7 +281,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -281,7 +281,7 @@ export default class CorporateAnnualTarget extends Component {
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}` `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
) )
res = await res.blob() res = await res.blob()
// // // console.log(res) // // // // console.log(res)
if (res.size > 0) { if (res.size > 0) {
let url = window.URL.createObjectURL(res); let url = window.URL.createObjectURL(res);
let a = document.createElement('a'); let a = document.createElement('a');
...@@ -292,16 +292,16 @@ export default class CorporateAnnualTarget extends Component { ...@@ -292,16 +292,16 @@ export default class CorporateAnnualTarget extends Component {
} }
async downloadAllData() { async downloadAllData() {
// // // console.log('masuk') // // // // console.log('masuk')
let bram = [this.props.submissionID, this.props.report_id, this.props.company.company_id, this.props.periode, this.props.revision] let bram = [this.props.submissionID, this.props.report_id, this.props.company.company_id, this.props.periode, this.props.revision]
// // // console.log(bram) // // // // console.log(bram)
let resReal = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}` let resReal = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
let resNull = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}` let resNull = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
let res = await fetch( let res = await fetch(
this.props.submissionID == null ? resNull : resReal this.props.submissionID == null ? resNull : resReal
) )
res = await res.blob() res = await res.blob()
// // // console.log(res) // // // // console.log(res)
this.setState({ loading: false }) this.setState({ loading: false })
if (res.size > 0) { if (res.size > 0) {
let url = window.URL.createObjectURL(res); let url = window.URL.createObjectURL(res);
...@@ -315,13 +315,13 @@ export default class CorporateAnnualTarget extends Component { ...@@ -315,13 +315,13 @@ export default class CorporateAnnualTarget extends Component {
fileHandler = (event) => { fileHandler = (event) => {
let fileObj = event let fileObj = event
ExcelRenderer(fileObj, (err, resp) => { ExcelRenderer(fileObj, (err, resp) => {
// // // // console.log(resp) // // // // // console.log(resp)
if (err) { if (err) {
// // // console.log(err); // // // // console.log(err);
} }
else { else {
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]+)?$/; let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
let newValidate = false let newValidate = false
...@@ -358,7 +358,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -358,7 +358,7 @@ export default class CorporateAnnualTarget extends Component {
payload.push({ payload.push({
item_report_id: i[0] === undefined ? 0 : reg.test(String(i[0])) === false ? 0 : String(i[0]).trim(), 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(), item_report: i[1] === undefined ? "" : String(i[1]).trim(),
weight: i[2] === undefined ? "" : (String(i[2]).includes('%')? String(i[2].trim()) : (String(Number(i[2] * 100)).length > 3 ? String(Number(i[2] * 100).toFixed(0) + '%') : String(Number(i[2] * 100)) + '%')), weight: i[2] === undefined ? "" : String(Number(i[2] * 100).toFixed(1)) + '%',
uom: i[3] === undefined ? "" : String(i[3]).trim(), uom: i[3] === undefined ? "" : String(i[3]).trim(),
kpi_type: i[4] === undefined ? "" : String(i[4]).trim(), kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
max_ach: i[5] === undefined ? "" : String(i[5]).toLocaleLowerCase() !== 'unlimited' ? (String(i[5]).includes('%')? String(i[5].trim()) : String(Number(i[5] * 100) + '%')) : String(i[5]).trim(), max_ach: i[5] === undefined ? "" : String(i[5]).toLocaleLowerCase() !== 'unlimited' ? (String(i[5]).includes('%')? String(i[5].trim()) : String(Number(i[5] * 100) + '%')) : String(i[5]).trim(),
...@@ -387,7 +387,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -387,7 +387,7 @@ export default class CorporateAnnualTarget extends Component {
payload.push({ payload.push({
item_report_id: i[0] === undefined ? 0 : reg.test(String(i[0])) === false ? 0 : String(i[0]).trim(), 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(), item_report: i[1] === undefined ? "" : String(i[1]).trim(),
weight: i[2] === undefined ? "" : (String(i[2]).includes('%')? String(i[2].trim()) : (String(Number(i[2] * 100)).length > 3 ? String(Number(i[2] * 100).toFixed(0) + '%') : String(Number(i[2] * 100)) + '%')), weight: i[2] === undefined ? "" : String(Number(i[2] * 100).toFixed(1)) + '%',
uom: i[3] === undefined ? "" : String(i[3]).trim(), uom: i[3] === undefined ? "" : String(i[3]).trim(),
kpi_type: i[4] === undefined ? "" : String(i[4]).trim(), kpi_type: i[4] === undefined ? "" : String(i[4]).trim(),
max_ach: i[5] === undefined ? "" : String(i[5]).toLocaleLowerCase() !== 'unlimited' ? (String(i[5]).includes('%')? String(i[5].trim()) : String(Number(i[5] * 100) + '%')) : String(i[5]).trim(), max_ach: i[5] === undefined ? "" : String(i[5]).toLocaleLowerCase() !== 'unlimited' ? (String(i[5]).includes('%')? String(i[5].trim()) : String(Number(i[5] * 100) + '%')) : String(i[5]).trim(),
...@@ -412,14 +412,14 @@ export default class CorporateAnnualTarget extends Component { ...@@ -412,14 +412,14 @@ export default class CorporateAnnualTarget extends Component {
pic: i[24] === undefined ? "" : String(i[24]).trim() pic: i[24] === undefined ? "" : String(i[24]).trim()
}) })
} }
// console.log(i[2]) // // console.log(i[2])
// // console.log(Number(i[2] * 100)) // // // console.log(Number(i[2] * 100))
// // // // console.log(i[2] === undefined ? "" : String(Number(i[2]*100)).length > 3? String(Number(i[2]*100).toFixed(0) + '%') : String(Number(i[2]*100)) + '%') // // // // // console.log(i[2] === undefined ? "" : String(Number(i[2]*100)).length > 3? String(Number(i[2]*100).toFixed(0) + '%') : String(Number(i[2]*100)) + '%')
} }
}) })
// console.log(payload) // // console.log(payload)
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,
...@@ -427,7 +427,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -427,7 +427,7 @@ export default class CorporateAnnualTarget extends Component {
status: '', status: '',
cat: payload cat: payload
} }
// // // console.log(body) // // // // console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0] }) this.setState({ payload: body, judul: resp.rows[1][0] })
} }
}); });
...@@ -438,7 +438,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -438,7 +438,7 @@ export default class CorporateAnnualTarget extends Component {
let dataDelete = this.state.dataDelete let dataDelete = this.state.dataDelete
api.create().getIdDeleteFromExcel(this.state.payload).then((response) => { api.create().getIdDeleteFromExcel(this.state.payload).then((response) => {
if (response.data) { if (response.data) {
// // // // console.log(response.data) // // // // // console.log(response.data)
let idDelete = response.data.data.item_report_id let idDelete = response.data.data.item_report_id
if (idDelete.length > 0) { if (idDelete.length > 0) {
idDelete.map((item, index) => { idDelete.map((item, index) => {
...@@ -450,7 +450,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -450,7 +450,7 @@ export default class CorporateAnnualTarget extends Component {
}) })
// console.log(this.state.payload) // console.log(this.state.payload)
api.create().checkUploadMB(this.state.payload).then(response => { api.create().checkUploadMB(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload)); // // console.log(JSON.stringify(this.state.payload));
// console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -512,7 +512,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -512,7 +512,7 @@ export default class CorporateAnnualTarget extends Component {
item.level == null ? 1 : item.level, item.level == null ? 1 : item.level,
"", "",
item.item_report, item.item_report,
item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.weight).indexOf(".") == -1 ? item.weight : `${Number(item.weight) * 100}%`), item.type_report_id == 1 ? `${Number(item.weight) * 100}%` : (String(item.weight)),
item.uom, item.uom,
item.kpi_type == "" || item.kpi_type == null ? null : { value: item.kpi_type }, item.kpi_type == "" || item.kpi_type == null ? null : { value: item.kpi_type },
item.max_ach == "" || item.max_ach == null ? null : { value: titleCase(item.max_ach) }, item.max_ach == "" || item.max_ach == null ? null : { value: titleCase(item.max_ach) },
...@@ -547,17 +547,17 @@ export default class CorporateAnnualTarget extends Component { ...@@ -547,17 +547,17 @@ export default class CorporateAnnualTarget extends Component {
if (checkDataFin.length > 0 || checkDataLearn.length > 0) { if (checkDataFin.length > 0 || checkDataLearn.length > 0) {
handleDataSalah = true handleDataSalah = true
} }
// console.log(indexCheck) // // console.log(indexCheck)
// // // console.log(this.state.buttonError) // // // // console.log(this.state.buttonError)
// console.log(dataTable) // // console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, dataDelete, handleDataSalah }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, dataDelete, handleDataSalah }, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[30].length > 0) { if (item[30].length > 0) {
// // // console.log('masuk') // // // // console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true }) this.setState({ buttonError: true, errorPreview: true, editable: true })
} }
}) })
// // // // console.log(this.state.dataTable); // // // // // console.log(this.state.dataTable);
}) })
} 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 }, () => {
...@@ -580,7 +580,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -580,7 +580,7 @@ export default class CorporateAnnualTarget extends Component {
uploadCAT(type) { uploadCAT(type) {
// let dataDelete = this.state.dataDelete // let dataDelete = this.state.dataDelete
// // // console.log(dataDelete) // // // // console.log(dataDelete)
let payload = { "item_report_id": this.state.dataDelete } let payload = { "item_report_id": this.state.dataDelete }
if (this.state.dataDelete.length > 0) { if (this.state.dataDelete.length > 0) {
api.create().deleteAllItemReport(payload).then((response) => { api.create().deleteAllItemReport(payload).then((response) => {
...@@ -595,7 +595,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -595,7 +595,7 @@ export default class CorporateAnnualTarget extends Component {
functionUpload(type) { functionUpload(type) {
let data = [] let data = []
let stateFR = false let stateFR = false
// // console.log(this.state.dataTable) // // // console.log(this.state.dataTable)
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
if (i[2] !== null) { if (i[2] !== null) {
let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2]) let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
...@@ -647,10 +647,10 @@ export default class CorporateAnnualTarget extends Component { ...@@ -647,10 +647,10 @@ export default class CorporateAnnualTarget extends Component {
"status": type, "status": type,
"cat": data "cat": data
} }
// console.log(data); // // console.log(data);
// console.log(JSON.stringify(body)) // // console.log(JSON.stringify(body))
api.create('UPLOAD').uploadMasterBudget(body).then(response => { api.create('UPLOAD').uploadMasterBudget(body).then(response => {
// // // console.log(response); // // // // console.log(response);
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
...@@ -677,7 +677,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -677,7 +677,7 @@ export default class CorporateAnnualTarget extends Component {
handleValidate() { handleValidate() {
let data = [] let data = []
// // console.log(this.state.dataTable) // // // console.log(this.state.dataTable)
let totalWeight = 0 let totalWeight = 0
let dataTableBaru = this.state.dataTable let dataTableBaru = this.state.dataTable
let dataTampung = [] let dataTampung = []
...@@ -699,14 +699,14 @@ export default class CorporateAnnualTarget extends Component { ...@@ -699,14 +699,14 @@ export default class CorporateAnnualTarget extends Component {
if (i[2] !== null) { if (i[2] !== null) {
let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2]) let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
// // // console.log(indexID) // // // // console.log(indexID)
// // // console.log(i[2]) // // // // console.log(i[2])
if (indexID !== -1) { if (indexID !== -1) {
// // // console.log(dataTableBaru[indexID][6]) // // // // console.log(dataTableBaru[indexID][6])
if (dataTableBaru[indexID][6] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || dataTableBaru[indexID][6] == 'CUSTOMER PERSPECTIVE') { if (dataTableBaru[indexID][6] == 'INTERNAL BUSINESS PROCESS PERSPECTIVE' || dataTableBaru[indexID][6] == 'CUSTOMER PERSPECTIVE') {
if (i[6] == "" || i[7] == "" || i[9] == null || i[10] == null || i[11] == null) { if (i[6] == "" || i[7] == "" || i[9] == null || i[10] == null || i[11] == null) {
handleKosongKPIMAXYTD = true handleKosongKPIMAXYTD = true
// // // console.log(handleKosongKPIMAXYTD) // // // // console.log(handleKosongKPIMAXYTD)
} }
} else if (dataTableBaru[indexID][6] === 'FINANCIAL PERSPECTIVE') { } else if (dataTableBaru[indexID][6] === 'FINANCIAL PERSPECTIVE') {
stateFR = true stateFR = true
...@@ -719,7 +719,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -719,7 +719,7 @@ export default class CorporateAnnualTarget extends Component {
// if (i[0] == null && i[2] == null) { // if (i[0] == null && i[2] == null) {
// if (i[6] == "" || i[7] == "" || i[9] == null || i[10] == null || i[11] == null) { // if (i[6] == "" || i[7] == "" || i[9] == null || i[10] == null || i[11] == null) {
// handleKosongKPIMAXYTD = true // handleKosongKPIMAXYTD = true
// // // // console.log(handleKosongKPIMAXYTD) // // // // // console.log(handleKosongKPIMAXYTD)
// } // }
// } // }
...@@ -731,20 +731,21 @@ export default class CorporateAnnualTarget extends Component { ...@@ -731,20 +731,21 @@ export default class CorporateAnnualTarget extends Component {
let valReal = Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', '')) let valReal = Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
let totalBaru = valChild + valReal let totalBaru = valChild + valReal
if (totalBaru > weightParent) { if (totalBaru > weightParent) {
dataTableBaru[index][7] = `${(weightParent - valChild)}%` dataTableBaru[index][7] = `${String(Number(weightParent - valChild).toFixed(1)) + '%'}`
dataTampung[indexID].valChild = dataTampung[indexID].valChild + weightParent - valChild dataTampung[indexID].valChild = dataTampung[indexID].valChild + weightParent - valChild
weightReal = `${(weightParent - valChild)}%` weightReal = `${String(Number(weightParent - valChild).toFixed(1)) + '%'}`
} else { } else {
dataTableBaru[index][7] = i[7] dataTableBaru[index][7] = i[7]
weightReal = i[7] weightReal = i[7]
dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', '')) dataTampung[indexID].valChild = dataTampung[indexID].valChild + Number(i[7] == "" || i[7] == undefined ? 0 : i[7].replace('%', ''))
} }
// // // console.log(weightReal) // // // // console.log(weightReal)
// // // console.log(dataTableBaru[index][7]) // console.log(dataTableBaru[index][7])
// // // console.log(dataTampung[indexID].valChild) // console.log(dataTampung[indexID].valChild)
} }
} }
// // console.log(String(weightReal).substr(0,String(weightReal).length-1))
// // console.log(Number(String(weightReal).substr(0,String(weightReal).length-1)).toFixed(1));
data.push({ data.push({
"item_report_id": i[1] == "" || i[1] == null ? 0 : i[1], "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
"item_name": String(i[6]), "item_name": String(i[6]),
...@@ -775,8 +776,8 @@ export default class CorporateAnnualTarget extends Component { ...@@ -775,8 +776,8 @@ export default class CorporateAnnualTarget extends Component {
}) })
}) })
// // // console.log(dataTableBaru) // // // // console.log(dataTableBaru)
// // // console.log(JSON.stringify(data)) // // // // console.log(JSON.stringify(data))
let payload = { let payload = {
"submission_id": this.props.submissionID, "submission_id": this.props.submissionID,
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
...@@ -785,7 +786,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -785,7 +786,7 @@ export default class CorporateAnnualTarget extends Component {
"status": "submitted", "status": "submitted",
"cat": data "cat": data
} }
// // // console.log(totalWeight) // // // // console.log(totalWeight)
// this.setState({dataTable: dataTampung}) // this.setState({dataTable: dataTampung})
if (handleKosongKPIMAXYTD) { if (handleKosongKPIMAXYTD) {
this.setState({ alert: true, messageAlert: 'KPI / Weight / KPI Type / Max Ach / Formula YTD / Cannot be Empty', tipeAlert: 'warning', loading: false, editable: true }) this.setState({ alert: true, messageAlert: 'KPI / Weight / KPI Type / Max Ach / Formula YTD / Cannot be Empty', tipeAlert: 'warning', loading: false, editable: true })
...@@ -793,7 +794,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -793,7 +794,7 @@ export default class CorporateAnnualTarget extends Component {
this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, editable: true }) this.setState({ alert: true, messageAlert: 'Total weight less than 100%', tipeAlert: 'warning', loading: false, editable: true })
} else { } else {
api.create().validateSubmitReport(payload).then((response) => { api.create().validateSubmitReport(payload).then((response) => {
// // // console.log(response) // // // // console.log(response)
if (response.data.data.result) { if (response.data.data.result) {
this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false }) this.setState({ loading: false, buttonError: false, editable: false, buttonDraft: false })
} else { } else {
...@@ -810,14 +811,14 @@ export default class CorporateAnnualTarget extends Component { ...@@ -810,14 +811,14 @@ export default class CorporateAnnualTarget extends Component {
backToMasterBudget(type) { backToMasterBudget(type) {
let data = [] let data = []
let stateFR = false let stateFR = false
// // console.log(this.state.dataTable) // // // console.log(this.state.dataTable)
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
if (i[2] !== null) { if (i[2] !== null) {
let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2]) let indexID = this.state.dataTable.findIndex((val) => val[1] == i[2])
// // // console.log(indexID) // // // // console.log(indexID)
// // // console.log(i[2]) // // // // console.log(i[2])
if (indexID !== -1) { if (indexID !== -1) {
// // // console.log(dataTableBaru[indexID][6]) // // // // console.log(dataTableBaru[indexID][6])
if (this.state.dataTable[indexID][6] === 'FINANCIAL PERSPECTIVE') { if (this.state.dataTable[indexID][6] === 'FINANCIAL PERSPECTIVE') {
stateFR = true stateFR = true
} else { } else {
...@@ -827,7 +828,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -827,7 +828,7 @@ export default class CorporateAnnualTarget extends Component {
} else { } else {
stateFR = false stateFR = false
} }
// // // // 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] == "" || i[1] == null ? 0 : i[1], "item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
"item_name": String(i[6]), "item_name": String(i[6]),
...@@ -857,7 +858,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -857,7 +858,7 @@ export default class CorporateAnnualTarget extends Component {
"pic": String(i[29]) "pic": String(i[29])
}) })
}) })
// // console.log(JSON.stringify(data)) // // // console.log(JSON.stringify(data))
let payload = { let payload = {
"submission_id": this.props.submissionID, "submission_id": this.props.submissionID,
"company_id": this.props.company.company_id, "company_id": this.props.company.company_id,
...@@ -866,7 +867,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -866,7 +867,7 @@ export default class CorporateAnnualTarget extends Component {
"status": type, "status": type,
"cat": data "cat": data
} }
// // console.log(JSON.stringify(payload)); // console.log(JSON.stringify(payload));
this.deleteReport(payload) this.deleteReport(payload)
} }
...@@ -875,10 +876,10 @@ export default class CorporateAnnualTarget extends Component { ...@@ -875,10 +876,10 @@ export default class CorporateAnnualTarget extends Component {
if (this.state.dataDelete.length > 0) { if (this.state.dataDelete.length > 0) {
api.create().deleteAllItemReport(payload).then((response) => { api.create().deleteAllItemReport(payload).then((response) => {
// // // console.log(response) // // // // console.log(response)
// api.create().validateSubmitReport(payloadBro).then((response) => { // api.create().validateSubmitReport(payloadBro).then((response) => {
// // // // console.log(response) // // // // // console.log(response)
// if (response.data.data.result) { // if (response.data.data.result) {
this.props.saveToMasterBudget(payloadBro) this.props.saveToMasterBudget(payloadBro)
this.props.onClickClose() this.props.onClickClose()
...@@ -888,9 +889,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -888,9 +889,9 @@ export default class CorporateAnnualTarget extends Component {
// }) // })
}) })
} else { } else {
// // // // console.log('sini jing') // // // // // console.log('sini jing')
// api.create().validateSubmitReport(payloadBro).then((response) => { // api.create().validateSubmitReport(payloadBro).then((response) => {
// // // // console.log(response) // // // // // console.log(response)
// if (response.data.data.result) { // if (response.data.data.result) {
this.props.saveToMasterBudget(payloadBro) this.props.saveToMasterBudget(payloadBro)
this.props.onClickClose() this.props.onClickClose()
...@@ -909,12 +910,12 @@ export default class CorporateAnnualTarget extends Component { ...@@ -909,12 +910,12 @@ export default class CorporateAnnualTarget extends Component {
type: 'KPI_TYPE' type: 'KPI_TYPE'
} }
api.create().getAllSettingByType(body).then(response => { api.create().getAllSettingByType(body).then(response => {
// // // // console.log(response) // // // // // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
// // // console.log(data) // // // // console.log(data)
let inputKPI = [] let inputKPI = []
data.map((item) => { data.map((item) => {
...@@ -926,7 +927,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -926,7 +927,7 @@ export default class CorporateAnnualTarget extends Component {
options: inputKPI, options: inputKPI,
getOptionLabel: (option) => titleCase(option.value), getOptionLabel: (option) => titleCase(option.value),
}; };
// // // console.log(defaultProps) // // // // console.log(defaultProps)
this.setState({ kpiTypeList: defaultProps }) this.setState({ kpiTypeList: defaultProps })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -1053,7 +1054,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1053,7 +1054,7 @@ export default class CorporateAnnualTarget extends Component {
let columnEnd = 24 let columnEnd = 24
let month = column - 1 let month = column - 1
let total = 0 let total = 0
// // console.log(formulaAwal) // // // console.log(formulaAwal)
if (forecast == undefined) { if (forecast == undefined) {
dataTable2[tableMeta.rowIndex].map((itemz, indexz) => { dataTable2[tableMeta.rowIndex].map((itemz, indexz) => {
if (indexz >= columnStart && indexz <= columnStart + month) { if (indexz >= columnStart && indexz <= columnStart + month) {
...@@ -1090,10 +1091,10 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1090,10 +1091,10 @@ export default class CorporateAnnualTarget extends Component {
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
} }
} else { } else {
// // console.log(dataTable2[tableMeta.rowIndex][30]) // // // console.log(dataTable2[tableMeta.rowIndex][30])
let array = dataTable2[tableMeta.rowIndex][30].filter((val) => val.periode == Number(column)) let array = dataTable2[tableMeta.rowIndex][30].filter((val) => val.periode == Number(column))
let valuezz = array[0].value let valuezz = array[0].value
// // console.log(valuezz) // // // console.log(valuezz)
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
// let indexID = dataTable2[tableMeta.rowIndex][30].findIndex((val) => val.periode == Number(this.props.periode)) // let indexID = dataTable2[tableMeta.rowIndex][30].findIndex((val) => val.periode == Number(this.props.periode))
// if (indexID !== -1) { // if (indexID !== -1) {
...@@ -1251,21 +1252,21 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1251,21 +1252,21 @@ export default class CorporateAnnualTarget extends Component {
} }
}) })
// if (dataTable2[tableMeta.rowIndex][6] == "NPAT" && forecast !== undefined) { // if (dataTable2[tableMeta.rowIndex][6] == "NPAT" && forecast !== undefined) {
// // console.log(tableMeta.rowData[3]) // // // console.log(tableMeta.rowData[3])
// // console.log(splitFormula) // // // console.log(splitFormula)
// // console.log(baru) // // // console.log(baru)
// // console.log(anjay) // // // console.log(anjay)
// // // console.log(item1) // // // // console.log(item1)
// // console.log(anjay2) // // // console.log(anjay2)
// // console.log(total) // // // console.log(total)
// } // }
// // console.log(tableMeta.rowData[3]) // // // console.log(tableMeta.rowData[3])
// // console.log(splitFormula) // // // console.log(splitFormula)
// // console.log(baru) // // // console.log(baru)
// // console.log(anjay) // // // console.log(anjay)
// // console.log(item1) // // // console.log(item1)
// // console.log(anjay2) // // // console.log(anjay2)
// // console.log(total) // // // console.log(total)
total = dataTable2[tableMeta.rowIndex][6] == "ROIC" ? "0" : R.equals(total, NaN) ? "0.0" : total total = dataTable2[tableMeta.rowIndex][6] == "ROIC" ? "0" : R.equals(total, NaN) ? "0.0" : total
if (dataTable2[tableMeta.rowIndex][6] == "ROIC") { if (dataTable2[tableMeta.rowIndex][6] == "ROIC") {
...@@ -1383,7 +1384,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1383,7 +1384,7 @@ export default class CorporateAnnualTarget extends Component {
} }
const handleTambah = (data, rowIndex) => { 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)
...@@ -1427,7 +1428,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1427,7 +1428,7 @@ export default class CorporateAnnualTarget extends Component {
this.setState({ dataTable: dataTable2 }, () => { this.setState({ dataTable: dataTable2 }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false }) this.setState({ loading: false })
// // console.log(dataTable2) // // // console.log(dataTable2)
}, 500) }, 500)
}) })
} }
...@@ -1516,7 +1517,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1516,7 +1517,7 @@ export default class CorporateAnnualTarget extends Component {
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
}} }}
// 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], tableMeta.rowIndex) handleTambah(tableMeta.rowData[1], tableMeta.rowIndex)
...@@ -1572,9 +1573,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1572,9 +1573,9 @@ export default class CorporateAnnualTarget extends Component {
defaultValue={val} defaultValue={val}
// disabled={!handleAction(tableMeta.rowData[2])} // disabled={!handleAction(tableMeta.rowData[2])}
onBlur={(event) => { onBlur={(event) => {
// // // console.log(event.target.value) // // // // console.log(event.target.value)
handleChangeText(event.target.value, tableMeta) handleChangeText(event.target.value, tableMeta)
// // console.log(dataTable2) // // // console.log(dataTable2)
}} }}
/> />
} }
...@@ -1689,10 +1690,10 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1689,10 +1690,10 @@ export default class CorporateAnnualTarget extends Component {
color={"#5198ea"} color={"#5198ea"}
disabled={true} disabled={true}
onBlur={(event) => { onBlur={(event) => {
// // // console.log(event.target.value) // // // // console.log(event.target.value)
// updateValue(event.target.value) // updateValue(event.target.value)
handleChangeText(event.target.value, tableMeta) handleChangeText(event.target.value, tableMeta)
// // // console.log(dataTable2) // // // // console.log(dataTable2)
}} }}
/> : /> :
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
...@@ -1705,10 +1706,10 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1705,10 +1706,10 @@ export default class CorporateAnnualTarget extends Component {
color={"#5198ea"} color={"#5198ea"}
// disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))} // disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false ? false : !handleAction(tableMeta.rowData[2]))}
onBlur={(event) => { onBlur={(event) => {
// // // console.log(event.target.value) // // // // console.log(event.target.value)
// updateValue(event.target.value) // updateValue(event.target.value)
handleChangeText(event.target.value, tableMeta) handleChangeText(event.target.value, tableMeta)
// // // console.log(dataTable2) // // // // console.log(dataTable2)
}} }}
/> />
</ThemeProvider> </ThemeProvider>
...@@ -1855,7 +1856,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1855,7 +1856,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(dataTable2) // // // // console.log(dataTable2)
}} }}
/> />
} }
...@@ -1875,7 +1876,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1875,7 +1876,7 @@ export default class CorporateAnnualTarget extends Component {
</TableCell> </TableCell>
), ),
customBodyRender: (value, tableMeta) => { customBodyRender: (value, tableMeta) => {
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
return ( return (
<div style={{ width: 96 }}> <div style={{ width: 96 }}>
{ {
...@@ -1894,7 +1895,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1894,7 +1895,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -1919,7 +1920,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1919,7 +1920,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -1942,7 +1943,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1942,7 +1943,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -1980,7 +1981,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1980,7 +1981,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2005,7 +2006,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2005,7 +2006,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2028,7 +2029,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2028,7 +2029,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2066,7 +2067,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2066,7 +2067,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2091,7 +2092,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2091,7 +2092,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2114,7 +2115,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2114,7 +2115,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2153,7 +2154,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2153,7 +2154,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2178,7 +2179,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2178,7 +2179,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2201,7 +2202,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2201,7 +2202,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2240,7 +2241,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2240,7 +2241,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2265,7 +2266,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2265,7 +2266,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2288,7 +2289,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2288,7 +2289,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2327,7 +2328,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2327,7 +2328,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2352,7 +2353,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2352,7 +2353,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2375,7 +2376,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2375,7 +2376,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2414,7 +2415,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2414,7 +2415,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2439,7 +2440,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2439,7 +2440,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2462,7 +2463,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2462,7 +2463,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2501,7 +2502,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2501,7 +2502,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2526,7 +2527,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2526,7 +2527,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2549,7 +2550,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2549,7 +2550,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2588,7 +2589,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2588,7 +2589,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2613,7 +2614,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2613,7 +2614,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2636,7 +2637,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2636,7 +2637,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2675,7 +2676,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2675,7 +2676,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2700,7 +2701,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2700,7 +2701,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2723,7 +2724,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2723,7 +2724,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2762,7 +2763,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2762,7 +2763,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2787,7 +2788,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2787,7 +2788,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2810,7 +2811,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2810,7 +2811,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2849,7 +2850,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2849,7 +2850,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2874,7 +2875,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2874,7 +2875,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2897,7 +2898,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2897,7 +2898,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2937,7 +2938,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2937,7 +2938,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2962,7 +2963,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2962,7 +2963,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -2985,7 +2986,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -2985,7 +2986,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -3024,7 +3025,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -3024,7 +3025,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -3049,7 +3050,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -3049,7 +3050,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -3072,7 +3073,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -3072,7 +3073,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -3111,7 +3112,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -3111,7 +3112,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -3136,7 +3137,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -3136,7 +3137,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -3159,7 +3160,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -3159,7 +3160,7 @@ export default class CorporateAnnualTarget extends Component {
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta)
// // // console.log(tableMeta.rowData[0]) // // // // console.log(tableMeta.rowData[0])
}} }}
/> />
} }
...@@ -3196,9 +3197,9 @@ export default class CorporateAnnualTarget extends Component { ...@@ -3196,9 +3197,9 @@ export default class CorporateAnnualTarget extends Component {
disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)} disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
defaultValue={value} defaultValue={value}
onBlur={(event) => { onBlur={(event) => {
// // // console.log(event.target.value) // // // // console.log(event.target.value)
handleChangeText(event.target.value, tableMeta) handleChangeText(event.target.value, tableMeta)
// // // console.log(dataTable2) // // // // console.log(dataTable2)
}} }}
/> />
</ThemeProvider> </ThemeProvider>
...@@ -3236,10 +3237,10 @@ export default class CorporateAnnualTarget extends Component { ...@@ -3236,10 +3237,10 @@ export default class CorporateAnnualTarget extends Component {
disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)} disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)}
defaultValue={value} defaultValue={value}
onBlur={(event) => { onBlur={(event) => {
// // // console.log(event.target.value) // // // // console.log(event.target.value)
// updateValue(event.target.value) // updateValue(event.target.value)
handleChangeText(event.target.value, tableMeta) handleChangeText(event.target.value, tableMeta)
// // // console.log(dataTable2) // // // // console.log(dataTable2)
}} }}
/> />
</ThemeProvider> </ThemeProvider>
......
...@@ -9,6 +9,8 @@ import Tooltip from '@material-ui/core/Tooltip'; ...@@ -9,6 +9,8 @@ import Tooltip from '@material-ui/core/Tooltip';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import Constant from '../../library/Constant'; import Constant from '../../library/Constant';
import { Alert, Autocomplete } from '@material-ui/lab'; import { Alert, Autocomplete } from '@material-ui/lab';
import UploadFile from '../../library/Upload';
import { ExcelRenderer } from 'react-excel-renderer';
const LightTooltip = withStyles((theme) => ({ const LightTooltip = withStyles((theme) => ({
tooltip: { tooltip: {
...@@ -60,7 +62,10 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -60,7 +62,10 @@ export default class CorporateAnnualTargetMR extends Component {
options: [{ value: 'SUM' }, { value: 'AVG' }, { value: 'LAST' }], options: [{ value: 'SUM' }, { value: 'AVG' }, { value: 'LAST' }],
getOptionLabel: (option) => titleCase(option.value), getOptionLabel: (option) => titleCase(option.value),
}, },
visibleCATMR: true,
updateBy: '-'
} }
this.fileHandler = this.fileHandler.bind(this);
} }
componentDidMount() { componentDidMount() {
...@@ -187,6 +192,155 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -187,6 +192,155 @@ export default class CorporateAnnualTargetMR extends Component {
}) })
} }
downloadTemplate = async () => {
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report/cat/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
)
res = await res.blob()
console.log(res);
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Template Monthly Report Corporate Annual Target.xlsx'
a.click();
}
}
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
if (err) {
console.log(err);
}
else {
let isi = resp.rows.slice(3)
let payload = []
let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
orders: i[0] === undefined ? "" : String(i[0]).trim(),
item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
wight: i[3] === undefined ? "" : (String(i[3])) === false ? "0" : String(i[3]).trim(),
oum: i[4] === undefined ? "" : (String(i[4])) === false ? "0" : String(i[4]).trim(),
kpi_type: i[5] === undefined ? "" : (String(i[5])) === false ? "0" : String(i[5]).trim(),
max_ach: i[6] === undefined ? "" : (String(i[6])) === false ? "0" : String(i[6]).trim(),
actual_monthly: i[7] === undefined ? "0.0" : (String(i[7])) === false ? "0" : String(i[7]).trim(),
notes: i[8] === undefined ? "" : (String(i[8])) === false ? "0" : String(i[8]).trim(),
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
months: this.props.month.month_id,
corporate_annual_target: payload
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
}
});
}
checkUpload() {
api.create().checkUploadMonthlyReportCAT(this.state.payload).then(response => {
console.log(JSON.stringify(this.state.payload));
// console.log(this.state.payload)
// console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleCATMR: false })
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,
item.max_ach,
item.formula,
item.actual_monthly,
item.target_monthly,
item.achivement_monthly,
item.score,
item.score_x_weight,
item.notes
]
})
console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.state.dataTable.map(item => {
if (item[18].length > 0) {
console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
})
console.log(this.state.dataTable);
})
}
}
})
}
uploadCATMR(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
item_report: String(i[5]).trim(),
wight: String(i[6]),
uom: String(i[7]),
jenis_kpi: i[8] == null ? "" : i[8].value,
max_ach: i[9] == null ? "" : i[9].value,
formula_ytd: i[10] == null ? "" : i[10].value,
actual_monthly: String(Number(i[11]).toFixed(1)),
target_monthly: String(Number(i[12]).toFixed(1)),
achivement_monthly: String(Number(i[13]).toFixed(1)),
score: String(Number(i[14]).toFixed(1)),
score_x_weight: String(Number(i[15]).toFixed(1)),
notes: String(i[16]).trim()
})
})
let body = {
"monthly_report_id": this.props.monthlyReportId,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"months": this.props.month.month_id,
"corporate_annual_target": data
// "fixed_asset_movement": data
}
console.log(data);
api.create('UPLOAD').uploadMonthlyReportCAT(body).then(response => {
// console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
// this.props.getReport()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
getKPIType() { getKPIType() {
let body = { let body = {
group: 'CAT', group: 'CAT',
...@@ -1065,7 +1219,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1065,7 +1219,7 @@ export default class CorporateAnnualTargetMR extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => null} onClick={() => this.downloadTemplate() }
> >
<img src={Images.template} /> <img src={Images.template} />
</button> </button>
...@@ -1079,7 +1233,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1079,7 +1233,7 @@ export default class CorporateAnnualTargetMR extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => null} onClick={() => this.setState({ visibleUpload: true })}
> >
<img src={Images.upload} /> <img src={Images.upload} />
</button> </button>
...@@ -1093,7 +1247,12 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1093,7 +1247,12 @@ export default class CorporateAnnualTargetMR extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => null} onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
}, 100);
})}
> >
<img src={Images.download} /> <img src={Images.download} />
</button> </button>
...@@ -1104,6 +1263,7 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1104,6 +1263,7 @@ export default class CorporateAnnualTargetMR 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 && (
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
...@@ -1111,7 +1271,9 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1111,7 +1271,9 @@ export default class CorporateAnnualTargetMR extends Component {
options={options} options={options}
/> />
</MuiThemeProvider> </MuiThemeProvider>
)}
</div> </div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
</div> </div>
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1"> <div className="col-1">
...@@ -1137,6 +1299,43 @@ export default class CorporateAnnualTargetMR extends Component { ...@@ -1137,6 +1299,43 @@ export default class CorporateAnnualTargetMR extends Component {
</div> </div>
</Paper> </Paper>
</div> </div>
{this.state.visibleUpload && (
<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' }}>Upload File</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({ visibleUpload: false })}
>
<img src={Images.close} />
</button>
</div>
</div>
<UploadFile
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onUpload={() => {
String(this.state.judul).includes("MONTHLY REPORT - PERFORMANCE CAT") ?
this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</div>
</div>
)}
</div> </div>
) )
} }
......
...@@ -76,7 +76,8 @@ export default class ProfitLossMR extends Component { ...@@ -76,7 +76,8 @@ export default class ProfitLossMR extends Component {
// valueThreshold: 0, // valueThreshold: 0,
minValue: 0, minValue: 0,
maxValue: 0, maxValue: 0,
updateBy: '-' updateBy: '-',
bebeas: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -488,6 +489,30 @@ export default class ProfitLossMR extends Component { ...@@ -488,6 +489,30 @@ export default class ProfitLossMR extends Component {
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
const handleCalculate = () => {
let error = false
let messageError = ""
dataTable2.map((item, index) => {
if (item[19] == "" && Number(item[14]) <= this.state.minValue || Number(item[14]) >= this.state.maxValue) {
error = true
messageError = "MTD Explanation vs Prev. Month is Reqiured"
}
if (item[20] == "" && Number(item[16]) <= this.state.minValue || Number(item[16]) >= this.state.maxValue) {
error = true
messageError = "MTD Explanation vs MB is Reqiured"
}
if (item[21] == "" && Number(item[18]) <= this.state.minValue || Number(item[18]) >= this.state.maxValue) {
error = true
messageError = "MTD Explanation vs RB is Reqiured"
}
})
if (error === true) {
this.setState({ alert: true, messageAlert: messageError, tipeAlert: 'error', loading: false, bebas: true })
}
}
const handleText = (value, tableMeta, type) => { const handleText = (value, tableMeta, type) => {
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = value let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = value
// console.log(dataTable2[tableMeta.rowIndex]); // console.log(dataTable2[tableMeta.rowIndex]);
...@@ -1503,12 +1528,30 @@ export default class ProfitLossMR extends Component { ...@@ -1503,12 +1528,30 @@ export default class ProfitLossMR extends Component {
style={{ margin: 0 }} style={{ margin: 0 }}
// value={value} // value={value}
control={ control={
tableMeta.rowData[19] == "" && Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ?
<LightTooltip title={"MTD Explanation vs Prev. Month is Reqiured"} arrow>
<Input
disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[19]}
inputProps={{style: {
color: "#5198ea",
textAlign: 'right'
}}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 0)
}}
/>
</LightTooltip> :
<Input <Input
disableUnderline={true} disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ? false : true} // disabled={Number(tableMeta.rowData[14]) <= this.state.minValue || Number(tableMeta.rowData[14]) >= this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[19]} defaultValue={tableMeta.rowData[19]}
inputProps={{style: { inputProps={{style: {
color: "#5198ea", color: "#5198ea",
...@@ -1531,12 +1574,30 @@ export default class ProfitLossMR extends Component { ...@@ -1531,12 +1574,30 @@ export default class ProfitLossMR extends Component {
style={{ margin: 0 }} style={{ margin: 0 }}
// value={value} // value={value}
control={ control={
tableMeta.rowData[20] == "" && Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ?
<LightTooltip title={"MTD Explanation vs MB is Reqiured"} arrow>
<Input <Input
disableUnderline={true} disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ? false : true} // disabled={Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[20]}
inputProps={{style: {
color: "#5198ea",
textAlign: 'right'
}}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 1)
}}
/>
</LightTooltip> :
<Input
disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={Number(tableMeta.rowData[16]) <= this.state.minValue || Number(tableMeta.rowData[16]) >= this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[20]} defaultValue={tableMeta.rowData[20]}
inputProps={{style: { inputProps={{style: {
color: "#5198ea", color: "#5198ea",
...@@ -1559,12 +1620,30 @@ export default class ProfitLossMR extends Component { ...@@ -1559,12 +1620,30 @@ export default class ProfitLossMR extends Component {
style={{ margin: 0 }} style={{ margin: 0 }}
// value={value} // value={value}
control={ control={
tableMeta.rowData[21] == "" && Number(tableMeta.rowData[18]) <= this.state.minValue || Number(tableMeta.rowData[18]) >= this.state.maxValue ?
<LightTooltip title={"MTD Explanation vs RB is Reqiured"} arrow>
<Input <Input
disableUnderline={true} disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={Number(tableMeta.rowData[18]) <= this.state.minValue || Number(tableMeta.rowData[18]) >= this.state.maxValue ? false : true} // disabled={Number(tableMeta.rowData[18]) <= this.state.minValue || Number(tableMeta.rowData[18]) >= this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[21]}
inputProps={{style: {
color: "#5198ea",
textAlign: 'right'
}}}
onBlur={(event) => {
handleText(event.target.value, tableMeta, 0)
}}
/>
</LightTooltip> :
<Input
disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
// disabled={Number(tableMeta.rowData[18]) <= this.state.minValue || Number(tableMeta.rowData[18]) >= this.state.maxValue ? false : true}
defaultValue={tableMeta.rowData[21]} defaultValue={tableMeta.rowData[21]}
inputProps={{style: { inputProps={{style: {
color: "#5198ea", color: "#5198ea",
...@@ -1768,8 +1847,10 @@ export default class ProfitLossMR extends Component { ...@@ -1768,8 +1847,10 @@ export default class ProfitLossMR extends Component {
marginRight: 20 marginRight: 20
}} }}
onClick={() => { onClick={() => {
this.setState({ loading: true }, () => { this.setState({ loading: true, bebas: false }, () => {
setTimeout(() => { setTimeout(() => {
handleCalculate()
this.setState({ loading: false }) this.setState({ loading: false })
// this.handleValidate() // this.handleValidate()
}, 100); }, 100);
...@@ -1785,7 +1866,7 @@ export default class ProfitLossMR extends Component { ...@@ -1785,7 +1866,7 @@ export default class ProfitLossMR extends Component {
type="button" type="button"
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.saveDraft !== true ? 'pointer' : 'default', cursor: this.state.bebas ? 'default' : this.state.saveDraft !== true ? 'pointer' : 'default',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
...@@ -1793,6 +1874,7 @@ export default class ProfitLossMR extends Component { ...@@ -1793,6 +1874,7 @@ export default class ProfitLossMR extends Component {
onClick={() => onClick={() =>
this.state.saveDraft === true ? this.state.saveDraft === true ?
null : null :
this.state.bebas ? null :
this.state.handleTekTekTek == 1 ? null : this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1, loading: true }, () => { this.setState({ handleTekTekTek: 1, loading: true }, () => {
this.backToMonthlyReport('draft') this.backToMonthlyReport('draft')
...@@ -1807,6 +1889,7 @@ export default class ProfitLossMR extends Component { ...@@ -1807,6 +1889,7 @@ export default class ProfitLossMR extends Component {
type="button" type="button"
// disabled={this.state.buttonError} // disabled={this.state.buttonError}
onClick={() => onClick={() =>
this.state.bebas ? null :
this.state.buttonError ? this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
: :
...@@ -1816,7 +1899,7 @@ export default class ProfitLossMR extends Component { ...@@ -1816,7 +1899,7 @@ export default class ProfitLossMR extends Component {
})} })}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer', cursor: this.state.buttonError === true ? 'default' : this.state.bebas ? 'default' : 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
}} }}
......
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