Commit b3c244f5 authored by Hardiansyah's avatar Hardiansyah

budget tahunan

parent 25e3c70f
......@@ -91,14 +91,12 @@ export default class BudgetTahunan extends Component {
listApprover: null,
truelyApprover: false,
approver: null,
isAdmin: false,
selectReport: [],
isCheckAll: false,
downloadedFileReportId: null,
arrayReport: [],
popupDownload: false,
defaultCurrency: null,
dataCurrency: [],
currency: [],
visibleAlertSave: false,
dataCurrency: [
......@@ -110,7 +108,13 @@ export default class BudgetTahunan extends Component {
"id": 2,
"value": "USD",
}
]
],
dataTableCAT: [],
dataTableRevisionCAT: [],
dataForRevisionCAT: [],
rowDataFinance: [],
rowDataCAT: [],
}
this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this);
......@@ -265,12 +269,12 @@ export default class BudgetTahunan extends Component {
this.getRevision()
this.getCurrency(this.state.company.company_id)
} else {
this.setState({ listRevision: null, revision: null, dataTable: [], checkApprover: false, lastRevision: "", visibleTableHistory: false })
this.setState({ listRevision: null, revision: null, dataTable: [], dataTableCAT: [], checkApprover: false, lastRevision: "", visibleTableHistory: false })
}
//
})
} else {
this.setState({ listRevision: null, revision: null, dataTable: [], checkApprover: false, lastRevision: "", visibleTableHistory: false, loading: false }, () => {
this.setState({ listRevision: null, revision: null, dataTable: [], dataTableCAT: [], checkApprover: false, lastRevision: "", visibleTableHistory: false, loading: false }, () => {
document.body.style.overflow = 'unset';
})
}
......@@ -318,7 +322,8 @@ export default class BudgetTahunan extends Component {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
let dataTable = response.data.data.map((item, index) => {
const listData = response?.data?.data || []
let dataTable = listData.map((item, index) => {
let indexC = String(item.current_status).toLocaleUpperCase().indexOf('C')
let status_approv = ''
if (String(item.current_status).toLocaleUpperCase().includes('CC')) {
......@@ -348,20 +353,55 @@ export default class BudgetTahunan extends Component {
item.revision
]
})
// console.log(dataTable);
let dataTableRevision = []
response.data.data.map((item, index) => {
if (item.report_name !== 'Cash Flow') {
dataTableRevision.push([
const transformRevision = (rows = []) =>
rows
.filter(item => item.report_name !== 'Cash Flow')
.map(item => [
item.report_id,
item.report_name === 'CAT' ? 'Corporate Annual Target' : item.report_name,
"",
item.number
item.report_name === 'CAT'
? 'Corporate Annual Target'
: item.report_name,
'',
item.number,
])
}
})
// // // console.log(dataTableRevision);
this.setState({ loading: false, dataTable, dataTableRevision: dataTableRevision.sort((a, b) => a.number - b.number), dataForRevision: response.data.data }, () => {
const [rawCAT, resultDataTableFinance] = (dataTable ?? []).reduce(
(acc, item) => {
acc[item[1] === 'Corporate Annual Target' ? 0 : 1].push(item)
return acc
},
[[], []]
)
const [rowDataTableCAT, rowDataTableFinance] = (response?.data?.data ?? []).reduce(
(acc, item) => {
acc[item.report_name === 'CAT' ? 0 : 1].push(item)
return acc
},
[[], []]
)
const resultDataTableCAT = rawCAT.map((item, i) => [
i + 1,
...item.slice(1),
])
const rowDataFinance = listData.filter(
item => item.master_report_type_id === 1
);
const rowDataCAT = listData.filter(
item => item.master_report_type_id === 2
);
const dataTableRevisionCAT = transformRevision(rowDataTableCAT)
const dataTableRevision = transformRevision(rowDataTableFinance)
// console.log(dataTableRevision);
this.setState({
loading: false, dataTable: resultDataTableFinance, dataTableCAT: resultDataTableCAT,
rowDataFinance,
rowDataCAT,
dataTableRevision: dataTableRevision,
dataForRevision: rowDataTableFinance,
dataTableRevisionCAT: dataTableRevisionCAT,
dataForRevisionCAT: rowDataTableCAT,
}, () => {
document.body.style.overflow = 'unset';
})
}
......@@ -639,7 +679,8 @@ export default class BudgetTahunan extends Component {
submissionID: response.data.data.submission_id,
submitter: response.data.data.submitter,
approverID: response.data.data.approve_id, pic: response.data.data.approver == null ? '' : response.data.data.approver,
lastStatus: response.data.data.last_status === null ? 'SUBMIT' : response.data.data.last_status,
lastStatus: response.data.data.last_status_finance === null ? 'SUBMIT' : response.data.data.last_status_finance,
lastStatusCat: response.data.data.last_status_cat === null ? 'SUBMIT' : response.data.data.last_status_cat,
lastRevision: response.data.data.last_revision,
btnApprove: response.data.data.is_submit,
loading: false
......@@ -2192,7 +2233,7 @@ export default class BudgetTahunan extends Component {
}, 200);
}
clickDetail(item, id, revision, status) {
clickDetail(item, id, revision, status, tableKey) {
let items = ''
if (item === 'Corporate Annual Target') {
items = 'CAT'
......@@ -2218,7 +2259,8 @@ export default class BudgetTahunan extends Component {
this.setState({
report_id: id,
revisionTable: revision,
status: status
status: status,
tableKey
}, () => {
if (item === 'Balance Sheet') {
this.setState({
......@@ -2408,13 +2450,14 @@ export default class BudgetTahunan extends Component {
}
}
validate() {
validate(master_report_type_id) {
this.setState({ loading: true }, () => {
document.body.style.overflow = 'hidden';
})
let array = []
let canSubmit = true
this.state.dataTable.map(item => {
const listTable = master_report_type_id == 1 ? this.state.dataTable : this.state.dataTableCAT
listTable.map(item => {
// if (item[1] !== 'Cash Flow') {
if (item[3] !== "submitted" && item[3] !== 'approved') {
canSubmit = false
......@@ -2429,7 +2472,8 @@ export default class BudgetTahunan extends Component {
})
if (canSubmit === true) {
let body = {
submission_id: this.state.submissionID
submission_id: this.state.submissionID,
master_report_type_id
}
api.create().submitMasterBudget(body).then(response => {
// // // console.log(response);
......@@ -2683,12 +2727,352 @@ export default class BudgetTahunan extends Component {
})
}
getLastStatus = () => {
const { tableKey, lastStatus, lastStatusCat } = this.state
if (tableKey === 'CAT') {
return lastStatusCat
} else {
return lastStatus
}
}
renderFilter = () => {
return (
<div>
<div style={{ display: "flex" }}>
<div style={{ marginRight: 50 }}>
<Autocomplete
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
if (this.state.isApprover === true) {
this.getCompanySubmitted()
} else {
this.setState({ visibleTableHistory: false })
this.getRevision()
}
})}
disabled={this.state.intent === 'Home' ? true : false}
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }}
/>}
value={this.state.periode}
/>
</div>
<div style={{ width: 255 }}>
<Autocomplete
id="tipe"
disableClearable
options={this.state.currency}
getOptionLabel={(option) => option.value}
value={this.state.defaultCurrency}
// onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue })}
onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue }, () => {
this.getRevision()
})}
renderInput={(params) =>
<TextField
{...params}
variant="standard"
label="Currency"
margin="normal"
style={{ marginTop: 6 }}
// InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
// InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>
}
/>
{/* <Autocomplete
options={this.state.dataCurrency}
getOptionLabel={(option) => option.value}
onChange={(event, newInputValue) => this.setState({ currency: newInputValue })}
renderInput={(params) => (
<TextField
{...params}
variant="standard"
label="Currency"
margin="normal"
style={{ marginTop: 0 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>
)}
value={this.state.currency == null ? "IDR" : this.state.currency}
/> */}
</div>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listCompany}
id="company"
disabled={this.state.listCompany === null ? true : this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
this.getLastPeriod()
this.getCurrency(newInputValue.company_id)
this.getRevision()
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.company}
/>
</div>
<div style={{ marginTop: 20 }}>
{/* <Autocomplete
{...this.state.listRevision}
id="revision"
onChange={(event, newInputValue) => this.setState({ revision: newInputValue }, () => {
this.getReport()
this.getReportAttachment()
})}
disabled={true}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Revision" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.revision}
/> */}
<TextField disabled={true} label="Revision" margin="normal" style={{ marginTop: 7, width: 250 }} value={this.state.lastRevision} />
</div>
</div>
)
}
renderAttachment = () => {
return (
<>
<div style={{ display: 'flex', marginTop: 20 }}>
<div style={{ width: '50%' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
</div>
{!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
<div style={{ width: '50%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: this.state.isSubmit === false ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<Typography style={{ fontSize: '16px', color: this.state.isSubmit === false ? 'GrayText' : '#5198ea' }}>Upload File</Typography>
</button>
</div>
)}
</div>
<div style={{ display: 'flex', marginTop: 10 }}>
<div style={{ width: '50%', paddingLeft: 20 }}>
{this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item, index) => {
return (
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: '13px', color: '#4b4b4b', width: 25 }}>{index + 1}. </Typography>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
display: 'grid'
}}
onClick={() => {
this.downloadAttachment(item.attachment_url, item.attachment_name)
}}
>
<div>
<Typography style={{ fontSize: '13px', color: '#5198ea' }}> {item.attachment_name}</Typography>
</div>
</button>
</div>
)
})
: null
}
</div>
{!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
<div style={{ width: '50%' }}>
{
this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item) => {
return (
<button
style={{
backgroundColor: 'transparent',
cursor: this.state.isSubmit === false ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
display: 'grid'
}}
onClick={() => this.state.isSubmit === false ? null : this.deleteAttachment(item)}
>
<Typography style={{ fontSize: '13px', color: this.state.isSubmit === false ? 'GrayText' : '#ff3939' }}>Delete</Typography>
</button>
)
})
: null
}
</div>
)}
</div>
</>
)
}
renderBtnSubmit = (master_report_type_id) => {
return (
this.state.isAdmin && this.state.lastStatus == 'APPROVED' ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
</div>
</button>
{/* <button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button> */}
</div>
</div>
:
this.state.isAdmin && (this.state.lastStatus == 'WAITING FOR YOUR APPROVAL' || this.state.lastStatus == 'WAITING FOR APPROVAL') ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.handleApproveAdmin()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div>
:
this.state.checkApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() =>
this.approvalSubmission('review')
}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Review</Typography>
</div>
</button>
</div> : (this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' && this.state.btnApprove) ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
</div>
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div> : null
:
(this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && this.state.isSubmit === true ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.validate(master_report_type_id)}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
</div>
</button>
</div> :
this.state.lastStatus === 'SUBMITTED' && this.state.submitter ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('cancel')}
>
<div style={{ backgroundColor: 'gray', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div> : null
)
}
render() {
const handleMaxDate = () => {
let handleDate = Number(moment(this.state.maxDateRevision).format('YYYYMMDD')) - Number(moment(this.state.minDateRevision).format('YYYYMMDD'))
return handleDate < 0 ? moment(this.state.minDateRevision).format('YYYY/MM/DD') : moment(this.state.maxDateRevision).format('YYYY/MM/DD')
}
const columns = ["#", "Report Type",
const columns = (tableKey) => ["#", "Report Type",
{
name: "Revision",
options: {
......@@ -2765,7 +3149,7 @@ export default class BudgetTahunan extends Component {
}}
onClick={() =>
tableMeta.rowData[5] == true ?
this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3], tableKey)
: null
}
>
......@@ -2801,7 +3185,8 @@ export default class BudgetTahunan extends Component {
}, {
name: "",
options: { display: false }
}]
}
]
const columnsHistory = [
"Name", "Status", "Remarks", "Revision Item", "Date"
......@@ -2993,254 +3378,53 @@ export default class BudgetTahunan extends Component {
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget</Typography>
</div>
<div style={{ padding: 20 }}>
<div style={{ display: "flex" }}>
<div style={{ marginRight: 50 }}>
<Autocomplete
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
if (this.state.isApprover === true) {
this.getCompanySubmitted()
} else {
this.setState({ visibleTableHistory: false })
this.getRevision()
}
})}
disabled={this.state.intent === 'Home' ? true : false}
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }}
/>}
value={this.state.periode}
/>
</div>
<div style={{ width: 255 }}>
<Autocomplete
id="tipe"
disableClearable
options={this.state.currency}
getOptionLabel={(option) => option.value}
value={this.state.defaultCurrency}
// onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue })}
onChange={(event, newInputValue) => this.setState({ defaultCurrency: newInputValue }, () => {
this.getRevision()
})}
renderInput={(params) =>
<TextField
{...params}
variant="standard"
label="Currency"
margin="normal"
style={{ marginTop: 6 }}
// InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
// InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>
}
/>
{/* <Autocomplete
options={this.state.dataCurrency}
getOptionLabel={(option) => option.value}
onChange={(event, newInputValue) => this.setState({ currency: newInputValue })}
renderInput={(params) => (
<TextField
{...params}
variant="standard"
label="Currency"
margin="normal"
style={{ marginTop: 0 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>
)}
value={this.state.currency == null ? "IDR" : this.state.currency}
/> */}
</div>
</div>
{this.renderFilter()}
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listCompany}
id="company"
disabled={this.state.listCompany === null ? true : this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
this.getLastPeriod()
this.getCurrency(newInputValue.company_id)
this.getRevision()
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.company}
/>
</div>
<div style={{ marginTop: 20 }}>
{/* <Autocomplete
{...this.state.listRevision}
id="revision"
onChange={(event, newInputValue) => this.setState({ revision: newInputValue }, () => {
this.getReport()
this.getReportAttachment()
})}
disabled={true}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Revision" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.revision}
/> */}
<TextField disabled={true} label="Revision" margin="normal" style={{ marginTop: 7, width: 250 }} value={this.state.lastRevision} />
</div>
<div style={{ marginTop: 20 }}>
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '24px 5px' }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.handleSelectAll(this.state.dataTable)}
>
<div style={{ backgroundColor: '#fff', width: 100, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Check All</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.state.selectReport.length > 0 ? this.handleDownloadReport(this.state.dataTable) : alert("Anda harus memilih report yang ingin di download terlebih dahulu!")}
style={{
backgroundColor: 'transparent',
borderColor: 'transparent',
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 100, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Download</Typography>
</div>
</button>
</div>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTable}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
<div style={{ display: 'flex', marginTop: 20 }}>
<div style={{ width: '50%' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
</div>
{!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
<div style={{ width: '50%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Report Finance</Typography>
<div style={{ display: 'flex', margin: '24px 5px' }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.handleSelectAll(this.state.dataTable)}
>
<div style={{ backgroundColor: '#fff', width: 100, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Check All</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.state.selectReport.length > 0 ? this.handleDownloadReport(this.state.dataTable) : alert("Anda harus memilih report yang ingin di download terlebih dahulu!")}
style={{
backgroundColor: 'transparent',
cursor: this.state.isSubmit === false ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none'
outline: 'none',
}}
onClick={() => this.state.isSubmit === false ? null : this.setState({ visibleUpload: true })}
>
<Typography style={{ fontSize: '16px', color: this.state.isSubmit === false ? 'GrayText' : '#5198ea' }}>Upload File</Typography>
<div style={{ backgroundColor: '#354960', width: 100, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Download</Typography>
</div>
</button>
</div>
)}
</div>
<div style={{ display: 'flex', marginTop: 10 }}>
<div style={{ width: '50%', paddingLeft: 20 }}>
{this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item, index) => {
return (
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: '13px', color: '#4b4b4b', width: 25 }}>{index + 1}. </Typography>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
display: 'grid'
}}
onClick={() => {
this.downloadAttachment(item.attachment_url, item.attachment_name)
}}
>
<div>
<Typography style={{ fontSize: '13px', color: '#5198ea' }}> {item.attachment_name}</Typography>
</div>
</button>
</div>
)
})
: null
}
</div>
{!this.state.isApprover && (this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && (
<div style={{ width: '50%' }}>
{
this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item) => {
return (
<button
style={{
backgroundColor: 'transparent',
cursor: this.state.isSubmit === false ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
display: 'grid'
}}
onClick={() => this.state.isSubmit === false ? null : this.deleteAttachment(item)}
>
<Typography style={{ fontSize: '13px', color: this.state.isSubmit === false ? 'GrayText' : '#ff3939' }}>Delete</Typography>
</button>
)
})
: null
}
</div>
)}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTable}
columns={columns('FINANCE')}
options={options}
/>
</MuiThemeProvider>
</div>
{this.state.checkApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{this.state.lastStatus}</span>
</div> : this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{this.state.lastStatus}</span>
</div> : this.state.lastStatus === 'WAITING FOR APPROVAL' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{`${this.state.lastStatus} - ${this.state.pic}`}</span>
</div> : this.state.lastStatus === 'APPROVED' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{`${this.state.lastStatus}`}</span>
</div> : null
:
this.state.lastStatus === 'SUBMITTED' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{this.state.lastStatus}</span>
</div> :
this.state.lastStatus === 'WAITING FOR APPROVAL' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{`${this.state.lastStatus} - ${this.state.pic}`}</span>
</div> :
this.state.lastStatus === 'REVISION' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>NEED REVISION</span>
</div> :
this.state.lastStatus === 'APPROVED' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>APPROVED</span>
</div> : null
}
{this.renderAttachment()}
{this.state.visibleTableHistory && (
<div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}>
......@@ -3253,147 +3437,38 @@ export default class BudgetTahunan extends Component {
</div>
)}
</div>
{this.state.isAdmin && this.state.lastStatus == 'APPROVED' ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
{this.renderBtnSubmit(this.state?.rowDataFinance?.length > 0 && this.state.rowDataFinance[0]?.master_report_type_id)}
<div style={{ padding: '0 20px 20px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Report CAT</Typography>
<div style={{ display: 'flex', margin: '24px 5px' }}>
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.state.selectReport.length > 0 ? this.handleDownloadReport(this.state.dataTableCAT) : alert("Anda harus memilih report yang ingin di download terlebih dahulu!")}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
<div style={{ backgroundColor: '#354960', width: 100, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Download</Typography>
</div>
</button>
{/* <button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button> */}
</div>
</div>
:
this.state.isAdmin && (this.state.lastStatus == 'WAITING FOR YOUR APPROVAL' || this.state.lastStatus == 'WAITING FOR APPROVAL') ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.handleApproveAdmin()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div>
:
this.state.checkApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() =>
this.approvalSubmission('review')
}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Review</Typography>
</div>
</button>
</div> : (this.state.lastStatus === 'WAITING FOR YOUR APPROVAL' && this.state.btnApprove) ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
</div>
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button>
</div>
</div> : null
:
(this.state.lastStatus === 'SUBMIT' || this.state.lastStatus === 'REVISION') && this.state.isSubmit === true ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.validate()}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Submit</Typography>
</div>
</button>
</div> :
this.state.lastStatus === 'SUBMITTED' && this.state.submitter ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('cancel')}
>
<div style={{ backgroundColor: 'gray', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
</div> : null
}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTableCAT}
columns={columns('CAT')}
options={options}
/>
</MuiThemeProvider>
{this.renderAttachment()}
</div>
{this.renderBtnSubmit(this.state?.rowDataFinance?.length > 0 && this.state.rowDataFinance[0]?.master_report_type_id)}
</Paper>
</div>
</div>
)
......@@ -3453,7 +3528,7 @@ export default class BudgetTahunan extends Component {
getReport={this.getSubmission.bind(this)}
isApprover={this.state.isApprover}
truelyApprover={this.state.truelyApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
status={this.state.status}
/>
......@@ -3478,7 +3553,7 @@ export default class BudgetTahunan extends Component {
status={this.state.status}
isApprover={this.state.isApprover}
truelyApprover={this.state.truelyApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)
......@@ -3502,7 +3577,7 @@ export default class BudgetTahunan extends Component {
status={this.state.status}
isApprover={this.state.isApprover}
truelyApprover={this.state.truelyApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)
......@@ -3526,7 +3601,7 @@ export default class BudgetTahunan extends Component {
status={this.state.status}
isApprover={this.state.isApprover}
truelyApprover={this.state.truelyApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)
......@@ -3551,7 +3626,7 @@ export default class BudgetTahunan extends Component {
truelyApprover={this.state.truelyApprover}
status={this.state.status}
// status={'not-yet'}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
// lastStatus={'SUBMIT'}
// prevRevision={false}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
......@@ -3577,7 +3652,7 @@ export default class BudgetTahunan extends Component {
isApprover={this.state.isApprover}
truelyApprover={this.state.truelyApprover}
status={this.state.status}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
// PLBSFAMSubmitted={false}
PLBSFAMSubmitted={this.state.lastStatus == 'APPROVED' ? true : false}
......
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