Browse Source

trans

pull/2/head
farhan048 2 years ago
parent
commit
bb279c5769
  1. 2
      package.json
  2. 2
      src/const/ApiConst.js
  3. 75
      src/const/en.json
  4. 24
      src/const/i18n.js
  5. 75
      src/const/id.json
  6. 6
      src/utils/LangUtils.js
  7. 395
      src/views/Master/MasterAbsensi/index.js
  8. 159
      src/views/Master/MasterMenu/DialogForm.js
  9. 130
      src/views/Master/MasterMenu/index.js
  10. 107
      src/views/Master/MasterRoles/DialogForm.js
  11. 202
      src/views/Master/MasterRoles/DialogMenuRoles.js
  12. 29
      src/views/Master/MasterRoles/index.js
  13. 10
      src/views/Master/ProjectPhase/DialogForm.js
  14. 28
      src/views/Master/ProjectPhase/index.js
  15. 107
      src/views/Master/RoleProject/DialogForm.js
  16. 28
      src/views/Master/RoleProject/index.js
  17. 400
      src/views/Report/k3/index.js
  18. 15
      src/views/SimproV2/ChecklistK3/DialogForm.js
  19. 30
      src/views/SimproV2/ChecklistK3/index.js
  20. 33
      src/views/SimproV2/Divisi/DialogForm.js
  21. 26
      src/views/SimproV2/Divisi/index.js
  22. 28
      src/views/SimproV2/Presence/DialogFoto.js
  23. 40
      src/views/SimproV2/Presence/index.js
  24. 117
      src/views/SimproV2/ProjectType/DialogForm.js
  25. 26
      src/views/SimproV2/ProjectType/DialogInitialGantt.js
  26. 33
      src/views/SimproV2/ProjectType/index.js
  27. 13
      src/views/SimproV2/Satuan/DialogForm.js
  28. 30
      src/views/SimproV2/Satuan/index.js

2
package.json

@ -46,6 +46,7 @@
"enzyme-adapter-react-16": "^1.14.0",
"flag-icon-css": "^3.3.0",
"font-awesome": "^4.7.0",
"i18next": "^22.4.9",
"interactjs": "^1.10.11",
"jspdf": "^2.5.1",
"jspdf-autotable": "^3.5.25",
@ -73,6 +74,7 @@
"react-dom": "^16.14.0",
"react-grid-layout": "^1.2.5",
"react-highlight-words": "^0.18.0",
"react-i18next": "^12.1.5",
"react-leaflet": "^3.2.0",
"react-leaflet-draw": "^0.19.8",
"react-loader-spinner": "^3.1.5",

2
src/const/ApiConst.js

