Browse Source

add company in table

pull/1/head
wahyun 12 months ago
parent
commit
3f13eac471
  1. 113
      src/views/Master/MasterRoles/index.js
  2. 145
      src/views/Master/RoleProject/index.js
  3. 18
      src/views/SimproV2/Presence/index.js
  4. 47
      src/views/SimproV2/ResourceWorker/index.js

113
src/views/Master/MasterRoles/index.js

@ -16,26 +16,7 @@ const LENGTH_DATA = 10
class index extends Component { class index extends Component {
constructor(props) { constructor(props) {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
super(props) super(props)
this.config = {
headers: {
Authorization: `Bearer ${token}`,
"Content-type": "application/json"
}
};
this.state = { this.state = {
alertDelete: false, alertDelete: false,
alertNotDelete: false, alertNotDelete: false,
@ -61,8 +42,21 @@ class index extends Component {
tooltipTambah: false, tooltipTambah: false,
totalPage: 0, totalPage: 0,
typeDialog: 'Save', typeDialog: 'Save',
company_id: company_id, company_id: props.company_id || 0,
role_name: role_name role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
} }
this.columns = [ this.columns = [
{ {
@ -84,6 +78,16 @@ class index extends Component {
</Tooltip> </Tooltip>
</>, </>,
}, },
{
title: this.state.role_name === 'Super Admin' ? "Company Name" : null,
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => {
return this.state.role_name === 'Super Admin' ? (
<span>{record.join_first_company_name}</span>
) : null;
}
},
{ title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' },
] ]
@ -114,9 +118,18 @@ class index extends Component {
const formData = { const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage }, "paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }, group_column: {
], "operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
@ -128,9 +141,15 @@ class index extends Component {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, this.config) .post(ROLE_SEARCH, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -347,18 +366,42 @@ class index extends Component {
handleExportExcel = async () => { handleExportExcel = async () => {
let start = 0; let start = 0;
let end = "ALL";
const formData = { const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage }, "paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } "group_column": {
], "operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
} else {
formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, this.config) .post(ROLE_SEARCH, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -366,10 +409,12 @@ class index extends Component {
const dataRes = result.data.data || []; const dataRes = result.data.data || [];
const dataExport = []; const dataExport = [];
dataRes.map((val, index) => { dataRes.map((val, index) => {
let row = { let row = {};
Nama: val.name, if (this.state.role_name === 'Super Admin') {
Deskripsi: val.description row.Company = val.join_first_company_name;
} }
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row); dataExport.push(row);
}) })
this.setState({ dataExport: dataExport }, () => { this.setState({ dataExport: dataExport }, () => {
@ -445,7 +490,7 @@ class index extends Component {
<h4>{this.props.params.name}</h4> <h4>{this.props.params.name}</h4>
<Row> <Row>
<Col> <Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('searchRoles')} /> <Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('search')} />
</Col> </Col>
<Col> <Col>
<Tooltip title={this.props.t('rolesAdd')}> <Tooltip title={this.props.t('rolesAdd')}>

145
src/views/Master/RoleProject/index.js

@ -9,46 +9,10 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js'; import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js';
import { Pagination, Tooltip, Table } from 'antd'; import { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const company_id = localStorage.getItem("company_id")
const role_name = window.localStorage.getItem('role_name');
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const momentFormat = 'HH:mm';
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
]
const LENGTH_DATA = 10 const LENGTH_DATA = 10
class index extends Component { class index extends Component {
constructor(props) { constructor(props) {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; super(props);
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
super(props)
this.state = { this.state = {
alertDelete: false, alertDelete: false,
alertNotDelete: false, alertNotDelete: false,
@ -74,9 +38,23 @@ class index extends Component {
tooltipTambah: false, tooltipTambah: false,
totalPage: 0, totalPage: 0,
typeDialog: 'Save', typeDialog: 'Save',
company_id: company_id, company_id: props.company_id || 0,
role_name: role_name role_name: props.role_name || '',
role_id: props.role_id || 0,
user_id: props.user_id || 0,
isLogin: props.isLogin || false,
token: props.token || '',
all_project: props.all_project || null,
hierarchy: props.hierarchy || [],
user_name: props.user_name || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
} }
}
};
this.columns = [ this.columns = [
{ {
title: this.props.t('action'), title: this.props.t('action'),
@ -86,21 +64,27 @@ class index extends Component {
render: (text, record) => <> render: (text, record) => <>
<Tooltip title={this.props.t('delete')}> <Tooltip title={this.props.t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i> <i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
</Tooltip> </Tooltip>
<Tooltip title={this.props.t('edit')}> <Tooltip title={this.props.t('edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i> <i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
</Tooltip> </Tooltip>
</>, </>,
}, },
{
title: this.state.role_name === 'Super Admin' ? "Company Name" : null,
dataIndex: "join_first_company_name",
key: "join_first_company_name",
render: (text, record) => {
return this.state.role_name === 'Super Admin' ? (
<span>{record.join_first_company_name}</span>
) : null;
}
},
{ title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' },
]; ];
} }
async componentDidMount() { async componentDidMount() {
this.getDataRoles(); this.getDataRoles();
} }
@ -123,9 +107,18 @@ class index extends Component {
const formData = { const formData = {
"paging": { "start": start, "length": this.state.rowsPerPage }, "paging": { "start": start, "length": this.state.rowsPerPage },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }, group_column: {
], "operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
@ -137,9 +130,15 @@ class index extends Component {
formData.columns.push( formData.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
formData.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
formData.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
.post(PROJECT_ROLE_SEARCH, formData, config) .post(PROJECT_ROLE_SEARCH, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -184,7 +183,7 @@ class index extends Component {
const { idDelete } = this.state const { idDelete } = this.state
const url = PROJECT_ROLE_DELETE(idDelete) const url = PROJECT_ROLE_DELETE(idDelete)
const result = await axios.delete(url, config) const result = await axios.delete(url, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -203,10 +202,10 @@ class index extends Component {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description, description: data.description,
company_id company_id: this.state.company_id
} }
const result = await axios.post(PROJECT_ROLE_ADD, formData, config) const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -224,10 +223,10 @@ class index extends Component {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description, description: data.description,
company_id company_id : this.state.company_id
} }
const url = PROJECT_ROLE_EDIT(data.id) const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, config) const result = await axios.put(url, formData, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -290,24 +289,50 @@ class index extends Component {
handleExportExcel = async () => { handleExportExcel = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } "group_column": {
], "operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "name",
"logic_operator": "~*",
"value": this.state.search,
}
]
},
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
if (this.state.role_name !== "Super Admin") {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
} else {
payload.columns.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
payload.joins.push(
{ "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" }
)
}
const result = await axios const result = await axios
.post(PROJECT_ROLE_SEARCH, payload, config) .post(PROJECT_ROLE_SEARCH, payload, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.statusText == "OK") { if (result && result.data && result.statusText == "OK") {
const dataRes = result.data.data || []; const dataRes = result.data.data || [];
const dataExport = []; const dataExport = [];
dataRes.map((val, index) => { dataRes.map((val, index) => {
let row = { let row = {};
Nama: val.name, if (this.state.role_name === 'Super Admin') {
Deskripsi: val.description row.Company = val.join_first_company_name;
} }
row.Nama = val.name;
row.Deskripsi = val.description;
dataExport.push(row); dataExport.push(row);
}) })
this.setState({ dataExport: dataExport }, () => { this.setState({ dataExport: dataExport }, () => {
@ -371,7 +396,7 @@ class index extends Component {
<h4>{this.props.params.name}</h4> <h4>{this.props.params.name}</h4>
<Row> <Row>
<Col> <Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('searchProjectRoles')} /> <Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('search')} />
</Col> </Col>
<Col> <Col>
<Tooltip title={this.props.t('rolesAdd')}> <Tooltip title={this.props.t('rolesAdd')}>

18
src/views/SimproV2/Presence/index.js

@ -10,10 +10,22 @@ import { PRESENCE_SEARCH, IMAGE_GET_BY_ID } from '../../../const/ApiConst.js';
import DialogFoto from './DialogFoto'; import DialogFoto from './DialogFoto';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const token = window.localStorage.getItem('token');
const Index = ({ params,...props }) => {
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='';
if (props && props.role_id && props.user_id) {
role_id = props.role_id;
user_id = props.user_id;
token = props.token;
isLogin = props.isLogin;
company_id = props.company_id;
all_project = props.all_project;
role_name = props.role_name;
isLogin = props.isLogin;
hierarchy = props.hierarchy;
user_name = props.user_name;
}
const Index = ({ params }) => {
const [dataTable, setDatatable] = useState([]) const [dataTable, setDatatable] = useState([])
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1) const [currentPage, setCurrentPage] = useState(1)
@ -54,8 +66,6 @@ const Index = ({ params }) => {
}; };
const getDataPresence = async () => { const getDataPresence = async () => {
let start = 0; let start = 0;
if (currentPage !== 1 && currentPage > 1) { if (currentPage !== 1 && currentPage > 1) {

47
src/views/SimproV2/ResourceWorker/index.js

@ -230,7 +230,10 @@ const ResourceWorker = ({ params, ...props }) => {
} else { } else {
payload.group_column.where.push( payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) );
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
);
} }
const result = await axios const result = await axios
@ -352,6 +355,19 @@ const ResourceWorker = ({ params, ...props }) => {
"ascending": false "ascending": false
} }
} }
if (role_name !== "Super Admin") {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
)
} else {
payload.group_column.where.push(
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
);
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
);
}
const result = await axios const result = await axios
.post(USER_SEARCH, payload, HEADER) .post(USER_SEARCH, payload, HEADER)
.then(res => res) .then(res => res)
@ -361,14 +377,16 @@ const ResourceWorker = ({ params, ...props }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((n, index) => { resData.map((n, index) => {
let dataRow = { let dataRow = {};
"NIK (Nomor Induk Karyawan)": n.ktp_number, if (role_name === 'Super Admin') {
"Employee Name": n.name, dataRow.Company = n.join_third_company_name;
"Divisi": n.join_second_name, }
"Employee Type": n.employee_type, dataRow["NIK (Nomor Induk Karyawan)"] = n.ktp_number;
"Role": n.join_first_name, dataRow["Employee Name"] = n.name;
"Phone No": n.phone_number, dataRow["Divisi"] = n.join_second_name;
} dataRow["Employee Type"] = n.employee_type;
dataRow.Role = n.join_first_name;
dataRow["Phone No"] = n.phone_number;
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
@ -521,7 +539,16 @@ const ResourceWorker = ({ params, ...props }) => {
</Tooltip> </Tooltip>
</>, </>,
}, },
{
title: role_name === 'Super Admin' ? "Company Name" : null,
dataIndex: "join_third_company_name",
key: "join_third_company_name",
render: (text, record) => {
return role_name === 'Super Admin' ? (
<span>{record.join_third_company_name}</span>
) : null;
}
},
{ title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' }, { title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' },
{ title: t('nameHR'), dataIndex: 'name', key: 'name' }, { title: t('nameHR'), dataIndex: 'name', key: 'name' },
{ title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' }, { title: t('division'), dataIndex: 'join_second_name', key: 'join_second_name' },

Loading…
Cancel
Save