Commit 5f57998a authored by Hardiansyah's avatar Hardiansyah

pemisahan report finance & CAT

parent 28a98f05
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -54,7 +54,6 @@ export default class OutlookPA extends Component {
visiblePL: false,
visibleCF: false,
visibleCAT: false,
listAttachment: [],
visibleUpload: false,
revisionTable: null,
alert: false,
......@@ -90,7 +89,6 @@ export default class OutlookPA extends Component {
arrayReport: [],
popupDownload: false,
defaultCurrency: null,
dataCurrency: [],
currency: [],
visibleAlertSave: false,
dataCurrency: [
......@@ -102,7 +100,27 @@ export default class OutlookPA extends Component {
"id": 2,
"value": "USD",
}
]
],
dataTableCAT: [],
dataTableRevisionCAT: [],
dataForRevisionCAT: [],
rowDataFinance: [],
rowDataCAT: [],
submitterCAT: null,
approverIDCAT: null,
picCAT: null,
btnApproveCAT: false,
lastStatusCat: null,
rowData: [],
dataTableHistoryCAT: [],
visibleTableHistoryCAT: false,
isApproverFinance: false,
isApproverCAT: false,
currentMasterReportTypeId: null,
listReportTypeId: [],
listAttachmentCAT: [],
listAttachment: [],
}
this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this);
......@@ -139,10 +157,10 @@ export default class OutlookPA extends Component {
api.create().checkApproverOLPA().then(response => {
if (response.data.status === 'success') {
if (response.data.data.is_approver === true) {
this.setState({ isApprover: true, checkApprover: true, listStatus: listStatus1, selectedStatus: listStatus1 }, () =>
this.setState({ isApprover: true, checkApprover: true, isApproverFinance: response.data.data.is_finance, isApproverCAT: response.data.data.is_cat, listStatus: listStatus1, selectedStatus: listStatus1 }, () =>
this.getPeriode())
} else {
this.setState({ isApprover: false, checkApprover: false, listStatus: listStatus2, selectedStatus: listStatus2 }, () =>
this.setState({ isApprover: false, checkApprover: false, isApproverFinance: false, isApproverCAT: false, listStatus: listStatus2, selectedStatus: listStatus2 }, () =>
this.getPeriode())
}
} else {
......@@ -261,12 +279,12 @@ export default class OutlookPA extends Component {
this.getRevision()
this.getCurrency(this.state.company.company_id)
} 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, visibleTableHistoryCAT: false, loading: false })
}
//
})
} else {
this.setState({ listRevision: null, revision: null, listCompany: null, company: null, dataTable: [], lastRevision: "", visibleTableHistory: false, loading: false }, () => {
this.setState({ listRevision: null, revision: null, listCompany: null, company: null, dataTable: [], dataTableCAT: [], lastRevision: "", visibleTableHistory: false, visibleTableHistoryCAT: false, loading: false }, () => {
document.body.style.overflow = 'unset';
})
}
......@@ -287,28 +305,31 @@ export default class OutlookPA extends Component {
}
getReportAttachment() {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"revision": this.state.revision.revision,
}
api.create().getOLPAAtt(payload).then(response => {
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({ listAttachment: response.data.data })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
this.state.listReportTypeId.forEach((master_report_type_id) => {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"revision": this.state.revision.revision,
master_report_type_id
}
// console.log(response);
api.create().getOLPAAtt(payload).then(response => {
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({ listAttachment: response.data.data })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
// console.log(response);
})
})
}
......@@ -323,7 +344,8 @@ export default class OutlookPA 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) => {
return [
item.number,
item.report_name,
......@@ -338,19 +360,56 @@ export default class OutlookPA extends Component {
// dataTable.push([
// 5, "Corporate Annual Target", 0, "not-yet", 39, false, 0
// ])
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,
])
}
})
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(dataTable);
this.setState({ dataTable, loading: false, dataTableRevision: dataTableRevision.sort((a, b) => a.number - b.number), dataForRevision: response.data.data })
this.setState({
loading: false, dataTable: resultDataTableFinance, dataTableCAT: resultDataTableCAT,
rowDataFinance,
rowDataCAT,
rowData: listData,
dataTableRevision: dataTableRevision,
dataForRevision: rowDataTableFinance,
dataTableRevisionCAT: dataTableRevisionCAT,
dataForRevisionCAT: rowDataTableCAT,
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
......@@ -579,23 +638,33 @@ export default class OutlookPA extends Component {
}
getOutlookPAID(type) {
const _lastStatus = this.getLastStatus()
this.setState({ loading: true })
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"is_approver": this.state.isAdmin && this.state.lastStatus == 'WAITING FOR APPROVAL' ? false : this.state.isApprover
"is_approver": this.state.isAdmin && _lastStatus === 'WAITING FOR APPROVAL' ? false : this.state.isApprover
}
api.create().getOutlookPAID(payload).then(response => {
console.log(response)
if (response) {
if (response.data.status === "success") {
const uniqueTypeIds =
this.state.rowData?.length
? [...new Set(this.state.rowData.map(item => item.master_report_type_id))]
: [1, 2];
this.setState({
outlook_pa_id: response.data.data.outlook_pa_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,
submitter: response.data.data.submitter_finance,
submitterCAT: response.data.data.submitter_cat,
approverID: response.data.data.finance_approve_id,
approverIDCAT: response.data.data.cat_approve_id,
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
btnApprove: response.data.data.is_submit_finance,
btnApproveCAT: response.data.data.is_submit_cat,
listReportTypeId: uniqueTypeIds
}, () => {
// console.log(this.state.lastStatus);
if (this.state.isAdmin) {
......@@ -638,9 +707,9 @@ export default class OutlookPA extends Component {
api.create().checkApproverOLPA().then(response => {
// console.log(response);
if (response.data.data.is_approver === true) {
this.setState({ isApprover: true, checkApprover: true })
this.setState({ checkApprover: true, isApproverFinance: response.data.data.is_finance, isApproverCAT: response.data.data.is_cat, })
} else {
this.setState({ isApprover: false, checkApprover: false })
this.setState({ isApprover: false, checkApprover: false, isApproverFinance: false, isApproverCAT: false, })
}
})
......@@ -662,38 +731,41 @@ export default class OutlookPA extends Component {
}
historyApproval() {
let body = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode
}
api.create().historyApprovalOLPA(body).then(response => {
// console.log(response);
if (response.data.data.length > 0) {
let dataTableHistory = response.data.data.map(item => {
return [
item.pic,
item.status_approval,
// String(item.status_approval).replace('APPROVAL_PROCCESS', 'WAITING FOR APPROVAL').replace('- -', ''),
item.remarks,
item.item_revision,
item.history_approval_date
]
})
this.setState({ dataTableHistory, visibleTableHistory: true })
this.state.listReportTypeId.forEach((master_report_type_id) => {
let body = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
master_report_type_id
}
api.create().historyApprovalOLPA(body).then(response => {
// console.log(response);
if (response.data.data.length > 0) {
let dataTableHistory = response.data.data.map(item => {
return [
item.pic,
item.status_approval,
// String(item.status_approval).replace('APPROVAL_PROCCESS', 'WAITING FOR APPROVAL').replace('- -', ''),
item.remarks,
item.item_revision,
item.history_approval_date
]
})
this.setState({ dataTableHistory, visibleTableHistory: true })
}
})
})
}
async setHeaderTokenSuperadmin(type) {
async setHeaderTokenSuperadmin(type, master_report_type_id) {
let realToken = await localStorage.getItem(Constant.TOKEN)
api.create().getIdToken(this.state.approver.userId).then((response) => {
console.log(response.data.data.token)
localStorage.setItem(Constant.TOKEN, response.data.data.token)
this.approvalSubmission(type, realToken)
this.approvalSubmission(type, master_report_type_id, realToken)
})
}
approvalSubmission(type, realToken) {
approvalSubmission(type, master_report_type_id, realToken) {
this.scrollToMyRef()
// if (this.state.isAdmin && type == 'approve') {
// api.create().getIdToken(this.state.approver.userId).then((response) => {
......@@ -704,11 +776,12 @@ export default class OutlookPA extends Component {
// }
this.setState({ loading: true })
let body = {
"approval_id": this.props.location.state == undefined ? this.state.approverID : this.state.rawData.approval_id,
"approval_id": !this.props.location.state ? master_report_type_id === 2 ? this.state.approverIDCAT : this.state.approverID : this.state.rawData.approval_id,
"status": type,
"detail": this.state.detailRevisiCheck,
"is_superadmin": this.state.isAdmin,
"currency_id": this.state.defaultCurrency.id,
master_report_type_id
}
let payload = {
"company_id": this.state.company.company_id,
......@@ -734,7 +807,7 @@ export default class OutlookPA extends Component {
// })
if (this.state.isAdmin && type == 'approve') {
localStorage.setItem(Constant.TOKEN, realToken)
this.setState({ visibleApproveSuperadmin: false })
this.setState({ visibleApproveSuperadmin: false, currentMasterReportTypeId: null })
}
setTimeout(() => {
if (type == 'revision') {
......@@ -746,8 +819,9 @@ export default class OutlookPA extends Component {
}, 100);
}
clickDetail(item, id, revision, status) {
this.state.dataForRevision.map(i => {
clickDetail(item, id, revision, status, tableKey) {
const listTable = tableKey === 'CAT' ? this.state.dataForRevisionCAT : this.state.dataForRevision
listTable.map(i => {
if (i.report_name === item) {
if (i.revision == revision) {
this.setState({ prevRevision: true })
......@@ -759,7 +833,8 @@ export default class OutlookPA extends Component {
this.setState({
report_id: id,
revisionTable: revision,
status: status
status: status,
tableKey
}, () => {
if (item === 'Balance Sheet') {
this.setState({
......@@ -811,7 +886,7 @@ export default class OutlookPA extends Component {
})
}
validateRevision() {
validateRevision(master_report_type_id) {
let arrayRevisi = this.state.detailRevisiCheck
let remarksKosong = 0
arrayRevisi.map((item, index) => {
......@@ -822,7 +897,7 @@ export default class OutlookPA extends Component {
if (remarksKosong > 0) {
this.setState({ alert: true, messageAlert: 'Remarks Cannot be Empty', tipeAlert: 'error' })
} else {
this.setState({ visibleRevision: false }, () => this.approvalSubmission('revision'))
this.setState({ visibleRevision: false }, () => this.approvalSubmission('revision', master_report_type_id))
}
}
......@@ -843,6 +918,7 @@ export default class OutlookPA extends Component {
formData.append("revision", Number(this.state.revision.revision));
formData.append("companyId", this.state.company.company_id);
formData.append("periode", Number(this.state.periode.periode));
formData.append("master_report_type_id", this.state.currentMasterReportTypeId);
formData.append("file", event);
this.setState({ formData })
}
......@@ -961,11 +1037,12 @@ export default class OutlookPA extends Component {
}
}
validate() {
validate(master_report_type_id) {
this.setState({ loading: true })
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[3] !== "submitted" && item[3] !== 'approved') {
canSubmit = false
array.push(item[3])
......@@ -984,7 +1061,8 @@ export default class OutlookPA extends Component {
})
if (canSubmit === true) {
let body = {
outlook_pa_id: this.state.outlook_pa_id
outlook_pa_id: this.state.outlook_pa_id,
master_report_type_id
}
api.create().submitOLPA(body).then(response => {
// console.log(response);
......@@ -1498,8 +1576,8 @@ export default class OutlookPA extends Component {
})
}
handleApproveAdmin() {
this.setState({ visibleApproveSuperadmin: true })
handleApproveAdmin(master_report_type_id) {
this.setState({ visibleApproveSuperadmin: true, currentMasterReportTypeId: master_report_type_id })
}
handleSelectAll(data) {
......@@ -1546,7 +1624,7 @@ export default class OutlookPA extends Component {
"month": "",
"quartal": "",
"type_report_name": "Outlook PA",
"currency_id" : defaultCurrency.id
"currency_id": defaultCurrency.id
}
console.log(payload);
api.create().createDownloadFile(payload).then((response) => {
......@@ -1662,12 +1740,405 @@ export default class OutlookPA extends Component {
})
}
getLastStatus = () => {
const { tableKey, lastStatus, lastStatusCat } = this.state
return tableKey === 'CAT' ? lastStatusCat : lastStatus
}
getSubmissionObj = (tableKeyParam) => {
const {
tableKey,
btnApprove,
btnApproveCAT,
lastStatus,
lastStatusCat,
submitter,
submitterCAT,
pic,
picCAT,
listAttachment,
listAttachmentCAT
} = this.state;
const key = tableKeyParam ?? tableKey;
return key === 2
? { btnApprove: btnApproveCAT, lastStatus: lastStatusCat, submitter: submitterCAT, pic: picCAT, listAttachment: listAttachmentCAT }
: { btnApprove, lastStatus, submitter, pic, listAttachment };
};
renderFilter = () => {
return (
<div >
<div style={{ display: "flex" }}>
<Autocomplete
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
if (this.state.listCompany == null) {
console.log('yak')
this.getCompanySubmitted()
} else {
console.log('zz')
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}
/>
<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()
})}
style={{ width: 250 }}
renderInput={(params) =>
<TextField
{...params}
variant="standard"
label="Currency"
margin="normal"
style={{ marginTop: 7, marginLeft: 20 }}
// InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
// InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>
}
/>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
multiple
id="tags-standard"
options={this.state.listStatus}
getOptionLabel={(option) => option.name}
style={{ width: 250 }}
onChange={(event, newInputValue) => {
this.setState({ selectedStatus: newInputValue, loading: true }, () => {
console.log(newInputValue);
this.getCompanySubmitted()
})
}}
value={this.state.selectedStatus}
renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />}
/>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listCompany}
id="company"
disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
this.getRevision()
this.getCurrency(newInputValue.company_id)
})}
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 = (master_report_type_id) => {
const _lastStatus = this.getLastStatus()
const obj = this.getSubmissionObj(master_report_type_id)
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 && (_lastStatus === 'SUBMIT' || _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, currentMasterReportTypeId: master_report_type_id })}
>
<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 }}>
{obj.listAttachment.length > 0 ?
obj.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 && (_lastStatus === 'SUBMIT' || _lastStatus === 'REVISION') && (
<div style={{ width: '50%' }}>
{
obj.listAttachment.length > 0 ?
obj.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>
</>
)
}
renderHistoryInfo = (master_report_type_id) => {
const obj = this.getSubmissionObj(master_report_type_id)
return this.state.checkApprover === true ?
obj.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{obj.lastStatus}</span>
</div> : obj.lastStatus === 'WAITING FOR YOUR APPROVAL' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{obj.lastStatus}</span>
</div> : obj.lastStatus === 'WAITING FOR APPROVAL' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{`${obj.lastStatus} - ${obj.pic}`}</span>
</div> : obj.lastStatus === 'APPROVED' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{`${obj.lastStatus}`}</span>
</div> : null
:
obj.lastStatus === 'SUBMITTED' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{obj.lastStatus}</span>
</div> :
obj.lastStatus === 'WAITING FOR APPROVAL' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>{`${obj.lastStatus} - ${obj.pic}`}</span>
</div> :
obj.lastStatus === 'REVISION' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>NEED REVISION</span>
</div> :
obj.lastStatus === 'APPROVED' ?
<div style={{ width: '100%', padding: '10px 20px', backgroundColor: 'yellow', textAlign: 'center', marginTop: 20 }}>
<span>APPROVED</span>
</div> : null
}
renderBtnSubmit = (master_report_type_id) => {
const obj = this.getSubmissionObj(master_report_type_id)
return this.state.isAdmin && obj.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, currentMasterReportTypeId: master_report_type_id })}
>
<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 && (obj.lastStatus === 'WAITING FOR YOUR APPROVAL' || obj.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(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' }}>Approve</Typography>
</div>
</button>
</div>
</div>
:
this.state.checkApprover === true ?
obj.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', 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' }}>Review</Typography>
</div>
</button>
</div> : (obj.lastStatus === 'WAITING FOR YOUR APPROVAL' && obj.btnApprove) ?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.setState({ visibleRevision: true, currentMasterReportTypeId: master_report_type_id })}
>
<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>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve', 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' }}>Approve</Typography>
</div>
</button>
</div>
</div> : null
:
(obj.lastStatus === 'SUBMIT' || obj.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> :
obj.lastStatus === 'SUBMITTED' && obj.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', master_report_type_id)}
>
<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: {
......@@ -1746,7 +2217,7 @@ export default class OutlookPA extends Component {
}}
onClick={() =>
tableMeta.rowData[5] == true || (this.state.periode.periode == '2020' && tableMeta.rowData[1] == 'Balance Sheet' && tableMeta.rowData[3] == 'CLOSED') ?
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
}
>
......@@ -1788,7 +2259,7 @@ export default class OutlookPA extends Component {
"Name", "Status", "Remarks", "Revision Item", "Date"
]
const columnRevisi = [
const columnRevisi = (master_report_type_id) => [
{
name: "#",
options: {
......@@ -1805,7 +2276,7 @@ export default class OutlookPA extends Component {
control={
<Checkbox
checked={this.state.detailRevisiCheck.findIndex((val) => val.report_id == tableMeta.rowData[0]) == -1 ? false : true}
onClick={() => handleCheckRevision(tableMeta.rowData)} />
onClick={() => handleCheckRevision(tableMeta.rowData, master_report_type_id)} />
}
/>
</div >
......@@ -1833,7 +2304,7 @@ export default class OutlookPA extends Component {
onBlur={(event) => {
// console.log(event.target.value)
// updateValue(event.target.value)
handleChangeText(event.target.value, tableMeta)
handleChangeText(event.target.value, tableMeta, master_report_type_id)
// console.log(dataTable2)
}}
/>}
......@@ -1848,9 +2319,9 @@ export default class OutlookPA extends Component {
}
]
const handleChangeText = (value, tableMeta) => {
let dataTableRevision = this.state.dataTableRevision
dataTableRevision[tableMeta.rowIndex][tableMeta.columnIndex] = value
const handleChangeText = (value, tableMeta, master_report_type_id) => {
const listTableRevision = master_report_type_id === 2 ? this.state.dataTableRevisionCAT : this.state.dataTableRevision
listTableRevision[tableMeta.rowIndex][tableMeta.columnIndex] = value
let detailRevisiCheck = this.state.detailRevisiCheck
let indexId = detailRevisiCheck.findIndex((val) => val.report_id == tableMeta.rowData[0])
......@@ -1858,7 +2329,7 @@ export default class OutlookPA extends Component {
detailRevisiCheck[indexId].remarks = value
}
this.setState({ dataTableRevision, detailRevisiCheck })
this.setState({ [master_report_type_id === 2 ? "dataTableRevisionCAT" : "dataTableRevision"]: listTableRevision, detailRevisiCheck })
}
// const handleCheckRevision = (value) => {
......@@ -1878,18 +2349,19 @@ export default class OutlookPA extends Component {
// // console.log(detailRevisiCheck)
// }
const handleCheckRevision = (value) => {
const handleCheckRevision = (value, master_report_type_id) => {
const listTableRevision = master_report_type_id === 2 ? this.state.dataTableRevisionCAT : this.state.dataTableRevision
let detailRevisiCheck = this.state.detailRevisiCheck
let payload = {
report_id: value[0],
remarks: value[2],
number: value[3]
}
let indexDataRevisi = this.state.dataTableRevision.findIndex((val) => val[3] == value[3])
let indexDataRevisi = listTableRevision.findIndex((val) => val[3] == value[3])
let indexId = detailRevisiCheck.sort((a, b) => a.number - b.number).findIndex((val) => val.number == value[3])
// // console.log(indexId)
if (indexId == -1) {
this.state.dataTableRevision.map((item, index) => {
listTableRevision.map((item, index) => {
if (index > indexDataRevisi) {
let indexIds = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIds == -1) {
......@@ -1912,7 +2384,7 @@ export default class OutlookPA extends Component {
}
})
if (x < 1) {
this.state.dataTableRevision.map((item, index) => {
listTableRevision.map((item, index) => {
if (index > indexDataRevisi) {
let indexIdz = detailRevisiCheck.findIndex((val) => val.number == item[3])
if (indexIdz !== -1) {
......@@ -1971,6 +2443,8 @@ export default class OutlookPA extends Component {
/>
</div>
);
const mstIdFinance = this.state?.rowDataFinance?.length > 0 && this.state.rowDataFinance[0]?.master_report_type_id
const mstIdCAT = this.state?.rowDataCAT?.length > 0 && this.state.rowDataCAT[0]?.master_report_type_id
return (
<div style={{ flex: 1, backgroundColor: '#f8f8f8' }} ref={this.myRef}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
......@@ -1990,251 +2464,54 @@ export default class OutlookPA extends Component {
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Outlook Performance Appraisal</Typography>
</div>
<div style={{ padding: 20 }}>
<div style={{ display: "flex" }}>
<Autocomplete
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
if (this.state.listCompany == null) {
console.log('yak')
this.getCompanySubmitted()
} else {
console.log('zz')
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}
/>
<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()
})}
style={{ width: 250 }}
renderInput={(params) =>
<TextField
{...params}
variant="standard"
label="Currency"
margin="normal"
style={{ marginTop: 7, marginLeft: 20 }}
// InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
// InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>
}
{this.renderFilter()}
/>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
multiple
id="tags-standard"
options={this.state.listStatus}
getOptionLabel={(option) => option.name}
style={{ width: 250 }}
onChange={(event, newInputValue) => {
this.setState({ selectedStatus: newInputValue, loading: true }, () => {
console.log(newInputValue);
this.getCompanySubmitted()
})
}}
value={this.state.selectedStatus}
renderInput={(params) => <TextField {...params} label="Submission Status" margin="normal" style={{ marginTop: 7 }} />}
/>
</div>
<div style={{ marginTop: 20 }}>
<Autocomplete
{...this.state.listCompany}
id="company"
disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.setState({ visibleTableHistory: false })
this.getRevision()
this.getCurrency(newInputValue.company_id)
})}
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: '20px 15px' }}>
<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: '20px 15px' }}>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: this.state.isSubmit === false ? 'default' : 'pointer',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
outline: 'none',
marginRight: 20
}}
onClick={() => this.state.isSubmit === false ? null : this.setState({ visibleUpload: true })}
onClick={() => this.handleSelectAll(this.state.dataTable)}
>
<Typography style={{ fontSize: '16px', color: this.state.isSubmit === false ? 'GrayText' : '#5198ea' }}>Upload File</Typography>
<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>
)}
</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(mstIdFinance)}
{this.renderHistoryInfo(mstIdFinance)}
{this.state.visibleTableHistory && (
<div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}>
......@@ -2247,147 +2524,50 @@ export default class OutlookPA 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.state.checkApprover && this.state.isApproverFinance) || this.state.submitter) && this.renderBtnSubmit(mstIdFinance)}
<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>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTableCAT}
columns={columns('CAT')}
options={options}
/>
</MuiThemeProvider>
{this.renderAttachment(mstIdCAT)}
{this.renderHistoryInfo(mstIdCAT)}
{this.state.visibleTableHistoryCAT && (
<div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTableHistoryCAT}
columns={columnsHistory}
options={optionsHistory}
/>
</MuiThemeProvider>
</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">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
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>
</div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<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
}
)}
</div>
{((this.state.checkApprover && this.state.isApproverCAT) || this.state.submitterCAT) && this.renderBtnSubmit(mstIdCAT)}
</Paper>
</div>
</div>
)}
......@@ -2405,7 +2585,7 @@ export default class OutlookPA extends Component {
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
onClick={() => this.setState({ visibleUpload: false, currentMasterReportTypeId: null })}
>
<img src={Images.close} />
</button>
......@@ -2442,7 +2622,7 @@ export default class OutlookPA extends Component {
onClickClose={() => this.setState({ visibleBS: false, visibleOutlookPA: true })}
getReport={this.getOutlookPAID.bind(this)}
isApprover={this.state.isApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
status={this.state.status}
/>
......@@ -2464,7 +2644,7 @@ export default class OutlookPA extends Component {
getReport={this.getOutlookPAID.bind(this)}
status={this.state.status}
isApprover={this.state.isApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
......@@ -2486,7 +2666,7 @@ export default class OutlookPA extends Component {
getReport={this.getOutlookPAID.bind(this)}
status={this.state.status}
isApprover={this.state.isApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)}
......@@ -2507,9 +2687,9 @@ export default class OutlookPA extends Component {
getReport={this.getOutlookPAID.bind(this)}
status={this.state.status}
isApprover={this.state.isApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
PLBSFAMSubmitted={this.state.lastStatus == 'APPROVED' ? true : false}
PLBSFAMSubmitted={this.getLastStatus() === 'APPROVED' ? true : false}
/>
)}
{this.state.visibleCAT && (
......@@ -2528,7 +2708,7 @@ export default class OutlookPA extends Component {
onClickClose={() => this.setState({ visibleCAT: false, visibleOutlookPA: true })}
getReport={this.getOutlookPAID.bind(this)}
isApprover={this.state.isApprover}
lastStatus={this.state.lastStatus}
lastStatus={this.getLastStatus()}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
status={this.state.status}
/>
......@@ -2547,7 +2727,7 @@ export default class OutlookPA extends Component {
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleRevision: false })}
onClick={() => this.setState({ visibleRevision: false, currentMasterReportTypeId: null })}
>
<img src={Images.close} />
</button>
......@@ -2558,7 +2738,7 @@ export default class OutlookPA extends Component {
<div style={{ marginTop: 20 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTableRevision}
data={this.state.currentMasterReportTypeId === 2 ? this.state.dataTableRevisionCAT : this.state.dataTableRevision}
columns={columnRevisi}
options={optionsRevision}
/>
......@@ -2630,7 +2810,7 @@ export default class OutlookPA extends Component {
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.setState({ visibleRevision: false })}
onClick={() => this.setState({ visibleRevision: false, currentMasterReportTypeId: null })}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
......@@ -2640,7 +2820,7 @@ export default class OutlookPA extends Component {
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.validateRevision()}
onClick={() => this.validateRevision(this.state.currentMasterReportTypeId)}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Revision</span>
......@@ -2665,7 +2845,7 @@ export default class OutlookPA extends Component {
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
onClick={() => this.setState({ visibleApproveSuperadmin: false, currentMasterReportTypeId: null })}
>
<img src={Images.close} />
</button>
......@@ -2692,7 +2872,7 @@ export default class OutlookPA extends Component {
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.setState({ visibleApproveSuperadmin: false })}
onClick={() => this.setState({ visibleApproveSuperadmin: false, currentMasterReportTypeId: null })}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
......@@ -2702,7 +2882,7 @@ export default class OutlookPA extends Component {
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.state.approver == null ? this.setState({ alert: true, messageAlert: 'Approver Cannot be Empty', tipeAlert: 'error' }) : this.setHeaderTokenSuperadmin('approve')}
onClick={() => this.state.approver == null ? this.setState({ alert: true, messageAlert: 'Approver Cannot be Empty', tipeAlert: 'error' }) : this.setHeaderTokenSuperadmin('approve', this.state.currentMasterReportTypeId)}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Confirm Approve</span>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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