Commit 7fd05354 authored by d.arizona's avatar d.arizona

update

parent 2cb7103e
......@@ -312,6 +312,9 @@ const create = (type = "") => {
const uploadMonthlyReportLOCF = (body) => api.post('transaction/locf/monthly_report/import_monthly_report', body)
const validateSubmitReportOI = (body) => api.post('transaction/operating_indicator/monthly_report/validate_save', body)
const getListUserSubcoMB = (periode) => api.get(`transaction/get_dashboard_sub_co/master_budget/${periode}`)
const getListUserSubcoMR = (months,periode) => api.get(`transaction/get_dashboard_sub_co/monthly_report/${periode}/${months}`)
// MonthlyPL
// const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body)
// const createMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/create_monthly_report', body)
......@@ -561,7 +564,9 @@ const create = (type = "") => {
deleteAllItemReportLOCF,
submitMonthlyReport,
approvalMonthly,
createPeriodeRevisionMonthly
createPeriodeRevisionMonthly,
getListUserSubcoMB,
getListUserSubcoMR
}
}
......
import React, { Component } from 'react';
import { Typography, MuiThemeProvider, createMuiTheme, Paper } from '@material-ui/core';
import { Typography, MuiThemeProvider, createMuiTheme, Paper, TextField} from '@material-ui/core';
import MUIDataTable from "mui-datatables";
import Images from '../assets/Images';
import DonutChart from 'react-d3-donut';
......@@ -9,6 +9,7 @@ import { Link } from 'react-router-dom';
import { PropagateLoader } from 'react-spinners';
import { titleCase } from '../library/Utils';
import { format } from 'date-fns';
import Autocomplete from '@material-ui/lab/Autocomplete';
var ct = require("../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
......@@ -31,6 +32,12 @@ class HomePage extends Component {
valueSubmit: 0,
listdmb: [],
dataTableMB: [],
listPeriodeMB: null,
listPeriodeMR: null,
listMonth: null,
periodeMB: null,
periodeMR: null,
month: null,
loading: false,
accessMB: false,
accessMR: false,
......@@ -61,9 +68,10 @@ class HomePage extends Component {
this.getPermissionMB()
this.getPermissionMR()
this.getApprMat()
this.getListUserSubco()
// this.getListUserSubco()
this.getDashboardMB()
this.getDashboard()
this.getMonth()
}
componentDidUpdate() {
......@@ -73,12 +81,94 @@ class HomePage extends Component {
}
}
getPeriode() {
let currentYear = new Date().getFullYear()
let MB = []
let MR = []
for(var i=2000;i<=currentYear; i++) {
MB.push({name: String(i), value: i})
MR.push({name: String(i), value: i})
if (i == currentYear) {
MB.push({name: String(i+1), value: i+1})
}
}
let defaultPropsMB = {
options: MB,
getOptionLabel: (option) => option.name,
};
let defaultPropsMR = {
options: MR,
getOptionLabel: (option) => option.name,
};
this.setState({listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[MR.length - 1]}, () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
})
}
getMonth() {
api.create().getMonthTransaction().then(response => {
let dateNow = new Date
let month = format(dateNow, 'MMMM')
// console.log(response);
if (response.data) {
if (response.data.status === "success") {
// console.log(response);
let data = response.data.data
let monthData = data.map((item) => {
return {
month_id: item.id,
month_value: String(item.month_name).substr(0, 3)
}
})
let defaultProps = {
options: monthData,
getOptionLabel: (option) => option.month_value,
};
let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == month)
// console.log(month)
// console.log(index)
this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => {
// if (this.state.isApprover === true) {
// if (this.state.submittedOnly) {
// console.log('masuk cuk')
// this.getPeriode()
// } else {
// this.getLastPeriod()
// }
this.getPeriode()
// } else {
// this.getLastPeriod()
// this.getPeriode()
// }
})
} 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' })
}
})
}
getPermissionMB() {
let payload = {
menu: "Master Budget & CAT"
}
api.create().getPermission(payload).then(response => {
console.log(response)
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
......@@ -106,7 +196,7 @@ class HomePage extends Component {
menu: "monthly report"
}
api.create().getPermission(payload).then(response => {
console.log(response)
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
......@@ -129,9 +219,64 @@ class HomePage extends Component {
})
}
getListUserSubcoMB() {
// console.log(this.state.month.month_id)
// console.log(this.state.periodeMR.value)
api.create().getListUserSubcoMB(this.state.periodeMB.value).then((response) => {
// console.log(response)
let valueSubmit = 0
let dataMB = []
if (response.data) {
if (response.data.status === "success") {
response.data.data.map((item, index) => {
if (item.is_submit === true) {
valueSubmit += 1
}
dataMB.push(item)
})
this.setState({
listSubcoMB: dataMB,
valueSubmit,
loading: false
})
}
} else {
this.setState({loading: false})
}
})
}
getListUserSubcoMR() {
// console.log(this.state.month.month_id)
// console.log(this.state.periodeMR.value)
api.create().getListUserSubcoMR(this.state.month.month_id, this.state.periodeMR.value).then((response) => {
let valueSubmitMR = 0
let dataMR = []
// console.log(response)
if (response.data) {
if (response.data.status === "success") {
response.data.data.map((item, index) => {
if (item.is_submit === true ) {
valueSubmitMR += 1
}
dataMR.push(item)
})
this.setState({
listSubcoMR: dataMR,
valueSubmitMR,
loading: false
})
}
} else {
this.setState({loading: false})
}
})
}
getListUserSubco() {
api.create().getDashboardUser().then(response => {
console.log(response);
// console.log(response);
let valueSubmit = 0
let valueSubmitMR = 0
let dataMB = []
......@@ -160,8 +305,8 @@ class HomePage extends Component {
})
}
}
console.log(this.state.listSubcoMB)
console.log(this.state.listSubcoMR)
// console.log(this.state.listSubcoMB)
// console.log(this.state.listSubcoMR)
})
}
......@@ -169,7 +314,7 @@ class HomePage extends Component {
let listDashboard = []
let rawData = []
api.create().getDashboard().then((response) => {
console.log(response);
// console.log(response);
if (String(response.data.status).toLocaleLowerCase() == 'success') {
let data = response.data.data
data.map((item, index) => {
......@@ -199,7 +344,7 @@ class HomePage extends Component {
let isApproverMR = false
let isApproverMB = false
api.create().getAM().then((response) => {
console.log(response);
// console.log(response);
let actAMActive = []
let actAM = response.data.data.map((item, index) => {
if (String(item.status).toLocaleLowerCase() == 'active') {
......@@ -208,7 +353,7 @@ class HomePage extends Component {
}
})
let userId = localStorage.getItem(Constant.USER)
console.log(userId);
// console.log(userId);
let indexId = actAMActive.findIndex((val) => val.user_id == userId)
actAMActive.map((item, index) => {
if (item.approval_type_name === "MONTHLY_REPORT"){
......@@ -220,7 +365,8 @@ class HomePage extends Component {
if (indexId === -1) {
this.setState({ isApprover: false })
this.getListUserSubco()
this.getMonth()
// this.getListUserSubco()
}
this.setState({ isApproverMB, isApproverMR})
this.getDashboardMB()
......@@ -231,7 +377,7 @@ class HomePage extends Component {
getDashboardMB() {
api.create().getDashboardMB().then((response) => {
console.log(response)
// console.log(response)
if (String(response.data.status).toLocaleLowerCase() == 'success') {
let data = response.data.data
let listdmb = data.sort((a, b) => a.company_id - b.company_id).map((item, index) => {
......@@ -257,7 +403,7 @@ class HomePage extends Component {
name: "Action",
options: {
customBodyRender: (val, tableMeta) => {
console.log(tableMeta);
// console.log(tableMeta);
return (
<div style={{ display: 'flex' }}>
<Link to={{
......@@ -519,7 +665,7 @@ class HomePage extends Component {
<Typography style={{ fontSize: '24px', color: 'white' }}>{this.state.userData === null ? '' : `Welcome, ${this.state.userData.fullname} !`}</Typography>
</div>
{(this.state.accessMB || this.state.accessMR) &&
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div style={{ flex: 1, paddingLeft: 20, paddingRight: 20, paddingTop: 20, paddingBottom: 0, width: '100%' }}>
<div style={{ display: 'flex' }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Tasks to be Complete</Typography>
</div>
......@@ -535,7 +681,26 @@ class HomePage extends Component {
<div style={{ display: 'inline-flex' }}>
{this.state.accessMB &&
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ width: 450, padding: 20, borderRadius: 10 }}>
<div style={{ display: 'flex' }}>
<Autocomplete
{...this.state.listPeriodeMB}
id="periodeMB"
onChange={(event, newInputValue) => this.setState({ periodeMB: newInputValue, loading: true }, () => {
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }\
this.getListUserSubcoMB()
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Periode MB" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.periodeMB}
/>
</div>
<Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5 }}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Master Budget ${this.state.valueSubmit}/${this.state.listSubcoMB.length}`}</Typography>
{this.state.listSubcoMB.map((item, index) => {
return (
......@@ -574,7 +739,42 @@ class HomePage extends Component {
}
{this.state.accessMR &&
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ width: 450, padding: 20, borderRadius: 10 }}>
<div style={{ display: 'flex' }}>
<Autocomplete
{...this.state.listMonth}
id="month"
onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }
})}
disableClearable
style={{ minWidth: 250, marginRight: 20 }}
renderInput={(params) => <TextField {...params} label="Month" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.month}
/>
<Autocomplete
{...this.state.listPeriodeMR}
id="periodeMR"
onChange={(event, newInputValue) => this.setState({ periodeMR: newInputValue, loading: true }, () => {
this.getListUserSubcoMR()
// if (this.state.isApprover === true) {
// this.getCompanySubmitted()
// } else {
// this.setState({ visibleTableHistory: false })
// this.getRevision()
// }
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Periode MR" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.periodeMR}
/>
</div>
<Paper style={{ width: 450, padding: 20, borderRadius: 10, marginTop: 5}}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Monthly Report - ${bulan} ${tahun} ${this.state.valueSubmitMR}/${this.state.listSubcoMR.length}`}</Typography>
{this.state.listSubcoMR.map((item, index) => {
return (
......
......@@ -1050,12 +1050,14 @@ export default class MonthlyReport extends Component {
cursor: tableMeta.rowData[5] ? 'pointer' : 'default',
borderColor: 'transparent'
}}
onClick={() =>{
onClick={() =>
// {
tableMeta.rowData[5] ?
this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
console.log(tableMeta.rowData)
}
// tableMeta.rowData[5] ?
// : null
: null
// console.log(tableMeta.rowData)
// }
}
>
<Typography style={{ color: tableMeta.rowData[5] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography>
......
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