Commit bd3ccc53 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

updateBalancesitttt & upload size

See merge request !327
parents babf96c2 e216e637
import React, { Component } from 'react';
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input } from '@material-ui/core';
import { Typography, Paper, createMuiTheme, MuiThemeProvider, TableCell, FormControlLabel, TextField, Input, Tooltip, withStyles } from '@material-ui/core';
import MUIDataTable from 'mui-datatables';
import NumberFormat from 'react-number-format';
import api from '../../api';
......@@ -11,6 +11,15 @@ import ReactTooltip from 'react-tooltip';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
const LightTooltip = withStyles((theme) => ({
tooltip: {
backgroundColor: theme.palette.common.white,
color: 'rgba(0, 0, 0, 0.87)',
boxShadow: theme.shadows[1],
fontSize: 11,
},
}))(Tooltip);
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());
......@@ -34,7 +43,8 @@ export default class BalanceSheet extends Component {
dataTable: [],
visibleBalanceSheet: true,
disabledSave: true,
editable: false
editable: false,
buttonError: false
}
this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this);
......@@ -128,7 +138,7 @@ export default class BalanceSheet extends Component {
}
}
})
this.setState({ dataTable, loading: false })
this.setState({ dataTable, loading: false, buttonError: true })
})
}
......@@ -222,27 +232,28 @@ export default class BalanceSheet extends Component {
let isi = resp.rows.slice(3)
console.log(isi);
let payload = []
let reg = /^\d+$/;
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(),
total_actual_before: i[2] === undefined ? "" : String(i[2]).trim(),
january: i[3] === undefined ? "" : String(i[3]).trim(),
february: i[4] === undefined ? "" : String(i[4]).trim(),
march: i[5] === undefined ? "" : String(i[5]).trim(),
april: i[6] === undefined ? "" : String(i[6]).trim(),
may: i[7] === undefined ? "" : String(i[7]).trim(),
june: i[8] === undefined ? "" : String(i[8]).trim(),
july: i[9] === undefined ? "" : String(i[9]).trim(),
august: i[10] === undefined ? "" : String(i[10]).trim(),
september: i[11] === undefined ? "" : String(i[11]).trim(),
october: i[12] === undefined ? "" : String(i[12]).trim(),
november: i[13] === undefined ? "" : String(i[13]).trim(),
december: i[14] === undefined ? "" : String(i[14]).trim(),
total_current_year: i[15] === undefined ? "" : String(i[15]).trim(),
total_next_year: i[16] === undefined ? "" : String(i[16]).trim(),
total_more_year: i[16] === undefined ? "" : String(i[17]).trim()
total_actual_before: i[2] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[2]).trim(),
january: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
february: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
march: i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
april: i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
may: i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
june: i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
july: i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
august: i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
september: i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
october: i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
november: i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
december: i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
total_current_year: i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
total_next_year: i[16] === undefined ? "0" : reg.test(String(i[16])) === false ? "0" : String(i[16]).trim(),
total_more_year: i[17] === undefined ? "0" : reg.test(String(i[17])) === false ? "0" : String(i[17]).trim()
})
}
})
......@@ -252,15 +263,15 @@ export default class BalanceSheet extends Component {
report_id: this.props.report_id,
balance_sheet: payload
}
// console.log(JSON.stringify(body))
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0] })
}
});
}
checkUpload() {
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)
if (response.data) {
if (response.data.status === 'success') {
......@@ -292,20 +303,16 @@ export default class BalanceSheet extends Component {
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
if (this.state.dataTable[22].length > 0) {
this.setState({ buttonError: true, errorPreview: true })
}
})
}
}
})
}
checkError(tableMeta) {
if (tableMeta.rowData[22]) {
if (tableMeta.rowData[22][0] === 'item') {
this.setState({ buttonError: true })
}
}
}
uploadBalanceSheet() {
let data = []
this.state.dataTable.map(i => {
......@@ -477,26 +484,11 @@ export default class BalanceSheet extends Component {
<div style={{ width: 300 }}>
{tableMeta.rowData[22] ?
tableMeta.rowData[22].length > 0 ?
tableMeta.rowData[22][0].field === 'item' ?
tableMeta.rowData[4] == 0 ?
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
{this.checkError(tableMeta)}
</a>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
{this.checkError(tableMeta)}
</a>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<LightTooltip title={"Report Items Not Registered"} arrow>
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</LightTooltip>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
......@@ -512,7 +504,6 @@ export default class BalanceSheet extends Component {
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
}
<ReactTooltip border={true} id="account" place="bottom" type="light" effect="solid" />
</div>
)
}
......@@ -598,7 +589,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -629,7 +620,6 @@ export default class BalanceSheet extends Component {
placeholder=""
value={value}
onBlur={(event) => {
// updateValue(event.target.value)
handleChange(event.target.value, tableMeta)
console.log(dataTable2)
}}
......@@ -685,7 +675,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -772,7 +762,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -859,7 +849,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -946,7 +936,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1033,7 +1023,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1120,7 +1110,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1207,7 +1197,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1294,7 +1284,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1381,7 +1371,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1468,7 +1458,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1555,7 +1545,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1642,7 +1632,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1729,7 +1719,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1816,7 +1806,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1903,7 +1893,7 @@ export default class BalanceSheet extends Component {
// />
null
:
<span>validasi</span>
null
}
</div>
)
......@@ -1944,7 +1934,7 @@ export default class BalanceSheet extends Component {
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ width: '50%' }}>
......@@ -2047,40 +2037,40 @@ export default class BalanceSheet extends Component {
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.disabledSave}
onClick={() => this.backToMasterBudget('submitted')}
style={{
backgroundColor: 'transparent',
cursor: this.state.disabledSave === true ? 'default' : 'pointer',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: false, editable: true })
}, 100);
})
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
className="button"
type="button"
disabled={this.state.buttonError}
onClick={() => this.backToMasterBudget('submitted')}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, disabledSave: false, editable: true })
}, 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>
......@@ -2117,33 +2107,20 @@ export default class BalanceSheet extends Component {
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError == true ? true : false}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadBalanceSheet()
}, 100);
})}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
cursor: this.state.buttonError === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none'
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false })
this.setState({ loading: false, buttonError: this.state.errorPreview === true ? true : false })
}, 100);
})
}}
......@@ -2152,6 +2129,19 @@ export default class BalanceSheet extends Component {
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadBalanceSheet()
}, 100);
})}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
</div>
</div>
</Paper>}
......
......@@ -50,7 +50,8 @@ export default class Parameter extends Component {
delete: false,
load: false,
judul: '',
loading: false
loading: false,
sizeUpload: "1"
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -58,6 +59,25 @@ export default class Parameter extends Component {
componentDidMount() {
this.getAllParameter()
this.getPermission()
this.getSizeUpload()
}
getSizeUpload(){
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
type: 'MAX_FILE_SIZE'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({
sizeUpload: response.data.data[0].value
})
}
}
})
}
getPermission() {
......@@ -1047,6 +1067,7 @@ export default class Parameter extends Component {
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
sizeUpload={Number(this.state.sizeUpload)}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandler(dt)
......
......@@ -62,7 +62,8 @@ export default class UnitBisnis extends Component {
rowData: [],
unitBisnisName: '',
// visibleLoad: true,
loading: false
loading: false,
sizeUpload: "1"
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -225,6 +226,25 @@ export default class UnitBisnis extends Component {
componentDidMount() {
this.getData()
this.getPermission()
this.getSizeUpload()
}
getSizeUpload(){
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
type: 'MAX_FILE_SIZE'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({
sizeUpload: response.data.data[0].value
})
}
}
})
}
getPermission() {
......@@ -771,6 +791,7 @@ export default class UnitBisnis extends Component {
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
sizeUpload={Number(this.state.sizeUpload)}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandler(dt)
......
......@@ -34,6 +34,8 @@ export default class CreateReportItems extends Component {
listCompany: null,
listReportType: null,
listParent: null,
listKPI: null,
listMaxAch: null,
errorOrder: false,
errorDesc: false,
errorFormula: false,
......@@ -66,7 +68,9 @@ export default class CreateReportItems extends Component {
formulaYtd: ['SUM', 'AVG', 'MIN', 'MAX'],
kpiTypeValue: null,
maxAchValue: null,
formulaYTDValue: null
formulaYTDValue: null,
kpiDisable: true,
maxAchDisable: true
}
}
......@@ -153,9 +157,9 @@ export default class CreateReportItems extends Component {
validasi() {
// alert('coba ya')
if (R.isNil(this.state.reportType)) {
this.setState({errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty'})
} else if (R.isNil(this.state.company)){
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty'})
this.setState({ errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty' })
} else if (R.isNil(this.state.company)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty' })
} else if (R.isEmpty(this.state.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' })
}
......@@ -199,8 +203,8 @@ export default class CreateReportItems extends Component {
"weight": this.state.weight,
"condition_if_wrong": this.state.condition,
"condition_it_should_be": this.state.realVal,
"type_kpi": this.state.kpiTypeValue,
"max_ach": this.state.maxAchValue,
"type_kpi": this.state.kpiTypeValue.value,
"max_ach": this.state.maxAchValue.value,
"formula_ytd": this.state.formulaYTDValue,
"start_date": this.state.startDate,
"end_date": this.state.endDate
......@@ -209,10 +213,92 @@ export default class CreateReportItems extends Component {
this.props.createReportItems(payload)
}
getKPIType() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'KPI_TYPE'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputKPI = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputKPI,
getOptionLabel: (option) => titleCase(option.value),
};
this.setState({ listKPI: defaultProps, inputKPI: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getMaxAch() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'MAX_ACHIEVEMENT'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputMaxAch = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputMaxAch,
getOptionLabel: (option) => titleCase(option.value),
};
this.setState({ listMaxAch: defaultProps, inputMaxAch: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getInputType() {
api.create().getInputType().then((response) => {
// console.log(response.data)
if(response.data) {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
......@@ -450,8 +536,8 @@ export default class CreateReportItems extends Component {
<Autocomplete
{...this.state.listReportType}
id="reportType"
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () => {
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ kpiTypeValue: null, maxAchValue: null, formulaYTDValue: null }, () => this.clearMessage())
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue, kpiDisable: true, maxAchDisable: true }, () => {
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ kpiTypeValue: null, maxAchValue: null, formulaYTDValue: null }, () => this.clearMessage())
: this.clearMessage();
})}
debug
......@@ -481,7 +567,12 @@ export default class CreateReportItems extends Component {
<Autocomplete
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => this.getParent(), this.clearMessage())}
onChange={(event, newInputValue) => this.setState({ company: newInputValue, kpiDisable: false, maxAchDisable: false }, () => {
this.getParent()
this.clearMessage()
this.getKPIType()
this.getMaxAch()
})}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -790,88 +881,90 @@ export default class CreateReportItems extends Component {
</div>
{this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.kpiTypeValue}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ kpiTypeValue: newValue }, () => this.clearMessage());
}}
options={this.state.kpiType}
renderInput={(params) =>
<TextField {...params}
label="KPI Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listKPI}
value={this.state.kpiTypeValue}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ kpiTypeValue: newValue }, () => this.clearMessage());
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.maxAchValue}
id="maxAch"
onChange={(event, newValue) => {
this.setState({ maxAchValue: newValue }, () => this.clearMessage());
}}
options={this.state.maxAch}
renderInput={(params) =>
<TextField {...params}
label="Max Achievement"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
disabled={this.state.kpiDisable}
renderInput={(params) =>
<TextField {...params}
label="KPI Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listMaxAch}
value={this.state.maxAchValue}
id="maxAch"
onChange={(event, newValue) => {
this.setState({ maxAchValue: newValue }, () => this.clearMessage());
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
disabled={this.state.maxAchDisable}
renderInput={(params) =>
<TextField {...params}
label="Max Achievement"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div>
</div>
</div>
))}
))}
{this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.formulaYTDValue}
id="formulaYTD"
onChange={(event, newValue) => {
this.setState({ formulaYTDValue: newValue }, () => this.clearMessage());
}}
options={this.state.formulaYtd}
renderInput={(params) =>
<TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.formulaYTDValue}
id="formulaYTD"
onChange={(event, newValue) => {
this.setState({ formulaYTDValue: newValue }, () => this.clearMessage());
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
options={this.state.formulaYtd}
renderInput={(params) =>
<TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div>
</div>
</div>
))}
))}
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
......@@ -968,7 +1061,7 @@ export default class CreateReportItems extends Component {
</div>
</div>
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30}}>
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30 }}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '13%' }}>Created By :</Typography>
{/* <Typography style={{ fontSize: 11 }}>: </Typography> */}
......
......@@ -36,6 +36,10 @@ export default class EditReportItems extends Component {
listCompany: null,
listReportType: null,
listParent: null,
listKPI: null,
listMaxAch: null,
MaxAchValue: null,
KPIValue: null,
errorOrder: false,
errorDesc: false,
errorFormula: false,
......@@ -134,10 +138,10 @@ export default class EditReportItems extends Component {
validasi() {
// alert('coba ya')
if (R.isNil(this.state.reportType)){
this.setState({errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty'})
} else if (R.isNil(this.state.company)){
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty'})
if (R.isNil(this.state.reportType)) {
this.setState({ errorJenisLaporan: true, msgErrorJenisLaporan: 'Report Type Cannot be Empty' })
} else if (R.isNil(this.state.company)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Name Cannot be Empty' })
} else if (R.isEmpty(this.state.tempData.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order Cannot be Empty' })
} else if (R.isEmpty(this.state.tempData.description)) {
......@@ -191,13 +195,13 @@ export default class EditReportItems extends Component {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
this.setState({
this.setState({
tempData: response.data.data,
getCompanyID: data.company_id
}, () => this.getInputType(),
this.getPerusahaan(),
this.getReportType(),)
console.log(response.data.data)
getCompanyID: data.company_id
}, () => this.getInputType(),
this.getPerusahaan(),
this.getReportType())
console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
......@@ -279,7 +283,94 @@ export default class EditReportItems extends Component {
getOptionLabel: (option) => option.company_name,
};
// let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
this.setState({ listCompany: defaultProps, companyData: response.data.data, company: index === -1 ? null : companyData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive.' : "", errorPerusahaan: index === -1 ? true : false }, () => this.getParent())
this.setState({ listCompany: defaultProps, companyData: response.data.data, company: index === -1 ? null : companyData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive.' : "", errorPerusahaan: index === -1 ? true : false }, () => {
this.getParent()
this.getKPIType()
this.getMaxAch()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getKPIType() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'KPI_TYPE'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputKPI = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputKPI,
getOptionLabel: (option) => titleCase(option.value),
};
let index = inputKPI.findIndex((val) => val.value === this.state.tempData.kpi_type)
this.setState({ listKPI: defaultProps, inputKPI: response.data.data, KPIValue: index === -1 ? null : inputKPI[index]})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getMaxAch() {
let body = {
group: 'CAT',
company_id: this.state.company.company_id,
type: 'MAX_ACHIEVEMENT'
}
api.create().getAllSettingByType(body).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let inputMaxAch = data.map((item) => {
return {
value: item.value
}
})
let defaultProps = {
options: inputMaxAch,
getOptionLabel: (option) => titleCase(option.value),
};
let index = inputMaxAch.findIndex((val) => val.value === this.state.tempData.max_ach)
this.setState({ listMaxAch: defaultProps, inputMaxAch: response.data.data, MaxAchValue: index === -1 ? null : inputMaxAch[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
......@@ -289,6 +380,7 @@ export default class EditReportItems extends Component {
}, 1000);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......@@ -465,9 +557,9 @@ export default class EditReportItems extends Component {
<Autocomplete
{...this.state.listReportType}
id="reportType"
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () =>
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ tempData: { ...this.state.tempData, kpi_type: null, max_ach: null, formula_ytd: null } }, () => this.getParent(), this.clearMessage())
: this.getParent(), this.clearMessage()
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () =>
newInputValue == null || (newInputValue.report_name !== 'CAT') ? this.setState({ tempData: { ...this.state.tempData, kpi_type: null, max_ach: null, formula_ytd: null } }, () => this.getParent(), this.clearMessage())
: this.getParent(), this.clearMessage()
)}
debug
renderInput={(params) =>
......@@ -774,88 +866,88 @@ export default class EditReportItems extends Component {
</div>
{this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.kpi_type}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, kpi_type: newValue } }, () => this.clearMessage());
}}
options={this.state.kpiType}
renderInput={(params) =>
<TextField {...params}
label="KPI Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listKPI}
value={this.state.KPIValue}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, kpi_type: newValue.value }, KPIValue: newValue }, () => this.clearMessage());
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.max_ach}
id="maxAch"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, max_ach: newValue } }, () => this.clearMessage());
}}
options={this.state.maxAch}
renderInput={(params) =>
<TextField {...params}
label="Max Achievement"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
renderInput={(params) =>
<TextField {...params}
label="KPI Type"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listMaxAch}
value={this.state.MaxAchValue}
id="maxAch"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, max_ach: newValue.value }, MaxAchValue: newValue }, () => this.clearMessage());
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
renderInput={(params) =>
<TextField {...params}
label="Max Achievement"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div>
</div>
</div>
))}
))}
{this.state.reportType !== null && (
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.formula_ytd}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, formula_ytd: newValue } }, () => this.clearMessage());
}}
options={this.state.formulaYtd}
renderInput={(params) =>
<TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
this.state.reportType.report_name === 'CAT' && (
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.tempData === null ? "" : this.state.tempData.formula_ytd}
id="kpiType"
onChange={(event, newValue) => {
this.setState({ tempData: { ...this.state.tempData, formula_ytd: newValue } }, () => this.clearMessage());
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
options={this.state.formulaYtd}
renderInput={(params) =>
<TextField {...params}
label="Formula YTD"
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
</div>
</div>
</div>
</div>
))}
))}
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
......@@ -949,7 +1041,7 @@ export default class EditReportItems extends Component {
</div>
</div>
</div>
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30}}>
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30 }}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.created}</Typography>
......
......@@ -25,7 +25,8 @@ class Upload extends Component {
percentage: '0',
completed: '0',
alert: false,
alertMessage: ''
alertMessage: '',
sizeUpload: this.props.sizeUpload === undefined ? 0 : this.props.sizeUpload
}
}
......@@ -146,7 +147,7 @@ class Upload extends Component {
// alert('File Tidak Boleh Lebih Dari 1MB')
}
} else {
if (this.state.sizeFile < 1000) {
if (this.state.sizeFile < this.state.sizeUpload * 1000) {
this.props.onUpload()
} else {
this.setState({ alertMessage: 'The file is too large. Allowed maximum size is 1MB', alert: true })
......
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