Commit bbbad0b4 authored by EKSAD's avatar EKSAD

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into riri

parents 1d06220e 064c7fd4
......@@ -3,25 +3,47 @@ import apisauce from 'apisauce'
import Constant from '../library/Constant'
// our "constructor"
const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => {
const create = (type = "") => {
let api;
// ------
// STEP 1
// ------
//
// Create and configure an apisauce-based api object.
//
const api = apisauce.create({
// base URL is read from the "constructor"
baseURL,
// here are some default headers
headers: {
'Cache-Control': 'no-cache',
Accept: 'application/json',
'Content-Type': 'application/json',
},
// 10 second timeout...
timeout: 30000
})
const baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/'
switch (type) {
case '':
api = apisauce.create({
// base URL is read from the "constructor"
baseURL,
// here are some default headers
headers: {
'Cache-Control': 'no-cache',
Accept: 'application/json',
'Content-Type': 'application/json',
},
// 60 second timeout...
timeout: 30000
})
break;
case 'UPLOAD':
api = apisauce.create({
// base URL is read from the "constructor"
baseURL,
// here are some default headers
headers: {
'Cache-Control': 'no-cache',
Accept: 'application/json',
'Content-Type': 'application/json',
},
// 40 second timeout...
timeout: 40000
})
break;
default:
break;
}
api.addAsyncRequestTransform(request => async () => {
var token
......@@ -169,6 +191,12 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const createSubmitReport = (body) => api.post('transaction/master_budget/create_submission_report', body)
const getSubmission = (body) => api.post('transaction/get_submission_id', body)
const checkUploadMB = (body) => api.post('transaction/master_budget/check_import', body)
const uploadMasterBudget = (body) => api.post('transaction/master_budget/import_master_budget', body)
const getAllOperatingInd = (body) => api.post('/transaction/get_all_operating_indicator_report', body)
const getOperatingIndDetail = (body) => api.post('/transaction/operating_indicator/get_operating_indicator_report_hierarki', body)
const createOpetaingInd = (body) => api.post('/transaction/operating_indicator/create_submission_report', body)
//Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
......@@ -182,6 +210,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const uploadDocument = (body) => api.post('document/upload_document', body)
const updateDocument = (body) => api.post('document/update_document', body)
const downloadDocument = (body) => api.post('document/download_document', body)
const getPerusahaanUserActive = () => api.get('company/get_all_user_company_active')
const getDetailDocument = (id) => api.get(`document/get_document_by_id/${id}`)
const deleteDocument = (id) => api.post(`document/delete_document/${id}`)
// ------
// STEP 3
......@@ -291,9 +322,16 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
uploadDocument,
updateDocument,
downloadDocument,
getPerusahaanUserActive,
getDetailDocument,
deleteDocument,
createSubmitReport,
getSubmission,
checkUploadMB
checkUploadMB,
getAllOperatingInd,
getOperatingIndDetail,
createOpetaingInd,
uploadMasterBudget
}
}
......
......@@ -653,6 +653,8 @@ export default class BudgetTahunan extends Component {
submissionID={this.state.submissionID}
saveToMasterBudget={this.saveToMasterBudget.bind(this)}
onClickClose={() => this.setState({ visibleBS: false, visibleBudgetTahunan: true })}
getReport={this.getReport.bind(this)}
getReportAttachment={this.getReportAttachment.bind(this)}
/>
)}
{this.state.visiblePL && (
......
......@@ -714,11 +714,6 @@ export default class BalanceSheet extends Component {
} else {
data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
}
// this.forceUpdate()
// console.log(this.state.dataTable)
// this.setState({
// data: a,
// }, () => console.log(this.state.dataTable))
}
backToMasterBudget(type) {
......@@ -743,7 +738,6 @@ export default class BalanceSheet extends Component {
total_next_year: String(i[20]),
total_more_year: String(i[21])
})
})
let payload = {
"submission_id": this.props.submissionID,
......@@ -808,32 +802,6 @@ export default class BalanceSheet extends Component {
})
}
})
let rows = isi.map((i, index) => {
return [
String(i[0]) === '-' ? 4 : 3,
0,
0,
"",
1,
i[0] === undefined ? "" : String(i[0]),
i[1] === undefined ? "" : String(i[1]),
i[2] === undefined ? "" : String(i[2]),
i[3] === undefined ? "" : String(i[3]),
i[4] === undefined ? "" : String(i[4]),
i[5] === undefined ? "" : String(i[5]),
i[6] === undefined ? "" : String(i[6]),
i[7] === undefined ? "" : String(i[7]),
i[8] === undefined ? "" : String(i[8]),
i[9] === undefined ? "" : String(i[9]),
i[10] === undefined ? "" : String(i[10]),
i[11] === undefined ? "" : String(i[11]),
i[12] === undefined ? "" : String(i[12]),
i[13] === undefined ? "" : String(i[13]),
i[14] === undefined ? "" : String(i[14]),
i[15] === undefined ? "" : String(i[15]),
i[16] === undefined ? "" : String(i[16])
]
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
......@@ -880,12 +848,66 @@ export default class BalanceSheet extends Component {
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false })
}
}
})
}
checkError(tableMeta) {
if (tableMeta.rowData[22]) {
if (tableMeta.rowData[22][0] === 'item') {
this.setState({ buttonError: true })
}
}
}
uploadBalanceSheet() {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
total_actual_before: String(i[6]),
january: String(i[7]),
february: String(i[8]),
march: String(i[9]),
april: String(i[10]),
may: String(i[11]),
june: String(i[12]),
july: String(i[13]),
august: String(i[14]),
september: String(i[15]),
october: String(i[16]),
november: String(i[17]),
december: String(i[18]),
total_current_year: String(i[19]),
total_next_year: String(i[20]),
total_more_year: String(i[21])
})
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
balance_sheet: data
}
console.log(data);
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
this.props.getReportAttachment()
} else {
alert(response.data.status)
}
} else {
alert(response.problem)
}
})
}
render() {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => {
......@@ -957,6 +979,7 @@ export default class BalanceSheet extends Component {
return a
}
const columns = [{
name: "",
options: {
......@@ -1000,11 +1023,13 @@ export default class BalanceSheet extends Component {
tableMeta.rowData[4] == 0 ?
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
{this.checkError(tableMeta)}
</a>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
{this.checkError(tableMeta)}
</a>
</div>
:
......@@ -2551,10 +2576,10 @@ export default class BalanceSheet extends Component {
cursor: this.state.disabledSave === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
marginRight: 20
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center'}}>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
......@@ -2609,14 +2634,18 @@ export default class BalanceSheet extends Component {
onClick={() => this.setState({ visibleBalanceSheet: true }, () => this.getItemHierarki())}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960'}}>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError == true ? true : false}
onClick={() => null}
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadBalanceSheet()
}, 100);
})}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
......@@ -2635,7 +2664,7 @@ export default class BalanceSheet extends Component {
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: false })
this.setState({ loading: false })
}, 100);
})
}}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import React, { Component } from 'react'
import MUIDataTable from 'mui-datatables'
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles';
import { createMuiTheme, MuiThemeProvider, Snackbar } from '@material-ui/core';
import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../library/Constant';
import api from '../../api';
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
import PopUpDelete from "./PopUpDelete";
import CreateManagementDoc from './CreateManagementDoc';
......@@ -11,13 +15,18 @@ 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 BOD extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [],
visibleCreate: false,
refresh: ''
refresh: '',
alert: false,
popupDel: false,
}
}
......@@ -67,8 +76,27 @@ export default class BOD extends Component {
]
})
this.setState({ docPath })
let docId = response.data.data.map((item) => {
return [
item.document_id
]
})
this.setState({ docId })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
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 })
}
})
}
......@@ -89,6 +117,48 @@ export default class BOD extends Component {
a.click();
}
}
if (type === 'delete') {
this.setState({
id: this.state.docId[val],
rowData: index,
popupDel: true
})
}
if (type === 'edit') {
alert("edit")
}
}
closeAlert() {
this.setState({ alert: false })
}
deleteDoc = (payload) => {
this.setState({ popupDel: false })
api.create().deleteDocument(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' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
render() {
......@@ -119,15 +189,53 @@ export default class BOD extends Component {
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
{/* </span>} */}
{this.props.btnedit && <span>
<a data-tip={'Edit'} data-for="edit">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginRight: 15
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'edit')}
>
<img src={Images.editCopy} />
</button>
</a>
<ReactTooltip border={true} id="edit" place="bottom" type="light" effect="solid" />
</span>}
{this.props.btndelete && <span>
<a data-tip={'Delete'} data-for="delete">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'delete')}
>
<img src={Images.delete} />
</button>
</a>
<ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
</span>}
</div >
);
}
}
}, "Nama File", "Keterangan", "Perusahaan", "Periode", "Tipe", "Ukuran", "Ditambahkan Oleh", "Ditambahkan Tanggal"
}, "File Name", "Description", "Company Name", "Period", "Type", "File Size", "Created By", "Created Date"
]
return (
<div style={{ width: '100%' }}>
<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>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
......@@ -137,6 +245,16 @@ export default class BOD extends Component {
/>
</MuiThemeProvider>
</div>
{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>
)
}
......
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'
......@@ -9,6 +10,9 @@ 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 CreateManagementDoc extends Component {
constructor(props) {
super(props)
......@@ -45,7 +49,7 @@ export default class CreateManagementDoc extends Component {
}
getDataCompany() {
api.create().getPerusahaanActive().then((response) => {
api.create().getPerusahaanUserActive().then((response) => {
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
......@@ -55,10 +59,10 @@ export default class CreateManagementDoc extends Component {
company_name: item.company_name
}
})
typeData.push({
company_id: 0,
company_name: 'Default'
})
// typeData.push({
// company_id: 0,
// company_name: 'Default'
// })
let typeProps = {
options: typeData.sort((a, b) => a.company_id - b.company_id),
getOptionLabel: (option) => option.company_name,
......@@ -173,6 +177,7 @@ export default class CreateManagementDoc extends Component {
this.setState({ errorDocument: true, msgErrorDocument: 'Category Cannot be Empty' })
} else if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
// this.setState({ errorDocument: true, msgErrorDocument: 'File Cannot be Empty' })
} else {
const formData = new FormData();
formData.append("file", this.state.file);
......@@ -191,6 +196,10 @@ export default class CreateManagementDoc extends Component {
this.setState({ file: null})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
<div>
......@@ -218,9 +227,10 @@ export default class CreateManagementDoc extends Component {
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.perusahaan}
debug
// debug
clearOnEscape
id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage())}
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage(), console.log(this.state.getPerusahaan))}
renderInput={(params) =>
<TextField {...params}
error={this.state.errorPerusahaan}
......@@ -235,15 +245,15 @@ export default class CreateManagementDoc extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listPeriode}
// debug
clearOnEscape
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.clearMessage()
})}
debug
disableClearable
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params} label="Periode" margin="normal" style={{ marginTop: 7 }}
<TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>}
......@@ -255,7 +265,8 @@ export default class CreateManagementDoc extends Component {
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.document}
debug
// debug
clearOnEscape
id="tipe"
onChange={(event, newInputValue) => this.setState({ getDocument: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
......@@ -341,6 +352,11 @@ export default class CreateManagementDoc extends Component {
</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>
)
......
......@@ -22,10 +22,39 @@ export default class DocumentManagement extends Component {
this.state = {
tab: 0,
listData: [],
id: 0
id: 0,
btncreate: false,
btnedit: false,
btndelete: false,
load: false,
}
}
getPermission() {
let payload = {
menu: "document management"
}
api.create().getPermission(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
btncreate: response.data.data.create,
btnedit: response.data.data.edit,
btndelete: response.data.data.delete,
load: true
})
} else {
this.setState({
load: true
})
}
} else {
this.setState({ load: true })
}
})
}
selectTab = (event, newEvent) => {
this.setState({ tab: newEvent })
console.log(this.state.tab)
......@@ -33,6 +62,7 @@ export default class DocumentManagement extends Component {
componentDidMount() {
this.getDataDocument()
this.getPermission()
}
getDataDocument(id) {
......@@ -160,7 +190,7 @@ export default class DocumentManagement extends Component {
<button
type="button"
onClick={() => this.setState({ visibleCreate: true, refresh: '' })}
style={{ marginRight: 25 }}
style={{ marginRight: 25, background: 'transparent' }}
>
<img src={Images.add} />
</button>
......@@ -188,31 +218,43 @@ export default class DocumentManagement extends Component {
<AuditTahunan
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
btnedit={this.state.btnedit}
btndelete={this.state.btndelete}
load={this.state.load}
/>
:
this.state.id === 68541 ?
<ManualBookTia
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
btnedit={this.state.btnedit}
btndelete={this.state.btndelete}
load={this.state.load}
/>
:
this.state.id === 68544 ?
<QReview
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
btnedit={this.state.btnedit}
btndelete={this.state.btndelete}
load={this.state.load}
/>
:
this.state.id === 68543 ?
<BOD
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
btnedit={this.state.btnedit}
btndelete={this.state.btndelete}
load={this.state.load}
/>
:
this.state.id === 68545 ?
<ManualBookETMS
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
// :
// this.state.id === 68545 ?
// <ManualBookETMS
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// />
:
<span>Coming Soon</span>
......@@ -233,6 +275,7 @@ export default class DocumentManagement extends Component {
// getDataDocument={this.getDataDocument.bind(this)}
createDocument={this.createDocument.bind(this)}
setting_id={this.state.id}
btncreate={this.state.btncreate}
/>
)}
</div>
......
This diff is collapsed.
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() {
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.onClickDelete()}
>
<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>
);
}
}
......@@ -2,11 +2,12 @@ import React, { Component } from 'react'
import MUIDataTable from 'mui-datatables'
import { withStyles } from '@material-ui/core/styles';
import { createMuiTheme, MuiThemeProvider, Snackbar } from '@material-ui/core';
import api from '../../api';
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 PopUpDelete from "./PopUpDelete";
import CreateManagementDoc from './CreateManagementDoc';
......@@ -25,6 +26,7 @@ export default class QReview extends Component {
visibleCreate: false,
refresh: '',
alert: false,
popupDel: false,
}
}
......@@ -71,6 +73,12 @@ export default class QReview extends Component {
]
})
this.setState({ docPath })
let docId = response.data.data.map((item) => {
return [
item.document_id
]
})
this.setState({ docId })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
......@@ -105,12 +113,50 @@ export default class QReview extends Component {
a.click();
}
}
if (type === 'delete') {
this.setState({
id: this.state.docId[val],
rowData: index,
popupDel: true
})
}
if (type === 'edit') {
alert("edit")
}
}
closeAlert() {
this.setState({ alert: false })
}
deleteDoc = (payload) => {
this.setState({ popupDel: false })
api.create().deleteDocument(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' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
render() {
let columns = [{
name: "Action",
......@@ -120,8 +166,23 @@ export default class QReview extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
{/* {this.state.btnedit && <span> */}
<a data-tip={'Download'} data-for="download">
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginRight: 15
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'download')}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
{this.props.btnedit && <span>
<a data-tip={'Edit'} data-for="edit">
<button
style={{
backgroundColor: 'transparent',
......@@ -130,18 +191,34 @@ export default class QReview extends Component {
marginRight: 15
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'download')}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'edit')}
>
<img src={Images.editCopy} />
</button>
</a>
<ReactTooltip border={true} id="edit" place="bottom" type="light" effect="solid" />
</span>}
{this.props.btndelete && <span>
<a data-tip={'Delete'} data-for="delete">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'delete')}
>
<img src={Images.download} />
<img src={Images.delete} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
{/* </span>} */}
<ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
</span>}
</div >
);
}
}
}, "Nama File", "Keterangan", "Perusahaan", "Periode", "Tipe", "Ukuran", "Ditambahkan Oleh", "Ditambahkan Tanggal"
}, "File Name", "Description", "Company Name", "Period", "Type", "File Size", "Created By", "Created Date"
]
return (
<div style={{ width: '100%' }}>
......@@ -160,6 +237,16 @@ export default class QReview extends Component {
/>
</MuiThemeProvider>
</div>
{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>
)
}
......
......@@ -3,11 +3,33 @@ import { Typography, MuiThemeProvider, createMuiTheme } from '@material-ui/core'
import MUIDataTable from "mui-datatables";
import Images from '../assets/Images';
import DonutChart from 'react-d3-donut';
import Constant from '../library/Constant';
import api from '../api';
var ct = require("../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
class HomePage extends Component {
constructor(props) {
super(props)
this.state = {
userData: null
}
}
componentDidMount() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.data.status == 'success') {
this.setState({userData: response.data.data}, () => {
console.log(this.state.userData)
})
}
}
})
}
render() {
const columns = ["#", "Nama Perusahaan", "Revisi", "Status", {
name: "Action",
......@@ -89,7 +111,7 @@ class HomePage extends Component {
return (
<div style={{ flex: 1, backgroundColor: '#f8f8f8' }}>
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '24px', color: 'white' }}>Selamat Datang, John!</Typography>
<Typography style={{ fontSize: '24px', color: 'white' }}>{this.state.userData == null? '' : `Selamat Datang, ${this.state.userData.fullname} !`}</Typography>
</div>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div style={{ display: 'flex' }}>
......
......@@ -301,7 +301,7 @@ export default class Parameter extends Component {
setting: payload
}
console.log(resp.rows[1]);
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
this.setState({ payload: body, buttonError: false, judul: resp.rows[1] === undefined ? "" : resp.rows[1][0] })
}
});
}
......
import React, { Component } from 'react';
import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel } from '@material-ui/core';
import MUIDataTable from 'mui-datatables';
import Images from '../assets/Images';
import api from '../api';
import Images from '../../assets/Images';
import OperatingIndicatorDetail from './OperatingIndicatorDetail'
import api from '../../api';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { titleCase } from '../library/Utils';
import { titleCase } from '../../library/Utils';
import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../library/Upload";
import UploadFile from "../../library/Upload";
import { format } from 'date-fns';
export default class OperatingIndicator extends Component {
......@@ -17,14 +18,15 @@ export default class OperatingIndicator extends Component {
listRevision: null,
revision: null,
visibleOperatingIndicator: true,
visibleMB: false,
visibleDetailOpt: false,
listPeriode: null,
periode: null,
listCompany: null,
company: null,
report_id: null,
listAttachment: [],
visibleUpload: false
visibleUpload: false,
submissionID: null
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -53,25 +55,25 @@ export default class OperatingIndicator extends Component {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
"report_type": "Operating Indicator",
"report_type": "operating indicator",
}
api.create().getReportTypeBody(payload).then(response => {
// console.log(response);
api.create().getAllOperatingInd(payload).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
let dataTable = response.data.data.map((item, index) => {
return [
item.number,
item.report_name,
item.revision,
// item.revision,
item.current_status,
item.report_id,
item.is_can_upload,
item.revision
// item.revision
]
})
// console.log(dataTable);
this.setState({ dataTable })
this.setState({ dataTable, dataReport: response.data.data})
}
}
})
......@@ -118,7 +120,8 @@ export default class OperatingIndicator extends Component {
};
let index = data.sort((a, b) => a - b).findIndex((val) => val == year)
this.setState({ listPeriode: defaultProps, periode: index == -1 ? periodeData[0] : periodeData[index] }, () => {
this.getRevision()
this.getReport()
this.getSubmission()
})
}
}
......@@ -153,14 +156,31 @@ export default class OperatingIndicator extends Component {
})
}
getSubmission() {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode
}
api.create().getSubmission(payload).then(response => {
if (response) {
if (response.data.data) {
this.setState({ submissionID: response.data.data.submission_id })
} else {
this.setState({ submissionID: null })
}
}
})
}
clickDetail(item, id) {
this.setState({ report_id: id })
if (item === 'Master Budget') {
let index = this.state.dataReport.findIndex((val) => val.report_name == item[1])
if (index !== -1) {
this.setState({
dataDetail: {...this.state.dataReport[index], periode: this.state.periode.periode, submissionID: this.state.submissionID, company: this.state.company},
visibleOperatingIndicator: false,
visibleMB: true,
visibleDetailOpt: true,
})
}
}
}
handleChange(value, tableMeta) {
......@@ -266,7 +286,7 @@ export default class OperatingIndicator extends Component {
borderColor: 'transparent'
}}
onClick={() =>
tableMeta.rowData[5] ? this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4]) : null
tableMeta.rowData[4] ? this.clickDetail(tableMeta.rowData) : null
}
>
<Typography style={{ color: tableMeta.rowData[5] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography>
......@@ -282,23 +302,6 @@ export default class OperatingIndicator extends Component {
name: "",
options: { display: false }
}]
const dataTable = [
["1", "Balance Sheet", "done"],
["2", "Profit & Loss", ""],
["3", "CAT", "done"],
["4", "Fixed Assets Movement", ""],
["5", "Tax Planning", "done"],
["6", "Balance Sheet", "done"],
["7", "Profit & Loss", ""],
["8", "CAT", "done"],
["9", "Fixed Assets Movement", ""],
["10", "Tax Planning", "done"],
["11", "Balance Sheet", "done"],
["12", "Profit & Loss", "done"],
["13", "CAT", "done"],
["14", "Fixed Assets Movement", "done"],
["15", "Tax Planning", "done"],
]
const options = {
filter: false,
sort: false,
......@@ -349,7 +352,8 @@ export default class OperatingIndicator extends Component {
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue }, () => {
this.getReport()
this.getReportAttachment()
this.getSubmission()
// this.getReportAttachment()
})}
debug
disableClearable
......@@ -364,7 +368,8 @@ export default class OperatingIndicator extends Component {
id="company"
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => {
this.getReport()
this.getReportAttachment()
this.getSubmission()
// this.getReportAttachment()
})}
debug
disableClearable
......@@ -396,7 +401,7 @@ export default class OperatingIndicator extends Component {
options={options}
/>
</div>
<div style={{ display: 'flex', marginTop: 20 }}>
{/* <div style={{ display: 'flex', marginTop: 20 }}>
<div style={{ width: '50%' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
</div>
......@@ -435,7 +440,7 @@ export default class OperatingIndicator extends Component {
: null
}
</div>
</div>
</div> */}
</div>
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
......@@ -448,6 +453,15 @@ export default class OperatingIndicator extends Component {
</div>
)}
{this.state.visibleDetailOpt &&
<OperatingIndicatorDetail
data={this.state.dataDetail}
height={this.props.height}
width={this.props.width}
onClickClose={() => this.setState({ visibleDetailOpt: false, visibleOperatingIndicator: true }, this.forceUpdate())}
/>
}
{this.state.visibleUpload && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ import ReportItems from '../container/MasterData/ReportItems'
import DashboardCAT from '../container/Laporan/DashboardCAT'
import BudgetTahunan from '../container/BudgetTahunan';
import RollingOutlook from '../container/RollingOutlook';
import OperatingIndicator from '../container/OperatingIndicator'
import OperatingIndicator from '../container/OprIndicator/OperatingIndicator'
import MonthlyReport from '../container/MonthlyReport';
import DocumentManagement from '../container/DocumentManagement/DocumentManagement';
......
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