@ -113,7 +113,7 @@ export const TOKEN_ADW = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxMjAyI
// export let BASE_OSPRO = "https://ospro-api.ospro.id";
export let BASE_OSPRO = "https://adw-api.ospro.id";
// export let BASE_OSPRO = "http://localhost:8444";
// export let BASE_OSPRO = "http://localhost:8444/adw-backend";
// export let BASE_OSPRO = "http://192.168.1.123:8444"; // local
// export let BASE_OSPRO = "http://103.73.125.81:8444"; // ip public adw
export let BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`;

75
src/const/en.json

@ -0,0 +1,75 @@
{
"3days": "3 Days Ago",
"7days": "7 Days Ago",
"action": "Action",
"add": "Add",
"ChecklistK3Add": "Add Checklist K3",
"cancel": "Cancel",
"close": "Close",
"color": "Color",
"date": "Date",
"dateAbsent": "Absent Date",
"dateReport": "Report Date",
"delete": "Delete",
"deleteMsg": "Delete this data ?",
"deleteConfirm": "Are you sure ?",
"description": "Description",
"division": "Division",
"divisionAdd": "Add Division",
"edit": "Edit",
"export": "Export",
"exportExcel": "Export Excel",
"exportPdf": "Export Pdf",
"gearUse": "Gear Used",
"gearNotUse": "Gear Not used",
"hr": "Human Resource",
"icon": "Icon",
"inputIcon": "Input Code Icon",
"inputName": "Input Name",
"inputDescription": "Input Description",
"inputParentMenu": "Select Parent Menu",
"inputAliasMenu": "Input Menu Alias",
"inputOrder": "Input Order",
"inputUrl": "Input URL",
"image": "Image",
"imageCheck": "Selfie Presence",
"locIn": "Location In",
"locOut": "Location Out",
"menuRoles": "Roles Menu",
"menuAdd": "Add Menu",
"nik": "ID Card",
"name": "Name",
"nameHR": "Name Human Resource",
"nameRole": "Name Role",
"nameDivision": "Name Division",
"nameProjectType": "Project Type",
"nameProjectRole": "Project Role",
"noData": "Data not yet available",
"order": "Order",
"parentMenu": "Parent Menu",
"phase": "Project Phase",
"projectType": "Add Project Type",
"projectPhase": "Add Project Phase",
"presenceIn": "Presence In",
"presenceOut": "Presence Out",
"rolesAdd": "Add Roles",
"roles": "Roles",
"search": "Search",
"save": "Save",
"searchType": "Search Project Type",
"searchPhase": "Search Project Phase",
"searchDivision": "Search Division",
"searchUom": "Search UOM",
"searchChecklistK3": "Search checklist K3",
"searchRoles": "Search Roles",
"searchProjectRoles": "Search Project Roles",
"searchProject": "All / Select Projects",
"searchMenu": "Search Menu",
"searchHR": "Search Human Resource",
"today": "Today",
"uom": "UOM",
"uomAdd": "Add UOM",
"workDuration": "Work Duration",
"workAreaIn": "Work Area In",
"workAreaOut": "Work Area Out"
}

24
src/const/i18n.js

@ -0,0 +1,24 @@
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import en from "./en.json";
import id from "./id.json";
i18n
.use(initReactI18next)
.init({
debug: true,
fallbackLng: 'id',
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
resources: {
en: {
translation: en,
},
id: {
translation: id,
}
},
lng: localStorage.getItem("lng") || "id",
});
export default i18n;

75
src/const/id.json

@ -0,0 +1,75 @@
{
"3days": "3 Hari Yang lalu",
"7days": "7 Hari Yang lalu",
"action": "Aksi",
"add": "Tambah",
"ChecklistK3Add": "Tambah Ceklis K3",
"cancel": "Batal",
"close": "Tutup",
"color": "Warna",
"date": "Tanggal",
"dateAbsent": "Tanggal Absen",
"dateReport": "Tanggal Lapor",
"delete": "Hapus",
"deleteMsg": "Hapus Data Ini ?",
"deleteConfirm": "Apakah Anda Yakin ?",
"description": "Deskripsi",
"division": "Divisi",
"divisionAdd": "Tambah Divisi",
"edit": "Ubah",
"export": "Ekspor",
"exportExcel": "Ekspor Excel",
"exportPdf": "Ekspor Pdf",
"gearUse": "Perlengkapan Dikenakan",
"gearNotUse": "Perlengkapan Tidak Dikenakan",
"hr": "Pegawai",
"icon": "Ikon",
"inputIcon": "Masukan Kode Ikon",
"inputName": "Masukan Nama",
"inputDescription": "Masukan Deskripsi",
"inputParentMenu": "Pilih Induk Menu",
"inputAliasMenu": "Masukan Alias Menu",
"inputOrder": "Masukan Urutan",
"inputUrl": "Masukan URL",
"image": "Gambar",
"imageCheck": "Lihat Selfie Presensi",
"locIn": "Lokasi Masuk",
"locOut": "Lokasi Pulang",
"menuRoles": "Menu Peran",
"menuAdd": "Tambah Menu",
"nik": "NIK",
"nameDivision": "Nama Divisi",
"name": "Nama",
"nameHR": "Nama Pegawai",
"nameRole": "Nama Peran",
"nameProjectType": "Tipe Proyek",
"nameProjectRole": "Peran Proyek",
"noData": "Data Belum tersedia",
"order": "Urutan",
"parentMenu": "Menu Induk",
"phase": "Fase Proyek",
"projectType": "Tambah Tipe Proyek",
"projectPhase": "Tambah Fase Proyek",
"presenceIn": "Waktu Masuk",
"presenceOut": "Waktu Pulang",
"rolesAdd": "Tambah Roles",
"roles": "Peran",
"save": "Simpan",
"search": "Cari",
"searchType": "Cari Tipe Proyek",
"searchPhase": "Cari Fase Proyek",
"searchDivision": "Cari Divisi",
"searchUom": "Cari Satuan",
"searchChecklistK3": "Cari Ceklis K3",
"searchRoles": "Cari Peran",
"searchProjectRoles": "Cari Peran Proyek",
"searchProject": "Semua / Pilih Proyek",
"searchMenu": "Cari Menu",
"searchHR": "Cari Nama Pegawai",
"today": "Hari Ini",
"uom": "Satuan",
"uomAdd": "Tambah Satuan",
"workDuration": "Durasi Kerja",
"workAreaIn": "Area Kerja In",
"workAreaOut": "Area Kerja Out"
}

6
src/utils/LangUtils.js

@ -0,0 +1,6 @@
import i18n from "../const/i18n";
export const handleChangeLng = (lng) => {
i18n.changeLanguage(lng);
localStorage.setItem("lng", lng);
};

395
src/views/Master/MasterAbsensi/index.js

@ -7,34 +7,27 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip } from 'antd';
import { DatePicker,Select } from 'antd';
import { DatePicker, Select } from 'antd';
import * as XLSX from 'xlsx';
import { ABSENSI_SEARCH, ABSENSI_ADD, ABSENSI_DELETE, ABSENSI_EDIT,PROYEK_SEARCH, USERPROYEK_SEARCH } from '../../../const/ApiConst.js';
import { ABSENSI_SEARCH, ABSENSI_ADD, ABSENSI_DELETE, ABSENSI_EDIT, PROYEK_SEARCH, USERPROYEK_SEARCH } from '../../../const/ApiConst.js';
import MapConfig from '../../MapConfig/MapConfig';
import { withTranslation } from 'react-i18next';
const { RangePicker } = DatePicker;
const { Option } = Select
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization : `Bearer ${token}`,
"Content-type" : `application/json`
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const BASE_URL = "";
const column = [
{ name: "Nama Human Resource" },
{ name: "Deskripsi"},
{ name: "Tanggal Absensi"},
]
const LENGTH_DATA = 10
export default class index extends Component {
class index extends Component {
constructor(props) {
super(props)
this.state = {
@ -54,15 +47,15 @@ export default class index extends Component {
totalPage: 0,
tooltipEdit: false,
tooltipDelete: false,
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentDay: 'today',
tooltipTambah:false,
tooltipExport:false,
currentProyek:parseInt(localStorage.getItem('role_id'))===2 ? parseInt(localStorage.getItem('proyek_id')) : null,
allUserToProyek:[],
allDataProyek:[],
finishSetupOption:false
tooltipTambah: false,
tooltipExport: false,
currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null,
allUserToProyek: [],
allDataProyek: [],
finishSetupOption: false
}
}
@ -73,29 +66,29 @@ export default class index extends Component {
}
async componentDidUpdate(prevProps, prevState) {
const { search,startDate, dataExport,currentProyek,allUserToProyek } = this.state
const { search, startDate, dataExport, currentProyek, allUserToProyek } = this.state
if (search !== prevState.search) this.getDataAbsensi()
if (startDate !== prevState.startDate) this.getDataAbsensi()
if (dataExport !== prevState.dataExport){
if(dataExport.length > 0){
if (dataExport !== prevState.dataExport) {
if (dataExport.length > 0) {
this.exportExcel()
}
}
if(currentProyek!== prevState.currentProyek){
if(localStorage.getItem('role_id')!==2){
if (currentProyek !== prevState.currentProyek) {
if (localStorage.getItem('role_id') !== 2) {
this.getUserProyek();
}
}
if(allUserToProyek!== prevState.allUserToProyek){
if (allUserToProyek !== prevState.allUserToProyek) {
this.getDataAbsensi();
}
}
setUpFirstProyek = () => {
if(parseInt(localStorage.getItem('role_id'))===2){
this.setState({disableProyek:true});
}else{
this.setState({currentProyek:null})
if (parseInt(localStorage.getItem('role_id')) === 2) {
this.setState({ disableProyek: true });
} else {
this.setState({ currentProyek: null })
}
}
@ -106,12 +99,12 @@ export default class index extends Component {
getAllProyek = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
"paging": { "start": 0, "length": -1 },
"columns": [
{"name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND"}
{ "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" }
],
"joins": [],
"orders": {"columns": ["id"], "ascending": false}
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
@ -120,29 +113,29 @@ export default class index extends Component {
.catch((error) => error.response);
if(result && result.data && result.data.code == 200){
this.setState({allDataProyek:result.data.data})
}else{
if (result && result.data && result.data.code == 200) {
this.setState({ allDataProyek: result.data.data })
} else {
}
}
getUserProyek = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
"paging": { "start": 0, "length": -1 },
"joins": [],
"orders": {"columns": ["id"], "ascending": false}
"orders": { "columns": ["id"], "ascending": false }
}
if(parseInt(localStorage.getItem('role_id'))===1){
if(this.state.currentProyek && this.state.currentProyek > 0){
if (parseInt(localStorage.getItem('role_id')) === 1) {
if (this.state.currentProyek && this.state.currentProyek > 0) {
payload['columns'] = [
{"name": "proyek_id", "logic_operator": "=", "value": `${this.state.currentProyek}`, "operator": "AND"}
{ "name": "proyek_id", "logic_operator": "=", "value": `${this.state.currentProyek}`, "operator": "AND" }
]
}
}else{
} else {
payload['columns'] = [
{"name": "proyek_id", "logic_operator": "=", "value": `${localStorage.getItem('proyek_id')}`, "operator": "AND"}
{ "name": "proyek_id", "logic_operator": "=", "value": `${localStorage.getItem('proyek_id')}`, "operator": "AND" }
]
}
@ -153,9 +146,9 @@ export default class index extends Component {
.catch((error) => error.response);
if(result && result.data && result.data.code == 200){
this.setState({allUserToProyek:result.data.data})
}else{
if (result && result.data && result.data.code == 200) {
this.setState({ allUserToProyek: result.data.data })
} else {
}
}
@ -171,53 +164,53 @@ export default class index extends Component {
let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59");
const payload = {
"paging":{
"start":start,
"length":this.state.rowsPerPage
"paging": {
"start": start,
"length": this.state.rowsPerPage
},
"filter_columns":[
{
"name":"name",
"value":"",
"table_name":"m_users"
}
"filter_columns": [
{
"name": "name",
"value": "",
"table_name": "m_users"
}
],
"columns":[
{"name": "created_at", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND"},
{"name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name":"m_users"}
"columns": [
{ "name": "created_at", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" },
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" }
],
"joins":[
{
"name":"m_users",
"column_join":"user_id",
"column_results":[
"name",
]
}
"joins": [
{
"name": "m_users",
"column_join": "user_id",
"column_results": [
"name",
]
}
],
"orders":{
"columns":[
"id"
],
"ascending":false
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
const result = await axios
.post(ABSENSI_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code == 200){
if (result && result.data && result.data.code == 200) {
console.log("cek res", result.data.data)
let totalRecord = result.data.totalRecord
let resData = result.data.data || []
this.setState({ dataTable: resData, totalPage: totalRecord });
}else{
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
@ -248,11 +241,11 @@ export default class index extends Component {
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code==200){
if (result && result.data && result.data.code == 200) {
this.getDataAbsensi()
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.success('Data absensi berhasil dihapus!!', 'Success!!');
}else{
} else {
this.getDataAbsensi()
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.error('Data absensi gagal dihapus!!', 'Failed!!');
@ -260,44 +253,44 @@ export default class index extends Component {
}
saveAbsensi = async (data) => {
const formData = {
user_id:data.idEmployee,
description:data.description,
created_at:data.dateAbsent
user_id: data.idEmployee,
description: data.description,
created_at: data.dateAbsent
}
const result = await axios.post(ABSENSI_ADD, formData, config)
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code==200){
if (result && result.data && result.data.code == 200) {
this.getDataAbsensi();
NotificationManager.success('Data absensi berhasil ditambahkan!!', 'Success!!');
}else{
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
editDataAbsensi = async (data) => {
let url = ABSENSI_EDIT(data.id)
const formData = {
user_id:data.idEmployee,
description:data.description,
created_at:data.dateAbsent
user_id: data.idEmployee,
description: data.description,
created_at: data.dateAbsent
}
const result = await axios.put(url, formData, config)
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code==200){
if (result && result.data && result.data.code == 200) {
this.getDataAbsensi();
NotificationManager.success('Data absensi berhasil diedit!!', 'Success!!');
}else{
} else {
NotificationManager.error('Data absensi gagal diedit!!', 'Failed!!');
}
}
@ -329,19 +322,19 @@ export default class index extends Component {
this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete }))
} else if (param === "tambah") {
this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah }))
} else if (param === "export") {
} else if (param === "export") {
this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport }))
}
}
handleDatePicker = (date, dateString) => {
this.setState({ startDate:date[0],endDate:date[1] },()=>{
this.setState({ startDate: date[0], endDate: date[1] }, () => {
this.getDataAbsensi();
})
}
handleTipe = (e) => {
this.setState({ typeClock:e.target.value }, () => {
this.setState({ typeClock: e.target.value }, () => {
this.getDataAbsensi();
});
}
@ -350,101 +343,102 @@ export default class index extends Component {
let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00");
let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59");
const payload = {
"paging":{
"start":0,
"length":-1
},
"filter_columns":[
"paging": {
"start": 0,
"length": -1
},
"filter_columns": [
{
"name":"name",
"value":"",
"table_name":"m_users"
"name": "name",
"value": "",
"table_name": "m_users"
}
],
"columns":[
{"name": "created_at", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND"},
{"name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name":"m_users"}
],
"joins":[
],
"columns": [
{ "name": "created_at", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" },
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" }
],
"joins": [
{
"name":"m_users",
"column_join":"user_id",
"column_results":[
"name",
]
"name": "m_users",
"column_join": "user_id",
"column_results": [
"name",
]
}
],
"orders":{
"columns":[
"id"
],
"orders": {
"columns": [
"id"
],
"ascending":false
}
}
"ascending": false
}
}
const result = await axios
.post(ABSENSI_SEARCH, payload, config)
.then(res => res)
.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 || []
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"Nama Human Resource":n.join_first_name ? n.join_first_name : "",
"Deskripsi":n.description ? n.description : "",
"Tanggal Absensi" :n.created_at!==null ? moment(n.created_at).format("DD-MM-YYYY") : "-",
"Nama Human Resource": n.join_first_name ? n.join_first_name : "",
"Deskripsi": n.description ? n.description : "",
"Tanggal Absensi": n.created_at !== null ? moment(n.created_at).format("DD-MM-YYYY") : "-",
}
excelData.push(dataRow)
})
this.setState({dataExport:excelData})
}else{
this.setState({ dataExport: excelData })
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
}
exportExcel = () => {
const dataExcel = this.state.dataExport || [];
const fileName = `Data Absensi.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data Absensi`);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data Absensi`);
XLSX.writeFile(wb, fileName);
this.setState({dataExport:[] })
XLSX.writeFile(wb, fileName);
this.setState({ dataExport: [] })
}
setupSelectProyek = () => {
let allDataProyek = this.state.allDataProyek
return(
return (
<>
{allDataProyek.map((val, index)=> {
return(
<Option key={index} value={parseInt(val.id)}>{val.nama}</Option>
)
})
}
{allDataProyek.map((val, index) => {
return (
<Option key={index} value={parseInt(val.id)}>{val.nama}</Option>
)
})
}
</>
)
}
onChangeProyek = (val) => {
this.setState({currentProyek:val});
this.setState({ currentProyek: val });
}
renderTable = () => {
const t = this.props;
const dataTable2 = this.state.dataTable || [];
return (
<tbody>
{dataTable2.length!==0 ? dataTable2.map((n) => {
return (
<tr key={n.id}>
{/* <td>
{dataTable2.length !== 0 ? dataTable2.map((n) => {
return (
<tr key={n.id}>
{/* <td>
<i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => this.handleDelete(n.id)}></i>
<Tooltip placement="right" isOpen={this.state.tooltipDelete} target="TooltipDelete" toggle={() => this.toggle("delete")}>
Delete
@ -455,55 +449,58 @@ export default class index extends Component {
Edit
</Tooltip>
</td> */}
<td>{n.join_first_name ? n.join_first_name : ""}</td>
<td>{ n.description ? n.description : "-" }</td>
<td>{ n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-" }</td>
</tr>
)
}) : <tr>
<td colSpan="4" align="center">No Data Available</td>
</tr>
}
</tbody>
<td>{n.join_first_name ? n.join_first_name : ""}</td>
<td>{n.description ? n.description : "-"}</td>
<td>{n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"}</td>
</tr>
)
}) : <tr>
<td colSpan="4" align="center">{this.props.t('noData')}</td>
</tr>
}
</tbody>
)
}
handleChangeDay = (e) => {
const val = e.target.value;
this.setState({ currentDay:val });
if(val==="today"){
console.log("test 1 test",val);
this.setState({ currentDay: val });
if (val === "today") {
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="3 day"){
console.log("test test",val);
} else if (val === "3 day") {
this.setState({
startDate:moment(moment().subtract(3, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().subtract(3, "days").format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="7 day"){
console.log("test test",val);
} else if (val === "7 day") {
this.setState({
startDate:moment(moment().subtract(7, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().subtract(7, "days").format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else{
console.log("test 2 test",val);
} else {
console.log("test 2 test", val);
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}
}
render() {
const { tooltipTambah,tooltipExport,dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state
const t = this.props;
const column = [
{ name: this.props.t('nameHR') },
{ name: this.props.t('description') },
{ name: this.props.t('dateAbsent') },
]
const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state
return (
<div>
<NotificationContainer />
@ -513,12 +510,12 @@ export default class index extends Component {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title="Are you sure?"
title={this.props.t('deleteConfirm')}
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
Data Absensi karyawan akan terhapus!!
{this.props.t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialog}
@ -533,33 +530,28 @@ export default class index extends Component {
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4>
<div>
{/* <Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> */}
<Tooltip title="Export Excel">
<Button style={{marginLeft:"5px"}} id="TooltipExport" color="primary" onClick={()=> this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
{/* <Button color="primary" onClick={() => this.handleOpenDialog('Save')}>Tambah Divisi Karyawan</Button> */}
{/* <Tooltip placement="right" isOpen={tooltipTambah} target="TooltipTambah" toggle={() => this.toggle("tambah")}>
Tambah Absensi
</Tooltip> */}
<Tooltip title={this.props.t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</div>
</CardHeader>
<CardBody>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<div style={{ width:"100%",display:"flex",alignItems:"center" }}>
<div style={{ width:"100%",marginRight:"10px",maxWidth:"200px" }}>
<Input type="select" onChange={(e) => this.handleChangeDay(e)} defaultValue={this.state.currentDay}>
<option value="today">Hari Ini</option>
<option value="3 day">3 Hari yang lalu</option>
<option value="7 day">7 Hari yang lalu</option>
</Input>
</div>
<div style={{ width:"50%",marginTop:"3px" }}>
<RangePicker size="default" allowClear={false} value={[this.state.startDate, this.state.endDate]} onChange={this.handleDatePicker}/>{' '}
<Button color="primary" onClick={() => this.getDataAbsensi()}>Cari</Button>
</div>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<div style={{ width: "100%", display: "flex", alignItems: "center" }}>
<div style={{ width: "100%", marginRight: "10px", maxWidth: "200px" }}>
<Input type="select" onChange={(e) => this.handleChangeDay(e)} defaultValue={this.state.currentDay}>
<option value="today">{this.props.t('today')}</option>
<option value="3 day">{this.props.t('3days')}</option>
<option value="7 day">{this.props.t('7days')}</option>
</Input>
</div>
<div style={{ width: "50%", marginTop: "3px" }}>
<RangePicker size="default" allowClear={false} value={[this.state.startDate, this.state.endDate]} onChange={this.handleDatePicker} />{' '}
<Button color="primary" onClick={() => this.getDataAbsensi()}>{this.props.t('search')}</Button>
</div>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari nama human resource" style={{ maxWidth: "200px", marginBottom: "20px" }} />
</div>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('searchHR')} style={{ maxWidth: "200px", marginBottom: "20px" }} />
</div>
<Table responsive striped hover>
<thead>
<tr>
@ -571,7 +563,7 @@ export default class index extends Component {
})}
</tr>
</thead>
{ this.renderTable() }
{this.renderTable()}
</Table>
<Pagination
showSizeChanger
@ -588,3 +580,4 @@ export default class index extends Component {
)
}
}
export default withTranslation()(index);

159
src/views/Master/MasterMenu/DialogForm.js

@ -4,10 +4,11 @@ import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap';
import { Select } from 'antd';
import moment from 'moment';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const { Option } = Select
const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataMenu}) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataMenu }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [url, setUrl] = useState('')
@ -15,10 +16,10 @@ const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit
const [icon, setIcon] = useState('')
const [sequence, setSequence] = useState(0)
const [parentId, setParentId] = useState(null)
const { t } = useTranslation()
useEffect(()=> {
if(typeDialog==="Edit"){
useEffect(() => {
if (typeDialog === "Edit") {
console.log("data edit", dataEdit)
setId(dataEdit.id)
setName(dataEdit.name)
@ -27,7 +28,7 @@ const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit
setParentId(dataEdit.parent_id)
setSequence(dataEdit.sequence)
setAliasName(dataEdit.alias_name)
}else{
} else {
setId(0)
setName('')
setUrl('')
@ -36,47 +37,47 @@ const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit
setSequence(0)
setAliasName('')
}
},[dataEdit,openDialog])
}, [dataEdit, openDialog])
const handleSave = () => {
let data = '';
if(typeDialog==="Save"){
data = {
name,
url,
sequence:parseInt(sequence),
icon,
alias_name:aliasName
}
if(parentId && parentId > 0){
data['parent_id'] = parentId
}
closeDialog('save', data);
}else{
data = {
id,
name,
url,
sequence: parseInt(sequence),
icon,
alias_name:aliasName
}
if(parentId && parentId > 0){
data['parent_id'] = parentId
}
closeDialog('edit', data);
let data = '';
if (typeDialog === "Save") {
data = {
name,
url,
sequence: parseInt(sequence),
icon,
alias_name: aliasName
}
setId(0)
setName('')
setUrl('')
setIcon('')
setParentId(null)
setSequence(0)
setAliasName('')
if (parentId && parentId > 0) {
data['parent_id'] = parentId
}
closeDialog('save', data);
} else {
data = {
id,
name,
url,
sequence: parseInt(sequence),
icon,
alias_name: aliasName
}
if (parentId && parentId > 0) {
data['parent_id'] = parentId
}
closeDialog('edit', data);
}
setId(0)
setName('')
setUrl('')
setIcon('')
setParentId(null)
setSequence(0)
setAliasName('')
}
const handleCancel = () => {
@ -95,71 +96,71 @@ const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit
}
const setupSelectParent = () => {
return(
return (
<>
{dataMenu.map((val, index)=> {
return(
<Option key={index} value={val.id}>{val.name}</Option>
)
})}
{dataMenu.map((val, index) => {
return (
<Option key={index} value={val.id}>{val.name}</Option>
)
})}
</>
)
}
const renderForm = () => {
return(
return (
<Form>
<Row>
<Col>
<FormGroup>
<Label className="capitalize">Nama Menu</Label>
<Input type="text" value={name} onChange={(e)=> setName(e.target.value)} placeholder={`Menu..`}/>
</FormGroup>
<FormGroup>
<FormGroup>
<Label className="capitalize">{t('name')} Menu</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} />
</FormGroup>
<FormGroup>
<Label className="capitalize">URL</Label>
<Input type="text" value={url} onChange={(e)=> setUrl(e.target.value)} placeholder={`Url..`} />
</FormGroup>
<FormGroup>
<Label className="capitalize">Icon</Label>
<Input type="text" value={icon} onChange={(e)=> setIcon(e.target.value)} placeholder={`Ikon..`} />
</FormGroup>
<Input type="text" value={url} onChange={(e) => setUrl(e.target.value)} placeholder={t('inputUrl')} />
</FormGroup>
<FormGroup>
<Label className="capitalize">{t('icon')} </Label>
<Input type="text" value={icon} onChange={(e) => setIcon(e.target.value)} placeholder={t('inputIcon')} />
</FormGroup>
</Col>
<Col>
<FormGroup>
<Label className="capitalize">Urutan</Label>
<Input type="number" value={sequence} onChange={(e)=> setSequence(e.target.value)} placeholder={`urutan..`} />
</FormGroup>
<FormGroup>
<Label className="capitalize">Parent</Label>
<Select showSearch defaultValue={parentId} onChange={onChangeParent} placeholder="Select Parent" style={{width:'100%'}}>
<FormGroup>
<Label className="capitalize">{t('order')}</Label>
<Input type="number" value={sequence} onChange={(e) => setSequence(e.target.value)} placeholder={t('inputOrder')} />
</FormGroup>
<FormGroup>
<Label className="capitalize">{t('parentMenu')}</Label>
<Select showSearch defaultValue={parentId} onChange={onChangeParent} placeholder={t('inputParentMenu')} style={{ width: '100%' }}>
{setupSelectParent()}
</Select>
</FormGroup>
<FormGroup>
</FormGroup>
<FormGroup>
<Label className="capitalize">Alias Menu</Label>
<Input type="text" value={aliasName} onChange={(e)=> setAliasName(e.target.value)} placeholder={`Alias..`} />
</FormGroup>
<Input type="text" value={aliasName} onChange={(e) => setAliasName(e.target.value)} placeholder={t('inputAliasMenu')} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
return (
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog=="Save" ? `Tambah` : "Edit"} Menu</ModalHeader>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Tambah` : "Edit"} Menu</ModalHeader>
<ModalBody>
{renderForm()}
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
)
}
export default DialogForm;

130
src/views/Master/MasterMenu/index.js

@ -5,10 +5,10 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { MENU_ADD,MENU_SEARCH,MENU_EDIT,MENU_DELETE } from '../../../const/ApiConst.js';
import { MENU_ADD, MENU_SEARCH, MENU_EDIT, MENU_DELETE } from '../../../const/ApiConst.js';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const column = [
@ -20,7 +20,7 @@ const column = [
{ name: "Parent" },
]
const Index = ({params}) => {
const Index = ({ params }) => {
const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
@ -38,33 +38,33 @@ const Index = ({params}) => {
const [tooltipTambah, setTooltipTambah] = useState(false)
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const { t } = useTranslation()
const pageName = params.name;
const config = {
headers:
{
Authorization : `Bearer ${token}`,
"Content-type" : `application/json`
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
useEffect(()=> {
useEffect(() => {
getDataMenu();
getDataAllMenu();
},[])
}, [])
useEffect(()=> {
getDataMenu();
},[search,currentPage,rowsPerPage])
useEffect(() => {
getDataMenu();
}, [search, currentPage, rowsPerPage])
useEffect(()=> {
useEffect(() => {
const cekData = dataExport || []
if(cekData.length > 0){
if (cekData.length > 0) {
exportExcel()
}
},[dataExport])
}, [dataExport])
const handleSearch = e => {
const value = e.target.value
@ -74,21 +74,21 @@ const Index = ({params}) => {
const getDataAllMenu = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
"paging": { "start": 0, "length": -1 },
"columns": [
{"name": "name", "logic_operator": "ilike", "value": "", "operator": "AND"}
{ "name": "name", "logic_operator": "ilike", "value": "", "operator": "AND" }
],
"joins": [],
"orders": {"columns": ["id"], "ascending": false}
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code == 200){
if (result && result.data && result.data.code == 200) {
setAllDataMenu(result.data.data);
}else{
} else {
}
}
@ -100,18 +100,18 @@ const Index = ({params}) => {
}
const payload = {
"paging": {"start": start, "length": rowsPerPage},
"paging": { "start": start, "length": rowsPerPage },
"columns": [
{"name": "name", "logic_operator": "ilike", "value": search, "operator": "AND"}
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" }
],
"joins": [{
"name":"m_menu",
"column_join":"parent_id",
"column_results":[
"name"
]
}],
"orders": {"columns": ["id"], "ascending": false}
"name": "m_menu",
"column_join": "parent_id",
"column_results": [
"name"
]
}],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
@ -119,10 +119,10 @@ const Index = ({params}) => {
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code == 200){
if (result && result.data && result.data.code == 200) {
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
}else{
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
@ -170,7 +170,7 @@ const Index = ({params}) => {
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code===200){
if (result && result.data && result.data.code === 200) {
getDataMenu();
getDataAllMenu();
NotificationManager.success(`Data menu berhasil ditambah`, 'Success!!');
@ -187,7 +187,7 @@ const Index = ({params}) => {
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code===200){
if (result && result.data && result.data.code === 200) {
getDataMenu();
NotificationManager.success(`Data menu berhasil diedit`, 'Success!!');
} else {
@ -220,25 +220,25 @@ const Index = ({params}) => {
setTooltipDelete(!tooltipDelete)
} else if (param === "tambah") {
setTooltipTambah(!tooltipTambah)
} else if (param === "export") {
} else if (param === "export") {
setTooltipExport(!tooltipExport)
}
}
const handleExportExcel = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
"paging": { "start": 0, "length": -1 },
"columns": [
{"name": "name", "logic_operator": "ilike", "value": search, "operator": "AND"}
{ "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" }
],
"joins": [{
"name":"m_menu",
"column_join":"parent_id",
"column_results":[
"name": "m_menu",
"column_join": "parent_id",
"column_results": [
"name"
]
}],
"orders": {"columns": ["id"], "ascending": false}
}],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
@ -246,22 +246,22 @@ const Index = ({params}) => {
.then(res => res)
.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;
const excelData = [];
resData.map((val, index) => {
let dataRow = {
"Nama":val.name,
"Url" :val.url,
"Icon" :val.icon,
"Alias Name":val.alias_name,
"Urutan" :val.sequence,
"Parent Name":val.join_first_name ? val.join_first_name : "-"
"Nama": val.name,
"Url": val.url,
"Icon": val.icon,
"Alias Name": val.alias_name,
"Urutan": val.sequence,
"Parent Name": val.join_first_name ? val.join_first_name : "-"
}
excelData.push(dataRow)
})
await setDataExport(excelData);
}else{
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
@ -270,9 +270,9 @@ const Index = ({params}) => {
const dataExcel = dataExport || [];
const fileName = `Data ${pageName}.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`);
XLSX.writeFile(wb, fileName);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`);
XLSX.writeFile(wb, fileName);
setDataExport([])
}
@ -284,24 +284,24 @@ const Index = ({params}) => {
const renderTable = useMemo(() => {
const columns = [
{
title: 'Action',
title: t('action'),
dataIndex: '',
key: 'x',
render: (text, record) => <>
<Tooltip title="Delete">
<Tooltip title={t('delete')}>
<i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<Tooltip title={t('edit')}>
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(text)}></i>
</Tooltip>
</>,
},
{ title: 'Nama Menu', dataIndex: 'name', key: 'name' },
{ title: t('name'), dataIndex: 'name', key: 'name' },
{ title: 'Url', dataIndex: 'url', key: 'url' },
{ title: 'Ikon', dataIndex: 'icon', key: 'icon' },
{ title: t('icon'), dataIndex: 'icon', key: 'icon' },
{ title: 'Alias', dataIndex: 'alias_name', key: 'alias_name' },
{ title: 'Urutan', dataIndex: 'sequence', key: 'sequence' },
{ title: 'Parent Menu', dataIndex: 'join_first_name', key: 'join_first_name', render: (text, record) => (text ? text : "-") }
{ title: t('order'), dataIndex: 'sequence', key: 'sequence' },
{ title: t('parentMenu'), dataIndex: 'join_first_name', key: 'join_first_name', render: (text, record) => (text ? text : "-") }
];
return (
<Table
@ -323,12 +323,12 @@ const Index = ({params}) => {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Apakah anda yakin?`}
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Data akan terhapus
{t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialog}
@ -344,14 +344,14 @@ const Index = ({params}) => {
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Cari nama`} />
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchMenu')} />
</Col>
<Col>
<Tooltip title="Tambah Menu">
<Tooltip title={t('menuAdd')}>
<Button id="TooltipTambah" color="success" onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Button style={{marginLeft:"5px"}} id="TooltipExport" color="primary" onClick={()=> handleExportExcel()}><i className="fa fa-print"></i></Button>
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
@ -359,7 +359,7 @@ const Index = ({params}) => {
<CardBody>
{renderTable}
<Pagination
style={{marginTop:"25px"}}
style={{ marginTop: "25px" }}
showSizeChanger
onShowSizeChange={onShowSizeChange}
onChange={onPagination}

107
src/views/Master/MasterRoles/DialogForm.js

@ -2,75 +2,76 @@ import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css';
import { withTranslation } from 'react-i18next';
export default class DialogForm extends Component {
class DialogForm extends Component {
constructor(props) {
super(props)
this.state = {
id: 0,
name:"",
description:"",
name: "",
description: "",
openDialog: false,
isParentClick: false,
}
}
async componentDidMount(){
async componentDidMount() {
this.props.showDialog(this.showDialog);
}
async componentDidUpdate (){
if(this.state.isParentClick===true){
if(this.props.typeDialog==="Edit"){
const { dataEdit } = this.props
this.setState({
id:dataEdit.id,
name:dataEdit.name,
description:dataEdit.description
})
}else{
this.setState({
id:0,
name:"",
description:""
})
}
this.setState({isParentClick:false});
async componentDidUpdate() {
if (this.state.isParentClick === true) {
if (this.props.typeDialog === "Edit") {
const { dataEdit } = this.props
this.setState({
id: dataEdit.id,
name: dataEdit.name,
description: dataEdit.description
})
} else {
this.setState({
id: 0,
name: "",
description: ""
})
}
this.setState({ isParentClick: false });
}
}
showDialog = () => {
this.setState({ isParentClick : true });
this.setState({ isParentClick: true });
}
handleSave = () => {
const {
id,
const {
id,
name,
description
} = this.state
let data = '';
if (this.props.typeDialog === "Save") {
data = {
id,
name,
description
}
this.props.closeDialog('save', data);
} else {
data = {
id,
name,
description
} = this.state
let data = '';
if(this.props.typeDialog==="Save"){
data = {
id,
name,
description
}
this.props.closeDialog('save', data);
}else{
data = {
id,
name,
description
}
this.props.closeDialog('edit', data);
}
this.setState({ id:0 });
this.props.closeDialog('edit', data);
}
this.setState({ id: 0 });
}
handleCancel = () => {
@ -78,15 +79,16 @@ export default class DialogForm extends Component {
}
renderForm = () => {
return(
const { t } = this.props;
return (
<Form>
<FormGroup>
<Label>Nama</Label>
<Input type="text" value={this.state.name} onChange={(e)=>this.setState({ name:e.target.value })} placeholder="name roles.." />
<Label>{this.props.t('nameRole')}</Label>
<Input type="text" value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} />
</FormGroup>
<FormGroup>
<Label>Deskripsi</Label>
<Input type="text" value={this.state.description} onChange={(e)=>this.setState({ description:e.target.value })} placeholder="deskripsi.." />
<Label>{this.props.t('description')}</Label>
<Input type="text" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} />
</FormGroup>
</Form>
)
@ -95,15 +97,16 @@ export default class DialogForm extends Component {
render() {
return (
<Modal isOpen={this.props.openDialog} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.props.closeDialog}>{this.props.typeDialog=="Save" ? "Tambah" : "Edit"} Roles</ModalHeader>
<ModalHeader toggle={this.props.closeDialog}>{this.props.typeDialog == "Save" ? "Tambah" : "Edit"} {this.props.t('roles')}</ModalHeader>
<ModalBody>
{this.renderForm()}
{this.renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => this.handleSave()}>{this.props.typeDialog}</Button>{' '}
<Button color="secondary" onClick={() => this.handleCancel()}>Cancel</Button>
<Button color="secondary" onClick={() => this.handleCancel()}>{this.props.t('cancel')}</Button>
</ModalFooter>
</Modal>
)
}
}
export default withTranslation()(DialogForm);

202
src/views/Master/MasterRoles/DialogMenuRoles.js

@ -4,87 +4,88 @@ import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css';
import axios from 'axios';
import { MENU_SEARCH } from '../../../const/ApiConst.js';
import { withTranslation, WithTranslation } from 'react-i18next';
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization : `Bearer ${token}`,
"Content-type" : `application/json`
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
export default class DialogMenuRoles extends Component {
class DialogMenuRoles extends Component {
constructor(props) {
super(props)
this.state = {
id: 0,
name:"",
description:"",
name: "",
description: "",
openDialog: false,
isParentClick: false,
menu:[],
stateMenu:[],
allChecked:true,
menu: [],
stateMenu: [],
allChecked: true,
}
}
async componentDidMount(){
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getAllMenu();
}
async componentDidUpdate (){
if(this.state.isParentClick===true){
const { idRoles } = this.props
this.setStateMenu(true);
this.setState({isParentClick:false, id:idRoles});
async componentDidUpdate() {
if (this.state.isParentClick === true) {
const { idRoles } = this.props
this.setStateMenu(true);
this.setState({ isParentClick: false, id: idRoles });
}
}
showDialog = () => {
this.setState({ isParentClick : true });
this.setState({ isParentClick: true });
}
getAllMenu = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
"paging": { "start": 0, "length": -1 },
"columns": [
{"name": "name", "logic_operator": "ilike", "value": "", "operator": "AND"}
{ "name": "name", "logic_operator": "ilike", "value": "", "operator": "AND" }
],
"joins": [],
"orders": {"columns": ["id"], "ascending": false}
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code == 200){
this.setState({ menu:result.data.data },() => {
if (result && result.data && result.data.code == 200) {
this.setState({ menu: result.data.data }, () => {
this.setStateMenu(false);
});
}else{
});
} else {
}
}
setStateMenu = edit => {
const stateMenu = [];
this.state.menu.map((val)=>{
stateMenu.push(false);
this.state.menu.map((val) => {
stateMenu.push(false);
})
this.setState({ stateMenu:[] },()=> {
this.setState({stateMenu:stateMenu},()=> {
if(edit){
this.setState({ stateMenu: [] }, () => {
this.setState({ stateMenu: stateMenu }, () => {
if (edit) {
this.checkMenuRoles();
}
})
@ -92,22 +93,22 @@ export default class DialogMenuRoles extends Component {
}
checkMenuRoles = () => {
let copyStateMenu = [...this.state.stateMenu];
this.props.menuRoles.map((val, indexMenu)=> {
let index = this.getIndexDataMenu(val.menu_id);
console.log("index true", val.menu_id);
if(index >= 0){
copyStateMenu[index] = true;
}
})
this.setState({ stateMenu:[] },()=>{
let check = copyStateMenu.some(this.checkArray);
if(check===false){
this.setState({ allChecked:true,stateMenu:copyStateMenu })
}else{
this.setState({ allChecked:false,stateMenu:copyStateMenu })
}
})
let copyStateMenu = [...this.state.stateMenu];
this.props.menuRoles.map((val, indexMenu) => {
let index = this.getIndexDataMenu(val.menu_id);
console.log("index true", val.menu_id);
if (index >= 0) {
copyStateMenu[index] = true;
}
})
this.setState({ stateMenu: [] }, () => {
let check = copyStateMenu.some(this.checkArray);
if (check === false) {
this.setState({ allChecked: true, stateMenu: copyStateMenu })
} else {
this.setState({ allChecked: false, stateMenu: copyStateMenu })
}
})
}
@ -117,24 +118,24 @@ export default class DialogMenuRoles extends Component {
}
handleSave = () => {
const {
stateMenu,
menu,
id
const {
stateMenu,
menu,
id
} = this.state
const arrayData = [];
menu.map((val, index) => {
let data = {
roles_id:id,
menu_id:val.id,
checked:stateMenu[index]
roles_id: id,
menu_id: val.id,
checked: stateMenu[index]
}
arrayData.push(data);
})
this.props.closeDialog('save', arrayData);
this.setState({ id:0 });
this.setState({ id: 0 });
}
handleCancel = () => {
@ -145,20 +146,20 @@ export default class DialogMenuRoles extends Component {
let copyStateMenu = [...this.state.stateMenu];
copyStateMenu[index] = checked;
console.log("cek uncek", copyStateMenu);
this.setState({ stateMenu:copyStateMenu })
this.setState({ stateMenu: copyStateMenu })
}
renderForm = () => {
const { menu, stateMenu } = this.state
return(
menu.map((val, index)=>{
return(
<tr key={index}>
<td>{val.name}</td>
<td><input type="checkbox" onClick={(e) => this.handleChangeCheckbox(e.target.checked, index)} defaultChecked={stateMenu[index]} /></td>
</tr>
)
})
return (
menu.map((val, index) => {
return (
<tr key={index}>
<td>{val.name}</td>
<td><input type="checkbox" onClick={(e) => this.handleChangeCheckbox(e.target.checked, index)} defaultChecked={stateMenu[index]} /></td>
</tr>
)
})
)
}
@ -167,32 +168,32 @@ export default class DialogMenuRoles extends Component {
}
handleAllChecked = (checked) => {
this.setState({ allChecked:!this.state.allChecked });
if(checked===true){
this.setState({ allChecked: !this.state.allChecked });
if (checked === true) {
console.log("test 1")
let check = this.state.stateMenu.some(this.checkArray);
if(check){
if (check) {
const stateMenu = [];
this.state.menu.map((val)=>{
stateMenu.push(true);
this.state.menu.map((val) => {
stateMenu.push(true);
})
this.setState({ stateMenu:[] },()=> {
this.setState({stateMenu:stateMenu});
this.setState({ stateMenu: [] }, () => {
this.setState({ stateMenu: stateMenu });
})
}
}else{
} else {
console.log("test 1 2 3 ")
const stateMenu = [];
this.state.menu.map((val)=>{
stateMenu.push(false);
this.state.menu.map((val) => {
stateMenu.push(false);
})
this.setState({ stateMenu:[] },()=> {
this.setState({stateMenu:stateMenu});
this.setState({ stateMenu: [] }, () => {
this.setState({ stateMenu: stateMenu });
})
}
}
@ -200,33 +201,34 @@ export default class DialogMenuRoles extends Component {
render() {
return (
<Modal scrollable={true} isOpen={this.props.openDialog} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.props.closeDialog}>Roles Menu</ModalHeader>
<ModalHeader toggle={this.props.closeDialog}>{this.props.t('menuRoles')}</ModalHeader>
<ModalBody>
<Form>
<Table>
<thead>
<tr>
<th>Menu</th>
<th>
T/F
</th>
</tr>
</thead>
<tbody>
<tr>
<td>All</td>
<td><input type="checkbox" onChange={(e) => this.handleAllChecked(e.target.checked)} checked={this.state.allChecked} /></td>
</tr>
<Form>
<Table>
<thead>
<tr>
<th>Menu</th>
<th>
T/F
</th>
</tr>
</thead>
<tbody>
<tr>
<td>All</td>
<td><input type="checkbox" onChange={(e) => this.handleAllChecked(e.target.checked)} checked={this.state.allChecked} /></td>
</tr>
{this.renderForm()}
</tbody>
</Table>
</Form>
</tbody>
</Table>
</Form>
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => this.handleSave()}>Save</Button>{' '}
<Button color="secondary" onClick={() => this.handleCancel()}>Cancel</Button>
<Button color="primary" onClick={() => this.handleSave()}>{this.props.t('save')}</Button>{' '}
<Button color="secondary" onClick={() => this.handleCancel()}>{this.props.t('cancel')}</Button>
</ModalFooter>
</Modal>
)
}
}
export default withTranslation()(DialogMenuRoles);

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

@ -9,6 +9,7 @@ import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip, Table } from 'antd';
import { ROLE_ADD, ROLE_SEARCH, ROLE_EDIT, ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
@ -26,7 +27,7 @@ const momentFormat = 'HH:mm';
const LENGTH_DATA = 10
export default class index extends Component {
class index extends Component {
constructor(props) {
super(props)
this.state = {
@ -58,26 +59,26 @@ export default class index extends Component {
this.columns = [
{
title: 'Action',
title: this.props.t('action'),
dataIndex: '',
key: 'x',
className: 'nowrap',
render: (text, record) => <>
<Tooltip title="Roles Menu">
<Tooltip title={this.props.t('menuRoles')}>
<i className="cil-menu" style={{ color: 'green', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleMenuRoles(text.id)}></i>
</Tooltip>
<Tooltip title="Hapus">
<Tooltip title={this.props.t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<Tooltip title={this.props.t('edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
</Tooltip>
</>,
},
{ title: 'Nama Role', dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: 'Description', dataIndex: 'description', key: 'description' },
{ title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' },
]
}
@ -249,7 +250,7 @@ export default class index extends Component {
if (this.state.dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">Not Data Available</td>
<td align="center" colSpan="3">{this.props.t('noData')}</td>
</tr>
)
}
@ -361,6 +362,7 @@ export default class index extends Component {
}
render() {
const { t } = this.props;
const { tooltipTambah, tooltipExport, dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state
let noSeq = 0;
return (
@ -372,12 +374,12 @@ export default class index extends Component {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title="Are you sure?"
title={this.props.t('deleteConfirm')}
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
Data tipe roles akan terhapus!!
{this.props.t('deleteMsg')}
</SweetAlert>
<SweetAlert
show={this.state.alertNotDelete}
@ -410,13 +412,13 @@ export default class index extends Component {
<h4>{this.props.params.name}</h4>
<Row>
<Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari Nama Roles" />
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('searchRoles')} />
</Col>
<Col>
<Tooltip title="Tambah Roles">
<Tooltip title={this.props.t('rolesAdd')}>
<Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Tooltip title={this.props.t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
@ -447,3 +449,4 @@ export default class index extends Component {
)
}
}
export default withTranslation()(index);

10
src/views/Master/ProjectPhase/DialogForm.js

@ -7,12 +7,12 @@ import 'antd/dist/antd.css';
import InputColor from "./InputColor";
import "./styles.css";
import "rc-color-picker/assets/index.css";
import { useTranslation } from 'react-i18next';
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0)
const [projectType, setProjectType] = useState('')
const [color, setColor] = useState('')
const { t } = useTranslation();
useEffect(() => {
if (typeDialog === "Edit") {
console.log("cel data Edit", dataEdit)
@ -56,13 +56,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Phase</Label>
<Label className="capitalize">{t('phase')}</Label>
<Input type="text" value={projectType} onChange={(e) => setProjectType(e.target.value)} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Warna</Label>
<Label className="capitalize">{t('color')}</Label>
<InputColor value={color} color={color} onChange={(e) => setColor(e.color)} />
</FormGroup>
</Col>
@ -80,7 +80,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
</>

28
src/views/Master/ProjectPhase/index.js

@ -8,7 +8,7 @@ import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, PROJECT_PHASE_LIST, BASE_OSPRO } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const config = {
headers:
@ -50,7 +50,7 @@ const ProjectPhase = ({ params }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const { t } = useTranslation()
useEffect(() => {
getDataProjectPhase()
}, [currentPage, rowsPerPage, search])
@ -279,7 +279,7 @@ const ProjectPhase = ({ params }) => {
if (dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">Tidak ada data project phase</td>
<td align="center" colSpan="3">{t('noData')}</td>
</tr>
)
}
@ -288,22 +288,22 @@ const ProjectPhase = ({ params }) => {
const renderTable = useMemo(() => {
const columns = [
{
title: 'Action',
title: t('action'),
dataIndex: '',
key: 'x',
className: 'nowrap',
render: (text, record) => <>
<Tooltip title="Delete">
<Tooltip title={t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<Tooltip title={t('Edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(text)}></i>
</Tooltip>{" "}
</>,
},
{ title: 'Fase', dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" },
{
title: 'Warna',
title: t('color'),
dataIndex: 'color',
key: 'color',
render: (text) => <>
@ -333,12 +333,12 @@ const ProjectPhase = ({ params }) => {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
onCancel={cancelDelete}
focusCancelBtn
>
Delete this data
{t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialog}
@ -354,13 +354,13 @@ const ProjectPhase = ({ params }) => {
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Cari Fase`} />
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchPhase')} />
</Col>
<Col>
<Tooltip title="Add new data">
<Tooltip title={t('projectPhase')}>
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>

107
src/views/Master/RoleProject/DialogForm.js

@ -2,75 +2,76 @@ import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css';
import { withTranslation } from 'react-i18next';
export default class DialogForm extends Component {
class DialogForm extends Component {
constructor(props) {
super(props)
this.state = {
id: 0,
name:"",
description:"",
name: "",
description: "",
openDialog: false,
isParentClick: false,
}
}
async componentDidMount(){
async componentDidMount() {
this.props.showDialog(this.showDialog);
}
async componentDidUpdate (){
if(this.state.isParentClick===true){
if(this.props.typeDialog==="Edit"){
const { dataEdit } = this.props
this.setState({
id:dataEdit.id,
name:dataEdit.name,
description:dataEdit.description
})
}else{
this.setState({
id:0,
name:"",
description:""
})
}
this.setState({isParentClick:false});
async componentDidUpdate() {
if (this.state.isParentClick === true) {
if (this.props.typeDialog === "Edit") {
const { dataEdit } = this.props
this.setState({
id: dataEdit.id,
name: dataEdit.name,
description: dataEdit.description
})
} else {
this.setState({
id: 0,
name: "",
description: ""
})
}
this.setState({ isParentClick: false });
}
}
showDialog = () => {
this.setState({ isParentClick : true });
this.setState({ isParentClick: true });
}
handleSave = () => {
const {
id,
const {
id,
name,
description
} = this.state
let data = '';
if (this.props.typeDialog === "Save") {
data = {
id,
name,
description
}
this.props.closeDialog('save', data);
} else {
data = {
id,
name,
description
} = this.state
let data = '';
if(this.props.typeDialog==="Save"){
data = {
id,
name,
description
}
this.props.closeDialog('save', data);
}else{
data = {
id,
name,
description
}
this.props.closeDialog('edit', data);
}
this.setState({ id:0 });
this.props.closeDialog('edit', data);
}
this.setState({ id: 0 });
}
handleCancel = () => {
@ -78,15 +79,16 @@ export default class DialogForm extends Component {
}
renderForm = () => {
return(
const { t } = this.props;
return (
<Form>
<FormGroup>
<Label>Nama</Label>
<Input type="text" value={this.state.name} onChange={(e)=>this.setState({ name:e.target.value })} placeholder="name roles.." />
<Label>{this.props.t('name')}</Label>
<Input type="text" value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} />
</FormGroup>
<FormGroup>
<Label>Deskripsi</Label>
<Input type="text" value={this.state.description} onChange={(e)=>this.setState({ description:e.target.value })} placeholder="deskripsi.." />
<Label>{this.props.t('description')}</Label>
<Input type="text" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} />
</FormGroup>
</Form>
)
@ -95,15 +97,16 @@ export default class DialogForm extends Component {
render() {
return (
<Modal isOpen={this.props.openDialog} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.props.closeDialog}>{this.props.typeDialog=="Save" ? "Tambah" : "Edit"} Project Role</ModalHeader>
<ModalHeader toggle={this.props.closeDialog}>{this.props.typeDialog == "Save" ? "Tambah" : "Edit"} {this.props.t('nameProjectRole')}</ModalHeader>
<ModalBody>
{this.renderForm()}
{this.renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => this.handleSave()}>{this.props.typeDialog}</Button>{' '}
<Button color="secondary" onClick={() => this.handleCancel()}>Cancel</Button>
<Button color="secondary" onClick={() => this.handleCancel()}>{this.props.t('cancel')}</Button>
</ModalFooter>
</Modal>
)
}
}
export default withTranslation()(DialogForm);

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

@ -8,7 +8,7 @@ import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
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 { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
@ -32,7 +32,7 @@ const column = [
const LENGTH_DATA = 10
export default class index extends Component {
class index extends Component {
constructor(props) {
super(props)
this.state = {
@ -63,23 +63,23 @@ export default class index extends Component {
}
this.columns = [
{
title: 'Action',
title: this.props.t('action'),
dataIndex: '',
key: 'x',
className: 'nowrap',
render: (text, record) => <>
<Tooltip title="Hapus">
<Tooltip title={this.props.t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<Tooltip title={this.props.t('edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i>
</Tooltip>
</>,
},
{ title: 'Nama Role', dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: 'Description', dataIndex: 'description', key: 'description' },
{ title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: this.props.t('description'), dataIndex: 'description', key: 'description' },
];
}
@ -255,7 +255,7 @@ export default class index extends Component {
if (this.state.dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">Tidak ada data project role</td>
<td align="center" colSpan="3">{this.props.t('noData')}</td>
</tr>
)
}
@ -303,6 +303,7 @@ export default class index extends Component {
}
render() {
const { t } = this.props;
const { tooltipTambah, tooltipExport, dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state
let noSeq = 0;
return (
@ -314,12 +315,12 @@ export default class index extends Component {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title="Are you sure?"
title={this.props.t('deleteConfirm')}
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
Data project role akan terhapus!!
{this.props.t('deleteMsg')}
</SweetAlert>
<SweetAlert
show={this.state.alertNotDelete}
@ -345,13 +346,13 @@ export default class index extends Component {
<h4>{this.props.params.name}</h4>
<Row>
<Col>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari Nama Project Role" />
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('searchProjectRoles')} />
</Col>
<Col>
<Tooltip title="Tambah Roles">
<Tooltip title={this.props.t('rolesAdd')}>
<Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Tooltip title={this.props.t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
@ -382,3 +383,4 @@ export default class index extends Component {
)
}
}
export default withTranslation()(index);

400
src/views/Report/k3/index.js

@ -10,14 +10,15 @@ import { Pagination, Tooltip } from 'antd';
import { DatePicker, Select } from 'antd';
import * as XLSX from 'xlsx';
import { PRESENSI_SEARCH, PROYEK_SEARCH, USERPROYEK_SEARCH, K3_SEARCH, SIMPRO_BASE_IMAGE } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next';
const { RangePicker } = DatePicker;
const { Option } = Select
const token = localStorage.getItem('token');
const config = {
headers:
{
Authorization : `Bearer ${token}`,
"Content-type" : `application/json`
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
@ -25,18 +26,11 @@ const BASE_URL = ""
const momentFormat = 'DD-MM-YY';
const column = [
{ name: "Nama Human Resource" },
{ name: "Tanggal Lapor"},
{ name: "Perlengkapan Dikenakan"},
{ name: "Perlengkapan Tidak Dikenakan"},
{ name: "Deskripsi" },
{ name: "Action" },
]
const LENGTH_DATA = 10
export default class index extends Component {
class index extends Component {
constructor(props) {
super(props)
this.state = {
@ -58,16 +52,16 @@ export default class index extends Component {
tooltipEdit: false,
tooltipDelete: false,
typeClock: "All",
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentDay: 'today',
tooltipExport:false,
disableProyek:false,
currentProyek:parseInt(localStorage.getItem('role_id'))===2 ? parseInt(localStorage.getItem('proyek_id')) : null,
allUserToProyek:[],
proyekIds:[],
allDataProyek:[],
finishSetupOption:false
tooltipExport: false,
disableProyek: false,
currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null,
allUserToProyek: [],
proyekIds: [],
allDataProyek: [],
finishSetupOption: false
}
}
@ -77,29 +71,29 @@ export default class index extends Component {
}
async componentDidUpdate(prevProps, prevState) {
const { search,startDate,dataExport,proyekIds, currentProyek } = this.state
const { search, startDate, dataExport, proyekIds, currentProyek } = this.state
if (search !== prevState.search) this.getDataLaporanK3()
if (startDate !== prevState.startDate) this.getDataLaporanK3()
if (dataExport !== prevState.dataExport){
if(dataExport.length > 0){
if (dataExport !== prevState.dataExport) {
if (dataExport.length > 0) {
this.exportExcel()
}
}
if(proyekIds!== prevState.proyekIds){
if (proyekIds !== prevState.proyekIds) {
this.getDataLaporanK3();
}
if(currentProyek!== prevState.currentProyek){
if (currentProyek !== prevState.currentProyek) {
this.getDataLaporanK3();
}
}
setUpFirstProyek = () => {
console.log("cek role id", localStorage.getItem('role_id'));
if(parseInt(localStorage.getItem('role_id'))===2){
this.setState({disableProyek:true});
}else{
this.setState({currentProyek:null})
if (parseInt(localStorage.getItem('role_id')) === 2) {
this.setState({ disableProyek: true });
} else {
this.setState({ currentProyek: null })
}
}
handleSearch = e => {
@ -109,12 +103,12 @@ export default class index extends Component {
getAllProyek = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
"paging": { "start": 0, "length": -1 },
"columns": [
{"name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND"}
{ "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" }
],
"joins": [],
"orders": {"columns": ["id"], "ascending": false}
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
@ -123,15 +117,15 @@ export default class index extends Component {
.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 proyekIds = []
resData.map((val, index) => {
proyekIds.push(val.id);
});
this.setState({allDataProyek:resData,proyekIds:proyekIds})
}else{
this.setState({ allDataProyek: resData, proyekIds: proyekIds })
} else {
}
}
@ -152,63 +146,63 @@ export default class index extends Component {
let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00");
let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59");
let currentProyek = this.state.currentProyek
const payload = {
"paging":{
"start":start,
"length":this.state.rowsPerPage
const payload = {
"paging": {
"start": start,
"length": this.state.rowsPerPage
},
"filter_columns":[
{
"name":"name",
"value":"",
"table_name":"m_users"
}
"filter_columns": [
{
"name": "name",
"value": "",
"table_name": "m_users"
}
],
"columns":[
{"name": "report_date", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND"},
{"name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name":"m_users"}
"columns": [
{ "name": "report_date", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" },
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" }
],
"joins":[
{
"name":"m_users",
"column_join":"user_id",
"column_results":[
"name",
]
}
"joins": [
{
"name": "m_users",
"column_join": "user_id",
"column_results": [
"name",
]
}
],
"orders":{
"columns":[
"id"
],
"ascending":false
"orders": {
"columns": [
"id"
],
"ascending": false
},
"child_data":{
"table_name":"t_report_k3_detail",
"column_table":"report_k3_id",
"column_name":"id"
"child_data": {
"table_name": "t_report_k3_detail",
"column_table": "report_k3_id",
"column_name": "id"
}
}
if(currentProyek){
let proyekPayload = {"name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek};
if (currentProyek) {
let proyekPayload = { "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek };
payload.columns.push(proyekPayload)
}else{
let proyekPayload = {"name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds};
} else {
let proyekPayload = { "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds };
payload.columns.push(proyekPayload)
}
const result = await axios
.post(K3_SEARCH, payload, config)
.then(res => res)
.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 || []
console.log("cek resdata", resData)
this.setState({ dataTable: resData, totalPage: result.data.totalRecord });
}else{
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
@ -239,7 +233,7 @@ export default class index extends Component {
.then(res => res)
.catch((error) => error.response);
if(result.message!==undefined){
if (result.message !== undefined) {
if (result.message === "Data Has Been Deleted") {
this.getDataLaporanK3()
this.setState({ idDelete: 0, alertDelete: false })
@ -248,7 +242,7 @@ export default class index extends Component {
this.setState({ idDelete: 0, alertDelete: false })
NotificationManager.error('Data division gagal dihapus!!', 'Failed!!');
}
}else{
} else {
if (result.data.message === "Data Has Been Deleted") {
this.getDataLaporanK3()
this.setState({ idDelete: 0, alertDelete: false })
@ -262,7 +256,7 @@ export default class index extends Component {
saveDivision = async (data) => {
let url = BASE_URL + "employee_devision.php?act=input";
const formData = new FormData()
formData.append('name', data.name);
formData.append('description', data.description);
@ -270,14 +264,14 @@ export default class index extends Component {
.then(res => res)
.catch((error) => error.response);
if(result.message!==undefined){
if (result.message !== undefined) {
if (result.message === "Data Has Been Saved") {
this.getDataLaporanK3();
NotificationManager.success('Data division berhasil ditambahkan!!', 'Success!!');
} else {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}else{
} else {
if (result.data.message === "Data Has Been Saved") {
this.getDataLaporanK3();
NotificationManager.success('Data division berhasil ditambahkan!!', 'Success!!');
@ -285,12 +279,12 @@ export default class index extends Component {
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
}
editDataDivision = async (data) => {
let url = "";
const formData = new FormData();
formData.append('name', data.name);
formData.append('description', data.description);
@ -299,14 +293,14 @@ export default class index extends Component {
.then(res => res)
.catch((error) => error.response);
if(result.data!==undefined){
if (result.data !== undefined) {
if (result.data.message === "Data Has Been Edited") {
this.getDataLaporanK3();
NotificationManager.success('Data division berhasil diedit!!', 'Success!!');
} else {
NotificationManager.error('Data division gagal diedit!!', 'Failed!!');
}
}
}
}
@ -342,13 +336,13 @@ export default class index extends Component {
}
handleDatePicker = (date, dateString) => {
this.setState({ startDate:date[0],endDate:date[1] },()=>{
this.setState({ startDate: date[0], endDate: date[1] }, () => {
this.getDataLaporanK3();
})
}
handleTipe = (e) => {
this.setState({ typeClock:e.target.value }, () => {
this.setState({ typeClock: e.target.value }, () => {
this.getDataLaporanK3();
});
}
@ -358,139 +352,140 @@ export default class index extends Component {
let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59");
let currentProyek = this.state.currentProyek
const payload = {
"paging":{
"start":0,
"length":-1
},
"columns":[
{"name": "report_date", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND"},
{"name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name":"m_users"}
],
"joins":[
"paging": {
"start": 0,
"length": -1
},
"columns": [
{ "name": "report_date", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" },
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" }
],
"joins": [
{
"name":"m_users",
"column_join":"user_id",
"column_results":[
"name",
]
"name": "m_users",
"column_join": "user_id",
"column_results": [
"name",
]
}
],
"orders":{
"columns":[
"id"
],
"orders": {
"columns": [
"id"
],
"ascending":false
},
"child_data":{
"table_name":"t_report_k3_detail",
"column_table":"report_k3_id",
"column_name":"id"
}
}
if(currentProyek){
let proyekPayload = {"name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek};
"ascending": false
},
"child_data": {
"table_name": "t_report_k3_detail",
"column_table": "report_k3_id",
"column_name": "id"
}
}
if (currentProyek) {
let proyekPayload = { "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek };
payload.columns.push(proyekPayload)
}else{
let proyekPayload = {"name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds};
} else {
let proyekPayload = { "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds };
payload.columns.push(proyekPayload)
}
const result = await axios
.post(K3_SEARCH, payload, config)
.then(res => res)
.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 || []
console.log("cek res data", resData)
const excelData = [];
resData.map((n, index) => {
let dataRow = {
"Nama Human Resource":n.join_first_name ? n.join_first_name : "-",
"Tanggal Lapor" :n.report_date ? moment(n.report_date).format("DD-MM-YYYY HH:mm:ss") : "-",
"Perlengkapan Dikenakan": n.k3_checked.length ? n.k3_checked.join() : "-",
"Perlengkapan Tidak Dikenakan": n.k3_not_checked.length ? n.k3_not_checked.join() : "-",
"Description" : n.description ? n.description : "-"
"Nama Human Resource": n.join_first_name ? n.join_first_name : "-",
"Tanggal Lapor": n.report_date ? moment(n.report_date).format("DD-MM-YYYY HH:mm:ss") : "-",
"Perlengkapan Dikenakan": n.k3_checked.length ? n.k3_checked.join() : "-",
"Perlengkapan Tidak Dikenakan": n.k3_not_checked.length ? n.k3_not_checked.join() : "-",
"Description": n.description ? n.description : "-"
}
excelData.push(dataRow)
})
this.setState({dataExport:excelData})
}else{
this.setState({ dataExport: excelData })
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
}
exportExcel = () => {
const dataExcel = this.state.dataExport || [];
const fileName = `Data Laporan K3.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data Laporan K3`);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data Laporan K3`);
XLSX.writeFile(wb, fileName);
this.setState({dataExport:[] })
XLSX.writeFile(wb, fileName);
this.setState({ dataExport: [] })
}
lihatFoto = (data) => {
this.showChildDialog();
this.setState({dataImage: data}, () => {
this.setState({openDialog:true});
this.setState({ dataImage: data }, () => {
this.setState({ openDialog: true });
});
}
renderTable = () => {
const { t } = this.props;
const dataTable2 = this.state.dataTable || [];
return (
<tbody>
{dataTable2.length!==0 ? dataTable2.map((n) => {
return (
<tr key={n.id}>
<td>{ n.join_first_name ? n.join_first_name : "-" }</td>
<td>{ n.report_date ? moment(n.report_date).format("DD-MM-YYYY HH:mm:ss") : "-" }</td>
<td>{ n.k3_checked.length ? n.k3_checked.join() : "-"}</td>
<td>{ n.k3_not_checked.length ? n.k3_not_checked.join() : "-"}</td>
<td>{ n.description ? n.description : "-"}</td>
<td> {n.image ? <Tooltip title="Lihat Foto"><i onClick={() => this.lihatFoto(n.image)} className='fa fa-image'></i></Tooltip>: ""}</td>
</tr>
)
}) : <tr>
<td colSpan="9" align="center">No Data Available</td>
</tr>
}
</tbody>
{dataTable2.length !== 0 ? dataTable2.map((n) => {
return (
<tr key={n.id}>
<td>{n.join_first_name ? n.join_first_name : "-"}</td>
<td>{n.report_date ? moment(n.report_date).format("DD-MM-YYYY HH:mm:ss") : "-"}</td>
<td>{n.k3_checked.length ? n.k3_checked.join() : "-"}</td>
<td>{n.k3_not_checked.length ? n.k3_not_checked.join() : "-"}</td>
<td>{n.description ? n.description : "-"}</td>
<td> {n.image ? <Tooltip title={this.props.t('image')}><i onClick={() => this.lihatFoto(n.image)} className='fa fa-image'></i></Tooltip> : ""}</td>
</tr>
)
}) : <tr>
<td colSpan="9" align="center">{this.props.t('noData')}</td>
</tr>
}
</tbody>
)
}
handleChangeDay = (e) => {
const val = e.target.value;
this.setState({ currentDay:val });
if(val==="today"){
this.setState({ currentDay: val });
if (val === "today") {
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="3 day"){
} else if (val === "3 day") {
this.setState({
startDate:moment(moment().subtract(3, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().subtract(3, "days").format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="7 day"){
} else if (val === "7 day") {
this.setState({
startDate:moment(moment().subtract(7, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().subtract(7, "days").format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else{
} else {
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
startDate: moment(moment().format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}
@ -498,26 +493,35 @@ export default class index extends Component {
setupSelectProyek = () => {
let allDataProyek = this.state.allDataProyek
return(
return (
<>
{allDataProyek.map((val, index)=> {
return(
<Option key={index} value={parseInt(val.id)}>{val.nama}</Option>
)
})
}
{allDataProyek.map((val, index) => {
return (
<Option key={index} value={parseInt(val.id)}>{val.nama}</Option>
)
})
}
</>
)
}
onChangeProyek = (val) => {
this.setState({currentProyek:val});
this.setState({ currentProyek: val });
}
delay = (ms) => new Promise(res => setTimeout(res, ms));
render() {
const { tooltipExport,dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state
const column = [
{ name: this.props.t('nameHR') },
{ name: this.props.t('dateReport') },
{ name: this.props.t('gearUse') },
{ name: this.props.t('gearNotUse') },
{ name: this.props.t('description') },
{ name: this.props.t('action') },
]
const t = this.props;
const { tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state
return (
<div>
<NotificationContainer />
@ -527,12 +531,12 @@ export default class index extends Component {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title="Are you sure?"
title={this.props.t('deleteConfirm')}
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
Data report k3 akan terhapus!!
{this.props.t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialog}
@ -545,34 +549,33 @@ export default class index extends Component {
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4>
<div>
<Tooltip title="Export Excel">
<Button id="TooltipExport" color="primary" onClick={()=> this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
{/* <Button color="success" onClick={() => this.handleExportExcel()}>Export Excel</Button> */}
<Tooltip title={this.props.t('exportExcel')}>
<Button id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</div>
</CardHeader>
<CardBody>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<div style={{ width:"100%",display:"flex",alignItems:"center" }}>
<div style={{width:"100%",marginRight:"10px",maxWidth:"200px" }}>
<Select showSearch defaultValue={this.state.currentProyek} onChange={this.onChangeProyek} placeholder="Semua / Pilih Proyek >" style={{width:'100%'}} disabled={this.state.disableProyek} allowClear={true}>
{this.setupSelectProyek()}
</Select>
</div>
<div style={{ width:"100%",marginRight:"10px",maxWidth:"200px" }}>
<Input type="select" onChange={(e) => this.handleChangeDay(e)} defaultValue={this.state.currentDay}>
<option value="today">Hari Ini</option>
<option value="3 day">3 Hari yang lalu</option>
<option value="7 day">7 Hari yang lalu</option>
</Input>
</div>
<div style={{ width:"50%",marginTop:"3px" }}>
<RangePicker size="default" allowClear={false} value={[this.state.startDate, this.state.endDate]} onChange={this.handleDatePicker}/>{' '}
<Button color="primary" onClick={() => this.getDataLaporanK3()}>Cari</Button>
</div>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<div style={{ width: "100%", display: "flex", alignItems: "center" }}>
<div style={{ width: "100%", marginRight: "10px", maxWidth: "200px" }}>
<Select showSearch defaultValue={this.state.currentProyek} onChange={this.onChangeProyek} placeholder={this.props.t('searchProject')} style={{ width: '100%' }} disabled={this.state.disableProyek} allowClear={true}>
{this.setupSelectProyek()}
</Select>
</div>
<div style={{ width: "100%", marginRight: "10px", maxWidth: "200px" }}>
<Input type="select" onChange={(e) => this.handleChangeDay(e)} defaultValue={this.state.currentDay}>
<option value="today">{this.props.t('today')}</option>
<option value="3 day">{this.props.t('3days')}</option>
<option value="7 day">{this.props.t('7days')}</option>
</Input>
</div>
<div style={{ width: "50%", marginTop: "3px" }}>
<RangePicker size="default" allowClear={false} value={[this.state.startDate, this.state.endDate]} onChange={this.handleDatePicker} />{' '}
<Button color="primary" onClick={() => this.getDataLaporanK3()}>{this.props.t('search')}</Button>
</div>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari nama human resource" style={{ maxWidth: "200px", marginBottom: "20px" }} />
</div>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder={this.props.t('searchHR')} style={{ maxWidth: "200px", marginBottom: "20px" }} />
</div>
<Table responsive striped hover>
<thead>
<tr>
@ -584,7 +587,7 @@ export default class index extends Component {
})}
</tr>
</thead>
{ this.renderTable() }
{this.renderTable()}
</Table>
<Pagination
showSizeChanger
@ -601,3 +604,4 @@ export default class index extends Component {
)
}
}
export default withTranslation()(index);

15
src/views/SimproV2/ChecklistK3/DialogForm.js

@ -4,13 +4,14 @@ import {
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [description, setDescription] = useState('')
const { t } = useTranslation()
useEffect(() => {
@ -62,14 +63,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Name</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={`Input name...`} />
<Label className="capitalize">{t('name')}</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={`Description ...`} />
<Label className="capitalize">{t('description')}</Label>
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={t('inputDescription')} />
</FormGroup>
</Col>
</Row>
@ -81,13 +82,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Resource</ModalHeader>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Checlist K3</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
</>

30
src/views/SimproV2/ChecklistK3/index.js

@ -9,6 +9,7 @@ import { Pagination, Button, Tooltip } from 'antd';
import {
CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH
} from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const config = {
@ -18,10 +19,7 @@ const config = {
"Content-type": `application/json`
}
};
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
]
const ChecklistK3 = ({ params }) => {
const token = localStorage.getItem("token")
const HEADER = {
@ -45,7 +43,11 @@ const ChecklistK3 = ({ params }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const { t } = useTranslation()
const column = [
{ name: t('name') },
{ name: t('description') },
]
useEffect(() => {
getDataChecklistK3()
}, [currentPage, rowsPerPage, search])
@ -240,7 +242,7 @@ const ChecklistK3 = ({ params }) => {
if (dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">Tidak ada data project type</td>
<td align="center" colSpan="3">{t('noData')}</td>
</tr>
)
}
@ -255,12 +257,12 @@ const ChecklistK3 = ({ params }) => {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
{t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialog}
@ -276,13 +278,13 @@ const ChecklistK3 = ({ params }) => {
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search checklist K3...`} />
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchChecklistK3')} />
</Col>
<Col>
<Tooltip title="Add Checklist K3">
<Tooltip title={t('ChecklistK3Add')}>
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
@ -292,7 +294,7 @@ const ChecklistK3 = ({ params }) => {
<Table responsive striped hover>
<thead>
<tr>
<th>Aksi</th>
<th>{t('action')}</th>
{column.map((i, index) => {
return (
<th key={index} scope="row">{i.name}</th>
@ -306,10 +308,10 @@ const ChecklistK3 = ({ params }) => {
return (
<tr key={n.id}>
<td className='nowrap'>
<Tooltip title="Hapus">
<Tooltip title={t('delete')}>
<i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<Tooltip title={t('edit')}>
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip>
</td>

33
src/views/SimproV2/Divisi/DialogForm.js

@ -3,17 +3,16 @@ import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import { DatePicker, Tooltip, Select } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import moment from 'moment';
import { Select } from 'antd';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const { Option } = Select
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataDivisions }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [parent, setParent] = useState(null)
const [description, setDescription] = useState('')
const { t } = useTranslation()
const onChangeParent = (val) => {
setParent(val)
@ -63,21 +62,21 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Name</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)}/>
<Label className="capitalize">{t('name')}</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Parent</Label>
<Select showSearch
value={parent}
onChange={onChangeParent}
style={{ width: '100%' }}
filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())}
>
<Label className="capitalize">{t('nameDivision')}</Label>
<Select showSearch
value={parent}
onChange={onChangeParent}
style={{ width: '100%' }}
filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())}
>
{dataDivisions.map((res, idx) => (
<Option key={res['id']} value={res['id']}>{res['displayName']}</Option>
))}
@ -88,8 +87,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)}/>
<Label className="capitalize">{t('description')}</Label>
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={t('inputDescription')} />
</FormGroup>
</Col>
</Row>
@ -101,13 +100,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Resource</ModalHeader>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} {t('division')}</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
</>

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

@ -1,15 +1,13 @@
import * as XLSX from 'xlsx';
import DialogForm from './DialogForm';
import React, { useState, useEffect, useMemo } from 'react';
import React, { useState, useEffect } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import moment from 'moment'
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 { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import { useTranslation } from 'react-i18next';
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
@ -53,7 +51,7 @@ const ProjectType = ({ params }) => {
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataDivisions, setDataDivisions] = useState([])
const { t } = useTranslation()
useEffect(() => {
getListDivision()
@ -281,7 +279,7 @@ const ProjectType = ({ params }) => {
if (dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">Belum ada data.</td>
<td align="center" colSpan="3">{t('noData')}</td>
</tr>
)
}
@ -296,12 +294,12 @@ const ProjectType = ({ params }) => {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
onCancel={cancelDelete}
focusCancelBtn
>
Delete this data
{t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialog}
@ -318,13 +316,13 @@ const ProjectType = ({ params }) => {
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Cari Divisi`} />
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchDivision')} />
</Col>
<Col>
<Tooltip title="Add Data">
<Tooltip title={t('divisionAdd')}>
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
@ -348,10 +346,10 @@ const ProjectType = ({ params }) => {
return (
<tr key={n.id}>
<td className='nowrap'>
<Tooltip title="Hapus">
<Tooltip title={t('delete')}>
<i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<Tooltip title={t('edit')}>
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip>
</td>

28
src/views/SimproV2/Presence/DialogFoto.js

@ -4,6 +4,7 @@ import { Button } from 'reactstrap';
import { Image } from 'antd'
import { BASE_SIMPRO_LUMEN_IMAGE } from '../../../const/ApiConst';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const DialogFoto = ({ openDialog, closeDialog, toggleDialog, dataImage }) => {
@ -11,9 +12,9 @@ const DialogFoto = ({ openDialog, closeDialog, toggleDialog, dataImage }) => {
const [urlImage, setUrlImage] = useState("")
const [dataReady, setDataReady] = useState(false)
const [hrName, setHrName] = useState(false)
const { t } = useTranslation()
useEffect(() => {
if(dataImage && dataImage!=null){
if (dataImage && dataImage != null) {
setUrlImage(dataImage.url);
setHrName(dataImage.name);
setDataReady(true)
@ -21,7 +22,7 @@ const DialogFoto = ({ openDialog, closeDialog, toggleDialog, dataImage }) => {
}, [dataImage])
useEffect(() => {
if(!openDialog){
if (!openDialog) {
setUrlImage("")
setHrName("")
setDataReady(false)
@ -29,27 +30,26 @@ const DialogFoto = ({ openDialog, closeDialog, toggleDialog, dataImage }) => {
}, [openDialog])
const renderModalBody = () => {
return(
<div style={{width:'100%',display:'flex',justifyContent:'center',flexDirection:'column',alignItems:'flex-start'}}>
<h6>Foto Selfie :</h6>
<div style={{width:'100%',display:'flex',justifyContent:'center',alignItems:'center'}}>
<Image
width={200}
src={`${BASE_SIMPRO_LUMEN_IMAGE}/${urlImage}`}
/>
return (
<div style={{ width: '100%', display: 'flex', justifyContent: 'center', flexDirection: 'column', alignItems: 'flex-start' }}>
<div style={{ width: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<Image
width={200}
src={`${BASE_SIMPRO_LUMEN_IMAGE}/${urlImage}`}
/>
</div>
</div>
</div>
)
}
return (
<Modal isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>Lihat Selfie Presensi | Nama Human Resource {hrName}</ModalHeader>
<ModalHeader className="capitalize" toggle={closeDialog}>{t('imageCheck')} | {t('nameHR')} {hrName}</ModalHeader>
<ModalBody>
{dataReady ? renderModalBody() : null}
</ModalBody>
<ModalFooter>
<Button className="capitalize" color="secondary" onClick={closeDialog}>Close</Button>
<Button className="capitalize" color="secondary" onClick={closeDialog}>{t('close')}</Button>
</ModalFooter>
</Modal>
)

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

@ -8,6 +8,7 @@ import { Pagination, Tooltip, Table, DatePicker } from 'antd';
import moment from 'moment';
import { PRESENCE_SEARCH, IMAGE_GET_BY_ID } from '../../../const/ApiConst.js';
import DialogFoto from './DialogFoto';
import { useTranslation } from 'react-i18next';
const { RangePicker } = DatePicker;
const token = window.localStorage.getItem('token');
@ -24,6 +25,7 @@ const Index = ({ params }) => {
const [currentDay, setCurrentDay] = useState("today")
const [dataImage, setDataImage] = useState(null)
const [openImage, setOpenImage] = useState(false)
const { t } = useTranslation()
const pageName = params.name;
const config = {
@ -230,26 +232,20 @@ const Index = ({ params }) => {
dataIndex: '',
key: 'x',
render: (text, record) => <>
{/* <Tooltip title="Delete">
<i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(text)}></i>
</Tooltip> */}
<Tooltip title="Image">
<Tooltip title={t('image')}>
<i id="TooltipEdit" className="fa fa-image" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleImage(text.id, text.join_first_name)}></i>
</Tooltip>
</>,
},
{ title: 'NIK/ID Card', dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' },
{ title: 'Nama HR', dataIndex: 'join_first_name', key: 'join_first_name' },
{ title: 'Waktu 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: 'Waktu 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: 'Lokasi Masuk', dataIndex: 'clock_in_loc', key: 'clock_in_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) => (<div style={{ whiteSpace: "nowrap", textAlign: "center" }}>{record.clock_in_boundary ? <i className="fa fa-check-circle fa-lg" style={{ color: 'green' }}></i> : <i className="fa fa-times-circle fa-lg" style={{ color: 'red' }}></i>}</div>) },
{ title: 'Area Kerja Out', dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => (<div style={{ whiteSpace: "nowrap", textAlign: "center" }}>{record.clock_out_boundary == null ? <i class="fa fa-window-minimize fa-lg" style={{ color: 'orange' }}></i> : record.clock_out_boundary ? <i className="fa fa-check-circle fa-lg" style={{ color: 'green' }}></i> : <i className="fa fa-times-circle fa-lg" style={{ color: 'red' }}></i>}</div>) },
{ title: t('nik'), dataIndex: 'join_first_ktp_number', key: 'join_first_ktp_number' },
{ title: t('nameHR'), dataIndex: 'join_first_name', key: 'join_first_name' },
{ title: t('presenceIn'), 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: t('presenceOut'), 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: t('workDuration'), render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{renderDurasiKerja(record.clock_in, record.clock_out)}</div>) },
{ title: t('locIn'), dataIndex: 'clock_in_loc', key: 'clock_in_loc', render: (text, record) => <>{text && text !== '' ? text : '-'}</> },
{ title: t('locOut'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => <>{text && text !== '' ? text : '-'}</> },
{ title: t('workAreaIn'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => (<div style={{ whiteSpace: "nowrap", textAlign: "center" }}>{record.clock_in_boundary ? <i className="fa fa-check-circle fa-lg" style={{ color: 'green' }}></i> : <i className="fa fa-times-circle fa-lg" style={{ color: 'red' }}></i>}</div>) },
{ title: t('workAreaOut'), dataIndex: 'clock_out_loc', key: 'clock_out_loc', render: (text, record) => (<div style={{ whiteSpace: "nowrap", textAlign: "center" }}>{record.clock_out_boundary == null ? <i class="fa fa-window-minimize fa-lg" style={{ color: 'orange' }}></i> : record.clock_out_boundary ? <i className="fa fa-check-circle fa-lg" style={{ color: 'green' }}></i> : <i className="fa fa-times-circle fa-lg" style={{ color: 'red' }}></i>}</div>) },
];
return (
<Table
@ -303,7 +299,7 @@ const Index = ({ params }) => {
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Tooltip title="Export Excel">
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
@ -314,17 +310,17 @@ const Index = ({ params }) => {
<div style={{ width: "100%", display: "flex", alignItems: "center" }}>
<div style={{ width: "100%", marginRight: "10px", maxWidth: "200px" }}>
<Input type="select" onChange={(e) => handleChangeDay(e)} defaultValue={currentDay}>
<option value="today">Hari Ini</option>
<option value="3 day">3 Hari yang lalu</option>
<option value="7 day">7 Hari yang lalu</option>
<option value="today">{t('today')}</option>
<option value="3 day">{t('3days')}</option>
<option value="7 day">{t('7days')}</option>
</Input>
</div>
<div style={{ width: "50%", marginTop: "3px" }}>
<RangePicker size="default" allowClear={false} value={[startDate, endDate]} onChange={handleDatePicker} />{' '}
<Button color="primary" onClick={() => getDataPresence()}>Cari</Button>
<Button color="primary" onClick={() => getDataPresence()}>{t('search')}</Button>
</div>
</div>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari nama human resource" style={{ maxWidth: "200px", marginBottom: "20px" }} />
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchHR')} style={{ maxWidth: "200px", marginBottom: "20px" }} />
</div>
{renderTable}
<Pagination

117
src/views/SimproV2/ProjectType/DialogForm.js

@ -1,66 +1,67 @@
import React, { useEffect, useState } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import { DatePicker, Tooltip, Select } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import moment from 'moment';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const { Option } = Select
const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit}) => {
const [id, setId] = useState(0)
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0)
const [projectType, setProjectType] = useState('')
const [uom, setUom] = useState('')
const [description, setDescription] = useState('')
const [unitPrice, setUnitPrice] = useState()
const { t } = useTranslation();
useEffect(()=> {
if(typeDialog==="Edit"){
useEffect(() => {
if (typeDialog === "Edit") {
console.log("cel data Edit", dataEdit)
setId(dataEdit.id)
setDescription(dataEdit.description)
setUnitPrice(dataEdit.unit_price)
setUom(dataEdit.uom)
setProjectType(dataEdit.name)
}else{
} else {
setId(0)
}
},[dataEdit,openDialog])
}, [dataEdit, openDialog])
const handleSave = () => {
let data = '';
if(typeDialog==="Save"){
data = {
name: projectType,
description
}
closeDialog('save', data);
}else{
data = {
id,
name: projectType,
description
}
closeDialog('edit', data);
let data = '';
if (typeDialog === "Save") {
data = {
name: projectType,
description
}
setId(0)
setDescription('')
closeDialog('save', data);
} else {
data = {
id,
name: projectType,
description
}
closeDialog('edit', data);
}
setId(0)
setDescription('')
}
const handleCancel = () => {
closeDialog('cancel', 'none')
setId(0)
setDescription('')
}
@ -69,41 +70,41 @@ const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit
const renderForm = () => {
return(
return (
<Form>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Project Type</Label>
<Input type="text" value={projectType} onChange={(e)=> setProjectType(e.target.value)} placeholder={`Input material name...`}/>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="4" type="textarea" value={description} onChange={(e)=> setDescription(e.target.value)} placeholder={`Description ...`} />
</FormGroup>
</Col>
</Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('nameProjectType')}</Label>
<Input type="text" value={projectType} onChange={(e) => setProjectType(e.target.value)} placeholder={t('inputName')} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">{t('description')}</Label>
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={t('inputDescription')} />
</FormGroup>
</Col>
</Row>
</Form>
)
}
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog=="Save" ? `Add` : "Edit"} Resource</ModalHeader>
<ModalBody>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Resource</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
</ModalFooter>
</Modal>
{/* <DialogMap
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
{/* <DialogMap
openDialog={openDialogMap}
closeDialog={handleCloseDialogMap}
toggleDialog={() => toggleMapDialog}
@ -115,7 +116,7 @@ const DialogForm = ({openDialog, closeDialog, toggleDialog, typeDialog, dataEdit
/> */}
</>
)
}
export default DialogForm;

26
src/views/SimproV2/ProjectType/DialogInitialGantt.js

@ -8,6 +8,7 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import { TEMPLATE_GANTT_ADD, TEMPLATE_GANTT_DELETE, TEMPLATE_GANTT_EDIT, TEMPLATE_GANTT_TREE } from '../../../const/ApiConst';
import axios from "../../../const/interceptorApi"
import DialogForm from './DialogFormInitial';
import { useTranslation } from 'react-i18next';
const DialogInitialGantt = ({ openDialog, closeDialog, toggleDialog, idTypeProject }) => {
const token = window.localStorage.getItem('token');
@ -26,7 +27,7 @@ const DialogInitialGantt = ({ openDialog, closeDialog, toggleDialog, idTypeProje
const [openDialogForm, setOpenDialogForm] = useState(false)
const [typeDialog, setTypeDialog] = useState("add")
const [dataEdit, setDataEdit] = useState([])
const { t } = useTranslation();
useEffect(() => {
if (idTypeProject && idTypeProject > 0) {
getDataInitial();
@ -149,12 +150,12 @@ const DialogInitialGantt = ({ openDialog, closeDialog, toggleDialog, idTypeProje
className: "nowrap",
render: (text, record) =>
<>
<Tooltip title="Delete Activity">
<Button size="small" size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>{" "}<Tooltip title="Add Activity">
<Button size="small" size={"sm"} color='primary' onClick={() => handleAddWithParent(text.id)}><i className="fa fa-plus"></i></Button>
</Tooltip>{" "}<Tooltip title="Edit Activity">
<Button size="small" size={"sm"} color='warning' onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
<Tooltip title={t("delete")}>
<Button size="small" color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>{" "}<Tooltip title={t("add")}>
<Button size="small" color='primary' onClick={() => handleAddWithParent(text.id)}><i className="fa fa-plus"></i></Button>
</Tooltip>{" "}<Tooltip title={t("edit")}>
<Button size="small" color='warning' onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
</Tooltip>
</>
,
@ -181,12 +182,12 @@ const DialogInitialGantt = ({ openDialog, closeDialog, toggleDialog, idTypeProje
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={cancelDelete}
focusCancelBtn
>
Delete this data
{t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialogForm}
@ -200,13 +201,16 @@ const DialogInitialGantt = ({ openDialog, closeDialog, toggleDialog, idTypeProje
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
{/* <ModalHeader className="capitalize" toggle={closeDialog}>Initial Gantt</ModalHeader> */}
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}>
<div>Template Gantt</div> <Button onClick={handleAdd} size='sm' color="primary"><i className='fa fa-plus'></i></Button>
<div>Template Gantt</div>
<Tooltip title={t("add")}>
<Button onClick={handleAdd} size='sm' color="primary"><i className='fa fa-plus'></i></Button>
</Tooltip>
</ModalHeader>
<ModalBody>
{renderTable}
</ModalBody>
<ModalFooter>
<Button className="capitalize" color="secondary" onClick={closeDialog}>Close</Button>
<Button className="capitalize" color="secondary" onClick={closeDialog}>{t('close')}</Button>
</ModalFooter>
</Modal>
</>

33
src/views/SimproV2/ProjectType/index.js

@ -10,7 +10,8 @@ import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
import { handleChangeLng } from '../../../utils/LangUtils';
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
@ -54,7 +55,7 @@ const ProjectType = ({ params }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const { t } = useTranslation();
useEffect(() => {
getDataProjectType()
}, [currentPage, rowsPerPage, search])
@ -286,7 +287,7 @@ const ProjectType = ({ params }) => {
if (dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">Tidak ada data project type</td>
<td align="center" colSpan="3">{t('noData')}</td>
</tr>
)
}
@ -295,15 +296,15 @@ const ProjectType = ({ params }) => {
const renderTable = useMemo(() => {
const columns = [
{
title: 'Action',
title: t('action'),
dataIndex: '',
key: 'x',
className: 'nowrap',
render: (text, record) => <>
<Tooltip title="Delete">
<Tooltip title={t('delete')}>
<i className="fa fa-trash" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => handleDelete(text.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<Tooltip title={t('edit')}>
<i className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(text)}></i>
</Tooltip>{" "}
<Tooltip title="Template Gantt">
@ -311,8 +312,8 @@ const ProjectType = ({ params }) => {
</Tooltip>
</>,
},
{ title: 'Nama Role', dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: 'Description', dataIndex: 'description', key: 'description' },
{ title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" },
{ title: t('description'), dataIndex: 'description', key: 'description' },
];
return (
<Table
@ -334,12 +335,12 @@ const ProjectType = ({ params }) => {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
{t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialog}
@ -361,13 +362,17 @@ const ProjectType = ({ params }) => {
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search project type...`} />
<button onClick={() => handleChangeLng("en")}>EN</button>
<button onClick={() => handleChangeLng("id")}>ID</button>
</Col>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchType')} />
</Col>
<Col>
<Tooltip title="Add Material Resource">
<Tooltip title={t('projectType')}>
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
@ -387,7 +392,7 @@ const ProjectType = ({ params }) => {
/>
</CardBody>
</Card>
</div>
</div >
)
}

13
src/views/SimproV2/Satuan/DialogForm.js

@ -4,13 +4,14 @@ import {
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => {
const [id, setId] = useState(0)
const [name, setName] = useState('')
const [description, setDescription] = useState('')
const { t } = useTranslation()
useEffect(() => {
@ -60,14 +61,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Name</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={`Input name...`} />
<Label className="capitalize">{t('name')}</Label>
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Description</Label>
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={`Description ...`} />
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={t('inputDescription')} />
</FormGroup>
</Col>
</Row>
@ -79,13 +80,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
return (
<>
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Resource</ModalHeader>
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} {'uom'}</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button>
</ModalFooter>
</Modal>
</>

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

@ -7,6 +7,7 @@ import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const config = {
@ -17,11 +18,6 @@ const config = {
}
};
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
]
const Satuan = ({ params }) => {
const token = localStorage.getItem("token")
const HEADER = {
@ -45,7 +41,7 @@ const Satuan = ({ params }) => {
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const { t } = useTranslation()
useEffect(() => {
getDataSatuan()
}, [currentPage, rowsPerPage, search])
@ -57,6 +53,10 @@ const Satuan = ({ params }) => {
}
}, [dataExport])
const column = [
{ name: t('name') },
{ name: t('description') },
]
const getDataSatuan = async () => {
let start = 0;
@ -243,7 +243,7 @@ const Satuan = ({ params }) => {
if (dataTable.length === 0) {
return (
<tr>
<td align="center" colSpan="3">Tidak ada data project type</td>
<td align="center" colSpan="3">{t('noData')}</td>
</tr>
)
}
@ -258,12 +258,12 @@ const Satuan = ({ params }) => {
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
{t('deleteMsg')}
</SweetAlert>
<DialogForm
openDialog={openDialog}
@ -279,13 +279,13 @@ const Satuan = ({ params }) => {
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Pencarian`} />
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={t('searchUom')} />
</Col>
<Col>
<Tooltip title="Add UOM">
<Tooltip title={t('uomAdd')}>
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
@ -295,7 +295,7 @@ const Satuan = ({ params }) => {
<Table responsive striped hover>
<thead>
<tr>
<th>Aksi</th>
<th>{t('action')}</th>
{column.map((i, index) => {
return (
<th key={index} scope="row">{i.name}</th>
@ -310,11 +310,11 @@ const Satuan = ({ params }) => {
<tr key={n.id}>
<td className='nowrap'>
<Tooltip title="Hapus">
<Tooltip title={t('delete')}>
<i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<Tooltip title={t('ubah')}>
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip>
</td>

Loading…
Cancel
Save