Commit 5a149315 authored by Deni Rinaldi's avatar Deni Rinaldi

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

isu donlot sh

See merge request !549
parents f643fe85 43b15da9
......@@ -6,6 +6,8 @@ import { titleCase } from '../../library/Utils'
import { Autocomplete } from '@material-ui/lab'
import TableSubHolding from './TableSubHolding'
import { PropagateLoader } from 'react-spinners'
import ReactTooltip from 'react-tooltip'
import Images from '../../assets/Images'
export default class SubHolding extends Component {
constructor(props) {
......@@ -272,9 +274,9 @@ export default class SubHolding extends Component {
}
}
})
this.setState({ dataTable, previewTable: true, loading: false })
this.setState({ dataTable, previewTable: true, loading: false, previewDownload: true })
} else {
this.setState({ dataTable: [], previewTable: false, loading: false })
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
}
} else if (this.state.report.value === 2) {
if (response.data) {
......@@ -353,16 +355,49 @@ export default class SubHolding extends Component {
}
})
// console.log(dataTable)
this.setState({ dataTable, previewTable: true, loading: false })
this.setState({ dataTable, previewTable: true, loading: false, previewDownload: true })
} else {
this.setState({ dataTable: [], previewTable: false, loading: false })
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
}
} else {
this.setState({ dataTable: [], previewTable: false, loading: false })
this.setState({ dataTable: [], previewTable: false, loading: false, previewDownload: false })
}
})
}
async downloadAllData() {
if (this.state.report.value === 1) {
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.state.submissionID === null ? "" : this.state.submissionID}&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.lastRevision}`
)
res = await res.blob()
this.setState({ loading: false })
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Master Budget Balance Sheet.xlsx';
a.click();
}
} else if (this.state.report.value === 2) {
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.state.submissionID}&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.lastRevision}`
let sub_null = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.state.report.value}&&company_id=${this.state.company.company_id}&&year=${this.state.periode.periode}&&revision=${this.state.lastRevision}`
// console.log(url);
let res = await fetch(
this.state.submissionID == null ? sub_null : url
)
res = await res.blob()
this.setState({ loading: false })
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Master Budget Profit & Loss.xlsx';
a.click();
}
}
}
render() {
const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
......@@ -385,8 +420,8 @@ export default class SubHolding extends Component {
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Sub Holding</Typography>
</div>
<div className="padding-20px" style={{ minWidth: 'max-content' }}>
<div style={{ marginTop: 20 }}>
<div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
<div style={{ marginTop: 15 }}>
<Autocomplete
options={this.state.reportType}
getOptionLabel={(option) => titleCase(option.label)}
......@@ -400,7 +435,7 @@ export default class SubHolding extends Component {
value={this.state.report}
/>
</div>
<div style={{ marginTop: 20 }}>
<div style={{ marginTop: 15 }}>
<Autocomplete
{...this.state.listCompany}
id="company"
......@@ -414,7 +449,7 @@ export default class SubHolding extends Component {
value={this.state.company}
/>
</div>
<div style={{ marginTop: 20 }}>
<div style={{ marginTop: 15 }}>
<Autocomplete
{...this.state.listPeriode}
id="periode"
......@@ -431,7 +466,33 @@ export default class SubHolding extends Component {
/>
</div>
</div>
<div style={{ marginTop: 20 }}>
<div>
<div style={{display: 'flex', justifyContent: 'space-between', padding: '0px 20px 10px 20px'}}>
<div></div>
{this.state.previewDownload && (
<div style={{ width: '50%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5,
outline: 'none'
}}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
}, 100);
})}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
</div>
)}
</div>
{this.state.loading && loadingComponent}
{this.state.previewTable && (
<TableSubHolding
......
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