Commit 1bd6874e authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

apdet

See merge request !490
parents be132695 bcc10220
......@@ -37,13 +37,49 @@ export default class OperatingIndicator extends Component {
operatingIndID: null,
alert: false,
tipeAlert: '',
messageAlert: ''
messageAlert: '',
buttonCreate: true,
buttonEdit: true,
buttonDelete: true
}
this.fileHandler = this.fileHandler.bind(this);
}
componentDidMount() {
this.getDetailUser()
this.getPermission()
}
getPermission() {
let payload = {
menu: "operating indicator"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
buttonCreate: response.data.data.create,
buttonEdit: response.data.data.edit,
buttonDelete: response.data.data.delete,
load: true
})
} else {
this.setState({ load: true })
}
}
})
}
getLastPeriod() {
api.create().getLastPeriod(this.state.company.company_id).then(response => {
console.log(response);
if (response.data.status === "success") {
this.setState({ lastPeriod: response.data.data.last_periode, latestPeriode: response.data.data.latest_periode }, () => {
this.getPeriode()
})
}
})
}
getReportAttachment() {
......@@ -150,7 +186,7 @@ export default class OperatingIndicator extends Component {
};
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1? companyData[0] : arrayBaru[0] }, () => {
this.getPeriode()
this.getLastPeriod()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -172,9 +208,21 @@ export default class OperatingIndicator extends Component {
api.create().getPeriodeTransaction().then(response => {
let dateNow = new Date
let year = format(dateNow, 'yyyy')
let currentYear = new Date().getFullYear()
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
let data = []
response.data.data.map((item) => {
if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
data.push(item)
}
} else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
data.push(item)
}
}
})
let periodeData = data.map((item) => {
return {
periode: item,
......@@ -184,7 +232,8 @@ export default class OperatingIndicator extends Component {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let index = data.sort((a, b) => a - b).findIndex((val) => val == year)
let periode = (this.state.latestPeriode == "" ? String(Number(currentYear) + 1) : this.state.latestPeriode)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
this.setState({ listPeriode: defaultProps, periode: index == -1 ? periodeData[0] : periodeData[index] }, () => {
this.getReport()
this.getOperatingID()
......@@ -522,7 +571,8 @@ export default class OperatingIndicator extends Component {
})}
getReport={() => this.getReport()}
saveOperatingInd={this.saveOperatingInd.bind(this)}
superUser={this.state.superUser}
// superUser={this.state.superUser}
permission={{create: this.state.buttonCreate, edit: this.state.buttonEdit, delete: this.state.buttonDelete}}
/>
}
......
......@@ -1244,7 +1244,7 @@ export default class BalanceSheet extends Component {
</div>
<div style={{ width: '50%' }}>
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
{this.props.superUser && <a data-tip={'Download Template'} data-for="template">
{(this.props.permission.create && this.props.permission.edit) && <a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
......@@ -1258,7 +1258,7 @@ export default class BalanceSheet extends Component {
</button>
</a>}
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
{this.props.superUser && <a data-tip={'Upload'} data-for="upload">
{(this.props.permission.create && this.props.permission.edit) && <a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
......@@ -1323,7 +1323,7 @@ export default class BalanceSheet extends Component {
</div>
</button>
</div>
{!this.state.emptyData && this.props.superUser && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
{!this.state.emptyData && (this.props.permission.create && this.props.permission.edit) && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
type="button"
onClick={() =>
......
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