Commit 77e9d6ff authored by Riri Novita's avatar Riri Novita

Merge branch 'ENV-STAGING' of http://103.44.149.204/d.arizona/tia-dev into ENV-PROD

parents 2f766a03 6b62ed99
......@@ -492,6 +492,11 @@ const create = (type = "") => {
const getDetailDocument = (id) => api.get(`document/get_document_by_id/${id}`)
const deleteDocument = (id) => api.post(`document/delete_document/${id}`)
const uploadCarfmDocument = (body) => api.post('document/upload_cafrm_document', body)
const getChcmDocumentBySubmenu = (body) => api.post('document/get_chcm_document_by_submenu', body);
const uploadChcmDocument = (body) => api.post('document/upload_chcm_document', body)
const deleteReportChcm = (id) => api.post(`document/delete_chcm_document/${id}`)
const getDetailReportChcm = (id) => api.get(`document/get_chcm_document_by_id/${id}`)
const updateReportChcm = (body) => api.post('document/update_chcm_document', body)
// Monitoring
......@@ -673,6 +678,11 @@ const create = (type = "") => {
getAllDocument,
uploadDocument,
uploadCarfmDocument,
getChcmDocumentBySubmenu,
uploadChcmDocument,
deleteReportChcm,
getDetailReportChcm,
updateReportChcm,
updateDocument,
downloadDocument,
getPerusahaanUserActive,
......
......@@ -2,6 +2,11 @@
background-color: #273b80 !important;
}
/* for staging */
/* .main-color{
background-color: #0b6b24 !important;
} */
.sub-color{
background-color: #f0f1f3 !important;
}
......@@ -553,7 +553,8 @@ export default class BudgetTahunan extends Component {
getOptionLabel: (option) => option.periode,
};
// ubah code dibawah ini jika mau mengubah default periode jadi tahun saat ini
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod)
// let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod)
let periode = String(Number(currentYear))
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// // console.log(this.props.location.state.rawData)
// console.log(this.state.lastPeriod)
......@@ -3832,4 +3833,4 @@ export default class BudgetTahunan extends Component {
</div >
);
}
}
}
\ No newline at end of file
......@@ -799,6 +799,12 @@ export default class CorporateAnnualTarget extends Component {
// console.log(i[7])
let b = []
// console.log(i[13].value == undefined? 'Y' : 'N')
if (String(i[6]) == "Revenue"){
console.log(Number(i[30]))
console.log(String(Number(i[30][2]?.value)/1000))
}
data.push({
"item_report_id": i[1] == "" || i[1] == null ? 0 : i[1],
"item_name": String(i[6]),
......@@ -1644,6 +1650,7 @@ export default class CorporateAnnualTarget extends Component {
return (valz == 'SUM' ? total : (valz == 'AVG' ? (total / 12) : lastValz))
// }
}
// console.log(dataTable2)
const columns = [{
name: "",
......
......@@ -149,7 +149,7 @@ export default class CafrmDocument extends Component {
let compActive = []
let userCompActive = []
this.state.userCompany.map((item, index) => {
if (index !== -1 && String(data[index].status).toLocaleLowerCase() == 'active'){
if (index !== -1 && String(data[index]?.status).toLocaleLowerCase() == 'active'){
userCompActive.push(item)
}
})
......
import React, { Component } from 'react'
import { withStyles } from '@material-ui/core/styles';
import { Paper, Snackbar, Typography } from '@material-ui/core';
import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../library/Constant';
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
import api from '../../api';
import PropagateLoader from "react-spinners/PropagateLoader"
import TableChcmDocument from "./TableChcmDocument";
import CreateChcmDoc from "./CreateChcmDocument";
const Alert = withStyles({})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class ChcmDocument extends Component {
constructor(props) {
super(props);
this.state = {
alert: false,
listData: [],
id: 0,
load: false,
name: '',
userCompActive: [],
submenu_id : 0,
submenu_name: "",
menu_title: "",
loading: false
}
}
componentDidMount() {
this.getMenuName();
}
getMenuName(){
api.create().getMenuByUser().then(
response => {
if(response.data){
if(response.data.status === 'success'){
response.data.data.map(
(item) => {
let arr = window.location.href.split('/');
if (item.class_id == arr.slice(-1)[0]){
this.setState({
submenu_id : item.menu_id,
submenu_name : item.menu_name.toLowerCase(),
menu_title : item.menu_name.replace(/\b\w/g, c => c.toUpperCase())
}, () => {
this.getPermission(this.state.submenu_name)
// this.getDataCarfm();
this.getDetailUser();
})
}
}
)
}
}
}
)
}
// getDataCarfm(create){
// let payload = {
// submenu_id : this.state.submenu_id
// }
// api.create().getCarfmDocumentBySubmenu(payload).then(
// response => {
// if(response){
// if(response.data.status === 'success'){
// let dataList = []
// response.data.data.map((item, index) => {
// dataList.push(item)
// })
// this.setState({
// listData: dataList,
// refresh: create == undefined ? '' : create,
// loading: false
// })
// } 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);
// }
// })
// }
// }else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
// }
// }
// )
// }
getPermission(subMenu) {
let payload = {
menu: subMenu
}
api.create().getPermission(payload).then(response => {
console.log(response);
if (response.data) {
console.log(`status get permission ${response.data.status}`);
if (response.data.status === "success") {
this.setState({
btncreate: response.data.data.create,
btnview: response.data.data.view,
btndownload: response.data.data.download,
btnedit: response.data.data.edit,
btndelete: response.data.data.delete,
load: true,
})
console.log("btn create " + this.state.btncreate);
} else {
this.setState({
load: true
})
}
} else {
this.setState({ load: true })
}
})
}
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company, visibleTrue: false }, () => {
this.getCompanyActive()
// console.log(this.state.userCompany);
})
}
}
}
})
}
getCompanyActive() {
api.create().getPerusahaanActive().then((response) => {
console.log("getcompanyactive start");
// console.log(response.data.data);
console.log("getcompanyactive stop");
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let compActive = []
let userCompActive = []
this.state.userCompany.map((item, index) => {
if (index !== -1 && String(data[index]?.status).toLocaleLowerCase() == 'active'){
userCompActive.push(item)
}
})
data.map(( item, index ) => {
if (String(item.status).toLocaleLowerCase() == 'active') {
compActive.push(item)
}
})
if (compActive.length == userCompActive.length){
this.setState({ btnadd: true})
} else {
this.setState({ btnadd: false})
}
this.setState({ userCompActive, visibleTrue: true })
console.log("usercompactive")
// console.log(userCompActive)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', visibleTrue: true }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
console.log("error di getcompany active")
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null, visibleTrue: true })
}
})
}
createDocument(payload) { //upload apinya disini
this.setState({ loading: true, visibleTrue: false })
api.create().uploadChcmDocument(payload).then(response => {
// console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.message === "Data was Saved Successfully") {
this.setState({ visibleCreate: false, visibleTrue: true, loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success'}, () => {
// window.location.reload();
})
// this.getDataCarfm('create')
}
else {
this.setState({ visibleCreate: false, visibleTrue: true, 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);
}
})
}
} else {
this.setState({ visibleCreate: false, visibleTrue: true, alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ visibleCreate: false, visibleTrue: true, alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
closeAlert() {
this.setState({alert: false})
}
handleLoading(tipe) {
this.setState({loading: tipe == 0 ? false : true})
}
render() {
const loadingComponent = (
<div style={{
position: 'absolute',
zIndex: 1500,
top: 0,
left: 0,
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
background: 'rgba(255,255,255,0.8)'
}}>
<PropagateLoader
// css={override}
size={20}
color={"#274B80"}
loading={this.state.loading}
/>
</div>
);
return (
<div style={{height: this.props.height, backgroundColor: '#f8f8f8'}}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>{this.state.menu_title}</Typography>
</div>
<div style={{padding: 20}}>
{this.state.loading && loadingComponent}
{this.state.btnview && (
<Paper style={{padding: 20}}>
<div style={{display: 'flex', justifyContent: 'flex-end'}}>
{/* {console.log("renderbtn" + this.state.btncreate)} */}
{(this.state.btncreate) && (
<span>
<a data-tip={'Add'} data-for="add">
<div style={{display: 'grid', justifyContent: 'flex-end'}}>
<button
type="button"
onClick={() => this.setState({visibleCreate: true, refresh: ''})}
style={{marginRight: 25, background: 'transparent'}}
>
<img src={Images.add}/>
</button>
</div>
</a>
<ReactTooltip border={true} id="add" place="bottom" type="light" effect="solid"/>
</span>
)}
</div>
<div style={{display: 'flex'}}>
{this.state.visibleTrue && (
<TableChcmDocument
data={this.state.listData}
refresh={this.state.refresh}
load={this.state.load}
userCompActive={this.state.userCompActive}
handleLoading={this.handleLoading.bind(this)}
name={this.state.name}
submenu_id={this.state.submenu_id}
btndownload = {this.state.btndownload}
btnedit = {this.state.btnedit}
btndelete = {this.state.btndelete}
menuName={this.state.menu_title}
submenu_id={this.state.submenu_id}
/>)}
</div>
</Paper>
)}
</div>
{this.state.visibleCreate && (
<CreateChcmDoc
onClickClose={() => this.setState({ visibleCreate: false })}
// getDataDocument={this.getDataDocument.bind(this)}
createDocument={this.createDocument.bind(this)}
handleLoading={this.handleLoading.bind(this)}
submenu_id={this.state.submenu_id}
menuName={this.state.menu_title}
/>
)}
</div>
);
}
}
import React, { Component } from 'react'
import Images from '../../assets/Images'
import { TextField, withStyles, Snackbar } from '@material-ui/core'
import MuiAlert from '@material-ui/lab/Alert';
import api from '../../api'
import Autocomplete from '@material-ui/lab/Autocomplete'
import Constant from '../../library/Constant'
import { format } from 'date-fns';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
import * as R from 'ramda'
import PropagateLoader from "react-spinners/PropagateLoader"
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class CreateChcmDoc extends Component {
constructor(props) {
super(props)
this.state = {
perusahaan: null,
perusahaanData: null,
getPerusahaan: null,
errorPerusahaan: false,
msgErrorPerusahaan: '',
document: null,
documentData: null,
getDocument: null,
errorDocument: false,
msgErrorDocument: '',
listPeriode: null,
periode: null,
errorPeriode: false,
msgErrorPeriode: '',
listMonth: null,
monthId: null,
errorMonth: false,
msgErrorMonth: '',
description: '',
errorDesc: false,
msgErrorDesc: '',
file: null,
alert: false,
tipeAlert: '',
messageAlert: '',
fileType: '',
docId: '',
sizeUpload: "1",
isClickSave: 0
}
}
componentDidMount() {
this.getDataCompany()
this.getPeriode()
this.getMonth()
this.getFileSize()
}
getFileSize() {
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
type: 'MAX_FILE_SIZE'
}
api.create().getAllSettingByType(body).then(response => {
// console.log(response);
if (response.data) {
if (response.data.status === "success") {
if (response.data.data.length == 0) {
this.setState({
sizeUpload: "1"
})
} else {
this.setState({
sizeUpload: response.data.data[0].value
})
}
// sizeUpload: response.data.data[0] ? response.data.data[0].value === undefined ? "1" : response.data.data[0].value : "1"
} 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);
}
})
}
}
})
}
getDataCompany() {
api.create().getPerusahaanUserActive().then((response) => {
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
// typeData.push({
// company_id: 0,
// company_name: 'Default'
// })
let typeProps = {
options: typeData.sort((a, b) => a.company_name - b.company_name),
getOptionLabel: (option) => option.company_name,
};
this.setState({ perusahaan: typeProps })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getPeriode() {
api.create().getPeriodeTransaction().then(response => {
let dateNow = new Date
let year = format(dateNow, 'yyyy')
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
let periodeData = data.map((item) => {
return {
periode: item,
}
})
let defaultProps = {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let index = data.sort((a, b) => a - b).findIndex((val) => val == year)
this.setState({ listPeriode: defaultProps, periode: index == -1 ? periodeData[0] : periodeData[index] })
} 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);
}
})
}
}
})
}
getMonth() {
api.create().getMonthTransaction().then(response => {
let dateNow = new Date
// let bulan = format(dateNow, 'MMMM')
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
let monthData = data.map((item) => {
return {
month_id: item.month_id,
month_name: item.month_name
}
})
let defaultProps = {
options: monthData,
getOptionLabel: (option) => option.month_name,
};
// let index = data.sort((a, b) => a - b).findIndex((val) => val == bulan)
// this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] })
this.setState({ listMonth: defaultProps })
} 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);
}
})
}
}
})
}
clearMessage() {
this.setState({
errorPerusahaan: false,
msgErrorPerusahaan: '',
errorDocument: false,
msgErrorDocument: '',
errorMonth: false,
msgErrorMonth: '',
errorPeriode: false,
msgErrorPeriode: '',
})
}
fileHandler = (event) => {
let fileObj = event
let length = event.name.split(".").length
let fileType = event.name.split(".")[length - 1]
if (fileType === 'zip' || 'rar') {
this.setState({ file: event, fileType: String(fileType) })
} else {
ExcelRenderer(fileObj, (err, resp) => {
// console.log(fileType)
if (err) {
// console.log(err);
}
else {
this.setState({ file: event, fileType: String(fileType) })
}
})
}
}
validasi() {
if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty', saveDisable: false })
}else if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty', saveDisable: false })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty', saveDisable: false })
}
else if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning', saveDisable: false })
} else {
console.log(this.state.isClickSave + " ===> di luar");
const formData = new FormData();
formData.append("file", this.state.file);
formData.append("companyId", this.state.getPerusahaan.company_id);
formData.append("submenuId", this.props.submenu_id);
formData.append("description", this.state.description);
formData.append("extension", this.state.fileType);
formData.append("documentPeriode", this.state.periode.periode);
formData.append("documentMonth", this.state.monthId.month_id);
this.setState({ formData }, () => {
this.props.createDocument(this.state.formData)
})
}
}
deleteFile(e) {
this.setState({ file: null })
}
closeAlert() {
this.setState({ alert: false })
}
render() {
const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader
// css={override}
size={20}
color={"#274B80"}
loading={this.state.loading}
/>
</div>
);
return (
<div>
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close} />
</button>
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20, paddingTop: 20 }}>
<div className="column-1">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.perusahaan}
// debug
clearOnEscape
id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField {...params}
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Company Name" />}
value={this.state.getPerusahaan}
/>
</div>
</div>
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5, marginTop: "1.2em" }}>
<TextField
value={this.props.menuName}
InputProps={{ style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
placeholder="Category"
disabled
size="medium"
fullWidth={true}
/>
</div>
</div>
<div className="column-1">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listMonth}
// debug
clearOnEscape
id="month"
onChange={(event, newInputValue) => this.setState({ monthId: newInputValue }, () => this.clearMessage())}
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Period Month" margin="normal" style={{ marginTop: 7 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
error={this.state.errorMonth}
helperText={this.state.msgErrorMonth}
/>}
value={this.state.monthId}
/>
</div>
</div>
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listPeriode}
// debug
clearOnEscape
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => this.clearMessage())}
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Period Year" margin="normal" style={{ marginTop: 7 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
error={this.state.errorPeriode}
helperText={this.state.msgErrorPeriode}
/>}
value={this.state.periode}
/>
</div>
</div>
</div>
<div style={{ paddingLeft: 30, paddingRight: 30, paddingTop: 10 }}>
<UploadFile
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["xls", "xlsx", "pdf", "PDF", "docx", "doc", "pptx", "ppt", "ods", "odf", "txt", "csv", "zip", "rar"]}
intent={"management"}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onDelete={(e) => {
this.deleteFile(e)
}}
onUpload={() => alert('sukses')}
sizeUpload={Number(this.state.sizeUpload)}
/>
</div>
<div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
<TextField
style={{ width: '100%' }}
id="description"
label="Description"
value={this.state.decription}
inputProps={{
min: 0,
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
name="Description"
onChange={(e) => {
this.setState({
description: e.target.value
})
this.clearMessage()
}}
error={this.state.errorDesc}
helperText={this.state.msgErrorDesc}
>
</TextField>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickClose()}
>
<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>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
{!this.state.saveDisable && <button
disabled={this.state.saveDisable}
type="button"
onClick={() =>
this.state.isClickSave == 1 ? null :
this.setState({ isClickSave: 1 }, () => {
this.validasi()
})
}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Save</span>
</div>
</button>}
</div>
</div>
</div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
</div>
</div>
)
}
}
import React, { Component } from 'react'
import Images from '../../assets/Images'
import { TextField, withStyles, Snackbar, Typography } from '@material-ui/core'
import MuiAlert from '@material-ui/lab/Alert';
import api from '../../api'
import Autocomplete from '@material-ui/lab/Autocomplete'
import Constant from '../../library/Constant'
import { format } from 'date-fns';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
import * as R from 'ramda'
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class EditDocumentChcm extends Component {
constructor(props) {
super(props)
this.state = {
perusahaan: null,
perusahaanData: null,
getPerusahaan: null,
errorPerusahaan: false,
msgErrorPerusahaan: '',
document: null,
documentData: null,
getDocument: null,
errorDocument: false,
msgErrorDocument: '',
listPeriode: null,
periode: null,
listMonth: null,
monthId: null,
description: '',
errorDesc: false,
msgErrorDesc: '',
errorMonth: false,
msgErrorMonth: '',
errorPeriode: false,
msgErrorPeriode: '',
file: null,
alert: false,
tipeAlert: '',
messageAlert: '',
fileType: '',
konfirmasi: false,
docId: '',
document_name: "",
document_size: 0,
loadUpload: false,
sizeUpload: "1",
name: '',
disabledPeriode: false
}
}
componentDidMount() {
this.getFileSize()
if (this.props.type === 'edit') {
this.getDetailDoc()
}
}
getFileSize() {
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
type: 'MAX_FILE_SIZE'
}
api.create().getAllSettingByType(body).then(response => {
// console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({
sizeUpload: response.data.data[0] ? response.data.data[0].value === undefined ? "1" : response.data.data[0].value : "1"
})
} 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);
}
})
}
}
})
}
getDetailDoc() {
api.create().getDetailReportChcm(this.props.idoc).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
this.setState({
companyId: data.company_id,
companyName: data.company_name,
period: data.document_periode,
getMonthName: data.document_month,
description: data.description,
filePath: data.document_filepath,
file: data.document_filepath,
document_name: data.document_name,
document_size: data.document_size,
fileType: data.document_type,
created: data.created,
updated: data.updated === null ? "" : data.updated,
loadUpload: true,
name: data.values,
disabledPeriode: data.values === 'Manual Book TIA 4.0' ? true : false
}, () => {
this.getDataCompany()
// this.getDataDocument()
this.getPeriode()
this.getMonth()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getDataCompany() {
api.create().getPerusahaanUserActive().then((response) => {
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
let typeProps = {
options: typeData,
getOptionLabel: (option) => option.company_name,
};
let index = typeData.findIndex((val) => val.company_id == this.state.companyId)
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index === -1 ? typeData[0] : typeData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
// getDataDocument() {
// // let payload = {
// // "setting_group_id": 7,
// // "setting_type_id": 167,
// // "company_id": 0
// // }
// api.create().getDocumentCategory().then(response => {
// // console.log(response);
// if (response.data) {
// if (response.data.status == 'success') {
// let data = response.data.data
// let typeData = data.map((item) => {
// return {
// document_category_id: item.setting_id,
// document_category_name: item.value
// }
// })
// let typeProps = {
// options: typeData,
// getOptionLabel: (option) => option.document_category_name,
// };
// let index = typeData.findIndex((val) => val.document_category_id == this.state.categoryId)
// this.setState({ document: typeProps, documentData: response.data.data, getDocument: index === -1 ? typeData[0] : typeData[index] })
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
// if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
// setTimeout(() => {
// localStorage.removeItem(Constant.TOKEN)
// window.location.reload();
// }, 1000);
// }
// })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
// }
// })
// }
getPeriode() {
api.create().getPeriodeTransaction().then(response => {
let dateNow = new Date
let year = format(dateNow, 'yyyy')
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
let periodeData = data.map((item) => {
return {
periode: item,
}
})
let defaultProps = {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let index = data.sort((a, b) => a - b).findIndex((val) => val == this.state.period)
this.setState({ listPeriode: defaultProps, periode: index == -1 ? periodeData[0] : periodeData[index] })
}
}
})
}
getMonth() {
api.create().getMonthTransaction().then(response => {
let dateNow = new Date
// let bulan = format(dateNow, 'MMMM')
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
let monthData = data.map((item) => {
return {
month_name: item.month_name,
month_id: item.month_id
}
})
let index = monthData.findIndex((val) => val.month_name == this.state.getMonthName)
let defaultProps = {
options: monthData,
getOptionLabel: (option) => option.month_name,
};
// let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == this.state.getMonth)
this.setState({ listMonth: defaultProps, monthId: index == -1 ? monthData[0] : monthData[index] })
}
}
})
}
clearMessage() {
this.setState({
errorPerusahaan: false,
msgErrorPerusahaan: '',
errorDocument: false,
msgErrorDocument: '',
errorMonth: false,
msgErrorMonth: '',
errorPeriode: false,
msgErrorPeriode: '',
})
}
fileHandler = (event) => {
let fileObj = event
let length = event.name.split(".").length
let fileType = event.name.split(".")[length - 1]
if (fileType === 'zip' || 'rar') {
this.setState({ file: event, fileType: String(fileType) })
} else {
ExcelRenderer(fileObj, (err, resp) => {
// console.log(fileType)
if (err) {
// console.log(err);
}
else {
this.setState({ file: event, fileType: String(fileType) })
}
})
}
}
validasi() {
if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
} else if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
} else {
const formData = new FormData();
if (this.state.file == this.state.filePath) {
formData.append("updated", 0);
formData.append("file", null);
} else {
formData.append("updated", 1);
formData.append("file", this.state.file);
}
formData.append("documentId", this.props.idoc);
formData.append("companyId", this.state.getPerusahaan.company_id);
formData.append("submenuId", this.props.submenu_id);
formData.append("description", this.state.description);
formData.append("extension", this.state.fileType);
formData.append("documentPeriode", this.state.periode.periode);
formData.append("documentMonth", this.state.monthId.month_id);
this.setState({ formData }, () => {
this.props.updateDocument(this.state.formData)
})
}
}
deleteFile(e) {
this.setState({ file: null })
}
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
<div>
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Edit</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close} />
</button>
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20, paddingTop: 20 }}>
<div className="column-1">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.perusahaan}
debug
// clearOnEscape
id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField {...params}
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Company Name" />}
value={this.state.getPerusahaan}
/>
</div>
</div>
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5, marginTop: "1.2em" }}>
<TextField
value={this.props.menuName}
InputProps={{ style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
placeholder="Category"
disabled
size="medium"
fullWidth={true}
/>
</div>
</div>
<div className="column-1">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listMonth}
// debug
clearOnEscape
id="month"
onChange={(event, newInputValue) => this.setState({ monthId: newInputValue }, () => this.clearMessage())}
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Period Month" margin="normal" style={{ marginTop: 7 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
error={this.state.errorMonth}
helperText={this.state.msgErrorMonth}
/>}
value={this.state.monthId}
/>
</div>
</div>
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listPeriode}
// debug
clearOnEscape
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => this.clearMessage())}
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Period Year" margin="normal" style={{ marginTop: 7 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
error={this.state.errorPeriode}
helperText={this.state.msgErrorPeriode}
/>}
value={this.state.periode}
/>
</div>
</div>
</div>
<div style={{ paddingLeft: 30, paddingRight: 30, paddingTop: 10 }}>
{this.state.loadUpload && (
<UploadFile
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["xls", "xlsx", "pdf", "PDF", "docx", "doc", "pptx", "ppt", "ods", "odf"]}
intent={"management"}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onDelete={(e) => {
this.deleteFile(e)
}}
onUpload={() => alert('sukses')}
value={this.state.file}
docSize={this.state.document_size}
docName={this.state.document_name}
sizeUpload={Number(this.state.sizeUpload)}
/>
)}
</div>
<div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
<TextField
style={{ width: '100%' }}
id="description"
label="Description"
value={this.state.description}
inputProps={{
min: 0,
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
name="Description"
onChange={(e) => {
this.setState({
description: e.target.value
})
this.clearMessage()
}}
error={this.state.errorDesc}
helperText={this.state.msgErrorDesc}
>
</TextField>
</div>
<div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.created}</Typography>
</div>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '12%' }}>Updated By</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.updated == - null ? "" : this.state.updated}</Typography>
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickClose()}
>
<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>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.validasi()
}, 100);
})
}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Save</span>
</div>
</button>
</div>
</div>
</div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
</div>
</div>
)
}
}
import React, { Component } from 'react';
import Images from '../../assets/Images';
import { Typography } from '@material-ui/core';
import api from "../../api";
import Constant from '../../library/Constant';
export default class PopUpDelete extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
getApprovedBy: null,
getTypes: null,
}
}
componentDidMount() {
console.log(this.props);
if (this.props.type === 'delete') {
// console.log(this.props.idoc)
// console.log(this.props.data)
}
}
onClickDelete() {
if (this.props.type == 'delete') {
let payload = this.props.idoc
this.props.deleteDoc(payload)
}
}
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}>
<img src={Images.failed} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20, paddingBottom: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold', fontFamily: 'Nunito Sans, sans-serif' }}>
Delete {this.props.data[1]} ?
</span>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickClose()}
>
<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>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.onClickDelete()
}, 100);
})
}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Delete</span>
</div>
</button>
</div>
</div>
</div>
</div>
);
}
}
import React, { Component } from 'react';
import api from "../../api";
import Constant from "../../library/Constant";
import Images from "../../assets/Images";
import ReactTooltip from "react-tooltip";
import PropagateLoader from "react-spinners/PropagateLoader";
import { createMuiTheme, MuiThemeProvider, Snackbar } from "@material-ui/core";
import MUIDataTable from "mui-datatables";
import { withStyles } from "@material-ui/core/styles";
import MuiAlert from "@material-ui/lab/Alert";
import EditDocumentChcm from './EditDocumentChcm';
import PopUpDelete from "./PopUpDelete";
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptionsManagementDocument();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class TableChcmDocument extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [],
visibleCreate: false,
refresh: '',
alert: false,
visibleEdit: false,
popupDel: false,
}
}
componentDidMount() {
this.getData()
}
componentWillReceiveProps(props) {
// console.log(props);
const { refresh } = this.props;
if (props.refresh !== refresh) {
this.getData()
}
}
getData() {
let payload = {
"submenu_id": this.props.submenu_id
}
this.setState({ loading: true })
api.create().getChcmDocumentBySubmenu(payload).then(response => {
// console.log("table document carfm");
console.log(response)
// console.log("table document carfm stop")
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let dataTable = []
response.data.data.map((item, index) => {
let indexId = this.props.userCompActive.findIndex((val) => val == item.company_id)
if (indexId !== -1) {
dataTable.push([
index,
item.document_name,
item.description,
item.company_name,
item.document_month,
item.document_periode,
item.document_type,
String(Number(item.document_size) / 1000 + ' KB'),
item.created_by,
item.created_at,
item.values,
item.document_id,
])
}
})
let docPath = response.data.data.map((item) => {
return [
item.document_filepath
]
})
let docId = response.data.data.map((item) => {
return [
item.document_id
]
})
// console.log(dataTable)
this.setState({ dataTable, docPath, docId, loading: false })
} 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);
}
})
}
} else {
console.log("error di table document getcarfm 1");
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
console.log("error di table document getcarfm 2");
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
openPopUp = async (index, val, type) => {
console.log(index);
if (type === "download") {
try {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/document/download_chcm_document?documentName=${this.state.docPath[val]}&&fileType=${index[6]}`;
console.log("Fetching URL:", url); // Debugging step
let response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
let blob = await response.blob();
if (blob.size > 0) {
let downloadUrl = window.URL.createObjectURL(blob);
let a = document.createElement("a");
a.href = downloadUrl;
a.download =
(String(index[3]).includes(":")
? String(index[3]).replace(":", " (") + ` )`
: String(index[3])) +
" - " +
index[4] +
" - " +
index[5] +
" - " +
index[1] +
"." +
index[6];
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
} else {
console.error("Downloaded file is empty.");
}
} catch (error) {
console.error("Download error:", error);
}
}
if (type === 'delete') {
this.setState({
id: this.state.docId[val],
rowData: index,
popupDel: true
})
}
if (type === 'edit') {
this.setState({
id: this.state.docId[val],
rowData: index,
visibleEdit: true
})
}
};
deleteDoc = (payload) => {
console.log(payload);
this.setState({ popupDel: false, loading: true })
api.create().deleteReportChcm(payload).then(response => {
console.log(response.data)
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', loading: false })
} 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);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
updateDocument(payload) {
console.log(payload);
this.setState({ visibleEdit: false, loading: true })
api.create().updateReportChcm(payload).then(response => {
// console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.getData()
this.setState({ konfirmasi: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success', visibleEdit: false, loading: false })
} 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);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
let columns = [{
name: "Action",
options: {
filter: false,
sort: false,
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
{this.props.btndownload && <a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginRight: 15
}}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'download')}
>
<img src={Images.download} />
</button>
</a>}
{this.props.btnedit && <a data-tip={'Edit'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginRight: 15
}}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'edit')}
>
<img src={Images.editCopy} />
</button>
</a>}
{this.props.btndelete && <a data-tip={'Delete'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginRight: 15
}}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'delete')}
>
<img src={Images.delete} />
</button>
</a>}
<ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
</div >
);
}
}
},
{
name: "File Name",
options: {
display: false
}
},
"Description", "Company Name", "Period Month", "Period Year",
"Type", "File Size", "Created By", "Created Date",
{
name: "Category",
options: {
display: false
}
},
{
name: "",
options: {
display: false
}
},
]
const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader
// css={override}
size={20}
color={"#274B80"}
loading={this.state.loading}
/>
</div>
);
return (
<div style={{ width: '100%' }}>
{this.props.load && (
<div style={{ padding: 25 }}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
// theme={getMuiTheme()}
data={this.state.dataTable}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
)}
{this.state.visibleEdit && (
<EditDocumentChcm
type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.rowData}
idoc={this.state.id}
updateDocument={this.updateDocument.bind(this)}
menuName={this.props.menuName}
submenu_id={this.props.submenu_id}
/>
)}
{this.state.popupDel && (
<PopUpDelete
type={"delete"}
onClickClose={() => this.setState({ popupDel: false })}
data={this.state.rowData}
idoc={this.state.id}
// getList={() => this.getData.bind(this)}
deleteDoc={this.deleteDoc.bind(this)}
/>
)}
</div>
)
}
}
......@@ -822,6 +822,8 @@ export default class CreateParameter extends Component {
}
} else if (this.state.getTypes.setting_group_name == "CURRENCY") {
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 15000' })
} else if (this.state.getTypes.setting_group_name == "DAY_OFF") {
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023' })
}
}
}
......@@ -907,6 +909,28 @@ export default class CreateParameter extends Component {
}
}
}
} else if (this.state.getTypes.setting_group_name == "DAY_OFF"){
console.log(this.state.errorMaxValue)
if (R.isEmpty(data.value)) {
}else {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) {
} else {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
if (data.maxValue.slice(-4)==data.value){
this.updateParameter()
}else {
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, value must same with a year of max value' })
}
}
}
}
}
}
}
} else {
if (R.isNil(this.state.getParameter)) {
} else {
......@@ -994,6 +1018,28 @@ export default class CreateParameter extends Component {
}
}
}
} else if (this.state.getTypes.setting_group_name == "DAY_OFF"){
console.log(this.state.errorMaxValue)
if (R.isEmpty(data.value)) {
}else {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) {
} else {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
if (data.maxValue.slice(-4)==data.value){
this.createParameter()
}else {
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, value must same with a year of max value' })
}
}
}
}
}
}
}
} else {
if (R.isNil(this.state.getParameter)) {
} else {
......@@ -1055,6 +1101,8 @@ export default class CreateParameter extends Component {
obj = { regexValue: (/Q1\s\d{4}/), valueLength: 7 }
}
}
}else if (this.state.getTypes.setting_group_name === "DAY_OFF"){
obj = {regexValue: (/\b\d{4}\b/), valueLength: 4}
}else{
obj = { regexValue: (/null.*$/), valueLength: 20 }
}
......@@ -1084,6 +1132,12 @@ export default class CreateParameter extends Component {
case "THRESHOLD_VARIANCE":
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Incorrect max value format, example : 99999999' })
break
case "DAY_OFF":
this.setState({
errorMaxValue: true,
msgErrorMaxValue: 'Incorrect max value format, example : 31 Jan 2023'
})
break
default:
this.setState({ errorMaxValue: false, msgErrorMaxValue: '' })
}
......@@ -1112,6 +1166,9 @@ export default class CreateParameter extends Component {
case "THRESHOLD_VARIANCE":
this.setState({ errorMinValue: true, msgErrorMinValue: 'Incorrect min value format, example : -99999999' })
break
case "DAY_OFF":
this.setState({ errorMinValue: true, msgErrorMinValue: 'Incorrect min value format, example : 1 Jan 2023' })
break
default:
this.setState({ errorMinValue: false, msgErrorMinValue: '' })
}
......@@ -1196,6 +1253,11 @@ export default class CreateParameter extends Component {
case "THRESHOLD_CONTROL":
obj = { minMaxRegex: (/^-?\d+(\.\d+)?$/), minLength: this.state.minValue.length, maxLength: this.state.maxValue.length }
break
case "DAY_OFF":
obj = {
minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/),
minLength: 11, maxLength: 11
}
default:
obj = { regexValue: null, minLength: 11, maxLength: 11 }
}
......
......@@ -87,7 +87,11 @@ const useStyles = makeStyles((theme) => ({
},
padding: 20,
display: 'flex',
<<<<<<< HEAD
backgroundColor: '#273b80'
=======
backgroundColor: '#319c23'
>>>>>>> 6b62ed9909ab356afa97d180033088819e3e7c03
},
drawerOpen: {
width: drawerWidth,
......
......@@ -318,7 +318,7 @@ export default class CorporateAnnualTargetMR extends Component {
}
}
})
// console.log(dataTable);
console.log(dataTable);
this.setState({ dataTable, loading: false, saveDraft: true }, () => {
this.handleCalculate(dataTable)
})
......
......@@ -149,7 +149,7 @@ export default class LOCF extends Component {
if (this.props.dataTablelocf !== prevProps.dataTablelocf) {
let array = this.props.dataTablelocf
let datas = array[array.length - 1]
this.setState({ dataTable: this.props.dataTablelocf, diff: datas[47], loanTotal: datas[48], perBS: datas[49] })
this.setState({ dataTable: this.props.dataTablelocf, diff: this.props.defaultCurrency.id == 1 ? fixNumber(Number(datas[47]), 1) : datas[47], loanTotal: datas[48], perBS: this.props.defaultCurrency.id == 1 ? fixNumber(Number(datas[49]), 1) : datas[49] })
}
if (this.props.loadingChild !== prevProps.loadingChild) {
this.setState({ loading: this.props.loadingChild })
......@@ -353,7 +353,7 @@ export default class LOCF extends Component {
// let sortingTable = dataTable.sort((a, b) => a[6].value - b[6].value)
// console.log(sortingTable);
let lastArray = dataTable[res.length - 1]
this.setState({ dataTable, diff: lastArray[47], loanTotal: lastArray[48], perBS: lastArray[49], loading: false, visibleLOCFMR: true }, () => {
this.setState({ dataTable, diff: this.props.defaultCurrency.id == 1 ? fixNumber(Number(lastArray[47]), 1) : lastArray[47], loanTotal: lastArray[48], perBS: this.props.defaultCurrency.id == 1 ? fixNumber(Number(lastArray[49]), 1) : lastArray[49], loading: false, visibleLOCFMR: true }, () => {
this.props.sendToParent(dataTable, lastArray, 'LOCF')
})
}
......@@ -565,10 +565,8 @@ export default class LOCF extends Component {
console.log(dataTable);
let lastArray = dataTable[dataTable.length - 1]
console.log(lastArray);
this.setState({ dataTable, diff: lastArray[47], loanTotal: lastArray[48], perBS: lastArray[49], dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => {
console.log(this.state.visibleLOCFMR);
this.props.sendToParent(dataTable, lastArray , 'LOCF', 'upload', this.state.visibleLOCFMR)
this.setState({ dataTable, diff: this.props.defaultCurrency.id == 1 ? fixNumber(Number(lastArray[47]), 1) : lastArray[47], loanTotal: lastArray[48], perBS: this.props.defaultCurrency.id == 1 ? fixNumber(Number(lastArray[49]), 1) : lastArray[49], dataLoaded: true, loading: false, buttonError: false, dataDelete: [] }, () => {
this.props.sendToParent(dataTable, lastArray, 'LOCF', 'upload', this.state.visibleLOCFMR)
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, typeAlert: 'warning', loading: false }, () => {
......@@ -970,7 +968,7 @@ export default class LOCF extends Component {
}
const handleValueDropDown = (value, type, tableMeta) => {
let data = type == 'bankName' ? this.state.bankNameList.options : type == 'typeOfCreditList' ? this.state.typeOfCreditList.options : this.state.businessBankList.options
let data = type == 'bankName' ? this.state.bankNameList.options : type == 'typeOfCreditList' ? this.state.typeOfCreditList.options : this.state.businessBankList.options
let index = 0
if (type == 'bankName' && dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] != null && dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] != "") {
indexNyasar = true
......@@ -3619,7 +3617,7 @@ export default class LOCF extends Component {
<Typography style={{ fontSize: '12px', color: '#4b4b4b' }}>Diff</Typography>
</div>
<div style={{ borderStyle: 'solid', borderWidth: '0px 1px 1px 1px', padding: 5, minWidth: 200, display: 'flex', justifyContent: 'flex-end' }}>
<Typography style={{ fontSize: '14px', color: Number(this.state.diff) > 0 ? 'red' : '#4b4b4b' }}><NumberFormat value={this.state.diff} displayType={'text'} thousandSeparator={true} prefix={''} /></Typography>
<Typography style={{ fontSize: '14px', color: Number(this.state.diff) > '0.0' || Number(this.state.diff) < '0.0' ? 'red' : '#4b4b4b' }}><NumberFormat value={this.state.diff == 0 ? "0.0" : this.state.diff} displayType={'text'} thousandSeparator={true} prefix={''} /></Typography>
</div>
</div>
</div>
......
......@@ -360,15 +360,15 @@ export default class LOV extends Component {
payload.push({
"item_report_id": i[1],
"company_name": this.props.company.company_name,
"institution_name": i[3],
"type_of_investment": i[4],
"remarks": i[5],
"placement_date": i[6] !== undefined ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : null,
"tenor": i[7],
"expected_return": i[8],
"currency": i[9],
"investment_amount_ori": i[10] !== undefined ? Number(i[10]) : i[10],
"investment_amount_cur": i[11] !== undefined ? Number(i[11]) : i[11],
"institution_name": i[3] !== undefined ? (i[3]) : "",
"type_of_investment": i[4] !== undefined ? (i[4]) : "",
"remarks": i[5] !== undefined ? (i[5]) : "",
"placement_date": i[6] !== undefined ? tgl[2] + '-' + tgl[1] + '-' + tgl[0] : "",
"tenor": i[7] !== undefined ? (i[7]) : "",
"expected_return": i[8] !== undefined ? (i[8]) : "",
"currency": i[9] !== undefined ? (i[9]) : "",
"investment_amount_ori": i[10] !== undefined ? Number(i[10]) : "",
"investment_amount_cur": i[11] !== undefined ? Number(i[11]) : "",
"notes": i[12],
})
}
......
......@@ -21,6 +21,7 @@ import { ExcelRenderer } from 'react-excel-renderer';
import { fixNumber, roundMath } from "../../library/Utils";
import LOCF from './LOCFMR';
import LOV from './LOVMR';
import PopUpValidationLOV from '../../library/PopUpValidationLOV';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
......@@ -142,6 +143,7 @@ export default class ListOfCreditFacilities extends Component {
alert: false,
tipeAlert: '',
messageAlert: '',
emptyData: false,
}
}
......@@ -947,14 +949,19 @@ export default class ListOfCreditFacilities extends Component {
if (i[0] == 3) {
if (i[6] == null || i[7] == null || i[9] == "" || i[10] == "" || i[11] == "" || i[12] == "") {
error = true
this.setState({ emptyData: true})
}
if ((i[7]?.value == 'Government bonds' && i[8] == '') || (i[7]?.value == 'Stocks' && i[8] == '') || (i[7]?.value == 'Mutual funds' && i[8] == '') || (i[7]?.value == 'Investment in associate' && i[8] == '') || (i[7]?.value == 'Investment in joint venture' && i[8] == '') || (i[7]?.value == 'Investment in subsidiary' && i[8] == '') || (i[7]?.value == 'Corporate bonds' && i[8] == '') || (i[7]?.value == 'Others' && i[8] == '')) {
error = true
} else {
error = false
}else {
if ((i[7].value == 'Government bonds' && i[8] == '') || (i[7].value == 'Stocks' && i[8] == '') || (i[7].value == 'Mutual funds' && i[8] == '') || (i[7].value == 'Investment in associate' && i[8] == '') || (i[7].value == 'Investment in joint venture' && i[8] == '') || (i[7].value == 'Investment in subsidiary' && i[8] == '') || (i[7].value == 'Corporate bonds' && i[8] == '') || (i[7].value == 'Others' && i[8] == '')) {
error = true
this.setState({ emptyData: true})
} else {
error = false
}
}
// if (i[7].value == 'Government bonds' || i[7].value == 'Stocks' || i[7].value == 'Mutual funds' || i[7].value == 'Investment in associate' || i[7].value == 'Investment in joint venture' || i[7].value == 'Investment in subsidiary' || i[7].value == 'Corporate bonds' || i[7].value == 'Others' && i[8] == '' ) {
// error = true
// }
......@@ -1764,7 +1771,11 @@ export default class ListOfCreditFacilities extends Component {
</div>
</Paper>}
</div>
{this.state.emptyData && (
<PopUpValidationLOV
onClickClose={() => this.setState({ emptyData: false })}
/>
)}
{
this.state.visibleAlertSave && (
<div className="test app-popup-show">
......
......@@ -100,6 +100,7 @@ class ReportProgress extends Component {
MB.push({ name: String(i + 1), value: i + 1})
}
}
console.log(MB);
let defaultPropsMB = {
options: MB,
......@@ -108,7 +109,8 @@ class ReportProgress extends Component {
this.setState({
listPeriodeMB: defaultPropsMB,
periodeMB: MB[MB.length - 1],
// periodeMB: MB[MB.length - 1],
periodeMB: MB[MB.length - 2],
}, () => {
this.getReportType()
// console.log(this.state.listMonth)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import React, { Component } from 'react';
import Images from '../assets/Images';
import { Typography } from '@material-ui/core';
export default class PopUpValidationLOV extends Component {
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8, padding: 50 }}>
<div style={{ display: 'flex', justifyContent: 'center' }}>
<img src={Images.failedCopy} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold' }}>
{`There is empty value`}
</span>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold' }}>
{`Please fill the blank`}
</span>
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 24 }}>
<button
className={"btn-save"}
onClick={()=> this.props.onClickClose()}
>
<span style={{ color: 'white' }}>OK</span>
</button>
</div>
</div>
</div>
);
}
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ import CafrmDocument from "../container/CAFRM/CafrmDocument";
import ReportCafrm from "../container/ReportCarfm/RepotrCafrm";
import Maintenance from "../container/Auth/Maintenance";
import DownloadReport from "../container/DownloadReport/DownloadReport"
import ChcmDocument from '../container/CHCM/ChcmDocument';
const routes = [
{
......@@ -139,6 +140,14 @@ const routes = [
path: "/home/download-report",
main: DownloadReport
},
{
path: "/home/report-talent-management-tm",
main: ChcmDocument
},
{
path: "/home/report-trec",
main: ChcmDocument
},
{
path: "*",
main: screen404
......
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