Browse Source

Add column in page presensi and Icon Action

pull/2/head
farhan048 2 years ago
parent
commit
643f6258b3
  1. 100
      src/views/Master/MasterRoles/index.js
  2. 4
      src/views/Master/RoleProject/index.js
  3. 8
      src/views/SimproV2/Divisi/index.js
  4. 228
      src/views/SimproV2/Presence/index.js
  5. 8
      src/views/SimproV2/Satuan/index.js

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

@ -17,8 +17,8 @@ const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
const config = { const config = {
headers: headers:
{ {
Authorization : `Bearer ${token}`, Authorization: `Bearer ${token}`,
"Content-type" : `application/json` "Content-type": `application/json`
} }
}; };
@ -34,24 +34,24 @@ export default class index extends Component {
alertNotDelete: false, alertNotDelete: false,
currentPage: 1, currentPage: 1,
dataEdit: null, dataEdit: null,
dataExport:[], dataExport: [],
dataGs: [], dataGs: [],
dataIdHo: [], dataIdHo: [],
dataTable: [], dataTable: [],
dialogMenuForm: false, dialogMenuForm: false,
idDelete: 0, idDelete: 0,
idRoles:0, idRoles: 0,
menuRoles:[], menuRoles: [],
openDialog: false, openDialog: false,
page: 0, page: 0,
rowsPerPage: LENGTH_DATA, rowsPerPage: LENGTH_DATA,
search: "", search: "",
tooltipDelete: false, tooltipDelete: false,
tooltipEdit: false, tooltipEdit: false,
tooltipExport:false, tooltipExport: false,
tooltipImport:false, tooltipImport: false,
tooltipMenu: false, tooltipMenu: false,
tooltipTambah:false, tooltipTambah: false,
totalPage: 0, totalPage: 0,
typeDialog: 'Save', typeDialog: 'Save',
} }
@ -61,22 +61,22 @@ export default class index extends Component {
title: 'Action', title: 'Action',
dataIndex: '', dataIndex: '',
key: 'x', key: 'x',
className:'nowrap', className: 'nowrap',
render: (text, record) => <> render: (text, record) => <>
<Tooltip title="Roles Menu"> <Tooltip title="Roles Menu">
<i className="cil-menu fa-lg" style={{ color: 'green', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleMenuRoles(text.id)}></i> <i className="cil-menu" style={{ color: 'green', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleMenuRoles(text.id)}></i>
</Tooltip> </Tooltip>
<Tooltip title="Hapus"> <Tooltip title="Hapus">
<i className="cil-trash fa-lg" 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="Edit"> <Tooltip title="Edit">
<i className="fa fa-edit fa-lg" 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: 'Nama Role', dataIndex: 'name', key: 'name', className:"nowrap" }, { title: 'Nama Role', dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: 'Description', dataIndex: 'description', key: 'description' }, { title: 'Description', dataIndex: 'description', key: 'description' },
] ]
} }
@ -102,12 +102,12 @@ export default 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"} { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" }
], ],
"joins": [], "joins": [],
"orders": {"columns": ["id"], "ascending": false} "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
@ -115,9 +115,9 @@ export default class index extends Component {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.data && result.data.code == 200){ if (result && result.data && result.data.code == 200) {
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord }); this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord });
}else{ } else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
} }
} }
@ -142,7 +142,7 @@ export default class index extends Component {
} }
handleCloseDialogMr = (type, data) => { handleCloseDialogMr = (type, data) => {
if(type==="save"){ if (type === "save") {
this.saveMenuRoles(data) this.saveMenuRoles(data)
} }
this.setState({ dialogMenuForm: false }) this.setState({ dialogMenuForm: false })
@ -174,15 +174,15 @@ export default class index extends Component {
saveRole = async (data) => { saveRole = async (data) => {
const formData = { const formData = {
name:data.name, name: data.name,
description:data.description description: data.description
} }
const result = await axios.post(ROLE_ADD, formData, config) const result = await axios.post(ROLE_ADD, formData, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.data && result.data.code===200){ if (result && result.data && result.data.code === 200) {
this.getDataRoles(); this.getDataRoles();
NotificationManager.success(`Data role berhasil ditambah`, 'Success!!'); NotificationManager.success(`Data role berhasil ditambah`, 'Success!!');
} else { } else {
@ -193,15 +193,15 @@ export default class index extends Component {
editRole = async (data) => { editRole = async (data) => {
const formData = { const formData = {
name:data.name, name: data.name,
description:data.description description: data.description
} }
const url = ROLE_EDIT(data.id) const url = ROLE_EDIT(data.id)
const result = await axios.put(url, formData, config) const result = await axios.put(url, formData, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.data && result.data.code===200){ if (result && result.data && result.data.code === 200) {
this.getDataRoles(); this.getDataRoles();
NotificationManager.success(`Data role berhasil diedit`, 'Success!!'); NotificationManager.success(`Data role berhasil diedit`, 'Success!!');
} else { } else {
@ -236,17 +236,17 @@ export default class index extends Component {
this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit })) this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit }))
} else if (param === "delete") { } else if (param === "delete") {
this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete })) this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete }))
} else if(param === "menu"){ } else if (param === "menu") {
this.setState(prevState => ({ tooltipMenu: !prevState.tooltipMenu })) this.setState(prevState => ({ tooltipMenu: !prevState.tooltipMenu }))
} else if (param === "tambah") { } else if (param === "tambah") {
this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah })) this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah }))
} else if (param === "export") { } else if (param === "export") {
this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport })) this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport }))
} }
} }
dataNotAvailable = () => { dataNotAvailable = () => {
if(this.state.dataTable.length===0){ if (this.state.dataTable.length === 0) {
return ( return (
<tr> <tr>
<td align="center" colSpan="3">Not Data Available</td> <td align="center" colSpan="3">Not Data Available</td>
@ -257,12 +257,12 @@ export default class index extends Component {
handleMenuRoles = async (id) => { handleMenuRoles = async (id) => {
const formData = { const formData = {
"paging": {"start": 0, "length": -1}, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [
{"name": "role_id", "logic_operator": "=", "value": `${id}`, "operator": "AND"} { "name": "role_id", "logic_operator": "=", "value": `${id}`, "operator": "AND" }
], ],
"joins": [], "joins": [],
"orders": {"columns": ["id"], "ascending": false} "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
@ -270,7 +270,7 @@ export default class index extends Component {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
this.setState({ menuRoles:result.data.data,idRoles:id },() => { this.setState({ menuRoles: result.data.data, idRoles: id }, () => {
this.handleOpenDialogMr(); this.handleOpenDialogMr();
}); });
} else { } else {
@ -279,16 +279,16 @@ export default class index extends Component {
saveMenuRoles = async (dataArray) => { saveMenuRoles = async (dataArray) => {
let payloadArray = dataArray || [] let payloadArray = dataArray || []
if(payloadArray.length > 0){ if (payloadArray.length > 0) {
await this.deleteCurrentRoleMenu(payloadArray[0].roles_id) await this.deleteCurrentRoleMenu(payloadArray[0].roles_id)
} }
let promises = [] let promises = []
let result = [] let result = []
dataArray.map((val, index)=> { dataArray.map((val, index) => {
if(val.checked===true){ if (val.checked === true) {
const formData = { const formData = {
menu_id:val.menu_id, menu_id: val.menu_id,
role_id:val.roles_id role_id: val.roles_id
} }
promises.push(axios.post(ROLEMENU_ADD, formData, config) promises.push(axios.post(ROLEMENU_ADD, formData, config)
.then(res => result.push(res))) .then(res => result.push(res)))
@ -296,8 +296,8 @@ export default class index extends Component {
}) })
await Promise.all(promises); await Promise.all(promises);
if(result){ if (result) {
if(result.length > 0){ if (result.length > 0) {
if (result[0].data.code === 200) { if (result[0].data.code === 200) {
this.getDataRoles(); this.getDataRoles();
NotificationManager.success('Data roles berhasil ditambahkan!!', 'Success!!'); NotificationManager.success('Data roles berhasil ditambahkan!!', 'Success!!');
@ -326,24 +326,24 @@ export default class index extends Component {
let url = BASE_URL + "roles.php?act=get_data"; let url = BASE_URL + "roles.php?act=get_data";
const formData = new FormData(); const formData = new FormData();
formData.append('field', 'name'); formData.append('field', 'name');
if(this.state.search !== ""){ if (this.state.search !== "") {
formData.append('value', this.state.search); formData.append('value', this.state.search);
} }
const result = await axios const result = await axios
.post(url,formData) .post(url, formData)
.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, Nama: val.name,
Deskripsi:val.description Deskripsi: val.description
} }
dataExport.push(row); dataExport.push(row);
}) })
this.setState({ dataExport:dataExport },()=> { this.setState({ dataExport: dataExport }, () => {
this.exportExcel(); this.exportExcel();
}); });
} else { } else {
@ -361,7 +361,7 @@ export default class index extends Component {
} }
render() { render() {
const { tooltipTambah,tooltipExport,dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete,tooltipMenu } = this.state const { tooltipTambah, tooltipExport, dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state
let noSeq = 0; let noSeq = 0;
return ( return (
<div> <div>
@ -385,7 +385,7 @@ export default class index extends Component {
confirmBtnText="Can't Delete" confirmBtnText="Can't Delete"
confirmBtnBsStyle="danger" confirmBtnBsStyle="danger"
title="Data can't be delete!" title="Data can't be delete!"
onConfirm={() => this.setState({ alertNotDelete: false})} onConfirm={() => this.setState({ alertNotDelete: false })}
> >
Data tipe roles tidak dapat di hapus!! Data tipe roles tidak dapat di hapus!!
</SweetAlert> </SweetAlert>
@ -417,7 +417,7 @@ export default class index extends Component {
<Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> <Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title="Export Excel"> <Tooltip title="Export Excel">
<Button style={{marginLeft:"5px"}} id="TooltipExport" color="primary" onClick={()=> this.handleExportExcel()}><i className="fa fa-print"></i></Button> <Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip> </Tooltip>
</Col> </Col>
</Row> </Row>
@ -432,7 +432,7 @@ export default class index extends Component {
bordered={false} bordered={false}
/> />
<Pagination <Pagination
style={{marginTop:"25px"}} style={{ marginTop: "25px" }}
showSizeChanger showSizeChanger
onShowSizeChange={this.onShowSizeChange} onShowSizeChange={this.onShowSizeChange}
onChange={this.onPagination} onChange={this.onPagination}

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

@ -69,12 +69,12 @@ export default class index extends Component {
className: 'nowrap', className: 'nowrap',
render: (text, record) => <> render: (text, record) => <>
<Tooltip title="Hapus"> <Tooltip title="Hapus">
<i className="cil-trash fa-lg" 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="Edit"> <Tooltip title="Edit">
<i className="fa fa-edit fa-lg" 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>
</>, </>,
}, },

8
src/views/SimproV2/Divisi/index.js

@ -5,7 +5,7 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import moment from 'moment' import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH} from '../../../const/ApiConst'; import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH } from '../../../const/ApiConst';
import { DownloadOutlined } from '@ant-design/icons'; import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip } from 'antd';
@ -67,7 +67,7 @@ const ProjectType = ({ params }) => {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (listDivions&& listDivions.data && listDivions.data.code == 200) { if (listDivions && listDivions.data && listDivions.data.code == 200) {
let arr = [] let arr = []
for (const v in listDivions.data.data) { for (const v in listDivions.data.data) {
arr.push(listDivions.data.data[v]) arr.push(listDivions.data.data[v])
@ -274,10 +274,10 @@ const ProjectType = ({ params }) => {
<tr key={n.id}> <tr key={n.id}>
<td className='nowrap'> <td className='nowrap'>
<Tooltip title="Hapus"> <Tooltip title="Hapus">
<i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i> <i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i>
</Tooltip> </Tooltip>
<Tooltip title="Edit"> <Tooltip title="Edit">
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
<td>{n.displayName}</td> <td>{n.displayName}</td>

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

@ -12,7 +12,7 @@ const { RangePicker } = DatePicker;
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
const Index = ({params}) => { 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)
@ -27,23 +27,23 @@ const Index = ({params}) => {
const pageName = params.name; const pageName = params.name;
const config = { const config = {
headers: headers:
{ {
Authorization : `Bearer ${token}`, Authorization: `Bearer ${token}`,
"Content-type" : `application/json` "Content-type": `application/json`
} }
}; };
useEffect(()=> { useEffect(() => {
getDataPresence(); getDataPresence();
},[search,currentPage,rowsPerPage, startDate, endDate]) }, [search, currentPage, rowsPerPage, startDate, endDate])
useEffect(()=> { useEffect(() => {
const cekData = dataExport || [] const cekData = dataExport || []
if(cekData.length > 0){ if (cekData.length > 0) {
exportExcel() exportExcel()
} }
},[dataExport]) }, [dataExport])
const handleSearch = e => { const handleSearch = e => {
const value = e.target.value const value = e.target.value
@ -64,35 +64,35 @@ const Index = ({params}) => {
let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59"); let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59");
const payload = { const payload = {
"paging": {"start": start, "length": rowsPerPage}, "paging": { "start": start, "length": rowsPerPage },
"columns": [ "columns": [
{"name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users"}, { "name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users" },
{"name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd}, { "name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd },
], ],
"joins": [{ "joins": [{
"name":"m_users", "name": "m_users",
"column_join":"user_id", "column_join": "user_id",
"column_results":[ "column_results": [
"name", "name",
"ktp_number" "ktp_number"
] ]
}], }],
"orders": {"columns": ["id"], "ascending": false} "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
.post(PRESENCE_SEARCH, payload, config) .post(PRESENCE_SEARCH, payload, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.data && result.data.code == 200){ if (result && result.data && result.data.code == 200) {
setDatatable(result.data.data); setDatatable(result.data.data);
console.log("resdata", result.data.data) console.log("resdata", result.data.data)
setTotalPage(result.data.totalRecord); setTotalPage(result.data.totalRecord);
}else{ } else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
} }
} }
@ -105,17 +105,17 @@ const Index = ({params}) => {
.get(url, config) .get(url, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.data.code==200){ if (result && result.data.code == 200) {
let dataRes = result.data.data let dataRes = result.data.data
let dataImage = { let dataImage = {
name, name,
url:dataRes.image url: dataRes.image
} }
console.log("dataImage", dataImage) console.log("dataImage", dataImage)
await setDataImage(dataImage) await setDataImage(dataImage)
setOpenImage(true) setOpenImage(true)
}else{ } else {
NotificationManager.error('Data image tidak ditemukan!', 'Failed'); NotificationManager.error('Data image tidak ditemukan!', 'Failed');
} }
} }
@ -125,8 +125,8 @@ const Index = ({params}) => {
} }
const toggleDialogImage = () => { const toggleDialogImage = () => {
if(openImage){ if (openImage) {
setDataImage(null) setDataImage(null)
} }
setOpenImage(!openImage) setOpenImage(!openImage)
} }
@ -140,20 +140,20 @@ const Index = ({params}) => {
} }
const renderDurasiKerja = (jamMasuk, jamKeluar) => { const renderDurasiKerja = (jamMasuk, jamKeluar) => {
if(jamMasuk && jamKeluar){ if (jamMasuk && jamKeluar) {
let start = moment(jamMasuk), let start = moment(jamMasuk),
end = moment(jamKeluar); end = moment(jamKeluar);
let diff = end.diff(start); let diff = end.diff(start);
let result = moment.utc(diff).format('HH:mm:ss'); let result = moment.utc(diff).format('HH:mm:ss');
if(result){ if (result) {
return result; return result;
}else{ } else {
return "-" return "-"
} }
}else{ } else {
return "-" return "-"
} }
} }
@ -164,51 +164,51 @@ const Index = ({params}) => {
let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59"); let dateEnd = moment(endDate).format("YYYY-MM-DD 23:59:59");
const payload = { const payload = {
"paging": {"start": 0, "length": -1}, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [
{"name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users"}, { "name": "name", "logic_operator": "ilike", "value": search, "table_name": "m_users" },
{"name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd}, { "name": "clock_in", "logic_operator": "range", "value": dateStart, "value1": dateEnd },
], ],
"joins": [{ "joins": [{
"name":"m_users", "name": "m_users",
"column_join":"user_id", "column_join": "user_id",
"column_results":[ "column_results": [
"name", "name",
"ktp_number" "ktp_number"
] ]
}], }],
"orders": {"columns": ["id"], "ascending": false} "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
.post(PRESENCE_SEARCH, payload, config) .post(PRESENCE_SEARCH, payload, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.data && result.data.code == 200){ if (result && result.data && result.data.code == 200) {
let resData = result.data.data; let resData = result.data.data;
console.log("resdata", resData) console.log("resdata", resData)
const excelData = []; const excelData = [];
resData.map((val, index) => { resData.map((val, index) => {
let dataRow = { let dataRow = {
"NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-', "NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-',
"Nama Human Resource": val.join_first_name ? val.join_first_name : '', "Nama Human Resource": val.join_first_name ? val.join_first_name : '',
"Tanggal Kehadiran" : val.date_presence ? moment(val.date_presence).format("D-M-YYYY") : '-', "Tanggal Kehadiran": val.date_presence ? moment(val.date_presence).format("D-M-YYYY") : '-',
"Jam Masuk" : val.clock_in ? moment(val.clock_in).format("D-M-YYYY HH:mm:ss") : '-', "Jam Masuk": val.clock_in ? moment(val.clock_in).format("D-M-YYYY HH:mm:ss") : '-',
"Jam Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-', "Jam Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-',
"Durasi Kerja" : renderDurasiKerja(val.clock_in, val.clock_out), "Durasi Kerja": renderDurasiKerja(val.clock_in, val.clock_out),
"Clock-in Location": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_loc : '-', "Clock-in Location": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_loc : '-',
"Clock-out Location": val.clock_out_loc && val.clock_out_loc !== '' ? val.clock_out_loc : '-' "Clock-out Location": val.clock_out_loc && val.clock_out_loc !== '' ? val.clock_out_loc : '-'
} }
excelData.push(dataRow) excelData.push(dataRow)
}) })
await setDataExport(excelData); await setDataExport(excelData);
}else{ } else {
NotificationManager.error('Gagal Export Data!!', 'Failed'); NotificationManager.error('Gagal Export Data!!', 'Failed');
} }
} }
@ -216,10 +216,10 @@ const Index = ({params}) => {
const dataExcel = dataExport || []; const dataExcel = dataExport || [];
const fileName = `Data ${pageName}.xlsx`; const fileName = `Data ${pageName}.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel); const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new(); const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`);
XLSX.writeFile(wb, fileName); XLSX.writeFile(wb, fileName);
setDataExport([]) setDataExport([])
} }
const renderTable = useMemo(() => { const renderTable = useMemo(() => {
@ -241,13 +241,15 @@ const Index = ({params}) => {
</>, </>,
}, },
{ title: 'NIK/ID Card', dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' }, { title: 'NIK/ID Card', dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' },
{ title: 'Nama Human Resource', dataIndex: 'join_first_name', key: 'join_first_name' }, { title: 'Nama HR', dataIndex: 'join_first_name', key: 'join_first_name' },
{ title: 'Tanggal Kehadiran', dataIndex: 'date_presence', key: 'date_presence', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY") : "-"}</div>) }, { title: 'Tanggal', dataIndex: 'date_presence', key: 'date_presence', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY") : "-"}</div>) },
{ title: 'Jam Masuk', dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) }, { title: 'Jam Masuk', dataIndex: 'clock_in', key: 'clock_in', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) },
{ title: 'Jam Keluar', dataIndex: 'clock_out', key: 'clock_out', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) }, { title: 'Jam Keluar', dataIndex: 'clock_out', key: 'clock_out', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY HH:mm:ss") : "-"}</div>) },
{ title: 'Durasi Kerja', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{renderDurasiKerja(record.clock_in, record.clock_out)}</div>) }, { title: 'Durasi Kerja', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{renderDurasiKerja(record.clock_in, record.clock_out)}</div>) },
{ title: 'Clock-in Location', dataIndex: 'clock_in_loc', key: 'clock_in_loc', render: (text, record) => <>{text && text !== '' ? text : '-'}</> }, { title: 'Lokasi Masuk', dataIndex: 'clock_in_loc', key: 'clock_in_loc', render: (text, record) => <>{text && text !== '' ? text : '-'}</> },
{ title: 'Clock-out Location', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'}</> }, { title: 'Lokasi Pulang', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'}</> },
{ title: 'Area Kerja In', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'}</> },
{ title: 'Area Kerja Out', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'}</> },
]; ];
return ( return (
<Table <Table
@ -261,72 +263,72 @@ const Index = ({params}) => {
}, [dataTable]) }, [dataTable])
const handleDatePicker = (date, dateString) => { const handleDatePicker = (date, dateString) => {
setStartDate(date[0]) setStartDate(date[0])
setEndDate(date[1]) setEndDate(date[1])
} }
const handleChangeDay = (e) => { const handleChangeDay = (e) => {
const val = e.target.value; const val = e.target.value;
setCurrentDay(val) setCurrentDay(val)
if(val==="today"){ if (val === "today") {
setStartDate(moment(moment().format("YYYY-M-D")))
setEndDate(moment(moment().format("YYYY-M-D")))
setCurrentPage(1)
} else if (val === "3 day") {
setStartDate(moment(moment().subtract(3, "days").format("YYYY-M-D")))
setEndDate(moment(moment().format("YYYY-M-D")))
setCurrentPage(1)
} else if (val === "7 day") {
setStartDate(moment(moment().subtract(7, "days").format("YYYY-M-D")))
setEndDate(moment(moment().format("YYYY-M-D")))
setCurrentPage(1)
} else {
setStartDate(moment(moment().format("YYYY-M-D"))) setStartDate(moment(moment().format("YYYY-M-D")))
setEndDate(moment(moment().format("YYYY-M-D"))) setEndDate(moment(moment().format("YYYY-M-D")))
setCurrentPage(1) setCurrentPage(1)
}else if(val==="3 day"){
setStartDate(moment(moment().subtract(3, "days").format("YYYY-M-D")))
setEndDate(moment(moment().format("YYYY-M-D")))
setCurrentPage(1)
}else if(val==="7 day"){
setStartDate(moment(moment().subtract(7, "days").format("YYYY-M-D")))
setEndDate(moment(moment().format("YYYY-M-D")))
setCurrentPage(1)
}else{
setStartDate(moment(moment().format("YYYY-M-D")))
setEndDate(moment(moment().format("YYYY-M-D")))
setCurrentPage(1)
} }
} }
return ( return (
<div> <div>
<NotificationContainer /> <NotificationContainer />
<DialogFoto <DialogFoto
openDialog={openImage} openDialog={openImage}
closeDialog={closeDialogImage} closeDialog={closeDialogImage}
toggleDialog={toggleDialogImage} toggleDialog={toggleDialogImage}
dataImage={dataImage} dataImage={dataImage}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4 className="capitalize">{pageName}</h4> <h4 className="capitalize">{pageName}</h4>
<Row> <Row>
<Col> <Col>
<Tooltip title="Export Excel"> <Tooltip title="Export Excel">
<Button style={{marginLeft:"5px"}} id="TooltipExport" color="primary" onClick={()=> handleExportExcel()}><i className="fa fa-print"></i></Button> <Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip> </Tooltip>
</Col> </Col>
</Row> </Row>
</CardHeader> </CardHeader>
<CardBody> <CardBody>
<div style={{ display: "flex", justifyContent: "space-between" }}> <div style={{ display: "flex", justifyContent: "space-between" }}>
<div style={{ width:"100%",display:"flex",alignItems:"center" }}> <div style={{ width: "100%", display: "flex", alignItems: "center" }}>
<div style={{ width:"100%",marginRight:"10px",maxWidth:"200px" }}> <div style={{ width: "100%", marginRight: "10px", maxWidth: "200px" }}>
<Input type="select" onChange={(e) => handleChangeDay(e)} defaultValue={currentDay}> <Input type="select" onChange={(e) => handleChangeDay(e)} defaultValue={currentDay}>
<option value="today">Hari Ini</option> <option value="today">Hari Ini</option>
<option value="3 day">3 Hari yang lalu</option> <option value="3 day">3 Hari yang lalu</option>
<option value="7 day">7 Hari yang lalu</option> <option value="7 day">7 Hari yang lalu</option>
</Input> </Input>
</div> </div>
<div style={{ width:"50%",marginTop:"3px" }}> <div style={{ width: "50%", marginTop: "3px" }}>
<RangePicker size="default" allowClear={false} value={[startDate, endDate]} onChange={handleDatePicker}/>{' '} <RangePicker size="default" allowClear={false} value={[startDate, endDate]} onChange={handleDatePicker} />{' '}
<Button color="primary" onClick={() => getDataPresence()}>Cari</Button> <Button color="primary" onClick={() => getDataPresence()}>Cari</Button>
</div> </div>
</div>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari nama human resource" style={{ maxWidth: "200px", marginBottom: "20px" }} />
</div> </div>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari nama human resource" style={{ maxWidth: "200px", marginBottom: "20px" }} />
</div>
{renderTable} {renderTable}
<Pagination <Pagination
style={{marginTop:"25px"}} style={{ marginTop: "25px" }}
showSizeChanger showSizeChanger
onShowSizeChange={onShowSizeChange} onShowSizeChange={onShowSizeChange}
onChange={onPagination} onChange={onPagination}

8
src/views/SimproV2/Satuan/index.js

@ -6,7 +6,7 @@ import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip } from 'antd';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE,SATUAN_SEARCH} from '../../../const/ApiConst'; import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst';
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
const config = { const config = {
@ -286,7 +286,7 @@ const Satuan = ({ params }) => {
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> <Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title="Export Excel"> <Tooltip title="Export Excel">
<Button style={{marginLeft:"5px"}} color="primary" onClick={()=> handleExportExcel()}><i className="fa fa-print"></i></Button> <Button style={{ marginLeft: "5px" }} color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip> </Tooltip>
</Col> </Col>
</Row> </Row>
@ -311,11 +311,11 @@ const Satuan = ({ params }) => {
<td className='nowrap'> <td className='nowrap'>
<Tooltip title="Hapus"> <Tooltip title="Hapus">
<i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i> <i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i>
</Tooltip> </Tooltip>
<Tooltip title="Edit"> <Tooltip title="Edit">
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
<td>{n.name}</td> <td>{n.name}</td>

Loading…
Cancel
Save